commit 085abcb349be2db4313f6ebd29f0c165af13990b Author: lijh Date: Tue Mar 10 11:37:55 2026 +0800 first commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..5b9ff50 --- /dev/null +++ b/.classpath @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..4dc2c0e --- /dev/null +++ b/.project @@ -0,0 +1,39 @@ + + + com.connor.erpintegration + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + + + 1668058720322 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..0fee6a9 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -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 diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000..d0e5005 --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,52 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Erpintegration +Bundle-SymbolicName: com.connor.erpintegration;singleton:=true +Bundle-Version: 1.0.0 +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime;bundle-version="3.15.100", + org.apache.poi.39;bundle-version="3.9.0", + com.teamcenter.rac.aifrcp;bundle-version="13000.1.0", + com.teamcenter.rac.common;bundle-version="13000.1.0", + com.teamcenter.rac.kernel;bundle-version="13000.1.0", + com.teamcenter.rac.tcapps;bundle-version="13000.1.0", + com.teamcenter.rac.util;bundle-version="13000.1.0", + cn.com.origin.autocode;bundle-version="1.0.0", + cn.com.origin.autocodemanager;bundle-version="1.0.0", + com.teamcenter.rac.workflow;bundle-version="13000.1.0", + com.teamcenter.rac.workflow.processdesigner;bundle-version="13000.1.0", + com.teamcenter.rac.workflow.processviewer;bundle-version="13000.1.0", + cn.net.connor.std.aifrcp;bundle-version="13000.1.0", + com.connor.nhjs.gy;bundle-version="1.0.0", + cn.net.connor.std.word;bundle-version="13000.1.0", + cn.net.connor.std.gdtex;bundle-version="12000.3.0" +Automatic-Module-Name: com.origin.erpintegration +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ClassPath: ., + lib/commons-beanutils-1.9.4.jar, + lib/commons-logging-1.2.jar, + lib/ezmorph-1.0.6.jar, + lib/httpclient-4.2.1.jar, + lib/httpcore-4.2.1.jar, + lib/json-lib-2.4-jdk15.jar, + lib/commons-collections-3.2.2.jar, + lib/commons-lang-2.6.jar, + lib/jdom.jar, + lib/ojdbc8.jar, + lib/gson-2.9.0.jar, + lib/jacob.jar +Export-Package: com.connor.erp.BomAddTransferToERP, + com.connor.erp.BomChgTransferToERP, + com.connor.erp.BomImport, + com.connor.erp.ItemAddTransferSendToERP, + com.connor.erp.ItemImport, + com.connor.erp.ProcessImport, + com.connor.erp.ProcessImport.ProcessAddTransferToERP, + com.connor.erp.ProcessImport.ProcessChgTransferToERP, + com.connor.erp.materialquery, + com.connor.erp.materialquery.ViewStockOfERP, + com.connor.erp.materialquery.ViewWorkInProcessOfERP, + com.connor.erp.processresource.EquipmentAcquiredFromERP, + com.connor.erp.searchImpResult, + com.connor.erp.toolkit, + com.connor.erpintegration.entity diff --git a/bin/cn/net/connor/nhjs/processcard/Activator.class b/bin/cn/net/connor/nhjs/processcard/Activator.class new file mode 100644 index 0000000..6e15201 Binary files /dev/null and b/bin/cn/net/connor/nhjs/processcard/Activator.class differ diff --git a/bin/cn/net/connor/nhjs/processcard/ExportCommand.class b/bin/cn/net/connor/nhjs/processcard/ExportCommand.class new file mode 100644 index 0000000..6caaf48 Binary files /dev/null and b/bin/cn/net/connor/nhjs/processcard/ExportCommand.class differ diff --git a/bin/cn/net/connor/nhjs/processcard/ExportOperation$FilterInfo.class b/bin/cn/net/connor/nhjs/processcard/ExportOperation$FilterInfo.class new file mode 100644 index 0000000..82e25d5 Binary files /dev/null and b/bin/cn/net/connor/nhjs/processcard/ExportOperation$FilterInfo.class differ diff --git a/bin/cn/net/connor/nhjs/processcard/ExportOperation.class b/bin/cn/net/connor/nhjs/processcard/ExportOperation.class new file mode 100644 index 0000000..976b492 Binary files /dev/null and b/bin/cn/net/connor/nhjs/processcard/ExportOperation.class differ diff --git a/bin/cn/net/connor/nhjs/processcard/processcard.properties b/bin/cn/net/connor/nhjs/processcard/processcard.properties new file mode 100644 index 0000000..0ea9591 --- /dev/null +++ b/bin/cn/net/connor/nhjs/processcard/processcard.properties @@ -0,0 +1,7 @@ +op.Name=\u751F\u6210\u5DE5\u827A\u5361\u7247 +novalidconfig.Error=\u6CA1\u6709\u627E\u5230\u6709\u6548\u7684\u914D\u7F6E\uFF0C\u8BF7\u68C0\u67E5\u3002 +exporting=\u6B63\u5728\u5BFC\u51FA +unsupportedtargets.Error1=\u4EE5\u4E0B\u5BF9\u8C61\u4E0D\u652F\u6301\u5BFC\u51FA\uFF1A\n%s +init.Name=\u51C6\u5907\u5BFC\u51FA... +notowner.Error=\u975E\u5F53\u524D\u5BF9\u8C61\u7684\u6240\u6709\u8005\uFF0C\u4E0D\u80FD\u6267\u884C\u5361\u7247\u751F\u6210\u64CD\u4F5C +novalidtarget.Error=\u672A\u627E\u5230\u53EF\u5BFC\u51FA\u7684\u5BF9\u8C61\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u3002 diff --git a/bin/com/connor/bomCompare/CXGYFrame$1.class b/bin/com/connor/bomCompare/CXGYFrame$1.class new file mode 100644 index 0000000..9699d31 Binary files /dev/null and b/bin/com/connor/bomCompare/CXGYFrame$1.class differ diff --git a/bin/com/connor/bomCompare/CXGYFrame$2.class b/bin/com/connor/bomCompare/CXGYFrame$2.class new file mode 100644 index 0000000..a8428bb Binary files /dev/null and b/bin/com/connor/bomCompare/CXGYFrame$2.class differ diff --git a/bin/com/connor/bomCompare/CXGYFrame$3.class b/bin/com/connor/bomCompare/CXGYFrame$3.class new file mode 100644 index 0000000..2a1c911 Binary files /dev/null and b/bin/com/connor/bomCompare/CXGYFrame$3.class differ diff --git a/bin/com/connor/bomCompare/CXGYFrame$4.class b/bin/com/connor/bomCompare/CXGYFrame$4.class new file mode 100644 index 0000000..582676c Binary files /dev/null and b/bin/com/connor/bomCompare/CXGYFrame$4.class differ diff --git a/bin/com/connor/bomCompare/CXGYFrame.class b/bin/com/connor/bomCompare/CXGYFrame.class new file mode 100644 index 0000000..71dc01d Binary files /dev/null and b/bin/com/connor/bomCompare/CXGYFrame.class differ diff --git a/bin/com/connor/bomCompare/CXGYWLDialog.class b/bin/com/connor/bomCompare/CXGYWLDialog.class new file mode 100644 index 0000000..74bac3f Binary files /dev/null and b/bin/com/connor/bomCompare/CXGYWLDialog.class differ diff --git a/bin/com/connor/bomCompare/DDGYDialog.class b/bin/com/connor/bomCompare/DDGYDialog.class new file mode 100644 index 0000000..e64e606 Binary files /dev/null and b/bin/com/connor/bomCompare/DDGYDialog.class differ diff --git a/bin/com/connor/bomCompare/DDGYFrame$1.class b/bin/com/connor/bomCompare/DDGYFrame$1.class new file mode 100644 index 0000000..dbbac2e Binary files /dev/null and b/bin/com/connor/bomCompare/DDGYFrame$1.class differ diff --git a/bin/com/connor/bomCompare/DDGYFrame$2.class b/bin/com/connor/bomCompare/DDGYFrame$2.class new file mode 100644 index 0000000..dee46b6 Binary files /dev/null and b/bin/com/connor/bomCompare/DDGYFrame$2.class differ diff --git a/bin/com/connor/bomCompare/DDGYFrame$3.class b/bin/com/connor/bomCompare/DDGYFrame$3.class new file mode 100644 index 0000000..0fed6c1 Binary files /dev/null and b/bin/com/connor/bomCompare/DDGYFrame$3.class differ diff --git a/bin/com/connor/bomCompare/DDGYFrame$4.class b/bin/com/connor/bomCompare/DDGYFrame$4.class new file mode 100644 index 0000000..6c8ae55 Binary files /dev/null and b/bin/com/connor/bomCompare/DDGYFrame$4.class differ diff --git a/bin/com/connor/bomCompare/DDGYFrame.class b/bin/com/connor/bomCompare/DDGYFrame.class new file mode 100644 index 0000000..c33223a Binary files /dev/null and b/bin/com/connor/bomCompare/DDGYFrame.class differ diff --git a/bin/com/connor/bomCompare/SJDBHandler.class b/bin/com/connor/bomCompare/SJDBHandler.class new file mode 100644 index 0000000..9c51d87 Binary files /dev/null and b/bin/com/connor/bomCompare/SJDBHandler.class differ diff --git a/bin/com/connor/bomCompare/WLFrame$1.class b/bin/com/connor/bomCompare/WLFrame$1.class new file mode 100644 index 0000000..4382dbb Binary files /dev/null and b/bin/com/connor/bomCompare/WLFrame$1.class differ diff --git a/bin/com/connor/bomCompare/WLFrame$2.class b/bin/com/connor/bomCompare/WLFrame$2.class new file mode 100644 index 0000000..958e54e Binary files /dev/null and b/bin/com/connor/bomCompare/WLFrame$2.class differ diff --git a/bin/com/connor/bomCompare/WLFrame$3.class b/bin/com/connor/bomCompare/WLFrame$3.class new file mode 100644 index 0000000..53d8d86 Binary files /dev/null and b/bin/com/connor/bomCompare/WLFrame$3.class differ diff --git a/bin/com/connor/bomCompare/WLFrame$4.class b/bin/com/connor/bomCompare/WLFrame$4.class new file mode 100644 index 0000000..b11ec95 Binary files /dev/null and b/bin/com/connor/bomCompare/WLFrame$4.class differ diff --git a/bin/com/connor/bomCompare/WLFrame.class b/bin/com/connor/bomCompare/WLFrame.class new file mode 100644 index 0000000..8e7a73a Binary files /dev/null and b/bin/com/connor/bomCompare/WLFrame.class differ diff --git a/bin/com/connor/erp/BomAddTransferToERP/AssemblyResult.class b/bin/com/connor/erp/BomAddTransferToERP/AssemblyResult.class new file mode 100644 index 0000000..09c54e5 Binary files /dev/null and b/bin/com/connor/erp/BomAddTransferToERP/AssemblyResult.class differ diff --git a/bin/com/connor/erp/BomAddTransferToERP/BomAdd.class b/bin/com/connor/erp/BomAddTransferToERP/BomAdd.class new file mode 100644 index 0000000..13d9a9b Binary files /dev/null and b/bin/com/connor/erp/BomAddTransferToERP/BomAdd.class differ diff --git a/bin/com/connor/erp/BomAddTransferToERP/BomAddEntry.class b/bin/com/connor/erp/BomAddTransferToERP/BomAddEntry.class new file mode 100644 index 0000000..75fd411 Binary files /dev/null and b/bin/com/connor/erp/BomAddTransferToERP/BomAddEntry.class differ diff --git a/bin/com/connor/erp/BomAddTransferToERP/BomAddImportXMLReader.class b/bin/com/connor/erp/BomAddTransferToERP/BomAddImportXMLReader.class new file mode 100644 index 0000000..d50deaa Binary files /dev/null and b/bin/com/connor/erp/BomAddTransferToERP/BomAddImportXMLReader.class differ diff --git a/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferCommand.class b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferCommand.class new file mode 100644 index 0000000..2e99688 Binary files /dev/null and b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferCommand.class differ diff --git a/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferDialog$1.class b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferDialog$1.class new file mode 100644 index 0000000..e004080 Binary files /dev/null and b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferDialog$1.class differ diff --git a/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferDialog$2.class b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferDialog$2.class new file mode 100644 index 0000000..5ee9769 Binary files /dev/null and b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferDialog$2.class differ diff --git a/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferDialog$3.class b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferDialog$3.class new file mode 100644 index 0000000..90fe402 Binary files /dev/null and b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferDialog$3.class differ diff --git a/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferDialog$4.class b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferDialog$4.class new file mode 100644 index 0000000..d0fe874 Binary files /dev/null and b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferDialog$4.class differ diff --git a/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferDialog.class b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferDialog.class new file mode 100644 index 0000000..b720189 Binary files /dev/null and b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferDialog.class differ diff --git a/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferHandler.class b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferHandler.class new file mode 100644 index 0000000..a03e9b0 Binary files /dev/null and b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferHandler.class differ diff --git a/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferOperation$1.class b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferOperation$1.class new file mode 100644 index 0000000..72e34da Binary files /dev/null and b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferOperation$1.class differ diff --git a/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferOperation$Daemon.class b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferOperation$Daemon.class new file mode 100644 index 0000000..f72ef4b Binary files /dev/null and b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferOperation$Daemon.class differ diff --git a/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferOperation$WaitingDialog.class b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferOperation$WaitingDialog.class new file mode 100644 index 0000000..acf79f0 Binary files /dev/null and b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferOperation$WaitingDialog.class differ diff --git a/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferOperation.class b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferOperation.class new file mode 100644 index 0000000..ca9a1e4 Binary files /dev/null and b/bin/com/connor/erp/BomAddTransferToERP/BomAddTransferOperation.class differ diff --git a/bin/com/connor/erp/BomAddTransferToERP/ItemResult.class b/bin/com/connor/erp/BomAddTransferToERP/ItemResult.class new file mode 100644 index 0000000..951ff9d Binary files /dev/null and b/bin/com/connor/erp/BomAddTransferToERP/ItemResult.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/BomChgImportXMLReader.class b/bin/com/connor/erp/BomChgTransferToERP/BomChgImportXMLReader.class new file mode 100644 index 0000000..72c4f5c Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/BomChgImportXMLReader.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferCommand.class b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferCommand.class new file mode 100644 index 0000000..1825116 Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferCommand.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$1.class b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$1.class new file mode 100644 index 0000000..6757b36 Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$1.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$2.class b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$2.class new file mode 100644 index 0000000..be8458e Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$2.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$3.class b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$3.class new file mode 100644 index 0000000..bbabfaa Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$3.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$4.class b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$4.class new file mode 100644 index 0000000..0d97a1a Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$4.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$5.class b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$5.class new file mode 100644 index 0000000..0a7cd09 Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$5.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$6.class b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$6.class new file mode 100644 index 0000000..5906bd8 Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$6.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$7.class b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$7.class new file mode 100644 index 0000000..667d13b Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$7.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$8.class b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$8.class new file mode 100644 index 0000000..4a33408 Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$8.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$MyDefaultTableCellRenderer.class b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$MyDefaultTableCellRenderer.class new file mode 100644 index 0000000..4f94a13 Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog$MyDefaultTableCellRenderer.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog.class b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog.class new file mode 100644 index 0000000..69fc092 Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferHandler.class b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferHandler.class new file mode 100644 index 0000000..e6ca6a6 Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferHandler.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferOperation$1.class b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferOperation$1.class new file mode 100644 index 0000000..8b01148 Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferOperation$1.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferOperation$Daemon.class b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferOperation$Daemon.class new file mode 100644 index 0000000..b85087b Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferOperation$Daemon.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferOperation$WaitingDialog.class b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferOperation$WaitingDialog.class new file mode 100644 index 0000000..956fedf Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferOperation$WaitingDialog.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferOperation.class b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferOperation.class new file mode 100644 index 0000000..9d7bb6a Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/BomChgTransferOperation.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/CompareLine.class b/bin/com/connor/erp/BomChgTransferToERP/CompareLine.class new file mode 100644 index 0000000..9d57e6d Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/CompareLine.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/CompareResult.class b/bin/com/connor/erp/BomChgTransferToERP/CompareResult.class new file mode 100644 index 0000000..e4b33b8 Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/CompareResult.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/DBUtils$1.class b/bin/com/connor/erp/BomChgTransferToERP/DBUtils$1.class new file mode 100644 index 0000000..7082ef2 Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/DBUtils$1.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/DBUtils.class b/bin/com/connor/erp/BomChgTransferToERP/DBUtils.class new file mode 100644 index 0000000..13aed33 Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/DBUtils.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/KUtil.class b/bin/com/connor/erp/BomChgTransferToERP/KUtil.class new file mode 100644 index 0000000..1b247d0 Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/KUtil.class differ diff --git a/bin/com/connor/erp/BomChgTransferToERP/UserList.class b/bin/com/connor/erp/BomChgTransferToERP/UserList.class new file mode 100644 index 0000000..d2cac49 Binary files /dev/null and b/bin/com/connor/erp/BomChgTransferToERP/UserList.class differ diff --git a/bin/com/connor/erp/BomImport/BomTransferCommand.class b/bin/com/connor/erp/BomImport/BomTransferCommand.class new file mode 100644 index 0000000..16f6306 Binary files /dev/null and b/bin/com/connor/erp/BomImport/BomTransferCommand.class differ diff --git a/bin/com/connor/erp/BomImport/BomTransferDialog.class b/bin/com/connor/erp/BomImport/BomTransferDialog.class new file mode 100644 index 0000000..de167b1 Binary files /dev/null and b/bin/com/connor/erp/BomImport/BomTransferDialog.class differ diff --git a/bin/com/connor/erp/BomImport/TransferBomXMLWriter.class b/bin/com/connor/erp/BomImport/TransferBomXMLWriter.class new file mode 100644 index 0000000..de80deb Binary files /dev/null and b/bin/com/connor/erp/BomImport/TransferBomXMLWriter.class differ diff --git a/bin/com/connor/erp/BomImport/ValidateBomXMLWriter.class b/bin/com/connor/erp/BomImport/ValidateBomXMLWriter.class new file mode 100644 index 0000000..7e337c3 Binary files /dev/null and b/bin/com/connor/erp/BomImport/ValidateBomXMLWriter.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPCommand.class b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPCommand.class new file mode 100644 index 0000000..129140a Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPCommand.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$1.class b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$1.class new file mode 100644 index 0000000..aaab5de Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$1.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$2.class b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$2.class new file mode 100644 index 0000000..39f06a8 Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$2.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$3.class b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$3.class new file mode 100644 index 0000000..fd2c166 Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$3.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$4.class b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$4.class new file mode 100644 index 0000000..5144ba1 Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$4.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$5.class b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$5.class new file mode 100644 index 0000000..4ecd8c1 Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$5.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$6.class b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$6.class new file mode 100644 index 0000000..cdcdcc8 Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$6.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$7.class b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$7.class new file mode 100644 index 0000000..d4ccf9e Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$7.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$CheckHeaderCellRenderer$1.class b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$CheckHeaderCellRenderer$1.class new file mode 100644 index 0000000..3c8ca35 Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$CheckHeaderCellRenderer$1.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$CheckHeaderCellRenderer.class b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$CheckHeaderCellRenderer.class new file mode 100644 index 0000000..78fdfdf Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$CheckHeaderCellRenderer.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$CheckTableModle$Row.class b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$CheckTableModle$Row.class new file mode 100644 index 0000000..3a1cbe7 Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$CheckTableModle$Row.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$CheckTableModle.class b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$CheckTableModle.class new file mode 100644 index 0000000..bb388d9 Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$CheckTableModle.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$NHLItemERPTypeDefine.class b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$NHLItemERPTypeDefine.class new file mode 100644 index 0000000..d64ee87 Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$NHLItemERPTypeDefine.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$NHLItemERPTypePreference.class b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$NHLItemERPTypePreference.class new file mode 100644 index 0000000..279de78 Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog$NHLItemERPTypePreference.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog.class b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog.class new file mode 100644 index 0000000..4683768 Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPHandler.class b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPHandler.class new file mode 100644 index 0000000..bc094d0 Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPHandler.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPOperation$1.class b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPOperation$1.class new file mode 100644 index 0000000..042d38a Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPOperation$1.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPOperation$Daemon.class b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPOperation$Daemon.class new file mode 100644 index 0000000..e2ce4d6 Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPOperation$Daemon.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPOperation$WaitingDialog.class b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPOperation$WaitingDialog.class new file mode 100644 index 0000000..fe3fbba Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPOperation$WaitingDialog.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPOperation.class b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPOperation.class new file mode 100644 index 0000000..33d5904 Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/SendToERPOperation.class differ diff --git a/bin/com/connor/erp/ItemAddTransferSendToERP/ViewResultOfItemTransferHandler.class b/bin/com/connor/erp/ItemAddTransferSendToERP/ViewResultOfItemTransferHandler.class new file mode 100644 index 0000000..2a93377 Binary files /dev/null and b/bin/com/connor/erp/ItemAddTransferSendToERP/ViewResultOfItemTransferHandler.class differ diff --git a/bin/com/connor/erp/ItemImport/ItemImportXMLReader.class b/bin/com/connor/erp/ItemImport/ItemImportXMLReader.class new file mode 100644 index 0000000..c6385f0 Binary files /dev/null and b/bin/com/connor/erp/ItemImport/ItemImportXMLReader.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPCommand.class b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPCommand.class new file mode 100644 index 0000000..0966083 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPCommand.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog$1.class b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog$1.class new file mode 100644 index 0000000..128e29b Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog$1.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog$2.class b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog$2.class new file mode 100644 index 0000000..326f34b Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog$2.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog$3.class b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog$3.class new file mode 100644 index 0000000..f72ad47 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog$3.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog$4.class b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog$4.class new file mode 100644 index 0000000..6826583 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog$4.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog$5.class b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog$5.class new file mode 100644 index 0000000..64b4beb Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog$5.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog.class b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog.class new file mode 100644 index 0000000..6e33096 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPHandler.class b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPHandler.class new file mode 100644 index 0000000..9f7fb09 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPHandler.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPOperation$1.class b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPOperation$1.class new file mode 100644 index 0000000..4d12829 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPOperation$1.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPOperation$Daemon.class b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPOperation$Daemon.class new file mode 100644 index 0000000..783e5cd Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPOperation$Daemon.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPOperation$WaitingDialog.class b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPOperation$WaitingDialog.class new file mode 100644 index 0000000..f614ad7 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPOperation$WaitingDialog.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPOperation.class b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPOperation.class new file mode 100644 index 0000000..9937dfb Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPOperation.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RootAddEnty.class b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RootAddEnty.class new file mode 100644 index 0000000..71b9d6f Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RootAddEnty.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RootCheckResult.class b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RootCheckResult.class new file mode 100644 index 0000000..7e1e21d Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RootCheckResult.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RootEntry.class b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RootEntry.class new file mode 100644 index 0000000..d54a7b7 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RootEntry.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RouteLineCheck.class b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RouteLineCheck.class new file mode 100644 index 0000000..4b37545 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RouteLineCheck.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferOperation$1.class b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferOperation$1.class new file mode 100644 index 0000000..f297036 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferOperation$1.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferOperation$Daemon.class b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferOperation$Daemon.class new file mode 100644 index 0000000..a7ba5ef Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferOperation$Daemon.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferOperation$WaitingDialog.class b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferOperation$WaitingDialog.class new file mode 100644 index 0000000..db5eee6 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferOperation$WaitingDialog.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferOperation.class b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferOperation.class new file mode 100644 index 0000000..cff9039 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferOperation.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPCommand.class b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPCommand.class new file mode 100644 index 0000000..ff2b2b4 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPCommand.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$1.class b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$1.class new file mode 100644 index 0000000..1977296 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$1.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$2.class b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$2.class new file mode 100644 index 0000000..227fe00 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$2.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$3.class b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$3.class new file mode 100644 index 0000000..9644094 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$3.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$4.class b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$4.class new file mode 100644 index 0000000..86ba0c6 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$4.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$5.class b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$5.class new file mode 100644 index 0000000..84bae04 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$5.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$6.class b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$6.class new file mode 100644 index 0000000..909af11 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$6.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$MyDefaultTableCellRenderer.class b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$MyDefaultTableCellRenderer.class new file mode 100644 index 0000000..6473a48 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog$MyDefaultTableCellRenderer.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog.class b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog.class new file mode 100644 index 0000000..40cc20b Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPHandler.class b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPHandler.class new file mode 100644 index 0000000..e12c31e Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPHandler.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/projectobject_16.png b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/projectobject_16.png new file mode 100644 index 0000000..e0f6c32 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessChgTransferToERP/projectobject_16.png differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessImportApi.class b/bin/com/connor/erp/ProcessImport/ProcessImportApi.class new file mode 100644 index 0000000..1b66f5d Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessImportApi.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessImportHandler.class b/bin/com/connor/erp/ProcessImport/ProcessImportHandler.class new file mode 100644 index 0000000..243ef78 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessImportHandler.class differ diff --git a/bin/com/connor/erp/ProcessImport/ProcessImportReadXMLStr.class b/bin/com/connor/erp/ProcessImport/ProcessImportReadXMLStr.class new file mode 100644 index 0000000..5dcdadf Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ProcessImportReadXMLStr.class differ diff --git a/bin/com/connor/erp/ProcessImport/TransferRouteXMLWriter.class b/bin/com/connor/erp/ProcessImport/TransferRouteXMLWriter.class new file mode 100644 index 0000000..c0b1e9a Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/TransferRouteXMLWriter.class differ diff --git a/bin/com/connor/erp/ProcessImport/ValidateFailDialog$1.class b/bin/com/connor/erp/ProcessImport/ValidateFailDialog$1.class new file mode 100644 index 0000000..099f612 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ValidateFailDialog$1.class differ diff --git a/bin/com/connor/erp/ProcessImport/ValidateFailDialog$2.class b/bin/com/connor/erp/ProcessImport/ValidateFailDialog$2.class new file mode 100644 index 0000000..e4f406d Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ValidateFailDialog$2.class differ diff --git a/bin/com/connor/erp/ProcessImport/ValidateFailDialog$3.class b/bin/com/connor/erp/ProcessImport/ValidateFailDialog$3.class new file mode 100644 index 0000000..ff8c78c Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ValidateFailDialog$3.class differ diff --git a/bin/com/connor/erp/ProcessImport/ValidateFailDialog$4.class b/bin/com/connor/erp/ProcessImport/ValidateFailDialog$4.class new file mode 100644 index 0000000..b87a744 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ValidateFailDialog$4.class differ diff --git a/bin/com/connor/erp/ProcessImport/ValidateFailDialog$ExampleFileFilter.class b/bin/com/connor/erp/ProcessImport/ValidateFailDialog$ExampleFileFilter.class new file mode 100644 index 0000000..8c82444 Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ValidateFailDialog$ExampleFileFilter.class differ diff --git a/bin/com/connor/erp/ProcessImport/ValidateFailDialog.class b/bin/com/connor/erp/ProcessImport/ValidateFailDialog.class new file mode 100644 index 0000000..26f057b Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ValidateFailDialog.class differ diff --git a/bin/com/connor/erp/ProcessImport/ValidateRouteXMLWriter.class b/bin/com/connor/erp/ProcessImport/ValidateRouteXMLWriter.class new file mode 100644 index 0000000..adda90a Binary files /dev/null and b/bin/com/connor/erp/ProcessImport/ValidateRouteXMLWriter.class differ diff --git a/bin/com/connor/erp/materialquery/InProcessReadXMLStr.class b/bin/com/connor/erp/materialquery/InProcessReadXMLStr.class new file mode 100644 index 0000000..1e96ab7 Binary files /dev/null and b/bin/com/connor/erp/materialquery/InProcessReadXMLStr.class differ diff --git a/bin/com/connor/erp/materialquery/Quantity.class b/bin/com/connor/erp/materialquery/Quantity.class new file mode 100644 index 0000000..ccf40dd Binary files /dev/null and b/bin/com/connor/erp/materialquery/Quantity.class differ diff --git a/bin/com/connor/erp/materialquery/StockReadXMLStr.class b/bin/com/connor/erp/materialquery/StockReadXMLStr.class new file mode 100644 index 0000000..2c95c3b Binary files /dev/null and b/bin/com/connor/erp/materialquery/StockReadXMLStr.class differ diff --git a/bin/com/connor/erp/materialquery/ViewStockOfERP/CMap.class b/bin/com/connor/erp/materialquery/ViewStockOfERP/CMap.class new file mode 100644 index 0000000..a45c421 Binary files /dev/null and b/bin/com/connor/erp/materialquery/ViewStockOfERP/CMap.class differ diff --git a/bin/com/connor/erp/materialquery/ViewStockOfERP/CMap1.class b/bin/com/connor/erp/materialquery/ViewStockOfERP/CMap1.class new file mode 100644 index 0000000..9d94892 Binary files /dev/null and b/bin/com/connor/erp/materialquery/ViewStockOfERP/CMap1.class differ diff --git a/bin/com/connor/erp/materialquery/ViewStockOfERP/CMap2.class b/bin/com/connor/erp/materialquery/ViewStockOfERP/CMap2.class new file mode 100644 index 0000000..eeca052 Binary files /dev/null and b/bin/com/connor/erp/materialquery/ViewStockOfERP/CMap2.class differ diff --git a/bin/com/connor/erp/materialquery/ViewStockOfERP/CTUI.class b/bin/com/connor/erp/materialquery/ViewStockOfERP/CTUI.class new file mode 100644 index 0000000..45f51ee Binary files /dev/null and b/bin/com/connor/erp/materialquery/ViewStockOfERP/CTUI.class differ diff --git a/bin/com/connor/erp/materialquery/ViewStockOfERP/CTable.class b/bin/com/connor/erp/materialquery/ViewStockOfERP/CTable.class new file mode 100644 index 0000000..848463f Binary files /dev/null and b/bin/com/connor/erp/materialquery/ViewStockOfERP/CTable.class differ diff --git a/bin/com/connor/erp/materialquery/ViewStockOfERP/Test.class b/bin/com/connor/erp/materialquery/ViewStockOfERP/Test.class new file mode 100644 index 0000000..cc85895 Binary files /dev/null and b/bin/com/connor/erp/materialquery/ViewStockOfERP/Test.class differ diff --git a/bin/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPCommand.class b/bin/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPCommand.class new file mode 100644 index 0000000..f09fda0 Binary files /dev/null and b/bin/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPCommand.class differ diff --git a/bin/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPDialog$1.class b/bin/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPDialog$1.class new file mode 100644 index 0000000..7bfca44 Binary files /dev/null and b/bin/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPDialog$1.class differ diff --git a/bin/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPDialog$2.class b/bin/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPDialog$2.class new file mode 100644 index 0000000..77f5719 Binary files /dev/null and b/bin/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPDialog$2.class differ diff --git a/bin/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPDialog.class b/bin/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPDialog.class new file mode 100644 index 0000000..571ffe2 Binary files /dev/null and b/bin/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPDialog.class differ diff --git a/bin/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPHandler.class b/bin/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPHandler.class new file mode 100644 index 0000000..80b7f70 Binary files /dev/null and b/bin/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPHandler.class differ diff --git a/bin/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPCommand.class b/bin/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPCommand.class new file mode 100644 index 0000000..5e1fe38 Binary files /dev/null and b/bin/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPCommand.class differ diff --git a/bin/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPDialog$1.class b/bin/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPDialog$1.class new file mode 100644 index 0000000..9523b87 Binary files /dev/null and b/bin/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPDialog$1.class differ diff --git a/bin/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPDialog$2.class b/bin/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPDialog$2.class new file mode 100644 index 0000000..744b049 Binary files /dev/null and b/bin/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPDialog$2.class differ diff --git a/bin/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPDialog.class b/bin/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPDialog.class new file mode 100644 index 0000000..9768b8d Binary files /dev/null and b/bin/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPDialog.class differ diff --git a/bin/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPHandler.class b/bin/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPHandler.class new file mode 100644 index 0000000..211235b Binary files /dev/null and b/bin/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPHandler.class differ diff --git a/bin/com/connor/erp/materialquery/WIPInfo.class b/bin/com/connor/erp/materialquery/WIPInfo.class new file mode 100644 index 0000000..0f5a604 Binary files /dev/null and b/bin/com/connor/erp/materialquery/WIPInfo.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/CreateClassificationPropertyPanel$1.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/CreateClassificationPropertyPanel$1.class new file mode 100644 index 0000000..1dd85f7 Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/CreateClassificationPropertyPanel$1.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/CreateClassificationPropertyPanel$2.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/CreateClassificationPropertyPanel$2.class new file mode 100644 index 0000000..51d0ae8 Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/CreateClassificationPropertyPanel$2.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/CreateClassificationPropertyPanel.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/CreateClassificationPropertyPanel.class new file mode 100644 index 0000000..adb7ee4 Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/CreateClassificationPropertyPanel.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPCommand.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPCommand.class new file mode 100644 index 0000000..2c0828e Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPCommand.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPDialog$1.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPDialog$1.class new file mode 100644 index 0000000..8730866 Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPDialog$1.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPDialog$CheckHeaderCellRenderer$1.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPDialog$CheckHeaderCellRenderer$1.class new file mode 100644 index 0000000..50fc48a Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPDialog$CheckHeaderCellRenderer$1.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPDialog$CheckHeaderCellRenderer.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPDialog$CheckHeaderCellRenderer.class new file mode 100644 index 0000000..0e9c077 Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPDialog$CheckHeaderCellRenderer.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPDialog$CheckTableModle.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPDialog$CheckTableModle.class new file mode 100644 index 0000000..0417f17 Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPDialog$CheckTableModle.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPDialog.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPDialog.class new file mode 100644 index 0000000..d5ede76 Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPDialog.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPHandler.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPHandler.class new file mode 100644 index 0000000..700a3cd Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPHandler.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateClassificationPanel$MyRenderer.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateClassificationPanel$MyRenderer.class new file mode 100644 index 0000000..961ce1c Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateClassificationPanel$MyRenderer.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateClassificationPanel$TreeExpandedListener.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateClassificationPanel$TreeExpandedListener.class new file mode 100644 index 0000000..9f03897 Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateClassificationPanel$TreeExpandedListener.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateClassificationPanel$treeSelectedListener.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateClassificationPanel$treeSelectedListener.class new file mode 100644 index 0000000..09dd8b1 Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateClassificationPanel$treeSelectedListener.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateClassificationPanel.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateClassificationPanel.class new file mode 100644 index 0000000..b02e97c Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateClassificationPanel.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateICOObj.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateICOObj.class new file mode 100644 index 0000000..8e7fb0c Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateICOObj.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORNewEquipmentDialog$1.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORNewEquipmentDialog$1.class new file mode 100644 index 0000000..d68c768 Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORNewEquipmentDialog$1.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORNewEquipmentDialog$2.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORNewEquipmentDialog$2.class new file mode 100644 index 0000000..dd3840c Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORNewEquipmentDialog$2.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORNewEquipmentDialog.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORNewEquipmentDialog.class new file mode 100644 index 0000000..a1e7920 Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORNewEquipmentDialog.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORSendToIcsOperation.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORSendToIcsOperation.class new file mode 100644 index 0000000..bdd51f0 Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORSendToIcsOperation.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/PackClassificationInfos.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/PackClassificationInfos.class new file mode 100644 index 0000000..ab3a3a3 Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/PackClassificationInfos.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/TCPreferenceUitl.class b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/TCPreferenceUitl.class new file mode 100644 index 0000000..db90076 Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/TCPreferenceUitl.class differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/image/inclassabstractclass_16.png b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/image/inclassabstractclass_16.png new file mode 100644 index 0000000..d28e0f0 Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/image/inclassabstractclass_16.png differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/image/inclassgroup_16.png b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/image/inclassgroup_16.png new file mode 100644 index 0000000..3f39188 Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/image/inclassgroup_16.png differ diff --git a/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/image/inclassstorageclass_16.png b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/image/inclassstorageclass_16.png new file mode 100644 index 0000000..780fcdb Binary files /dev/null and b/bin/com/connor/erp/processresource/EquipmentAcquiredFromERP/image/inclassstorageclass_16.png differ diff --git a/bin/com/connor/erp/searchImpResult/DateChooser$1.class b/bin/com/connor/erp/searchImpResult/DateChooser$1.class new file mode 100644 index 0000000..03898b7 Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/DateChooser$1.class differ diff --git a/bin/com/connor/erp/searchImpResult/DateChooser$2.class b/bin/com/connor/erp/searchImpResult/DateChooser$2.class new file mode 100644 index 0000000..87eae36 Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/DateChooser$2.class differ diff --git a/bin/com/connor/erp/searchImpResult/DateChooser$3.class b/bin/com/connor/erp/searchImpResult/DateChooser$3.class new file mode 100644 index 0000000..315433a Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/DateChooser$3.class differ diff --git a/bin/com/connor/erp/searchImpResult/DateChooser$4.class b/bin/com/connor/erp/searchImpResult/DateChooser$4.class new file mode 100644 index 0000000..caa43fe Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/DateChooser$4.class differ diff --git a/bin/com/connor/erp/searchImpResult/DateChooser$JP1$1.class b/bin/com/connor/erp/searchImpResult/DateChooser$JP1$1.class new file mode 100644 index 0000000..5d96e7c Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/DateChooser$JP1$1.class differ diff --git a/bin/com/connor/erp/searchImpResult/DateChooser$JP1$2.class b/bin/com/connor/erp/searchImpResult/DateChooser$JP1$2.class new file mode 100644 index 0000000..e5ad94d Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/DateChooser$JP1$2.class differ diff --git a/bin/com/connor/erp/searchImpResult/DateChooser$JP1$3.class b/bin/com/connor/erp/searchImpResult/DateChooser$JP1$3.class new file mode 100644 index 0000000..63b16f1 Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/DateChooser$JP1$3.class differ diff --git a/bin/com/connor/erp/searchImpResult/DateChooser$JP1$4.class b/bin/com/connor/erp/searchImpResult/DateChooser$JP1$4.class new file mode 100644 index 0000000..fca5c44 Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/DateChooser$JP1$4.class differ diff --git a/bin/com/connor/erp/searchImpResult/DateChooser$JP1.class b/bin/com/connor/erp/searchImpResult/DateChooser$JP1.class new file mode 100644 index 0000000..cb48ea3 Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/DateChooser$JP1.class differ diff --git a/bin/com/connor/erp/searchImpResult/DateChooser$JP2.class b/bin/com/connor/erp/searchImpResult/DateChooser$JP2.class new file mode 100644 index 0000000..95fa34a Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/DateChooser$JP2.class differ diff --git a/bin/com/connor/erp/searchImpResult/DateChooser$JP3.class b/bin/com/connor/erp/searchImpResult/DateChooser$JP3.class new file mode 100644 index 0000000..b71de55 Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/DateChooser$JP3.class differ diff --git a/bin/com/connor/erp/searchImpResult/DateChooser$JP4$1.class b/bin/com/connor/erp/searchImpResult/DateChooser$JP4$1.class new file mode 100644 index 0000000..13be2fe Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/DateChooser$JP4$1.class differ diff --git a/bin/com/connor/erp/searchImpResult/DateChooser$JP4.class b/bin/com/connor/erp/searchImpResult/DateChooser$JP4.class new file mode 100644 index 0000000..237ea03 Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/DateChooser$JP4.class differ diff --git a/bin/com/connor/erp/searchImpResult/DateChooser$LabelManager.class b/bin/com/connor/erp/searchImpResult/DateChooser$LabelManager.class new file mode 100644 index 0000000..e153716 Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/DateChooser$LabelManager.class differ diff --git a/bin/com/connor/erp/searchImpResult/DateChooser$MyLabel.class b/bin/com/connor/erp/searchImpResult/DateChooser$MyLabel.class new file mode 100644 index 0000000..56a5a19 Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/DateChooser$MyLabel.class differ diff --git a/bin/com/connor/erp/searchImpResult/DateChooser.class b/bin/com/connor/erp/searchImpResult/DateChooser.class new file mode 100644 index 0000000..14bddb4 Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/DateChooser.class differ diff --git a/bin/com/connor/erp/searchImpResult/SearchImpResultDialog$1.class b/bin/com/connor/erp/searchImpResult/SearchImpResultDialog$1.class new file mode 100644 index 0000000..9b048bf Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/SearchImpResultDialog$1.class differ diff --git a/bin/com/connor/erp/searchImpResult/SearchImpResultDialog.class b/bin/com/connor/erp/searchImpResult/SearchImpResultDialog.class new file mode 100644 index 0000000..e692884 Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/SearchImpResultDialog.class differ diff --git a/bin/com/connor/erp/searchImpResult/SearchImpResultHandler.class b/bin/com/connor/erp/searchImpResult/SearchImpResultHandler.class new file mode 100644 index 0000000..539323c Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/SearchImpResultHandler.class differ diff --git a/bin/com/connor/erp/searchImpResult/SearchImpResultOperation.class b/bin/com/connor/erp/searchImpResult/SearchImpResultOperation.class new file mode 100644 index 0000000..28e18ec Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/SearchImpResultOperation.class differ diff --git a/bin/com/connor/erp/searchImpResult/Test.class b/bin/com/connor/erp/searchImpResult/Test.class new file mode 100644 index 0000000..56f7f51 Binary files /dev/null and b/bin/com/connor/erp/searchImpResult/Test.class differ diff --git a/bin/com/connor/erp/toolkit/ActionType.class b/bin/com/connor/erp/toolkit/ActionType.class new file mode 100644 index 0000000..e4e3587 Binary files /dev/null and b/bin/com/connor/erp/toolkit/ActionType.class differ diff --git a/bin/com/connor/erp/toolkit/AimType.class b/bin/com/connor/erp/toolkit/AimType.class new file mode 100644 index 0000000..f2402ff Binary files /dev/null and b/bin/com/connor/erp/toolkit/AimType.class differ diff --git a/bin/com/connor/erp/toolkit/FileType.class b/bin/com/connor/erp/toolkit/FileType.class new file mode 100644 index 0000000..692d079 Binary files /dev/null and b/bin/com/connor/erp/toolkit/FileType.class differ diff --git a/bin/com/connor/erp/toolkit/HttpUtil.class b/bin/com/connor/erp/toolkit/HttpUtil.class new file mode 100644 index 0000000..b527cae Binary files /dev/null and b/bin/com/connor/erp/toolkit/HttpUtil.class differ diff --git a/bin/com/connor/erp/toolkit/IsContinueDialog$1.class b/bin/com/connor/erp/toolkit/IsContinueDialog$1.class new file mode 100644 index 0000000..9875398 Binary files /dev/null and b/bin/com/connor/erp/toolkit/IsContinueDialog$1.class differ diff --git a/bin/com/connor/erp/toolkit/IsContinueDialog$2.class b/bin/com/connor/erp/toolkit/IsContinueDialog$2.class new file mode 100644 index 0000000..8d9d32f Binary files /dev/null and b/bin/com/connor/erp/toolkit/IsContinueDialog$2.class differ diff --git a/bin/com/connor/erp/toolkit/IsContinueDialog$3.class b/bin/com/connor/erp/toolkit/IsContinueDialog$3.class new file mode 100644 index 0000000..969c016 Binary files /dev/null and b/bin/com/connor/erp/toolkit/IsContinueDialog$3.class differ diff --git a/bin/com/connor/erp/toolkit/IsContinueDialog$4.class b/bin/com/connor/erp/toolkit/IsContinueDialog$4.class new file mode 100644 index 0000000..a737ebb Binary files /dev/null and b/bin/com/connor/erp/toolkit/IsContinueDialog$4.class differ diff --git a/bin/com/connor/erp/toolkit/IsContinueDialog$ExampleFileFilter.class b/bin/com/connor/erp/toolkit/IsContinueDialog$ExampleFileFilter.class new file mode 100644 index 0000000..5beff02 Binary files /dev/null and b/bin/com/connor/erp/toolkit/IsContinueDialog$ExampleFileFilter.class differ diff --git a/bin/com/connor/erp/toolkit/IsContinueDialog.class b/bin/com/connor/erp/toolkit/IsContinueDialog.class new file mode 100644 index 0000000..f8695c9 Binary files /dev/null and b/bin/com/connor/erp/toolkit/IsContinueDialog.class differ diff --git a/bin/com/connor/erp/toolkit/ReadResultXMLStr.class b/bin/com/connor/erp/toolkit/ReadResultXMLStr.class new file mode 100644 index 0000000..cf79ac3 Binary files /dev/null and b/bin/com/connor/erp/toolkit/ReadResultXMLStr.class differ diff --git a/bin/com/connor/erp/toolkit/ResultInfo.class b/bin/com/connor/erp/toolkit/ResultInfo.class new file mode 100644 index 0000000..75736d9 Binary files /dev/null and b/bin/com/connor/erp/toolkit/ResultInfo.class differ diff --git a/bin/com/connor/erp/toolkit/TCPreferenceUitl.class b/bin/com/connor/erp/toolkit/TCPreferenceUitl.class new file mode 100644 index 0000000..4f7805f Binary files /dev/null and b/bin/com/connor/erp/toolkit/TCPreferenceUitl.class differ diff --git a/bin/com/connor/erp/toolkit/Test.class b/bin/com/connor/erp/toolkit/Test.class new file mode 100644 index 0000000..08767f0 Binary files /dev/null and b/bin/com/connor/erp/toolkit/Test.class differ diff --git a/bin/com/connor/erp/toolkit/UtilApi.class b/bin/com/connor/erp/toolkit/UtilApi.class new file mode 100644 index 0000000..2654e5a Binary files /dev/null and b/bin/com/connor/erp/toolkit/UtilApi.class differ diff --git a/bin/com/connor/erpintegration/entity/BOMLineEntity.class b/bin/com/connor/erpintegration/entity/BOMLineEntity.class new file mode 100644 index 0000000..83a2175 Binary files /dev/null and b/bin/com/connor/erpintegration/entity/BOMLineEntity.class differ diff --git a/bin/com/connor/erpintegration/entity/BomCheckResult.class b/bin/com/connor/erpintegration/entity/BomCheckResult.class new file mode 100644 index 0000000..ab6718d Binary files /dev/null and b/bin/com/connor/erpintegration/entity/BomCheckResult.class differ diff --git a/bin/com/connor/erpintegration/entity/CheckResult.class b/bin/com/connor/erpintegration/entity/CheckResult.class new file mode 100644 index 0000000..19a93ac Binary files /dev/null and b/bin/com/connor/erpintegration/entity/CheckResult.class differ diff --git a/bin/com/connor/erpintegration/entity/DepResEntity.class b/bin/com/connor/erpintegration/entity/DepResEntity.class new file mode 100644 index 0000000..9515ee8 Binary files /dev/null and b/bin/com/connor/erpintegration/entity/DepResEntity.class differ diff --git a/bin/com/connor/erpintegration/entity/ERPResultEntity.class b/bin/com/connor/erpintegration/entity/ERPResultEntity.class new file mode 100644 index 0000000..7ec4d6c Binary files /dev/null and b/bin/com/connor/erpintegration/entity/ERPResultEntity.class differ diff --git a/bin/com/connor/erpintegration/entity/RouteCheckResult.class b/bin/com/connor/erpintegration/entity/RouteCheckResult.class new file mode 100644 index 0000000..bb8b4d4 Binary files /dev/null and b/bin/com/connor/erpintegration/entity/RouteCheckResult.class differ diff --git a/bin/com/connor/erpintegration/entity/RouteLineEntity.class b/bin/com/connor/erpintegration/entity/RouteLineEntity.class new file mode 100644 index 0000000..fe59a35 Binary files /dev/null and b/bin/com/connor/erpintegration/entity/RouteLineEntity.class differ diff --git a/bin/com/connor/touliao/MessageDialog$1.class b/bin/com/connor/touliao/MessageDialog$1.class new file mode 100644 index 0000000..6f01e7f Binary files /dev/null and b/bin/com/connor/touliao/MessageDialog$1.class differ diff --git a/bin/com/connor/touliao/MessageDialog$2.class b/bin/com/connor/touliao/MessageDialog$2.class new file mode 100644 index 0000000..f937299 Binary files /dev/null and b/bin/com/connor/touliao/MessageDialog$2.class differ diff --git a/bin/com/connor/touliao/MessageDialog.class b/bin/com/connor/touliao/MessageDialog.class new file mode 100644 index 0000000..b79c6bf Binary files /dev/null and b/bin/com/connor/touliao/MessageDialog.class differ diff --git a/bin/com/connor/touliao/MyRenderer.class b/bin/com/connor/touliao/MyRenderer.class new file mode 100644 index 0000000..a7423f3 Binary files /dev/null and b/bin/com/connor/touliao/MyRenderer.class differ diff --git a/bin/com/connor/touliao/TouliaoDialog$1.class b/bin/com/connor/touliao/TouliaoDialog$1.class new file mode 100644 index 0000000..379e621 Binary files /dev/null and b/bin/com/connor/touliao/TouliaoDialog$1.class differ diff --git a/bin/com/connor/touliao/TouliaoDialog.class b/bin/com/connor/touliao/TouliaoDialog.class new file mode 100644 index 0000000..1da2166 Binary files /dev/null and b/bin/com/connor/touliao/TouliaoDialog.class differ diff --git a/bin/com/connor/touliao/TouliaoHandler.class b/bin/com/connor/touliao/TouliaoHandler.class new file mode 100644 index 0000000..8dc22f3 Binary files /dev/null and b/bin/com/connor/touliao/TouliaoHandler.class differ diff --git a/bin/com/connor/touliao/TouliaoOperation.class b/bin/com/connor/touliao/TouliaoOperation.class new file mode 100644 index 0000000..12761fa Binary files /dev/null and b/bin/com/connor/touliao/TouliaoOperation.class differ diff --git a/bin/com/connor/touliao/鎶曟枡瀵煎嚭妯℃澘.xlsx b/bin/com/connor/touliao/鎶曟枡瀵煎嚭妯℃澘.xlsx new file mode 100644 index 0000000..8cc1b03 Binary files /dev/null and b/bin/com/connor/touliao/鎶曟枡瀵煎嚭妯℃澘.xlsx differ diff --git a/bin/com/teamcenter/rac/workflow/commands/digitalsign/PerformTaskUtil.class b/bin/com/teamcenter/rac/workflow/commands/digitalsign/PerformTaskUtil.class new file mode 100644 index 0000000..f284c77 Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/digitalsign/PerformTaskUtil.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/DesignChange.class b/bin/com/teamcenter/rac/workflow/commands/dotask/DesignChange.class new file mode 100644 index 0000000..6c37808 Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/DesignChange.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$1.class b/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$1.class new file mode 100644 index 0000000..fabc3ba Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$1.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$2.class b/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$2.class new file mode 100644 index 0000000..3242a01 Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$2.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$3.class b/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$3.class new file mode 100644 index 0000000..43e470c Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$3.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$4.class b/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$4.class new file mode 100644 index 0000000..1e370ea Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$4.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$5.class b/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$5.class new file mode 100644 index 0000000..19c6199 Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$5.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$6.class b/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$6.class new file mode 100644 index 0000000..ad77859 Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$6.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$7.class b/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$7.class new file mode 100644 index 0000000..51390d0 Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel$7.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel.class b/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel.class new file mode 100644 index 0000000..1e36ed7 Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/DoTaskPanel.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/ExportOperation$FilterInfo.class b/bin/com/teamcenter/rac/workflow/commands/dotask/ExportOperation$FilterInfo.class new file mode 100644 index 0000000..117d781 Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/ExportOperation$FilterInfo.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/ExportOperation.class b/bin/com/teamcenter/rac/workflow/commands/dotask/ExportOperation.class new file mode 100644 index 0000000..a5ce227 Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/ExportOperation.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/FindPzBean.class b/bin/com/teamcenter/rac/workflow/commands/dotask/FindPzBean.class new file mode 100644 index 0000000..c38cb94 Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/FindPzBean.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/FindPzOperation$1.class b/bin/com/teamcenter/rac/workflow/commands/dotask/FindPzOperation$1.class new file mode 100644 index 0000000..3aae282 Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/FindPzOperation$1.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/FindPzOperation$2.class b/bin/com/teamcenter/rac/workflow/commands/dotask/FindPzOperation$2.class new file mode 100644 index 0000000..6f59ac9 Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/FindPzOperation$2.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/FindPzOperation.class b/bin/com/teamcenter/rac/workflow/commands/dotask/FindPzOperation.class new file mode 100644 index 0000000..38a1125 Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/FindPzOperation.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/ProgressBar$1.class b/bin/com/teamcenter/rac/workflow/commands/dotask/ProgressBar$1.class new file mode 100644 index 0000000..40b49b8 Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/ProgressBar$1.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/ProgressBar$TaskThread.class b/bin/com/teamcenter/rac/workflow/commands/dotask/ProgressBar$TaskThread.class new file mode 100644 index 0000000..44e896b Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/ProgressBar$TaskThread.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/ProgressBar.class b/bin/com/teamcenter/rac/workflow/commands/dotask/ProgressBar.class new file mode 100644 index 0000000..6030dd6 Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/ProgressBar.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/ProgressBarThread.class b/bin/com/teamcenter/rac/workflow/commands/dotask/ProgressBarThread.class new file mode 100644 index 0000000..3bee534 Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/ProgressBarThread.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/PzCard.class b/bin/com/teamcenter/rac/workflow/commands/dotask/PzCard.class new file mode 100644 index 0000000..5d9da94 Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/PzCard.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/TestDoTaskDialog.class b/bin/com/teamcenter/rac/workflow/commands/dotask/TestDoTaskDialog.class new file mode 100644 index 0000000..57bc834 Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/TestDoTaskDialog.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/Util.class b/bin/com/teamcenter/rac/workflow/commands/dotask/Util.class new file mode 100644 index 0000000..b4a940c Binary files /dev/null and b/bin/com/teamcenter/rac/workflow/commands/dotask/Util.class differ diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/newprocess_user.properties b/bin/com/teamcenter/rac/workflow/commands/dotask/newprocess_user.properties new file mode 100644 index 0000000..498d9d7 --- /dev/null +++ b/bin/com/teamcenter/rac/workflow/commands/dotask/newprocess_user.properties @@ -0,0 +1,41 @@ +#*================================================================================================== +# +# Copyright (c) 1998 Unigraphics Solutions Inc., An EDS Company +# Unpublished - All rights reserved +# +#=================================================================================================== +# File description: This properties file contains all keys pertaining to the dotask package. This +# is an internal file so therefore only TC PBU developers should be modifying +# this file. To make changes please modify the dotask_user.properties file. Do +# NOT modify this file. This allows properties found in this file to be +# over-written but not destroyed. +# +# Filename: dotask.properties +# Module : com.teamcenter.rac.workflow.common.commands.dotask +# +#=================================================================================================== +#Date Name Description of Change +#04-Oct-1999 ROWLANDS created +#15-Oct-1999 ROWLANDS merge from lee_cs_15Sep99 tc_v60_cs latest +#11-Feb-2000 mccollr Remove the localization keys and place within the locale file. +#05-Mar-2000 chenm Merge from int_v6.2 to chenm_v62 +#27-Jan-2005 Zhixin Huang Change the icon from gif to png file. +#06-Feb-2006 Venkatesh Chitnis de-imanization +#$HISTORY$ +#=================================================================================================*/ + +#import=com.teamcenter.rac.workflow.common.common +#newProcessDialog=com.teamcenter.rac.workflow.commands.dotask.TestDoTaskDialog +#command.TITLE=\u6267\u884C Do \u4EFB\u52A1\u6D4B\u8BD5123 + +#taskNameLabel=\u4EFB\u52A1\u540D\uFF1A +#taskInstructionsLabel=\u4EFB\u52A1\u8BF4\u660E\uFF1A +#doTaskComplete.LABEL=\u5B8C\u6210 +#doTaskUnableToComplete.LABEL=\u65E0\u6CD5\u5B8C\u6210 +#processDescLabel=\u6D41\u7A0B\u63CF\u8FF0\uFF1A +# +## Messages +## ------------------------ +##xxxMessage=XXX +#completingDoTaskMessage=\u6B63\u5728\u5B8C\u6210 Do \u4EFB\u52A1 +#failedCompleteDoTaskMessage=\u672A\u80FD\u5B8C\u6210 Do \u4EFB\u52A1 \ No newline at end of file diff --git a/bin/com/teamcenter/rac/workflow/commands/dotask/processcard.properties b/bin/com/teamcenter/rac/workflow/commands/dotask/processcard.properties new file mode 100644 index 0000000..0ea9591 --- /dev/null +++ b/bin/com/teamcenter/rac/workflow/commands/dotask/processcard.properties @@ -0,0 +1,7 @@ +op.Name=\u751F\u6210\u5DE5\u827A\u5361\u7247 +novalidconfig.Error=\u6CA1\u6709\u627E\u5230\u6709\u6548\u7684\u914D\u7F6E\uFF0C\u8BF7\u68C0\u67E5\u3002 +exporting=\u6B63\u5728\u5BFC\u51FA +unsupportedtargets.Error1=\u4EE5\u4E0B\u5BF9\u8C61\u4E0D\u652F\u6301\u5BFC\u51FA\uFF1A\n%s +init.Name=\u51C6\u5907\u5BFC\u51FA... +notowner.Error=\u975E\u5F53\u524D\u5BF9\u8C61\u7684\u6240\u6709\u8005\uFF0C\u4E0D\u80FD\u6267\u884C\u5361\u7247\u751F\u6210\u64CD\u4F5C +novalidtarget.Error=\u672A\u627E\u5230\u53EF\u5BFC\u51FA\u7684\u5BF9\u8C61\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u3002 diff --git a/bin/tcUser_erpUser.properties b/bin/tcUser_erpUser.properties new file mode 100644 index 0000000..a139502 --- /dev/null +++ b/bin/tcUser_erpUser.properties @@ -0,0 +1,58 @@ +admin=IT_PLM +24294=ZX_LWZ +70094=ZX_YHJ +24649=YYG_KLX +70284=ZX_HJ +70399=ZX_DJF +70491=ZX_DF +70132=ZX_HQP +70403=ZX_LXW +70199=ZX_WCM +01157=JS_wxl +23466=JS_LRF +22873=JS_WJB +22295=ZX_WJ +70285=ZX_MTY +70286=ZX_WQC +70538=ZX_WPC +70532=ZX_BY +75398=ZX_ZGL +70550=ZX_BYET +70099=ZX_LLP +01425=ZX_WMS +70090=ZX_GLJ +70091=ZX_GHQ +70311=ZX_JZJ +70458=ZX_ZXF +70068=ZX_ZCY +70495=ZX_JY +70407=ZX_PJ +70498=ZX_CL +70152=ZX_YZ +70446=ZX_DZM +70460=ZX_SLM +70528=ZX_LZG +70463=ZX_LJ +70489=ZX_LXJ +70088=ZX_YJL +70194=ZX_FM +70201=ZX_WSQ +70287=ZX_WYJ +70400=ZX_CPB +70442=ZX_LGP +70443=ZX_GJC +70472=ZX_GYY +70244=ZX_WFQ +70086=ZX_ZQX +70276=ZX_WXL +70200=ZX_SMD +70447=ZX_MYP +70444=ZX_LQ +70465=ZX_WRZ +70462=ZX_DZH +70237=ZX_WXG +70195=ZX_ZB +70518=ZX_LT +70504=ZX_WW +70560=ZX_GSX +70552=ZX_COMM \ No newline at end of file diff --git a/bin/test/WorkFlowTest.class b/bin/test/WorkFlowTest.class new file mode 100644 index 0000000..ef8323d Binary files /dev/null and b/bin/test/WorkFlowTest.class differ diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..7695c6a --- /dev/null +++ b/build.properties @@ -0,0 +1,18 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + lib/httpclient-4.2.1.jar,\ + lib/httpcore-4.2.1.jar,\ + lib/commons-logging-1.2.jar,\ + lib/json-lib-2.4-jdk15.jar,\ + lib/commons-beanutils-1.9.4.jar,\ + lib/ezmorph-1.0.6.jar,\ + lib/commons-collections-3.2.2.jar,\ + lib/commons-lang-2.6.jar,\ + lib/jdom.jar,\ + lib/ojdbc8.jar,\ + lib/gson-2.9.0.jar,\ + lib/jacob.jar diff --git a/icons/sample.png b/icons/sample.png new file mode 100644 index 0000000..02c4b79 Binary files /dev/null and b/icons/sample.png differ diff --git a/icons/sample@2x.png b/icons/sample@2x.png new file mode 100644 index 0000000..c1224d1 Binary files /dev/null and b/icons/sample@2x.png differ diff --git a/lib/commons-beanutils-1.9.4.jar b/lib/commons-beanutils-1.9.4.jar new file mode 100644 index 0000000..b73543c Binary files /dev/null and b/lib/commons-beanutils-1.9.4.jar differ diff --git a/lib/commons-collections-3.2.2.jar b/lib/commons-collections-3.2.2.jar new file mode 100644 index 0000000..fa5df82 Binary files /dev/null and b/lib/commons-collections-3.2.2.jar differ diff --git a/lib/commons-lang-2.6.jar b/lib/commons-lang-2.6.jar new file mode 100644 index 0000000..98467d3 Binary files /dev/null and b/lib/commons-lang-2.6.jar differ diff --git a/lib/commons-logging-1.2.jar b/lib/commons-logging-1.2.jar new file mode 100644 index 0000000..93a3b9f Binary files /dev/null and b/lib/commons-logging-1.2.jar differ diff --git a/lib/ezmorph-1.0.6.jar b/lib/ezmorph-1.0.6.jar new file mode 100644 index 0000000..30fad12 Binary files /dev/null and b/lib/ezmorph-1.0.6.jar differ diff --git a/lib/gson-2.9.0.jar b/lib/gson-2.9.0.jar new file mode 100644 index 0000000..fb62e05 Binary files /dev/null and b/lib/gson-2.9.0.jar differ diff --git a/lib/httpclient-4.2.1.jar b/lib/httpclient-4.2.1.jar new file mode 100644 index 0000000..0e999fc Binary files /dev/null and b/lib/httpclient-4.2.1.jar differ diff --git a/lib/httpcore-4.2.1.jar b/lib/httpcore-4.2.1.jar new file mode 100644 index 0000000..16d75e1 Binary files /dev/null and b/lib/httpcore-4.2.1.jar differ diff --git a/lib/jacob.jar b/lib/jacob.jar new file mode 100644 index 0000000..3b24a91 Binary files /dev/null and b/lib/jacob.jar differ diff --git a/lib/jdom.jar b/lib/jdom.jar new file mode 100644 index 0000000..288e64c Binary files /dev/null and b/lib/jdom.jar differ diff --git a/lib/json-lib-2.4-jdk15.jar b/lib/json-lib-2.4-jdk15.jar new file mode 100644 index 0000000..68d4f3b Binary files /dev/null and b/lib/json-lib-2.4-jdk15.jar differ diff --git a/lib/ojdbc8.jar b/lib/ojdbc8.jar new file mode 100644 index 0000000..b46608c Binary files /dev/null and b/lib/ojdbc8.jar differ diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..f19b371 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,261 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/cn/net/connor/nhjs/processcard/Activator.java b/src/cn/net/connor/nhjs/processcard/Activator.java new file mode 100644 index 0000000..9ab43f4 --- /dev/null +++ b/src/cn/net/connor/nhjs/processcard/Activator.java @@ -0,0 +1,44 @@ +package cn.net.connor.nhjs.processcard; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "cn.net.connor.nhjs.processcard"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/src/cn/net/connor/nhjs/processcard/ExportCommand.java b/src/cn/net/connor/nhjs/processcard/ExportCommand.java new file mode 100644 index 0000000..600b424 --- /dev/null +++ b/src/cn/net/connor/nhjs/processcard/ExportCommand.java @@ -0,0 +1,14 @@ +package cn.net.connor.nhjs.processcard; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.std.aifrcp.KCommand; + +public class ExportCommand extends KCommand{ + + public ExportCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new ExportOperation(app, actionInfo)); + } + +} diff --git a/src/cn/net/connor/nhjs/processcard/ExportOperation.java b/src/cn/net/connor/nhjs/processcard/ExportOperation.java new file mode 100644 index 0000000..4ffc68e --- /dev/null +++ b/src/cn/net/connor/nhjs/processcard/ExportOperation.java @@ -0,0 +1,282 @@ +package cn.net.connor.nhjs.processcard; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOPWindowType; +import com.teamcenter.rac.kernel.TCComponentCfgAttachmentLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.Registry; + +import cn.net.connor.std.aifrcp.KOperation; +import cn.net.connor.std.aifrcp.util.KSWTProgressDialog; +import cn.net.connor.std.aifrcp.util.KUtil; +import cn.net.connor.std.word.word.KWordCategory; +import cn.net.connor.std.word.word.KWordUtil; + +public class ExportOperation extends KOperation { + + protected static final Registry REG = Registry.getRegistry(ExportOperation.class); + public static final String PREF_FILTER = "Connor_NHL_ProessCard"; + + protected KSWTProgressDialog progressDialog; + protected List kWordCategories = new ArrayList<>(); + protected List filterInfos = new ArrayList<>(); + protected List windowToClose = new ArrayList<>(); + private TCComponentBOPWindowType bopWindowType; + + public ExportOperation(AbstractAIFApplication app, String prefNames) { + super(app, REG.getString("op.Name")); + } + + public static class FilterInfo { + + private String itemType_METarget; + private String itemType_MEProcess; + private String itemType_MEOP; + private String itemName_MEOP; + + public FilterInfo(String itemType_METarget, String itemType_MEProcess, String itemType_MEOP, String itemName_MEOP) { + super(); + this.itemType_METarget = itemType_METarget; + this.itemType_MEProcess = itemType_MEProcess; + this.itemType_MEOP = itemType_MEOP; + this.itemName_MEOP = itemName_MEOP; + } + + @Override + public String toString() { + if (KUtil.isEmpty(itemName_MEOP)) { + return String.format("GY[%s][%s][%s]", itemType_METarget, itemType_MEProcess, itemName_MEOP); + } + return String.format("GX[%s][%s][%s]", itemType_METarget, itemType_MEOP, itemName_MEOP); + } + + } + + @Override + public boolean init() throws Exception { + InterfaceAIFComponent[] targets = app.getTargetComponents(); + System.out.println("Select: " + Arrays.toString(targets)); + int targetCnt = KUtil.getLen(targets); + if (targetCnt == 0) { + return false; + } + bopWindowType = (TCComponentBOPWindowType) session.getTypeComponent("BOPWindow"); + String msg = REG.getString("init.Name") + " "; + this.progressDialog = new KSWTProgressDialog(AIFDesktop.getActiveDesktop().getShell(), "", msg, 0, false, true); + progressDialog.openDialog(); + readFilterConfig(); + // 瀵归変腑鐨勫璞¤繘琛岃繃婊 + targets = reloadTargetsByFilter(targets); + System.out.println("After Filter: " + Arrays.toString(targets)); + targetCnt = KUtil.getLen(targets); + if (targetCnt == 0) { + throw new Exception(REG.getString("novalidtarget.Error")); + } + TCComponentUser owner = session.getUser(); + boolean isDba = owner.getLogicalProperty(TCComponentUser.PROP_IS_MEMBER_OF_DBA); + System.out.println("Current User:" + owner + " DBA: " + isDba); + List unsupportedTargets = new ArrayList<>(); + for (int i = 0; i < targetCnt; i++) { + TCComponent target = (TCComponent) targets[i]; + KWordCategory wordCategory = KWordCategory.parse(session, target); + if (wordCategory != null) { + TCComponent targetOwner; + if (target instanceof TCComponentBOMLine) { + targetOwner = ((TCComponentBOMLine) target).getItemRevision().getReferenceProperty("owning_user"); + } else if (target instanceof TCComponentCfgAttachmentLine) { + targetOwner = target.getUnderlyingComponent().getReferenceProperty("owning_user"); + } else { + targetOwner = target.getReferenceProperty("owning_user"); + } + System.out.println("Check Owner [" + target + "]: " + targetOwner); + if (!owner.equals(targetOwner) && !isDba) { + System.out.println(">> Skip"); + // throw new TCException(REG.getString("notowner.Error")); + continue; + } + this.kWordCategories.add(wordCategory); + } else { + System.out.println("No valid config: " + target); + unsupportedTargets.add(target); + } + } + if (unsupportedTargets.size() > 0) { + throw new TCException(String.format(REG.getString("unsupportedtargets.Error1"), unsupportedTargets.toString())); + } + if (this.kWordCategories.size() == 0) { + throw new TCException(REG.getString("novalidconfig.Error")); + } + return true; + } + + private InterfaceAIFComponent[] reloadTargetsByFilter(InterfaceAIFComponent[] targets) throws Exception { + List res = new ArrayList<>(); + int len = KUtil.getLen(targets); + for (int i = 0; i < len; i++) { + InterfaceAIFComponent target = targets[i]; + if (target instanceof TCComponentBOMLine) { + reloadTarget((TCComponentBOMLine) target, res, null); + } else if(target instanceof TCComponentItemRevision){ + TCComponentItemRevision rev = (TCComponentItemRevision) target; + TCComponentBOMWindow bopWindow = bopWindowType.create(null); + this.windowToClose.add(bopWindow); + TCComponentBOMLine bopLine = bopWindow.setWindowTopLine(rev.getItem(), rev, null, null); + reloadTarget(bopLine, res, null); + }else { + System.out.println(">> Not BOMLine Or Revision: " + target); + } + } + return res.toArray(new InterfaceAIFComponent[] {}); + } + + private void reloadTarget(TCComponentBOMLine target, List res, List matargetTypes) throws Exception { + int filterCnt = this.filterInfos.size(); + String targetType = target.getStringProperty("bl_item_object_type"); + System.out.println("Filter > " + target + " >> " + targetType); + if (res.contains(target)) { + System.out.println(">> Skip Duplicate"); + return; + } + for (int i = 0; i < filterCnt; i++) { + FilterInfo info = this.filterInfos.get(i); + TCComponentItemRevision procRev = null; + boolean cycleChildren = false; + if (targetType.equals(info.itemType_MEProcess)) { + System.out.println(">> Check: " + info); + procRev = target.getItemRevision(); + cycleChildren = true; + } else if (targetType.equals(info.itemType_MEOP)) { + System.out.println(">> Check: " + info); + String itemName = target.getStringProperty("bl_item_object_name"); + if (!itemName.equals(info.itemName_MEOP)) { + System.out.println(">> Skip By Name [" + itemName + "]"); + continue; + } + if(matargetTypes==null) { + for (TCComponentBOMLine pLine = target.parent(); pLine != null; pLine = pLine.parent()) { + procRev = pLine.getItemRevision(); + } + System.out.println("Proc: " + procRev); + } + } else { + continue; + } + if(matargetTypes==null) { + if (procRev == null) { + System.out.println(">> Process Revision Not Found"); + continue; + } + matargetTypes = new ArrayList<>(); + TCComponent[] meTargets = procRev.getRelatedComponents("IMAN_METarget"); + System.out.println(">> METargets: " + Arrays.toString(meTargets)); + int len = KUtil.getLen(meTargets); + for (int j = 0; j < len; j++) { + TCComponent meTarget = meTargets[j]; + if (meTarget instanceof TCComponentItemRevision) { + String meTargetType = ((TCComponentItemRevision) meTarget).getItem().getType(); + if(!matargetTypes.contains(meTargetType)) { + matargetTypes.add(meTargetType); + } + } + } + } + if (!matargetTypes.contains(info.itemType_METarget)) { + System.out.println(">> Skip By METarget"); + continue; + } + if (!res.contains(target)) { + res.add(target); + } + if (cycleChildren) { + AIFComponentContext[] cc = target.getChildren(); + int childCnt = KUtil.getLen(cc); + for (int j = 0; j < childCnt; j++) { + TCComponentBOMLine cLine = (TCComponentBOMLine) cc[j].getComponent(); + reloadTarget(cLine, res, matargetTypes); + } + } + } + } + + private void readFilterConfig() throws Exception { + String[] prefValues = KUtil.getPrefVals(session, PREF_FILTER); + int len = KUtil.getLen(prefValues); + for (int i = 0; i < len; i++) { + String[] split = prefValues[i].split("=", -1); + if (KUtil.getLen(split) != 4) { + continue; + } + String itemType_METarget = split[0].trim(); + String typeName = split[1].trim(); + String itemName_MEOP = split[2].trim(); + boolean export = "Y".equalsIgnoreCase(split[3].trim()); + if (!export || KUtil.isEmpty(itemType_METarget) || KUtil.isEmpty(typeName)) { + continue; + } + String itemType_MEProcess = null; + String itemType_MEOP = null; + if (KUtil.isEmpty(itemName_MEOP)) { + itemType_MEProcess = typeName; + } else { + itemType_MEOP = typeName; + } + FilterInfo filterInfo = new FilterInfo(itemType_METarget, itemType_MEProcess, itemType_MEOP, itemName_MEOP); + this.filterInfos.add(filterInfo); + } + System.out.println("FilterInfos: " + this.filterInfos); + if (this.filterInfos.size() == 0) { + throw new Exception("Preference Error: " + PREF_FILTER); + } + } + + @Override + public void execute() throws Exception { + int wordCnt = this.kWordCategories.size(); + KWordUtil.startWord(); + for (int i = 0; i < wordCnt; i++) { + KWordCategory wordCate = this.kWordCategories.get(i); + String msg; + if (wordCnt == 1) { + msg = String.format("%s %s", REG.getString("exporting"), wordCate.toString()); + } else { + msg = String.format("( %d / %d ) %s %s", i + 1, wordCnt, REG.getString("exporting"), wordCate.toString()); + } + progressDialog.updateMessage(msg); + wordCate.export(session, progressDialog); + } + session.refreshComponentsByType("CfgBlAttachmentLine"); + } + + @Override + public void clearCache() throws Exception { + if (progressDialog != null) { + progressDialog.closeDialog(); + } + KWordUtil.closeWord(); + int wordCnt = this.kWordCategories.size(); + for (int i = 0; i < wordCnt; i++) { + KWordCategory wordCate = this.kWordCategories.get(i); + wordCate.clearCache(); + } + for (TCComponentBOMWindow w : windowToClose) { + try { + w.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + +} diff --git a/src/cn/net/connor/nhjs/processcard/processcard.properties b/src/cn/net/connor/nhjs/processcard/processcard.properties new file mode 100644 index 0000000..0ea9591 --- /dev/null +++ b/src/cn/net/connor/nhjs/processcard/processcard.properties @@ -0,0 +1,7 @@ +op.Name=\u751F\u6210\u5DE5\u827A\u5361\u7247 +novalidconfig.Error=\u6CA1\u6709\u627E\u5230\u6709\u6548\u7684\u914D\u7F6E\uFF0C\u8BF7\u68C0\u67E5\u3002 +exporting=\u6B63\u5728\u5BFC\u51FA +unsupportedtargets.Error1=\u4EE5\u4E0B\u5BF9\u8C61\u4E0D\u652F\u6301\u5BFC\u51FA\uFF1A\n%s +init.Name=\u51C6\u5907\u5BFC\u51FA... +notowner.Error=\u975E\u5F53\u524D\u5BF9\u8C61\u7684\u6240\u6709\u8005\uFF0C\u4E0D\u80FD\u6267\u884C\u5361\u7247\u751F\u6210\u64CD\u4F5C +novalidtarget.Error=\u672A\u627E\u5230\u53EF\u5BFC\u51FA\u7684\u5BF9\u8C61\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u3002 diff --git a/src/com/connor/bomCompare/CXGYFrame.java b/src/com/connor/bomCompare/CXGYFrame.java new file mode 100644 index 0000000..ee94989 --- /dev/null +++ b/src/com/connor/bomCompare/CXGYFrame.java @@ -0,0 +1,510 @@ +package com.connor.bomCompare; + +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.accessibility.AccessibleContext; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTree; +import javax.swing.RowSorter; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableRowSorter; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.pse.operations.ExpandBelowOperation; +import com.teamcenter.rac.psebase.AbstractBOMLineViewerApplication; +import com.teamcenter.rac.psebase.common.AbstractViewableNode; +import com.teamcenter.rac.psebase.common.AbstractViewableTreeTable; +import com.teamcenter.rac.treetable.IViewableNode; +import com.teamcenter.rac.treetable.TreeTableNode; + + +public class CXGYFrame extends JFrame{ + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp1; + private InterfaceAIFComponent comp2; + private List comp1List=new ArrayList();//订单bom数据。零部件ID + private Map> comp1Data=new HashMap>();//订单bom数据 + private List comp2List=new ArrayList();//订单工艺数据,消耗件ID + private Map> comp2Data=new HashMap>();//订单工艺数据 + + private int selectButton=1; + private List lightRow=new ArrayList();//高亮行的行号 + + + private Vector table1Vector = new Vector(); + private Vector table2Vector = new Vector(); + private Vector table3Vector = new Vector(); + private String[] Names; + private JLabel headLabel;//源对象 + private JLabel targetLabel;//目标对象 + private JTextArea headName;// 源对象名称 + private JTextArea targetName;// 目标对象名称 + private JButton[] topBtns; + private CardLayout tableSwitch = new CardLayout(); + private JPanel table; + private boolean isturn=true; + private JButton refreshButton;// 刷新 + private JButton cancelButton;// 取消 + private int selectRow=-1; + //表格 + private JTable mainTable1; + private String[] header1 = new String[]{"序号","ID","名称","数量"}; + + + public CXGYFrame(TCSession session,InterfaceAIFComponent comp1,InterfaceAIFComponent comp2,String[] Names) { + super(); + this.session = session; + this.Names=Names; + this.comp1=comp1; + this.comp2=comp2; + + init(); + + } + + private void init() { + try { + getMEOP1(comp1); + getMEOP2(comp2); + } catch (TCException e3) { + // TODO Auto-generated catch block + e3.printStackTrace(); + } + + compareData(); + this.setTitle("对比结果"); + this.setSize(new Dimension(1000, 600)); + this.setLayout(new BorderLayout()); + this.setResizable(true); + this.setAlwaysOnTop(true); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.setLocationRelativeTo(null); + this.setVisible(true); + + Container container = this.getContentPane(); + container.setLayout(new BorderLayout()); + container.setSize(new Dimension(1000, 600)); + + + JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + + this.headLabel=new JLabel("源目标"); + this.headLabel.setPreferredSize(new Dimension(450,20)); + this.targetLabel=new JLabel("目标对象"); + this.targetLabel.setPreferredSize(new Dimension(450,20)); + + this.headName=new JTextArea(Names[0]); + this.headName.setPreferredSize(new Dimension(450,60)); + this.targetName=new JTextArea(Names[1]); + this.targetName.setPreferredSize(new Dimension(450,60)); + + + + panel1.add("1.1.left.top",headLabel); + panel1.add("1.2.left.top",targetLabel); + panel1.add("2.1.left.top",headName); + panel1.add("2.2.left.top",targetName); + panel1.setPreferredSize(new Dimension(1000,100)); + + + //JPanel topBtnPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + topBtns = new JButton[3]; + topBtns[0] = new JButton("源对象独有数据"); + topBtns[1] = new JButton("目标对象独有数据"); + topBtns[2] = new JButton("数量差异数据"); + topBtns[0].setSelected(true); + for (JButton btn : topBtns) { + panel2.add("1.1.left.top",btn); + btn.addActionListener(panelSwitch()); + } + + + Vector headVector = new Vector(); + headVector.add("序号"); + headVector.add("ID"); + headVector.add("名称"); + headVector.add("数量"); + + DefaultTableModel dtm = new DefaultTableModel(table1Vector,headVector); + + mainTable1=new JTable(dtm); + mainTable1.setRowHeight(30); + //mainTable1.setEnabled(false);//设置表格不可编辑 + mainTable1.addMouseListener(new MouseAdapter() { + /** + *鼠标监听 + */ + public void mouseClicked(MouseEvent e) { + //获取当前的行 + int row = mainTable1.getSelectedRow(); + AbstractBOMLineViewerApplication bomapp = (AbstractBOMLineViewerApplication) AIFUtility + .getCurrentApplication(); + AbstractViewableTreeTable m_tree = null; + // 获取BOM树 + if (m_tree == null) { + m_tree = bomapp.getAbstractViewableTreeTable(); + } else { + m_tree = bomapp.getAbstractViewableTreeTable(); + + } + + // 展开BOM + ExpandBelowOperation operation = new ExpandBelowOperation(m_tree); + // session.queueOperation(operation); + session.queueOperation(operation, true); + // session.queueOperation(operation, false); + //根据当前选中的表格和顶层bom类型来判断获取表格哪个值 + AbstractViewableNode TopNode= m_tree.getRootNode(); + //获取顶层bom类型 + String type=""; + try { + type=TopNode.getBOMLine().getItem().getType(); + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + String ID=""; + switch (selectButton) { + case 1: + ID=(String) mainTable1.getValueAt(row, 1); + break; + case 2: + ID=(String) mainTable1.getValueAt(row, 1); + break; + case 3: + try { + if(type.equals(((TCComponentBOMLine)comp1).getItem().getType())) { + ID=(String) mainTable1.getValueAt(row, 1); + }else { + ID=(String) mainTable1.getValueAt(row, 4); + } + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + break; + default: + } + + try { + getNode(TopNode,ID,m_tree); + if(selectRow>0) { + m_tree.clearSelection(); + m_tree.setRowSelectionInterval(selectRow,selectRow); + selectRow=-1; + }else { + m_tree.clearSelection(); + selectRow=-1; + } + } catch (NumberFormatException | TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + session.queueOperation(operation, false); + + } +}); + JScrollPane J1= new JScrollPane(); + J1.setPreferredSize(new Dimension(900, 300)); + J1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + J1.setViewportView(mainTable1); + panel2.add("2.1.left.top",J1); + + this.refreshButton=new JButton("刷新"); + this.refreshButton.addActionListener(new ActionListener() { + // 当按钮被点击时,就会触发 ActionEvent事件 + // actionPerformed 方法就会被执行 + public void actionPerformed(ActionEvent e) { + dispose(); + CXGYFrame sj=new CXGYFrame(session,comp1,comp2,Names); + } + }); + this.cancelButton=new JButton("取消"); + this.cancelButton.addActionListener(new ActionListener() { + // 当按钮被点击时,就会触发 ActionEvent事件 + // actionPerformed 方法就会被执行 + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + panel3.add(this.refreshButton); + panel3.add(this.cancelButton); + panel3.setPreferredSize(new Dimension(1000,100)); + + + + + container.add(panel1,BorderLayout.NORTH); + container.add(panel2, BorderLayout.CENTER); + container.add(panel3, BorderLayout.SOUTH); + //container.add(table, BorderLayout.SOUTH); + + } + + private ActionListener panelSwitch() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String text = ((JButton) e.getSource()).getText(); + for (int i = 0; i < topBtns.length; i++) { + topBtns[i].setSelected(topBtns[i].getText().equals(text)); + } + switch (text) { + case "源对象独有数据": + Vector headVector1 = new Vector(); + headVector1.add("序号"); + headVector1.add("ID"); + headVector1.add("名称"); + headVector1.add("数量"); + + DefaultTableModel dtm1=(DefaultTableModel)mainTable1.getModel();//获取表格模型 + dtm1.setDataVector(table1Vector,headVector1);//设置新内容 + mainTable1.updateUI();//更新显示 + selectButton=1; + break; + case "目标对象独有数据": + Vector headVector2 = new Vector(); + headVector2.add("序号"); + headVector2.add("ID"); + headVector2.add("名称"); + headVector2.add("数量"); + + DefaultTableModel dtm2=(DefaultTableModel)mainTable1.getModel();//获取表格模型 + dtm2.setDataVector(table2Vector,headVector2);//设置新内容 + mainTable1.updateUI();//更新显示 + selectButton=2; + break; + case "数量差异数据": + Vector headVector3 = new Vector(); + headVector3.add("序号"); + headVector3.add("ID"); + headVector3.add("名称"); + headVector3.add("数量"); + headVector3.add("ID"); + headVector3.add("名称"); + headVector3.add("数量"); + + DefaultTableModel dtm3=(DefaultTableModel)mainTable1.getModel();//获取表格模型 + dtm3.setDataVector(table3Vector,headVector3);//设置新内容 + mainTable1.updateUI();//更新显示 + selectButton=3; + break; + default: +// createLogDataSourceTable(); + } + } + + }; + } + + +// //获取订单BOM对象数据 +// private void getData(InterfaceAIFComponent comp) throws TCException { +// +// } +// //获取订单工艺对象数据 +// private void getOPData(InterfaceAIFComponent comp) throws TCException {//bl_occ_type +// getMEOP(comp); +// } + + private void getMEOP1(InterfaceAIFComponent MEOP) throws TCException { + AIFComponentContext[] meops=((TCComponentBOMLine) MEOP).getChildren(); + + //事例类型为消耗件 + if(((TCComponentBOMLine)MEOP).getItemRevision().getType()!=null) { + List partData=new ArrayList(); + + if(!comp1List.contains(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id"))) { + comp1List.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id")); + partData.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id"));//获取ID + partData.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("object_name"));//获取名称 + partData.add(((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity")==null||((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity").equals("")? + "1":((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity"));//获取数量 + comp1Data.put(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id"), partData); + }else { + Float oldnum=Float.valueOf(comp1Data.get(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id")).get(2)); + Float newnum=Float.valueOf(((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity")==null||((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity").equals("")? + "1":((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity")); + partData.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id"));//获取ID + partData.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("object_name"));//获取名称 +// //可以去除小数点后面多余的.0 +// partData.add(String.valueOf(new BigDecimal(oldnum+newnum).stripTrailingZeros()));//累计数量 + partData.add(String.valueOf(oldnum+newnum));//累计数量 + comp1Data.put(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id"),partData); + } + + } + + if((meops.length==0||meops==null)) { + return; + }else { + for(AIFComponentContext meop:meops) { + getMEOP1(((TCComponentBOMLine)meop.getComponent())); + } + } + } + + + + private void getMEOP2(InterfaceAIFComponent MEOP) throws TCException { + AIFComponentContext[] meops=((TCComponentBOMLine) MEOP).getChildren(); + + //事例类型为消耗件 + if(((TCComponentBOMLine)MEOP).getItemRevision().getType()!=null) { + List partData=new ArrayList(); + + if(!comp2List.contains(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id"))) { + comp2List.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id")); + partData.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id"));//获取ID + partData.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("object_name"));//获取名称 + partData.add(((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity")==null||((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity").equals("")? + "1":((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity"));//获取数量 + comp2Data.put(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id"), partData); + }else { + Float oldnum=Float.valueOf(comp2Data.get(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id")).get(2)); + Float newnum=Float.valueOf(((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity")==null||((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity").equals("")? + "1":((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity")); + partData.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id"));//获取ID + partData.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("object_name"));//获取名称 +// //可以去除小数点后面多余的.0 +// partData.add(String.valueOf(new BigDecimal(oldnum+newnum).stripTrailingZeros()));//累计数量 + partData.add(String.valueOf(oldnum+newnum));//累计数量 + comp2Data.put(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id"),partData); + } + + } + + if((meops.length==0||meops==null)) { + return; + }else { + for(AIFComponentContext meop:meops) { + getMEOP2(((TCComponentBOMLine)meop.getComponent())); + } + } + } + + +// //获取bom行高亮选中 +// private void getNode(TCComponentBOMLine nodeBOMLine,String ID) throws TCException { +// AIFComponentContext[] nodeBOMLineChild=nodeBOMLine.getChildren(); +// if(getID(nodeBOMLine)==ID||getID(nodeBOMLine).equals(ID)) { +// lightRow.add(Integer.valueOf(getID(nodeBOMLine))); +// } +// if(nodeBOMLineChild.length==0||nodeBOMLineChild==null) { +// return; +// }else { +// for(AIFComponentContext node:nodeBOMLineChild) { +// getNode(((TCComponentBOMLine)node.getComponent()), ID); +// } +// } +// } + + private void getNode(AbstractViewableNode Node,String ID,AbstractViewableTreeTable m_tree) throws NumberFormatException, TCException { + AbstractViewableNode nextNode=(AbstractViewableNode) Node.getNextNode(); + TCComponentBOMLine NodeBOMLine=((IViewableNode) Node).getBOMLine(); + String IDS=getID(NodeBOMLine); + if(IDS==ID||getID(NodeBOMLine).equals(ID)) { + selectRow=m_tree.getRowForNode(Node); + return; + } + if(nextNode!=null){ + getNode(nextNode,ID,m_tree); + } + } + + private String getID(TCComponentBOMLine bomline) throws TCException { + //获取ID,若ID内存在“-”则只取“-”前面的字符 + String ID=((TCComponentBOMLine)bomline).getItemRevision().getStringProperty("item_id"); + if(ID.indexOf("-")>=0) { + return ID.split("-")[0]; + } + return ID; + } + + + //数据对比 + private void compareData() { + List List=new ArrayList(); + + if(true) { + //comp1是订单bom + for(int i=0;i> StationDatas=new ArrayList>();//工步 + private TCComponentItem target; + private String outPathString =System.getenv("TEMP") + "\\";//导出路径 + private String nameString=""; + private Map Files=new HashMap();//工位工艺作业指导书 + private List files=new ArrayList();//工位工艺作业指导书 + + + private JLabel headLabel;//源对象 + private JTextArea headName;// 源对象名称 + private JLabel targetLabel;//目标对象 + private JTextArea targetName;// 目标对象名称 + private JButton addButton;// 添加 + private JButton removeButton;// 移除 + private JButton sureButton;// 确定 + private JButton cancelButton;// 取消 + private InterfaceAIFComponent comp1; + private InterfaceAIFComponent comp2; + //InterfaceAIFComponent comp, TCSession session,Tree05 tree,TCComponentItem target + public CXGYWLDialog(TCSession session) throws IOException { + this.session = session; + //this.nameString="test"; + init(); + + } +// public DDGYSOPDialog(TCSession session) throws IOException { +// this.session = session; +// init(); +// } + + private void init() { + this.setTitle("对比关联"); + this.setSize(500, 500); + this.setLayout(new BorderLayout()); + this.setLocationRelativeTo(null); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.setAlwaysOnTop(true); + //源目标 + JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + JPanel panel4 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + panel1.setLayout(new FlowLayout(FlowLayout.LEADING,15,15)); + this.headLabel=new JLabel("源目标"); + this.headLabel.setPreferredSize(new Dimension(300,20)); + String name1=""; + try { + comp1=AIFUtility.getCurrentApplication().getTargetComponent(); + name1=((TCComponentBOMLine)comp1).getStringProperty("bl_line_name"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + this.headName=new JTextArea(name1); + this.headName.setPreferredSize(new Dimension(350,40)); + this.headName.setLineWrap(true); + this.headName.setWrapStyleWord(true); + this.headName.setEditable(false); + this.headName.setOpaque(true); + this.headName.setBackground(new Color(220,220,220)); + panel1.add(this.headLabel); + panel1.add(this.headName); + panel1.setPreferredSize(new Dimension(100,150)); + + + this.targetLabel=new JLabel("目标对象"); + this.targetLabel.setPreferredSize(new Dimension(300,20)); + this.targetName=new JTextArea(); + this.targetName.setPreferredSize(new Dimension(350,40)); + this.targetName.setLineWrap(true); + this.targetName.setWrapStyleWord(true); + this.targetName.setEditable(false); + this.targetName.setOpaque(true); + this.targetName.setBackground(new Color(220,220,220)); + panel2.add(this.targetLabel); + panel2.add(this.targetName); + panel2.setPreferredSize(new Dimension(100,200)); + + + this.addButton=new JButton("添加"); + this.removeButton=new JButton("移除"); + panel3.add(this.addButton); + panel3.add(this.removeButton); + panel3.setPreferredSize(new Dimension(100,200)); + + this.sureButton=new JButton("确定"); + this.cancelButton=new JButton("取消"); + panel4.add("1.1.left.top",this.sureButton); + panel4.add("1.2.left.top",this.cancelButton); + panel4.setPreferredSize(new Dimension(100,200)); + //添加监听 + createActionEvent(); + + this.add(panel1,BorderLayout.NORTH); + this.add(panel2,BorderLayout.CENTER); + this.add(panel3,BorderLayout.EAST); + this.add(panel4,BorderLayout.SOUTH); + this.setVisible(true); + } + + // 添加监听 + public void createActionEvent() { + this.addButton.addActionListener(this); + this.removeButton.addActionListener(this); + this.sureButton.addActionListener(this); + this.cancelButton.addActionListener(this); + } + + + + @Override + public void actionPerformed(ActionEvent e) { + Object source = e.getSource(); + if(source.equals(this.addButton)) { + comp2=AIFUtility.getCurrentApplication().getTargetComponent(); + String name2=""; + try { + if(comp2 instanceof TCComponentBOMLine) { + + if(((TCComponentBOMLine)comp1).getItem().getType().equals(((TCComponentBOMLine)comp2).getItem().getType())|| + ((TCComponentBOMLine)comp1).getItem().getType()==((TCComponentBOMLine)comp2).getItem().getType()) { + this.setAlwaysOnTop(false); + MessageBox.post("请勿选择同类型关联对象", "错误", MessageBox.ERROR); + this.setAlwaysOnTop(true); + return; + }else { + name2=((TCComponentBOMLine)comp2).getStringProperty("bl_line_name"); + } + + }else { + comp2=null; + this.setAlwaysOnTop(false); + MessageBox.post("请在结构管理器或制造工艺规划器中添加对象", "错误", MessageBox.ERROR); + this.setAlwaysOnTop(true); + return; + } + + this.targetName.setText(name2); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + else if(source.equals(this.removeButton)) { + comp2=null; + this.targetName.setText(""); + } + else if(source.equals(this.sureButton)) { + String[] Names = {headName.getText(),targetName.getText()}; + + if(comp1!=null&&comp2!=null) { + this.dispose(); + try { + CXGYFrame Frame=new CXGYFrame(session,comp1,comp2,Names); +// if((((TCComponentBOMLine)comp1).getItem().getType().equals("ML8_ProdProcess")&& +// ((TCComponentBOMLine)comp2).getItem().getType().equals("ML8_PlantBOP"))|| +// (((TCComponentBOMLine)comp2).getItem().getType().equals("ML8_ProdProcess")&& +// ((TCComponentBOMLine)comp1).getItem().getType().equals("ML8_PlantBOP"))) { +// CXGYFrame Frame=new CXGYFrame(session,comp1,comp2,Names); +// }else if((((TCComponentBOMLine)comp1).getItem().getType().equals("ML8_ProdProcess")&& +// ((TCComponentBOMLine)comp2).getItem().getType().equals("ML8_Refrigerator"))|| +// (((TCComponentBOMLine)comp2).getItem().getType().equals("ML8_ProdProcess")&& +// ((TCComponentBOMLine)comp1).getItem().getType().equals("ML8_Refrigerator"))) { +// WLFrame Frame=new WLFrame(session,comp1,comp2,Names); +// } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + //SJDBFrame sj=new SJDBFrame(session,comp1,comp2,Names); + + + }else{ + this.setAlwaysOnTop(false); + MessageBox.post("请选择对比目标", "错误", MessageBox.ERROR); + this.setAlwaysOnTop(true); + return; + } + + } + else if(source.equals(this.cancelButton)) { + dispose(); + } + + } + + + + @Override + public void dispose() { + // TODO Auto-generated method stub + + super.dispose(); + } + + +} diff --git a/src/com/connor/bomCompare/DDGYDialog.java b/src/com/connor/bomCompare/DDGYDialog.java new file mode 100644 index 0000000..a6c05db --- /dev/null +++ b/src/com/connor/bomCompare/DDGYDialog.java @@ -0,0 +1,246 @@ +package com.connor.bomCompare; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.imageio.ImageIO; +import javax.swing.Box; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.ListSelectionModel; +import javax.swing.table.DefaultTableModel; +import javax.swing.tree.TreePath; + +import org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter.White; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class DDGYDialog extends AbstractAIFDialog implements ActionListener { + + private TCSession session; + private InterfaceAIFComponent comp; + + private List> StationDatas=new ArrayList>();//工步 + private TCComponentItem target; + private String outPathString =System.getenv("TEMP") + "\\";//导出路径 + private String nameString=""; + private Map Files=new HashMap();//工位工艺作业指导书 + private List files=new ArrayList();//工位工艺作业指导书 + + + private JLabel headLabel;//源对象 + private JTextArea headName;// 源对象名称 + private JLabel targetLabel;//目标对象 + private JTextArea targetName;// 目标对象名称 + private JButton addButton;// 添加 + private JButton removeButton;// 移除 + private JButton sureButton;// 确定 + private JButton cancelButton;// 取消 + private InterfaceAIFComponent comp1; + private InterfaceAIFComponent comp2; + //InterfaceAIFComponent comp, TCSession session,Tree05 tree,TCComponentItem target + public DDGYDialog(TCSession session) throws IOException { + this.session = session; + //this.nameString="test"; + init(); + + } +// public DDGYSOPDialog(TCSession session) throws IOException { +// this.session = session; +// init(); +// } + + private void init() { + this.setTitle("对比关联"); + this.setSize(500, 500); + this.setLayout(new BorderLayout()); + this.setLocationRelativeTo(null); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.setAlwaysOnTop(true); + //源目标 + JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + JPanel panel4 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + panel1.setLayout(new FlowLayout(FlowLayout.LEADING,15,15)); + this.headLabel=new JLabel("源目标"); + this.headLabel.setPreferredSize(new Dimension(300,20)); + String name1=""; + try { + comp1=AIFUtility.getCurrentApplication().getTargetComponent(); + if(((TCComponentBOMLine)comp1).getItem().getType().equals("ML8_OrdMBOMItem")||((TCComponentBOMLine)comp1).getItem().getType().equals("ML8_OrderProcess")) { + name1=((TCComponentBOMLine)comp1).getStringProperty("bl_line_name"); + }else { + MessageBox.post("请选择订单BOM或订单工艺!", "错误", MessageBox.ERROR); + return; + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + this.headName=new JTextArea(name1); + this.headName.setPreferredSize(new Dimension(350,40)); + this.headName.setLineWrap(true); + this.headName.setWrapStyleWord(true); + this.headName.setEditable(false); + this.headName.setOpaque(true); + this.headName.setBackground(new Color(220,220,220)); + panel1.add(this.headLabel); + panel1.add(this.headName); + panel1.setPreferredSize(new Dimension(100,150)); + + + this.targetLabel=new JLabel("目标对象"); + this.targetLabel.setPreferredSize(new Dimension(300,20)); + this.targetName=new JTextArea(); + this.targetName.setPreferredSize(new Dimension(350,40)); + this.targetName.setLineWrap(true); + this.targetName.setWrapStyleWord(true); + this.targetName.setEditable(false); + this.targetName.setOpaque(true); + this.targetName.setBackground(new Color(220,220,220)); + panel2.add(this.targetLabel); + panel2.add(this.targetName); + panel2.setPreferredSize(new Dimension(100,200)); + + + this.addButton=new JButton("添加"); + this.removeButton=new JButton("移除"); + panel3.add(this.addButton); + panel3.add(this.removeButton); + panel3.setPreferredSize(new Dimension(100,200)); + + this.sureButton=new JButton("确定"); + this.cancelButton=new JButton("取消"); + panel4.add("1.1.left.top",this.sureButton); + panel4.add("1.2.left.top",this.cancelButton); + panel4.setPreferredSize(new Dimension(100,200)); + //添加监听 + createActionEvent(); + + this.add(panel1,BorderLayout.NORTH); + this.add(panel2,BorderLayout.CENTER); + this.add(panel3,BorderLayout.EAST); + this.add(panel4,BorderLayout.SOUTH); + this.setVisible(true); + } + + // 添加监听 + public void createActionEvent() { + this.addButton.addActionListener(this); + this.removeButton.addActionListener(this); + this.sureButton.addActionListener(this); + this.cancelButton.addActionListener(this); + } + + + + @Override + public void actionPerformed(ActionEvent e) { + Object source = e.getSource(); + if(source.equals(this.addButton)) { + comp2=AIFUtility.getCurrentApplication().getTargetComponent(); + String name2=""; + try { + if(comp2 instanceof TCComponentBOMLine&& + (((TCComponentBOMLine)comp2).getItem().getType().equals("ML8_OrdMBOMItem")|| + ((TCComponentBOMLine)comp2).getItem().getType().equals("ML8_OrderProcess"))) { + + if(((TCComponentBOMLine)comp1).getItem().getType().equals(((TCComponentBOMLine)comp2).getItem().getType())|| + ((TCComponentBOMLine)comp1).getItem().getType()==((TCComponentBOMLine)comp2).getItem().getType()) { + this.setAlwaysOnTop(false); + MessageBox.post("请勿选择同类型关联对象", "错误", MessageBox.ERROR); + this.setAlwaysOnTop(true); + return; + }else { + name2=((TCComponentBOMLine)comp2).getStringProperty("bl_line_name"); + } + }else { + comp2=null; + this.setAlwaysOnTop(false); + MessageBox.post("请在结构管理器或制造工艺规划器中选择订单BOM或订单工艺!", "错误", MessageBox.ERROR); + this.setAlwaysOnTop(true); + return; + } + + this.targetName.setText(name2); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + else if(source.equals(this.removeButton)) { + comp2=null; + this.targetName.setText(""); + } + else if(source.equals(this.sureButton)) { + String[] Names = {headName.getText(),targetName.getText()}; + + if(comp1!=null&&comp2!=null) { + this.dispose(); + DDGYFrame sj=new DDGYFrame(session,comp1,comp2,Names); + }else{ + this.setAlwaysOnTop(false); + MessageBox.post("请选择对比目标", "错误", MessageBox.ERROR); + this.setAlwaysOnTop(true); + return; + } + + } + else if(source.equals(this.cancelButton)) { + dispose(); + } + + } + + + + @Override + public void dispose() { + // TODO Auto-generated method stub + + super.dispose(); + } + + +} diff --git a/src/com/connor/bomCompare/DDGYFrame.java b/src/com/connor/bomCompare/DDGYFrame.java new file mode 100644 index 0000000..a427b2c --- /dev/null +++ b/src/com/connor/bomCompare/DDGYFrame.java @@ -0,0 +1,556 @@ +package com.connor.bomCompare; + +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.FileNotFoundException; +import java.math.BigDecimal; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.accessibility.AccessibleContext; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTree; +import javax.swing.RowSorter; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableRowSorter; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.pse.operations.ExpandBelowOperation; +import com.teamcenter.rac.psebase.AbstractBOMLineViewerApplication; +import com.teamcenter.rac.psebase.common.AbstractViewableNode; +import com.teamcenter.rac.psebase.common.AbstractViewableTreeTable; +import com.teamcenter.rac.treetable.IViewableNode; +import com.teamcenter.rac.treetable.TreeTableNode; +import com.teamcenter.rac.util.MessageBox; + + +public class DDGYFrame extends JFrame{ + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp1; + private InterfaceAIFComponent comp2; + private List comp1List=new ArrayList();//订单bom数据。零部件ID + private Map> comp1Data=new HashMap>();//订单bom数据 + private List comp2List=new ArrayList();//订单工艺数据,消耗件ID + private Map> comp2Data=new HashMap>();//订单工艺数据 + + private int selectButton=1; + private List lightRow=new ArrayList();//高亮行的行号 + + + private Vector table1Vector = new Vector(); + private Vector table2Vector = new Vector(); + private Vector table3Vector = new Vector(); + private String[] Names; + private JLabel headLabel;//源对象 + private JLabel targetLabel;//目标对象 + private JTextArea headName;// 源对象名称 + private JTextArea targetName;// 目标对象名称 + private JButton[] topBtns; + private CardLayout tableSwitch = new CardLayout(); + private JButton refreshButton;// 刷新 + private JButton cancelButton;// 取消 + private JPanel table; + private boolean isturn=true; + private int selectRow=-1; + //表格 + private JTable mainTable1; + private String[] header1 = new String[]{"序号","ID","名称","数量"}; + + + public DDGYFrame(TCSession session,InterfaceAIFComponent comp1,InterfaceAIFComponent comp2,String[] Names) { + super(); + this.session = session; + this.Names=Names; + this.comp1=comp1; + this.comp2=comp2; + + init(); + + } + + private void init() { + try { + if(((TCComponentBOMLine)comp1).getItem().getType().equals("ML8_OrdMBOMItem")) { + getBOMData(this.comp1); + getOPData(this.comp2); + }else { + isturn=false; + getBOMData(this.comp2); + getOPData(this.comp1); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + compareData(); + this.setTitle("对比结果"); + this.setSize(new Dimension(1000, 600)); + this.setLayout(new BorderLayout()); + this.setResizable(true); + this.setAlwaysOnTop(true); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.setLocationRelativeTo(null); + this.setVisible(true); + + Container container = this.getContentPane(); + container.setLayout(new BorderLayout()); + container.setSize(new Dimension(1000, 600)); + + + JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + + this.headLabel=new JLabel("源目标"); + this.headLabel.setPreferredSize(new Dimension(450,20)); + this.targetLabel=new JLabel("目标对象"); + this.targetLabel.setPreferredSize(new Dimension(450,20)); + + this.headName=new JTextArea(Names[0]); + this.headName.setPreferredSize(new Dimension(450,60)); + this.targetName=new JTextArea(Names[1]); + this.targetName.setPreferredSize(new Dimension(450,60)); + + + + panel1.add("1.1.left.top",headLabel); + panel1.add("1.2.left.top",targetLabel); + panel1.add("2.1.left.top",headName); + panel1.add("2.2.left.top",targetName); + panel1.setPreferredSize(new Dimension(1000,100)); + + + //JPanel topBtnPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + topBtns = new JButton[3]; + topBtns[0] = new JButton("源对象独有数据"); + topBtns[1] = new JButton("目标对象独有数据"); + topBtns[2] = new JButton("数量差异数据"); + topBtns[0].setSelected(true); + for (JButton btn : topBtns) { + panel2.add("1.1.left.top",btn); + btn.addActionListener(panelSwitch()); + } + + + Vector headVector = new Vector(); + headVector.add("序号"); + headVector.add("ID"); + headVector.add("名称"); + headVector.add("数量"); + + DefaultTableModel dtm = new DefaultTableModel(table1Vector,headVector); + + mainTable1=new JTable(dtm); + mainTable1.setRowHeight(30); + //mainTable1.setEnabled(false);//设置表格不可编辑 + mainTable1.addMouseListener(new MouseAdapter() { + /** + *鼠标监听 + */ + public void mouseClicked(MouseEvent e) { + //获取当前的行 + int row = mainTable1.getSelectedRow(); + AbstractBOMLineViewerApplication bomapp = (AbstractBOMLineViewerApplication) AIFUtility + .getCurrentApplication(); + AbstractViewableTreeTable m_tree = null; + // 获取BOM树 + if (m_tree == null) { + m_tree = bomapp.getAbstractViewableTreeTable(); + } else { + m_tree = bomapp.getAbstractViewableTreeTable(); + + } + + // 展开BOM + ExpandBelowOperation operation = new ExpandBelowOperation(m_tree); + // session.queueOperation(operation); + session.queueOperation(operation, true); + + //根据当前选中的表格和顶层bom类型来判断获取表格哪个值 + AbstractViewableNode TopNode= m_tree.getRootNode(); + //获取顶层bom类型 + String type=""; + try { + type=TopNode.getBOMLine().getItem().getType(); + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + String ID=""; + switch (selectButton) { + case 1: + ID=(String) mainTable1.getValueAt(row, 1); + break; + case 2: + ID=(String) mainTable1.getValueAt(row, 1); + break; + case 3: + if(type.equals("ML8_OrdMBOMItem")) { + if(isturn) { + ID=(String) mainTable1.getValueAt(row, 1); + }else { + ID=(String) mainTable1.getValueAt(row, 4); + } + + }else if(type.equals("ML8_OrderProcess")) { + if(isturn) { + ID=(String) mainTable1.getValueAt(row, 4); + }else { + ID=(String) mainTable1.getValueAt(row, 1); + } + } + break; + default: + } + + try { + getNode(TopNode,ID,m_tree); + if(selectRow>0) { + m_tree.clearSelection(); + m_tree.setRowSelectionInterval(selectRow,selectRow); + selectRow=-1; + }else { + m_tree.clearSelection(); + selectRow=-1; + } + } catch (NumberFormatException | TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + +// mainTable1.getValueAt(row, 2); + //输出当前行第一列数据 + //System.out.println(a1); + session.queueOperation(operation, false); + } + +}); + JScrollPane J1= new JScrollPane(); + J1.setPreferredSize(new Dimension(900, 300)); + J1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + J1.setViewportView(mainTable1); + panel2.add("2.1.left.top",J1); + + this.refreshButton=new JButton("刷新"); + this.refreshButton.addActionListener(new ActionListener() { + // 当按钮被点击时,就会触发 ActionEvent事件 + // actionPerformed 方法就会被执行 + public void actionPerformed(ActionEvent e) { + dispose(); + DDGYFrame sj=new DDGYFrame(session,comp1,comp2,Names); + } + }); + this.cancelButton=new JButton("取消"); + this.cancelButton.addActionListener(new ActionListener() { + // 当按钮被点击时,就会触发 ActionEvent事件 + // actionPerformed 方法就会被执行 + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + panel3.add(this.refreshButton); + panel3.add(this.cancelButton); + panel3.setPreferredSize(new Dimension(1000,100)); + //tableSwitch.show(table, "head"); + + + container.add(panel1,BorderLayout.NORTH); + container.add(panel2, BorderLayout.CENTER); + container.add(panel3, BorderLayout.SOUTH); + + } + + private ActionListener panelSwitch() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String text = ((JButton) e.getSource()).getText(); + for (int i = 0; i < topBtns.length; i++) { + topBtns[i].setSelected(topBtns[i].getText().equals(text)); + } + switch (text) { + case "源对象独有数据": + Vector headVector1 = new Vector(); + headVector1.add("序号"); + headVector1.add("ID"); + headVector1.add("名称"); + headVector1.add("数量"); + + DefaultTableModel dtm1=(DefaultTableModel)mainTable1.getModel();//获取表格模型 + dtm1.setDataVector(table1Vector,headVector1);//设置新内容 + mainTable1.updateUI();//更新显示 + selectButton=1; + break; + case "目标对象独有数据": + Vector headVector2 = new Vector(); + headVector2.add("序号"); + headVector2.add("ID"); + headVector2.add("名称"); + headVector2.add("数量"); + + DefaultTableModel dtm2=(DefaultTableModel)mainTable1.getModel();//获取表格模型 + dtm2.setDataVector(table2Vector,headVector2);//设置新内容 + mainTable1.updateUI();//更新显示 + selectButton=2; + break; + case "数量差异数据": + Vector headVector3 = new Vector(); + headVector3.add("序号"); + headVector3.add("ID"); + headVector3.add("名称"); + headVector3.add("数量"); + headVector3.add("ID"); + headVector3.add("名称"); + headVector3.add("数量"); + + DefaultTableModel dtm3=(DefaultTableModel)mainTable1.getModel();//获取表格模型 + dtm3.setDataVector(table3Vector,headVector3);//设置新内容 + mainTable1.updateUI();//更新显示 + selectButton=3; + break; + default: +// createLogDataSourceTable(); + } + } + + }; + } + + + //获取订单BOM对象数据 + private void getBOMData(InterfaceAIFComponent comp) throws TCException { + + AIFComponentContext[] parts=((TCComponentBOMLine)comp).getChildren(); + for(int i=0;i partData=new ArrayList(); + //合并数量 + if(!comp1List.contains(part.getItemRevision().getStringProperty("item_id"))) { + comp1List.add(part.getItemRevision().getStringProperty("item_id")); + partData.add(part.getItemRevision().getStringProperty("item_id"));//获取ID + partData.add(part.getItemRevision().getStringProperty("ml8_MaterialNo"));//获取物料编码 + partData.add(part.getItemRevision().getStringProperty("object_name"));//获取名称 + partData.add(part.getStringProperty("bl_quantity")==null||part.getStringProperty("bl_quantity").equals("")? + "1":part.getStringProperty("bl_quantity"));//获取数量 + comp1Data.put(part.getItemRevision().getStringProperty("item_id"), partData); + }else { + Float oldnum=Float.valueOf(comp1Data.get(part.getItemRevision().getStringProperty("item_id")).get(3)); + Float newnum=Float.valueOf(part.getStringProperty("bl_quantity")==null||part.getStringProperty("bl_quantity").equals("")? + "1":part.getStringProperty("bl_quantity")); + partData.add(part.getItemRevision().getStringProperty("item_id"));//获取ID + partData.add(part.getItemRevision().getStringProperty("ml8_MaterialNo"));//获取物料编码 + partData.add(part.getItemRevision().getStringProperty("object_name"));//获取名称 +// //可以去除小数点后面多余的.0 +// partData.add(String.valueOf(new BigDecimal(oldnum+newnum).stripTrailingZeros()));//累计数量 + partData.add(String.valueOf(oldnum+newnum));//累计数量 + comp1Data.put(part.getItemRevision().getStringProperty("item_id"),partData); + } + + } + + } + + + //获取订单工艺对象数据 + private void getOPData(InterfaceAIFComponent comp) throws TCException {//bl_occ_type + getMEOP(comp); + } + + + private void getMEOP(InterfaceAIFComponent MEOP) throws TCException { + AIFComponentContext[] meops=((TCComponentBOMLine) MEOP).getChildren(); + //事例类型为消耗件 + if(((TCComponentBOMLine)MEOP).getStringProperty("bl_occ_type").equals("MEConsumed")) { + List partData=new ArrayList(); + //获取ID,若ID内存在“-”则只取“-”前面的字符 + String ID=((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id"); + if(ID.indexOf("-")>=0) { + ID=ID.split("-")[0]; + } + if(!comp2List.contains(ID)) { + comp2List.add(ID); + partData.add(ID);//获取ID + partData.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("object_name"));//获取名称 + partData.add(((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity")==null||((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity").equals("")? + "1":((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity"));//获取数量 + comp2Data.put(ID, partData); + }else { + Float oldnum=Float.valueOf(comp2Data.get(ID).get(2)); + Float newnum=Float.valueOf(((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity")==null||((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity").equals("")? + "1":((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity")); +// if(Math.floor(oldnum+newnum)==(oldnum+newnum)) { +// partData.add(ID);//获取ID +// partData.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("object_name"));//获取名称 +// partData.add(String.valueOf((int)(oldnum+newnum)));//累计数量 +// }else { +// partData.add(ID);//获取ID +// partData.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("object_name"));//获取名称 +// partData.add(String.valueOf(oldnum+newnum));//累计数量 +// } + partData.add(ID);//获取ID + partData.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("object_name"));//获取名称 +// //可以去除小数点后面多余的.0 +// partData.add(String.valueOf(new BigDecimal(oldnum+newnum).stripTrailingZeros()));//累计数量 + partData.add(String.valueOf(oldnum+newnum));//累计数量 + comp2Data.put(ID,partData); + } + + } + + if((meops.length==0||meops==null)) { + return; + }else { + for(AIFComponentContext meop:meops) { + getMEOP(((TCComponentBOMLine)meop.getComponent())); + } + } + } + +// //获取bom行高亮选中 +// private void getNode(TCComponentBOMLine nodeBOMLine,String ID) throws TCException { +// AIFComponentContext[] nodeBOMLineChild=nodeBOMLine.getChildren(); +// if(getID(nodeBOMLine)==ID||getID(nodeBOMLine).equals(ID)) { +// lightRow.add(Integer.valueOf(getID(nodeBOMLine))); +// } +// if(nodeBOMLineChild.length==0||nodeBOMLineChild==null) { +// return; +// }else { +// for(AIFComponentContext node:nodeBOMLineChild) { +// getNode(((TCComponentBOMLine)node.getComponent()), ID); +// } +// } +// } + + private void getNode(AbstractViewableNode Node,String ID,AbstractViewableTreeTable m_tree) throws NumberFormatException, TCException { + AbstractViewableNode nextNode=(AbstractViewableNode) Node.getNextNode(); + TCComponentBOMLine NodeBOMLine=((IViewableNode) Node).getBOMLine(); + String IDS=getID(NodeBOMLine); + if(IDS==ID||getID(NodeBOMLine).equals(ID)) { + selectRow=m_tree.getRowForNode(Node); + return; + } + if(nextNode!=null){ + getNode(nextNode,ID,m_tree); + } + } + + private String getID(TCComponentBOMLine bomline) throws TCException { + //获取ID,若ID内存在“-”则只取“-”前面的字符 + String ID=((TCComponentBOMLine)bomline).getItemRevision().getStringProperty("item_id"); + if(ID.indexOf("-")>=0) { + return ID.split("-")[0]; + } + return ID; + } + + + //数据对比 + private void compareData() { + List List=new ArrayList();//记录订单工艺中存在消耗件与订单bom中ID或无聊编码相同的消耗件ID + + if(true) { + //comp1是订单bom + for(int i=0;i1){ + DDGYDialog Dialog=new DDGYDialog(session); + }else if(1==1){ + CXGYWLDialog Dialog=new CXGYWLDialog(session); + }else { + MessageBox.post("请选择:订单BOM,订单工艺,产品工艺,产品BOM,产线工艺。", "错误", MessageBox.ERROR); + } + //String ssString=((TCComponentBOMLine)comp).getItem().getType(); + + //System.out.print(ssString); + }else { + MessageBox.post("请在结构管理器或制造工艺规划器中选中BOMLine对象!", "错误", MessageBox.ERROR); + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + //MessageBox.post("1", "错误", MessageBox.ERROR); + return null; + } + + +} diff --git a/src/com/connor/bomCompare/WLFrame.java b/src/com/connor/bomCompare/WLFrame.java new file mode 100644 index 0000000..5e80e8f --- /dev/null +++ b/src/com/connor/bomCompare/WLFrame.java @@ -0,0 +1,598 @@ +package com.connor.bomCompare; + +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.accessibility.AccessibleContext; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTree; +import javax.swing.RowSorter; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableRowSorter; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.pse.operations.ExpandBelowOperation; +import com.teamcenter.rac.psebase.AbstractBOMLineViewerApplication; +import com.teamcenter.rac.psebase.common.AbstractViewableNode; +import com.teamcenter.rac.psebase.common.AbstractViewableTreeTable; +import com.teamcenter.rac.treetable.IViewableNode; +import com.teamcenter.rac.treetable.TreeTableNode; + + +public class WLFrame extends JFrame{ + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp1; + private InterfaceAIFComponent comp2; + private List comp1List=new ArrayList();//订单bom数据。零部件ID + private Map> comp1Data=new HashMap>();//订单bom数据 + private List comp2List=new ArrayList();//订单工艺数据,消耗件ID + private List comp12List=new ArrayList();//工艺bom的数据,不考虑父子件 + private Map> comp2Data=new HashMap>();//订单工艺数据 + private List sameList=new ArrayList();//记录同ID的数据 + + private int selectButton=1; + private List lightRow=new ArrayList();//高亮行的行号 + + + private Vector table1Vector = new Vector(); + private Vector table2Vector = new Vector(); + private Vector table3Vector = new Vector(); + private String[] Names; + private JLabel headLabel;//源对象 + private JLabel targetLabel;//目标对象 + private JTextArea headName;// 源对象名称 + private JTextArea targetName;// 目标对象名称 + private JButton refreshButton;// 刷新 + private JButton cancelButton;// 取消 + private JButton[] topBtns; + private CardLayout tableSwitch = new CardLayout(); + private JPanel table; + private boolean isturn=true; + private int selectRow=-1; + //表格 + private JTable mainTable1; + private String[] header1 = new String[]{"序号","ID","名称","数量"}; + + + public WLFrame(TCSession session,InterfaceAIFComponent comp1,InterfaceAIFComponent comp2,String[] Names) { + super(); + this.session = session; + this.Names=Names; + this.comp1=comp1; + this.comp2=comp2; + + init(); + + } + + private void init() { + try { + if(((TCComponentBOMLine)comp1).getItem().getType().equals("ML8_Refrigerator")) { + getMEOP1(this.comp1); + getMEOP2(this.comp2); + getSameID(); + comp12List.addAll(comp1List); + comp1List.clear(); + comp2List.clear(); + getMEOP1(this.comp1); + getMEOP2(this.comp2); + }else { + isturn=false; + getMEOP1(this.comp2); + getMEOP2(this.comp1); + getSameID(); + comp12List.addAll(comp1List); + comp1List.clear(); + comp2List.clear(); + getMEOP1(this.comp2); + getMEOP2(this.comp1); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } +// getSameID(); +// comp1List.clear(); +// comp2List.clear(); +// try { +// if(((TCComponentBOMLine)comp1).getItem().getType().equals("ML8_Refrigerator")) { +// getMEOP1(this.comp1); +// getMEOP2(this.comp2); +// }else { +// isturn=false; +// getMEOP1(this.comp2); +// getMEOP2(this.comp1); +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + compareData(); + this.setTitle("对比结果"); + this.setSize(new Dimension(1000, 600)); + this.setLayout(new BorderLayout()); + this.setResizable(true); + this.setAlwaysOnTop(true); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.setLocationRelativeTo(null); + this.setVisible(true); + + Container container = this.getContentPane(); + container.setLayout(new BorderLayout()); + container.setSize(new Dimension(1000, 600)); + + + JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + + this.headLabel=new JLabel("源目标"); + this.headLabel.setPreferredSize(new Dimension(450,20)); + this.targetLabel=new JLabel("目标对象"); + this.targetLabel.setPreferredSize(new Dimension(450,20)); + + this.headName=new JTextArea(Names[0]); + this.headName.setPreferredSize(new Dimension(450,60)); + this.targetName=new JTextArea(Names[1]); + this.targetName.setPreferredSize(new Dimension(450,60)); + + + + panel1.add("1.1.left.top",headLabel); + panel1.add("1.2.left.top",targetLabel); + panel1.add("2.1.left.top",headName); + panel1.add("2.2.left.top",targetName); + panel1.setPreferredSize(new Dimension(1000,100)); + + + //JPanel topBtnPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + topBtns = new JButton[3]; + topBtns[0] = new JButton("源对象独有数据"); + topBtns[1] = new JButton("目标对象独有数据"); + topBtns[2] = new JButton("数量差异数据"); + topBtns[0].setSelected(true); + for (JButton btn : topBtns) { + panel2.add("1.1.left.top",btn); + btn.addActionListener(panelSwitch()); + } + + + Vector headVector = new Vector(); + headVector.add("序号"); + headVector.add("ID"); + headVector.add("名称"); + headVector.add("数量"); + + DefaultTableModel dtm = new DefaultTableModel(table1Vector,headVector); + + mainTable1=new JTable(dtm); + mainTable1.setRowHeight(30); + //mainTable1.setEnabled(false);//设置表格不可编辑 + mainTable1.addMouseListener(new MouseAdapter() { + /** + *鼠标监听 + */ + public void mouseClicked(MouseEvent e) { + //获取当前的行 + int row = mainTable1.getSelectedRow(); + AbstractBOMLineViewerApplication bomapp = (AbstractBOMLineViewerApplication) AIFUtility + .getCurrentApplication(); + AbstractViewableTreeTable m_tree = null; + // 获取BOM树 + if (m_tree == null) { + m_tree = bomapp.getAbstractViewableTreeTable(); + } else { + m_tree = bomapp.getAbstractViewableTreeTable(); + + } + + // 展开BOM + ExpandBelowOperation operation = new ExpandBelowOperation(m_tree); + // session.queueOperation(operation); + session.queueOperation(operation, true); + + //根据当前选中的表格和顶层bom类型来判断获取表格哪个值 + AbstractViewableNode TopNode= m_tree.getRootNode(); + //获取顶层bom类型 + String type=""; + try { + type=TopNode.getBOMLine().getItem().getType(); + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + String ID=""; + switch (selectButton) { + case 1: + ID=(String) mainTable1.getValueAt(row, 1); + break; + case 2: + ID=(String) mainTable1.getValueAt(row, 1); + break; + case 3: + try { + if(type.equals(((TCComponentBOMLine)comp1).getItem().getType())) { + ID=(String) mainTable1.getValueAt(row, 1); + + }else if(type.equals(((TCComponentBOMLine)comp2).getItem().getType())) { + ID=(String) mainTable1.getValueAt(row, 1); + } + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } +// if(type.equals("ML8_Refrigerator")) { +// if(isturn) { +// ID=(String) mainTable1.getValueAt(row, 1); +// }else { +// ID=(String) mainTable1.getValueAt(row, 4); +// } +// +// }else if(type.equals("ML8_ProdProcess")) { +// if(isturn) { +// ID=(String) mainTable1.getValueAt(row, 4); +// }else { +// ID=(String) mainTable1.getValueAt(row, 1); +// } +// } + break; + default: + } + + try { + getNode(TopNode,ID,m_tree); + if(selectRow>0) { + m_tree.clearSelection(); + m_tree.setRowSelectionInterval(selectRow,selectRow); + selectRow=-1; + }else { + m_tree.clearSelection(); + selectRow=-1; + } + } catch (NumberFormatException | TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + session.queueOperation(operation, false); + } + +}); + JScrollPane J1= new JScrollPane(); + J1.setPreferredSize(new Dimension(900, 300)); + J1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + J1.setViewportView(mainTable1); + + panel2.add("2.1.left.top",J1); + + + this.refreshButton=new JButton("刷新"); + this.refreshButton.addActionListener(new ActionListener() { + // 当按钮被点击时,就会触发 ActionEvent事件 + // actionPerformed 方法就会被执行 + public void actionPerformed(ActionEvent e) { + dispose(); + WLFrame sj=new WLFrame(session,comp1,comp2,Names); + } + }); + this.cancelButton=new JButton("取消"); + this.cancelButton.addActionListener(new ActionListener() { + // 当按钮被点击时,就会触发 ActionEvent事件 + // actionPerformed 方法就会被执行 + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + panel3.add(this.refreshButton); + panel3.add(this.cancelButton); + panel3.setPreferredSize(new Dimension(1000,100)); + + + container.add(panel1,BorderLayout.NORTH); + container.add(panel2, BorderLayout.CENTER); + container.add(panel3, BorderLayout.SOUTH); + //container.add(table, BorderLayout.SOUTH); + + } + + private ActionListener panelSwitch() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String text = ((JButton) e.getSource()).getText(); + for (int i = 0; i < topBtns.length; i++) { + topBtns[i].setSelected(topBtns[i].getText().equals(text)); + } + switch (text) { + case "源对象独有数据": + Vector headVector1 = new Vector(); + headVector1.add("序号"); + headVector1.add("ID"); + headVector1.add("名称"); + headVector1.add("数量"); + + DefaultTableModel dtm1=(DefaultTableModel)mainTable1.getModel();//获取表格模型 + dtm1.setDataVector(table1Vector,headVector1);//设置新内容 + mainTable1.updateUI();//更新显示 + selectButton=1; + break; + case "目标对象独有数据": + Vector headVector2 = new Vector(); + headVector2.add("序号"); + headVector2.add("ID"); + headVector2.add("名称"); + headVector2.add("数量"); + + DefaultTableModel dtm2=(DefaultTableModel)mainTable1.getModel();//获取表格模型 + dtm2.setDataVector(table2Vector,headVector2);//设置新内容 + mainTable1.updateUI();//更新显示 + selectButton=2; + break; + case "数量差异数据": + Vector headVector3 = new Vector(); + headVector3.add("序号"); + headVector3.add("ID"); + headVector3.add("名称"); + headVector3.add("数量"); + headVector3.add("ID"); + headVector3.add("名称"); + headVector3.add("数量"); + + DefaultTableModel dtm3=(DefaultTableModel)mainTable1.getModel();//获取表格模型 + dtm3.setDataVector(table3Vector,headVector3);//设置新内容 + mainTable1.updateUI();//更新显示 + selectButton=3; + break; + default: +// createLogDataSourceTable(); + } + } + + }; + } + + +// //获取订单BOM对象数据 +// private void getData(InterfaceAIFComponent comp) throws TCException { +// +// } +// //获取订单工艺对象数据 +// private void getOPData(InterfaceAIFComponent comp) throws TCException {//bl_occ_type +// getMEOP(comp); +// } + + + //获取产品bom + private void getMEOP1(InterfaceAIFComponent MEOP) throws TCException { + AIFComponentContext[] meops=((TCComponentBOMLine) MEOP).getChildren(); + //事例类型为消耗件 + if(((TCComponentBOMLine)MEOP).getItem().getType().equals("ML8_Part")|| + ((TCComponentBOMLine)MEOP).getItem().getType().equals("ML8_RawMaterial")) { + List partData=new ArrayList(); + + if(!comp1List.contains(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id"))) { + comp1List.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id")); + partData.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id"));//获取ID + partData.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("object_name"));//获取名称 + partData.add(((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity")==null||((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity").equals("")? + "1":((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity"));//获取数量 + comp1Data.put(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id"), partData); + }else { + Float oldnum=Float.valueOf(comp1Data.get(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id")).get(2)); + Float newnum=Float.valueOf(((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity")==null||((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity").equals("")? + "1":((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity")); + partData.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id"));//获取ID + partData.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("object_name"));//获取名称 +// //可以去除小数点后面多余的.0 +// partData.add(String.valueOf(new BigDecimal(oldnum+newnum).stripTrailingZeros()));//累计数量 + partData.add(String.valueOf(oldnum+newnum));//累计数量 + comp1Data.put(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id"),partData); + } + + } + + if(meops.length==0||meops==null||sameList.contains(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id"))) { + return; + }else { + for(AIFComponentContext meop:meops) { + getMEOP1(((TCComponentBOMLine)meop.getComponent())); + } + } + } + + + //获取产品工艺 + private void getMEOP2(InterfaceAIFComponent MEOP) throws TCException {AIFComponentContext[] meops=((TCComponentBOMLine) MEOP).getChildren(); + //事例类型为消耗件 + if(((TCComponentBOMLine)MEOP).getStringProperty("bl_occ_type").equals("MEConsumed")) { + List partData=new ArrayList(); + //获取ID,若ID内存在“-”则只取“-”前面的字符 + String ID=((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("item_id"); + if(ID.indexOf("-")>=0) { + ID=ID.split("-")[0]; + } + if(!comp2List.contains(ID)) { + comp2List.add(ID); + partData.add(ID);//获取ID + partData.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("object_name"));//获取名称 + partData.add(((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity")==null||((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity").equals("")? + "1":((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity"));//获取数量 + comp2Data.put(ID, partData); + }else { + Float oldnum=Float.valueOf(comp2Data.get(ID).get(2)); + Float newnum=Float.valueOf(((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity")==null||((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity").equals("")? + "1":((TCComponentBOMLine)MEOP).getStringProperty("bl_quantity")); + partData.add(ID);//获取ID + partData.add(((TCComponentBOMLine)MEOP).getItemRevision().getStringProperty("object_name"));//获取名称 +// //可以去除小数点后面多余的.0 +// partData.add(String.valueOf(new BigDecimal(oldnum+newnum).stripTrailingZeros()));//累计数量 + partData.add(String.valueOf(oldnum+newnum));//累计数量 + comp2Data.put(ID,partData); + } + + } + + if(meops.length==0||meops==null) { + return; + }else { + for(AIFComponentContext meop:meops) { + getMEOP2(((TCComponentBOMLine)meop.getComponent())); + } + }} + + +// //获取bom行高亮选中 +// private void getNode(TCComponentBOMLine nodeBOMLine,String ID) throws TCException { +// AIFComponentContext[] nodeBOMLineChild=nodeBOMLine.getChildren(); +// if(getID(nodeBOMLine)==ID||getID(nodeBOMLine).equals(ID)) { +// lightRow.add(Integer.valueOf(getID(nodeBOMLine))); +// } +// if(nodeBOMLineChild.length==0||nodeBOMLineChild==null) { +// return; +// }else { +// for(AIFComponentContext node:nodeBOMLineChild) { +// getNode(((TCComponentBOMLine)node.getComponent()), ID); +// } +// } +// } + + private void getNode(AbstractViewableNode Node,String ID,AbstractViewableTreeTable m_tree) throws NumberFormatException, TCException { + AbstractViewableNode nextNode=(AbstractViewableNode) Node.getNextNode(); + TCComponentBOMLine NodeBOMLine=((IViewableNode) Node).getBOMLine(); + String IDS=getID(NodeBOMLine); + if(IDS==ID||getID(NodeBOMLine).equals(ID)) { + selectRow=m_tree.getRowForNode(Node); + return; + } + if(nextNode!=null){ + getNode(nextNode,ID,m_tree); + } + } + + private String getID(TCComponentBOMLine bomline) throws TCException { + //获取ID,若ID内存在“-”则只取“-”前面的字符 + String ID=((TCComponentBOMLine)bomline).getItemRevision().getStringProperty("item_id"); + if(ID.indexOf("-")>=0) { + return ID.split("-")[0]; + } + return ID; + } + + //获取相同的 + private void getSameID() { + for(int i=0;i List=new ArrayList(); + + if(true) { + //comp1是订单bom + for(int i=0;i BOMLine; +// "assembly_item": "CAL1600A01", +// "assembly_item_exist": true, +// "locator_integrity": false, +// "bom_exist": true, +// "route_exist": true, + public String getAssembly_item() { + return assembly_item; + } + public void setAssembly_item(String assembly_item) { + this.assembly_item = assembly_item; + } + public String getAssembly_item_exist() { + return assembly_item_exist; + } + public void setAssembly_item_exist(String assembly_item_exist) { + this.assembly_item_exist = assembly_item_exist; + } + public String getLocator_integrity() { + return locator_integrity; + } + public void setLocator_integrity(String locator_integrity) { + this.locator_integrity = locator_integrity; + } + public String getBom_exist() { + return bom_exist; + } + public void setBom_exist(String bom_exist) { + this.bom_exist = bom_exist; + } + public String getRoute_exist() { + return route_exist; + } + public void setRoute_exist(String route_exist) { + this.route_exist = route_exist; + } + public List getBOMLine() { + return BOMLine; + } + public void setBOMLine(List bOMLine) { + BOMLine = bOMLine; + } +} diff --git a/src/com/connor/erp/BomAddTransferToERP/BomAdd.java b/src/com/connor/erp/BomAddTransferToERP/BomAdd.java new file mode 100644 index 0000000..c740caf --- /dev/null +++ b/src/com/connor/erp/BomAddTransferToERP/BomAdd.java @@ -0,0 +1,36 @@ +package com.connor.erp.BomAddTransferToERP; + +import java.util.List; +import java.util.Map; + +public class BomAdd { + private String assembly_item; + + private String version; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + private List> BOMLine; + + public List> getBOMLine() { + return BOMLine; + } + + public void setBOMLine(List> bOMLine) { + BOMLine = bOMLine; + } + + public String getAssembly_item() { + return assembly_item; + } + + public void setAssembly_item(String assembly_item) { + this.assembly_item = assembly_item; + } +} diff --git a/src/com/connor/erp/BomAddTransferToERP/BomAddEntry.java b/src/com/connor/erp/BomAddTransferToERP/BomAddEntry.java new file mode 100644 index 0000000..3ec96cf --- /dev/null +++ b/src/com/connor/erp/BomAddTransferToERP/BomAddEntry.java @@ -0,0 +1,26 @@ +package com.connor.erp.BomAddTransferToERP; + +import java.util.List; +import java.util.Map; + +public class BomAddEntry { + private String assembly_item; + + private List> BOMLine; + + public List> getBOMLine() { + return BOMLine; + } + + public void setBOMLine(List> bOMLine) { + BOMLine = bOMLine; + } + + public String getAssembly_item() { + return assembly_item; + } + + public void setAssembly_item(String assembly_item) { + this.assembly_item = assembly_item; + } +} diff --git a/src/com/connor/erp/BomAddTransferToERP/BomAddImportXMLReader.java b/src/com/connor/erp/BomAddTransferToERP/BomAddImportXMLReader.java new file mode 100644 index 0000000..321fa2d --- /dev/null +++ b/src/com/connor/erp/BomAddTransferToERP/BomAddImportXMLReader.java @@ -0,0 +1,139 @@ + package com.connor.erp.BomAddTransferToERP; + + import java.io.File; + import java.io.FileInputStream; + import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.xml.parsers.DocumentBuilder; + import javax.xml.parsers.DocumentBuilderFactory; + import javax.xml.parsers.ParserConfigurationException; + import org.w3c.dom.Document; + import org.w3c.dom.Element; + import org.w3c.dom.NamedNodeMap; + import org.w3c.dom.Node; + import org.w3c.dom.NodeList; + import org.xml.sax.SAXException; + +import com.connor.erpintegration.entity.BOMLineEntity; +import com.connor.erpintegration.entity.BomCheckResult; + +import net.sf.json.JSONObject; + + public class BomAddImportXMLReader { + +// public static String loadXMLDatas(File file, StringBuffer errorInfo) { +// /* 23 */ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); +// /* */ +// /* 25 */ Document doc = null; +// /* */ +// /* */ try { +// /* 28 */ DocumentBuilder builder = factory.newDocumentBuilder(); +// /* 29 */ doc = builder.parse(new FileInputStream(file)); +// /* 30 */ } catch (ParserConfigurationException e) { +// /* 31 */ e.printStackTrace(); +// /* 32 */ } catch (SAXException e) { +// /* 33 */ e.printStackTrace(); +// /* 34 */ } catch (IOException e) { +// /* 35 */ e.printStackTrace(); +// /* */ } +// /* */ +// /* 38 */ Element root = doc.getDocumentElement(); +// /* 39 */ if (root.getAttributeNode("hasWrong").getNodeValue().equals("false")) { +// /* 40 */ return "成功"; +// /* */ } +// /* 42 */ NodeList list = root.getChildNodes(); +// /* 43 */ return loadElements(list, errorInfo); +// /* */ } + public static void loadXMLDatas(File file, StringBuffer errorInfo) { +/* 23 */ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); +/* 25 */ Document doc = null; + try { +/* 28 */ DocumentBuilder builder = factory.newDocumentBuilder(); +/* 29 */ doc = builder.parse(new FileInputStream(file)); +/* 30 */ } catch (ParserConfigurationException e) { +/* 31 */ e.printStackTrace(); +/* 32 */ } catch (SAXException e) { +/* 33 */ e.printStackTrace(); +/* 34 */ } catch (IOException e) { +/* 35 */ e.printStackTrace(); + } +/* 38 */ Element root = doc.getDocumentElement(); +///* 39 */ if (root.getAttributeNode("hasWrong").getNodeValue().equals("false")) +///* 40 */ return "成功"; +///* 42 */ NodeList list = root.getChildNodes(); +///* 43 */ return loadElements(list, errorInfo); + } + + public static String loadElements(List list, StringBuffer errorInfo) { +/* 47 */ int listLen = list.size(); +/* 48 */ if (listLen == 0) +/* 49 */ return ""; +/* 51 */ int existBomNum = 0; +/* 52 */ for (int i = 0; i < listLen; i++) { +/* 53 */ BomCheckResult bomCheckResult = list.get(i); + Map classMap = new HashMap(); + classMap.put("BOMLine", BOMLineEntity.class); + BomCheckResult r =(BomCheckResult)JSONObject.toBean(JSONObject.fromObject(bomCheckResult),BomCheckResult.class,classMap); + if(r.getAssembly_item_exist().equals("true"))errorInfo.append(String.valueOf(r.getAssembly_item()) + " 在ERP生产组织中已经存在
"); + if(r.getBom_exist().equals("true")) { + existBomNum++; + errorInfo.append(String.valueOf(r.getAssembly_item()) + " BOM在ERP生产组织中已经存在
"); + } + if(r.getRoute_exist().equals("true"))errorInfo.append(String.valueOf(r.getAssembly_item()) + " 在ERP生产组织中已经存在
"); + if(!"true".equals(r.getLocator_integrity()))errorInfo.append(String.valueOf(r.getAssembly_item()) + " 装配件货位没定义
"); + List bomline = r.getBOMLine(); + for(BOMLineEntity b:bomline) { + if(b.getItem_exist().equals("false"))errorInfo.append(String.valueOf(b.getItem()) + " 对象在生产组织中不存在
"); + else if(b.getItem_valid().equals("false"))errorInfo.append(String.valueOf(b.getItem()) + " 对象在生产组织中失效
"); + if(!"true".equals(b.getLocator_integrity()))errorInfo.append(String.valueOf(b.getItem()) + " 装配子件定义了子库但没定义货位,请先登录ERP手动填写货位信息
"); + if(b.getOperation_seq_num_exist_in_route().equals("false"))errorInfo.append(String.valueOf(b.getItem()) + " " + b.getOperation_seq_num() + "工序 在装配件对应工艺路线中不存在!
"); + } + } +/* 122 */ System.out.println("existBomNum=" + existBomNum); +/* 123 */ if (existBomNum == listLen) +/* 124 */ return "所有的BOM都已经存在"; +/* 126 */ return ""; + } + +public static String loadXMLDatas(List results,StringBuffer errorInfo, Map canSendErpMap) { + // TODO Auto-generated method stub + int listLen = results.size(); +/* 48 */ if (listLen == 0) +/* 49 */ return ""; +/* 51 */ int existBomNum = 0; +/* 52 */ for (int i = 0; i < listLen; i++) { +/* 53 */ AssemblyResult bomCheckResult = results.get(i); + if(!bomCheckResult.getCanBOMImport().equals("false")) { + canSendErpMap.put(bomCheckResult.getAssembly_item(), "true"); + continue; + } + Map classMap = new HashMap(); + classMap.put("BOMLine", ItemResult.class); + AssemblyResult r =(AssemblyResult)JSONObject.toBean(JSONObject.fromObject(bomCheckResult),AssemblyResult.class,classMap); + if(r.getAssembly_item_exist().equals("false")) + errorInfo.append(String.valueOf(r.getAssembly_item()) + " 在ERP生产组织中已经存在
"); + if(r.getBom_exist().equals("true")) { + existBomNum++; + errorInfo.append(String.valueOf(r.getAssembly_item()) + " BOM在ERP生产组织中已经存在
"); + } + if(r.getRoute_exist().equals("true")) + errorInfo.append(String.valueOf(r.getAssembly_item()) + " 在ERP生产组织中已经存在
"); + if("false".equals(r.getLocator_integrity())) + errorInfo.append(String.valueOf(r.getAssembly_item()) + " 装配件货位没定义
"); + List bomline = r.getBOMLine(); + for(ItemResult b:bomline) { + if(b.getItem_exist().equals("false"))errorInfo.append(String.valueOf(b.getItem()) + " 对象在生产组织中不存在
"); + else if(b.getItem_valid().equals("false"))errorInfo.append(String.valueOf(b.getItem()) + " 对象在生产组织中失效
"); + if(!"true".equals(b.getLocator_integrity()))errorInfo.append(String.valueOf(b.getItem()) + " 装配子件定义了子库但没定义货位,请先登录ERP手动填写货位信息
"); + if(b.getOperation_seq_num_exist_in_route().equals("false"))errorInfo.append(String.valueOf(b.getItem()) + " " + b.getOperation_seq_num() + "工序 在装配件对应工艺路线中不存在!
"); + } + } +/* 122 */ System.out.println("existBomNum=" + existBomNum); +/* 123 */ if (existBomNum == listLen) +/* 124 */ return "所有的BOM都已经存在"; +/* 126 */ return ""; + } + } diff --git a/src/com/connor/erp/BomAddTransferToERP/BomAddTransferCommand.java b/src/com/connor/erp/BomAddTransferToERP/BomAddTransferCommand.java new file mode 100644 index 0000000..9447472 --- /dev/null +++ b/src/com/connor/erp/BomAddTransferToERP/BomAddTransferCommand.java @@ -0,0 +1,46 @@ +/* */ package com.connor.erp.BomAddTransferToERP; +/* */ +/* */ import com.connor.erp.BomImport.BomTransferCommand; +/* */ import com.connor.erp.toolkit.AimType; +/* */ import com.teamcenter.rac.aif.AbstractAIFUIApplication; +/* */ import com.teamcenter.rac.kernel.TCSession; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class BomAddTransferCommand +/* */ extends BomTransferCommand +/* */ { +/* */ public BomAddTransferCommand(TCSession pSession, AbstractAIFUIApplication app) { +/* 28 */ super(pSession, app); +// BomAddTransferDialog dialog=new BomAddTransferDialog(pSession,app,null,null,null); +/* 29 */ postDialog(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void postDialog() { +/* 37 */ checkTarget(AimType.add); +/* */ } +/* */ } + + +/* Location: C:\Users\cyh\Documents\WeChat Files\wxid_ztg4pdvd5bjn12\FileStorage\File\2022-03\com.origin.erpintegration_1.0.0.jar!\com\origin\erp\BomAddTransferToERP\BomAddTransferCommand.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 1.1.3 + */ \ No newline at end of file diff --git a/src/com/connor/erp/BomAddTransferToERP/BomAddTransferDialog.java b/src/com/connor/erp/BomAddTransferToERP/BomAddTransferDialog.java new file mode 100644 index 0000000..aad96df --- /dev/null +++ b/src/com/connor/erp/BomAddTransferToERP/BomAddTransferDialog.java @@ -0,0 +1,481 @@ +/* */ package com.connor.erp.BomAddTransferToERP; +import com.connor.erp.BomChgTransferToERP.DBUtils; +import com.connor.erp.BomChgTransferToERP.UserList; +/* */ +/* */ import com.connor.erp.BomImport.BomTransferDialog; +/* */ import com.connor.erp.BomImport.TransferBomXMLWriter; +/* */ import com.connor.erp.BomImport.ValidateBomXMLWriter; +import com.connor.erp.ItemAddTransferSendToERP.SendToERPDialog; +/* */ import com.connor.erp.ProcessImport.ValidateFailDialog; +/* */ import com.connor.erp.materialquery.ViewStockOfERP.CMap; +/* */ import com.connor.erp.materialquery.ViewStockOfERP.CMap2; +/* */ import com.connor.erp.materialquery.ViewStockOfERP.CTable; +import com.connor.erp.processresource.EquipmentAcquiredFromERP.TCPreferenceUitl; +/* */ import com.connor.erp.toolkit.ActionType; +/* */ import com.connor.erp.toolkit.AimType; +/* */ import com.connor.erp.toolkit.FileType; +import com.connor.erp.toolkit.HttpUtil; +/* */ import com.connor.erp.toolkit.UtilApi; +///* */ import com.connor.tcerp.conn.PlmErpIntegration; +/* */ import com.teamcenter.rac.aif.AbstractAIFUIApplication; +/* */ import com.teamcenter.rac.kernel.TCComponentForm; +/* */ import com.teamcenter.rac.kernel.TCComponentItemRevision; +/* */ import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +/* */ import com.teamcenter.rac.kernel.TCSession; +/* */ import com.teamcenter.rac.kernel.TCUserService; +/* */ import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.tabbedpane.iTabbedPane; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/* */ import java.awt.BorderLayout; +/* */ import java.awt.Dimension; +/* */ import java.awt.event.ActionEvent; +/* */ import java.awt.event.ActionListener; +/* */ import java.io.File; +/* */ import java.io.FileNotFoundException; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +/* */ import java.util.List; +/* */ import java.util.Map; +import java.util.ResourceBundle; +import java.util.Map.Entry; +import java.util.Set; +/* */ import java.util.Vector; +/* */ import javax.swing.JButton; +/* */ import javax.swing.JPanel; +/* */ import javax.swing.JScrollPane; +/* */ import javax.swing.JTable; +/* */ import javax.swing.SwingUtilities; +/* */ import javax.swing.table.DefaultTableModel; +/* */ import javax.swing.table.TableModel; +/* */ import javax.xml.parsers.ParserConfigurationException; +/* */ import javax.xml.transform.TransformerException; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +public class BomAddTransferDialog +/* */ extends BomTransferDialog +/* */ { +/* */ private static final long serialVersionUID = 1L; +/* */ private String xmlFilePath; +/* 63 */ private String user_id = ""; +/* */ private Vector title; +/* */ private JButton btnBomCheck; +/* */ private JButton btnBomImportERP; +/* */ private JButton btnCancel; +/* */ private JTable table; + private String msgString; + private ResourceBundle resource = ResourceBundle.getBundle("tcUser_erpUser"); +/* */ private static String erpPreference = "connor_tc_to_erp_url"; + +private String canAllImport; + +private Map canSendErpMap=new HashMap(); +private int maxWidth = 0; +private String bomAddCheckSvr = "BOMAddCheck"; +/* */ public BomAddTransferDialog(TCSession session, AbstractAIFUIApplication app, List itemRevision, Map>> map, Vector> data) { +/* 71 */ super(session, app, itemRevision, map, data); +/* 72 */ System.out.println("BomAddTransferDialog::map==============" + map); +/* 73 */ System.out.println("BomAddTransferDialog::itemRevision==============" + itemRevision); +/* 74 */ System.out.println("BomAddTransferDialog::data==============" + data); + +// Object obj[] = new Object[1]; +// obj[0] = 1; +///* 203 */ TCUserService service = BomAddTransferDialog.this.session.getUserService(); +///* 204 */ int revNum = BomAddTransferDialog.this.ItemRevision.size(); +///* 205 */ for (int i = 0; i < revNum; i++) { +///* */ try { +///* 207 */ service.call("openByPass", obj); +///* 208 */ TCComponentForm form = (TCComponentForm)((TCComponentItemRevision)BomAddTransferDialog.this.ItemRevision.get(i)).getRelatedComponent("IMAN_master_form_rev"); +// System.out.println("itemRevision"+ItemRevision.get(i)); +///* 209 */ form.setLogicalProperty("nhl8_BOMimpSucc", true); +///* 210 */ form.save(); +///* 211 */ service.call("closeByPass", obj); +///* 212 */ } catch (TCException e1) { +///* 213 */ e1.printStackTrace(); +///* */ } +///* */ } +/* 75 */ initUI(); +/* */ } +/* */ +/* */ +/* */ private void initUI() { + System.out.println("showdialog"); +/* 80 */ this.setTitle("新增BOM"); +/* 81 */ this.btnBomCheck = new JButton("BOM导入验证"); +/* 82 */ this.btnBomImportERP = new JButton("BOM导入ERP系统"); +/* 83 */ this.btnCancel = new JButton("取消"); +/* 84 */ this.btnBomImportERP.setEnabled(false); +/* */ +/* 86 */ JPanel paneButton = new JPanel(); +/* 87 */ paneButton.add(this.btnBomCheck); +/* 88 */ paneButton.add(this.btnBomImportERP); +/* 89 */ paneButton.add(this.btnCancel); +/* */ +/* 91 */ this.title = new Vector(); +/* 92 */ this.title.add("组织ID"); +/* 93 */ this.title.add("装配件编码"); +/* 94 */ this.title.add("子件编码"); +/* 95 */ this.title.add("工序序号"); +/* 96 */ this.title.add("数量"); + +//Vector test2=new Vector(); +//test2.add("id2"); +//test2.add("bm123452"); +///* */ test2.add("zj1234562"); +//test2.add("xh123452"); +//test2.add("122"); +// Vector test=new Vector(); +// test.add("id"); +// test.add("bm12345"); +///* */ test.add("zj123456"); +//test.add("xh12345"); +//test.add("1"); +//data=new Vector(); +//data.add(test); +//data.add(test2); +/* 98 */ CMap2 cMap2 = new CMap2(); +/* */ +/* 100 */ DefaultTableModel model = new DefaultTableModel(this.data, this.title); +/* 101 */ this.table = (JTable)new CTable((CMap)cMap2, model) +/* */ { +/* */ private static final long serialVersionUID = 1L; +/* */ +/* */ +/* */ +/* */ public boolean isCellEditable(int row, int column) { +/* 108 */ return false; +/* */ } +/* */ }; +/* 111 */ int totalWidth = UtilApi.FitTableColumns(this.table); + + this.maxWidth = totalWidth + 100; + setPreferredSize(new Dimension(maxWidth,500)); + this.setResizable(true); +/* 112 */ JPanel paneMain = new JPanel(new BorderLayout()); +/* 113 */ paneMain.add("Center", new JScrollPane(this.table)); +/* 114 */ paneMain.add("South",paneButton); + +/* 115 */ getContentPane().add(paneMain); +/* 116 */ +/* */ + +/* 118 */ this.btnBomCheck.addActionListener(new ActionListener() +/* */ { +/* */ public void actionPerformed(ActionEvent e) +/* */ { + List entryMap=new ArrayList(); + Map> bomMap=new HashMap>(); + + List> list=new ArrayList>(); + + String assembly = BomAddTransferDialog.this.table.getValueAt(0, 1).toString(); + BomAddEntry bomAddEntry=new BomAddEntry(); +/* 122 */ int rowCount = BomAddTransferDialog.this.table.getRowCount(); +/* 123 */ for (int i = 0; i < rowCount; i++) { + bomAddEntry.setAssembly_item(assembly.split("/")[0]); + + if(assembly!=BomAddTransferDialog.this.table.getValueAt(i, 1).toString()) { + entryMap.add(bomAddEntry); + bomAddEntry.setBOMLine(list); + bomAddEntry=new BomAddEntry(); + assembly=BomAddTransferDialog.this.table.getValueAt(i, 1).toString(); + list=new ArrayList>(); + } + if(i==rowCount-1) { + entryMap.add(bomAddEntry); + bomAddEntry.setBOMLine(list); + bomAddEntry=new BomAddEntry(); + } + + +/* 124 */ if (BomAddTransferDialog.this.table.getValueAt(i, 3).toString().trim().equals("")) { +/* 125 */ MessageBox.post(BomAddTransferDialog.this.application.getDesktop().getShell(), "工序序号不能为空!", "错误", 1); +/* */ return; +/* */ } + Map jsonMap=new HashMap(); + jsonMap.put("item", BomAddTransferDialog.this.table.getValueAt(i, 2).toString().split("/")[0]); + jsonMap.put("operation_seq_num",BomAddTransferDialog.this.table.getValueAt(i, 3).toString().split("_")[0]); + list.add(jsonMap); +/* */ } + bomMap.put("BOM", entryMap); + + + + +// try { +// connection = DBUtils.ConnectionFun(session); +// if(connection!=null) { +// DBUtils.InsertData("ps123", "PBOM", "taskNum", user_id, "a", connection); +// }else { +// System.out.println("connection==null"); +// } +// } catch (SQLException e2) { +// // TODO Auto-generated catch block +// e2.printStackTrace(); +// } +// JSONObject fromObject = JSONObject.fromObject(bomMap); + List results = doPost(bomMap,"BOMAddCheck"); +// System.out.println(fromObject.toString()); +/* */ try { +/* 130 */ BomAddTransferDialog.this.user_id = BomAddTransferDialog.this.session.getUser().getProperty("user_id"); +/* 131 */ } catch (TCException ex) { +/* 132 */ ex.printStackTrace(); +/* */ } + +// 生成json + +///* 134 */ String xmlFileName = System.getProperty("java.io.tmpdir") + File.separator + BomAddTransferDialog.this.user_id + "_" + UtilApi.getCurrentTime() + "_validate_bom_add"; +///* 135 */ String xmlFilePath = xmlFileName + ".xml"; +///* */ +///* */ try { +///* 138 */ ValidateBomXMLWriter.createXML(BomAddTransferDialog.this.user_id, xmlFilePath, FileType.bom, AimType.add, BomAddTransferDialog.this.map); +///* 139 */ } catch (FileNotFoundException e1) { +///* 140 */ e1.printStackTrace(); +///* 141 */ } catch (ParserConfigurationException e1) { +///* 142 */ e1.printStackTrace(); +///* 143 */ } catch (TransformerException e1) { +///* 144 */ e1.printStackTrace(); +///* */ } +///* */ PlmErpIntegration.validateData(xmlFilePath) +///* 147 */ String result = UtilApi.getErrorInfoFromCode(8); +/* 148 */ if (!msgString.equals("succ")) { +/* 149 */ MessageBox.post(BomAddTransferDialog.this.application.getDesktop().getShell(), msgString, "验证出现错误", 1); +/* */ } else { +/* 151 */ StringBuffer errorInfo = new StringBuffer(""); +//String returnInfo=""; +/* 152 */ String returnInfo = BomAddImportXMLReader.loadXMLDatas(results,errorInfo,canSendErpMap); +//String returnInfo=""; + + + + Set> entries = canSendErpMap.entrySet(); +/* 153 */ if (errorInfo.toString().equals("") ||canAllImport.equals("true")) { +/* 154 */ MessageBox.post(BomAddTransferDialog.this.application.getDesktop().getShell(), "导入验证成功,可以执行导入操作!", "成功", 2); +/* 155 */ BomAddTransferDialog.this.btnBomImportERP.setEnabled(true); +/* */ } +/* 157 */ else if (returnInfo.equals("所有的BOM都已经存在")) { +/* 158 */ BomAddTransferDialog.this.dispose(); +/* 159 */ Object[] obj = new Object[1]; +/* 160 */ obj[0] = Integer.valueOf(11); +/* 161 */ TCUserService service = BomAddTransferDialog.this.session.getUserService(); +/* 162 */ int revNum = BomAddTransferDialog.this.ItemRevision.size(); +/* 163 */ for (int j = 0; j < revNum; j++) { +/* */ try { +/* 165 */ service.call("openByPass", obj); +/* 166 */ ((TCComponentItemRevision)BomAddTransferDialog.this.ItemRevision.get(j)).getRelatedComponent("IMAN_master_form_rev").setLogicalProperty("nhl8_BOMimpSucc", true); +/* 167 */ service.call("closeByPass", obj); +/* 168 */ } catch (TCException e1) { +/* 169 */ e1.printStackTrace(); +/* */ } +/* */ } +/* 172 */ MessageBox.post(BomAddTransferDialog.this.application.getDesktop().getShell(), "工艺BOM已经存在,不可重复导入;如需变更,请执行变更导入!", "警告", 2); +/* */ }else if (entries.size()>0) { + SwingUtilities.invokeLater((Runnable)new ValidateFailDialog("验证失败,请查看详细信息:", "警告", errorInfo.toString())); + } + else { +/* 174 */ SwingUtilities.invokeLater((Runnable)new ValidateFailDialog("验证失败,请查看详细信息:", "警告", errorInfo.toString())); +/* */ } +/* */ } +/* */ } +/* */ }); +/* */ +/* */ +/* 181 */ this.btnBomImportERP.addActionListener(new ActionListener() +/* */ { +/* */ public void actionPerformed(ActionEvent e) +/* */ { + Map userMap=new HashMap(); + userMap.put("TCUser", user_id); + List doPost = DBUtils.doPost(userMap, session); + UserList userList = doPost.get(0); + List entryMap=new ArrayList(); + + Map bomMap=new HashMap(); + List> list=new ArrayList>(); +// if(resource.containsKey(user_id)) { +// bomMap.put("creater", resource.getString(user_id)); +// }else { + bomMap.put("creater", userList.getERP_USER_CODE()); +// } + String assembly = BomAddTransferDialog.this.table.getValueAt(0, 1).toString(); + BomAdd bomAddEntry=new BomAdd(); + int indx=0; + String revisionString=""; + TCComponentItemRevision rev = ItemRevision.get(indx); + try { + String object_string = rev.getStringProperty("object_string"); + System.out.println(object_string); + if(object_string.equals(assembly.split(" ")[0])) { + revisionString=rev.getStringProperty("item_revision_id"); + } + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + + int rowCount = BomAddTransferDialog.this.table.getRowCount(); + for (int i = 0; i < rowCount; i++) { + bomAddEntry.setAssembly_item(assembly.split("/")[0]); + bomAddEntry.setVersion(revisionString); + if(assembly!=BomAddTransferDialog.this.table.getValueAt(i, 1).toString()) { + entryMap.add(bomAddEntry); + bomAddEntry.setBOMLine(list); + bomAddEntry=new BomAdd(); + assembly=BomAddTransferDialog.this.table.getValueAt(i, 1).toString(); + try { + indx++; + TCComponentItemRevision rev2 = ItemRevision.get(indx); + String object_string = rev2.getStringProperty("object_string"); + if(object_string.equals(assembly.split(" ")[0])) { + revisionString=rev2.getStringProperty("item_revision_id"); + bomAddEntry.setVersion(revisionString); + + } + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + list=new ArrayList>(); + } + if(i==rowCount-1) { + entryMap.add(bomAddEntry); + bomAddEntry.setBOMLine(list); + bomAddEntry=new BomAdd(); + } + + + if (BomAddTransferDialog.this.table.getValueAt(i, 3).toString().trim().equals("")) { + MessageBox.post(BomAddTransferDialog.this.application.getDesktop().getShell(), "工序序号不能为空!", "错误", 1); + return; + } + + Map jsonMap=new HashMap(); + jsonMap.put("item", BomAddTransferDialog.this.table.getValueAt(i, 2).toString().split("/")[0]); + jsonMap.put("operation_seq_num",BomAddTransferDialog.this.table.getValueAt(i, 3).toString()); + jsonMap.put("quantity", BomAddTransferDialog.this.table.getValueAt(i, 4).toString()); + list.add(jsonMap); + } + + BomAddTransferOperation operation=new BomAddTransferOperation(application,session,entryMap,bomMap,BomAddTransferDialog.this); + session.queueOperation(operation); +// for(BomAdd bAdd:entryMap) { +// List entryMap2=new ArrayList(); +// entryMap2.add(bAdd); +// bomMap.put("BOM", entryMap2); +//// String task_num="task_num"; +// String task_num= doPost1(bomMap,"BOMAdd"); +/////* 197 */ String result1 = UtilApi.getErrorInfoFromCode(8); +///* 198 */ if (!msgString.equals("succ")) { +///* 199 */ SwingUtilities.invokeLater((Runnable)new ValidateFailDialog("验证失败,请查看详细信息:", "警告", msgString)); +///* */ } else { +///* 201 */ Object obj[] = new Object[1]; +// obj[0] = 1; +///* 203 */ TCUserService service = BomAddTransferDialog.this.session.getUserService(); +///* 204 */ int revNum = BomAddTransferDialog.this.ItemRevision.size(); +// DBUtils.InsertData(bAdd.getAssembly_item(), "PBOM", task_num, user_id, bAdd.getVersion(), session); +///* 205 */ for (int i = 0; i < revNum; i++) { +///* */ try { +///* 207 */ service.call("openByPass", obj); +///* 208 */ TCComponentForm form = (TCComponentForm)((TCComponentItemRevision)BomAddTransferDialog.this.ItemRevision.get(i)).getRelatedComponent("IMAN_master_form_rev"); +///* 209 */ form.setLogicalProperty("nhl8_BOMimpSucc", true); +///* 210 */ form.save(); +///* 211 */ service.call("closeByPass", obj); +///* 212 */ } catch (TCException e1) { +///* 213 */ e1.printStackTrace(); +///* */ } +///* */ } +///* 216 */ +///* 217 */ +///* */ } +// } +// MessageBox.post(BomAddTransferDialog.this.application.getDesktop().getShell(), "任务已成功加入ERP导入队列,请及时通过【导入结果查询】—【PBOM】功能查询导入结果", "成功", 2); +// BomAddTransferDialog.this.dispose(); +/* */ } +/* */ }); +/* */ +/* 222 */ this.btnCancel.addActionListener(new ActionListener() +/* */ { +/* */ public void actionPerformed(ActionEvent e) +/* */ { +/* 226 */ BomAddTransferDialog.this.dispose(); +/* */ } +/* */ }); +this.centerToScreen(); +this.showDialog(); +this.setVisible(true); +System.out.println("end"); +/* */ } +private List doPost(Map itemCheckMap, String svr) { + HashMap preferenceHashMap = TCPreferenceUitl.getPreferenceHashMap(session, TCPreferenceService.TC_preference_site, erpPreference); + String url = preferenceHashMap.get("url"); + String token = preferenceHashMap.get("token"); + JSONObject itemCheckJson = JSONObject.fromObject(itemCheckMap); + String sid = null; + try { + System.out.println("开始发送请求"); + String args = itemCheckJson.toString(); + System.out.println(args); + token = URLEncoder.encode(token,"UTF-8"); + svr = URLEncoder.encode(svr,"UTF-8"); + args = URLEncoder.encode(args,"UTF-8"); + String param = "usr="+token+"&svr="+svr+"&args="+args; + + System.out.println("url=============="+url); + System.out.println("param==========="+args); + String response = HttpUtil.doPost(url, param); //.doGet(url+"?"+param) +// System.out.println("请求结果================"+response); + + JSONObject jsonObject = JSONObject.fromObject(response); + System.out.println("json格式==============="+jsonObject); + msgString = jsonObject.getString("msg"); + if(jsonObject.has("cont")) { + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); + canAllImport = jsonObject2.getString("canAllImport"); + if(jsonObject2.has("checkResult")) { + JSONArray jsonObject3 = jsonObject2.getJSONArray("checkResult"); + List list = JSONArray.toList(jsonObject3,AssemblyResult.class); + return list; + } + } + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return null; +} + + +/* */ } + + +/* Location: C:\Users\cyh\Documents\WeChat Files\wxid_ztg4pdvd5bjn12\FileStorage\File\2022-03\com.origin.erpintegration_1.0.0.jar!\com\origin\erp\BomAddTransferToERP\BomAddTransferDialog.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 1.1.3 + */ \ No newline at end of file diff --git a/src/com/connor/erp/BomAddTransferToERP/BomAddTransferHandler.java b/src/com/connor/erp/BomAddTransferToERP/BomAddTransferHandler.java new file mode 100644 index 0000000..4a5f27f --- /dev/null +++ b/src/com/connor/erp/BomAddTransferToERP/BomAddTransferHandler.java @@ -0,0 +1,39 @@ +/* */ package com.connor.erp.BomAddTransferToERP; +/* */ +/* */ import com.teamcenter.rac.aif.AbstractAIFUIApplication; +/* */ import com.teamcenter.rac.aifrcp.AIFUtility; +/* */ import com.teamcenter.rac.kernel.TCSession; +/* */ import org.eclipse.core.commands.AbstractHandler; +/* */ import org.eclipse.core.commands.ExecutionEvent; +/* */ import org.eclipse.core.commands.ExecutionException; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class BomAddTransferHandler +/* */ extends AbstractHandler +/* */ { +/* */ public Object execute(ExecutionEvent event) throws ExecutionException { +/* 23 */ AbstractAIFUIApplication application = AIFUtility.getCurrentApplication(); +/* 24 */ TCSession session = (TCSession)application.getSession(); +/* 25 */ BomAddTransferCommand command = new BomAddTransferCommand(session, application); +/* */ try { +/* 27 */ command.executeModal(); +/* 28 */ } catch (Exception e) { +/* 29 */ e.printStackTrace(); +/* */ } +/* 31 */ return null; +/* */ } +/* */ } + + +/* Location: C:\Users\cyh\Documents\WeChat Files\wxid_ztg4pdvd5bjn12\FileStorage\File\2022-03\com.origin.erpintegration_1.0.0.jar!\com\origin\erp\BomAddTransferToERP\BomAddTransferHandler.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 1.1.3 + */ \ No newline at end of file diff --git a/src/com/connor/erp/BomAddTransferToERP/BomAddTransferOperation.java b/src/com/connor/erp/BomAddTransferToERP/BomAddTransferOperation.java new file mode 100644 index 0000000..6f7324f --- /dev/null +++ b/src/com/connor/erp/BomAddTransferToERP/BomAddTransferOperation.java @@ -0,0 +1,334 @@ +package com.connor.erp.BomAddTransferToERP; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Label; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.Map.Entry; + +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; + +import com.connor.erp.BomChgTransferToERP.DBUtils; +import com.connor.erp.ProcessImport.ValidateFailDialog; +import com.connor.erp.processresource.EquipmentAcquiredFromERP.TCPreferenceUitl; +import com.connor.erp.toolkit.HttpUtil; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.commands.newproxylink.ArrayOfXMLParameterContainer; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSTemplateClassAttrMapping; +import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONObject; + +public class BomAddTransferOperation extends AbstractAIFOperation{ + private final String CONNOR_TC_TO_ERP_PART_TIME = "connor_tc_to_erp_part_time"; + private String msgString; + private AbstractAIFUIApplication app; + private TCSession session; + private List entryMap=new ArrayList(); + private Map bomMap=new HashMap(); + private String user_id; + private AbstractAIFDialog dialog; + private String erpPreference = "connor_tc_to_erp_url"; + private PreparedStatement stmt; + private Connection connectionFun; + private ResultSet r ; + private ResourceBundle resource = ResourceBundle.getBundle("tcUser_erpUser"); + public BomAddTransferOperation(AbstractAIFUIApplication app,TCSession session,List entryMap,Map bomMap,AbstractAIFDialog dialog) { + this.app=app; + this.session=session; + this.entryMap=entryMap; + this.bomMap=bomMap; + this.dialog=dialog; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + user_id = session.getUser().getProperty("user_id"); + String timeout = session.getPreferenceService().getStringValue(CONNOR_TC_TO_ERP_PART_TIME); + if(timeout!=null&&timeout.length()>0) { + System.out.println("超时时间为"+timeout+"秒!"); + Daemon daemon = new Daemon(new Thread() { + public void run() { + WaitingDialog dia = new WaitingDialog(app.getDesktop(), "INFOMATION", "正在导入ERP..."); + dia.setAlwaysOnTop(true);//设置在窗口最前端 + dia.setVisible(true); + boolean flag = false; + try { + flag = importItemToERP(); + + }catch (InterruptedException e) { + // TODO Auto-generated catch block +// e.printStackTrace(); + dia.setVisible(false); + try { + if(r!=null) { + r.close(); + } + if(stmt!=null) { + stmt.close(); + } + if(connectionFun!=null) { + connectionFun.close(); + } + + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + MessageBox.post("导入超时!", "", MessageBox.INFORMATION); + return; + }catch(Exception e) { + + + e.printStackTrace(); + } + if (flag) { + dia.setVisible(false); + MessageBox.post("导入成功! 如需查询导入状态,请在“ERP集成”—“ERP任务导入记录”中查找", "发送到ERP成功", 2); + } else { + dia.setVisible(false); + try { + if(r!=null) { + r.close(); + } + if(stmt!=null) { + stmt.close(); + } + if(connectionFun!=null) { + connectionFun.close(); + } + + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + MessageBox.post("导入失败!", "", MessageBox.INFORMATION); + } + }; + },new BigDecimal(timeout)); + new Thread(daemon).start(); + }else { + MessageBox.post("请联系管理员配置"+CONNOR_TC_TO_ERP_PART_TIME+"首选项","",MessageBox.INFORMATION); + } + + + + +// r.close(); +// stmt.close(); +// connectionFun.close(); + + } + class Daemon implements Runnable { + private Thread thread; + private BigDecimal time; + + public Daemon(Thread r, BigDecimal t) { + thread = r; + time = t; + } + + @Override + public void run() { + this.thread.start(); + while (true) { + try { + Thread.sleep(time.multiply(new BigDecimal("1000")).longValue()); + } catch (InterruptedException e) { + e.printStackTrace(); + } + thread.interrupt(); + } + } + + } + class WaitingDialog extends com.teamcenter.rac.aif.AbstractAIFDialog { + private static final long serialVersionUID = 1L; + public JPanel panel; + JProgressBar progressBar = null; + + public WaitingDialog(Frame arg0, String title, String message) { + super(arg0, title); + this.setModal(false); + + panel = new JPanel(new BorderLayout()); + + /* + * JLabel label = new JLabel(message); System.out.println("message:"+message); + * System.out.println("label:"+label); panel.add(label); + */ + + progressBar = new JProgressBar(SwingConstants.HORIZONTAL); + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + + panel.add(BorderLayout.CENTER, new Label(message)); + panel.add(BorderLayout.SOUTH, progressBar); + + panel.setPreferredSize(new Dimension(350, 60)); + + this.getContentPane().add(panel); + + centerToScreen(); + + pack(); + + } + } + protected boolean importItemToERP() throws InterruptedException, Exception { + // TODO Auto-generated method stub + List taskNums=new ArrayList(); + + String sql = "select ImpResult from connor_ERP_record where TaskNumber =?"; + Map> map=new HashMap>(); + for(BomAdd bAdd:entryMap) { + List entryMap2=new ArrayList(); + entryMap2.add(bAdd); + bomMap.put("BOM", entryMap2); +// String task_num="task_num"; + String task_num= doPost1(bomMap,"BOMAdd"); + if (!msgString.equals("succ")) { + SwingUtilities.invokeLater((Runnable)new ValidateFailDialog("验证失败,请查看详细信息:", "警告", msgString)); + } else { + DBUtils.InsertData(bAdd.getAssembly_item(), "PBOM", task_num, user_id, bAdd.getVersion(), session); + List itemMap=new ArrayList(); + itemMap.add(bAdd.getAssembly_item()); + itemMap.add(bAdd.getVersion()); + map.put(task_num,itemMap); +// Object obj[] = new Object[1]; +// obj[0] = 1; +// TCUserService service = session.getUserService(); +// service.call("openByPass", obj); +// TCComponentItemRevision itemRevision = DBUtils.getItemRevision(session,bAdd.getAssembly_item(),bAdd.getVersion()); +// TCComponentForm form = (TCComponentForm) itemRevision.getRelatedComponent("IMAN_master_form_rev"); +// form.setLogicalProperty("nhl8_BOMimpSucc", true); +// service.call("closeByPass", obj); + taskNums.add(task_num); + } + } + + boolean allSucc=false; +// taskNums.add("03e72c4b-d3c6-4969-a38e-85cafa3bb9bc"); + connectionFun = DBUtils.ConnectionFun(session); + while (!allSucc) { + + for(int i=0;i list = map.get(taskNums.get(i)); + Object obj[] = new Object[1]; + obj[0] = 1; + TCUserService service = session.getUserService(); + service.call("openByPass", obj); + TCComponentItemRevision itemRevision = DBUtils.getItemRevision(session,list.get(0),list.get(1)); + TCComponentForm form = (TCComponentForm) itemRevision.getRelatedComponent("IMAN_master_form_rev"); + form.setLogicalProperty("nhl8_BOMimpSucc", true); + System.out.println("回填属性itemid"+list.get(0)+"rev"+list.get(1)); + service.call("closeByPass", obj); + taskNums.remove(i); + i--; + }else if(impResult.contains("失败") || impResult.equals("任务id无效")){ + return false; + } + } + if(taskNums.size()==0) { + allSucc=true; + System.out.println("所有任务都已完成"); + } + + Thread.sleep(1000); + } + if(r!=null) { + r.close(); + } + if(stmt!=null) { + stmt.close(); + } + if(connectionFun!=null) { + connectionFun.close(); + } + + dialog.dispose(); + return true; + } + + private String doPost1(Map itemCheckMap, String svr) { + HashMap preferenceHashMap = TCPreferenceUitl.getPreferenceHashMap(session, TCPreferenceService.TC_preference_site, erpPreference); + String url = preferenceHashMap.get("url"); + String token = preferenceHashMap.get("token"); + JSONObject itemCheckJson = JSONObject.fromObject(itemCheckMap); + String sid = null; + try { + System.out.println("开始发送请求"); + String args = itemCheckJson.toString(); + System.out.println(args); + token = URLEncoder.encode(token,"UTF-8"); + svr = URLEncoder.encode(svr,"UTF-8"); + args = URLEncoder.encode(args,"UTF-8"); + String param = "usr="+token+"&svr="+svr+"&args="+args; + + System.out.println("url=============="+url); + System.out.println("param==========="+args); + String response = HttpUtil.doPost(url,param); +// System.out.println("请求结果================"+response); + + JSONObject jsonObject = JSONObject.fromObject(response); + System.out.println("json格式==============="+jsonObject); + msgString = jsonObject.getString("msg"); + if(jsonObject.has("cont")) { + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); + sid = jsonObject2.getString("sid"); + } + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return sid; + } + +} diff --git a/src/com/connor/erp/BomAddTransferToERP/ItemResult.java b/src/com/connor/erp/BomAddTransferToERP/ItemResult.java new file mode 100644 index 0000000..7180dc5 --- /dev/null +++ b/src/com/connor/erp/BomAddTransferToERP/ItemResult.java @@ -0,0 +1,54 @@ +package com.connor.erp.BomAddTransferToERP; + +import java.util.List; + +public class ItemResult { + + private String item; + private String operation_seq_num; + private String item_exist; + private String item_valid; + private String locator_integrity; + private String operation_seq_num_exist_in_route; + public String getItem() { + return item; + } + public void setItem(String item) { + this.item = item; + } + public String getOperation_seq_num() { + return operation_seq_num; + } + public void setOperation_seq_num(String operation_seq_num) { + this.operation_seq_num = operation_seq_num; + } + public String getItem_exist() { + return item_exist; + } + public void setItem_exist(String item_exist) { + this.item_exist = item_exist; + } + public String getItem_valid() { + return item_valid; + } + public void setItem_valid(String item_valid) { + this.item_valid = item_valid; + } + public String getLocator_integrity() { + return locator_integrity; + } + public void setLocator_integrity(String locator_integrity) { + this.locator_integrity = locator_integrity; + } + public String getOperation_seq_num_exist_in_route() { + return operation_seq_num_exist_in_route; + } + public void setOperation_seq_num_exist_in_route(String operation_seq_num_exist_in_route) { + this.operation_seq_num_exist_in_route = operation_seq_num_exist_in_route; + } + + + + + +} diff --git a/src/com/connor/erp/BomChgTransferToERP/BomChgImportXMLReader.java b/src/com/connor/erp/BomChgTransferToERP/BomChgImportXMLReader.java new file mode 100644 index 0000000..2499aa4 --- /dev/null +++ b/src/com/connor/erp/BomChgTransferToERP/BomChgImportXMLReader.java @@ -0,0 +1,231 @@ +package com.connor.erp.BomChgTransferToERP; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +import com.connor.erp.BomAddTransferToERP.AssemblyResult; +import com.connor.erp.BomAddTransferToERP.ItemResult; +import com.connor.erpintegration.entity.BOMLineEntity; +import com.connor.erpintegration.entity.BomCheckResult; + +import net.sf.json.JSONObject; + +public class BomChgImportXMLReader { + public static final String SEPARATOR = "|"; + + public static String loadXMLDatas(File file) { + /* 22 */ StringBuffer errorInfo = new StringBuffer(""); + /* 24 */ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + /* 26 */ Document doc = null; + try { + /* 29 */ DocumentBuilder builder = factory.newDocumentBuilder(); + /* 30 */ doc = builder.parse(new FileInputStream(file)); + /* 31 */ } catch (ParserConfigurationException e) { + /* 32 */ e.printStackTrace(); + /* 33 */ } catch (SAXException e) { + /* 34 */ e.printStackTrace(); + /* 35 */ } catch (IOException e) { + /* 36 */ e.printStackTrace(); + } + /* 39 */ Element element = doc.getDocumentElement(); + /* 40 */ NodeList list = element.getChildNodes(); +///* 41 */ loadElements(list, errorInfo); + /* 42 */ return errorInfo.toString(); + } + + public static String loadElements(List list) { + /* 46 */ if (list.size() == 0) + return ""; + StringBuffer errorInfo = new StringBuffer(); + for (int i = 0; i < list.size(); i++) { + BomCheckResult bomCheckResult = list.get(i); + Map classMap = new HashMap(); + classMap.put("BOMLine", BOMLineEntity.class); + BomCheckResult r = (BomCheckResult) JSONObject.toBean(JSONObject.fromObject(bomCheckResult), + BomCheckResult.class, classMap); + if (r.getAssembly_item_exist().equals("true")) + errorInfo.append(String.valueOf(r.getAssembly_item()) + " 在ERP生产组织中已经存在
"); + if (r.getBom_exist().equals("true")) + errorInfo.append(String.valueOf(r.getAssembly_item()) + " BOM在ERP生产组织中已经存在
"); + if (r.getRoute_exist().equals("true")) + errorInfo.append(String.valueOf(r.getAssembly_item()) + " 在ERP生产组织中已经存在
"); + if (!"true".equals(r.getLocator_integrity())) + errorInfo.append(String.valueOf(r.getAssembly_item()) + " 在ERP生产组织中已经存在
"); + List bomline = r.getBOMLine(); + for (BOMLineEntity b : bomline) { + if (b.getItem_exist().equals("false")) + errorInfo.append(String.valueOf(b.getItem()) + " 对象在生产组织中不存在
"); + else if (b.getItem_valid().equals("false")) + errorInfo.append(String.valueOf(b.getItem()) + " 对象在生产组织中失效
"); + if (!"true".equals(b.getLocator_integrity())) + errorInfo.append(String.valueOf(b.getItem()) + " 装配子件定义了子库但没定义货位,请先登录ERP手动填写货位信息
"); + if (b.getOperation_seq_num_exist_in_route().equals("false")) + errorInfo.append( + String.valueOf(b.getItem()) + " " + b.getOperation_seq_num() + "工序 在装配件对应工艺路线中不存在!
"); + } + } + return errorInfo.toString(); + } + + public static String loadElements(List list,String string) { + /* 46 */ if (list.size() == 0) + return ""; + StringBuffer errorInfo = new StringBuffer(); + for (int i = 0; i < list.size(); i++) { + AssemblyResult bomCheckResult = list.get(i); + Map classMap = new HashMap(); + classMap.put("BOMLine", ItemResult.class); + AssemblyResult r = (AssemblyResult) JSONObject.toBean(JSONObject.fromObject(bomCheckResult), + AssemblyResult.class, classMap); + String canBOMImport = r.getCanBOMImport(); + if(!canBOMImport.equals("false")) { + continue; + } + if (r.getAssembly_item_exist().equals("false")) { + errorInfo.append(String.valueOf(r.getAssembly_item()) + " 在ERP生产组织中已经存在
"); + System.out.println(r.getAssembly_item_exist()+"assembly_item_exist"); + } + + if (r.getBom_exist().equals("false")) + errorInfo.append(String.valueOf(r.getAssembly_item()) + " BOM在ERP生产组织中已经存在
"); + if (r.getRoute_exist().equals("false")) + errorInfo.append(String.valueOf(r.getAssembly_item()) + " 装配件没有ROUTE
"); + if (!"true".equals(r.getLocator_integrity())) + errorInfo.append(String.valueOf(r.getAssembly_item()) + " 在ERP生产组织中已经存在
"); + List bomline = r.getBOMLine(); + for (ItemResult b : bomline) { + if (b.getItem_exist().equals("false")) + errorInfo.append(String.valueOf(b.getItem()) + " 对象在生产组织中不存在
"); + else if (b.getItem_valid().equals("false")) + errorInfo.append(String.valueOf(b.getItem()) + " 对象在生产组织中失效
"); + if (!"true".equals(b.getLocator_integrity())) + errorInfo.append(String.valueOf(b.getItem()) + " 装配子件定义了子库但没定义货位,请先登录ERP手动填写货位信息
"); + if (b.getOperation_seq_num_exist_in_route().equals("false")) + errorInfo.append( + String.valueOf(b.getItem()) + " " + b.getOperation_seq_num() + "工序 在装配件对应工艺路线中不存在!
"); + } + } + return errorInfo.toString(); + } +/* */ public static void loadElements(List results, Vector> erpData, Vector vec) { +/* 43 */ if (results.size() == 0) { +/* */ return; +/* */ } +/* 46 */ for (int i = 0; i classMap = new HashMap(); + classMap.put("BOMLine", CompareLine.class); + CompareResult r =(CompareResult)JSONObject.toBean(JSONObject.fromObject(compareResult),CompareResult.class,classMap); + List bomLine = r.getBOMLine(); + for(int t=0;t rowData = new Vector(); + rowData.add("2"); + rowData.add(compareResult.getAssembly_item()); +// rowData.add(assembly_item); + rowData.add(compare.getItem()); +// rowData.add("item_name"); + rowData.add(compare.getOperation_seq_num()); + rowData.add(compare.getQuantity()); +// rowData.add(compare.getLineState()); + erpData.add(rowData); + int status = Integer.parseInt(compare.getLineState()); + String compare_status=""; + switch (status) { + case 0: + compare_status = "比较失败"; + break; + case 1: + compare_status = "新增"; + break; + case 2: + compare_status = "修改"; + break; + case 3: + compare_status = "删除"; + break; + case 4: + compare_status = "未改"; + vec.add(compare_status); + break; + } + rowData.add(compare_status); + } + +///* 48 */ NodeList childlist = node.getChildNodes(); +///* 49 */ int listSize = childlist.getLength(); +///* 50 */ String assembly_item_number_str = ""; +///* 51 */ for (int j = 0; j < listSize; j++) { +///* 52 */ Node childnode = childlist.item(j); +///* 53 */ String nodeName = childnode.getNodeName(); +///* 54 */ if (nodeName.equals("assembly_item_number")) { +///* 55 */ assembly_item_number_str = childnode.getTextContent(); +///* 56 */ } else if (nodeName.equals("component_item_number")) { +///* 57 */ NodeList component_item_number_child_node_list = childnode.getChildNodes(); +///* 58 */ for (int k = 0; k < component_item_number_child_node_list.getLength(); k++) { +///* 59 */ Node component_item_number_child_node = component_item_number_child_node_list.item(k); +///* 60 */ String component_item_number_nodeName = component_item_number_child_node.getNodeName(); +///* 61 */ if (component_item_number_nodeName.equals("item")) { +///* 62 */ Vector rowData = new Vector(); +///* 63 */ NodeList item_list = component_item_number_child_node.getChildNodes(); +///* 64 */ String item_name = ""; +///* 65 */ String operation_seq_num = ""; +///* 66 */ String item_quantity = ""; +///* 67 */ String compare_status = ""; +///* 68 */ for (int m = 0; m < item_list.getLength(); m++) { +///* 69 */ Node item = item_list.item(m); +///* 70 */ String node_name = item.getNodeName(); +///* 71 */ String node_value = item.getTextContent(); +///* 72 */ if (node_name.equals("item_name")) { +///* 73 */ item_name = node_value; +///* 74 */ } else if (node_name.equals("operation_seq_num")) { +///* 75 */ operation_seq_num = node_value; +///* 76 */ } else if (node_name.equals("item_quantity")) { +///* 77 */ item_quantity = node_value; +///* 78 */ } else if (node_name.equals("compare_status")) { +///* 79 */ int status = Integer.parseInt(node_value); +///* 80 */ switch (status) { +///* */ case 0: +///* 82 */ compare_status = "比较失败"; +///* */ break; +///* */ case 1: +///* 85 */ compare_status = "新增"; +///* */ break; +///* */ case 2: +///* 88 */ compare_status = "修改"; +///* */ break; +///* */ case 3: +///* 91 */ compare_status = "删除"; +///* */ break; +///* */ case 4: +///* 94 */ compare_status = "未改"; +///* 95 */ vec.add(compare_status); +///* */ break; +///* */ } +///* */ +///* */ +///* */ } +///* */ } +///* 102 */ +///* */ } +///* */ } +///* */ } +///* */ } +/* */ } +/* */ } +} diff --git a/src/com/connor/erp/BomChgTransferToERP/BomChgTransferCommand.java b/src/com/connor/erp/BomChgTransferToERP/BomChgTransferCommand.java new file mode 100644 index 0000000..7c6ed25 --- /dev/null +++ b/src/com/connor/erp/BomChgTransferToERP/BomChgTransferCommand.java @@ -0,0 +1,39 @@ +/* */ package com.connor.erp.BomChgTransferToERP; +/* */ +/* */ import com.connor.erp.BomImport.BomTransferCommand; +/* */ import com.connor.erp.toolkit.AimType; +/* */ import com.teamcenter.rac.aif.AbstractAIFUIApplication; +/* */ import com.teamcenter.rac.kernel.TCSession; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class BomChgTransferCommand +/* */ extends BomTransferCommand +/* */ { +/* */ public BomChgTransferCommand(TCSession pSession, AbstractAIFUIApplication application) { +/* 27 */ super(pSession, application); +/* 28 */ postDialog(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void postDialog() { +/* 36 */ checkTarget(AimType.chg); +/* */ } +/* */ } + diff --git a/src/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog.java b/src/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog.java new file mode 100644 index 0000000..d32f433 --- /dev/null +++ b/src/com/connor/erp/BomChgTransferToERP/BomChgTransferDialog.java @@ -0,0 +1,716 @@ + package com.connor.erp.BomChgTransferToERP; + + import com.connor.erp.BomAddTransferToERP.AssemblyResult; +import com.connor.erp.BomAddTransferToERP.BomAdd; +import com.connor.erp.BomAddTransferToERP.BomAddEntry; +import com.connor.erp.BomAddTransferToERP.BomAddTransferDialog; +import com.connor.erp.BomImport.BomTransferDialog; +// import com.connor.erp.BomImport.TransferBomXMLWriter; +// import com.connor.erp.BomImport.ValidateBomXMLWriter; + import com.connor.erp.ProcessImport.ValidateFailDialog; + import com.connor.erp.materialquery.ViewStockOfERP.CMap; +import com.connor.erp.materialquery.ViewStockOfERP.CMap2; +import com.connor.erp.materialquery.ViewStockOfERP.CTable; +import com.connor.erp.processresource.EquipmentAcquiredFromERP.TCPreferenceUitl; +// import com.connor.erp.materialquery.ViewStockOfERP.CMap; +// import com.connor.erp.materialquery.ViewStockOfERP.CMap2; +// import com.connor.erp.materialquery.ViewStockOfERP.CTable; +// import com.connor.erp.toolkit.ActionType; + import com.connor.erp.toolkit.AimType; + import com.connor.erp.toolkit.FileType; +import com.connor.erp.toolkit.HttpUtil; +import com.connor.erp.toolkit.UtilApi; +// import com.connor.tcerp.conn.PlmErpIntegration; + import com.teamcenter.rac.aif.AbstractAIFUIApplication; + import com.teamcenter.rac.kernel.TCComponentItemRevision; + import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; + import com.teamcenter.rac.kernel.TCUserService; + import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import java.awt.BorderLayout; + import java.awt.Color; + import java.awt.Component; + import java.awt.Dimension; + import java.awt.event.ActionEvent; + import java.awt.event.ActionListener; + import java.awt.event.ItemEvent; + import java.awt.event.ItemListener; + import java.io.File; + import java.io.FileNotFoundException; +import java.net.URL; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.HashMap; + import java.util.List; + import java.util.Map; +import java.util.ResourceBundle; +import java.util.Vector; + import javax.swing.Icon; + import javax.swing.ImageIcon; + import javax.swing.JButton; + import javax.swing.JCheckBox; + import javax.swing.JPanel; + import javax.swing.JScrollPane; + import javax.swing.JTabbedPane; + import javax.swing.JTable; + import javax.swing.SwingUtilities; + import javax.swing.event.ChangeEvent; + import javax.swing.event.ChangeListener; + import javax.swing.table.DefaultTableCellRenderer; + import javax.swing.table.DefaultTableModel; + import javax.swing.table.TableModel; + import javax.xml.parsers.ParserConfigurationException; + import javax.xml.transform.TransformerException; + + /* */ public class BomChgTransferDialog + /* */ extends BomTransferDialog + /* */ { + /* */ private static final long serialVersionUID = 1L; + /* 73 */ private String user_id = ""; + /* */ + /* */ private JCheckBox cbMerge; + /* */ + /* */ private JButton btnBomCheck; + /* */ + /* */ private JButton btnBomCompare; + /* */ + /* */ private JButton btnBomImportERP; + /* */ private ResourceBundle resource = ResourceBundle.getBundle("tcUser_erpUser"); + /* */ private JButton btnCancel; + /* */ + /* */ private DefaultTableModel newTableModel; + /* */ private static String erpPreference = "connor_tc_to_erp_url"; + /* */ private Vector newTableTitle; + /* */ + /* */ private CTable newTable; + /* */ private String msgString; + /* */ private DefaultTableModel compareTableModel; + /* */ private Vector compareTableTitle; + /* */ private CTable compareTable; + /* */ private JScrollPane newScrollPane; + /* */ private JScrollPane compareScrollPane; + /* 96 */ private Vector> erpData = new Vector>(); + /* */ + /* 98 */ private JTabbedPane tabbedPane = null; + + + /* 100 */ private int maxWidth = 0; + /* */ + /* */ public BomChgTransferDialog(TCSession session, AbstractAIFUIApplication app, List itemRevision, Map>> map, Vector> data) { + /* 103 */ super(session, app, itemRevision, map, data); + /* 104 */ System.out.println("BomChgTransferDialog::map==============" + map); + /* 105 */ System.out.println("BomChgTransferDialog::itemRevision==============" + itemRevision); + /* 106 */ System.out.println("BomChgTransferDialog::data==============" + data); + /* 107 */ initUI(); + /* */ } + /* */ + /* */ private void initUI() { + /* 111 */ setTitle("变更BOM"); + /* 112 */ this.cbMerge = new JCheckBox("同件号同工序合并"); + /* 113 */ this.btnBomCheck = new JButton("BOM导入验证"); + /* */ + /* 115 */ this.btnBomCompare = new JButton("BOM比较"); + /* 116 */ this.btnBomCompare.setEnabled(false); + /* */ + /* 118 */ this.btnBomImportERP = new JButton("BOM导入ERP系统"); + /* 119 */ this.btnBomImportERP.setEnabled(false); + /* */ + /* 121 */ this.btnCancel = new JButton("取消"); + /* */ + /* 123 */ JPanel paneButton = new JPanel(); + /* 124 */ paneButton.add(this.cbMerge); + /* 125 */ paneButton.add(this.btnBomCheck); + /* 126 */ paneButton.add(this.btnBomCompare); + /* 127 */ paneButton.add(this.btnBomImportERP); + /* 128 */ paneButton.add(this.btnCancel); + /* */ + /* 130 */ this.newTableTitle = new Vector(); + /* 131 */ this.newTableTitle.add("组织ID"); + /* 132 */ this.newTableTitle.add("装配件编码"); + /* 133 */ this.newTableTitle.add("子件编码"); + /* 134 */ this.newTableTitle.add("工序序号"); + /* 135 */ this.newTableTitle.add("数量"); + /* */ + /* 137 */ CMap2 cMap2 = new CMap2(); + /* */ + /* 139 */ this.newTableModel = new DefaultTableModel(this.data, this.newTableTitle); + /* 140 */ this.newTable = new CTable((CMap)cMap2, this.newTableModel) + /* */ { + /* */ private static final long serialVersionUID = 1L; + /* */ + /* */ + /* */ + /* */ public boolean isCellEditable(int row, int column) { + /* 147 */ return false; + /* */ } + /* */ }; + /* */ + /* 151 */ this.compareTableTitle = new Vector(); + /* 152 */ this.compareTableTitle.add("组织ID"); + /* 153 */ this.compareTableTitle.add("装配件编码"); + /* 154 */ this.compareTableTitle.add("子件编码"); + /* 155 */ this.compareTableTitle.add("工序序号"); + /* 156 */ this.compareTableTitle.add("数量"); + /* 157 */ this.compareTableTitle.add("状态"); + /* 158 */ this.compareTableModel = new DefaultTableModel(this.erpData, this.compareTableTitle); + /* 159 */ this.compareTable = new CTable((CMap)cMap2, this.compareTableModel) + /* */ { + /* */ private static final long serialVersionUID = 1L; + /* */ public boolean isCellEditable(int i, int j) { + /* 167 */ return false; + /* */ } + /* */ }; + /* 170 */ int totalWidth = UtilApi.FitTableColumns((JTable)this.newTable); + /* */ + /* 172 */ JPanel paneMain = new JPanel(new BorderLayout()); + /* */ + /* 174 */ this.newScrollPane = new JScrollPane((Component)this.newTable); + /* */ + /* 176 */ this.compareScrollPane = new JScrollPane((Component)this.compareTable); + /* */ + /* 178 */ this.tabbedPane = new JTabbedPane(1); + /* 179 */ this.tabbedPane.setTabPlacement(1); + /* 180 */ Icon icon = new ImageIcon(("projectobject_16.png")); + /* 181 */ this.tabbedPane.addTab("PLM新BOM", icon, this.newScrollPane, "PLM新BOM"); + /* 182 */ this.tabbedPane.addTab("与ERP旧BOM比较结果", icon, this.compareScrollPane, "与ERP旧BOM比较结果"); + /* 183 */ this.tabbedPane.setEnabledAt(1, false); + /* 184 */ this.tabbedPane.addChangeListener(new ChangeListener() + /* */ { + /* */ public void stateChanged(ChangeEvent e) + /* */ { + /* 188 */ if (BomChgTransferDialog.this.tabbedPane.getSelectedIndex() == 0) { + /* 189 */ BomChgTransferDialog.this.cbMerge.setEnabled(true); + /* */ } else { + /* 191 */ BomChgTransferDialog.this.cbMerge.setEnabled(false); + /* */ } + /* */ } + /* */ }); + /* */ + /* 196 */ paneMain.add("Center", new JScrollPane(this.tabbedPane)); + /* 197 */ paneMain.add("South", paneButton); + /* 198 */ getContentPane().add(paneMain); + /* 199 */ this.maxWidth = totalWidth + 100; + /* 200 */ setPreferredSize(new Dimension(this.maxWidth, 600)); + /* */ + /* 202 */ this.cbMerge.addItemListener(new ItemListener() + /* */ { + /* */ + /* */ public void itemStateChanged(ItemEvent ev) + /* */ { + /* 207 */ if (BomChgTransferDialog.this.cbMerge.isEnabled()) { + /* 208 */ if (ev.getStateChange() == 1) { + /* 209 */ int rowCount = BomChgTransferDialog.this.data.size(); + /* 210 */ Vector> newData = new Vector>(); + /* 211 */ Map idToNumMap = new HashMap(); + /* 212 */ Map> idToRowDataMap = new HashMap>(); + /* 213 */ for (int i = 0; i < rowCount; i++) { + /* 214 */ Vector rowData = BomChgTransferDialog.this.data.get(i); + /* 215 */ String processId = rowData.get(1).toString(); + /* 216 */ String operId = rowData.get(2).toString(); + /* 217 */ String seqNum = rowData.get(3).toString(); + /* 218 */ String quantity = rowData.get(4).toString(); + /* */ + /* 220 */ String gongxu = seqNum.split("_")[0]; + /* */ + /* 222 */ String process_and_oper = String.valueOf(processId + "|" + operId) + "|" + gongxu; + /* 223 */ String seqNum_and_quantity = seqNum + "&&" + quantity; + /* */ + /* */ + /* */ + /* */ + /* 228 */ if (idToNumMap.containsKey(process_and_oper)) { + /* 229 */ int index = newData.indexOf(idToRowDataMap.get(process_and_oper)); + /* 230 */ Vector newRowData = new Vector(); + /* 231 */ String[] seqNum_and_quantityArrStr = ((String)idToNumMap.get(process_and_oper)).split("&&"); + /* 232 */ String seqNum2 = seqNum_and_quantityArrStr[0]; + /* 233 */ String quantity2 = seqNum_and_quantityArrStr[1]; + /* 234 */ String sumQuantity = UtilApi.subZeroAndDot(String.valueOf(UtilApi.add(Double.parseDouble(quantity), Double.parseDouble(quantity2)))); + /* 235 */ String newSeqNum = seqNum2 + "×" + quantity2 + ";" + seqNum + "×" + quantity; + /* 236 */ String newSeqNumAndQuantity = newSeqNum + "&&" + sumQuantity; + /* */ + /* 238 */ idToNumMap.put(process_and_oper, newSeqNumAndQuantity); + /* 239 */ newRowData.add(rowData.get(0).toString()); + /* 240 */ newRowData.add(processId); + /* 241 */ newRowData.add(operId); + /* 242 */ newRowData.add(newSeqNum); + /* 243 */ newRowData.add(sumQuantity); + /* 244 */ idToRowDataMap.put(process_and_oper, newRowData); + /* 245 */ newData.set(index, newRowData); + /* */ } else { + /* 247 */ idToNumMap.put(process_and_oper, seqNum_and_quantity); + /* 248 */ idToRowDataMap.put(process_and_oper, rowData); + /* 249 */ newData.add(rowData); + /* */ } + /* */ } + /* 252 */ BomChgTransferDialog.this.newTableModel.setDataVector(newData, BomChgTransferDialog.this.newTableTitle); + /* 253 */ int oldWidth = UtilApi.FitTableColumns((JTable)BomChgTransferDialog.this.newTable); + /* 254 */ int newWidth = UtilApi.FitTableColumns((JTable)BomChgTransferDialog.this.compareTable); + /* 255 */ if (oldWidth > newWidth) { + /* 256 */ if (oldWidth > BomChgTransferDialog.this.maxWidth) { + /* 257 */ BomChgTransferDialog.this.maxWidth = oldWidth; + /* 258 */ BomChgTransferDialog.this.setPreferredSize(new Dimension(oldWidth, 400)); + /* */ } + /* */ + /* 261 */ } else if (newWidth > BomChgTransferDialog.this.maxWidth) { + /* 262 */ BomChgTransferDialog.this.maxWidth = newWidth; + /* 263 */ BomChgTransferDialog.this.setPreferredSize(new Dimension(newWidth, 400)); + /* */ } + /* */ } else { + /* */ + /* 267 */ BomChgTransferDialog.this.newTableModel.setDataVector(BomChgTransferDialog.this.data, BomChgTransferDialog.this.newTableTitle); + /* 268 */ int oldWidth = UtilApi.FitTableColumns((JTable)BomChgTransferDialog.this.newTable); + /* 269 */ int newWidth = UtilApi.FitTableColumns((JTable)BomChgTransferDialog.this.compareTable); + /* 270 */ if (oldWidth > newWidth) { + /* 271 */ if (oldWidth > BomChgTransferDialog.this.maxWidth) { + /* 272 */ BomChgTransferDialog.this.maxWidth = oldWidth; + /* 273 */ BomChgTransferDialog.this.setPreferredSize(new Dimension(oldWidth, 400)); + /* */ } + /* */ + /* 276 */ } else if (newWidth > BomChgTransferDialog.this.maxWidth) { + /* 277 */ BomChgTransferDialog.this.maxWidth = newWidth; + /* 278 */ BomChgTransferDialog.this.setPreferredSize(new Dimension(newWidth, 400)); + /* */ } + /* */ } + /* */ } + /* */ } + /* */ }); + /* */ + /* */ + /* */ + /* 287 */ this.btnBomCheck.addActionListener(new ActionListener() + /* */ { + /* */ public void actionPerformed(ActionEvent e) + /* */ { + /* 291 */ BomChgTransferDialog.this.check(); + /* */ } + /* */ }); + /* */ + /* 295 */ this.btnBomCompare.addActionListener(new ActionListener() + /* */ { + /* */ public void actionPerformed(ActionEvent e) + /* */ { + /* 299 */ BomChgTransferDialog.this.compare(); + /* */ } + /* */ }); + /* */ + /* */ + /* */ + /* 305 */ this.btnBomImportERP.addActionListener(new ActionListener() + /* */ { + /* */ public void actionPerformed(ActionEvent e) + /* */ { + /* 309 */ BomChgTransferDialog.this.importToERP(); + /* */ } + /* */ }); + /* */ + /* 313 */ this.btnCancel.addActionListener(new ActionListener() + /* */ { + /* */ public void actionPerformed(ActionEvent e) + /* */ { + /* 317 */ BomChgTransferDialog.this.dispose(); + /* */ } + /* */ }); + /* */ } + /* */ + /* */ + /* */ public void check() { + System.out.println("check"); + /* 324 */ int rowCount = this.newTable.getRowCount(); + /* 325 */ for (int i = 0; i < rowCount; i++) { + /* 326 */ if (this.newTable.getValueAt(i, 3).toString().trim().equals("")) { + /* 327 */ MessageBox.post(this.application.getDesktop().getShell(), "工序序号不能为空!", "错误", 1); + /* */ return; + /* */ } + /* */ } + /* */ try { + /* 332 */ this.user_id = this.session.getUser().getProperty("user_id"); + /* 333 */ } catch (TCException ex) { + /* 334 */ ex.printStackTrace(); + /* */ } + List entryMap=new ArrayList(); + Map> bomMap=new HashMap>(); + + List> list=new ArrayList>(); + + String assembly = newTable.getValueAt(0, 1).toString(); + BomAddEntry bomAddEntry=new BomAddEntry(); + bomAddEntry.setAssembly_item(assembly.split("/")[0]); +///* 122 */ int rowCount = newTable.getRowCount(); +/* 123 */ for (int i = 0; i < rowCount; i++) { + + + if(assembly!=newTable.getValueAt(i, 1).toString()) { + entryMap.add(bomAddEntry); + bomAddEntry.setBOMLine(list); + bomAddEntry=new BomAddEntry(); + assembly=newTable.getValueAt(i, 1).toString(); + bomAddEntry.setAssembly_item(assembly.split("/")[0]); + list=new ArrayList>(); + } + if(i==rowCount-1) { + entryMap.add(bomAddEntry); + bomAddEntry.setBOMLine(list); + bomAddEntry=new BomAddEntry(); + } + + +/* 124 */ if (newTable.getValueAt(i, 3).toString().trim().equals("")) { +/* 125 */ MessageBox.post(application.getDesktop().getShell(), "工序序号不能为空!", "错误", 1); +/* */ return; +/* */ } + Map jsonMap=new HashMap(); + jsonMap.put("item", newTable.getValueAt(i, 2).toString().split("/")[0]); + jsonMap.put("operation_seq_num",newTable.getValueAt(i, 3).toString().split("_")[0]); + list.add(jsonMap); +/* */ } + bomMap.put("BOM", entryMap); +// /* */ try { +// /* 339 */ ValidateBomXMLWriter.createXML(this.user_id, xmlFilePath, FileType.bom, AimType.chg, this.map); +// /* 340 */ } catch (FileNotFoundException e1) { +// /* 341 */ e1.printStackTrace(); +// /* 342 */ } catch (ParserConfigurationException e1) { +// /* 343 */ e1.printStackTrace(); +// /* 344 */ } catch (TransformerException e1) { +// /* 345 */ e1.printStackTrace(); +// /* */ } +// /* */ + List results = doPost(bomMap,"BOMChgCheck"); + + System.out.println("msg"+msgString); +// /* 348 */ String result = ""; +// UtilApi.getErrorInfoFromCode(PlmErpIntegration.validateData(xmlFilePath)); + /* */ + /* */ + /* */ + /* 352 */ if (!msgString.equals("succ")) { + /* 353 */ MessageBox.post(this.application.getDesktop().getShell(), msgString, "验证出现错误", MessageBox.INFORMATION); + /* */ + /* */ } + /* */ else { + /* */ + /* 358 */ String errorInfo = BomChgImportXMLReader.loadElements(results,"1"); + System.out.println("errorInfo"+errorInfo); +// String errorInfo=""; + /* 359 */ if (errorInfo.equals("")) { + /* 360 */ MessageBox.post(this.application.getDesktop().getShell(), "导入验证成功,可以执行导入操作!", "成功", 2); + /* 361 */ this.btnBomCompare.setEnabled(true); + /* 362 */ this.btnBomImportERP.setEnabled(true); + /* */ } else { + /* 364 */ SwingUtilities.invokeLater((Runnable)new ValidateFailDialog("验证失败,请查看详细信息:", "警告", errorInfo)); + /* */ } + /* */ } + /* */ } + /* */ + /* */ public void compare() { + /* */ + List entryMap=new ArrayList(); + Map> bomMap=new HashMap>(); + + List> list=new ArrayList>(); + + String assembly = newTable.getValueAt(0, 1).toString(); + BomAddEntry bomAddEntry=new BomAddEntry(); +/* 122 */ int rowCount = newTable.getRowCount(); +bomAddEntry.setAssembly_item(assembly.split("/")[0]); + /* 123 */ for (int i = 0; i < rowCount; i++) { + if(assembly!=newTable.getValueAt(i, 1).toString()) { + entryMap.add(bomAddEntry); + bomAddEntry.setBOMLine(list); + bomAddEntry=new BomAddEntry(); + assembly=newTable.getValueAt(i, 1).toString(); + bomAddEntry.setAssembly_item(assembly.split("/")[0]); + list=new ArrayList>(); + } + if(i==rowCount-1) { + entryMap.add(bomAddEntry); + bomAddEntry.setBOMLine(list); + bomAddEntry=new BomAddEntry(); + } + + + if (newTable.getValueAt(i, 3).toString().trim().equals("")) { + MessageBox.post(application.getDesktop().getShell(), "工序序号不能为空!", "错误", 1); + return; + } + Map jsonMap=new HashMap(); + jsonMap.put("item", newTable.getValueAt(i, 2).toString().split("/")[0]); + jsonMap.put("operation_seq_num",newTable.getValueAt(i, 3).toString().split("_")[0]+"_"); + jsonMap.put("quantity",newTable.getValueAt(i, 4).toString()); + list.add(jsonMap); +/* */ } + bomMap.put("BOM", entryMap); + List results = doPost(bomMap,"CompareBOMdetail"); +// /* 382 */ String result =""; +// UtilApi.getErrorInfoFromCode(PlmErpIntegration.compareBom(xmlFilePath)); + /* */ + /* */ + /* */ + /* 386 */ if (!msgString.equals("succ")) { + /* 387 */ SwingUtilities.invokeLater((Runnable)new ValidateFailDialog("比较验证失败,请查看详细信息:", "警告", msgString)); + /* */ + /* */ } + /* */ else { + /* */ + /* 392 */ Vector vec = new Vector(); + + /* 393 */ this.erpData.clear(); + BomChgImportXMLReader.loadElements(results, erpData, vec); +// /* 394 */ BomChgCompareXMLReader.loadXMLDatas(new File(xmlFileName + "_r.xml"), this.erpData, vec); + /* 395 */ this.tabbedPane.setEnabledAt(1, true); + /* 396 */ this.tabbedPane.setSelectedIndex(1); + /* 397 */ for (int i = 2; i < 6; i++) { + /* 398 */ this.compareTable.getColumn(this.compareTable.getColumnName(i)).setCellRenderer(new MyDefaultTableCellRenderer()); + /* */ } + /* 400 */ int oldWidth = UtilApi.FitTableColumns((JTable)this.newTable); + /* 401 */ int newWidth = UtilApi.FitTableColumns((JTable)this.compareTable); + /* 402 */ if (oldWidth > newWidth) { + /* 403 */ if (oldWidth > this.maxWidth) { + /* 404 */ this.maxWidth = oldWidth; + /* 405 */ setPreferredSize(new Dimension(oldWidth, 400)); + /* */ } + /* */ + /* 408 */ } else if (newWidth > this.maxWidth) { + /* 409 */ this.maxWidth = newWidth; + /* 410 */ setPreferredSize(new Dimension(newWidth, 400)); + /* */ } + /* */ + /* 413 */ if (vec.size() == this.erpData.size()) { + + Object obj[] = new Object[1]; + obj[0] = 1; + TCUserService service = session.getUserService(); + try { + service.call("openByPass", obj); + int rev_num = this.ItemRevision.size(); + + for (int i = 0; i < rev_num; i++) { + + this.ItemRevision.get(i).getRelatedComponent("IMAN_master_form_rev").setLogicalProperty("nhl8_BOMimpSucc", true); + + } + + + service.call("closeByPass", obj); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + this.btnBomImportERP.setEnabled(false); + /* 414 */ MessageBox.post(this.application.getDesktop().getShell(), "与ERP中的BOM相同,无需导入!", "提示", 2); + /* */ } + /* */ } + /* */ } + /* */ + /* */ + /* */ public void importToERP() { +// 导入 + Map userMap=new HashMap(); + userMap.put("TCUser", user_id); + List doPost = DBUtils.doPost(userMap, session); + UserList userList = doPost.get(0); + List entryMap=new ArrayList(); + Map bomMap=new HashMap(); + + List> list=new ArrayList>(); +// if(resource.containsKey(user_id)) { +// bomMap.put("creater", resource.getString(user_id)); +// }else { + bomMap.put("creater", userList.getERP_USER_CODE()); +// } + String assembly = newTable.getValueAt(0, 1).toString(); + BomAdd bomAddEntry=new BomAdd(); + int indx=0; + String revisionString=""; + TCComponentItemRevision rev = ItemRevision.get(indx); + try { + String object_string = rev.getStringProperty("object_string"); + System.out.println(object_string); + if(object_string.equals(assembly.split(" ")[0])) { + revisionString=rev.getStringProperty("item_revision_id"); + } + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + + int rowCount = newTable.getRowCount(); + for (int i = 0; i < rowCount; i++) { + bomAddEntry.setAssembly_item(assembly.split("/")[0]); + bomAddEntry.setVersion(revisionString); + if(assembly!=newTable.getValueAt(i, 1).toString()) { + entryMap.add(bomAddEntry); + bomAddEntry.setBOMLine(list); + bomAddEntry=new BomAdd(); + assembly=newTable.getValueAt(i, 1).toString(); + try { + indx++; + TCComponentItemRevision rev2 = ItemRevision.get(indx); + String object_string = rev2.getStringProperty("object_string"); + if(object_string.equals(assembly.split(" ")[0])) { + revisionString=rev2.getStringProperty("item_revision_id"); + bomAddEntry.setVersion(revisionString); + + } + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + list=new ArrayList>(); + } + if(i==rowCount-1) { + entryMap.add(bomAddEntry); + bomAddEntry.setBOMLine(list); + bomAddEntry=new BomAdd(); + } + + + if (newTable.getValueAt(i, 3).toString().trim().equals("")) { + MessageBox.post(application.getDesktop().getShell(), "工序序号不能为空!", "错误", 1); + return; + } + + Map jsonMap=new HashMap(); + jsonMap.put("item", newTable.getValueAt(i, 2).toString().split("/")[0]); + jsonMap.put("operation_seq_num",newTable.getValueAt(i, 3).toString()); + jsonMap.put("quantity",Double.valueOf(newTable.getValueAt(i, 4).toString()) ); + list.add(jsonMap); + } + + BomChgTransferOperation operation=new BomChgTransferOperation(application,session,entryMap,bomMap,BomChgTransferDialog.this); + session.queueOperation(operation); + /* */ } + /* */ + /* */ + /* */ public class MyDefaultTableCellRenderer + /* */ extends DefaultTableCellRenderer + /* */ { + /* */ private static final long serialVersionUID = 1L; + /* */ + /* */ + /* */ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + /* 465 */ String fiveValue = table.getValueAt(row, 5).toString(); + /* 466 */ if (fiveValue.equals("删除")) { + /* 467 */ setBackground(Color.RED); + /* 468 */ } else if (fiveValue.equals("新增")) { + /* 469 */ setBackground(Color.GREEN); + /* 470 */ } else if (fiveValue.equals("修改")) { + /* 471 */ setBackground(Color.YELLOW); + /* 472 */ } else if (fiveValue.equals("未改")) { + /* 473 */ setBackground(Color.WHITE); + /* */ } + /* 475 */ return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + /* */ } + /* */ } + + /* */ private List doPost(Map> itemCheckMap, String svr) { + HashMap preferenceHashMap = TCPreferenceUitl.getPreferenceHashMap(session, TCPreferenceService.TC_preference_site, erpPreference); + String url = preferenceHashMap.get("url"); + String token = preferenceHashMap.get("token"); + JSONObject itemCheckJson = JSONObject.fromObject(itemCheckMap); + String sid = null; + try { + System.out.println("开始发送请求"); + String args = itemCheckJson.toString(); + System.out.println(args); + token = URLEncoder.encode(token,"UTF-8"); + svr = URLEncoder.encode(svr,"UTF-8"); + args = URLEncoder.encode(args,"UTF-8"); + String param = "usr="+token+"&svr="+svr+"&args="+args; + + System.out.println("url=============="+url); + System.out.println("param==========="+args); + String response = HttpUtil.doPost(url,param); +// System.out.println("请求结果================"+response); + JSONObject jsonObject = JSONObject.fromObject(response); + System.out.println("json格式==============="+jsonObject); + if(svr.equals("BOMChgCheck")) { + msgString = jsonObject.getString("msg"); + if(jsonObject.has("cont")) { + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); + + if(jsonObject2.has("checkResult")) { + JSONArray jsonObject3 = jsonObject2.getJSONArray("checkResult"); + List list = JSONArray.toList(jsonObject3,AssemblyResult.class); + return list; + } + } + }else if (svr.equals("CompareBOMdetail")) { + msgString = jsonObject.getString("msg"); + if(jsonObject.has("cont")) { + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); + + if(jsonObject2.has("compareResult")) { + + + JSONArray jsonObject3 = jsonObject2.getJSONArray("compareResult"); +// JSONObject compare = jsonObject2.getJSONObject("compareResult"); +// assembly_item = compare.getString("assembly_item"); + List list = JSONArray.toList(jsonObject3,CompareResult.class); +// System.out.println(jsonObject3+"list"+list.size()); + + return list; + } + } + } + + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return null; + } +// private String doPost1(Map itemCheckMap, String svr) { +// HashMap preferenceHashMap = TCPreferenceUitl.getPreferenceHashMap(session, TCPreferenceService.TC_preference_site, erpPreference); +// String url = preferenceHashMap.get("url"); +// String token = preferenceHashMap.get("token"); +// JSONObject itemCheckJson = JSONObject.fromObject(itemCheckMap); +// String sid = null; +// try { +// System.out.println("开始发送请求"); +// String args = itemCheckJson.toString(); +// System.out.println(args); +// token = URLEncoder.encode(token,"UTF-8"); +// svr = URLEncoder.encode(svr,"UTF-8"); +// args = URLEncoder.encode(args,"UTF-8"); +// String param = "usr="+token+"&svr="+svr+"&args="+args; +// +// System.out.println("url=============="+url); +// System.out.println("param==========="+args); +// String response = HttpUtil.doGet(url+"?"+param); +//// System.out.println("请求结果================"+response); +// +// JSONObject jsonObject = JSONObject.fromObject(response); +// System.out.println("json格式==============="+jsonObject); +// msgString = jsonObject.getString("msg"); +// if(jsonObject.has("cont")) { +// JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); +// sid = jsonObject2.getString("sid"); +// } +// +// } catch (Exception e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// return sid; +// } + /* */ + /* */ public static void main(String[] args) throws Exception { + + } +// /* 481 */ String file_path = "C:\\70188_20130522095010011_compare_bom_chg.xml"; +// /* 482 */ String txt_path = file_path.replaceAll("\\.xml$", "_r.txt"); +// /* 483 */ System.out.println(txt_path); +// /* 484 */ if ((new File(txt_path)).exists()) { +// /* 485 */ Runtime run = Runtime.getRuntime(); +// /* 486 */ run.exec("cmd /c start notepad \"" + txt_path + "\""); +// /* */ } +// /* */ } + /* */ } + diff --git a/src/com/connor/erp/BomChgTransferToERP/BomChgTransferHandler.java b/src/com/connor/erp/BomChgTransferToERP/BomChgTransferHandler.java new file mode 100644 index 0000000..c82cfb5 --- /dev/null +++ b/src/com/connor/erp/BomChgTransferToERP/BomChgTransferHandler.java @@ -0,0 +1,40 @@ +/* */ package com.connor.erp.BomChgTransferToERP; +/* */ +/* */ import com.teamcenter.rac.aif.AbstractAIFUIApplication; +/* */ import com.teamcenter.rac.aifrcp.AIFUtility; +/* */ import com.teamcenter.rac.kernel.TCSession; +/* */ import org.eclipse.core.commands.AbstractHandler; +/* */ import org.eclipse.core.commands.ExecutionEvent; +/* */ import org.eclipse.core.commands.ExecutionException; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class BomChgTransferHandler +/* */ extends AbstractHandler +/* */ { +/* */ public Object execute(ExecutionEvent event) throws ExecutionException { +/* 23 */ AbstractAIFUIApplication application = +/* 24 */ AIFUtility.getCurrentApplication(); +/* 25 */ TCSession session = (TCSession)application.getSession(); +/* 26 */ BomChgTransferCommand command = new BomChgTransferCommand(session, application); +/* */ try { +/* 28 */ command.executeModal(); +/* 29 */ } catch (Exception e) { +/* 30 */ e.printStackTrace(); +/* */ } +/* 32 */ return null; +/* */ } +/* */ } + + +/* Location: C:\Users\cyh\Documents\WeChat Files\wxid_ztg4pdvd5bjn12\FileStorage\File\2022-03\com.origin.erpintegration_1.0.0.jar!\com\origin\erp\BomChgTransferToERP\BomChgTransferHandler.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 1.1.3 + */ \ No newline at end of file diff --git a/src/com/connor/erp/BomChgTransferToERP/BomChgTransferOperation.java b/src/com/connor/erp/BomChgTransferToERP/BomChgTransferOperation.java new file mode 100644 index 0000000..b873120 --- /dev/null +++ b/src/com/connor/erp/BomChgTransferToERP/BomChgTransferOperation.java @@ -0,0 +1,326 @@ +package com.connor.erp.BomChgTransferToERP; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Label; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; + +import com.connor.erp.BomAddTransferToERP.BomAdd; +import com.connor.erp.ProcessImport.ValidateFailDialog; +import com.connor.erp.processresource.EquipmentAcquiredFromERP.TCPreferenceUitl; +import com.connor.erp.toolkit.HttpUtil; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONObject; + +public class BomChgTransferOperation extends AbstractAIFOperation{ + private final String CONNOR_TC_TO_ERP_PART_TIME = "connor_tc_to_erp_part_time"; + private String msgString; + private AbstractAIFUIApplication app; + private TCSession session; + private List entryMap=new ArrayList(); + private Map bomMap=new HashMap(); + private String user_id; + private AbstractAIFDialog dialog; + private String erpPreference = "connor_tc_to_erp_url"; + private PreparedStatement stmt; + private Connection connectionFun; + private ResultSet r ; + private ResourceBundle resource = ResourceBundle.getBundle("tcUser_erpUser"); + public BomChgTransferOperation(AbstractAIFUIApplication app,TCSession session,List entryMap,Map bomMap,AbstractAIFDialog dialog) { + this.app=app; + this.session=session; + this.entryMap=entryMap; + this.bomMap=bomMap; + this.dialog=dialog; + } + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + user_id = session.getUser().getProperty("user_id"); + String timeout = session.getPreferenceService().getStringValue(CONNOR_TC_TO_ERP_PART_TIME); + if(timeout!=null&&timeout.length()>0) { + System.out.println("超时时间为"+timeout+"秒!"); + Daemon daemon = new Daemon(new Thread() { + public void run() { + WaitingDialog dia = new WaitingDialog(app.getDesktop(), "INFOMATION", "正在导入ERP..."); + dia.setAlwaysOnTop(true);//设置在窗口最前端 + dia.setVisible(true); + boolean flag = false; + try { + flag = importItemToERP(); + + }catch (InterruptedException e) { + // TODO Auto-generated catch block +// e.printStackTrace(); + dia.setVisible(false); + try { + if(r!=null) { + r.close(); + } + if(stmt!=null) { + stmt.close(); + } + if(connectionFun!=null) { + connectionFun.close(); + } + + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + MessageBox.post("导入超时!", "", MessageBox.INFORMATION); + return; + }catch(Exception e) { + + + e.printStackTrace(); + } + if (flag) { + dia.setVisible(false); + MessageBox.post("导入成功! 如需查询导入状态,请在“ERP集成”—“ERP任务导入记录”中查找", "发送到ERP成功", 2); + } else { + dia.setVisible(false); + try { + if(r!=null) { + r.close(); + } + if(stmt!=null) { + stmt.close(); + } + if(connectionFun!=null) { + connectionFun.close(); + } + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + MessageBox.post("导入失败!", "", MessageBox.INFORMATION); + } + }; + },new BigDecimal(timeout)); + new Thread(daemon).start(); + }else { + MessageBox.post("请联系管理员配置"+CONNOR_TC_TO_ERP_PART_TIME+"首选项","",MessageBox.INFORMATION); + } + } + + protected boolean importItemToERP() throws InterruptedException, Exception { + + List taskNums=new ArrayList(); + Map> map=new HashMap>(); + String sql = "select ImpResult from connor_ERP_record where TaskNumber =?"; + for(BomAdd bAdd:entryMap) { + List entryMap2=new ArrayList(); + entryMap2.add(bAdd); + bomMap.put("BOM", entryMap2); + String task_num = doPost1(bomMap,"BOMChg"); +/* 436 */ if (!msgString.equals("succ")) { +/* 437 */ SwingUtilities.invokeLater((Runnable)new ValidateFailDialog("验证失败,请查看详细信息:", "警告", msgString)); + + DBUtils.InsertData(bAdd.getAssembly_item(), "PBOM", task_num, user_id, bAdd.getVersion(), session); +// return false; +/* */ } else { + DBUtils.InsertData(bAdd.getAssembly_item(), "PBOM", task_num, user_id, bAdd.getVersion(), session); + + List itemMap=new ArrayList(); + itemMap.add(bAdd.getAssembly_item()); + itemMap.add(bAdd.getVersion()); + map.put(task_num,itemMap); +// Object obj[] = new Object[1]; +// obj[0] = 1; +// TCUserService service = session.getUserService(); +// service.call("openByPass", obj); +// TCComponentItemRevision itemRevision = DBUtils.getItemRevision(session,bAdd.getAssembly_item(),bAdd.getVersion()); +// TCComponentForm form = (TCComponentForm) itemRevision.getRelatedComponent("IMAN_master_form_rev"); +// form.setLogicalProperty("nhl8_BOMimpSucc", true); +// service.call("closeByPass", obj); + taskNums.add(task_num); +/* */ } + } + + boolean allSucc=false; +// taskNums.add("03e72c4b-d3c6-4969-a38e-85cafa3bb9bc"); + connectionFun = DBUtils.ConnectionFun(session); + while (!allSucc) { + + for(int i=0;i list = map.get(taskNums.get(i)); + Object obj[] = new Object[1]; + obj[0] = 1; + TCUserService service = session.getUserService(); + service.call("openByPass", obj); + TCComponentItemRevision itemRevision = DBUtils.getItemRevision(session,list.get(0),list.get(1)); + TCComponentForm form = (TCComponentForm) itemRevision.getRelatedComponent("IMAN_master_form_rev"); + form.setLogicalProperty("nhl8_BOMimpSucc", true); + System.out.println("回填属性itemid"+list.get(0)+"rev"+list.get(1)); + service.call("closeByPass", obj); + + taskNums.remove(i); + i--; + }else if(impResult.contains("失败") || impResult.equals("任务id无效")){ + return false; + } + } + if(taskNums.size()==0) { + allSucc=true; + System.out.println("所有任务都已完成"); + } + + Thread.sleep(1000); + } + if(r!=null) { + r.close(); + } + if(stmt!=null) { + stmt.close(); + } + if(connectionFun!=null) { + connectionFun.close(); + } + + dialog.dispose(); + + + return true; + } + + class Daemon implements Runnable { + private Thread thread; + private BigDecimal time; + + public Daemon(Thread r, BigDecimal t) { + thread = r; + time = t; + } + + @Override + public void run() { + this.thread.start(); + while (true) { + try { + Thread.sleep(time.multiply(new BigDecimal("1000")).longValue()); + } catch (InterruptedException e) { + e.printStackTrace(); + } + thread.interrupt(); + } + } + + } + class WaitingDialog extends com.teamcenter.rac.aif.AbstractAIFDialog { + private static final long serialVersionUID = 1L; + public JPanel panel; + JProgressBar progressBar = null; + + public WaitingDialog(Frame arg0, String title, String message) { + super(arg0, title); + this.setModal(false); + + panel = new JPanel(new BorderLayout()); + + /* + * JLabel label = new JLabel(message); System.out.println("message:"+message); + * System.out.println("label:"+label); panel.add(label); + */ + + progressBar = new JProgressBar(SwingConstants.HORIZONTAL); + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + + panel.add(BorderLayout.CENTER, new Label(message)); + panel.add(BorderLayout.SOUTH, progressBar); + + panel.setPreferredSize(new Dimension(350, 60)); + + this.getContentPane().add(panel); + + centerToScreen(); + + pack(); + + } + } + private String doPost1(Map itemCheckMap, String svr) { + HashMap preferenceHashMap = TCPreferenceUitl.getPreferenceHashMap(session, TCPreferenceService.TC_preference_site, erpPreference); + String url = preferenceHashMap.get("url"); + String token = preferenceHashMap.get("token"); + JSONObject itemCheckJson = JSONObject.fromObject(itemCheckMap); + String sid = null; + try { + System.out.println("开始发送请求"); + String args = itemCheckJson.toString(); + System.out.println(args); + token = URLEncoder.encode(token,"UTF-8"); + svr = URLEncoder.encode(svr,"UTF-8"); + args = URLEncoder.encode(args,"UTF-8"); + String param = "usr="+token+"&svr="+svr+"&args="+args; + + System.out.println("url=============="+url); + System.out.println("param==========="+args); + String response = HttpUtil.doPost(url,param); +// System.out.println("请求结果================"+response); + + JSONObject jsonObject = JSONObject.fromObject(response); + System.out.println("json格式==============="+jsonObject); + msgString = jsonObject.getString("msg"); + if(jsonObject.has("cont")) { + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); + sid = jsonObject2.getString("sid"); + } + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return sid; + } + +} + + diff --git a/src/com/connor/erp/BomChgTransferToERP/CompareLine.java b/src/com/connor/erp/BomChgTransferToERP/CompareLine.java new file mode 100644 index 0000000..6216e7e --- /dev/null +++ b/src/com/connor/erp/BomChgTransferToERP/CompareLine.java @@ -0,0 +1,41 @@ +package com.connor.erp.BomChgTransferToERP; + +public class CompareLine { + + private String item; + private String operation_seq_num; + + private String quantity; + private String lineState; + private String stateDesc; + public String getItem() { + return item; + } + public void setItem(String item) { + this.item = item; + } + public String getOperation_seq_num() { + return operation_seq_num; + } + public void setOperation_seq_num(String operation_seq_num) { + this.operation_seq_num = operation_seq_num; + } + public String getQuantity() { + return quantity; + } + public void setQuantity(String quantity) { + this.quantity = quantity; + } + public String getLineState() { + return lineState; + } + public void setLineState(String lineState) { + this.lineState = lineState; + } + public String getStateDesc() { + return stateDesc; + } + public void setStateDesc(String stateDesc) { + this.stateDesc = stateDesc; + } +} diff --git a/src/com/connor/erp/BomChgTransferToERP/CompareResult.java b/src/com/connor/erp/BomChgTransferToERP/CompareResult.java new file mode 100644 index 0000000..6e8e5c6 --- /dev/null +++ b/src/com/connor/erp/BomChgTransferToERP/CompareResult.java @@ -0,0 +1,21 @@ +package com.connor.erp.BomChgTransferToERP; + +import java.util.List; + +public class CompareResult { + + private String assembly_item; + private List BOMLine; + public String getAssembly_item() { + return assembly_item; + } + public void setAssembly_item(String assembly_item) { + this.assembly_item = assembly_item; + } + public List getBOMLine() { + return BOMLine; + } + public void setBOMLine(List bOMLine) { + BOMLine = bOMLine; + } +} diff --git a/src/com/connor/erp/BomChgTransferToERP/DBUtils.java b/src/com/connor/erp/BomChgTransferToERP/DBUtils.java new file mode 100644 index 0000000..483d0b6 --- /dev/null +++ b/src/com/connor/erp/BomChgTransferToERP/DBUtils.java @@ -0,0 +1,585 @@ +package com.connor.erp.BomChgTransferToERP; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Frame; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JMenu; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.ListSelectionModel; +import javax.swing.RowSorter; +import javax.swing.SwingConstants; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.filechooser.FileSystemView; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreePath; + +import org.apache.xalan.xsltc.compiler.util.StringStack; + +import com.connor.erp.BomAddTransferToERP.AssemblyResult; +import com.connor.erp.BomAddTransferToERP.BomAddEntry; +import com.connor.erp.ProcessImport.ProcessAddTransferToERP.RootCheckResult; +import com.connor.erp.ProcessImport.ProcessAddTransferToERP.RouteLineCheck; +import com.connor.erp.processresource.EquipmentAcquiredFromERP.TCPreferenceUitl; +import com.connor.erp.toolkit.HttpUtil; +import com.connor.touliao.MessageDialog; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.VerticalLayout; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.ServiceData; +import com.teamcenter.soaictstubs.booleanSeq_tHolder; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +public class DBUtils { + private static String erpPreference = "connor_tc_to_erp_url"; + private static SimpleDateFormat df = new SimpleDateFormat("yyyy-M-dd HH:mm"); +// private JTree leftTree; + + + + public static String getStdOpNumber( String itemID,int num) { + + + DecimalFormat df = new DecimalFormat("000"); + String newID = "010"; + // String idTemp = + try { + int i = 10; + while (itemID.compareTo(newID) != 0) { + i = i+1; + newID = df.format(i); + } + newID = df.format(i+num); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newID; + } + public static void main(String[] args) { + + String string="123\n123"; + System.out.println(string); + +// String bl_sequence_no = "D:\\sss"; +// +// System.out.println(bl_sequence_no); +// +// bl_sequence_no = bl_sequence_no.replaceAll("\\\\", "_"); +// +// +// System.out.println(bl_sequence_no); + +// String path = "/dadw"; +// if ('/' == path.charAt(0)) { +// path = path.substring(1); +// } +// System.out.println(path); +// +// List selectedDeliveryNameList = new ArrayList(); +// selectedDeliveryNameList.add("0"); +// selectedDeliveryNameList.add("1"); +// selectedDeliveryNameList.add("2"); +// boolean indexOf = selectedDeliveryNameList.contains("2"); +// System.out.println(indexOf); +// +// String sql = "select * from AHMC_TASK_CHECK a WHERE a.STAGE = \'%s\'"; +// String selectSql = String.format( +// sql, "第一阶段"); +// System.out.println(selectSql); +// List list2=new ArrayList(2); +// list2.add(0, erpPreference); +// list2.add(1, erpPreference); +// list2.add(2, erpPreference); +// System.out.println(list2.get(2)); +// String sqlString="Select * from xxx where 1=1, text = *编号 , name = *名称 , type = *类型,id=*id"; +// +// String[] split = sqlString.split("where 1=1,"); +// +// System.out.println("split"+split.toString()); +// String[] split2 = split[1].split(","); +// +// ArrayList list=new ArrayList(); +// +// for(String string:split2) { +// +// String[] split3 = string.split("="); +// if(split3[1].contains("*")) { +// System.out.println(split3[1]); +// list.add(split3[1]); +// } +// +// } +// +// for(String lString:list) { +// sqlString = sqlString.replace(lString, "?"); +// } +// System.out.println("sql === "+sqlString); +// +// JDialog dialog=new JDialog(); +// +// dialog.setPreferredSize(new Dimension(600, 400)); +// List nameList=new ArrayList(); +// +// +// +// DefaultMutableTreeNode childNode = new DefaultMutableTreeNode("资源库"); +//// DefaultMutableTreeNode childNode = new DefaultMutableTreeNode("油漆"); +// addNode(childNode,"油漆"); +// addNode(childNode,"刀具"); +// addNode(childNode,"量具"); +// addNode(childNode,"工具"); +//// childNode.add(childNode);.add("油漆"); +//// childNode.add("刀具"); +//// childNode.add("量具"); +//// childNode.add("工具"); +// +// +// +// DefaultTreeModel treeModel = new DefaultTreeModel(childNode); +// +// JTree leftTree = new JTree(); +// leftTree.setPreferredSize(new Dimension(150, 250)); +//// leftTree.setBackground(bgColor); +// leftTree.setName("tree"); +// +// leftTree.setModel(treeModel); +//// leftTree.setCellRenderer(new CheckBoxTreeCellRenderer()); +// leftTree.setExpandsSelectedPaths(true); +// leftTree.setScrollsOnExpand(true); +// +// leftTree.addMouseListener(new MouseAdapter() { +// @Override +// public void mouseClicked(MouseEvent event) { +// Object selectObj = leftTree.getLastSelectedPathComponent(); +// if (selectObj instanceof DefaultMutableTreeNode) { +// Object userObj = ((DefaultMutableTreeNode) selectObj).getUserObject(); +// +// System.out.println(userObj); +// } +// +// } +// }); +// JPanel totalPanel = new JPanel(); +// totalPanel.setLayout(new BorderLayout()); +// +// JPanel designPanel = new JPanel(); +// designPanel.setLayout(new BorderLayout()); +//// designPanel.add(leftTree, BorderLayout.WEST); +// designPanel.setPreferredSize(new Dimension(600, 400)); +// totalPanel.add(designPanel,BorderLayout.CENTER); +// totalPanel.add(leftTree, BorderLayout.WEST); +// dialog.add(totalPanel); +//// dialog.setContentPane(designPanel); +////// designPanel.pack(); +// JPanel southJPanel=new JPanel(); +// +// JButton obButton = new JButton("确定"); +// JButton closeBtn = new JButton("取消"); +// southJPanel.add(obButton); +// southJPanel.add(new JButton("取消")); +// designPanel.add(southJPanel,BorderLayout.SOUTH); +// obButton.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +//// dispose(); +// } +// }); +// closeBtn.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +//// dispose(); +// } +// }); +// +// JPanel searchJPanel=new JPanel(); +// searchJPanel.setPreferredSize(new Dimension(600, 50)); +// JLabel lb_Weight = new JLabel("编号"); +// lb_Weight.setFont(new Font("微软雅黑", Font.PLAIN, 12)); +// lb_Weight.setHorizontalAlignment(SwingConstants.LEFT); +// lb_Weight.setBounds(10, 10, 60, 20); +// searchJPanel.add(lb_Weight); +// +//// searchJPanel.setLayout(new VerticalLayout()); +// JTextField h8_Weight_text = new JTextField(); +// h8_Weight_text.setBounds(80, 10, 80, 20); +// h8_Weight_text.setColumns(8); +// searchJPanel.add(h8_Weight_text); +// +// JLabel lb_Weight1 = new JLabel("编号"); +// lb_Weight1.setFont(new Font("微软雅黑", Font.PLAIN, 12)); +// lb_Weight1.setHorizontalAlignment(SwingConstants.LEFT); +// lb_Weight1.setBounds(10, 10, 60, 20); +// searchJPanel.add(lb_Weight1); +// +//// searchJPanel.setLayout(new VerticalLayout()); +// JTextField h8_Weight_text2 = new JTextField(); +// h8_Weight_text2.setBounds(80, 10, 80, 20); +// h8_Weight_text2.setColumns(8); +// searchJPanel.add(h8_Weight_text2); +// JTable mainTable = null; +// String[] columnNames = new String[] { "序号", "名称", "规格", "备注"}; +// designPanel.add(searchJPanel,BorderLayout.NORTH); +// mainTable = getjTable(mainTable, null, columnNames, null); +//// mainTable.addA +// DefaultTableModel model =(DefaultTableModel) mainTable.getModel(); +// model.addRow(new String[] {"1","2","3","4"}); +// model.addRow(new String[] {"","","",""}); +// mainTable.addKeyListener(new KeyListener() { +// +// @Override +// public void keyTyped(KeyEvent e) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void keyReleased(KeyEvent e) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void keyPressed(KeyEvent e) { +// // TODO Auto-generated method stub +// if (e.getKeyCode() == KeyEvent.VK_V) { // Copy +// System.out.println("here"); +// +// Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); +//// model.get +// Transferable contents = clipboard.getContents(null); +// try { +// +// String obj = (String) contents.getTransferData(DataFlavor.stringFlavor); +// String[] split4 = obj.split("\n"); +// for(String string:split4) { +// System.out.println(string.contains(" ")); +// System.out.println(string.contains("")); +// System.out.println(string.contains(" ")); +// String[] split3 = string.split(" "); +// model.addRow(split3); +// } +// +//// +// +// +// System.out.println(obj.toString().replaceAll(" ", "111")); +// } catch (UnsupportedFlavorException e111) { +// // TODO Auto-generated catch block +// e111.printStackTrace(); +// } catch (IOException e11) { +// // TODO Auto-generated catch block +// e11.printStackTrace(); +// } +// } +// } +// }); +// +// designPanel.add(new JScrollPane(mainTable), BorderLayout.CENTER); +// +// dialog.pack(); +// dialog. validate(); +//// designPanel.centerToScreen(); +// dialog.setVisible(true); +// showDialog(); + } + + public static DefaultTableModel getTableModel(DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + DefaultTableModel tableModel = null; + if (dtm == null) { + tableModel = new DefaultTableModel(values, titleNames) { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + } + + return tableModel; + } + + + + + public static JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(getTableModel(dtm, titleNames, values)); + partsTable.setRowHeight(20); + RowSorter sorter = new TableRowSorter(partsTable.getModel()); + partsTable.setRowSorter(sorter); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + +private static void addNode(DefaultMutableTreeNode childNode, String string) { + // TODO Auto-generated method stub + DefaultMutableTreeNode node1 = new DefaultMutableTreeNode(string); + childNode.add(node1); +} + // public static void showDialog() { +// pack(); +// validate(); +// centerToScreen(); +// setVisible(true); +// } + public static File saveExcelChooser(String defaultFile,String item_id) { + File dir = null; + JFileChooser chooser = new JFileChooser(); + chooser.setAcceptAllFileFilterUsed(false); +// File currentDir = FileSystemView.getFileSystemView().getDefaultDirectory(); + File desktopDir = FileSystemView.getFileSystemView().getHomeDirectory(); + chooser.setCurrentDirectory(desktopDir); + chooser.setSelectedFile(new File(defaultFile)); + String saveType[] = { "xlsx" }; + chooser.setFileFilter(new FileNameExtensionFilter("Excel工作簿", saveType)); + int returnVal = chooser.showSaveDialog(new Frame()); + if (returnVal == JFileChooser.APPROVE_OPTION) { + + dir = chooser.getSelectedFile(); + String path = dir.getPath(); + String substring = path.substring(path.lastIndexOf("\\")); + substring=item_id+substring; + path=dir.getParent()+File.separator+substring.replace("\\", "_"); + System.out.println(path); + if(!path.toLowerCase().endsWith(".xlsx")) { + path += ".xlsx"; + dir = new File(path); + } + if(dir.exists()) + dir.delete(); +// System.out.println("saveExcelChooser1:" + dir.getPath()); + } + return dir; + } + public static List doPost(Map itemCheckMap,TCSession session) { + HashMap preferenceHashMap = TCPreferenceUitl.getPreferenceHashMap(session, TCPreferenceService.TC_preference_site, erpPreference); + String url = preferenceHashMap.get("url"); + String token = preferenceHashMap.get("token"); + JSONObject itemCheckJson = JSONObject.fromObject(itemCheckMap); + String svr="TcERPUserMap"; + try { + System.out.println("开始发送请求"); + String args = itemCheckJson.toString(); + System.out.println(args); + token = URLEncoder.encode(token,"UTF-8"); + svr = URLEncoder.encode(svr,"UTF-8"); + args = URLEncoder.encode(args,"UTF-8"); + String param = "usr="+token+"&svr="+svr+"&args="+args; + + System.out.println("url=============="+url); + System.out.println("param==========="+args + "svr"+svr); + String response = HttpUtil.doPost(url,param); + JSONObject jsonObject = JSONObject.fromObject(response); + + System.out.println("json格式==============="+jsonObject); + + if(jsonObject.has("cont")) { + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); + + if(jsonObject2.has("TC_ERP_USER")) { + JSONArray jsonObject3 = jsonObject2.getJSONArray("TC_ERP_USER"); + List list = JSONArray.toList(jsonObject3,UserList.class); + if (list.size()==0) { + MessageBox.post("“此TC账号未关联ERP账号,请联系管理员处理”","提示",MessageBox.INFORMATION); + } + return list; + } + } + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return null; + } + + public static boolean isEmpty(String str) { + return str == null || "".equals(str.trim()); + } + public static String getText(TCSession session, String str) throws Exception { + if (isEmpty(str)) { + return str; + } else { + String res = session.getTextService().getTextValue(str); + return !isEmpty(res) ? res : str; + } + } + public static int getLen(Object[] arr) { + return arr == null ? 0 : arr.length; + } + + public static TCComponent[] query(TCSession session, String queryName, String[] keys, String[] vals) + throws Exception { + System.out.println("Query: " + queryName); + System.out.println("keys = " + Arrays.toString(keys)); + System.out.println("vals = " + Arrays.toString(vals)); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + System.out.println("null"+queryName); + } else { + query.clearCache(); + query.refresh(); + return query.execute(keys, vals); + } + return null; + } + + public static TCComponentItemRevision getItemRevision(TCSession session, String itemId,String itemRevId) throws Exception { + System.out.println("Search Revision: " + itemId+itemRevId); + if (isEmpty(itemId) || isEmpty(itemRevId)) { + return null; + } else { + String queryName = "Item Revision..."; + String[] keys = new String[]{getText(session, "ItemID"),getText(session, "Revision")}; + String[] vals = new String[]{itemId,itemRevId}; + TCComponent[] res = query(session, queryName, keys, vals); + int len = getLen(res); + if (len == 0) { + return null; + } else if (len > 1) { + System.out.println("找到了多个rev"); + } else { + return (TCComponentItemRevision) res[0]; + } + } + return null; + } + + public static void InsertData(String itemId,String taskType,String taskNumber,String userName,String item_rev,TCSession session) { + PreparedStatement stmt = null; + Connection con =null; + String sql = "insert into connor_ERP_record (ItemId,TaskType,TaskNumber,ImpDate,UserName,Rev_Id) values(?,?,?,to_date(?,'yyyy-fmmm-dd hh24:mi'),?,?)";// + try { + con = ConnectionFun(session); + stmt = con.prepareStatement(sql); + stmt.setString(1, itemId); + stmt.setString(2, taskType); + stmt.setString(3, taskNumber); +// Date javaDate = null; +// try { +// javaDate = df.parse(impDate); +// } catch (ParseException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// java.sql.Date sqlDate = new java.sql.Date(javaDate.getTime()); + stmt.setString(4, df.format(new Date())); + stmt.setString(5, userName); + stmt.setString(6, item_rev); + stmt.executeUpdate(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + public static Connection ConnectionFun(TCSession session) throws SQLException { + String[] stringArray = session.getPreferenceService().getStringValues("connor_oracle_connection"); + + String url = "jdbc:oracle:thin:@" + stringArray[0];// + + String oracleUser = stringArray[1];// + + String password = stringArray[2];// + + Connection conn = null;// + + try { + System.out.println(url); + System.out.println(oracleUser); + System.out.println(password); + Class.forName("oracle.jdbc.driver.OracleDriver"); + System.out.println("驱动加载成功"); + } catch (ClassNotFoundException e) { + System.out.println("驱动加载失败"); + } + + conn = DriverManager.getConnection(url, oracleUser, password); + + System.out.println("数据库连接成功"); + return conn; + + } +} diff --git a/src/com/connor/erp/BomChgTransferToERP/KUtil.java b/src/com/connor/erp/BomChgTransferToERP/KUtil.java new file mode 100644 index 0000000..0d0269b --- /dev/null +++ b/src/com/connor/erp/BomChgTransferToERP/KUtil.java @@ -0,0 +1,35 @@ +package com.connor.erp.BomChgTransferToERP; + +import java.awt.Component; +import java.awt.GridBagConstraints; + +import javax.swing.JDialog; +import javax.swing.JPanel; + +public class KUtil { + public static void newRow(JPanel panel, Component comp, GridBagConstraints s, int width) { newRow(panel, comp, s, width, 0.0D); } + /* */ + /* */ + /* */ public static void newRow(JPanel panel, Component comp, GridBagConstraints s, int width, double weightx) { + /* 555 */ s.weightx = weightx; + /* 556 */ s.gridwidth = width; + /* 557 */ s.gridx = 0; + /* 558 */ s.gridy++; + /* 559 */ panel.add(comp, s); + /* */ } + /* */ + /* */ public static void newRow(JDialog panel, Component comp, GridBagConstraints s, int width) { + /* 563 */ s.weightx = 0.0D; + /* 564 */ s.gridwidth = width; + /* 565 */ s.gridx = 0; + /* 566 */ s.gridy++; + /* 567 */ panel.add(comp, s); + /* */ } + /* */ + /* */ public static void addCol(JPanel panel, Component comp, GridBagConstraints s, int width, double weightx) { + /* 571 */ s.gridx++; + /* 572 */ s.gridwidth = width; + /* 573 */ s.weightx = weightx; + /* 574 */ panel.add(comp, s); + /* */ } +} diff --git a/src/com/connor/erp/BomChgTransferToERP/UserList.java b/src/com/connor/erp/BomChgTransferToERP/UserList.java new file mode 100644 index 0000000..aae17d1 --- /dev/null +++ b/src/com/connor/erp/BomChgTransferToERP/UserList.java @@ -0,0 +1,33 @@ +package com.connor.erp.BomChgTransferToERP; + +public class UserList { + + private String TC_USER_CODE; + private String ERP_USER_ID; + private String ERP_USER_DESC; + private String ERP_USER_CODE; + public String getTC_USER_CODE() { + return TC_USER_CODE; + } + public void setTC_USER_CODE(String tC_USER_CODE) { + TC_USER_CODE = tC_USER_CODE; + } + public String getERP_USER_ID() { + return ERP_USER_ID; + } + public void setERP_USER_ID(String eRP_USER_ID) { + ERP_USER_ID = eRP_USER_ID; + } + public String getERP_USER_DESC() { + return ERP_USER_DESC; + } + public void setERP_USER_DESC(String eRP_USER_DESC) { + ERP_USER_DESC = eRP_USER_DESC; + } + public String getERP_USER_CODE() { + return ERP_USER_CODE; + } + public void setERP_USER_CODE(String eRP_USER_CODE) { + ERP_USER_CODE = eRP_USER_CODE; + } +} diff --git a/src/com/connor/erp/BomImport/BomTransferCommand.java b/src/com/connor/erp/BomImport/BomTransferCommand.java new file mode 100644 index 0000000..1aaf736 --- /dev/null +++ b/src/com/connor/erp/BomImport/BomTransferCommand.java @@ -0,0 +1,1393 @@ + package com.connor.erp.BomImport; + + import com.connor.erp.BomAddTransferToERP.BomAddTransferDialog; + import com.connor.erp.BomChgTransferToERP.BomChgTransferDialog; +import com.connor.erp.BomChgTransferToERP.DBUtils; +import com.connor.erp.toolkit.AimType; + import com.connor.erp.toolkit.FileType; + import com.connor.erp.toolkit.IsContinueDialog; + import com.connor.erp.toolkit.UtilApi; + import com.teamcenter.rac.aif.AbstractAIFCommand; + import com.teamcenter.rac.aif.AbstractAIFOperation; + import com.teamcenter.rac.aif.AbstractAIFUIApplication; + import com.teamcenter.rac.aif.kernel.AIFComponentContext; + import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; + import com.teamcenter.rac.kernel.TCComponent; + import com.teamcenter.rac.kernel.TCComponentBOMLine; + import com.teamcenter.rac.kernel.TCComponentForm; + import com.teamcenter.rac.kernel.TCComponentItemRevision; + import com.teamcenter.rac.kernel.TCComponentMEProcess; + import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; + import com.teamcenter.rac.kernel.TCComponentSignoff; + import com.teamcenter.rac.kernel.TCComponentTask; + import com.teamcenter.rac.kernel.TCComponentUser; + import com.teamcenter.rac.kernel.TCException; + import com.teamcenter.rac.kernel.TCPreferenceService; + import com.teamcenter.rac.kernel.TCSession; + import com.teamcenter.rac.kernel.TCUserService; + import com.teamcenter.rac.pse.operations.UnpackOperation; + import com.teamcenter.rac.util.MessageBox; + import java.util.ArrayList; + import java.util.HashMap; + import java.util.List; + import java.util.Map; + import java.util.Vector; + import javax.swing.SwingUtilities; + + public class BomTransferCommand extends AbstractAIFCommand { + private static final String NHL_BOMTRANSFERTYPE = "NHL_BomTrasferType"; + + private static final String NHL_BOMIMPERP_PRIVILEGES = "NHL_BOMimpERP_Privileges"; + + private static final String NHL_BOMIMPERP_MENUAUTH = "NHL_BOMimpERP_MenuAuth"; + + public TCSession session; + + public AbstractAIFUIApplication application; + +/* 62 */ public List NoBomItemRevisions = new ArrayList(); + +/* 63 */ public List ItemRevisions = new ArrayList(); + +/* 64 */ public Map>> id_to_list_map = new HashMap>>(); + +/* 65 */ public Vector> data = new Vector>(); + + private boolean isPrivilege = false; + + private TCPreferenceService ps; + + TCComponentUser currentUser; + + int targetNum; + +/* 75 */ List listItemTypes = new ArrayList(); + +/* 77 */ List listProcessTypes = new ArrayList(); + + private StringBuffer resultInfo; + + private StringBuffer detailInfo; + +/* 82 */ private Map itemToMeprocessMap = new HashMap(); + + private InterfaceAIFComponent[] targets; + + public BomTransferCommand(TCSession pSession, AbstractAIFUIApplication app) { +/* 86 */ this.session = pSession; +/* 87 */ this.application = app; + } + + private void addItemRevision(TCComponentMEProcessRevision meprocessRev, TCComponentItemRevision itemRev) { +/* 102 */ if (this.ItemRevisions.contains(itemRev) || this.NoBomItemRevisions.contains(itemRev)) + return; + try { +/* 106 */ if ((itemRev.getRelatedComponents("ps_children")).length > 0 || "NHL8_PartsProRevision".equals(meprocessRev.getType()) ) { +/* 107 */ this.ItemRevisions.add(itemRev); + } else { +/* 109 */ this.NoBomItemRevisions.add(itemRev); + } +/* 111 */ } catch (TCException tcEx) { +/* 112 */ tcEx.printStackTrace(); + } + } + + public void checkTarget(AimType aimType) { +/* 117 */ this.targets = this.application.getTargetComponents(); +/* 118 */ if (this.targets == null || this.targets.length == 0) { +/* 119 */ MessageBox.post(this.application.getDesktop().getShell(), " 请选择一个对象", "警告", 4); + return; + } +/* 122 */ this.ps = this.session.getPreferenceService(); +/* 123 */ String[] NHL8_BomTrasferType = this.ps.getStringArray(4, "NHL_BomTrasferType"); +/* 125 */ this.listProcessTypes.add("NHL8_AssemblyProRevision"); +/* 126 */ this.listProcessTypes.add("NHL8_PartsProRevision"); +this.listProcessTypes.add("NHL8_DivergeProRevision"); +/* 127 */ if (NHL8_BomTrasferType == null || NHL8_BomTrasferType.length == 0) { +/* 128 */ MessageBox.post("首选项NHL_BomTrasferType尚未配置,请联系系统管理员!", "提示", 4); + } else { +/* 130 */ int typesLen = NHL8_BomTrasferType.length; +/* 131 */ for (int n = 0; n < typesLen; n++) +/* 132 */ this.listItemTypes.add(NHL8_BomTrasferType[n]); + } +/* 136 */ String[] userNames = this.ps.getStringArray(4, "NHL_BOMimpERP_Privileges"); +/* 137 */ this.currentUser = this.session.getUser(); +/* 138 */ String userID = ""; + try { +/* 140 */ userID = this.currentUser.getProperty("user_id"); +/* 141 */ } catch (TCException e1) { +/* 142 */ e1.printStackTrace(); + } +/* 144 */ if (userNames != null && userNames.length > 0) { +/* 145 */ int nameLen = userNames.length; +/* 146 */ for (int i = 0; i < nameLen; i++) { +/* 147 */ if (userNames[i].trim().equals(userID)) { +/* 148 */ this.isPrivilege = true; //首选项配的权限 + break; + } + } + } else { +/* 153 */ MessageBox.post(this.application.getDesktop().getShell(), "请配置首选项NHL_BOMimpERP_Privileges!!", "警告", 4); + return; + } +/* 156 */ this.targetNum = this.targets.length; +/* 157 */ TCComponent targetComponent = (TCComponent)this.targets[0]; +/* 158 */ String targetType = ""; +/* 159 */ if (targetComponent instanceof TCComponentBOMLine) { //bomline对象获取item版本的类型 +/* 160 */ if (!this.isPrivilege) { +/* 161 */ MessageBox.post(this.application.getDesktop().getShell(), "您是普通用户权限不够,请联系管理员!", "警告", 4); + return; + } + try { +/* 165 */ targetType = ((TCComponentBOMLine)targetComponent).getItemRevision().getType(); +/* 166 */ } catch (TCException e) { +/* 167 */ e.printStackTrace(); + } + } else { +/* 170 */ targetType = targetComponent.getType(); + } +/* 173 */ if (targetComponent instanceof TCComponentTask) { //选择的类型要是流程中的 或者是工艺的 +/* 174 */ if (this.isPrivilege) { + String errMsgCheck=""; +/* 175 */ StringBuffer resultInfo = new StringBuffer(""); +/* 176 */ StringBuffer detailInfo = new StringBuffer(""); +/* 177 */ for (int i = 0; i < this.targetNum; i++) { +/* 178 */ if (this.targets[i] instanceof TCComponentTask) { + +/* 179 */ TCComponentTask task = (TCComponentTask)this.targets[i]; + try { +/* 181 */ TCComponent[] attachmentComponents = task.getRelatedComponents("root_target_attachments"); +/* 182 */ int attachmentsLen = attachmentComponents.length; +/* 183 */ for (int j = 0; j < attachmentsLen; j++) { +/* 184 */ String type = attachmentComponents[j].getType(); +/* 185 */ if (this.listProcessTypes.contains(type)) { +/* 186 */ TCComponentMEProcessRevision meprocessRev = (TCComponentMEProcessRevision)attachmentComponents[j]; +/* 187 */ TCComponent[] metargets = meprocessRev.getRelatedComponents("IMAN_METarget"); +/* 188 */ int metargetsLen = metargets.length; +/* 189 */ if (metargetsLen > 0) { + + +/* 190 */ TCComponentItemRevision itemRev = (TCComponentItemRevision)metargets[0]; + + if(meprocessRev.getType().equals("NHL8_AssemblyProRevision")){ + if(itemRev.getType().equals("NHL8_PartsRevision") ||itemRev.getType().equals("NHL8_ProductRevision") ) { + TCComponent masterRev = meprocessRev.getRelatedComponent("IMAN_master_form_rev"); + boolean isfpass = masterRev.getLogicalProperty("nhl8_isfPass"); + if(!isfpass) { + TCComponent relatedComponent = itemRev.getRelatedComponent("IMAN_master_form_rev"); + String itemId = meprocessRev.getStringProperty("item_id"); + Object obj[] = new Object[1]; + obj[0] = 1; + TCUserService service = session.getUserService(); + service.call("openByPass", obj); + relatedComponent.setLogicalProperty("nhl8_BOMimpSucc", true); + service.call("closeByPass", obj); + errMsgCheck=errMsgCheck+itemId+"的设计BOM和工艺BOM不一致\n"; +// MessageBox.post("设计BOM和工艺BOM不一致,无法执行BOM导入ERP操作,请在ERP中手" +// + "动录入工艺BOM。BOM录入成功后,可直接完成该任务节点。","提示",2); +// return; + } + } + } + +/* 191 */ this.itemToMeprocessMap.put(itemRev, meprocessRev); +/* 192 */ String comType = itemRev.getType(); +/* 193 */ if (!this.listItemTypes.contains(comType)) +/* 194 */ detailInfo.append(itemRev + "类型不在首选项中存在
"); +/* 196 */ addItemRevision(meprocessRev, itemRev); + } + } + } +/* 200 */ } catch (TCException e) { +/* 201 */ e.printStackTrace(); +/* 202 */ } catch (Exception e) { +/* 203 */ e.printStackTrace(); + } + } else { +/* 206 */ MessageBox.post(this.application.getDesktop().getShell(), "请确认选中的是任务对象!!", "警告", 4); + return; + } + } + if(!errMsgCheck.equals("")) { + errMsgCheck=errMsgCheck+"无法执行BOM导入ERP操作,请在ERP中手" + + "动录入工艺BOM。BOM录入成功后,可直接完成该任务节点"; + MessageBox.post(errMsgCheck,"提示",2); + return; + } +/* 210 */ if (!detailInfo.toString().equals("")) { +/* 211 */ resultInfo.append("所选或提取制造目标的业务对象类型在首选项中不存在
"); +/* 212 */ loadDataForPrivilege(aimType, resultInfo, detailInfo); + } else { +/* 214 */ loadDataForPrivilege(aimType, new StringBuffer(""), new StringBuffer("")); + } +/* 217 */ } else if (aimType.toString().equals("add")) { +/* 218 */ if (!UtilApi.getTaskBomAddResult(this.application, this.session, FileType.bom, "BOM传递新增结果", this, "task", aimType)) + return; +/* 221 */ } else if (aimType.toString().equals("chg") && +/* 222 */ !UtilApi.getTaskBomChgResult(this.application, this.session, FileType.bom, "BOM传递变更结果", this, "task", aimType)) { + return; + } +/* 227 */ } else if (this.listItemTypes.contains(targetType) || this.listProcessTypes.contains(targetType)) { +/* 228 */ if (this.isPrivilege) { +/* 229 */ StringBuffer resultInfo = new StringBuffer(""); +/* 230 */ StringBuffer detailInfo = new StringBuffer(""); +/* 231 */ boolean notFind = false; +/* 232 */ boolean findMore = false; +/* 233 */ for (int i = 0; i < this.targetNum; i++) { +/* 234 */ String type = ""; +/* 235 */ TCComponentItemRevision revision = null; +/* 236 */ TCComponentMEProcessRevision meprocessRev = null; +/* 237 */ if (this.targets[i] instanceof TCComponentBOMLine) { + try { +/* 239 */ revision = ((TCComponentBOMLine)this.targets[i]).getItemRevision(); +/* 240 */ if (revision instanceof TCComponentMEProcessRevision) +/* 241 */ meprocessRev = (TCComponentMEProcessRevision)this.targets[i]; +/* 243 */ type = revision.getType(); +/* 244 */ } catch (TCException e) { +/* 245 */ e.printStackTrace(); + } + } else { +/* 248 */ revision = (TCComponentItemRevision)this.targets[i]; + +// String revisionType =revision.getType(); +// +// if(revisionType.equals("NHL8_PartsRevision")||revisionType.equals("NHL8_ProductRevision") +// ||revisionType.equals("NHL8_FixtureRevision")) { +// TCComponent masterComponent; +// try { +// masterComponent = revision.getRelatedComponent("IMAN_master_form_rev"); +// boolean isfpass = masterComponent.getLogicalProperty("nhl8_isfPass"); +// if(!isfpass) { +// MessageBox.post("设计BOM和工艺BOM不一致,无法执行BOM导入ERP操作,请在ERP中手" +// + "动录入工艺BOM。BOM录入成功后,可直接完成该任务节点。","提示",2); +// return; +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } + +/* 249 */ if (revision instanceof TCComponentMEProcessRevision) +/* 250 */ meprocessRev = (TCComponentMEProcessRevision)this.targets[i]; +/* 252 */ type = revision.getType(); + } +/* 254 */ if (this.listItemTypes.contains(type)) { +/* 255 */ AIFComponentContext[] referenceComponents = null; + try { +/* 257 */ referenceComponents = revision.whereReferenced(); +/* 258 */ } catch (TCException e) { +/* 259 */ e.printStackTrace(); + } +/* 261 */ TCComponentMEProcessRevision meprocess_rev = null; +/* 262 */ int referenceNum = referenceComponents.length; +/* 263 */ int meprocessNum = 0; +/* 264 */ for (int k = 0; k < referenceNum; k++) { +/* 265 */ String comtype = referenceComponents[k].getComponent().getType(); +/* 266 */ if (this.listProcessTypes.contains(comtype)) { + try { +/* 268 */ TCComponentMEProcess meprocessItem = (TCComponentMEProcess)((TCComponentMEProcessRevision)referenceComponents[k].getComponent()).getItem(); +/* 269 */ TCComponentItemRevision[] releaseRevisions = meprocessItem.getReleasedItemRevisions(); +/* 270 */ int releaseRevisionNum = releaseRevisions.length; +/* 271 */ if (releaseRevisionNum > 0) { +/* 272 */ meprocess_rev = (TCComponentMEProcessRevision)releaseRevisions[0]; + } else { +/* 274 */ meprocess_rev = (TCComponentMEProcessRevision)meprocessItem.getLatestItemRevision(); + } +/* 276 */ } catch (TCException e) { +/* 277 */ e.printStackTrace(); + } +/* 279 */ meprocessNum++; + } + } + +/* 282 */ System.out.println("265 meprocess_rev===" + meprocess_rev); + + +/* 283 */ if (meprocess_rev != null) { + + + if(meprocessRev.getType().equals("NHL8_AssemblyProRevision")){ + if(revision.getType().equals("NHL8_PartsRevision") ||revision.getType().equals("NHL8_ProductRevision") ) { + TCComponent masterRev; + try { + masterRev = meprocess_rev.getRelatedComponent("IMAN_master_form_rev"); + boolean isfpass = masterRev.getLogicalProperty("nhl8_isfPass"); + + + if(!isfpass) { + TCComponent relatedComponent = revision.getRelatedComponent("IMAN_master_form_rev"); + Object obj[] = new Object[1]; + obj[0] = 1; + TCUserService service = session.getUserService(); + service.call("openByPass", obj); + relatedComponent.setLogicalProperty("nhl8_BOMimpSucc", true); + service.call("closeByPass", obj); + MessageBox.post("设计BOM和工艺BOM不一致,无法执行BOM导入ERP操作,请在ERP中手" + + "动录入工艺BOM。BOM录入成功后,可直接完成该任务节点。","提示",2); + return; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + +/* 284 */ if (meprocessNum > 1) { +/* 285 */ findMore = true; +/* 286 */ detailInfo.append(revision + "找到多个关联的工艺版本对象
"); + } +/* 288 */ this.itemToMeprocessMap.put(revision, meprocess_rev); +/* 289 */ addItemRevision(meprocess_rev, revision); + } else { +/* 291 */ notFind = true; +/* 292 */ addItemRevision(meprocess_rev, revision); +/* 293 */ detailInfo.append(revision + "没有找到关联的工艺对象
"); + } +/* 295 */ } else if (this.listProcessTypes.contains(type)) { +/* 296 */ TCComponent[] metargets = null; + try { +/* 298 */ metargets = meprocessRev.getRelatedComponents("IMAN_METarget"); + +/* 299 */ } catch (TCException e) { +/* 300 */ e.printStackTrace(); + } +/* 302 */ int metargetsLen = metargets.length; +/* 303 */ if (metargetsLen == 0) { +/* 304 */ MessageBox.post(meprocessRev + "制造目标关系没有关联任何零组件!", "提示", 4); + return; + } +/* 307 */ TCComponentItemRevision itemRev = (TCComponentItemRevision)metargets[0]; +if(meprocessRev.getType().equals("NHL8_AssemblyProRevision")){ + if(itemRev.getType().equals("NHL8_PartsRevision") ||itemRev.getType().equals("NHL8_ProductRevision") ) { + TCComponent masterRev; + try { + masterRev = meprocessRev.getRelatedComponent("IMAN_master_form_rev"); + boolean isfpass = masterRev.getLogicalProperty("nhl8_isfPass"); + + + if(!isfpass) { + TCComponent relatedComponent = itemRev.getRelatedComponent("IMAN_master_form_rev"); + Object obj[] = new Object[1]; + obj[0] = 1; + TCUserService service = session.getUserService(); + service.call("openByPass", obj); + relatedComponent.setLogicalProperty("nhl8_BOMimpSucc", true); + service.call("closeByPass", obj); + MessageBox.post("设计BOM和工艺BOM不一致,无法执行BOM导入ERP操作,请在ERP中手" + + "动录入工艺BOM。BOM录入成功后,可直接完成该任务节点。","提示",2); + return; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } +} + +/* 308 */ this.itemToMeprocessMap.put(itemRev, meprocessRev); +/* 309 */ String comType = itemRev.getType(); +/* 310 */ if (this.listItemTypes.contains(comType)) { +/* 311 */ addItemRevision(meprocessRev, itemRev); + } else { +/* 313 */ MessageBox.post(meprocessRev + "制造目标关系关联零组件类型没有在首选项中配置!", "提示", 4); + return; + } + } else { +/* 318 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中首选项中配置的Item版本对象!!", "警告", 4); + return; + } + } +/* 322 */ if (notFind) +/* 323 */ resultInfo.append("有部分零组件对象没有关联的工艺对象
"); +/* 325 */ if (findMore) +/* 326 */ resultInfo.append("有部分零组件对象找到多个关联的工艺版本对象
"); +/* 328 */ if (!detailInfo.toString().equals("")) { +/* 329 */ loadDataForPrivilege(aimType, resultInfo, detailInfo); + } else { +/* 331 */ loadDataForPrivilege(aimType, new StringBuffer(""), new StringBuffer("")); + } +/* 334 */ } else if (aimType.toString().equals("add")) { +/* 335 */ if (!UtilApi.getTaskBomAddResult(this.application, this.session, FileType.bom, "BOM传递新增结果", this, "bom", aimType)) { + return; + } + +/* 338 */ } else if (aimType.toString().equals("chg") && +/* 339 */ !UtilApi.getTaskBomChgResult(this.application, this.session, FileType.bom, "BOM传递变更结果", this, "bom", aimType)) { + return; + } + } else { +/* 345 */ MessageBox.post(this.application.getDesktop().getShell(), "请您选择流程中的任务或工艺版本对象!!!", "警告", 4); + return; + } + } +// gettarget + + public void postDialogForTask(AimType aimType) { +/* 351 */ List listProcessAndTaskNames = new ArrayList(); +/* 352 */ String[] processAndTaskNames = this.ps.getStringArray(4, "NHL_BOMimpERP_MenuAuth"); +/* 353 */ if (processAndTaskNames == null || processAndTaskNames.length == 0) { +/* 354 */ MessageBox.post("首选项NHL_BOMimpERP_MenuAuth尚未配置,请联系系统管理员!", "提示", 4); + return; + } +/* 357 */ int nameLen = processAndTaskNames.length; +/* 358 */ for (int j = 0; j < nameLen; j++) +/* 359 */ listProcessAndTaskNames.add(processAndTaskNames[j].trim().replace(":", ":")); +/* 362 */ for (int i = 0; i < this.targetNum; i++) { +/* 363 */ if (this.targets[i] instanceof TCComponentTask) { +/* 364 */ TCComponentTask task = (TCComponentTask)this.targets[i]; +/* 365 */ String taskType = task.getType(); +/* 366 */ String processAndTaskName = ""; +/* 367 */ boolean isTaskPerformer = false; + String errMsgCheck=""; + try { +/* 369 */ if (taskType.equals("EPMPerformSignoffTask")) { +/* 370 */ processAndTaskName = task.getRoot().getProcessDefinition().getName() + ":" + task.getParent().getName(); +/* 371 */ TCComponentSignoff[] signoffs = task.getPredecessors()[0].getValidSignoffs(); +/* 372 */ int signoffNum = signoffs.length; +/* 373 */ for (int k = 0; k < signoffNum; k++) { +/* 374 */ if (signoffs[k].getGroupMember().getUser().equals(this.currentUser)) { +/* 375 */ isTaskPerformer = true; + break; + } + } + } +/* 380 */ if (listProcessAndTaskNames.contains(processAndTaskName) && isTaskPerformer) { +/* 381 */ TCComponent[] attachmentComponents = task.getRelatedComponents("root_target_attachments"); +/* 382 */ int attachmentsLen = attachmentComponents.length; +/* 383 */ for (int k = 0; k < attachmentsLen; k++) { +/* 384 */ String type = attachmentComponents[k].getType(); + + +/* 385 */ if (this.listProcessTypes.contains(type)) { +/* 386 */ TCComponentMEProcessRevision meprocessRev = (TCComponentMEProcessRevision)attachmentComponents[k]; +/* 387 */ TCComponent[] metargets = meprocessRev.getRelatedComponents("IMAN_METarget"); +/* 388 */ int metargetsLen = metargets.length; +/* 389 */ if (metargetsLen == 0) { +/* 390 */ MessageBox.post(meprocessRev + "制造目标关系没有关联任何零组件!", "提示", 4); + return; + } +/* 393 */ TCComponentItemRevision itemRev = (TCComponentItemRevision)metargets[0]; + + + if(meprocessRev.getType().equals("NHL8_AssemblyProRevision")){ + if(itemRev.getType().equals("NHL8_PartsRevision") ||itemRev.getType().equals("NHL8_ProductRevision") ) { + TCComponent masterRev; + try { + masterRev = meprocessRev.getRelatedComponent("IMAN_master_form_rev"); + boolean isfpass = masterRev.getLogicalProperty("nhl8_isfPass"); + String itemId = meprocessRev.getStringProperty("item_id"); + + if(!isfpass) { + TCComponent relatedComponent = itemRev.getRelatedComponent("IMAN_master_form_rev"); + Object obj[] = new Object[1]; + obj[0] = 1; + TCUserService service = session.getUserService(); + service.call("openByPass", obj); + relatedComponent.setLogicalProperty("nhl8_BOMimpSucc", true); + service.call("closeByPass", obj); + // MessageBox.post("设计BOM和工艺BOM不一致,无法执行BOM导入ERP操作,请在ERP中手" + // + "动录入工艺BOM。BOM录入成功后,可直接完成该任务节点。","提示",2); + // return; + errMsgCheck=errMsgCheck+itemId+"的设计BOM和工艺BOM不一致\n"; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + } + +/* 394 */ this.itemToMeprocessMap.put(itemRev, meprocessRev); +/* 395 */ String comType = itemRev.getType(); +/* 396 */ if (this.listItemTypes.contains(comType)) { +/* 397 */ addItemRevision(meprocessRev, itemRev); + } else { +/* 399 */ MessageBox.post(meprocessRev + "制造目标关系关联零组件类型没有在首选项中配置!", "提示", 4); + return; + } + } + } + } else { +/* 406 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中有权限的任务对象!!", "警告", 4); + return; + } +/* 409 */ } catch (TCException e) { +/* 410 */ e.printStackTrace(); +/* 411 */ } catch (Exception e) { +/* 412 */ e.printStackTrace(); + } + if(!errMsgCheck.equals("")) { + errMsgCheck=errMsgCheck+"无法执行BOM导入ERP操作,请在ERP中手" + + "动录入工艺BOM。BOM录入成功后,可直接完成该任务节点"; + MessageBox.post(errMsgCheck,"提示",2); + return; + } + } else { +/* 415 */ MessageBox.post(this.application.getDesktop().getShell(), "请确认选中的是任务对象!!", "警告", 4); + return; + } + } +/* 419 */ loadData(aimType); + } + + public void postDialogForBom(AimType aimType) { +/* 423 */ List listProcessAndTaskNames = new ArrayList(); +/* 424 */ String[] processAndTaskNames = this.ps.getStringArray(4, "NHL_BOMimpERP_MenuAuth"); +/* 425 */ if (processAndTaskNames == null || processAndTaskNames.length == 0) { +/* 426 */ MessageBox.post("首选项NHL_BOMimpERP_MenuAuth尚未配置,请联系系统管理员!", "提示", 4); + } else { +/* 428 */ int nameLen = processAndTaskNames.length; +/* 429 */ for (int j = 0; j < nameLen; j++) +/* 430 */ listProcessAndTaskNames.add(processAndTaskNames[j].trim().replace(":", ":")); + } +/* 433 */ for (int i = 0; i < this.targetNum; i++) { +/* 434 */ String type = this.targets[i].getType(); + + +/* 435 */ if (this.listProcessTypes.contains(type)) { +/* 436 */ TCComponentMEProcessRevision meprocessRev = (TCComponentMEProcessRevision)this.targets[i]; +/* 437 */ TCComponent[] metargets = null; + try { +/* 439 */ metargets = meprocessRev.getRelatedComponents("IMAN_METarget"); +/* 440 */ } catch (TCException e) { +/* 441 */ e.printStackTrace(); + } +/* 443 */ int metargetsLen = metargets.length; +/* 444 */ if (metargetsLen == 0) { +/* 445 */ MessageBox.post(meprocessRev + "制造目标关系没有关联任何零组件!", "提示", 4); + return; + } +/* 448 */ TCComponentItemRevision itemRev = (TCComponentItemRevision)metargets[0]; + if(meprocessRev.getType().equals("NHL8_AssemblyProRevision")){ + if(itemRev.getType().equals("NHL8_PartsRevision") ||itemRev.getType().equals("NHL8_ProductRevision") ) { + TCComponent masterRev; + try { + masterRev = meprocessRev.getRelatedComponent("IMAN_master_form_rev"); + boolean isfpass = masterRev.getLogicalProperty("nhl8_isfPass"); + + + if(!isfpass) { + TCComponent relatedComponent = itemRev.getRelatedComponent("IMAN_master_form_rev"); + Object obj[] = new Object[1]; + obj[0] = 1; + TCUserService service = session.getUserService(); + service.call("openByPass", obj); + relatedComponent.setLogicalProperty("nhl8_BOMimpSucc", true); + service.call("closeByPass", obj); + MessageBox.post("设计BOM和工艺BOM不一致,无法执行BOM导入ERP操作,请在ERP中手" + + "动录入工艺BOM。BOM录入成功后,可直接完成该任务节点。","提示",2); + return; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + } + + try { +/* 450 */ if ((itemRev.getReferenceListProperty("release_status_list")).length == 0) { +/* 451 */ MessageBox.post(itemRev + " 对象未发布", "警告", 4); + return; + } +/* 454 */ } catch (TCException e) { +/* 455 */ e.printStackTrace(); + } +/* 457 */ if (!revRefRightProcess(meprocessRev, listProcessAndTaskNames)) + return; +/* 460 */ this.itemToMeprocessMap.put(itemRev, meprocessRev); +/* 461 */ String comType = itemRev.getType(); +/* 462 */ if (this.listItemTypes.contains(comType)) { +/* 463 */ addItemRevision(meprocessRev, itemRev); + } else { +/* 465 */ MessageBox.post(meprocessRev + "制造目标关系关联零组件类型没有在首选项中配置!", "提示", 4); + return; + } + } else { +/* 470 */ MessageBox.post(this.application.getDesktop().getShell(), "请您选择流程中的任务或工艺版本对象!!", "警告", 4); + return; + } + } +/* 474 */ loadData(aimType); + } + + private boolean revRefRightProcess(TCComponentMEProcessRevision meprocessRev, List listProcessAndTaskNames) { + try { +/* 479 */ TCComponent[] processStageList = meprocessRev.getReferenceListProperty("fnd0StartedWorkflowTasks"); +/* 480 */ int listSize = processStageList.length; +/* 481 */ TCComponentTask referenceTask = null; +/* 482 */ if (listSize > 0) { +/* 483 */ String rootTaskName = processStageList[0].getProperty("object_name"); +/* 484 */ for (int j = 1; j < listSize; j++) { +/* 485 */ if (listProcessAndTaskNames.contains(rootTaskName + ":" + processStageList[j].getProperty("object_name"))) { +/* 486 */ referenceTask = (TCComponentTask)processStageList[j]; + break; + } + } +/* 490 */ if (referenceTask != null) { +/* 491 */ TCComponentTask[] subTasks = referenceTask.getSubtasks(); +/* 492 */ int subTaskNum = subTasks.length; +/* 493 */ boolean isTaskPerformer = false; +/* 494 */ for (int i = 0; i < subTaskNum; i++) { +/* 495 */ TCComponentTask subTask = subTasks[i]; +/* 496 */ String taskType = subTask.getType(); +/* 497 */ if (taskType.equals("EPMPerformSignoffTask")) { +/* 498 */ TCComponentSignoff[] signoffs = subTask.getPredecessors()[0].getValidSignoffs(); +/* 499 */ int signoffNum = signoffs.length; +/* 500 */ for (int k = 0; k < signoffNum; k++) { +/* 501 */ if (signoffs[k].getGroupMember().getUser().equals(this.currentUser)) { +/* 502 */ isTaskPerformer = true; + break; + } + } + break; + } + } +/* 509 */ if (!isTaskPerformer) { +/* 510 */ MessageBox.post(this.application.getDesktop().getShell(), "请确定对工艺版本对象的操作权限!!", "警告", 4); +/* 511 */ return false; + } + } else { +/* 514 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中在正确流程节点中的工艺版本对象!!", "警告", 4); +/* 515 */ return false; + } + } else { +/* 518 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中在流程中的工艺版本对象!!", "警告", 4); +/* 519 */ return false; + } +/* 522 */ } catch (TCException e) { +/* 523 */ e.printStackTrace(); + } +/* 525 */ return true; + } + + public void loadDataForPrivilege(AimType aimType, StringBuffer resultInfo, StringBuffer detailInfo) { +/* 537 */ this.resultInfo = resultInfo; +/* 538 */ this.detailInfo = detailInfo; +/* 539 */ if (this.NoBomItemRevisions.size() > 0) { +/* 540 */ StringBuilder sb = new StringBuilder(); +/* 541 */ for (TCComponentItemRevision itemRev : this.NoBomItemRevisions) +/* 542 */ sb.append(itemRev + "没有子BOM
"); +/* 544 */ SwingUtilities.invokeLater((Runnable)new IsContinueDialog(this, "loadDataForPrivilege1", aimType, "有 " + this.NoBomItemRevisions.size() + " 个零组件没有子BOM对象", sb.toString())); + } else { +/* 546 */ loadDataForPrivilege1(aimType); + } + } + + public void loadDataForPrivilege1(AimType aimType) { +/* 553 */ if (this.NoBomItemRevisions.size() > 0) { +/* 554 */ Object[] obj = new Object[1]; +/* 555 */ obj[0] = Integer.valueOf(11); +/* 556 */ TCUserService service = this.session.getUserService(); +///* 557 */ for (TCComponentItemRevision itemRev : this.NoBomItemRevisions) { +// try { +///* 559 */ service.call("openByPass", obj); +///* 560 */ TCComponentForm form = (TCComponentForm)itemRev.getRelatedComponent("IMAN_master_form_rev"); +///* 561 */ form.setLogicalProperty("nhl8_BOMimpSucc", true); +///* 562 */ form.save(); +///* 563 */ service.call("closeByPass", obj); +///* 564 */ } catch (TCException e) { +///* 565 */ e.printStackTrace(); +// } +// } + } +/* 569 */ int revNum = this.ItemRevisions.size(); +/* 570 */ if (revNum == 0) { +/* 571 */ MessageBox.post("有子BOM的零组件的数量为0", "提示", 4); + return; + } +/* 574 */ int selectRevNoReleaseNum = 0; +/* 575 */ int materialNoReleaseNum = 0; +/* 576 */ int childRevNoReleaseNum = 0; +/* 577 */ for (int i = 0; i < revNum; i++) { + try { +/* 579 */ TCComponentItemRevision ItemRev = this.ItemRevisions.get(i); +/* 580 */ Map> item_map = new HashMap>(); +/* 581 */ TCComponent[] rev_release = ItemRev.getReferenceListProperty("release_status_list"); +/* 582 */ if (rev_release.length == 0) { +/* 583 */ selectRevNoReleaseNum++; +/* 584 */ this.detailInfo.append(ItemRev + " 对象未发布
"); + } +/* 587 */ List bl_child_list = new ArrayList(); +/* 588 */ List bl_quantity_list = new ArrayList(); +/* 589 */ List nhl8_step_num_list = new ArrayList(); +/* 590 */ List dataList = new ArrayList(); +/* 592 */ TCComponentMEProcessRevision parts_rev = null; +/* 593 */ TCComponentMEProcessRevision meprocess_rev = this.itemToMeprocessMap.get(ItemRev); + System.out.println("999 === meprocess_rev type name"+meprocess_rev.getType()+meprocess_rev); +/* 595 */ if (meprocess_rev != null && meprocess_rev.getType().equals("NHL8_PartsProRevision")) { + parts_rev = meprocess_rev; + } +/* 596 */ +/* 598 */ if (parts_rev != null) { +/* 599 */ TCComponent[] NHL8_MateriaRlation = parts_rev.getRelatedComponents("NHL8_MateriaRlation"); +/* 601 */ if (NHL8_MateriaRlation == null || NHL8_MateriaRlation.length == 0) { +/* 602 */ MessageBox.post(this.application.getDesktop().getShell(), parts_rev + "没有关联的原材料", "警告", 4); + return; + } +/* 606 */ TCComponentItemRevision materialCom = (TCComponentItemRevision)NHL8_MateriaRlation[0]; +/* 607 */ if ((materialCom.getReferenceListProperty("release_status_list")).length == 0) { +/* 608 */ materialNoReleaseNum++; +/* 609 */ this.detailInfo.append(materialCom + " 对象未发布
"); + } +/* 611 */ String[] revProNames = { "object_string", "item_id" }; +/* 612 */ String[] revProValues = ItemRev.getProperties(revProNames); +/* 613 */ String parent_obj_str = revProValues[0]; +/* 614 */ String parent_item_id = revProValues[1]; +/* 615 */ TCComponentForm partRevform = (TCComponentForm)parts_rev.getRelatedComponent("IMAN_master_form_rev"); +/* 616 */ double nhl8_GWeight = partRevform.getDoubleProperty("nhl8_GWeight"); +/* 617 */ String gweight_str = ""; +/* 619 */ if (NHL8_MateriaRlation[0].getType().equals("NHL8_RawMaterialRevision")) { + try { +/* 621 */ double quantityNum = UtilApi.div(nhl8_GWeight, 1000.0D); +/* 622 */ gweight_str = UtilApi.subZeroAndDot(String.valueOf(quantityNum)); +/* 623 */ } catch (NumberFormatException numberFormatException) { +/* 624 */ MessageBox.post(partRevform + "的毛重不能为空,请修改后再提交!", "错误", 1); + return; + } + } else { +/* 628 */ gweight_str = UtilApi.subZeroAndDot(String.valueOf(nhl8_GWeight)); + } +/* 630 */ String[] comProValues = materialCom.getProperties(revProNames); +/* 631 */ String bl_child_line_name = comProValues[0]; +/* 632 */ String bl_child_line_id = comProValues[1]; +/* 633 */ bl_child_list.add(bl_child_line_id); +/* 634 */ bl_quantity_list.add(gweight_str); +/* 635 */ nhl8_step_num_list.add("10_"); +/* 637 */ Vector vec = new Vector(); +/* 638 */ vec.add(Integer.valueOf(2)); +/* 639 */ vec.add(parent_obj_str); +/* 640 */ vec.add(bl_child_line_name); +/* 641 */ vec.add("10_"); +/* 642 */ vec.add(gweight_str); +/* 644 */ dataList.add(vec); +/* 645 */ item_map.put("item_name", bl_child_list); +/* 646 */ item_map.put("item_quantity", bl_quantity_list); +/* 647 */ item_map.put("operation_seq_num", nhl8_step_num_list); +/* 648 */ this.id_to_list_map.put(parent_item_id, item_map); +/* 651 */ for (int m = 0; m < dataList.size(); m++) { +/* 652 */ Vector vector = dataList.get(m); +/* 653 */ this.data.add(vector); + } + } else { +/* 657 */ TCComponentBOMLine topbomline = UtilApi.getNewBOMLine(this.session, ItemRev, null); +/* 658 */ String bl_line_name = topbomline.getProperty("bl_line_name"); +/* 659 */ String bl_line_id = topbomline.getProperty("bl_item_item_id"); +/* 660 */ AIFComponentContext[] childrenContexts = topbomline.getChildren(); +/* 661 */ int childCount = childrenContexts.length; +/* 662 */ boolean isNeedUnPack = false; +/* 663 */ List idList1 = new ArrayList(); +/* 664 */ Map idToQuantityMap1 = new HashMap(); +/* 665 */ for (int j = 0; j < childCount; j++) { + try { +/* 667 */ TCComponentBOMLine childbomline = (TCComponentBOMLine)childrenContexts[j].getComponent(); +/* 668 */ String bl_child_line_name = childbomline.getProperty("bl_line_name"); +/* 669 */ String bl_chlid_line_id = childbomline.getProperty("bl_item_item_id"); +/* 670 */ String bl_quantity = childbomline.getProperty("bl_quantity"); +/* 671 */ if (!bl_quantity.equals("")) { +/* 672 */ bl_quantity = UtilApi.subZeroAndDot(bl_quantity); + } else { + /* 674 */ bl_quantity = "1"; + } +/* 677 */ String nhl8_step_num = childbomline.getProperty("NHL8_step_num"); // 10_xxxx +/* 678 */ if (nhl8_step_num.equals("")) { +/* 679 */ MessageBox.post(this.application.getDesktop().getShell(), "设计BOM不能导入ERP,请重新选择!!!", "警告", 4); + return; + } +/* 682 */ if (nhl8_step_num.contains("已打包的注释")) { +/* 683 */ isNeedUnPack = true; +/* 685 */ } else if (nhl8_step_num.contains(",")) { +/* 686 */ String[] arrStr = nhl8_step_num.split(","); +/* 687 */ int arrLen = arrStr.length; +/* 688 */ for (int k = 0; k < arrLen; k++) { +/* 689 */ String[] str = arrStr[k].split("×"); + if(arrStr[k].contains("x")) { + str = arrStr[k].split("x"); + } +/* 690 */ nhl8_step_num = str[0]; +/* 691 */ bl_quantity = str[1]; + if(childbomline.getProperty("bl_occ_type").equals("MEDisassemble")|| childbomline.getProperty("bl_occ_type").equals("拆卸")) { + if(!bl_quantity.startsWith("-")) { + bl_quantity="-"+bl_quantity; + System.out.println("MEDisassemble"+bl_quantity); + } + } +/* 692 */ String id_and_stepNum = bl_chlid_line_id + "&" + bl_child_line_name + "&" + nhl8_step_num; +/* 693 */ System.out.println("666 id_and_stepNum==" + id_and_stepNum); +/* 694 */ if (!idList1.contains(id_and_stepNum)) +/* 695 */ idList1.add(id_and_stepNum); +/* 697 */ if (idToQuantityMap1.get(id_and_stepNum) == null) { +/* 698 */ idToQuantityMap1.put(id_and_stepNum, Double.valueOf(Double.parseDouble(bl_quantity))); + } else { + /* 700 */ idToQuantityMap1.put(id_and_stepNum, Double.valueOf(((Double)idToQuantityMap1.get(id_and_stepNum)).doubleValue() + Double.parseDouble(bl_quantity))); + } + } + } else { +/* 704 */ if (nhl8_step_num.contains("×")) { + nhl8_step_num = nhl8_step_num.split("×")[0]; + }else if (nhl8_step_num.contains("x")) { + nhl8_step_num = nhl8_step_num.split("x")[0]; + } +/* 705 */ if(childbomline.getProperty("bl_occ_type").equals("MEDisassemble")|| childbomline.getProperty("bl_occ_type").equals("拆卸")) { + if(!bl_quantity.startsWith("-")) { + bl_quantity="-"+bl_quantity; + System.out.println("MEDisassemble"+bl_quantity); + } + } +/* 707 */ String id_and_stepNum = bl_chlid_line_id + "&" + bl_child_line_name + "&" + nhl8_step_num; +/* 708 */ System.out.println("680 id_and_stepNum==" + id_and_stepNum); +/* 709 */ if (!idList1.contains(id_and_stepNum)) +/* 710 */ idList1.add(id_and_stepNum); +/* 712 */ if (idToQuantityMap1.get(id_and_stepNum) == null) { +/* 713 */ idToQuantityMap1.put(id_and_stepNum, Double.valueOf(Double.parseDouble(bl_quantity))); + } else { + /* 715 */ idToQuantityMap1.put(id_and_stepNum, Double.valueOf(((Double)idToQuantityMap1.get(id_and_stepNum)).doubleValue() + Double.parseDouble(bl_quantity))); + } + } +/* 719 */ } catch (Exception e) { +/* 720 */ e.printStackTrace(); + } + } +/* 725 */ if (isNeedUnPack) { +/* 726 */ bl_child_list.clear(); +/* 727 */ bl_quantity_list.clear(); +/* 728 */ nhl8_step_num_list.clear(); +/* 729 */ dataList.clear(); +/* 731 */ if (isNeedUnPack) { +/* 732 */ childrenContexts = unpack(topbomline, childCount); +/* 733 */ childCount = childrenContexts.length; + } +/* 736 */ List idList = new ArrayList(); +/* 737 */ Map idToQuantityMap = new HashMap(); +/* 738 */ for (int k = 0; k < childCount; k++) { + try { +/* 740 */ TCComponentBOMLine childbomline = (TCComponentBOMLine)childrenContexts[k].getComponent(); +/* 741 */ String bl_child_line_name = childbomline.getProperty("bl_line_name"); +/* 742 */ String bl_chlid_line_id = childbomline.getProperty("bl_item_item_id"); +/* 743 */ String bl_quantity = childbomline.getProperty("bl_quantity"); +/* 744 */ if (!bl_quantity.equals("")) { +/* 745 */ bl_quantity = UtilApi.subZeroAndDot(bl_quantity); + } else { + /* 747 */ bl_quantity = "1"; + } +/* 749 */ String nhl8_step_num = childbomline.getProperty("NHL8_step_num"); +/* 750 */ if (nhl8_step_num.equals("")) { +/* 751 */ MessageBox.post(this.application.getDesktop().getShell(), "设计BOM不能导入ERP,请重新选择!!!", "警告", 4); + return; + } +/* 754 */ if (nhl8_step_num.contains(",")) { +/* 755 */ String[] arrStr = nhl8_step_num.split(","); +/* 756 */ int arrLen = arrStr.length; +/* 757 */ for (int i1 = 0; i1 < arrLen; i1++) { +/* 758 */ String[] str = arrStr[i1].split("×"); + if(arrStr[i1].contains("x")) { + str = arrStr[i1].split("x"); + } +/* 759 */ nhl8_step_num = str[0]; +/* 760 */ bl_quantity = str[1]; + if(childbomline.getProperty("bl_occ_type").equals("MEDisassemble")|| childbomline.getProperty("bl_occ_type").equals("拆卸")) { + if(!bl_quantity.startsWith("-")) { + bl_quantity="-"+bl_quantity; + System.out.println("MEDisassemble"+bl_quantity); + } + } +/* 761 */ String id_and_stepNum = bl_chlid_line_id + "&" + bl_child_line_name + "&" + nhl8_step_num; +/* 762 */ if (!idList.contains(id_and_stepNum)) +/* 763 */ idList.add(id_and_stepNum); +/* 765 */ if (idToQuantityMap.get(id_and_stepNum) == null) { +/* 766 */ idToQuantityMap.put(id_and_stepNum, Double.valueOf(Double.parseDouble(bl_quantity))); + } else { +/* 768 */ idToQuantityMap.put(id_and_stepNum, Double.valueOf(((Double)idToQuantityMap.get(id_and_stepNum)).doubleValue() + Double.parseDouble(bl_quantity))); + } + } + } else { +/* 772 */ if (nhl8_step_num.contains("×")) { + nhl8_step_num = nhl8_step_num.split("×")[0]; + }else if (nhl8_step_num.contains("x")) { + nhl8_step_num = nhl8_step_num.split("x")[0]; + } +/* 773 */ +/* 775 */ String id_and_stepNum = bl_chlid_line_id + "&" + bl_child_line_name + "&" + nhl8_step_num; +/* 776 */ if (!idList.contains(id_and_stepNum)) +/* 777 */ idList.add(id_and_stepNum); +/* 779 */ if (idToQuantityMap.get(id_and_stepNum) == null) { +/* 780 */ idToQuantityMap.put(id_and_stepNum, Double.valueOf(Double.parseDouble(bl_quantity))); + } else { +/* 782 */ idToQuantityMap.put(id_and_stepNum, Double.valueOf(((Double)idToQuantityMap.get(id_and_stepNum)).doubleValue() + Double.parseDouble(bl_quantity))); + } + } +/* 786 */ } catch (Exception e) { +/* 787 */ e.printStackTrace(); + } + } +/* 790 */ int listSize = idList.size(); +/* 791 */ for (int n = 0; n < listSize; n++) { +/* 792 */ String[] arrStr = ((String)idList.get(n)).split("&"); +/* 793 */ String bl_chlid_line_id = arrStr[0]; +/* 794 */ String bl_child_line_name = arrStr[1].split("\\(视图")[0]; +/* 795 */ String nhl8_step_num = arrStr[2]; +/* 796 */ String bl_quantity = ((Double)idToQuantityMap.get(idList.get(n))).toString(); +/* 797 */ bl_quantity = bl_quantity.replaceAll("\\.0+$", ""); +/* 798 */ bl_child_list.add(bl_chlid_line_id); +/* 799 */ bl_quantity_list.add(bl_quantity); +/* 800 */ nhl8_step_num_list.add(nhl8_step_num); +/* 802 */ Vector vec = new Vector(); +/* 803 */ vec.add(Integer.valueOf(2)); +/* 804 */ vec.add(bl_line_name); +/* 805 */ vec.add(bl_child_line_name); +/* 806 */ vec.add(nhl8_step_num); +/* 807 */ vec.add(bl_quantity); +/* 809 */ dataList.add(vec); + } +/* 812 */ item_map.put("item_name", bl_child_list); +/* 813 */ item_map.put("item_quantity", bl_quantity_list); +/* 814 */ item_map.put("operation_seq_num", nhl8_step_num_list); +/* 815 */ idToQuantityMap.clear(); + } else { +/* 817 */ int listSize = idList1.size(); +/* 818 */ for (int k = 0; k < listSize; k++) { +/* 819 */ System.out.println("788 idList1.get(m)==" + (String)idList1.get(k)); +/* 820 */ String[] arrStr = ((String)idList1.get(k)).split("&"); +/* 821 */ String bl_chlid_line_id = arrStr[0]; +/* 822 */ String bl_child_line_name = arrStr[1].split("\\(视图")[0]; +/* 823 */ String nhl8_step_num = arrStr[2]; +/* 824 */ String bl_quantity = ((Double)idToQuantityMap1.get(idList1.get(k))).toString(); +/* 825 */ bl_quantity = bl_quantity.replaceAll("\\.0+$", ""); +/* 826 */ bl_child_list.add(bl_chlid_line_id); +/* 827 */ bl_quantity_list.add(bl_quantity); +/* 828 */ nhl8_step_num_list.add(nhl8_step_num); +/* 830 */ Vector vec = new Vector(); +/* 831 */ vec.add(Integer.valueOf(2)); +/* 832 */ vec.add(bl_line_name); +/* 833 */ vec.add(bl_child_line_name); +/* 834 */ vec.add(nhl8_step_num); +/* 835 */ vec.add(bl_quantity); +/* 837 */ dataList.add(vec); + } +/* 839 */ item_map.put("item_name", bl_child_list); +/* 840 */ item_map.put("item_quantity", bl_quantity_list); +/* 841 */ item_map.put("operation_seq_num", nhl8_step_num_list); +/* 842 */ idToQuantityMap1.clear(); + } +/* 844 */ this.id_to_list_map.put(bl_line_id, item_map); +/* 847 */ for (int m = 0; m < dataList.size(); m++) { +/* 848 */ Vector vector = dataList.get(m); +/* 849 */ this.data.add(vector); + } + } +/* 854 */ } catch (TCException e) { +/* 855 */ e.printStackTrace(); + } + } +/* 858 */ if (selectRevNoReleaseNum > 0) +/* 859 */ this.resultInfo.append("所选对象中存在未发布的;
"); +/* 861 */ if (materialNoReleaseNum > 0) +/* 862 */ this.resultInfo.append("所选对象中存在关联的零件工艺对应的原材料未发布;
"); +/* 864 */ if (childRevNoReleaseNum > 0) +/* 865 */ this.resultInfo.append("所选对象中存在子BOM未发布的"); +/* 867 */ if (!this.resultInfo.toString().equals("")) { +/* 868 */ SwingUtilities.invokeLater((Runnable)new IsContinueDialog(this, aimType, this.resultInfo.toString(), this.detailInfo.toString())); + } else { +/* 870 */ postDialog(aimType); + } + } + + public void postDialog(AimType aimType) { +/* 876 */ if (aimType.toString().equals("add")) { +/* 877 */ SwingUtilities.invokeLater((Runnable)new BomAddTransferDialog(this.session, this.application, this.ItemRevisions, this.id_to_list_map, this.data)); +/* 878 */ } else if (aimType.toString().equals("chg")) { +/* 879 */ Object[] obj = new Object[1]; +/* 880 */ obj[0] = Integer.valueOf(11); +/* 881 */ TCUserService service = this.session.getUserService(); +/* 882 */ for (int i = 0; i < this.ItemRevisions.size(); i++) { + try { +/* 884 */ service.call("openByPass", obj); +/* 885 */ TCComponentForm form = (TCComponentForm)((TCComponentItemRevision)this.ItemRevisions.get(i)).getRelatedComponent("IMAN_master_form_rev"); +/* 886 */ form.setLogicalProperty("nhl8_BOMimpSucc", false); +/* 887 */ form.save(); +/* 888 */ service.call("closeByPass", obj); +/* 889 */ } catch (TCException e) { +/* 890 */ e.printStackTrace(); + } + } +/* 893 */ SwingUtilities.invokeLater((Runnable)new BomChgTransferDialog(this.session, this.application, this.ItemRevisions, this.id_to_list_map, this.data)); + } + } + + public void postDialog2(AimType aimType) { +/* 898 */ if (aimType.toString().equals("add")) { +/* 899 */ SwingUtilities.invokeLater((Runnable)new BomAddTransferDialog(this.session, this.application, this.ItemRevisions, this.id_to_list_map, this.data)); +/* 900 */ } else if (aimType.toString().equals("chg")) { +/* 901 */ Object[] obj = new Object[1]; +/* 902 */ obj[0] = Integer.valueOf(11); +/* 903 */ TCUserService service = this.session.getUserService(); +/* 904 */ for (int i = 0; i < this.ItemRevisions.size(); i++) { + try { +/* 906 */ service.call("openByPass", obj); +/* 907 */ TCComponentForm form = (TCComponentForm)((TCComponentItemRevision)this.ItemRevisions.get(i)).getRelatedComponent("IMAN_master_form_rev"); +/* 908 */ form.setLogicalProperty("nhl8_BOMimpSucc", false); +/* 909 */ form.save(); +/* 910 */ service.call("closeByPass", obj); +/* 911 */ } catch (TCException e) { +/* 912 */ e.printStackTrace(); + } + } +/* 915 */ SwingUtilities.invokeLater((Runnable)new BomChgTransferDialog(this.session, this.application, this.ItemRevisions, this.id_to_list_map, this.data)); + } + } + + public void loadData(AimType aimType) { +/* 921 */ if (this.NoBomItemRevisions.size() > 0) { +/* 922 */ StringBuilder sb = new StringBuilder(); +/* 923 */ for (TCComponentItemRevision itemRev : this.NoBomItemRevisions) +/* 924 */ sb.append(itemRev + "没有子BOM
"); +/* 926 */ SwingUtilities.invokeLater((Runnable)new IsContinueDialog(this, "loadData1", aimType, "有 " + this.NoBomItemRevisions.size() + " 个零组件没有子BOM对象", sb.toString())); + } else { +/* 928 */ loadData1(aimType); + } + } + + public void loadData1(AimType aimType) { +/* 937 */ if (this.NoBomItemRevisions.size() > 0) { +/* 938 */ Object[] obj = new Object[1]; +/* 939 */ obj[0] = Integer.valueOf(11); +/* 940 */ TCUserService service = this.session.getUserService(); +///* 941 */ for (TCComponentItemRevision itemRev : this.NoBomItemRevisions) { +// try { +///* 943 */ service.call("openByPass", obj); +///* 944 */ TCComponentForm form = (TCComponentForm)itemRev.getRelatedComponent("IMAN_master_form_rev"); +///* 945 */ form.setLogicalProperty("nhl8_BOMimpSucc", true); +///* 946 */ form.save(); +///* 947 */ service.call("closeByPass", obj); +///* 948 */ } catch (TCException e) { +///* 949 */ e.printStackTrace(); +// } +// } + } +/* 953 */ int revNum = this.ItemRevisions.size(); +/* 954 */ if (revNum == 0) { +/* 955 */ MessageBox.post("有子BOM的零组件的数量为0", "提示", 4); + return; + } +/* 958 */ for (int i = 0; i < revNum; i++) { + try { +/* 960 */ List dataList = new ArrayList(); +/* 961 */ TCComponentItemRevision ItemRev = this.ItemRevisions.get(i); +/* 962 */ Map> item_map = new HashMap>(); +/* 963 */ TCComponent[] rev_release = ItemRev.getReferenceListProperty("release_status_list"); +/* 964 */ if (rev_release.length == 0) { +/* 965 */ MessageBox.post(ItemRev + " 对象未发布", "警告", 4); + return; + } +/* 969 */ List bl_child_list = new ArrayList(); +/* 970 */ List bl_quantity_list = new ArrayList(); +/* 971 */ List nhl8_step_num_list = new ArrayList(); +/* 973 */ TCComponentMEProcessRevision parts_rev = null; +/* 974 */ TCComponentMEProcessRevision meprocess_rev = this.itemToMeprocessMap.get(ItemRev); +/* 975 */ if (meprocess_rev.getType().equals("NHL8_PartsProRevision")) +/* 976 */ parts_rev = meprocess_rev; +/* 978 */ if (parts_rev != null) { +/* 979 */ TCComponent[] NHL8_MateriaRlation = parts_rev.getRelatedComponents("NHL8_MateriaRlation"); +/* 981 */ if (NHL8_MateriaRlation == null || NHL8_MateriaRlation.length == 0) { +/* 982 */ MessageBox.post(this.application.getDesktop().getShell(), parts_rev + "没有关联的原材料", "警告", 4); + return; + } +/* 985 */ TCComponentItemRevision materialCom = (TCComponentItemRevision)NHL8_MateriaRlation[0]; +/* 986 */ if ((materialCom.getReferenceListProperty("release_status_list")).length == 0) { +/* 987 */ MessageBox.post(this.application.getDesktop().getShell(), materialCom + " 对象未发布", "警告", 4); + return; + } +/* 990 */ String[] revProNames = { "object_string", "item_id" }; +/* 991 */ String[] revProValues = ItemRev.getProperties(revProNames); +/* 992 */ String parent_obj_str = revProValues[0]; +/* 993 */ String parent_item_id = revProValues[1]; +/* 994 */ TCComponentForm partRevform = (TCComponentForm)parts_rev.getRelatedComponent("IMAN_master_form_rev"); +/* 995 */ double nhl8_GWeight = partRevform.getDoubleProperty("nhl8_GWeight"); +/* 996 */ String gweight_str = ""; +/* 998 */ if (NHL8_MateriaRlation[0].getType().equals("NHL8_RawMaterialRevision")) { + try { +/* 1000 */ double quantityNum = UtilApi.div(nhl8_GWeight, 1000.0D); +/* 1001 */ gweight_str = UtilApi.subZeroAndDot(String.valueOf(quantityNum)); +/* 1002 */ } catch (NumberFormatException numberFormatException) { +/* 1003 */ MessageBox.post(partRevform + "的毛重不能为空,请修改后再提交!", "错误", 1); + return; + } + } else { +/* 1007 */ gweight_str = UtilApi.subZeroAndDot(String.valueOf(nhl8_GWeight)); + } +/* 1010 */ String[] comProValues = materialCom.getProperties(revProNames); +/* 1011 */ String bl_child_line_name = comProValues[0]; +/* 1012 */ String bl_child_line_id = comProValues[1]; +/* 1013 */ bl_child_list.add(bl_child_line_id); +/* 1014 */ bl_quantity_list.add(gweight_str); +/* 1015 */ nhl8_step_num_list.add("10_"); +/* 1017 */ Vector vec = new Vector(); +/* 1018 */ vec.add(Integer.valueOf(2)); +/* 1019 */ vec.add(parent_obj_str); +/* 1020 */ vec.add(bl_child_line_name); +/* 1021 */ vec.add("10_"); +/* 1022 */ vec.add(gweight_str); +/* 1024 */ dataList.add(vec); +/* 1025 */ item_map.put("item_name", bl_child_list); +/* 1026 */ item_map.put("item_quantity", bl_quantity_list); +/* 1027 */ item_map.put("operation_seq_num", nhl8_step_num_list); +/* 1028 */ this.id_to_list_map.put(parent_item_id, item_map); +/* 1030 */ for (int m = 0; m < dataList.size(); m++) { +/* 1031 */ Vector vector = dataList.get(m); +/* 1032 */ this.data.add(vector); + } + } else { +/* 1036 */ TCComponentBOMLine topbomline = UtilApi.getNewBOMLine(this.session, ItemRev, null); +/* 1037 */ String bl_line_name = topbomline.getProperty("bl_line_name"); +/* 1038 */ String bl_line_id = topbomline.getProperty("bl_item_item_id"); +/* 1039 */ AIFComponentContext[] childrenContexts = topbomline.getChildren(); +/* 1040 */ int childCount = childrenContexts.length; +/* 1041 */ boolean isNeedUnPack = false; +/* 1042 */ List idList1 = new ArrayList(); +/* 1043 */ Map idToQuantityMap1 = new HashMap(); +/* 1044 */ for (int j = 0; j < childCount; j++) { + try { +/* 1046 */ TCComponentBOMLine childbomline = (TCComponentBOMLine)childrenContexts[j].getComponent(); +/* 1047 */ String bl_child_line_name = childbomline.getProperty("bl_line_name"); +/* 1048 */ String bl_chlid_line_id = childbomline.getProperty("bl_item_item_id"); +/* 1049 */ String bl_quantity = childbomline.getProperty("bl_quantity"); +/* 1050 */ if (!bl_quantity.equals("")) { +/* 1051 */ bl_quantity = UtilApi.subZeroAndDot(bl_quantity); + } else { +/* 1053 */ bl_quantity = "1"; + } +/* 1055 */ String nhl8_step_num = childbomline.getProperty("NHL8_step_num"); +/* 1056 */ if (nhl8_step_num.equals("")) { +/* 1057 */ MessageBox.post(this.application.getDesktop().getShell(), "设计BOM不能导入ERP,请重新选择!!!", "警告", 4); + return; + } +/* 1060 */ if (nhl8_step_num.contains("已打包的注释")) { +/* 1061 */ isNeedUnPack = true; +/* 1063 */ } else if (nhl8_step_num.contains(",")) { +/* 1064 */ String[] arrStr = nhl8_step_num.split(","); +/* 1065 */ int arrLen = arrStr.length; +/* 1066 */ for (int k = 0; k < arrLen; k++) { +/* 1067 */ String[] str = arrStr[k].split("×"); + if(arrStr[k].contains("x")) { + str = arrStr[k].split("x"); + } +/* 1068 */ nhl8_step_num = str[0]; +/* 1069 */ bl_quantity = str[1]; +/* 1070 */ String id_and_stepNum = bl_chlid_line_id + "&" + bl_child_line_name + "&" + nhl8_step_num; +/* 1071 */ if (!idList1.contains(id_and_stepNum)) +/* 1072 */ idList1.add(id_and_stepNum); + if(childbomline.getProperty("bl_occ_type").equals("MEDisassemble") || childbomline.getProperty("bl_occ_type").equals("拆卸")) { + if(!bl_quantity.startsWith("-")) { + bl_quantity="-"+bl_quantity; + System.out.println("MEDisassemble"+bl_quantity); + } + } +/* 1074 */ if (idToQuantityMap1.get(id_and_stepNum) == null) { +/* 1075 */ idToQuantityMap1.put(id_and_stepNum, Double.valueOf(Double.parseDouble(bl_quantity))); + } else { +/* 1077 */ idToQuantityMap1.put(id_and_stepNum, Double.valueOf(((Double)idToQuantityMap1.get(id_and_stepNum)).doubleValue() + Double.parseDouble(bl_quantity))); + } + } + } else { +/* 1081 */ if (nhl8_step_num.contains("×")) +/* 1082 */ nhl8_step_num = nhl8_step_num.split("×")[0]; + if(nhl8_step_num.contains("x")) { + nhl8_step_num = nhl8_step_num.split("x")[0]; + } +/* 1084 */ String id_and_stepNum = bl_chlid_line_id + "&" + bl_child_line_name + "&" + nhl8_step_num; +/* 1085 */ if (!idList1.contains(id_and_stepNum)) +/* 1086 */ idList1.add(id_and_stepNum); + if(childbomline.getProperty("bl_occ_type").equals("MEDisassemble")|| childbomline.getProperty("bl_occ_type").equals("拆卸")) { + if(!bl_quantity.startsWith("-")) { + bl_quantity="-"+bl_quantity; + System.out.println("MEDisassemble"+bl_quantity); + } + } +/* 1088 */ if (idToQuantityMap1.get(id_and_stepNum) == null) { +/* 1089 */ idToQuantityMap1.put(id_and_stepNum, Double.valueOf(Double.parseDouble(bl_quantity))); + } else { +/* 1091 */ idToQuantityMap1.put(id_and_stepNum, Double.valueOf(((Double)idToQuantityMap1.get(id_and_stepNum)).doubleValue() + Double.parseDouble(bl_quantity))); + } + } +/* 1109 */ } catch (Exception e) { +/* 1110 */ e.printStackTrace(); + } + } +/* 1114 */ if (isNeedUnPack) { +/* 1115 */ bl_child_list.clear(); +/* 1116 */ bl_quantity_list.clear(); +/* 1117 */ nhl8_step_num_list.clear(); +/* 1118 */ dataList.clear(); +/* 1120 */ if (isNeedUnPack) { +/* 1121 */ System.out.println("childCount=" + childCount); +/* 1122 */ childrenContexts = unpack(topbomline, childCount); +/* 1123 */ childCount = childrenContexts.length; +/* 1124 */ System.out.println("childCount=" + childCount); + } +/* 1127 */ List idList = new ArrayList(); +/* 1128 */ Map idToQuantityMap = new HashMap(); +/* 1129 */ for (int k = 0; k < childCount; k++) { + try { +/* 1131 */ TCComponentBOMLine childbomline = (TCComponentBOMLine)childrenContexts[k].getComponent(); +/* 1132 */ String bl_child_line_name = childbomline.getProperty("bl_line_name"); +/* 1133 */ String bl_chlid_line_id = childbomline.getProperty("bl_item_item_id"); +/* 1134 */ String bl_quantity = childbomline.getProperty("bl_quantity"); +/* 1135 */ if (!bl_quantity.equals("")) { +/* 1136 */ bl_quantity = UtilApi.subZeroAndDot(bl_quantity); + } else { +/* 1138 */ bl_quantity = "1"; + } +/* 1140 */ String nhl8_step_num = childbomline.getProperty("NHL8_step_num"); +/* 1141 */ if (nhl8_step_num.equals("")) { +/* 1142 */ MessageBox.post(this.application.getDesktop().getShell(), "设计BOM不能导入ERP,请重新选择!!!", "警告", 4); + return; + } +/* 1145 */ if (nhl8_step_num.contains(",")) { +/* 1146 */ String[] arrStr = nhl8_step_num.split(","); +/* 1147 */ int arrLen = arrStr.length; +/* 1148 */ for (int i1 = 0; i1 < arrLen; i1++) { +/* 1149 */ String[] str = arrStr[i1].split("×"); + if(arrStr[i1].contains("x")) { + str = arrStr[i1].split("x"); + } +/* 1150 */ nhl8_step_num = str[0]; +/* 1151 */ bl_quantity = str[1]; +/* 1152 */ String id_and_stepNum = bl_chlid_line_id + "&" + bl_child_line_name + "&" + nhl8_step_num; +/* 1153 */ if (!idList.contains(id_and_stepNum)) +/* 1154 */ idList.add(id_and_stepNum); + + if(childbomline.getProperty("bl_occ_type").equals("MEDisassemble")|| childbomline.getProperty("bl_occ_type").equals("拆卸")) { + if(!bl_quantity.startsWith("-")) { + bl_quantity="-"+bl_quantity; + } + } +/* 1156 */ if (idToQuantityMap.get(id_and_stepNum) == null) { +/* 1157 */ idToQuantityMap.put(id_and_stepNum, Double.valueOf(Double.parseDouble(bl_quantity))); + } else { +/* 1159 */ idToQuantityMap.put(id_and_stepNum, Double.valueOf(((Double)idToQuantityMap.get(id_and_stepNum)).doubleValue() + Double.parseDouble(bl_quantity))); + } + } + } else { +/* 1163 */ if (nhl8_step_num.contains("×")) +/* 1164 */ nhl8_step_num = nhl8_step_num.split("×")[0]; + if(nhl8_step_num.contains("x")) { + nhl8_step_num = nhl8_step_num.split("x")[0]; + } +/* 1166 */ String id_and_stepNum = bl_chlid_line_id + "&" + bl_child_line_name + "&" + nhl8_step_num; +/* 1167 */ if (!idList.contains(id_and_stepNum)) +/* 1168 */ idList.add(id_and_stepNum); + + if(childbomline.getProperty("bl_occ_type").equals("MEDisassemble")|| childbomline.getProperty("bl_occ_type").equals("拆卸")) { + if(!bl_quantity.startsWith("-")) { + bl_quantity="-"+bl_quantity; + System.out.println("MEDisassemble"+bl_quantity); + } + } +/* 1170 */ if (idToQuantityMap.get(id_and_stepNum) == null) { +/* 1171 */ idToQuantityMap.put(id_and_stepNum, Double.valueOf(Double.parseDouble(bl_quantity))); + } else { +/* 1173 */ idToQuantityMap.put(id_and_stepNum, Double.valueOf(((Double)idToQuantityMap.get(id_and_stepNum)).doubleValue() + Double.parseDouble(bl_quantity))); + } + } +/* 1177 */ } catch (Exception e) { +/* 1178 */ e.printStackTrace(); + } + } +/* 1181 */ int listSize = idList.size(); +/* 1182 */ for (int n = 0; n < listSize; n++) { +/* 1183 */ String[] arrStr = ((String)idList.get(n)).split("&"); +/* 1184 */ String bl_chlid_line_id = arrStr[0]; +/* 1185 */ String bl_child_line_name = arrStr[1]; +/* 1186 */ String nhl8_step_num = arrStr[2]; +/* 1187 */ String bl_quantity = ((Double)idToQuantityMap.get(idList.get(n))).toString(); +/* 1188 */ bl_quantity = bl_quantity.replaceAll("\\.0+$", ""); +/* 1190 */ bl_child_list.add(bl_chlid_line_id); +/* 1191 */ bl_quantity_list.add(bl_quantity); +/* 1192 */ nhl8_step_num_list.add(nhl8_step_num); +/* 1194 */ Vector vec = new Vector(); +/* 1195 */ vec.add(Integer.valueOf(2)); +/* 1196 */ vec.add(bl_line_name); +/* 1197 */ vec.add(bl_child_line_name); +/* 1198 */ vec.add(nhl8_step_num); +/* 1199 */ vec.add(bl_quantity); +/* 1200 */ dataList.add(vec); + } +/* 1203 */ item_map.put("item_name", bl_child_list); +/* 1204 */ item_map.put("item_quantity", bl_quantity_list); +/* 1205 */ item_map.put("operation_seq_num", nhl8_step_num_list); +/* 1206 */ idToQuantityMap.clear(); + } else { +/* 1208 */ int listSize = idList1.size(); +/* 1209 */ for (int k = 0; k < listSize; k++) { +/* 1210 */ String[] arrStr = ((String)idList1.get(k)).split("&"); +/* 1211 */ String bl_chlid_line_id = arrStr[0]; +/* 1212 */ String bl_child_line_name = arrStr[1]; +/* 1213 */ String nhl8_step_num = arrStr[2]; +/* 1214 */ String bl_quantity = ((Double)idToQuantityMap1.get(idList1.get(k))).toString(); +/* 1215 */ bl_quantity = bl_quantity.replaceAll("\\.0+$", ""); +/* 1217 */ bl_child_list.add(bl_chlid_line_id); +/* 1218 */ bl_quantity_list.add(bl_quantity); +/* 1219 */ nhl8_step_num_list.add(nhl8_step_num); +/* 1221 */ Vector vec = new Vector(); +/* 1222 */ vec.add(Integer.valueOf(2)); +/* 1223 */ vec.add(bl_line_name); +/* 1224 */ vec.add(bl_child_line_name); +/* 1225 */ vec.add(nhl8_step_num); +/* 1226 */ vec.add(bl_quantity); +/* 1227 */ dataList.add(vec); + } +/* 1231 */ item_map.put("item_name", bl_child_list); +/* 1232 */ item_map.put("item_quantity", bl_quantity_list); +/* 1233 */ item_map.put("operation_seq_num", nhl8_step_num_list); +/* 1234 */ idToQuantityMap1.clear(); + } +/* 1237 */ this.id_to_list_map.put(bl_line_id, item_map); +/* 1240 */ for (int m = 0; m < dataList.size(); m++) { +/* 1241 */ Vector vector = dataList.get(m); +/* 1242 */ this.data.add(vector); + } + } +/* 1246 */ } catch (TCException e) { +/* 1247 */ e.printStackTrace(); + } + } +/* 1250 */ postDialog2(aimType); + } + + public AIFComponentContext[] unpack(TCComponentBOMLine topbomline, int childCount) { +/* 1254 */ UnpackOperation unpackoperation = new UnpackOperation(topbomline); +/* 1255 */ this.session.queueOperation((AbstractAIFOperation)unpackoperation); +/* 1256 */ AIFComponentContext[] childrenContexts = null; +/* 1257 */ int childCount2 = 0; + try { +/* 1259 */ topbomline.refresh(); +/* 1260 */ childrenContexts = topbomline.getChildren(); +/* 1261 */ childCount2 = childrenContexts.length; +/* 1262 */ } catch (TCException e) { +/* 1263 */ e.printStackTrace(); + } +/* 1265 */ int unpackCount = 1; +/* 1266 */ while (childCount2 == childCount) { +/* 1267 */ System.out.println("第" + unpackCount + "次解包失败..."); +/* 1268 */ this.session.queueOperation((AbstractAIFOperation)unpackoperation); + try { +/* 1270 */ topbomline.refresh(); +/* 1271 */ childrenContexts = topbomline.getChildren(); +/* 1272 */ childCount2 = childrenContexts.length; +/* 1273 */ } catch (TCException e) { +/* 1274 */ e.printStackTrace(); + } +/* 1276 */ unpackCount++; + } +/* 1278 */ return childrenContexts; + } + + public static void main(String[] args) { +/* 1282 */ System.out.println("2.0000".replaceAll("\\.0+$", "")); + } + } diff --git a/src/com/connor/erp/BomImport/BomTransferDialog.java b/src/com/connor/erp/BomImport/BomTransferDialog.java new file mode 100644 index 0000000..df91e52 --- /dev/null +++ b/src/com/connor/erp/BomImport/BomTransferDialog.java @@ -0,0 +1,33 @@ +package com.connor.erp.BomImport; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +public class BomTransferDialog extends AbstractAIFDialog { + public static final long serialVersionUID = 1L; + + public AbstractAIFUIApplication application; + + public TCSession session; + + public Map>> map = new HashMap>>(); + + public List ItemRevision; + + public Vector> data; + + public BomTransferDialog(TCSession pSession, AbstractAIFUIApplication app, List itemRevision, Map>> map, Vector> data) { + super(false); + this.session = pSession; + this.ItemRevision = itemRevision; + this.application = app; + this.map = map; + this.data = data; + } +} diff --git a/src/com/connor/erp/BomImport/TransferBomXMLWriter.java b/src/com/connor/erp/BomImport/TransferBomXMLWriter.java new file mode 100644 index 0000000..5a2314f --- /dev/null +++ b/src/com/connor/erp/BomImport/TransferBomXMLWriter.java @@ -0,0 +1,111 @@ +/* */ package com.connor.erp.BomImport; +/* */ +/* */ import com.connor.erp.toolkit.ActionType; +/* */ import com.connor.erp.toolkit.AimType; +/* */ import com.connor.erp.toolkit.FileType; +/* */ import com.connor.erp.toolkit.UtilApi; +/* */ import java.io.FileNotFoundException; +/* */ import java.io.FileOutputStream; +/* */ import java.io.PrintWriter; +/* */ import java.util.Iterator; +/* */ import java.util.List; +/* */ import java.util.Map; +/* */ import javax.xml.parsers.DocumentBuilder; +/* */ import javax.xml.parsers.DocumentBuilderFactory; +/* */ import javax.xml.parsers.ParserConfigurationException; +/* */ import javax.xml.transform.Transformer; +/* */ import javax.xml.transform.TransformerException; +/* */ import javax.xml.transform.TransformerFactory; +/* */ import javax.xml.transform.dom.DOMSource; +/* */ import javax.xml.transform.stream.StreamResult; +/* */ import org.w3c.dom.Document; +/* */ import org.w3c.dom.Element; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class TransferBomXMLWriter +/* */ { +/* */ public static void createXML(String user_id, String file, ActionType actionType, FileType fileType, AimType aimType, Map>> map) throws ParserConfigurationException, FileNotFoundException, TransformerException { +/* 39 */ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); +/* 40 */ DocumentBuilder db = dbf.newDocumentBuilder(); +/* 41 */ Document doc = db.newDocument(); +/* */ +/* 43 */ Element root = doc.createElement("ERPFramework"); +/* 44 */ root.setAttribute("userId", user_id); +/* 45 */ root.setAttribute("time", UtilApi.getCurrentTime()); +/* 46 */ root.setAttribute("actionType", actionType.toString()); +/* 47 */ root.setAttribute("fileType", fileType.toString()); +/* 48 */ root.setAttribute("aimType", aimType.toString()); +/* 49 */ doc.appendChild(root); +/* */ +/* 51 */ Iterator iterator = map.keySet().iterator(); +/* 52 */ while (iterator.hasNext()) { +/* 53 */ String item_number = iterator.next(); +/* 54 */ Element BomInfo = doc.createElement("BomInfo"); +/* 55 */ if (actionType.toString().equals(ActionType.transfer)) { +/* 56 */ Element organization_id = doc.createElement("organization_id"); +/* 57 */ organization_id.setTextContent("2"); +/* 58 */ BomInfo.appendChild(organization_id); +/* */ } +/* */ +/* 61 */ Element assembly_item_number = doc.createElement("assembly_item_number"); +/* 62 */ Element component_item_number = doc.createElement("component_item_number"); +/* */ +/* */ +/* 65 */ assembly_item_number.setTextContent(item_number); +/* */ +/* 67 */ Map> item_name_map = map.get(item_number); +/* 68 */ List item_name_list = item_name_map.get("item_name"); +/* 69 */ List item_quantity_list = item_name_map.get("item_quantity"); +/* 70 */ List operation_seq_num_list = item_name_map.get("operation_seq_num"); +/* */ +/* 72 */ for (int i = 0; i < item_name_list.size(); i++) { +/* */ +/* 74 */ Element item = doc.createElement("item"); +/* 75 */ Element item_name = doc.createElement("item_name"); +/* 76 */ Element item_quantity = doc.createElement("item_quantity"); +/* 77 */ Element operation_seq_num = doc.createElement("operation_seq_num"); +/* 78 */ item_name.setTextContent(item_name_list.get(i)); +/* 79 */ item_quantity.setTextContent(item_quantity_list.get(i)); +/* 80 */ operation_seq_num.setTextContent(operation_seq_num_list.get(i)); +/* */ +/* 82 */ item.appendChild(item_name); +/* 83 */ item.appendChild(item_quantity); +/* 84 */ item.appendChild(operation_seq_num); +/* 85 */ component_item_number.appendChild(item); +/* */ } +/* */ +/* */ +/* 89 */ BomInfo.appendChild(assembly_item_number); +/* 90 */ BomInfo.appendChild(component_item_number); +/* */ +/* 92 */ root.appendChild(BomInfo); +/* */ } +/* */ +/* 95 */ TransformerFactory tf = TransformerFactory.newInstance(); +/* 96 */ Transformer transformer = tf.newTransformer(); +/* 97 */ DOMSource source = new DOMSource(doc); +/* 98 */ transformer.setOutputProperty("encoding", "GB2312"); +/* 99 */ transformer.setOutputProperty("indent", "yes"); +/* 100 */ PrintWriter pw = new PrintWriter(new FileOutputStream(file)); +/* 101 */ StreamResult result = new StreamResult(pw); +/* 102 */ transformer.transform(source, result); +/* 103 */ pw.close(); +/* */ } +/* */ } + + +/* Location: C:\Users\cyh\Documents\WeChat Files\wxid_ztg4pdvd5bjn12\FileStorage\File\2022-03\com.origin.erpintegration_1.0.0.jar!\com\origin\erp\BomImport\TransferBomXMLWriter.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 1.1.3 + */ \ No newline at end of file diff --git a/src/com/connor/erp/BomImport/ValidateBomXMLWriter.java b/src/com/connor/erp/BomImport/ValidateBomXMLWriter.java new file mode 100644 index 0000000..89474ad --- /dev/null +++ b/src/com/connor/erp/BomImport/ValidateBomXMLWriter.java @@ -0,0 +1,101 @@ +/* */ package com.connor.erp.BomImport; +/* */ +/* */ import com.connor.erp.toolkit.AimType; +/* */ import com.connor.erp.toolkit.FileType; +/* */ import com.connor.erp.toolkit.UtilApi; +/* */ import java.io.FileNotFoundException; +/* */ import java.io.FileOutputStream; +/* */ import java.io.PrintWriter; +/* */ import java.util.Iterator; +/* */ import java.util.List; +/* */ import java.util.Map; +/* */ import javax.xml.parsers.DocumentBuilder; +/* */ import javax.xml.parsers.DocumentBuilderFactory; +/* */ import javax.xml.parsers.ParserConfigurationException; +/* */ import javax.xml.transform.Transformer; +/* */ import javax.xml.transform.TransformerException; +/* */ import javax.xml.transform.TransformerFactory; +/* */ import javax.xml.transform.dom.DOMSource; +/* */ import javax.xml.transform.stream.StreamResult; +/* */ import org.w3c.dom.Document; +/* */ import org.w3c.dom.Element; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class ValidateBomXMLWriter +/* */ { +/* */ public static void createXML(String user_id, String file, FileType fileType, AimType aimType, Map>> map) throws ParserConfigurationException, FileNotFoundException, TransformerException { +/* 39 */ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); +/* 40 */ DocumentBuilder db = dbf.newDocumentBuilder(); +/* 41 */ Document doc = db.newDocument(); +/* */ +/* 43 */ Element root = doc.createElement("ERPFramework"); +/* 44 */ root.setAttribute("userId", user_id); +/* 45 */ root.setAttribute("time", UtilApi.getCurrentTime()); +/* 46 */ root.setAttribute("actionType", "validate"); +/* 47 */ root.setAttribute("fileType", fileType.toString()); +/* 48 */ root.setAttribute("aimType", aimType.toString()); +/* 49 */ root.setAttribute("compareType", "details"); +/* 50 */ doc.appendChild(root); +/* */ +/* 52 */ Iterator iterator = map.keySet().iterator(); +/* 53 */ while (iterator.hasNext()) { +/* 54 */ String item_number = iterator.next(); +/* 55 */ Element BomInfo = doc.createElement("BomInfo"); +/* */ +/* 57 */ Element assembly_item_number = doc.createElement("assembly_item_number"); +/* */ +/* 59 */ assembly_item_number.setTextContent(item_number); +/* 60 */ Element component_item_number = doc.createElement("component_item_number"); +/* */ +/* 62 */ Map> item_name_map = map.get(item_number); +/* */ +/* 64 */ List namelist = item_name_map.get("item_name"); +/* */ +/* 66 */ List numlist = item_name_map.get("operation_seq_num"); +/* 67 */ int listSize = namelist.size(); +/* 68 */ for (int i = 0; i < listSize; i++) { +/* 69 */ Element item = doc.createElement("item"); +/* 70 */ Element item_name = doc.createElement("item_name"); +/* 71 */ Element operation_seq_num = doc.createElement("operation_seq_num"); +/* 72 */ item_name.setTextContent(namelist.get(i)); +/* 73 */ operation_seq_num.setTextContent(numlist.get(i)); +/* 74 */ item.appendChild(item_name); +/* 75 */ item.appendChild(operation_seq_num); +/* 76 */ component_item_number.appendChild(item); +/* */ } +/* */ +/* 79 */ BomInfo.appendChild(assembly_item_number); +/* 80 */ BomInfo.appendChild(component_item_number); +/* */ +/* 82 */ root.appendChild(BomInfo); +/* */ } +/* */ +/* 85 */ TransformerFactory tf = TransformerFactory.newInstance(); +/* 86 */ Transformer transformer = tf.newTransformer(); +/* 87 */ DOMSource source = new DOMSource(doc); +/* 88 */ transformer.setOutputProperty("encoding", "GB2312"); +/* 89 */ transformer.setOutputProperty("indent", "yes"); +/* 90 */ PrintWriter pw = new PrintWriter(new FileOutputStream(file)); +/* 91 */ StreamResult result = new StreamResult(pw); +/* 92 */ transformer.transform(source, result); +/* 93 */ pw.close(); +/* */ } +/* */ } + + +/* Location: C:\Users\cyh\Documents\WeChat Files\wxid_ztg4pdvd5bjn12\FileStorage\File\2022-03\com.origin.erpintegration_1.0.0.jar!\com\origin\erp\BomImport\ValidateBomXMLWriter.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 1.1.3 + */ \ No newline at end of file diff --git a/src/com/connor/erp/ItemAddTransferSendToERP/SendToERPCommand.java b/src/com/connor/erp/ItemAddTransferSendToERP/SendToERPCommand.java new file mode 100644 index 0000000..6a0813a --- /dev/null +++ b/src/com/connor/erp/ItemAddTransferSendToERP/SendToERPCommand.java @@ -0,0 +1,584 @@ + package com.connor.erp.ItemAddTransferSendToERP; + + import com.connor.erp.toolkit.FileType; + import com.connor.erp.toolkit.IsContinueDialog; + import com.connor.erp.toolkit.UtilApi; + import com.teamcenter.rac.aif.AbstractAIFCommand; + import com.teamcenter.rac.aif.AbstractAIFUIApplication; + import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; + import com.teamcenter.rac.kernel.TCComponent; + import com.teamcenter.rac.kernel.TCComponentBOMLine; + import com.teamcenter.rac.kernel.TCComponentItemRevision; + import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; + import com.teamcenter.rac.kernel.TCComponentSignoff; + import com.teamcenter.rac.kernel.TCComponentTask; + import com.teamcenter.rac.kernel.TCComponentUser; + import com.teamcenter.rac.kernel.TCException; + import com.teamcenter.rac.kernel.TCPreferenceService; + import com.teamcenter.rac.kernel.TCSession; + import com.teamcenter.rac.util.MessageBox; + import java.util.ArrayList; + import java.util.HashMap; + import java.util.List; + import java.util.Map; + import javax.swing.SwingUtilities; + + public class SendToERPCommand extends AbstractAIFCommand { + private static final String NHL_ITEMIMPERP_PRIVILEGES = "NHL_ItemimpERP_Privileges"; + + private static final String NHL_ITEMIMPERP_MENUAUTH = "NHL_ItemimpERP_MenuAuth"; + + private static final String NHL_ITEMTYPEMOULD = "NHL_ItemtypeMould"; + + private static final String NHL_ITEMTRANSFERTYPE = "NHL_ItemTransferType"; + + private TCSession session; + + private AbstractAIFUIApplication application; + +/* 59 */ private List ItemRevision = new ArrayList(); + +/* 60 */ private StringBuffer detailInfo = new StringBuffer(""); + + private InterfaceAIFComponent[] targets; + + private String[] NHL_ItemtypeMould; + +/* 69 */ private Map typeToProsMap = (Map)new HashMap(); + + private TCPreferenceService ps; + + private int targetNum; + + private TCComponentUser currentUser; + +/* 77 */ private List listTypes = new ArrayList(); + + public SendToERPCommand(TCSession pSession, AbstractAIFUIApplication application) throws TCException { +/* 80 */ this.session = pSession; +/* 81 */ this.application = application; +/* 82 */ application.getTargetComponent(); +/* 83 */ checkTarget(); + } + + public static void main(String[] args) { +/* 87 */ String str = "NHL8TESTRevsion:nhl8_test1,nhl8_test2".replace(":", ":").replace(",", ","); +/* 88 */ String[] arrStr = str.split(":"); +/* 89 */ System.out.println("arrStr[0]===" + arrStr[0]); +/* 90 */ System.out.println("arrStr[1]===" + arrStr[1].split(",")[0]); + } + + private void checkTarget() throws TCException { +/* 115 */ this.targets = this.application.getTargetComponents(); +/* 116 */ if (this.targets == null || this.targets.length == 0) { +/* 117 */ MessageBox.post("请选择一个对象!", "提示", 2); + return; + } + for(InterfaceAIFComponent comp:targets) { + TCComponent com = (TCComponent)comp; + System.out.println("刷新"+com.toString()); + com.refresh(); + } +/* 121 */ this.ps = this.session.getPreferenceService(); +/* 123 */ this.NHL_ItemtypeMould = this.ps.getStringArray(4, "NHL_ItemtypeMould"); +/* 124 */ if (this.NHL_ItemtypeMould == null || this.NHL_ItemtypeMould.length == 0) { +/* 125 */ MessageBox.post("首选项NHL_ItemtypeMould尚未配置,请联系系统管理员!", "提示", 4); + return; + } +/* 129 */ String[] NHL_ItemTransferType = this.ps.getStringArray(4, "NHL_ItemTransferType"); +/* 131 */ if (NHL_ItemTransferType == null || NHL_ItemTransferType.length == 0) { +/* 132 */ MessageBox.post("首选项NHL_ItemTransferType尚未配置,请联系系统管理员!", "提示", 4); + return; + } +/* 135 */ int typesLen = NHL_ItemTransferType.length; +/* 136 */ for (int n = 0; n < typesLen; n++) { +/* 137 */ String typeAndProNames = NHL_ItemTransferType[n].replace(":", ":").replace(",", ","); +/* 138 */ if (typeAndProNames.contains(":")) { +/* 139 */ String[] arrStr = typeAndProNames.split(":"); +/* 140 */ this.typeToProsMap.put(arrStr[0], arrStr[1].split(",")); +/* 141 */ this.listTypes.add(arrStr[0]); + } else { +/* 143 */ this.listTypes.add(typeAndProNames); + } + } +/* 147 */ System.out.println("listTypes===" + this.listTypes); +/* 148 */ boolean isPrivilege = false; +/* 149 */ String[] userNames = this.ps.getStringArray(4, "NHL_ItemimpERP_Privileges"); +/* 150 */ this.currentUser = this.session.getUser(); +/* 151 */ String userID = ""; + try { +/* 153 */ userID = this.currentUser.getProperty("user_id"); +/* 154 */ } catch (TCException e1) { +/* 155 */ e1.printStackTrace(); + } +/* 157 */ if (userNames != null && userNames.length > 0) { +/* 158 */ int nameLen = userNames.length; +/* 159 */ for (int i = 0; i < nameLen; i++) { +/* 160 */ if (userNames[i].trim().equals(userID)) { +/* 161 */ isPrivilege = true; + break; + } + } + } else { +/* 166 */ MessageBox.post(this.application.getDesktop().getShell(), "请配置首选项NHL_ItemimpERP_Privileges!!", "警告", 4); + return; + } +/* 170 */ this.targetNum = this.targets.length; +/* 171 */ TCComponent targetComponent = (TCComponent)this.targets[0]; +/* 172 */ String targetType = ""; +/* 173 */ if (targetComponent instanceof TCComponentBOMLine) { +/* 174 */ if (!isPrivilege) { +/* 175 */ MessageBox.post(this.application.getDesktop().getShell(), "您是普通用户权限不够,请联系管理员!", "警告", 4); + return; + } +/* 178 */ targetType = ((TCComponentBOMLine)targetComponent).getItemRevision().getType(); + } else { +/* 180 */ targetType = targetComponent.getType(); + } +/* 182 */ System.out.println("targetType===" + targetType); +/* 183 */ if (!this.detailInfo.equals("")) +/* 184 */ this.detailInfo = new StringBuffer(""); +/* 186 */ if (targetComponent instanceof TCComponentTask) { + System.out.println("目标是流程类型"); +/* 187 */ if (isPrivilege) { + System.out.println("用户有权限"); +/* 188 */ for (int i = 0; i < this.targetNum; i++) { +/* 189 */ if (this.targets[i] instanceof TCComponentTask) { +/* 190 */ TCComponentTask task = (TCComponentTask)this.targets[i]; + try { +/* 192 */ TCComponent[] attachmentComponents = task.getRelatedComponents("root_target_attachments"); +/* 193 */ int attachmentsLen = attachmentComponents.length; +System.out.println("流程目标下的对象数量为:"+attachmentsLen); +/* 194 */ int virtualNum = 0; +/* 195 */ boolean existProcess = false; +/* 196 */ for (int j = 0; j < attachmentsLen; j++) { +/* 197 */ String type = attachmentComponents[j].getType(); +System.out.println("版本类型:"+type); +/* 198 */ if (this.listTypes.contains(type)) { +/* 199 */ TCComponentItemRevision revision = (TCComponentItemRevision)attachmentComponents[j]; +/* 200 */ if ((revision.getReferenceListProperty("release_status_list")).length == 0) +/* 201 */ this.detailInfo.append(revision + " 对象未发布
"); +/* 203 */ if (!this.ItemRevision.contains(revision)) { + System.out.println("添加"+revision); + /* 204 */ this.ItemRevision.add(revision); +} +/* 206 */ } else if (attachmentComponents[j] instanceof TCComponentMEProcessRevision) { +/* 207 */ TCComponentMEProcessRevision meprocessRev = (TCComponentMEProcessRevision)attachmentComponents[j]; +/* 208 */ if (meprocessRev.getTCClass().getSuperClass().toString().equals("NHL8_MeprocessRevision") && !meprocessRev.getType().equals("NHL8_RigOutGXRevision")) { +/* 209 */ existProcess = true; +/* 210 */ TCComponent[] meTargetComs = meprocessRev.getRelatedComponents("IMAN_METarget"); +/* 211 */ if (meTargetComs.length == 0) { +/* 212 */ this.detailInfo.append(meprocessRev + " 制造目标关系没有关联任何零组件
"); +/* 214 */ } else if (meTargetComs[0].getType().equals("NHL8_VirtualPartRevision")) { +/* 215 */ virtualNum++; +/* 216 */ TCComponentItemRevision revision = (TCComponentItemRevision)meTargetComs[0]; +/* 217 */ if ((revision.getReferenceListProperty("release_status_list")).length == 0) +/* 218 */ this.detailInfo.append(revision + " 对象未发布"); +/* 220 */ if (!this.ItemRevision.contains(revision)) +/* 221 */ this.ItemRevision.add(revision); + } + } + } + } +/* 228 */ if (existProcess && virtualNum == 0) { +/* 229 */ MessageBox.post(this.application.getDesktop().getShell(), "制造目标均非工艺虚拟件,不可导入!", "警告", 4); + return; + } +/* 232 */ } catch (TCException e) { +/* 233 */ e.printStackTrace(); +/* 234 */ } catch (Exception e) { +/* 235 */ e.printStackTrace(); + } + } else { +/* 238 */ MessageBox.post(this.application.getDesktop().getShell(), "请确认选中的是任务对象!!", "警告", 4); + return; + } + } +/* 242 */ if (!this.detailInfo.toString().equals("")) { +/* 243 */ setRunnable((Runnable)new IsContinueDialog(this, "所选部分基础物料版本对象未发布", this.detailInfo.toString())); + } else { +/* 245 */ setRunnable((Runnable)new SendToERPDialog(this.session, this.NHL_ItemtypeMould, this.ItemRevision, this.typeToProsMap)); + } +/* 248 */ } else if (!UtilApi.getTaskItemAddResult(this.application, this.session, FileType.item, "基础物料新增结果", Boolean.valueOf(false), this, "task")) { + return; + } +/* 253 */ } else if (this.listTypes.contains(targetType)) { +/* 254 */ if (isPrivilege) { +/* 255 */ for (int i = 0; i < this.targetNum; i++) { +/* 256 */ String type = ""; +/* 257 */ TCComponentItemRevision revision = null; +/* 258 */ if (this.targets[i] instanceof TCComponentBOMLine) { +/* 259 */ revision = ((TCComponentBOMLine)this.targets[i]).getItemRevision(); +/* 260 */ type = revision.getType(); + } else { +/* 262 */ revision = (TCComponentItemRevision)this.targets[i]; +/* 263 */ type = this.targets[i].getType(); + } +/* 265 */ if (revision != null && this.listTypes.contains(type)) { +/* 266 */ if ((revision.getReferenceListProperty("release_status_list")).length == 0) +/* 267 */ this.detailInfo.append(revision + " 对象未发布
"); +/* 269 */ this.ItemRevision.add(revision); + } else { +/* 271 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中首选项中配置的Item版本对象!!", "警告", 4); + return; + } + } +/* 275 */ if (!this.detailInfo.toString().equals("")) { +/* 276 */ setRunnable((Runnable)new IsContinueDialog(this, "所选部分基础物料版本对象未发布", this.detailInfo.toString())); + } else { +/* 278 */ setRunnable((Runnable)new SendToERPDialog(this.session, this.NHL_ItemtypeMould, this.ItemRevision, this.typeToProsMap)); + } +/* 281 */ } else if (!UtilApi.getTaskItemAddResult(this.application, this.session, FileType.item, "基础物料新增结果", Boolean.valueOf(false), this, "item")) { + return; + } +/* 285 */ } else if (targetComponent instanceof TCComponentBOMLine || targetComponent instanceof TCComponentMEProcessRevision) { +/* 286 */ TCComponentMEProcessRevision meprocessRev = null; +/* 287 */ if (targetComponent instanceof TCComponentBOMLine) { +/* 288 */ if (((TCComponentBOMLine)targetComponent).getItemRevision() instanceof TCComponentMEProcessRevision) +/* 289 */ meprocessRev = (TCComponentMEProcessRevision)((TCComponentBOMLine)targetComponent).getItemRevision(); + } else { +/* 292 */ meprocessRev = (TCComponentMEProcessRevision)targetComponent; + } +/* 294 */ if (meprocessRev != null && meprocessRev.getTCClass().getSuperClass().toString().equals("NHL8_MeprocessRevision")) { +/* 295 */ if (isPrivilege) { +/* 296 */ int virtualNum = 0; +/* 297 */ boolean existProcess = false; +/* 298 */ for (int i = 0; i < this.targetNum; i++) { +/* 299 */ if (this.targets[i] instanceof TCComponentMEProcessRevision) { +/* 300 */ TCComponentMEProcessRevision processRev = (TCComponentMEProcessRevision)this.targets[i]; +/* 301 */ if (processRev.getTCClass().getSuperClass().toString().equals("NHL8_MeprocessRevision") && !meprocessRev.getType().equals("NHL8_RigOutGXRevision")) { +/* 302 */ existProcess = true; +/* 303 */ TCComponent[] meTargetComs = processRev.getRelatedComponents("IMAN_METarget"); +/* 304 */ if (meTargetComs.length == 0) { +/* 305 */ this.detailInfo.append(processRev + " 制造目标关系没有关联任何零组件
"); +/* 310 */ } else if (meTargetComs[0].getType().equals("NHL8_VirtualPartRevision")) { +/* 311 */ virtualNum++; +/* 312 */ TCComponentItemRevision revision = (TCComponentItemRevision)meTargetComs[0]; +/* 313 */ if ((revision.getReferenceListProperty("release_status_list")).length == 0) +/* 314 */ this.detailInfo.append(revision + " 对象未发布
"); +/* 316 */ if (!this.ItemRevision.contains(revision)) +/* 317 */ this.ItemRevision.add(revision); + } + } else { +/* 322 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中工艺版本对象!!", "警告", 4); + return; + } + } else { +/* 326 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中工艺版本对象!!", "警告", 4); + return; + } + } +/* 330 */ if (existProcess && virtualNum == 0) { +/* 331 */ MessageBox.post(this.application.getDesktop().getShell(), "制造目标均非工艺虚拟件,不可导入!", "警告", 4); + return; + } +/* 334 */ if (!this.detailInfo.toString().equals("")) { +/* 335 */ setRunnable((Runnable)new IsContinueDialog(this, "所选部分基础物料版本对象未发布", this.detailInfo.toString())); + } else { +/* 337 */ setRunnable((Runnable)new SendToERPDialog(this.session, this.NHL_ItemtypeMould, this.ItemRevision, this.typeToProsMap)); + } +/* 340 */ } else if (!UtilApi.getTaskItemAddResult(this.application, this.session, FileType.item, "基础物料新增结果", Boolean.valueOf(false), this, "process")) { + return; + } + } else { +/* 345 */ MessageBox.post(this.application.getDesktop().getShell(), "请您选择流程中的任务或ITEM版本对象!!", "警告", 4); + return; + } + } else { +/* 349 */ MessageBox.post(this.application.getDesktop().getShell(), "请您选择流程中的任务或ITEM版本对象!!", "警告", 4); + return; + } + } + + public boolean isRightProcess(TCComponentMEProcessRevision meProcessRevision, List listProcessAndTaskNames) throws TCException { +/* 363 */ TCComponent[] processStageList = meProcessRevision.getReferenceListProperty("process_stage_list"); +/* 364 */ int listSize = processStageList.length; +/* 365 */ TCComponentTask referenceTask = null; +/* 366 */ if (listSize > 0) { +/* 367 */ String rootTaskName = processStageList[0].getProperty("object_name"); +/* 368 */ for (int j = 1; j < listSize; j++) { +/* 369 */ if (listProcessAndTaskNames.contains(rootTaskName + ":" + processStageList[j].getProperty("object_name"))) { +/* 370 */ referenceTask = (TCComponentTask)processStageList[j]; + break; + } + } +/* 374 */ if (referenceTask != null) { +/* 375 */ TCComponentTask[] subTasks = referenceTask.getSubtasks(); +/* 376 */ int subTaskNum = subTasks.length; +/* 377 */ boolean isTaskPerformer = false; +/* 378 */ for (int i = 0; i < subTaskNum; i++) { +/* 379 */ TCComponentTask subTask = subTasks[i]; +/* 380 */ String taskType = subTask.getType(); +/* 381 */ if (taskType.equals("EPMPerformSignoffTask")) { +/* 382 */ TCComponentSignoff[] signoffs = subTask.getPredecessors()[0].getValidSignoffs(); +/* 383 */ int signoffNum = signoffs.length; +/* 384 */ for (int k = 0; k < signoffNum; k++) { +/* 385 */ if (signoffs[k].getGroupMember().getUser().equals(this.currentUser)) { +/* 386 */ isTaskPerformer = true; + break; + } + } + break; + } + } +/* 393 */ if (isTaskPerformer) +/* 394 */ return true; +/* 396 */ MessageBox.post(this.application.getDesktop().getShell(), "请确定对工艺版本对象的操作权限!!", "警告", 4); +/* 397 */ return false; + } +/* 400 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中在正确流程节点中的工艺版本对象!!", "警告", 4); +/* 401 */ return false; + } +/* 404 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中在正确流程节点中的工艺版本对象!!", "警告", 4); +/* 405 */ return false; + } + + public void postDialogForTask() { +/* 410 */ String[] processAndTaskNames = this.ps.getStringArray(4, "NHL_ItemimpERP_MenuAuth"); +/* 411 */ List listProcessAndTaskNames = new ArrayList(); +/* 412 */ if (processAndTaskNames == null || processAndTaskNames.length == 0) { +/* 413 */ MessageBox.post("首选项NHL_ItemimpERP_MenuAuth尚未配置,请联系系统管理员!", "提示", 4); + return; + } +/* 416 */ int nameLen = processAndTaskNames.length; +/* 417 */ for (int j = 0; j < nameLen; j++) +/* 418 */ listProcessAndTaskNames.add(processAndTaskNames[j].trim().replace(":", ":")); +/* 421 */ for (int i = 0; i < this.targetNum; i++) { +/* 422 */ if (this.targets[i] instanceof TCComponentTask) { +/* 423 */ TCComponentTask task = (TCComponentTask)this.targets[i]; +/* 424 */ String taskType = task.getType(); +/* 425 */ String processAndTaskName = ""; +/* 426 */ boolean isTaskPerformer = false; + try { +/* 428 */ if (taskType.equals("EPMPerformSignoffTask")) { +/* 429 */ processAndTaskName = task.getRoot().getProcessDefinition().getName() + ":" + task.getParent().getName(); +/* 430 */ TCComponentSignoff[] signoffs = task.getPredecessors()[0].getValidSignoffs(); +/* 431 */ int signoffNum = signoffs.length; +/* 432 */ for (int k = 0; k < signoffNum; k++) { +/* 433 */ if (signoffs[k].getGroupMember().getUser().equals(this.currentUser)) { +/* 434 */ isTaskPerformer = true; + break; + } + } + } +/* 439 */ if (isTaskPerformer) { +/* 440 */ if (listProcessAndTaskNames.contains(processAndTaskName)) { +/* 441 */ TCComponent[] attachmentComponents = task.getRelatedComponents("root_target_attachments"); +/* 442 */ int attachmentsLen = attachmentComponents.length; +System.out.println("流程目标下的对象数量:"+attachmentsLen); +/* 443 */ boolean existMEPro = false; +/* 444 */ int virtualNum = 0; +/* 445 */ for (int k = 0; k < attachmentsLen; k++) { +/* 446 */ String type = attachmentComponents[k].getType(); +System.out.println("目标类型:"+type); +/* 447 */ if (this.listTypes.contains(type)) { + System.out.println("符合类型"); +/* 448 */ TCComponentItemRevision revision = (TCComponentItemRevision)attachmentComponents[k]; +/* 449 */ if ((revision.getReferenceListProperty("release_status_list")).length == 0) { +/* 450 */ MessageBox.post(revision + " 对象未发布", "警告", 4); + return; + } +/* 453 */ if (!this.ItemRevision.contains(revision)) { + System.out.println("添加:"+revision); + /* 454 */ this.ItemRevision.add(revision); +} +/* 457 */ } else if (attachmentComponents[k] instanceof TCComponentMEProcessRevision) { +/* 458 */ TCComponentMEProcessRevision meprocessRev = (TCComponentMEProcessRevision)attachmentComponents[k]; +/* 459 */ if (meprocessRev.getTCClass().getSuperClass().toString().equals("NHL8_MeprocessRevision") && !meprocessRev.getType().equals("NHL8_RigOutGXRevision")) { +/* 460 */ existMEPro = true; +/* 461 */ TCComponent[] meTargetComs = meprocessRev.getRelatedComponents("IMAN_METarget"); +/* 462 */ if (meTargetComs.length == 0) { +/* 463 */ MessageBox.post(meprocessRev + "制造目标关系没有关联任何零组件!", "提示", 4); + return; + } +/* 469 */ if (meTargetComs[0].getType().equals("NHL8_VirtualPartRevision")) { +/* 470 */ TCComponentItemRevision revision = (TCComponentItemRevision)meTargetComs[0]; +/* 471 */ if ((revision.getReferenceListProperty("release_status_list")).length == 0) { +/* 472 */ MessageBox.post(revision + " 对象未发布", "警告", 4); + return; + } +/* 475 */ virtualNum++; +/* 476 */ if (!this.ItemRevision.contains(revision)) +/* 477 */ this.ItemRevision.add(revision); + } + } + } + } +/* 485 */ if (existMEPro && virtualNum == 0) { +/* 486 */ MessageBox.post(this.application.getDesktop().getShell(), "制造目标均非工艺虚拟件,不可导入!", "警告", 4); + return; + } + } else { +/* 490 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中在正确流程节点中的对象!!", "警告", 4); + return; + } + } else { +/* 494 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中有权限的任务对象!!", "警告", 4); + return; + } +/* 497 */ } catch (TCException e) { +/* 498 */ e.printStackTrace(); +/* 499 */ } catch (Exception e) { +/* 500 */ e.printStackTrace(); + } + } else { +/* 503 */ MessageBox.post(this.application.getDesktop().getShell(), "请确认选中的是任务对象!!", "警告", 4); + return; + } + } +/* 507 */ if (this.ItemRevision.size() > 0) { +/* 508 */ SwingUtilities.invokeLater((Runnable)new SendToERPDialog(this.session, this.NHL_ItemtypeMould, this.ItemRevision, this.typeToProsMap)); + } else { +/* 510 */ MessageBox.post(this.application.getDesktop().getShell(), "没有在流程下面找到合适的版本对象!", "警告", 4); + return; + } + } + + public void postDialogForItem() { +/* 516 */ String[] processAndTaskNames = this.ps.getStringArray(4, "NHL_ItemimpERP_MenuAuth"); +/* 517 */ List listProcessAndTaskNames = new ArrayList(); +/* 518 */ if (processAndTaskNames == null || processAndTaskNames.length == 0) { +/* 519 */ MessageBox.post("首选项NHL_ItemimpERP_MenuAuth尚未配置,请联系系统管理员!", "提示", 4); + return; + } +/* 522 */ int nameLen = processAndTaskNames.length; +/* 523 */ for (int j = 0; j < nameLen; j++) +/* 524 */ listProcessAndTaskNames.add(processAndTaskNames[j].trim().replace(":", ":")); +/* 527 */ for (int i = 0; i < this.targetNum; i++) { +/* 528 */ String type = this.targets[i].getType(); +/* 529 */ if (this.listTypes.contains(type)) { +/* 530 */ TCComponentItemRevision revision = (TCComponentItemRevision)this.targets[i]; + try { +/* 532 */ if ((revision.getReferenceListProperty("release_status_list")).length == 0) { +/* 533 */ MessageBox.post(this.application.getDesktop().getShell(), revision + " 对象未发布!!", "警告", 4); + return; + } +/* 536 */ TCComponent[] processStageList = revision.getReferenceListProperty("fnd0StartedWorkflowTasks"); +/* 537 */ int listSize = processStageList.length; +/* 538 */ TCComponentTask referenceTask = null; +/* 539 */ if (listSize > 0) { +/* 540 */ String rootTaskName = processStageList[0].getProperty("object_name"); +/* 541 */ for (int k = 1; k < listSize; k++) { +/* 542 */ if (listProcessAndTaskNames.contains(rootTaskName + ":" + processStageList[k].getProperty("object_name"))) { +/* 543 */ referenceTask = (TCComponentTask)processStageList[k]; + break; + } + } +/* 547 */ if (referenceTask != null) { +/* 548 */ TCComponentTask[] subTasks = referenceTask.getSubtasks(); +/* 549 */ int subTaskNum = subTasks.length; +/* 550 */ boolean isTaskPerformer = false; +/* 551 */ for (int m = 0; m < subTaskNum; m++) { +/* 552 */ TCComponentTask subTask = subTasks[m]; +/* 553 */ String taskType = subTask.getType(); +/* 554 */ if (taskType.equals("EPMPerformSignoffTask")) { +/* 555 */ TCComponentSignoff[] signoffs = subTask.getPredecessors()[0].getValidSignoffs(); +/* 556 */ int signoffNum = signoffs.length; +/* 557 */ for (int n = 0; n < signoffNum; n++) { +/* 558 */ if (signoffs[n].getGroupMember().getUser().equals(this.currentUser)) { +/* 559 */ isTaskPerformer = true; + break; + } + } + break; + } + } +/* 566 */ if (isTaskPerformer) { +/* 567 */ this.ItemRevision.add(revision); + } else { +/* 569 */ MessageBox.post(this.application.getDesktop().getShell(), "请确定对Item版本对象的操作权限!!", "警告", 4); + return; + } + } else { +/* 573 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中在正确流程节点中的Item版本对象!!", "警告", 4); + return; + } + } else { +/* 577 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中流程中的ITEM对象!!!", "警告", 4); + return; + } +/* 581 */ } catch (TCException e) { +/* 582 */ e.printStackTrace(); + } + } else { +/* 585 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中首选项中配置的Item版本对象!!", "警告", 4); + return; + } + } +/* 589 */ if (this.ItemRevision.size() > 0) { +/* 590 */ SwingUtilities.invokeLater((Runnable)new SendToERPDialog(this.session, this.NHL_ItemtypeMould, this.ItemRevision, this.typeToProsMap)); + } else { +/* 592 */ MessageBox.post(this.application.getDesktop().getShell(), "没有在流程下面找到合适的版本对象!", "警告", 4); + return; + } + } + + public void postDialogForMeProcess() { +/* 598 */ String[] processAndTaskNames = this.ps.getStringArray(4, "NHL_ItemimpERP_MenuAuth"); +/* 599 */ List listProcessAndTaskNames = new ArrayList(); +/* 600 */ if (processAndTaskNames == null || processAndTaskNames.length == 0) { +/* 601 */ MessageBox.post("首选项NHL_ItemimpERP_MenuAuth尚未配置,请联系系统管理员!", "提示", 4); + return; + } +/* 604 */ int nameLen = processAndTaskNames.length; +/* 605 */ for (int i = 0; i < nameLen; i++) +/* 606 */ listProcessAndTaskNames.add(processAndTaskNames[i].trim().replace(":", ":")); +/* 609 */ int virtualNum = 0; +/* 610 */ boolean existProcess = false; +/* 611 */ for (int j = 0; j < this.targetNum; j++) { +/* 612 */ if (this.targets[j] instanceof TCComponentMEProcessRevision) { +/* 613 */ TCComponentMEProcessRevision processRev = (TCComponentMEProcessRevision)this.targets[j]; + try { +/* 615 */ if (processRev.getTCClass().getSuperClass().toString().equals("NHL8_MeprocessRevision") && !processRev.getType().equals("NHL8_RigOutGXRevision")) { +/* 616 */ if (!isRightProcess(processRev, listProcessAndTaskNames)) + return; +/* 619 */ existProcess = true; +/* 620 */ TCComponent[] meTargetComs = processRev.getRelatedComponents("IMAN_METarget"); +/* 621 */ if (meTargetComs.length == 0) { +/* 622 */ MessageBox.post(this.application.getDesktop().getShell(), processRev + " 制造目标关系没有关联任何零组件!", "警告", 4); + return; + } +/* 627 */ if (meTargetComs[0].getType().equals("NHL8_VirtualPartRevision")) { +/* 628 */ TCComponentItemRevision revision = (TCComponentItemRevision)meTargetComs[0]; +/* 629 */ if ((revision.getReferenceListProperty("release_status_list")).length == 0) { +/* 630 */ MessageBox.post(this.application.getDesktop().getShell(), revision + " 对象未发布!", "警告", 4); + return; + } +/* 633 */ virtualNum++; +/* 634 */ if (!this.ItemRevision.contains(revision)) +/* 635 */ this.ItemRevision.add(revision); + } + } else { +/* 641 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中工艺版本对象!!", "警告", 4); + return; + } +/* 644 */ } catch (TCException e) { +/* 645 */ e.printStackTrace(); + } + } else { +/* 648 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中工艺版本对象!!", "警告", 4); + return; + } + } +/* 652 */ if (existProcess && virtualNum == 0) { +/* 653 */ MessageBox.post(this.application.getDesktop().getShell(), "制造目标均非工艺虚拟件,不可导入!", "警告", 4); + return; + } +/* 656 */ if (this.ItemRevision.size() > 0) { +/* 657 */ SwingUtilities.invokeLater((Runnable)new SendToERPDialog(this.session, this.NHL_ItemtypeMould, this.ItemRevision, this.typeToProsMap)); + } else { +/* 659 */ MessageBox.post(this.application.getDesktop().getShell(), "没有在流程下面找到合适的版本对象!", "警告", 4); + return; + } + } + + public void postDialog() { +/* 665 */ if (this.ItemRevision.size() > 0) { +/* 666 */ SwingUtilities.invokeLater((Runnable)new SendToERPDialog(this.session, this.NHL_ItemtypeMould, this.ItemRevision, this.typeToProsMap)); + } else { +/* 668 */ MessageBox.post(this.application.getDesktop().getShell(), "没有在流程下面找到合适的版本对象!", "警告", 4); + return; + } + } + } + diff --git a/src/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog.java b/src/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog.java new file mode 100644 index 0000000..c8d23f5 --- /dev/null +++ b/src/com/connor/erp/ItemAddTransferSendToERP/SendToERPDialog.java @@ -0,0 +1,979 @@ + package com.connor.erp.ItemAddTransferSendToERP; + +import com.connor.erp.ItemImport.ItemImportXMLReader; +// import com.connor.erp.ItemImport.TransferItemXMLWriter; +// import com.connor.erp.ItemImport.ValidateItemXMLWriter; + import com.connor.erp.ProcessImport.ValidateFailDialog; +import com.connor.erp.processresource.EquipmentAcquiredFromERP.TCPreferenceUitl; +import com.connor.erp.toolkit.AimType; + import com.connor.erp.toolkit.FileType; +import com.connor.erp.toolkit.HttpUtil; +import com.connor.erp.toolkit.UtilApi; +import com.connor.erpintegration.entity.CheckResult; +import com.connor.erpintegration.entity.DepResEntity; +import com.connor.erpintegration.entity.ERPResultEntity; +// import com.connor.tcerp.conn.PlmErpIntegration; + import com.teamcenter.rac.aif.AbstractAIFDialog; + import com.teamcenter.rac.aif.AbstractAIFUIApplication; + import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.common.actions.NewAddressListAction; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; + import com.teamcenter.rac.kernel.TCException; + import com.teamcenter.rac.kernel.TCPreferenceService; + import com.teamcenter.rac.kernel.TCProperty; + import com.teamcenter.rac.kernel.TCSession; + import com.teamcenter.rac.kernel.TCUserService; + import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import java.awt.BorderLayout; + import java.awt.Component; + import java.awt.Dimension; + import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.event.ActionEvent; + import java.awt.event.ActionListener; + import java.awt.event.MouseAdapter; + import java.awt.event.MouseEvent; + import java.io.File; + import java.io.FileNotFoundException; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; + import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; + import java.util.Iterator; + import java.util.List; + import java.util.Map; +import java.util.ResourceBundle; +import java.util.Set; + import java.util.Vector; + import javax.swing.DefaultCellEditor; + import javax.swing.JButton; + import javax.swing.JCheckBox; + import javax.swing.JComboBox; + import javax.swing.JComponent; + import javax.swing.JLabel; + import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JScrollPane; + import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; + import javax.swing.UIManager; + import javax.swing.event.TableModelEvent; + import javax.swing.event.TableModelListener; + import javax.swing.table.DefaultTableModel; + import javax.swing.table.JTableHeader; + import javax.swing.table.TableCellRenderer; + import javax.swing.table.TableColumnModel; + import javax.xml.parsers.ParserConfigurationException; + import javax.xml.transform.TransformerException; + + public class SendToERPDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + + private TCSession session; + + private AbstractAIFUIApplication application; + + private List ItemRevision; + + private ResourceBundle resource = ResourceBundle.getBundle("tcUser_erpUser"); + + private SimpleDateFormat df = new SimpleDateFormat("yyyy-M-dd HH:mm"); + + private String errInfo = ""; + + public class CheckHeaderCellRenderer implements TableCellRenderer { + SendToERPDialog.CheckTableModle tableModel; + + JTableHeader tableHeader; + + final JCheckBox selectBox0; + + final JCheckBox selectBox4; + + final JCheckBox selectBox5; + + final JCheckBox selectBox6; + + public CheckHeaderCellRenderer(JTable table) { +/* 870 */ this.tableModel = (SendToERPDialog.CheckTableModle)table.getModel(); +/* 871 */ this.tableHeader = table.getTableHeader(); +/* 872 */ this.selectBox0 = new JCheckBox(this.tableModel.getColumnName(0)); +/* 873 */ this.selectBox0.setSelected(true); +/* 875 */ this.selectBox4 = new JCheckBox(this.tableModel.getColumnName(4)); +/* 876 */ this.selectBox4.setSelected(false); +/* 878 */ this.selectBox5 = new JCheckBox(this.tableModel.getColumnName(5)); +/* 879 */ this.selectBox5.setSelected(false); +/* 881 */ this.selectBox6 = new JCheckBox(this.tableModel.getColumnName(6)); +/* 882 */ this.selectBox6.setSelected(false); +/* 884 */ this.tableHeader.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { +/* 886 */ if (e.getClickCount() != 1) + return; +/* 889 */ int selectColumn = SendToERPDialog.CheckHeaderCellRenderer.this.tableHeader.columnAtPoint(e.getPoint()); +/* 890 */ if (selectColumn == 0) { +/* 891 */ btnImportERP.setEnabled(true); +/* 892 */ boolean value = !SendToERPDialog.CheckHeaderCellRenderer.this.selectBox0.isSelected(); +/* 893 */ SendToERPDialog.CheckHeaderCellRenderer.this.selectBox0.setSelected(value); +/* 894 */ SendToERPDialog.CheckHeaderCellRenderer.this.tableModel.selectAllOrNull(value, 0); +/* 895 */ SendToERPDialog.CheckHeaderCellRenderer.this.tableHeader.repaint(); +/* 896 */ } else if (selectColumn == 4) { +/* 897 */ boolean value = !SendToERPDialog.CheckHeaderCellRenderer.this.selectBox4.isSelected(); +/* 898 */ SendToERPDialog.CheckHeaderCellRenderer.this.selectBox4.setSelected(value); +/* 899 */ SendToERPDialog.CheckHeaderCellRenderer.this.tableModel.selectAllOrNull(value, 4); +/* 900 */ SendToERPDialog.CheckHeaderCellRenderer.this.tableHeader.repaint(); +/* 901 */ } else if (selectColumn == 5) { +/* 902 */ boolean value = !SendToERPDialog.CheckHeaderCellRenderer.this.selectBox5.isSelected(); +/* 903 */ SendToERPDialog.CheckHeaderCellRenderer.this.selectBox5.setSelected(value); +/* 904 */ SendToERPDialog.CheckHeaderCellRenderer.this.tableModel.selectAllOrNull(value, 5); +/* 905 */ SendToERPDialog.CheckHeaderCellRenderer.this.tableHeader.repaint(); +/* 906 */ } else if (selectColumn == 6) { +/* 907 */ boolean value = !SendToERPDialog.CheckHeaderCellRenderer.this.selectBox6.isSelected(); +/* 908 */ SendToERPDialog.CheckHeaderCellRenderer.this.selectBox6.setSelected(value); +/* 909 */ SendToERPDialog.CheckHeaderCellRenderer.this.tableModel.selectAllOrNull(value, 6); +/* 910 */ SendToERPDialog.CheckHeaderCellRenderer.this.tableHeader.repaint(); + } else { +/* 912 */ SendToERPDialog.CheckHeaderCellRenderer.this.tableModel.sort(selectColumn); +/* 913 */ SendToERPDialog.CheckHeaderCellRenderer.this.tableModel.fireTableDataChanged(); + } + } + }); + } + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { +/* 922 */ String valueStr = (String)value; +/* 923 */ JLabel label = new JLabel(valueStr); +/* 924 */ label.setHorizontalAlignment(0); +/* 925 */ this.selectBox0.setHorizontalAlignment(0); +/* 926 */ this.selectBox0.setBorderPainted(true); +/* 927 */ this.selectBox4.setHorizontalAlignment(0); +/* 928 */ this.selectBox4.setBorderPainted(true); +/* 929 */ this.selectBox5.setHorizontalAlignment(0); +/* 930 */ this.selectBox5.setBorderPainted(true); +/* 931 */ this.selectBox6.setHorizontalAlignment(0); +/* 932 */ this.selectBox6.setBorderPainted(true); +/* 933 */ JComponent component = label; +/* 934 */ if (column == 0) { +/* 935 */ component = this.selectBox0; +/* 936 */ } else if (column == 4) { +/* 937 */ component = this.selectBox4; +/* 938 */ } else if (column == 5) { +/* 939 */ component = this.selectBox5; +/* 940 */ } else if (column == 6) { +/* 941 */ component = this.selectBox6; + } +/* 943 */ component.setForeground(this.tableHeader.getForeground()); +/* 944 */ component.setBackground(this.tableHeader.getBackground()); +/* 945 */ component.setFont(this.tableHeader.getFont()); +/* 946 */ component.setBorder(UIManager.getBorder("TableHeader.cellBorder")); +/* 948 */ return component; + } + } + + private class NHLItemERPTypeDefine { + private String typeName; + + private int templateId; + + private ArrayList TCObjectType; + + private ArrayList TCNHLwlzt; + + private NHLItemERPTypeDefine() {} + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + public String getTypeName() { + return this.typeName; + } + + public void setTemplateId(int templateId) { + this.templateId = templateId; + } + + public int getTemplateId() { + return this.templateId; + } + + public void putTCObjectType(String TCObjectType) { + if (this.TCObjectType == null) + this.TCObjectType = new ArrayList(); + this.TCObjectType.add(TCObjectType); + } + + public void putTCNHLwlzt(String nhlwlzt) { + if (this.TCNHLwlzt == null) + this.TCNHLwlzt = new ArrayList(); + this.TCNHLwlzt.add(nhlwlzt); + } + + public boolean check(String objectType, String nhlwlzt) { + System.out.println("objectType:" + objectType + ";nhlwlzt:" + nhlwlzt); + boolean result = false; + if (objectType == null || this.TCObjectType == null || objectType.trim().equals("")) + return false; + if (this.TCObjectType.contains(objectType)) { + result = true; + } else { + return false; + } + if (this.TCNHLwlzt != null && nhlwlzt != null && !nhlwlzt.trim().equals("")) + if (this.TCNHLwlzt.contains(nhlwlzt)) { + result = true; + } else { + result = false; + } + return result; + } + } + + private class NHLItemERPTypePreference { + private ArrayList nhlItemERPTypeDefineArr; + + private HashMap ItemERPTypeTemplate; + + private String selectTypeName; + + private int selectTemplateId; + + private NHLItemERPTypePreference() {} + + public ArrayList GetTypeDefineArr() { + return this.nhlItemERPTypeDefineArr; + } + + public HashMap GetTypeTemplateMap() { + return this.ItemERPTypeTemplate; + } + + public boolean LoadFromPreference(TCSession session, String preferenceName) { + this.nhlItemERPTypeDefineArr = new ArrayList(); + this.ItemERPTypeTemplate = new HashMap(); + TCPreferenceService tcps = session.getPreferenceService(); + String[] pfStr = tcps.getStringArray(4, preferenceName); + if (pfStr == null || pfStr.length == 0) { + MessageBox.post("首选项" + preferenceName + "尚未配置,请联系系统管理员!", "提示", 4); + return false; + } + for (int index = 0; index < pfStr.length; index++) { + String pfLine = pfStr[index].replace(":", ":").replace(",", ","); + String[] segmentStr = pfLine.split(":"); + SendToERPDialog.NHLItemERPTypeDefine nit = new SendToERPDialog.NHLItemERPTypeDefine(); + nit.setTypeName(segmentStr[0]); + nit.setTemplateId(Integer.parseInt(segmentStr[1])); + this.ItemERPTypeTemplate.put(segmentStr[0], segmentStr[1]); + String[] objType = segmentStr[2].split(","); + for (int otIndex = 0; otIndex < objType.length; otIndex++) + nit.putTCObjectType(objType[otIndex]); + if (segmentStr.length == 4 && !segmentStr[3].trim().equals("")) { + System.out.println(segmentStr[3]); + String[] wlzt = segmentStr[3].split(","); + for (int wlztIndex = 0; wlztIndex < wlzt.length; wlztIndex++) + nit.putTCNHLwlzt(wlzt[wlztIndex]); + } + this.nhlItemERPTypeDefineArr.add(nit); + } + return true; + } + + public boolean Select(String tcObjectType, String nhlwlzt) { + if (this.nhlItemERPTypeDefineArr == null) + return false; + for (int index = 0; index < this.nhlItemERPTypeDefineArr.size(); index++) { + SendToERPDialog.NHLItemERPTypeDefine nit = this.nhlItemERPTypeDefineArr.get(index); + if (nit.check(tcObjectType, nhlwlzt)) { + this.selectTypeName = nit.getTypeName(); + this.selectTemplateId = nit.getTemplateId(); + System.out.println("selectTypeName:" + this.selectTypeName); + System.out.println("selectTemplateId:" + this.selectTemplateId); + return true; + } + } + return false; + } + + public String getSelectTypeName() { + return this.selectTypeName; + } + + public int getSelectTemplateId() { + return this.selectTemplateId; + } + } + + private List item_id = new ArrayList(); + + private List object_name = new ArrayList(); + + private List nhl8_uom_tag = new ArrayList(); + + private List nhl8_wllx = new ArrayList(); + + private List nhl8_templateID = new ArrayList(); + + private List nhl8_ProdrOrg = new ArrayList(); + + private List nhl8_SpareOrg = new ArrayList(); + + private List nhl8_UnprodrOrg = new ArrayList(); + + private List nhl8_wlzt = new ArrayList(); + + private List nhl8_MaxType = new ArrayList(); + + private List nhl8_MinType = new ArrayList(); + + private List Nhl8_IfToERP = new ArrayList(); + + private List Info = new ArrayList(); + + private Map wllxToTemIdMap = new HashMap(); + + private Map temIdToWllxMap = new HashMap(); + + private List listNotEditableRow = new ArrayList(); + + private JTable table; + + private Boolean isCellEdit = Boolean.valueOf(false); + + private String xmlFilePath; + + private String user_id = ""; + + private JButton btnCheck; + + private JButton btnCancel; + + private JButton btnImportERP; + + private JButton btnEditProp; + + private JButton btnSaveProp; + + private String[] NHL_ItemtypeMould; + + private Map typeToProsMap; + + private NHLItemERPTypePreference nitp = new NHLItemERPTypePreference(); + + private String erpPreference = "connor_tc_to_erp_url"; + private String itemAddCheckSvr = "ITEMAddCheck"; +// private String PLMImpResultSvr = "PLMImpResult"; + private String itemAddSvr = "ITEMAdd"; + private boolean canAllImport ; + + public SendToERPDialog(TCSession pSession, String[] NHL_ItemtypeMould, List itemRevision, Map typeToProsMap) { + super(false); + System.out.println("进入发送erp菜单初始化"); + this.session = pSession; + this.NHL_ItemtypeMould = NHL_ItemtypeMould; + this.ItemRevision = itemRevision; + this.application = AIFUtility.getCurrentApplication(); + this.typeToProsMap = typeToProsMap; + this.nitp.LoadFromPreference(this.session, "NHL_ItemERPType"); + initUI(); + } + + private void initUI() { + setTitle("基础物料传递"); + this.btnCheck = new JButton("导入ERP前检查数据"); + this.btnImportERP = new JButton("导入ERP"); + this.btnImportERP.setEnabled(false); + this.btnEditProp = new JButton("编辑属性"); + this.btnSaveProp = new JButton("保存属性"); + this.btnCancel = new JButton("取消"); + JPanel formPanel = new JPanel(new FlowLayout()); + JPanel paneButton = new JPanel(new FlowLayout()); + paneButton.add(this.btnCheck); + paneButton.add(this.btnImportERP); + paneButton.add(this.btnEditProp); + paneButton.add(this.btnSaveProp); + paneButton.add(this.btnCancel); + Vector headerNames = new Vector(); + headerNames.add("是否选择传递ERP"); + headerNames.add("件号"); + headerNames.add("名称"); + headerNames.add("计量单位"); + headerNames.add("生产组织"); + headerNames.add("备件组织"); + headerNames.add("非生产组织"); + headerNames.add("物料状态"); + headerNames.add("物料类型"); + headerNames.add("导入模板"); + headerNames.add("项目大类"); + headerNames.add("项目小类"); + int revNum = this.ItemRevision.size(); +// this.NHL_ItemtypeMould.length; + this.wllxToTemIdMap = this.nitp.GetTypeTemplateMap(); + Set ts = this.wllxToTemIdMap.keySet(); + for (Iterator it = ts.iterator(); it.hasNext(); ) { + String key_wllx = it.next(); + String val_templateId = this.wllxToTemIdMap.get(key_wllx); + this.temIdToWllxMap.put(val_templateId, key_wllx); + } + for (int i = 0; i < revNum; i++) { + TCComponentItemRevision itemRev = this.ItemRevision.get(i); + String revType = itemRev.getType(); + System.out.println("revType=" + revType); + System.out.println("typeToProsMap=" + this.typeToProsMap); + String[] formOtherProNames = this.typeToProsMap.get(revType); + TCComponentForm form = null; + try { + form = (TCComponentForm)itemRev.getRelatedComponent("IMAN_master_form_rev"); + String[] revProName = { "item_id", "object_name" }; + String[] revProValue = itemRev.getProperties(revProName); + this.item_id.add(revProValue[0]); + StringBuffer nameSb = new StringBuffer(revProValue[1]); + String uom_tag = itemRev.getItem().getProperty("uom_tag"); + if (uom_tag.equals("") || uom_tag.equals("每个")) { + this.nhl8_uom_tag.add("个"); + } else { + this.nhl8_uom_tag.add(uom_tag); + } + TCProperty[] formProperties = null; + if (formOtherProNames != null) { + int formOtherProNameLen = formOtherProNames.length; + String[] formProName = new String[formOtherProNameLen + 6]; + formProName[0] = "nhl8_wlzt"; + formProName[1] = "nhl8_ProdrOrg"; + formProName[2] = "nhl8_SpareOrg"; + formProName[3] = "nhl8_UnprodrOrg"; + formProName[4] = "nhl8_MaxType"; + formProName[5] = "nhl8_MinType"; + int j; + for (j = 0; j < formOtherProNameLen; j++) + formProName[j + 6] = formOtherProNames[j]; + formProperties = form.getTCProperties(formProName); + for (j = 0; j < formOtherProNameLen; j++) { + TCProperty tcproperty = formProperties[j + 6]; + int propertyType = tcproperty.getPropertyType(); + if (propertyType == 8) { + nameSb.append("|").append(tcproperty.getStringValue().trim()); + } else if (propertyType == 3) { + nameSb.append("|").append(String.valueOf(tcproperty.getDoubleValue())); + } else if (propertyType == 6) { + nameSb.append("|").append(String.valueOf(tcproperty.getLogicalValue())); + } + } + } else { + String[] formProName = new String[6]; + formProName[0] = "nhl8_wlzt"; + formProName[1] = "nhl8_ProdrOrg"; + formProName[2] = "nhl8_SpareOrg"; + formProName[3] = "nhl8_UnprodrOrg"; + formProName[4] = "nhl8_MaxType"; + formProName[5] = "nhl8_MinType"; + formProperties = form.getTCProperties(formProName); + } + this.object_name.add(nameSb.toString()); + String str_nhl8_wlzt = formProperties[0].getStringValue(); + this.nhl8_wlzt.add(str_nhl8_wlzt); + String nhl8_templateIDStr = form.getProperty("nhl8_templateID"); + if (nhl8_templateIDStr.equals("")) { + String itemType = itemRev.getItem().getType(); + if (this.nitp.Select(itemType, str_nhl8_wlzt)) { + this.nhl8_wllx.add(this.nitp.getSelectTypeName()); + this.nhl8_templateID.add((new StringBuilder(String.valueOf(this.nitp.getSelectTemplateId()))).toString()); + } else { + this.nhl8_wllx.add("请选择"); + this.nhl8_templateID.add("请选择"); + } + } else { + this.nhl8_templateID.add(nhl8_templateIDStr); + this.nhl8_wllx.add(this.temIdToWllxMap.get(nhl8_templateIDStr)); + } + this.nhl8_ProdrOrg.add(Boolean.valueOf(formProperties[1].getLogicalValue())); + this.nhl8_SpareOrg.add(Boolean.valueOf(formProperties[2].getLogicalValue())); + this.nhl8_UnprodrOrg.add(Boolean.valueOf(formProperties[3].getLogicalValue())); + this.nhl8_MaxType.add(formProperties[4].getStringValue()); + this.nhl8_MinType.add(formProperties[5].getStringValue()); + this.Nhl8_IfToERP.add(Boolean.valueOf(true)); + } catch (TCException e) { + e.printStackTrace(); + } + } + this.table = new JTable() { + private static final long serialVersionUID = 1L; + + public boolean isCellEditable(int row, int column) { + if (column == 0 || column == 4 || column == 5 || column == 6) + return true; + if (column == 8 || column == 9 || column == 10 || column == 11) + return SendToERPDialog.this.isCellEdit.booleanValue(); + return false; + } + }; + JComboBox jcom_wllx = new JComboBox(); + JComboBox jcom_templateID = new JComboBox(); + Set set = this.wllxToTemIdMap.keySet(); + Iterator iter = set.iterator(); + jcom_wllx.addItem(""); + jcom_templateID.addItem(""); + while (iter.hasNext()) { + String wllx = iter.next(); + jcom_wllx.addItem(wllx); + jcom_templateID.addItem(this.wllxToTemIdMap.get(wllx)); + } + this.table.setModel(new CheckTableModle(getData(), headerNames)); + this.table.getTableHeader().setDefaultRenderer(new CheckHeaderCellRenderer(this.table)); + JComboBox Jcom = new JComboBox(); + TableColumnModel tcm = this.table.getColumnModel(); + tcm.getColumn(8).setCellEditor(new DefaultCellEditor(jcom_wllx)); + tcm.getColumn(9).setCellEditor(new DefaultCellEditor(jcom_templateID)); + tcm.getColumn(10).setCellEditor(new DefaultCellEditor(Jcom)); + tcm.getColumn(11).setCellEditor(new DefaultCellEditor(Jcom)); + this.table.getColumnModel().getColumn(0).setPreferredWidth(130); + JScrollPane jsp = new JScrollPane(this.table); + jsp.setPreferredSize(new Dimension(850, 500)); + formPanel.add(jsp); + JPanel paneMain = new JPanel(new BorderLayout()); + paneMain.add("Center", jsp); + paneMain.add("South", paneButton); + getContentPane().add(paneMain); + setPreferredSize(new Dimension(900, 580)); + this.table.getModel().addTableModelListener(new TableModelListener() { + public void tableChanged(TableModelEvent tablemodelevent) { + int row = SendToERPDialog.this.table.getEditingRow(); + int col = SendToERPDialog.this.table.getEditingColumn(); + if (col == 0) { + SendToERPDialog.this.btnImportERP.setEnabled(false); + } else if (col == 8) { + String nhl8_wllx_value = SendToERPDialog.this.table.getValueAt(row, 8).toString(); + String nhl8_templateID_value = SendToERPDialog.this.table.getValueAt(row, 9).toString(); + String new_templateID_value = (String)SendToERPDialog.this.wllxToTemIdMap.get(nhl8_wllx_value); + if (new_templateID_value != null && !nhl8_templateID_value.equals(new_templateID_value)) + SendToERPDialog.this.table.setValueAt(new_templateID_value, row, 9); + } else if (col == 9) { + String nhl8_wllx_value = SendToERPDialog.this.table.getValueAt(row, 8).toString(); + String nhl8_templateID_value = SendToERPDialog.this.table.getValueAt(row, 9).toString(); + String new_wllx_value = (String)SendToERPDialog.this.temIdToWllxMap.get(nhl8_templateID_value); + if (new_wllx_value != null && !nhl8_wllx_value.equals(new_wllx_value)) + SendToERPDialog.this.table.setValueAt(new_wllx_value, row, 8); + } + } + }); + this.btnEditProp.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + SendToERPDialog.this.btnCheck.setEnabled(false); + SendToERPDialog.this.btnImportERP.setEnabled(false); + SendToERPDialog.this.isCellEdit = Boolean.valueOf(true); + } + }); + this.btnSaveProp.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Object[] obj = new Object[1]; + obj[0] = Integer.valueOf(11); + TCUserService service = SendToERPDialog.this.session.getUserService(); + String[] formProNames = { "nhl8_wlzt", "nhl8_templateID", "nhl8_MaxType", "nhl8_MinType", "nhl8_ProdrOrg", "nhl8_SpareOrg", "nhl8_UnprodrOrg" }; + for (int i = 0; i < SendToERPDialog.this.item_id.size(); i++) { + String nhl8_wlzt_value = (String)SendToERPDialog.this.table.getValueAt(i, 7); + String nhl8_templateID_value = (String)SendToERPDialog.this.table.getValueAt(i, 9); + String nhl8_MaxType_value = (String)SendToERPDialog.this.table.getValueAt(i, 10); + String nhl8_MinType_value = (String)SendToERPDialog.this.table.getValueAt(i, 11); + Boolean nhl8_ProdrOrg_value = (Boolean)SendToERPDialog.this.table.getValueAt(i, 4); + Boolean nhl8_SpareOrg_value = (Boolean)SendToERPDialog.this.table.getValueAt(i, 5); + Boolean nhl8_UnprodrOrg_value = (Boolean)SendToERPDialog.this.table.getValueAt(i, 6); + try { + service.call("openByPass", obj); + TCComponentForm form = (TCComponentForm)((TCComponentItemRevision)SendToERPDialog.this.ItemRevision.get(i)).getRelatedComponent("IMAN_master_form_rev"); + TCProperty[] formProperties = form.getTCProperties(formProNames); + formProperties[0].setStringValue(nhl8_wlzt_value); + formProperties[1].setStringValue(nhl8_templateID_value); + formProperties[2].setStringValue(nhl8_MaxType_value); + formProperties[3].setStringValue(nhl8_MinType_value); + formProperties[4].setLogicalValue(nhl8_ProdrOrg_value.booleanValue()); + formProperties[5].setLogicalValue(nhl8_SpareOrg_value.booleanValue()); + formProperties[6].setLogicalValue(nhl8_UnprodrOrg_value.booleanValue()); + form.setTCProperties(formProperties); + form.save(); + service.call("closeByPass", obj); + } catch (TCException e1) { + e1.printStackTrace(); + } + } + SendToERPDialog.this.btnCheck.setEnabled(true); + SendToERPDialog.this.isCellEdit = Boolean.valueOf(false); + } + }); + this.btnCancel.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + SendToERPDialog.this.dispose(); + } + }); + this.btnCheck.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + boolean isContinue = true; +// List item_id_list = new ArrayList(); +// List uom_code_list = new ArrayList(); + Boolean isTypeError = Boolean.valueOf(false); + Boolean isZuzhiError = Boolean.valueOf(false); + ArrayList partTranNums = new ArrayList(); + List> itemCheckList = new ArrayList>(); + Map>> itemCheckMap = new HashMap>>(); + for (int i = 0; i < SendToERPDialog.this.item_id.size(); i++) { + Boolean Nhl8_IfToERP_value = (Boolean)SendToERPDialog.this.table.getValueAt(i, 0); + if (Nhl8_IfToERP_value.booleanValue()) { + if (SendToERPDialog.this.table.getValueAt(i, 8).equals("请选择") || SendToERPDialog.this.table.getValueAt(i, 9).equals("请选择")) { + isTypeError = Boolean.valueOf(true); + isContinue = false; + } else if (SendToERPDialog.this.table.getValueAt(i, 4).equals(Boolean.valueOf(false)) && SendToERPDialog.this.table.getValueAt(i, 5).equals(Boolean.valueOf(false)) && SendToERPDialog.this.table.getValueAt(i, 6).equals(Boolean.valueOf(false))) { + isZuzhiError = Boolean.valueOf(true); + isContinue = false; + } + SendToERPDialog.CheckTableModle model = (SendToERPDialog.CheckTableModle)SendToERPDialog.this.table.getModel(); + int rowNum = model.getRowNum(i); + partTranNums.add(Integer.valueOf(i)); + Map map = new HashMap(); + map.put("item", item_id.get(rowNum)); + map.put("uom", nhl8_uom_tag.get(rowNum)); + itemCheckList.add(map); +// item_id_list.add(SendToERPDialog.this.item_id.get(rowNum)); +// uom_code_list.add(SendToERPDialog.this.nhl8_uom_tag.get(rowNum)); + } + } + itemCheckMap.put("items", itemCheckList); + if (isTypeError.booleanValue()) + MessageBox.post(SendToERPDialog.this.application.getDesktop().getShell(), "【物料类型】【导入模板】必须选择一个有效值!", "提示", 4); + if (isZuzhiError.booleanValue()) + MessageBox.post(SendToERPDialog.this.application.getDesktop().getShell(), "三个组织至少有一个要勾选!", "提示", 4); + if (isContinue) { + try { + SendToERPDialog.this.user_id = SendToERPDialog.this.session.getUser().getProperty("user_id"); + } catch (TCException ex) { + ex.printStackTrace(); + } +// String xmlFileName = System.getProperty("java.io.tmpdir") + File.separator + SendToERPDialog.this.user_id + "_" + UtilApi.getCurrentTime() + "_validate_item_add"; +// SendToERPDialog.this.xmlFilePath = xmlFileName + ".xml"; +// try { +// ValidateItemXMLWriter.createXML(SendToERPDialog.this.user_id, SendToERPDialog.this.xmlFilePath, FileType.item, AimType.add, item_id_list, uom_code_list); +// } catch (FileNotFoundException e1) { +// e1.printStackTrace(); +// } catch (ParserConfigurationException e1) { +// e1.printStackTrace(); +// } catch (TransformerException e1) { +// e1.printStackTrace(); +// } + int rowCount = SendToERPDialog.this.table.getRowCount(); + Map map = new HashMap(); + for (Iterator iterator = partTranNums.iterator(); iterator.hasNext(); ) { + int j = ((Integer)iterator.next()).intValue(); + SendToERPDialog.CheckTableModle model = (SendToERPDialog.CheckTableModle)SendToERPDialog.this.table.getModel(); + int row = model.getRowNum(j); + String value1 = SendToERPDialog.this.table.getValueAt(row, 1).toString(); + boolean value4 = ((Boolean)SendToERPDialog.this.table.getValueAt(row, 4)).booleanValue(); + boolean value5 = ((Boolean)SendToERPDialog.this.table.getValueAt(row, 5)).booleanValue(); + boolean value6 = ((Boolean)SendToERPDialog.this.table.getValueAt(row, 6)).booleanValue(); + map.put(value1, String.valueOf(value4) + "-" + value5 + "-" + value6); + } + + List checkResults = doGet(itemCheckMap,itemAddCheckSvr); + +// String result = UtilApi.getErrorInfoFromCode(PlmErpIntegration.validateData(SendToERPDialog.this.xmlFilePath)); +// if (!result.equals("成功")) { +// MessageBox.post(SendToERPDialog.this.application.getDesktop().getShell(), result, "验证出现错误", 1); +// } else { + List orgExistRightItems = new ArrayList(); + List orgExistWrongItems = new ArrayList(); + ItemImportXMLReader.loadElements(checkResults, SendToERPDialog.this.Info, orgExistRightItems, orgExistWrongItems, map); + String errorInfo = SendToERPDialog.this.Info.get(0); +// String errorInfo = ""; + if (errorInfo.equals("")) { + int orgExistRightItemNum = orgExistRightItems.size(); + if(canAllImport){ + MessageBox.post(SendToERPDialog.this.application.getDesktop().getShell(), "验证成功", "成功", 2); + SendToERPDialog.this.btnImportERP.setEnabled(true); + }else if (orgExistRightItemNum > 0) { + if (orgExistRightItemNum == rowCount) { + MessageBox.post(SendToERPDialog.this.application.getDesktop().getShell(), "所要导入数据在ERP均已经存在,无需导入!", "成功", 2); + Object[] obj = new Object[1]; + obj[0] = Integer.valueOf(11); + TCUserService service = SendToERPDialog.this.session.getUserService(); + for (Iterator iterator1 = partTranNums.iterator(); iterator1.hasNext(); ) { + int j = ((Integer)iterator1.next()).intValue(); + SendToERPDialog.CheckTableModle model = (SendToERPDialog.CheckTableModle)SendToERPDialog.this.table.getModel(); + int row = model.getRowNum(j); + try { + service.call("openByPass", obj); + ((TCComponentItemRevision)SendToERPDialog.this.ItemRevision.get(row)).getRelatedComponent("IMAN_master_form_rev").setLogicalProperty("nhl8_ItemimpSucc", true); + service.call("closeByPass", obj); + } catch (TCException e1) { + e1.printStackTrace(); + } + } + SendToERPDialog.this.dispose(); + } else { + Object[] obj = new Object[1]; + obj[0] = Integer.valueOf(11); + TCUserService service = SendToERPDialog.this.session.getUserService(); + SendToERPDialog.this.listNotEditableRow = new ArrayList(); + for (Iterator iterator1 = partTranNums.iterator(); iterator1.hasNext(); ) { + int k = ((Integer)iterator1.next()).intValue(); + String value1 = SendToERPDialog.this.table.getValueAt(k, 1).toString(); + SendToERPDialog.CheckTableModle model = (SendToERPDialog.CheckTableModle)SendToERPDialog.this.table.getModel(); + int row = model.getRowNum(k); + if (orgExistRightItems.contains(value1)) { + SendToERPDialog.this.table.setValueAt(Boolean.valueOf(false), k, 0); + SendToERPDialog.this.listNotEditableRow.add(Integer.valueOf(row)); + try { + service.call("openByPass", obj); + ((TCComponentItemRevision)SendToERPDialog.this.ItemRevision.get(row)).getRelatedComponent("IMAN_master_form_rev").setLogicalProperty("nhl8_ItemimpSucc", true); + service.call("closeByPass", obj); + } catch (TCException e1) { + e1.printStackTrace(); + } + } + } + StringBuffer errorInfo2 = new StringBuffer(""); + for (int j = 0; j < orgExistRightItemNum; j++) + errorInfo2.append(String.valueOf(orgExistRightItems.get(j)) + "在ERP中已经存在!
"); + SwingUtilities.invokeLater((Runnable)new ValidateFailDialog("验证成功但有忽略", "警告", errorInfo2.toString())); +// SendToERPDialog.this.btnImportERP.setEnabled(true); + } + } + } else { + int orgExistWrongItemNum = orgExistWrongItems.size(); + if (orgExistWrongItemNum > 0) { + if (orgExistWrongItemNum == rowCount) { + errorInfo.replace("但在主组织中已经存在,", ""); + SwingUtilities.invokeLater((Runnable)new ValidateFailDialog("所要导入的数据在主组织中已经存在,请查看详细!", "警告", errorInfo)); + SendToERPDialog.this.dispose(); + } else { + SwingUtilities.invokeLater((Runnable)new ValidateFailDialog("验证成功但有忽略", "警告", errorInfo)); + Object[] obj = new Object[1]; + obj[0] = Integer.valueOf(11); + TCUserService service = SendToERPDialog.this.session.getUserService(); + SendToERPDialog.this.listNotEditableRow = new ArrayList(); + for (Iterator iterator1 = partTranNums.iterator(); iterator1.hasNext(); ) { + int j = ((Integer)iterator1.next()).intValue(); + String value1 = SendToERPDialog.this.table.getValueAt(j, 1).toString(); + SendToERPDialog.CheckTableModle model = (SendToERPDialog.CheckTableModle)SendToERPDialog.this.table.getModel(); + int row = model.getRowNum(j); + if (orgExistWrongItems.contains(value1)) { + SendToERPDialog.this.table.setValueAt(Boolean.valueOf(false), j, 0); + SendToERPDialog.this.listNotEditableRow.add(Integer.valueOf(row)); + try { + service.call("openByPass", obj); + ((TCComponentItemRevision)SendToERPDialog.this.ItemRevision.get(row)).getRelatedComponent("IMAN_master_form_rev").setLogicalProperty("nhl8_ItemimpSucc", true); + service.call("closeByPass", obj); + } catch (TCException e1) { + e1.printStackTrace(); + } + } + } +// SendToERPDialog.this.btnImportERP.setEnabled(true); + } + } else { + SwingUtilities.invokeLater((Runnable)new ValidateFailDialog("验证失败", "错误", errorInfo)); + } + } +// } + } + } + + + }); + this.btnImportERP.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + SendToERPOperation operation = new SendToERPOperation(application, session, table,SendToERPDialog.this,item_id,Info,ItemRevision); + session.queueOperation(operation); + } + + }); + + + } + + +// private String doGet2(Map itemCheckMap, String svr) { +// HashMap preferenceHashMap = TCPreferenceUitl.getPreferenceHashMap(session, TCPreferenceService.TC_preference_site, erpPreference); +// String url = preferenceHashMap.get("url"); +// String token = preferenceHashMap.get("token"); +// JSONObject itemCheckJson = JSONObject.fromObject(itemCheckMap); +// JSONObject jsonObject2 = null; +// try { +// System.out.println("开始发送请求"); +// String args = itemCheckJson.toString(); +// token = URLEncoder.encode(token,"UTF-8"); +// svr = URLEncoder.encode(svr,"UTF-8"); +// args = URLEncoder.encode(args,"UTF-8"); +// String param = "usr="+token+"&svr="+svr+"&args="+args; +// System.out.println("url=============="+url); +// System.out.println("param==========="+param); +// String response = HttpUtil.doGet(url+"?"+param); +// System.out.println("请求结果================"+response); +// +// JSONObject jsonObject = JSONObject.fromObject(response); +// System.out.println("json格式==============="+jsonObject); +// if(jsonObject.has("cont")) { +// jsonObject2 = jsonObject.getJSONObject("cont"); +// System.out.println("cont==============="+jsonObject2); +// } +// +// } catch (Exception e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// return jsonObject2.toString(); +// } + + private List doGet(Map>> itemCheckMap, String svr) { + HashMap preferenceHashMap = TCPreferenceUitl.getPreferenceHashMap(session, TCPreferenceService.TC_preference_site, erpPreference); + String url = preferenceHashMap.get("url"); + String token = preferenceHashMap.get("token"); + JSONObject itemCheckJson = JSONObject.fromObject(itemCheckMap); + List checkResults =null; + try { + System.out.println("开始发送请求"); + String args = itemCheckJson.toString(); + token = URLEncoder.encode(token,"UTF-8"); + svr = URLEncoder.encode(svr,"UTF-8"); + args = URLEncoder.encode(args,"UTF-8"); + String param = "usr="+token+"&svr="+svr+"&args="+args; + System.out.println("url=============="+url); + System.out.println("param==========="+param); + String response = HttpUtil.doPost(url, param); + System.out.println("请求结果================"+response); + + JSONObject jsonObject = JSONObject.fromObject(response); + System.out.println("json格式==============="+jsonObject); + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); + System.out.println("cont==============="+jsonObject2); + JSONArray checkResult = jsonObject2.getJSONArray("checkResult"); +// canAllImport = true; + canAllImport = jsonObject2.getBoolean("canAllImport"); + checkResults = JSONArray.toList(checkResult,CheckResult.class); + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return checkResults; + } + + public class CheckTableModle extends DefaultTableModel { + private static final long serialVersionUID = 1L; + + private boolean SortDirection; + + private Row[] Rows; + + private int sortColumnIndex; + + public CheckTableModle(Vector data, Vector columnNames) { +/* 960 */ super(data,columnNames); +/* 997 */ this.SortDirection = true; + this.Rows = new Row[getRowCount()]; + for (int i = 0; i < this.Rows.length; i++) + this.Rows[i] = new Row(i); + } + + public Class getColumnClass(int c) { + return getValueAt(0, c).getClass(); + } + + public void selectAllOrNull(boolean value, int column) { + int rowNum = getRowCount(); + for (int row = 0; row < rowNum; row++) { + if (!SendToERPDialog.this.listNotEditableRow.contains(Integer.valueOf(getRowNum(row)))) + setValueAt(Boolean.valueOf(value), row, column); + } + } + + public void setValueAt(Object val, int row, int column) { + super.setValueAt(val, (this.Rows[row]).index, column); + } + + public Object getValueAt(int row, int column) { + return super.getValueAt((this.Rows[row]).index, column); + } + + public String getStringAt(int row, int column) { + return super.getValueAt(row, column).toString(); + } + + public int getRowNum(int row) { +/* 1002 */ return (this.Rows[row]).index; + } + + public void sort(int columnIndex) { +/* 1006 */ this.sortColumnIndex = columnIndex; +/* 1007 */ Arrays.sort((Object[])this.Rows); +/* 1008 */ this.SortDirection = !this.SortDirection; + } + + private class Row implements Comparable { + private int index; + + public Row(int _index) { +/* 1014 */ this.index = _index; + } + + public int getIndex() { +/* 1017 */ return this.index; + } + + public int compareTo(Row other) { +/* 1020 */ int n = SendToERPDialog.CheckTableModle.this.getStringAt(this.index, SendToERPDialog.CheckTableModle.this.sortColumnIndex).compareTo(SendToERPDialog.CheckTableModle.this.getStringAt(other.getIndex(), SendToERPDialog.CheckTableModle.this.sortColumnIndex)); +/* 1021 */ return SendToERPDialog.CheckTableModle.this.SortDirection ? n : -n; + } + } + } + + private Vector getData() { +/* 1031 */ Vector data = new Vector(); +/* 1032 */ int vecSize = this.item_id.size(); +/* 1033 */ for (int i = 0; i < vecSize; i++) { +/* 1034 */ Vector rowVector = new Vector(); +/* 1035 */ rowVector.add(Boolean.valueOf(true)); +/* 1036 */ rowVector.add(this.item_id.get(i)); +/* 1037 */ rowVector.add(this.object_name.get(i)); +/* 1038 */ rowVector.add(this.nhl8_uom_tag.get(i)); +/* 1039 */ rowVector.add(this.nhl8_ProdrOrg.get(i)); +/* 1040 */ rowVector.add(this.nhl8_SpareOrg.get(i)); +/* 1041 */ rowVector.add(this.nhl8_UnprodrOrg.get(i)); +/* 1042 */ rowVector.add(this.nhl8_wlzt.get(i)); +/* 1043 */ rowVector.add(this.nhl8_wllx.get(i)); +/* 1044 */ rowVector.add(this.nhl8_templateID.get(i)); +/* 1045 */ rowVector.add(this.nhl8_MaxType.get(i)); +/* 1046 */ rowVector.add(this.nhl8_MinType.get(i)); +/* 1047 */ data.add(rowVector); + } +/* 1050 */ return data; + } + + + public List getListNotEditableRow() { +/* 1057 */ return this.listNotEditableRow; + } + + public void setListNotEditableRow(List listNotEditableRow) { +/* 1064 */ this.listNotEditableRow = listNotEditableRow; + } + + + public static void main(String[] args) { +/* 1068 */ boolean is = false; +/* 1069 */ boolean is2 = true; +/* 1070 */ System.out.println((new StringBuffer(String.valueOf(is))).append("-").append(is2)); + } + } + diff --git a/src/com/connor/erp/ItemAddTransferSendToERP/SendToERPHandler.java b/src/com/connor/erp/ItemAddTransferSendToERP/SendToERPHandler.java new file mode 100644 index 0000000..1d4c9e1 --- /dev/null +++ b/src/com/connor/erp/ItemAddTransferSendToERP/SendToERPHandler.java @@ -0,0 +1,26 @@ +package com.connor.erp.ItemAddTransferSendToERP; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; + +public class SendToERPHandler extends AbstractHandler { + public Object execute(ExecutionEvent event) { + AbstractAIFUIApplication application = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)application.getSession(); + try { + SendToERPCommand command = new SendToERPCommand(session, application); + try { + command.executeModal(); + } catch (Exception e) { + e.printStackTrace(); + } + } catch (TCException e1) { + e1.printStackTrace(); + } + return null; + } +} \ No newline at end of file diff --git a/src/com/connor/erp/ItemAddTransferSendToERP/SendToERPOperation.java b/src/com/connor/erp/ItemAddTransferSendToERP/SendToERPOperation.java new file mode 100644 index 0000000..998463f --- /dev/null +++ b/src/com/connor/erp/ItemAddTransferSendToERP/SendToERPOperation.java @@ -0,0 +1,502 @@ +package com.connor.erp.ItemAddTransferSendToERP; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Label; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.ResourceBundle; + +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JTable; +import javax.swing.SwingConstants; + +import com.connor.erp.BomChgTransferToERP.DBUtils; +import com.connor.erp.BomChgTransferToERP.UserList; +import com.connor.erp.processresource.EquipmentAcquiredFromERP.TCPreferenceUitl; +import com.connor.erp.toolkit.HttpUtil; +//import com.sun.corba.se.impl.encoding.EncapsOutputStream; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONObject; + +public class SendToERPOperation extends AbstractAIFOperation{ + private AbstractAIFUIApplication app; + private TCSession session; + private ResourceBundle resource = ResourceBundle.getBundle("tcUser_erpUser"); + private String errInfo = ""; + private JTable table; + private AbstractAIFDialog dialog; + private final String CONNOR_ORACLE_CONNECTION = "connor_oracle_connection"; + private final String CONNOR_TC_TO_ERP_PART_TIME = "connor_tc_to_erp_part_time"; + private SimpleDateFormat df = new SimpleDateFormat("yyyy-M-dd HH:mm"); + private String user_id; + private List item_id = new ArrayList(); + private String itemAddSvr = "ITEMAdd"; + private List Info = new ArrayList(); + private String erpPreference = "connor_tc_to_erp_url"; + private List ItemRevision; + + + private PreparedStatement stmt; + private Connection connectionFun; + private ResultSet r ; + + public SendToERPOperation(AbstractAIFUIApplication app, TCSession session, JTable table, AbstractAIFDialog dialog, List item_id, List Info, List ItemRevision) { + this.app = app; + this.session = session; + this.table = table; + this.dialog = dialog; + this.item_id = item_id; + this.Info = Info; + this.ItemRevision = ItemRevision; + } + + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + user_id = session.getUser().getProperty("user_id"); + String timeout = session.getPreferenceService().getStringValue(CONNOR_TC_TO_ERP_PART_TIME); + if(timeout!=null&&timeout.length()>0) { + System.out.println("超时时间为"+timeout+"秒!"); + Daemon daemon = new Daemon(new Thread() { + public void run() { + WaitingDialog dia = new WaitingDialog(app.getDesktop(), "INFOMATION", "正在导入ERP..."); + dia.setAlwaysOnTop(true);//设置在窗口最前端 + dia.setVisible(true); + boolean flag = false; + try { + flag = importItemToERP(); + + }catch (InterruptedException e) { + // TODO Auto-generated catch block +// e.printStackTrace(); + + dia.setVisible(false); + try { + if(r!=null) { + r.close(); + } + if(stmt!=null) { + stmt.close(); + } + if(connectionFun!=null) { + connectionFun.close(); + } + } catch (SQLException ee) { + // TODO Auto-generated catch block + ee.printStackTrace(); + } + + MessageBox.post("导入超时!", "", MessageBox.INFORMATION); + dialog.dispose(); + return; + }catch(Exception e) { + e.printStackTrace(); + dialog.dispose(); + } + if (flag) { + dia.setVisible(false); + MessageBox.post("导入成功!", "", MessageBox.INFORMATION); + } else { + dia.setVisible(false); + try { + if(r!=null) { + r.close(); + } + if(stmt!=null) { + stmt.close(); + } + if(connectionFun!=null) { + connectionFun.close(); + } + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + MessageBox.post(errInfo+"导入失败!", "", MessageBox.INFORMATION); + } + }; + },new BigDecimal(timeout)); + new Thread(daemon).start(); + }else { + MessageBox.post("请联系管理员配置"+CONNOR_TC_TO_ERP_PART_TIME+"首选项","",MessageBox.INFORMATION); + } + + + } + + private boolean importItemToERP() throws InterruptedException, Exception { + + Map userMap=new HashMap(); + userMap.put("TCUser", user_id); + List doPost = DBUtils.doPost(userMap, session); + UserList userList = doPost.get(0); + + Map itemAddMap = new HashMap(); + List> itemAddList = new ArrayList>(); + Map orgMap = new HashMap(); +// Map totalItems = new HashMap(); +// Map notImportItems = new HashMap(); + +// if(resource.containsKey(user_id)) { +// itemAddMap.put("creater", resource.getString(user_id)); +// }else { + itemAddMap.put("creater", userList.getERP_USER_CODE()); +// } + + + int itemCount = item_id.size(); + ArrayList partTranNums = new ArrayList(); + int Info_i = 0; +// List revIds = new ArrayList(); + for (int i = 0; i < itemCount; i++) { + Thread.sleep(1); + Map itemAddMap2 = new HashMap(); + Boolean Nhl8_IfToERP_value = (Boolean) table.getValueAt(i, 0); + String nhl8_wlzt_value = (String) table.getValueAt(i, 7); + String item_id_value = (String) table.getValueAt(i, 1); + String object_name_value = (String) table.getValueAt(i, 2); + String nhl8_uom_tag_value = (String) table.getValueAt(i, 3); + Boolean isSCZZ = (Boolean) table.getValueAt(i, 4); + Boolean isBJZZ = (Boolean) table.getValueAt(i, 5); + Boolean isFSCZZ = (Boolean) table.getValueAt(i, 6); + Boolean isZZZ = false; + String nhl8_templateID_value = (String) table.getValueAt(i, 9); + String nhl8_MaxType_value = (String) table.getValueAt(i, 10); + String nhl8_MinType_value = (String) table.getValueAt(i, 11); + if (Nhl8_IfToERP_value.booleanValue()) { + Info_i++; + partTranNums.add(Integer.valueOf(i)); + StringBuffer org_Info = new StringBuffer(); + if (((String) Info.get(Info_i)).charAt(0) == '1') { + org_Info.append('0'); + } else { + org_Info.append('1'); + } + if(org_Info.toString().equals("0")) { + isZZZ = false; + }else { + isZZZ = true; + } + + orgMap.put("NHL", isZZZ); + orgMap.put("NSC", isSCZZ); + orgMap.put("NBJ", isBJZZ); + orgMap.put("NSJ", isFSCZZ); + try { +// revIds.add(ItemRevision.get(i).getStringProperty("item_revision_id")); + itemAddMap2.put("item", item_id_value); + itemAddMap2.put("version",ItemRevision.get(i).getStringProperty("item_revision_id")); + itemAddMap2.put("description", object_name_value); + itemAddMap2.put("uom", nhl8_uom_tag_value); + itemAddMap2.put("template_id", nhl8_templateID_value); + itemAddMap2.put("primary_category", nhl8_MaxType_value); + itemAddMap2.put("secondary_category", nhl8_MinType_value); + itemAddMap2.put("org", orgMap); + itemAddMap2.put("po_leadtime", null); + itemAddMap2.put("minimum_order_quantity", null); + itemAddMap2.put("maximum_order_quantity", null); + itemAddMap2.put("minimum_packing_quantity", null); + itemAddMap2.put("planner_code", null); + itemAddList.add(itemAddMap2); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + Map> map=new HashMap>(); + List taskNums=new ArrayList(); + for(Map m:itemAddList) { + + List> tempList = new ArrayList>(); + tempList.add(m); + itemAddMap.put("items", tempList); + final StringBuffer task_num = new StringBuffer(); + task_num.append(doGet(itemAddMap, itemAddSvr)); + try { + Object obj[] = new Object[1]; + obj[0] = 1; + TCUserService service = session.getUserService(); + service.call("openByPass", obj); + String itemId = m.get("item").toString(); + TCComponent[] item = session.search("零组件 ID", new String[] {"零组件 ID"}, new String[] {itemId}); + if(item!=null&&item.length>0) { + String revId = m.get("version").toString(); + System.out.println("插入数据库,任务号为:"+task_num.toString()); + InsertData(itemId, "基础物料", task_num.toString(), df.format(new Date()), user_id, revId); + taskNums.add(task_num.toString()); + + List itemMap=new ArrayList(); + itemMap.add(itemId); + itemMap.add(revId); + map.put(task_num.toString(),itemMap); + + +//// totalItems.put(revId,(TCComponentItem) item[0]); +// //反写添加成功属性 +// TCComponentItem ite = (TCComponentItem)item[0]; +// TCComponentItemRevision rev = ite.getLatestItemRevision(); +// TCComponentForm form = (TCComponentForm) rev.getRelatedComponent("IMAN_master_form_rev"); +// System.out.println("反写"+rev+"属性nhl8_ItemimpSucc值为true"); +// form.setLogicalProperty("nhl8_ItemimpSucc", true); + } + service.call("closeByPass", obj); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + Thread.sleep(1); + } + String sql = "select ImpResult from connor_ERP_record where TaskNumber =?"; + + +// notImportItems = new HashMap(totalItems); + boolean isAllSucc = false; + //循环检查表单属性 + connectionFun = DBUtils.ConnectionFun(session); + while(!isAllSucc) { + for(int i=0;i list = map.get(taskNums.get(i)); + Object obj[] = new Object[1]; + obj[0] = 1; + TCUserService service = session.getUserService(); + service.call("openByPass", obj); + TCComponentItemRevision itemRevision = DBUtils.getItemRevision(session,list.get(0),list.get(1)); + TCComponentForm form = (TCComponentForm) itemRevision.getRelatedComponent("IMAN_master_form_rev"); + form.setLogicalProperty("nhl8_ItemimpSucc", true); + System.out.println("回填属性itemid"+list.get(0)+"rev"+list.get(1)); + service.call("closeByPass", obj); + + taskNums.remove(i); + i--; + }else if(impResult.contains("失败") || impResult.equals("任务id无效")){ + return false; + } + } + if(taskNums.size()==0) { + isAllSucc=true; + System.out.println("所有任务都已完成"); + } + + Thread.sleep(1000); + } + if(r!=null) { + r.close(); + } + if(stmt!=null) { + stmt.close(); + } + if(connectionFun!=null) { + connectionFun.close(); + } + dialog.dispose(); + return true; + } + + private String doGet(Map itemCheckMap, String svr) { + HashMap preferenceHashMap = TCPreferenceUitl.getPreferenceHashMap(session, TCPreferenceService.TC_preference_site, erpPreference); + String url = preferenceHashMap.get("url"); + String token = preferenceHashMap.get("token"); + JSONObject itemCheckJson = JSONObject.fromObject(itemCheckMap); + String sid = null; + try { + System.out.println("开始发送请求"); + String args = itemCheckJson.toString(); + token = URLEncoder.encode(token,"UTF-8"); + svr = URLEncoder.encode(svr,"UTF-8"); + args = URLEncoder.encode(args,"UTF-8"); + String param = "usr="+token+"&svr="+svr+"&args="+args; + System.out.println("url=============="+url); + System.out.println("param==========="+param); + String response = HttpUtil.doPost(url, param); //.doGet(url+"?"+param) + System.out.println("请求结果================"+response); + + JSONObject jsonObject = JSONObject.fromObject(response); + System.out.println("json格式==============="+jsonObject); + if(jsonObject.has("cont")) { + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); + System.out.println("cont==============="+jsonObject2); + + sid = jsonObject2.getString("sid"); + + } + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return sid; + } + + public void InsertData(String itemId,String taskType,String taskNumber,String impDate,String userName,String revID) { + Connection con = null; + PreparedStatement stmt = null; + String sql = "insert into connor_ERP_record (ItemId,TaskType,TaskNumber,ImpDate,UserName,Rev_Id) values(?,?,?,to_date(?,'yyyy-fmmm-dd hh24:mi'),?,?)";// + try { + con = ConnectionFun(); + stmt = con.prepareStatement(sql); + stmt.setString(1, itemId); + stmt.setString(2, taskType); + stmt.setString(3, taskNumber); +// Date javaDate = null; +// try { +// javaDate = df.parse(impDate); +// } catch (ParseException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// java.sql.Date sqlDate = new java.sql.Date(javaDate.getTime()); + stmt.setString(4, impDate); + stmt.setString(5, userName); + stmt.setString(6, revID); + stmt.executeUpdate(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + public Connection ConnectionFun() throws SQLException { + String[] stringArray = session.getPreferenceService().getStringValues(CONNOR_ORACLE_CONNECTION); + + String url = "jdbc:oracle:thin:@" + stringArray[0];// + + String oracleUser = stringArray[1];// + + String password = stringArray[2];// + + Connection conn = null;// + + try { + System.out.println(url); + System.out.println(oracleUser); + System.out.println(password); + Class.forName("oracle.jdbc.driver.OracleDriver"); + System.out.println("驱动加载成功"); + } catch (ClassNotFoundException e) { + System.out.println("驱动加载失败"); + } + + conn = DriverManager.getConnection(url, oracleUser, password); + + System.out.println("数据库连接成功"); + return conn; + + } + + class WaitingDialog extends com.teamcenter.rac.aif.AbstractAIFDialog { + private static final long serialVersionUID = 1L; + public JPanel panel; + JProgressBar progressBar = null; + + public WaitingDialog(Frame arg0, String title, String message) { + super(arg0, title); + this.setModal(false); + + panel = new JPanel(new BorderLayout()); + + /* + * JLabel label = new JLabel(message); System.out.println("message:"+message); + * System.out.println("label:"+label); panel.add(label); + */ + + progressBar = new JProgressBar(SwingConstants.HORIZONTAL); + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + + panel.add(BorderLayout.CENTER, new Label(message)); + panel.add(BorderLayout.SOUTH, progressBar); + + panel.setPreferredSize(new Dimension(350, 60)); + + this.getContentPane().add(panel); + + centerToScreen(); + + pack(); + + } + } + + class Daemon implements Runnable { + private Thread thread; + private BigDecimal time; + + public Daemon(Thread r, BigDecimal t) { + thread = r; + time = t; + } + + @Override + public void run() { + this.thread.start(); + while (true) { + try { + Thread.sleep(time.multiply(new BigDecimal("1000")).longValue()); + } catch (InterruptedException e) { + e.printStackTrace(); + } + thread.interrupt(); + } + } + + } + +} diff --git a/src/com/connor/erp/ItemAddTransferSendToERP/ViewResultOfItemTransferHandler.java b/src/com/connor/erp/ItemAddTransferSendToERP/ViewResultOfItemTransferHandler.java new file mode 100644 index 0000000..227dda4 --- /dev/null +++ b/src/com/connor/erp/ItemAddTransferSendToERP/ViewResultOfItemTransferHandler.java @@ -0,0 +1,19 @@ +package com.connor.erp.ItemAddTransferSendToERP; + +import com.connor.erp.toolkit.FileType; +import com.connor.erp.toolkit.UtilApi; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +public class ViewResultOfItemTransferHandler extends AbstractHandler { + public Object execute(ExecutionEvent event) throws ExecutionException { + AbstractAIFUIApplication application = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)application.getSession(); + UtilApi.getTaskItemAddResult(application, session, FileType.item, "基础物料新增结果", Boolean.valueOf(true), null, ""); + return null; + } +} diff --git a/src/com/connor/erp/ItemImport/ItemImportXMLReader.java b/src/com/connor/erp/ItemImport/ItemImportXMLReader.java new file mode 100644 index 0000000..c42b8fb --- /dev/null +++ b/src/com/connor/erp/ItemImport/ItemImportXMLReader.java @@ -0,0 +1,187 @@ +package com.connor.erp.ItemImport; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +import com.connor.erpintegration.entity.CheckResult; + +public class ItemImportXMLReader { + public static void loadXMLDatas(File file, List Info, List orgExistRightItems, + List orgExistWrongItems, Map map) { + /* 23 */ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + /* 25 */ Document doc = null; + try { + /* 28 */ DocumentBuilder builder = factory.newDocumentBuilder(); + /* 29 */ doc = builder.parse(new FileInputStream(file)); + /* 30 */ } catch (ParserConfigurationException e) { + /* 31 */ e.printStackTrace(); + /* 32 */ } catch (SAXException e) { + /* 33 */ e.printStackTrace(); + /* 34 */ } catch (IOException e) { + /* 35 */ e.printStackTrace(); + } + /* 38 */ Element element = doc.getDocumentElement(); + /* 39 */ NodeList list = element.getChildNodes(); +///* 40 */ loadElements(list, Info, orgExistRightItems, orgExistWrongItems, map); + } + + public static void loadElements(List list, List Info, List orgExistRightItems, List orgExistWrongItems, Map map) { +/* 44 */ int listLen = list.size(); +/* 45 */ if (listLen == 0) + return; +/* 48 */ StringBuffer error = new StringBuffer(""); +/* 49 */ Info.add(""); +/* 50 */ for (int i = 0; i < listLen; i++) { +/* 51 */ CheckResult checkResult = list.get(i); +///* 52 */ NodeList childlist = node.getChildNodes(); +///* 53 */ int listSize = childlist.getLength(); +/* 54 */ boolean exist = false; +/* 55 */ String itemId = ""; +/* 56 */ StringBuffer org_id = new StringBuffer(""); +///* 57 */ for (int j = 0; j < listSize; j++) { +///* 58 */ Node childnode = childlist.item(j); +///* 59 */ String nodeName = childnode.getNodeName(); +/* 60 */ String nodeValue = checkResult.getItem(); +///* 61 */ if (nodeName.equals("Segment1")) { + + String Segment1_attrbute = "false"; + if(checkResult.getExistInNBJ()||checkResult.getExistInNHL()||checkResult.getExistInNSC()||checkResult.getExistInNSJ()) + Segment1_attrbute = "true"; +/* 63 */ if (Segment1_attrbute.equals("true")) { +/* 64 */ itemId = nodeValue; +/* 65 */ exist = true; + } +///* 67 */ } else if (nodeName.equals("isExist")) { +/* 68 */ if (!exist) { +/* 69 */ org_id.append("0000"); +/* 70 */ Info.add(org_id.toString()); + } else { +///* 73 */ NodeList isExist_child_node_list = childnode.getChildNodes(); +/* 75 */ String str_org_main = null; +/* 76 */ String str_org_prodr = null; +/* 77 */ String str_org_unprodr = null; +/* 78 */ String str_org_spare = null; +///* 80 */ for (int k = 0; k < isExist_child_node_list.getLength(); k++) { +///* 82 */ Node isExist_child_node = isExist_child_node_list.item(k); +///* 83 */ String isExist_nodeName = isExist_child_node.getNodeName(); +///* 84 */ String isExist_nodeValue = isExist_child_node.getTextContent(); +///* 85 */ if (isExist_nodeName.equals("org_main")) { + if(checkResult.getExistInNHL()) +/* 86 */ str_org_main = "true"; + else str_org_main = "false"; + if(checkResult.getExistInNSC()) + /* 86 */ str_org_prodr = "true"; + else str_org_prodr = "false"; + if(checkResult.getExistInNSJ()) + /* 86 */ str_org_unprodr = "true"; + else str_org_unprodr = "false"; + if(checkResult.getExistInNBJ()) + /* 86 */ str_org_spare = "true"; + else str_org_spare = "false"; + +///* 87 */ } else if (isExist_nodeName.equals("org_prodr")) { +///* 88 */ str_org_prodr = isExist_nodeValue; +///* 89 */ } else if (isExist_nodeName.equals("org_unprodr")) { +///* 90 */ str_org_unprodr = isExist_nodeValue; +///* 91 */ } else if (isExist_nodeName.equals("org_spare")) { +///* 92 */ str_org_spare = isExist_nodeValue; +// } +// } +/* 95 */ String org_str = map.get(itemId); +/* 96 */ String[] arrStr = org_str.split("-"); +/* 97 */ StringBuffer error2 = new StringBuffer(""); +/* 98 */ error2.append(itemId).append(" 在"); +/* 99 */ boolean org_prodr = false; +/* 100 */ boolean org_unprodr = false; +/* 101 */ boolean org_spare = false; +/* 103 */ if (str_org_main.equals("true")) { +/* 104 */ org_id.append('1'); +/* 105 */ } else if (str_org_main.equals("false")) { +/* 106 */ org_id.append('0'); + } +/* 109 */ if (arrStr[0].equals("true")) { +/* 110 */ if (str_org_prodr.equals("false")) { +/* 111 */ error2.append("生产组织"); +/* 112 */ org_id.append('0'); +/* 113 */ } else if (str_org_prodr.equals("true")) { +/* 114 */ org_prodr = true; +/* 115 */ org_id.append('1'); + } + } else { +/* 118 */ org_prodr = true; +/* 119 */ if (str_org_prodr.equals("true")) { +/* 120 */ org_id.append('1'); +/* 121 */ } else if (str_org_prodr.equals("false")) { +/* 122 */ org_id.append('0'); + } + } +/* 126 */ if (arrStr[2].equals("true")) { +/* 127 */ if (str_org_unprodr.equals("false")) { +/* 128 */ if (error2.toString().endsWith("组织")) { +/* 129 */ error2.append("、非生产组织"); + } else { +/* 131 */ error2.append("非生产组织"); + } +/* 133 */ org_id.append('0'); +/* 134 */ } else if (str_org_unprodr.equals("true")) { +/* 135 */ org_unprodr = true; +/* 136 */ org_id.append('1'); + } + } else { +/* 139 */ org_unprodr = true; +/* 140 */ if (str_org_unprodr.equals("true")) { +/* 141 */ org_id.append('1'); +/* 142 */ } else if (str_org_unprodr.equals("false")) { +/* 143 */ org_id.append('0'); + } + } +/* 146 */ if (arrStr[1].equals("true")) { +/* 147 */ if (str_org_spare.equals("false")) { +/* 148 */ if (error2.toString().endsWith("组织")) { +/* 149 */ error2.append("、备件组织"); + } else { +/* 151 */ error2.append("备件组织"); + } +/* 153 */ org_id.append('0'); +/* 154 */ } else if (str_org_spare.equals("true")) { +/* 155 */ org_spare = true; +/* 156 */ org_id.append('1'); + } + } else { +/* 159 */ org_spare = true; +/* 160 */ if (str_org_spare.equals("true")) { +/* 161 */ org_id.append('1'); +/* 162 */ } else if (str_org_spare.equals("false")) { +/* 163 */ org_id.append('0'); + } + } +/* 166 */ if (org_prodr && org_unprodr && org_spare) { +/* 167 */ orgExistRightItems.add(itemId); + } else { +/* 169 */ orgExistWrongItems.add(itemId); +/* 170 */ error2.append("中不存在,但在主组织中已经存在,请至ERP中确认并处理!
"); +/* 171 */ error.append(error2.toString()); + } + } +///* 173 */ } else if (nodeName.equals("primary_uom_code")) { +///* 174 */ String Segment1_attrbute = childnode.getAttributes().getNamedItem("isExist").getNodeValue(); +/* 175 */ if (!checkResult.getUomExist()) +/* 176 */ error.append("“").append(nodeValue).append("”在ERP中不存在对应单位或单位不匹配,请联系管理员!
"); +// } + +/* 180 */ Info.add(org_id.toString()); + } +/* 182 */ Info.set(0, error.toString()); + } + } diff --git a/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPCommand.java b/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPCommand.java new file mode 100644 index 0000000..7a13c40 --- /dev/null +++ b/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPCommand.java @@ -0,0 +1,172 @@ + package com.connor.erp.ProcessImport.ProcessAddTransferToERP; + + import com.connor.erp.toolkit.IsContinueDialog; + import com.connor.erp.toolkit.UtilApi; + import com.teamcenter.rac.aif.AbstractAIFCommand; + import com.teamcenter.rac.aif.AbstractAIFUIApplication; + import com.teamcenter.rac.aif.kernel.AIFComponentContext; + import com.teamcenter.rac.kernel.TCComponentBOMLine; + import com.teamcenter.rac.kernel.TCComponentForm; + import com.teamcenter.rac.kernel.TCComponentItemRevision; + import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; +import com.teamcenter.rac.kernel.TCException; + import com.teamcenter.rac.kernel.TCSession; + import com.teamcenter.rac.util.MessageBox; + import java.util.ArrayList; + import java.util.HashMap; + import java.util.List; + import java.util.Map; + import javax.swing.SwingUtilities; + + /* */ public class ProcessAddTransferToERPCommand + /* */ extends AbstractAIFCommand + /* */ { + /* */ private TCSession session; + /* */ private AbstractAIFUIApplication application; + /* */ private List listProcessRevisions; + /* */ private StringBuffer detailInfo; + /* 49 */ private List listRowDatas = (List)new ArrayList(); + /* */ + /* 51 */ private Map> map = new HashMap>(); + /* */ + /* 53 */ private List listProcessRevMasters = new ArrayList(); + /* */ + /* */ private List listProcessRevs = new ArrayList(); + /* */ private boolean isPrivilege; + /* */ + /* */ + /* */ private boolean isDepartmentNull = false; + /* */ + /* */ + /* */ + /* */ public ProcessAddTransferToERPCommand(TCSession pSession, AbstractAIFUIApplication app, List listProcessRevisions, StringBuffer detailInfo, boolean isPrivilege) { + /* 64 */ this.session = pSession; + /* 65 */ this.application = app; + /* 66 */ this.listProcessRevisions = listProcessRevisions; + /* 67 */ this.detailInfo = detailInfo; + /* 68 */ this.isPrivilege = isPrivilege; + /* 69 */ postDialog(); + /* */ } + /* */ + /* */ + /* */ + /* */ + /* */ public void postDialog() { + /* 76 */ int listSize = this.listProcessRevisions.size(); + for(int i = 0; i < listSize; i++) { + try { + System.out.println(listProcessRevisions.get(i).getStringProperty("object_string")); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /* 77 */ for (int i = 0; i < listSize; i++) { + /* 78 */ TCComponentItemRevision revision = this.listProcessRevisions.get(i); + /* */ try { + /* 80 */ this.listProcessRevMasters.add((TCComponentForm)revision.getRelatedComponent("IMAN_master_form_rev")); + /* 81 */ } catch (TCException e2) { + /* 82 */ e2.printStackTrace(); + /* */ } + /* 84 */ TCComponentBOMLine bomline = UtilApi.getNewBOMLine(this.session, revision, null); + /* 85 */ String process_item_id = ""; + /* */ try { + /* 87 */ process_item_id = revision.getProperty("item_id"); + /* 88 */ } catch (TCException e1) { + /* 89 */ e1.printStackTrace(); + /* */ } + /* 91 */ String part_item_id = process_item_id.substring(0, process_item_id.length() - 2); + /* */ + /* 93 */ List list = new ArrayList(); + /* */ try { + /* 95 */ AIFComponentContext[] opers = bomline.getChildren(); + /* 96 */ int childCount = opers.length; + /* 97 */ int operNum = 0; + + /* 98 */ for (int j = 0; j < childCount; j++) { + /* 99 */ TCComponentBOMLine operBom = (TCComponentBOMLine)opers[j].getComponent(); + /* 100 */ TCComponentItemRevision itemRevision = operBom.getItemRevision(); + /* 101 */ if (itemRevision instanceof TCComponentMEOPRevision || itemRevision.getType().equals("NHL8_RigOutGXRevision")) { +// /* 102 */ TCComponentMEOPRevision operRevision = (TCComponentMEOPRevision)itemRevision; + System.out.println("oper"+itemRevision.getTCClass().getSuperClass().toString()); + /* 103 */ if (itemRevision.getTCClass().getSuperClass().toString().equals("NHL8_MEOPRevision")|| itemRevision.getType().equals("NHL8_RigOutGXRevision")) { + /* 104 */ if ((itemRevision.getReferenceListProperty("release_status_list")).length == 0) { + /* 105 */ if (!this.isPrivilege) { + /* 106 */ MessageBox.post(itemRevision + " 对象未发布", "警告", 4); + /* */ return; + /* */ } + /* 109 */ this.detailInfo.append(itemRevision + " 对象未发布
"); + /* */ } + /* 112 */ String[] rowData = new String[6]; + /* 113 */ rowData[0] = part_item_id; + /* 114 */ rowData[1] = operBom.getProperty("bl_sequence_no"); + /* 115 */ rowData[2] = itemRevision.getProperty("object_name"); + /* 116 */ TCComponentForm form = (TCComponentForm)itemRevision.getRelatedComponent("IMAN_master_form_rev"); + /* 117 */ String[] formProNames = { "nhl8_StandardWH", "nhl8_AuxiliaryWH" }; + /* 118 */ String[] formProValues = form.getProperties(formProNames); + +// if(formProValues[1].equals(" ")||formProValues[1].equals("")) { +// try { +// System.out.println("获取double类型"); +// formProValues[1]=String.valueOf(form.getDoubleProperty("nhl8_AuxiliaryWH")); +// }catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// +// } + /* 119 */ rowData[4] = formProValues[0]; + /* 120 */ rowData[5] = formProValues[1]; + /* 121 */ AIFComponentContext[] children = operBom.getChildren(); + /* 122 */ int childCount2 = children.length; + /* 123 */ boolean existEquipment = false; + /* 124 */ for (int k = 0; k < childCount2; k++) { + /* 125 */ if (((TCComponentBOMLine)children[k].getComponent()).getItem().getType().equals("NHL8_Equipments")) { + /* 126 */ String equ_id = ""; + /* */ try { + System.out.println("equ_id"+children[k].getComponent().getProperty("bl_item_item_id")); + /* 128 */ equ_id = children[k].getComponent().getProperty("bl_item_item_id").substring(4); + /* 129 */ } catch (Exception e) { + /* 130 */ e.printStackTrace(); + /* */ } + /* 132 */ rowData[3] = equ_id; + /* 133 */ list.add(equ_id); + /* 134 */ existEquipment = true; + /* */ break; + /* */ } + /* */ } + /* 138 */ if (!existEquipment) { + /* 139 */ this.isDepartmentNull = true; + /* */ } + /* 141 */ this.listRowDatas.add(rowData); + /* 142 */ operNum++; + /* */ } + /* */ } + /* */ } + /* 146 */ if (operNum == 0) { + /* 147 */ MessageBox.post(this.application.getDesktop().getShell(), revision + "下面没有任何的工序对象!", "警告", 4); + /* */ return; + /* */ } + /* 150 */ } catch (TCException e) { + /* 151 */ e.printStackTrace(); + /* */ } + /* 153 */ this.map.put(part_item_id, list); + /* */ } + System.out.println("isPrivilege"+isPrivilege); + /* 155 */ if (this.isPrivilege) { + /* 156 */ if (!this.detailInfo.toString().equals("")) { + /* 157 */ setRunnable((Runnable)new IsContinueDialog(this, "所选部分工艺/工序对象未发布", this.detailInfo.toString())); + /* */ } else { + /* 159 */ setRunnable((Runnable)new ProcessAddTransferToERPDialog(this.session, this.application, this.listRowDatas, this.map, this.listProcessRevMasters, this.isDepartmentNull)); + /* */ } + /* */ } else { + /* 162 */ setRunnable((Runnable)new ProcessAddTransferToERPDialog(this.session, this.application, this.listRowDatas, this.map, this.listProcessRevMasters, this.isDepartmentNull)); + /* */ } + /* */ } + /* */ + /* */ public void postDialog2() { + /* 167 */ SwingUtilities.invokeLater((Runnable)new ProcessAddTransferToERPDialog(this.session, this.application, this.listRowDatas, this.map, this.listProcessRevMasters, this.isDepartmentNull)); + /* */ } + /* */ } + diff --git a/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog.java b/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog.java new file mode 100644 index 0000000..bd70088 --- /dev/null +++ b/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPDialog.java @@ -0,0 +1,423 @@ +/* */ package com.connor.erp.ProcessImport.ProcessAddTransferToERP; +import com.connor.erp.BomAddTransferToERP.AssemblyResult; +import com.connor.erp.BomAddTransferToERP.BomAdd; +import com.connor.erp.BomAddTransferToERP.BomAddEntry; +import com.connor.erp.BomChgTransferToERP.CompareResult; +import com.connor.erp.BomChgTransferToERP.DBUtils; +import com.connor.erp.BomChgTransferToERP.UserList; +/* */ +/* */ import com.connor.erp.ProcessImport.ProcessImportReadXMLStr; +/* */ import com.connor.erp.ProcessImport.TransferRouteXMLWriter; +/* */ import com.connor.erp.ProcessImport.ValidateFailDialog; +/* */ import com.connor.erp.ProcessImport.ValidateRouteXMLWriter; +import com.connor.erp.processresource.EquipmentAcquiredFromERP.TCPreferenceUitl; +/* */ import com.connor.erp.toolkit.ActionType; +/* */ import com.connor.erp.toolkit.AimType; +/* */ import com.connor.erp.toolkit.FileType; +import com.connor.erp.toolkit.HttpUtil; +/* */ import com.connor.erp.toolkit.UtilApi; +import com.connor.erpintegration.entity.RouteCheckResult; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +///* */ import com.connor.tcerp.conn.PlmErpIntegration; +/* */ import com.teamcenter.rac.aif.AbstractAIFDialog; +/* */ import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +/* */ import com.teamcenter.rac.common.TCTable; +import com.teamcenter.rac.kernel.TCComponent; +/* */ import com.teamcenter.rac.kernel.TCComponentForm; +/* */ import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +/* */ import com.teamcenter.rac.kernel.TCSession; +/* */ import com.teamcenter.rac.kernel.TCUserService; +/* */ import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/* */ import java.awt.BorderLayout; +/* */ import java.awt.Component; +/* */ import java.awt.Dimension; +/* */ import java.awt.event.ActionEvent; +/* */ import java.awt.event.ActionListener; +/* */ import java.io.File; +/* */ import java.io.FileNotFoundException; +import java.net.URLDecoder; +import java.net.URLEncoder; +/* */ import java.util.ArrayList; +/* */ import java.util.HashMap; +/* */ import java.util.List; +/* */ import java.util.Map; +import java.util.ResourceBundle; + +/* */ import javax.swing.JButton; +/* */ import javax.swing.JPanel; +/* */ import javax.swing.JScrollPane; +/* */ import javax.swing.JTable; +/* */ import javax.swing.SwingUtilities; + +import org.apache.logging.log4j.core.appender.rolling.action.IfAccumulatedFileCount; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class ProcessAddTransferToERPDialog +/* */ extends AbstractAIFDialog +/* */ { +/* */ private static final long serialVersionUID = 1L; +/* */ private TCSession session; +/* */ private AbstractAIFUIApplication application; +/* */ private TCTable table; +/* */ private List listRowDatas; +/* */ private Map> map; +/* */ private JButton btnImport; +/* */ private JButton btnValidate; +/* */ private JButton btnCancel; +/* */ private JScrollPane scrollPane; +/* */ private List listProcessRevMasters; +private static String erpPreference = "connor_tc_to_erp_url"; +/* */ private boolean isDepartmentNull = false; +/* */ private String msgString; +/* */ public ProcessAddTransferToERPDialog(TCSession pSession, AbstractAIFUIApplication app, List plistRowDatas, Map> pmap, List plistProcessRevMasters, boolean isDepartmentNull) { +/* 81 */ super(false); +/* 82 */ this.session = pSession; +/* 83 */ this.application = app; +/* 84 */ this.listRowDatas = plistRowDatas; +/* 85 */ this.map = pmap; +/* 86 */ this.listProcessRevMasters = plistProcessRevMasters; +/* 87 */ this.isDepartmentNull = isDepartmentNull; + + System.out.println("listRowDatas========"+listRowDatas); + System.out.println("map========"+map); + System.out.println("listProcessRevMasters========"+listProcessRevMasters); +/* 88 */ initUI(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ private void initUI() { +/* 95 */ setTitle("新增工艺路线"); +this.setLayout(new PropertyLayout()); +/* 96 */ String[] colName = { "装配件号", "工序号", "工序说明", "部门", "标准工时", "辅助工时" }; +/* 97 */ this.table = new TCTable(this.session, colName) +/* */ { +/* */ private static final long serialVersionUID = 1L; +/* */ +/* */ +/* */ +/* */ +/* */ public boolean isCellEditable(int i, int j) { +/* 105 */ return false; +/* */ } +/* */ }; +/* */ +/* 109 */ fillData(); +/* 110 */ int totalWidth = UtilApi.FitTableColumns((JTable)this.table); +/* 111 */ this.btnValidate = new JButton("工艺路线导入验证"); +/* 112 */ this.btnValidate.addActionListener(new ActionListener() +/* */ { +/* */ public void actionPerformed(ActionEvent e) +/* */ { +/* 116 */ ProcessAddTransferToERPDialog.this.validateImport(); +/* */ } +/* */ }); +/* */ +/* */ +/* 121 */ this.btnImport = new JButton("工艺路线导入ERP系统"); +/* 122 */ this.btnImport.addActionListener(new ActionListener() +/* */ { +/* */ public void actionPerformed(ActionEvent e) +/* */ { +/* 126 */ ProcessAddTransferToERPDialog.this.dispose(); +/* 127 */ try { + ProcessAddTransferToERPDialog.this.doImport(); +} catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); +} +/* */ } +/* */ }); +/* */ +/* 131 */ this.btnImport.setEnabled(false); +/* */ +/* 133 */ this.btnCancel = new JButton("取消"); +/* 134 */ this.btnCancel.addActionListener(new ActionListener() +/* */ { +/* */ public void actionPerformed(ActionEvent e) +/* */ { +/* 138 */ ProcessAddTransferToERPDialog.this.dispose(); +/* */ } +/* */ }); +/* */ +/* */ +/* 143 */ JPanel paneButton = new JPanel(); +/* 144 */ paneButton.add(this.btnValidate); +/* 145 */ paneButton.add(this.btnImport); +/* 146 */ paneButton.add(this.btnCancel); +/* */ +/* 148 */ this.scrollPane = new JScrollPane((Component)this.table); +/* */ this.setPreferredSize(new Dimension(500, 500)); +/* 150 */ JPanel paneMain = new JPanel(new BorderLayout()); +/* 151 */ paneMain.add("Center", this.scrollPane); +/* 152 */ paneMain.add("South", paneButton); +/* 153 */ this.add("1.1.left.top",paneMain); +/* 154 */ + this.setResizable(true); + showDialog(); + this.setVisible(true); +/* */ } +/* */ +/* */ public void fillData() { +/* 158 */ int vecSize = this.listRowDatas.size(); +/* 159 */ for (int i = 0; i < vecSize; i++) { +/* 160 */ this.table.addRow(this.listRowDatas.get(i)); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ private ResourceBundle resource = ResourceBundle.getBundle("tcUser_erpUser"); + +/* */ +/* */ private void doImport() throws TCException { +/* 169 */ String user_id = ""; +/* */ try { +/* 171 */ user_id = this.session.getUser().getProperty("user_id"); +/* 172 */ } catch (TCException ex) { +/* 173 */ ex.printStackTrace(); +/* */ } +///* 177 */ int rowCount = this.table.getRowCount(); + + Map userMap=new HashMap(); + userMap.put("TCUser", user_id); + List doPost = DBUtils.doPost(userMap, session); + UserList userList = doPost.get(0); + +/* 178 */ List rootList=new ArrayList(); + List entryMap=new ArrayList(); + List> list=new ArrayList>(); + Map bomMap=new HashMap(); +// if(resource.containsKey(user_id)) { + bomMap.put("creater", userList.getERP_USER_CODE()); +// }else { +// bomMap.put("creater", "ZX_COMM"); +// } + RootAddEnty rootEntry=new RootAddEnty(); + String assembly = table.getValueAt(0, 0).toString(); + int rowCount = this.table.getRowCount(); + int t=0; + for (int i = 0; i < rowCount; i++) { + rootEntry.setAssembly_item(assembly); + TCComponentForm tcComponentForm = listProcessRevMasters.get(t); + AIFComponentContext[] whereReferenced = tcComponentForm.whereReferenced(); + TCComponent component = (TCComponent) whereReferenced[0].getComponent(); + rootEntry.setVersion(component.getStringProperty("item_revision_id")); + if(assembly!=table.getValueAt(i, 0).toString()) { + t++; + entryMap.add(rootEntry); + rootEntry.setRouteLine(list); + rootEntry=new RootAddEnty(); + assembly=table.getValueAt(i, 0).toString(); + list=new ArrayList>(); + } + if(i==rowCount-1) { + entryMap.add(rootEntry); + rootEntry.setRouteLine(list); + rootEntry=new RootAddEnty(); + } + Map jsonMap=new HashMap(); + jsonMap.put("operation_seq_num", table.getValueAt(i, 1).toString()); + jsonMap.put("operation_description", table.getValueAt(i, 2).toString()); + jsonMap.put("department_code", table.getValueAt(i, 3).toString()); + + String amount = table.getValueAt(i, 4).toString(); + if(amount.equals(" ")|| amount.equals("0")) { + amount=null; + } + + String amount_auxiliary= table.getValueAt(i, 5).toString(); + if(amount_auxiliary.equals(" ")|| amount_auxiliary.equals("0")) { + amount_auxiliary=null; + } + jsonMap.put("usage_rate_or_amount", amount); + jsonMap.put("usage_rate_or_amount_auxiliary", amount_auxiliary); + list.add(jsonMap); +/* */ } + ProcessAddTransferToERPOperation operation=new ProcessAddTransferToERPOperation(application,session,entryMap,bomMap,ProcessAddTransferToERPDialog.this); + session.queueOperation(operation); + +// System.out.println("关闭页面"); +///* 223 */ this.dispose(); +/* 224 */ +/* */ } + +/* */ +/* */ +/* */ public void validateImport() { +/* 229 */ if (this.isDepartmentNull) { +/* 230 */ MessageBox.post(this.application.getDesktop().getShell(), "部门(设备)不能为空!", "警告", 4); +/* */ return; +/* */ } +/* 233 */ String user_id = ""; +/* */ try { +/* 235 */ user_id = this.session.getUser().getProperty("user_id"); +/* 236 */ } catch (TCException ex) { +/* 237 */ ex.printStackTrace(); +/* */ } + + + List entryMap=new ArrayList(); + List> list=new ArrayList>(); + Map bomMap=new HashMap(); + + + + RootEntry rootEntry=new RootEntry(); + String assembly = table.getValueAt(0, 0).toString(); + int rowCount = this.table.getRowCount(); + for (int i = 0; i < rowCount; i++) { + rootEntry.setAssembly_item(assembly); + + if(assembly!=table.getValueAt(i, 0).toString()) { + entryMap.add(rootEntry); + rootEntry.setRouteLine(list); + rootEntry=new RootEntry(); + assembly=table.getValueAt(i, 0).toString(); + list=new ArrayList>(); + } + if(i==rowCount-1) { + entryMap.add(rootEntry); + rootEntry.setRouteLine(list); +// rootEntry=new RootEntry(); + } + Map jsonMap=new HashMap(); + jsonMap.put("department_code", table.getValueAt(i, 3).toString()); + list.add(jsonMap); +/* */ } + + bomMap.put("ROUTE", entryMap); + List doPost = doPost(bomMap,"RouteAddCheck"); + +///* 250 */ String result = UtilApi.getErrorInfoFromCode(8); +/* 251 */ if (!msgString.equals("succ")) { +/* 252 */ MessageBox.post(this.application.getDesktop().getShell(), msgString, "验证出现错误", 1); +/* */ return; +/* */ } +///* 255 */ StringBuffer errorInfo = new StringBuffer(""); +//String returnInfo =""; + +/* 256 */ String errorInfo = ProcessImportReadXMLStr.loadAddElements(doPost); + System.out.println(errorInfo); +/* 257 */ if (errorInfo.toString().equals("") ) {//|| returnInfo.equals("成功") +/* 258 */ MessageBox.post(this.application.getDesktop().getShell(), "导入验证成功,可以执行导入操作!", "成功", 2); +/* 259 */ this.btnImport.setEnabled(true); +/* */ } +/* 261 */ else if (errorInfo.equals("所有的工艺路线都已经存在")) { +/* 262 */ dispose(); +/* 263 */ Object[] obj = new Object[1]; +/* 264 */ obj[0] = Integer.valueOf(11); +/* 265 */ TCUserService service = this.session.getUserService(); +/* 266 */ int formNum = this.listProcessRevMasters.size(); +/* 267 */ for (int i = 0; i < formNum; i++) { +/* */ try { +/* 269 */ service.call("openByPass", obj); +/* 270 */ ((TCComponentForm)this.listProcessRevMasters.get(i)).setLogicalProperty("nhl8_ERPimpSucc", true); +/* 271 */ service.call("closeByPass", obj); +/* 272 */ } catch (TCException e1) { +/* 273 */ e1.printStackTrace(); +/* */ } +/* */ } +/* 276 */ MessageBox.post(this.application.getDesktop().getShell(), "工艺路线已经存在,不可重复导入;如需变更,请执行变更导入!", "警告", 2); +/* */ } else { +/* 278 */ SwingUtilities.invokeLater((Runnable)new ValidateFailDialog("验证失败,请查看详细信息:", "警告", errorInfo.toString())); +/* */ } +/* */ } +private List doPost(Map itemCheckMap, String svr) { + HashMap preferenceHashMap = TCPreferenceUitl.getPreferenceHashMap(session, TCPreferenceService.TC_preference_site, erpPreference); + String url = preferenceHashMap.get("url"); + String token = preferenceHashMap.get("token"); + String jsonString=new Gson().toJson(itemCheckMap); + JSONObject itemCheckJson = JSONObject.fromObject(jsonString); + String sid = null; + try { + System.out.println("开始发送请求"); + String args = itemCheckJson.toString(); + System.out.println(args); + token = URLEncoder.encode(token,"UTF-8"); + svr = URLEncoder.encode(svr,"UTF-8"); + args = URLEncoder.encode(args,"UTF-8"); + String param = "usr="+token+"&svr="+svr+"&args="+args; + + System.out.println("url=============="+url); + System.out.println("param==========="+args); + String response = HttpUtil.doPost(url, param); //.doGet(url+"?"+param) +// System.out.println("请求结果================"+response); + + JSONObject jsonObject = JSONObject.fromObject(response); + System.out.println("json格式==============="+jsonObject); + if(svr.equals("RouteAddCheck")) { + msgString = jsonObject.getString("msg"); + if(jsonObject.has("cont")) { + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); + if(jsonObject2.has("checkResult")) { + JSONArray jsonObject3 = jsonObject2.getJSONArray("checkResult"); + Gson gson = new Gson(); + List list= gson.fromJson(jsonObject3.toString(), new TypeToken>() {}.getType()); + return list; + } + } + } +// else if (svr.equals("ROUTEAdd")) { +// msgString = jsonObject.getString("msg"); +// if(jsonObject.has("cont")) { +// JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); +// +// if(jsonObject2.has("compareResult")) { +// +// JSONArray jsonObject3 = jsonObject2.getJSONArray("compareResult"); +// List list = JSONArray.toList(jsonObject3,CompareResult.class); +//// System.out.println(jsonObject3+"list"+list.size()); +// +// return list; +// } +// } +// } + + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return null; +} +/* */ } + + +/* Location: C:\Users\cyh\Documents\WeChat Files\wxid_ztg4pdvd5bjn12\FileStorage\File\2022-03\com.origin.erpintegration_1.0.0.jar!\com\origin\erp\ProcessImport\ProcessAddTransferToERP\ProcessAddTransferToERPDialog.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 1.1.3 + */ \ No newline at end of file diff --git a/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPHandler.java b/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPHandler.java new file mode 100644 index 0000000..d882694 --- /dev/null +++ b/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPHandler.java @@ -0,0 +1,55 @@ +/* */ package com.connor.erp.ProcessImport.ProcessAddTransferToERP; +/* */ +/* */ import com.connor.erp.ProcessImport.ProcessImportHandler; +/* */ import com.connor.erp.toolkit.AimType; +/* */ import com.teamcenter.rac.aif.AbstractAIFCommand; +/* */ import org.eclipse.core.commands.ExecutionEvent; +/* */ import org.eclipse.core.commands.ExecutionException; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class ProcessAddTransferToERPHandler +/* */ extends ProcessImportHandler +/* */ { +/* */ public Object execute(ExecutionEvent event) throws ExecutionException { +/* 35 */ if (!checkTarget(AimType.add)) { +/* 36 */ return null; +/* */ } +/* 38 */ if (this.listProcessRevisions.size() > 0) { +/* */ try { +/* 40 */ AbstractAIFCommand command = new ProcessAddTransferToERPCommand(this.session, this.application, this.listProcessRevisions, this.detailInfo, this.isPrivilege); +/* 41 */ command.executeModal(); +/* 42 */ } catch (Exception e) { +/* 43 */ e.printStackTrace(); +/* */ } +/* */ } +/* */ +/* 47 */ return null; +/* */ } +/* */ } + + +/* Location: C:\Users\cyh\Documents\WeChat Files\wxid_ztg4pdvd5bjn12\FileStorage\File\2022-03\com.origin.erpintegration_1.0.0.jar!\com\origin\erp\ProcessImport\ProcessAddTransferToERP\ProcessAddTransferToERPHandler.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 1.1.3 + */ \ No newline at end of file diff --git a/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPOperation.java b/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPOperation.java new file mode 100644 index 0000000..69ab6a2 --- /dev/null +++ b/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/ProcessAddTransferToERPOperation.java @@ -0,0 +1,341 @@ +package com.connor.erp.ProcessImport.ProcessAddTransferToERP; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Label; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.SwingConstants; + +import com.connor.erp.BomAddTransferToERP.BomAdd; +import com.connor.erp.BomChgTransferToERP.DBUtils; +import com.connor.erp.processresource.EquipmentAcquiredFromERP.TCPreferenceUitl; +import com.connor.erp.toolkit.HttpUtil; +import com.google.gson.Gson; +import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ; +import com.sun.org.apache.xml.internal.serializer.ElemDesc; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONObject; + +public class ProcessAddTransferToERPOperation extends AbstractAIFOperation{ + private final String CONNOR_TC_TO_ERP_PART_TIME = "connor_tc_to_erp_part_time"; + private String msgString; + private AbstractAIFUIApplication app; + private TCSession session; + private List entryMap=new ArrayList(); + private Map bomMap=new HashMap(); + private String user_id; + private AbstractAIFDialog dialog; + private String erpPreference = "connor_tc_to_erp_url"; + private PreparedStatement stmt; + private Connection connectionFun; + private ResultSet r ; + private ResourceBundle resource = ResourceBundle.getBundle("tcUser_erpUser"); + public ProcessAddTransferToERPOperation(AbstractAIFUIApplication app,TCSession session,List entryMap,Map bomMap,AbstractAIFDialog dialog) { + this.app=app; + this.session=session; + this.entryMap=entryMap; + this.bomMap=bomMap; + this.dialog=dialog; + } + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + user_id = session.getUser().getProperty("user_id"); + String timeout = session.getPreferenceService().getStringValue(CONNOR_TC_TO_ERP_PART_TIME); + if(timeout!=null&&timeout.length()>0) { + System.out.println("超时时间为"+timeout+"秒!"); + Daemon daemon = new Daemon(new Thread() { + public void run() { + WaitingDialog dia = new WaitingDialog(app.getDesktop(), "INFOMATION", "正在导入ERP..."); + dia.setAlwaysOnTop(true);//设置在窗口最前端 + dia.setVisible(true); + boolean flag = false; + try { + flag = importItemToERP(); + + }catch (InterruptedException e) { + // TODO Auto-generated catch block +// e.printStackTrace(); + dia.setVisible(false); + try { + if(r!=null) { + r.close(); + } + if(stmt!=null) { + stmt.close(); + } + if(connectionFun!=null) { + connectionFun.close(); + } + + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + MessageBox.post("导入超时!", "", MessageBox.INFORMATION); + return; + }catch(Exception e) { + + MessageBox.post("导入失败!", "", MessageBox.INFORMATION); + e.printStackTrace(); + } + if (flag) { + dia.setVisible(false); + MessageBox.post("导入成功! 如需查询导入状态,请在“ERP集成”—“ERP任务导入记录”中查找", "发送到ERP成功", 2); +// MessageBox.post("导入成功!", "", MessageBox.INFORMATION); + } else { + dia.setVisible(false); + try { + if(r!=null) { + r.close(); + } + if(stmt!=null) { + stmt.close(); + } + if(connectionFun!=null) { + connectionFun.close(); + } + + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + MessageBox.post("导入失败!", "", MessageBox.INFORMATION); + } + }; + },new BigDecimal(timeout)); + new Thread(daemon).start(); + }else { + MessageBox.post("请联系管理员配置"+CONNOR_TC_TO_ERP_PART_TIME+"首选项","",MessageBox.INFORMATION); + } + + + + + + + } + + protected boolean importItemToERP()throws InterruptedException, Exception { + // TODO Auto-generated method stub + List taskNums=new ArrayList(); + String sql = "select ImpResult from connor_ERP_record where TaskNumber=?"; + + + Map> map=new HashMap>(); + for (RootAddEnty bAdd : entryMap) { + List entryMap2 = new ArrayList<>(); + entryMap2.add(bAdd); + bomMap.put("ROUTE", entryMap2); + String doPost = doPost1((Map)bomMap, "ROUTEAdd"); + if (!this.msgString.equals("succ")) { + MessageBox.post(app.getDesktop().getShell(), this.msgString, "导入出现错误", 1); + continue; + } + DBUtils.InsertData(bAdd.getAssembly_item(),"工艺路线", doPost, user_id, bAdd.getVersion(), this.session); + + List itemMap=new ArrayList(); + itemMap.add(bAdd.getAssembly_item()); + itemMap.add(bAdd.getVersion()); + map.put(doPost,itemMap); + + +// Object obj[] = new Object[1]; +// obj[0] = 1; +// TCUserService service = session.getUserService(); +// service.call("openByPass", obj); +// TCComponentItemRevision itemRevision = DBUtils.getItemRevision(session,bAdd.getAssembly_item(),bAdd.getVersion()); +// TCComponentForm form = (TCComponentForm) itemRevision.getRelatedComponent("IMAN_master_form_rev"); +// form.setLogicalProperty("nhl8_ERPimpSucc", true); +// service.call("closeByPass", obj); + taskNums.add(doPost); + } + + boolean allSucc=false; + + connectionFun = DBUtils.ConnectionFun(session); + while (!allSucc) { + for(int i=0;i list = map.get(taskNums.get(i)); + Object obj[] = new Object[1]; + obj[0] = 1; + TCUserService service = session.getUserService(); + service.call("openByPass", obj); + String itemid=""; + if(list.get(0).contains("GY")) { + itemid=list.get(0); + }else { + itemid=list.get(0)+"GY"; + } + TCComponentItemRevision itemRevision = DBUtils.getItemRevision(session,itemid,list.get(1)); + TCComponentForm form = (TCComponentForm) itemRevision.getRelatedComponent("IMAN_master_form_rev"); + form.setLogicalProperty("nhl8_ERPimpSucc", true); + System.out.println("回填属性itemid"+list.get(0)+"rev"+list.get(1)); + service.call("closeByPass", obj); + + taskNums.remove(i); + i--; + }else if(impResult.contains("失败") || impResult.equals("任务id无效")){ + return false; + } + + } + if(taskNums.size()==0) { + allSucc=true; + System.out.println("所有任务都已完成"); + } + + Thread.sleep(1000); + } + if(r!=null) { + r.close(); + } + if(stmt!=null) { + stmt.close(); + } + if(connectionFun!=null) { + connectionFun.close(); + } + return true; + } + + class Daemon implements Runnable { + private Thread thread; + private BigDecimal time; + + public Daemon(Thread r, BigDecimal t) { + thread = r; + time = t; + } + + @Override + public void run() { + this.thread.start(); + while (true) { + try { + Thread.sleep(time.multiply(new BigDecimal("1000")).longValue()); + } catch (InterruptedException e) { + e.printStackTrace(); + } + thread.interrupt(); + } + } + + } + class WaitingDialog extends com.teamcenter.rac.aif.AbstractAIFDialog { + private static final long serialVersionUID = 1L; + public JPanel panel; + JProgressBar progressBar = null; + + public WaitingDialog(Frame arg0, String title, String message) { + super(arg0, title); + this.setModal(false); + + panel = new JPanel(new BorderLayout()); + + /* + * JLabel label = new JLabel(message); System.out.println("message:"+message); + * System.out.println("label:"+label); panel.add(label); + */ + + progressBar = new JProgressBar(SwingConstants.HORIZONTAL); + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + + panel.add(BorderLayout.CENTER, new Label(message)); + panel.add(BorderLayout.SOUTH, progressBar); + + panel.setPreferredSize(new Dimension(350, 60)); + + this.getContentPane().add(panel); + + centerToScreen(); + + pack(); + + } + } + private String doPost1(Map itemCheckMap, String svr) { + // TODO Auto-generated method stub + HashMap preferenceHashMap = TCPreferenceUitl.getPreferenceHashMap(session, TCPreferenceService.TC_preference_site, erpPreference); + String url = preferenceHashMap.get("url"); + String token = preferenceHashMap.get("token"); + String jsonString=new Gson().toJson(itemCheckMap); + JSONObject itemCheckJson = JSONObject.fromObject(jsonString); + String sid = null; + try { + System.out.println("开始发送请求"); + String args = itemCheckJson.toString(); + System.out.println(args); + token = URLEncoder.encode(token,"UTF-8"); + svr = URLEncoder.encode(svr,"UTF-8"); + args = URLEncoder.encode(args,"UTF-8"); + String param = "usr="+token+"&svr="+svr+"&args="+args; + + System.out.println("url=============="+url); + System.out.println("param==========="+args); + String response = HttpUtil.doPost(url, param); //.doGet(url+"?"+param) + + JSONObject jsonObject = JSONObject.fromObject(response); + System.out.println("json格式==============="+jsonObject); + msgString = jsonObject.getString("msg"); + if(jsonObject.has("cont")) { + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); + sid = jsonObject2.getString("sid"); + } + + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return sid; + } + +} diff --git a/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RootAddEnty.java b/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RootAddEnty.java new file mode 100644 index 0000000..908f2d0 --- /dev/null +++ b/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RootAddEnty.java @@ -0,0 +1,29 @@ +package com.connor.erp.ProcessImport.ProcessAddTransferToERP; + +import java.util.List; +import java.util.Map; + +public class RootAddEnty { + private String assembly_item; + private String version; + private List> RouteLine; + public String getVersion() { + return version; + } + public void setVersion(String version) { + this.version = version; + } + + public List> getRouteLine() { + return RouteLine; + } + public void setRouteLine(List> routeLine) { + RouteLine = routeLine; + } + public String getAssembly_item() { + return assembly_item; + } + public void setAssembly_item(String assembly_item) { + this.assembly_item = assembly_item; + } +} diff --git a/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RootCheckResult.java b/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RootCheckResult.java new file mode 100644 index 0000000..6df5f4f --- /dev/null +++ b/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RootCheckResult.java @@ -0,0 +1,48 @@ +package com.connor.erp.ProcessImport.ProcessAddTransferToERP; + +import java.util.List; +import java.util.Map; + +import com.connor.erpintegration.entity.RouteLineEntity; + +public class RootCheckResult { + private String assembly_item; + private String assembly_item_exist; + private String route_exist; + + private String canRouteImport; + + private List RouteLine; + + + public List getRouteLine() { + return RouteLine; + } + public void setRouteLine(List routeLine) { + RouteLine = routeLine; + } + public String getAssembly_item() { + return assembly_item; + } + public void setAssembly_item(String assembly_item) { + this.assembly_item = assembly_item; + } + public String getAssembly_item_exist() { + return assembly_item_exist; + } + public void setAssembly_item_exist(String assembly_item_exist) { + this.assembly_item_exist = assembly_item_exist; + } + public String getRoute_exist() { + return route_exist; + } + public void setRoute_exist(String route_exist) { + this.route_exist = route_exist; + } + public String getCanRouteImport() { + return canRouteImport; + } + public void setCanRouteImport(String canRouteImport) { + this.canRouteImport = canRouteImport; + } +} diff --git a/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RootEntry.java b/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RootEntry.java new file mode 100644 index 0000000..11cf8c5 --- /dev/null +++ b/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RootEntry.java @@ -0,0 +1,21 @@ +package com.connor.erp.ProcessImport.ProcessAddTransferToERP; + +import java.util.List; +import java.util.Map; + +public class RootEntry { + private String assembly_item; + private List> RouteLine; + public List> getRouteLine() { + return RouteLine; + } + public void setRouteLine(List> RouteLine) { + this.RouteLine = RouteLine; + } + public String getAssembly_item() { + return assembly_item; + } + public void setAssembly_item(String assembly_item) { + this.assembly_item = assembly_item; + } +} diff --git a/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RouteLineCheck.java b/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RouteLineCheck.java new file mode 100644 index 0000000..4ddf7d7 --- /dev/null +++ b/src/com/connor/erp/ProcessImport/ProcessAddTransferToERP/RouteLineCheck.java @@ -0,0 +1,18 @@ +package com.connor.erp.ProcessImport.ProcessAddTransferToERP; + +public class RouteLineCheck { + private String department_code; + private String department_exist; + public String getDepartment_code() { + return department_code; + } + public void setDepartment_code(String department_code) { + this.department_code = department_code; + } + public String getDepartment_exist() { + return department_exist; + } + public void setDepartment_exist(String department_exist) { + this.department_exist = department_exist; + } +} diff --git a/src/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferOperation.java b/src/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferOperation.java new file mode 100644 index 0000000..824a9dc --- /dev/null +++ b/src/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferOperation.java @@ -0,0 +1,333 @@ +package com.connor.erp.ProcessImport.ProcessChgTransferToERP; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Label; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.SwingConstants; + +import com.connor.erp.BomChgTransferToERP.DBUtils; +import com.connor.erp.ProcessImport.ProcessAddTransferToERP.RootAddEnty; +import com.connor.erp.processresource.EquipmentAcquiredFromERP.TCPreferenceUitl; +import com.connor.erp.toolkit.HttpUtil; +import com.google.gson.Gson; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONObject; + +public class ProcessChgTransferOperation extends AbstractAIFOperation{ + private final String CONNOR_TC_TO_ERP_PART_TIME = "connor_tc_to_erp_part_time"; + private String msgString; + private AbstractAIFUIApplication app; + private TCSession session; + private List entryMap=new ArrayList(); + private Map bomMap=new HashMap(); + private String user_id; + private AbstractAIFDialog dialog; + private String erpPreference = "connor_tc_to_erp_url"; + private PreparedStatement stmt; + private Connection connectionFun; + private ResultSet r ; + private ResourceBundle resource = ResourceBundle.getBundle("tcUser_erpUser"); + public ProcessChgTransferOperation(AbstractAIFUIApplication app,TCSession session,List entryMap,Map bomMap,AbstractAIFDialog dialog) { + this.app=app; + this.session=session; + this.entryMap=entryMap; + this.bomMap=bomMap; + this.dialog=dialog; + } + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + user_id = session.getUser().getProperty("user_id"); + String timeout = session.getPreferenceService().getStringValue(CONNOR_TC_TO_ERP_PART_TIME); + if(timeout!=null&&timeout.length()>0) { + System.out.println("超时时间为"+timeout+"秒!"); + Daemon daemon = new Daemon(new Thread() { + public void run() { + WaitingDialog dia = new WaitingDialog(app.getDesktop(), "INFOMATION", "正在导入ERP..."); + dia.setAlwaysOnTop(true);//设置在窗口最前端 + dia.setVisible(true); + boolean flag = false; + try { + flag = importItemToERP(); + + }catch (InterruptedException e) { + // TODO Auto-generated catch block +// e.printStackTrace(); + dia.setVisible(false); + try { + if(r!=null) { + r.close(); + } + if(stmt!=null) { + stmt.close(); + } + if(connectionFun!=null) { + connectionFun.close(); + } + + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + MessageBox.post("导入超时!", "", MessageBox.INFORMATION); + return; + }catch(Exception e) { +// MessageBox.post("导入失败!", "", MessageBox.INFORMATION); + + e.printStackTrace(); + } + if (flag) { + dia.setVisible(false); + MessageBox.post("导入成功! 如需查询导入状态,请在“ERP集成”—“ERP任务导入记录”中查找", "发送到ERP成功", 2); + } else { + dia.setVisible(false); + try { + if(r!=null) { + r.close(); + } + if(stmt!=null) { + stmt.close(); + } + if(connectionFun!=null) { + connectionFun.close(); + } + + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + MessageBox.post("导入失败!", "", MessageBox.INFORMATION); + } + }; + },new BigDecimal(timeout)); + new Thread(daemon).start(); + }else { + MessageBox.post("请联系管理员配置"+CONNOR_TC_TO_ERP_PART_TIME+"首选项","",MessageBox.INFORMATION); + } + + } + protected boolean importItemToERP()throws InterruptedException, Exception { + + List taskNums=new ArrayList(); + String sql = "select ImpResult from connor_ERP_record where TaskNumber=?"; + Map> map=new HashMap>(); + for(RootAddEnty bAdd:entryMap) { + List entryMap2=new ArrayList(); + entryMap2.add(bAdd); + bomMap.put("ROUTE", entryMap2); + String doPost = doPost1(bomMap,"ROUTEChg"); + if (!msgString.equals("succ")) { +/* 207 */ MessageBox.post(this.app.getDesktop().getShell(), msgString, "导入出现错误", 1); +///* */ return; +/* */ } + DBUtils.InsertData(bAdd.getAssembly_item(), "工艺路线", doPost, user_id, bAdd.getVersion(), session); + + List itemMap=new ArrayList(); + itemMap.add(bAdd.getAssembly_item()); + itemMap.add(bAdd.getVersion()); + map.put(doPost,itemMap); + + taskNums.add(doPost); +// Object obj[] = new Object[1]; +// obj[0] = 1; +// TCUserService service = session.getUserService(); +// service.call("openByPass", obj); +// TCComponentItemRevision itemRevision = DBUtils.getItemRevision(session,bAdd.getAssembly_item(),bAdd.getVersion()); +// TCComponentForm form = (TCComponentForm) itemRevision.getRelatedComponent("IMAN_master_form_rev"); +// form.setLogicalProperty("nhl8_ERPimpSucc", true); +// service.call("closeByPass", obj); + + } + boolean allSucc=false; + connectionFun = DBUtils.ConnectionFun(session); + while (!allSucc) { + for(int i=0;i list = map.get(taskNums.get(i)); + Object obj[] = new Object[1]; + obj[0] = 1; + TCUserService service = session.getUserService(); + service.call("openByPass", obj); + String itemid=""; + if(list.get(0).contains("GY")) { + itemid=list.get(0); + }else { + itemid=list.get(0)+"GY"; + } + TCComponentItemRevision itemRevision = DBUtils.getItemRevision(session,itemid,list.get(1)); +// TCComponentItemRevision itemRevision = DBUtils.getItemRevision(session,list.get(0),list.get(1)); + TCComponentForm form = (TCComponentForm) itemRevision.getRelatedComponent("IMAN_master_form_rev"); + form.setLogicalProperty("nhl8_ERPimpSucc", true); + System.out.println("回填属性itemid"+list.get(0)+"rev"+list.get(1)); + service.call("closeByPass", obj); + + + taskNums.remove(i); + i--; + }else if(impResult.contains("失败") || impResult.equals("任务id无效")){ + return false; + } + + } + if(taskNums.size()==0) { + allSucc=true; + System.out.println("所有任务都已完成"); + } + + Thread.sleep(1000); + } + if(r!=null) { + r.close(); + } + if(stmt!=null) { + stmt.close(); + } + if(connectionFun!=null) { + connectionFun.close(); + } + dialog.dispose(); + return true; + } + + private String doPost1(Map itemCheckMap, String svr) { + // TODO Auto-generated method stub + HashMap preferenceHashMap = TCPreferenceUitl.getPreferenceHashMap(session, TCPreferenceService.TC_preference_site, erpPreference); + String url = preferenceHashMap.get("url"); + String token = preferenceHashMap.get("token"); + String jsonString=new Gson().toJson(itemCheckMap); + JSONObject itemCheckJson = JSONObject.fromObject(jsonString); + String sid = null; + try { + System.out.println("开始发送请求"); + String args = itemCheckJson.toString(); + System.out.println(args); + token = URLEncoder.encode(token,"UTF-8"); + svr = URLEncoder.encode(svr,"UTF-8"); + args = URLEncoder.encode(args,"UTF-8"); + String param = "usr="+token+"&svr="+svr+"&args="+args; + + System.out.println("url=============="+url); + System.out.println("param==========="+args); + String response = HttpUtil.doPost(url, param);//.doGet(url+"?"+param); +// System.out.println("请求结果================"+response); + + JSONObject jsonObject = JSONObject.fromObject(response); + System.out.println("json格式==============="+jsonObject); + msgString = jsonObject.getString("msg"); + if(jsonObject.has("cont")) { + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); + sid = jsonObject2.getString("sid"); + } + + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return sid; + } + + class Daemon implements Runnable { + private Thread thread; + private BigDecimal time; + + public Daemon(Thread r, BigDecimal t) { + thread = r; + time = t; + } + + @Override + public void run() { + this.thread.start(); + while (true) { + try { + Thread.sleep(time.multiply(new BigDecimal("1000")).longValue()); + } catch (InterruptedException e) { + e.printStackTrace(); + } + thread.interrupt(); + } + } + + } + class WaitingDialog extends com.teamcenter.rac.aif.AbstractAIFDialog { + private static final long serialVersionUID = 1L; + public JPanel panel; + JProgressBar progressBar = null; + + public WaitingDialog(Frame arg0, String title, String message) { + super(arg0, title); + this.setModal(false); + + panel = new JPanel(new BorderLayout()); + + /* + * JLabel label = new JLabel(message); System.out.println("message:"+message); + * System.out.println("label:"+label); panel.add(label); + */ + + progressBar = new JProgressBar(SwingConstants.HORIZONTAL); + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + + panel.add(BorderLayout.CENTER, new Label(message)); + panel.add(BorderLayout.SOUTH, progressBar); + + panel.setPreferredSize(new Dimension(350, 60)); + + this.getContentPane().add(panel); + + centerToScreen(); + + pack(); + + } + } + +} diff --git a/src/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPCommand.java b/src/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPCommand.java new file mode 100644 index 0000000..c0aab22 --- /dev/null +++ b/src/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPCommand.java @@ -0,0 +1,160 @@ +package com.connor.erp.ProcessImport.ProcessChgTransferToERP; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.SwingUtilities; + +import com.connor.erp.toolkit.IsContinueDialog; +import com.connor.erp.toolkit.UtilApi; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class ProcessChgTransferToERPCommand +/* */ extends AbstractAIFCommand +/* */ { +/* */ private TCSession session; +/* */ private AbstractAIFUIApplication application; +/* */ private List listProcessRevisions; +/* */ private StringBuffer detailInfo; +/* 49 */ private List listRowDatas = (List)new ArrayList(); +/* */ +/* 51 */ private Map> map = new HashMap>(); +/* */ +/* 53 */ private List listProcessRevMasters = new ArrayList(); +/* */ +/* */ +/* */ private boolean isPrivilege; +/* */ +/* */ +/* */ private boolean isDepartmentNull = false; +/* */ +/* */ +/* */ +/* */ public ProcessChgTransferToERPCommand(TCSession pSession, AbstractAIFUIApplication app, List listProcessRevisions, StringBuffer detailInfo, boolean isPrivilege) { +/* 64 */ this.session = pSession; +/* 65 */ this.application = app; +/* 66 */ this.listProcessRevisions = listProcessRevisions; +/* 67 */ this.detailInfo = detailInfo; +/* 68 */ this.isPrivilege = isPrivilege; +/* 69 */ postDialog(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public void postDialog() { +/* 76 */ int listSize = this.listProcessRevisions.size(); +/* 77 */ for (int i = 0; i < listSize; i++) { +/* 78 */ TCComponentItemRevision meprocessRevision = this.listProcessRevisions.get(i); +/* */ try { +/* 80 */ this.listProcessRevMasters.add((TCComponentForm)meprocessRevision.getRelatedComponent("IMAN_master_form_rev")); +/* 81 */ } catch (TCException e2) { +/* 82 */ e2.printStackTrace(); +/* */ } +/* 84 */ TCComponentBOMLine bomline = UtilApi.getNewBOMLine(this.session, meprocessRevision, null); +/* 85 */ String process_item_id = ""; +/* */ try { +/* 87 */ process_item_id = meprocessRevision.getProperty("item_id"); +/* 88 */ } catch (TCException e1) { +/* 89 */ e1.printStackTrace(); +/* */ } +/* 91 */ String part_item_id = process_item_id.substring(0, process_item_id.length() - 2); +/* 92 */ List list = new ArrayList(); +/* */ try { +/* 94 */ AIFComponentContext[] opers = bomline.getChildren(); +/* 95 */ int childCount = opers.length; +/* 96 */ int operNum = 0; +/* 97 */ for (int j = 0; j < childCount; j++) { +/* 98 */ TCComponentBOMLine operBom = (TCComponentBOMLine)opers[j].getComponent(); +/* 99 */ TCComponentItemRevision itemRevision = operBom.getItemRevision(); +/* 100 */ if (itemRevision instanceof TCComponentMEOPRevision || itemRevision.getType().equals("NHL8_RigOutGXRevision")) { +///* 101 */ TCComponentMEOPRevision operRevision = (TCComponentMEOPRevision)itemRevision; +/* 102 */ if (itemRevision.getTCClass().getSuperClass().toString().equals("NHL8_MEOPRevision") || itemRevision.getType().equals("NHL8_RigOutGXRevision")) { +/* 103 */ if ((itemRevision.getReferenceListProperty("release_status_list")).length == 0) { +/* 104 */ if (!this.isPrivilege) { +/* 105 */ MessageBox.post(itemRevision + " 对象未发布", "警告", 4); +/* */ return; +/* */ } +/* 108 */ this.detailInfo.append(itemRevision + " 对象未发布
"); +/* */ } +/* */ +/* 111 */ String[] rowData = new String[7]; +/* 112 */ rowData[0] = part_item_id; +/* 113 */ String bl_sequence_no = operBom.getProperty("bl_sequence_no"); +/* 114 */ rowData[1] = bl_sequence_no; +/* 115 */ rowData[2] = itemRevision.getProperty("object_name"); +/* 116 */ TCComponentForm form = (TCComponentForm)itemRevision.getRelatedComponent("IMAN_master_form_rev"); +/* 117 */ String[] formProNames = { "nhl8_StandardWH", "nhl8_AuxiliaryWH" }; +/* 118 */ String[] formProValues = form.getProperties(formProNames); +/* 119 */ if (formProValues[0].equals("")) { +/* 120 */ rowData[4] = "0"; +/* */ } else { +/* 122 */ rowData[4] = formProValues[0]; +/* */ } +/* 124 */ if (formProValues[1].equals("")) { +/* 125 */ rowData[5] = "0"; +/* */ } else { +/* 127 */ rowData[5] = formProValues[1]; +/* */ } +/* 129 */ rowData[6] = ""; +/* 130 */ AIFComponentContext[] children = operBom.getChildren(); +/* 131 */ int childCount2 = children.length; +/* 132 */ boolean existEquipment = false; +/* 133 */ for (int k = 0; k < childCount2; k++) { +/* 134 */ if (((TCComponentBOMLine)children[k].getComponent()).getItem().getType().equals("NHL8_Equipments")) { +/* 135 */ String equ_id = ""; +/* */ try { +/* 137 */ equ_id = children[k].getComponent().getProperty("bl_item_item_id").substring(4); +/* 138 */ } catch (Exception e) { +/* 139 */ e.printStackTrace(); +/* */ } +/* 141 */ rowData[3] = equ_id; +/* 142 */ list.add(bl_sequence_no + ";" + equ_id); +/* 143 */ existEquipment = true; +/* */ break; +/* */ } +/* */ } +/* 147 */ if (!existEquipment) { +/* 148 */ this.isDepartmentNull = true; +/* */ } +/* 150 */ this.listRowDatas.add(rowData); +/* 151 */ operNum++; +/* */ } +/* */ } +/* */ } +/* */ +/* 156 */ if (operNum == 0) { +/* 157 */ MessageBox.post(this.application.getDesktop().getShell(), meprocessRevision + "下面没有任何的工序对象!", "警告", 4); +/* */ return; +/* */ } +/* 160 */ } catch (TCException e) { +/* 161 */ e.printStackTrace(); +/* */ } +/* 163 */ this.map.put(part_item_id, list); +/* */ } +/* 165 */ if (this.isPrivilege) { +/* 166 */ if (!this.detailInfo.toString().equals("")) { +/* 167 */ setRunnable((Runnable)new IsContinueDialog(this, "所选部分工艺/工序对象未发布", this.detailInfo.toString())); +/* */ } else { +/* 169 */ setRunnable((Runnable)new ProcessChgTransferToERPDialog(this.session, this.application, this.listRowDatas, this.map, this.listProcessRevMasters, this.isDepartmentNull)); +/* */ } +/* */ } else { +/* 172 */ setRunnable((Runnable)new ProcessChgTransferToERPDialog(this.session, this.application, this.listRowDatas, this.map, this.listProcessRevMasters, this.isDepartmentNull)); +/* */ } +/* */ } +/* */ +/* */ public void postDialog2() { +/* 177 */ SwingUtilities.invokeLater((Runnable)new ProcessChgTransferToERPDialog(this.session, this.application, this.listRowDatas, this.map, this.listProcessRevMasters, this.isDepartmentNull)); +/* */ } +/* */ } diff --git a/src/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog.java b/src/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog.java new file mode 100644 index 0000000..8d8ef7f --- /dev/null +++ b/src/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPDialog.java @@ -0,0 +1,603 @@ +/* */ package com.connor.erp.ProcessImport.ProcessChgTransferToERP; +import com.connor.erp.BomChgTransferToERP.DBUtils; +import com.connor.erp.BomChgTransferToERP.UserList; +/* */ +/* */ import com.connor.erp.ProcessImport.ProcessImportReadXMLStr; +/* */ import com.connor.erp.ProcessImport.TransferRouteXMLWriter; +/* */ import com.connor.erp.ProcessImport.ValidateFailDialog; +/* */ import com.connor.erp.ProcessImport.ValidateRouteXMLWriter; +import com.connor.erp.ProcessImport.ProcessAddTransferToERP.RootAddEnty; +import com.connor.erp.ProcessImport.ProcessAddTransferToERP.RootCheckResult; +import com.connor.erp.ProcessImport.ProcessAddTransferToERP.RootEntry; +import com.connor.erp.processresource.EquipmentAcquiredFromERP.TCPreferenceUitl; +/* */ import com.connor.erp.toolkit.ActionType; +/* */ import com.connor.erp.toolkit.AimType; +/* */ import com.connor.erp.toolkit.FileType; +import com.connor.erp.toolkit.HttpUtil; +/* */ import com.connor.erp.toolkit.UtilApi; +import com.connor.erpintegration.entity.RouteCheckResult; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +///* */ import com.connor.tcerp.conn.PlmErpIntegration; +/* */ import com.teamcenter.rac.aif.AbstractAIFDialog; +/* */ import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +/* */ import com.teamcenter.rac.common.TCTable; +import com.teamcenter.rac.kernel.TCComponent; +/* */ import com.teamcenter.rac.kernel.TCComponentForm; +/* */ import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +/* */ import com.teamcenter.rac.kernel.TCSession; +/* */ import com.teamcenter.rac.kernel.TCUserService; +/* */ import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/* */ import java.awt.BorderLayout; +/* */ import java.awt.Color; +/* */ import java.awt.Component; +/* */ import java.awt.Dimension; +/* */ import java.awt.event.ActionEvent; +/* */ import java.awt.event.ActionListener; +/* */ import java.io.File; +/* */ import java.io.FileNotFoundException; +import java.net.URLEncoder; +/* */ import java.util.ArrayList; +/* */ import java.util.Collections; +/* */ import java.util.Comparator; +/* */ import java.util.HashMap; +/* */ import java.util.List; +/* */ import java.util.Map; +import java.util.ResourceBundle; + +/* */ import javax.swing.Icon; +/* */ import javax.swing.ImageIcon; +/* */ import javax.swing.JButton; +/* */ import javax.swing.JPanel; +/* */ import javax.swing.JScrollPane; +/* */ import javax.swing.JTabbedPane; +/* */ import javax.swing.JTable; +/* */ import javax.swing.SwingUtilities; +/* */ import javax.swing.table.DefaultTableCellRenderer; +/* */ import javax.xml.parsers.ParserConfigurationException; +/* */ import javax.xml.transform.TransformerException; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class ProcessChgTransferToERPDialog +/* */ extends AbstractAIFDialog +/* */ implements ActionListener +/* */ { +/* */ private static final long serialVersionUID = 1L; +/* */ private TCSession session; +/* */ private AbstractAIFUIApplication application; +/* */ private TCTable newTable; +/* */ private TCTable oldTable; +/* */ private List listRowDatas; +/* */ private JButton btnImport; +/* */ private JButton btnValidate; +/* */ private JButton btnCancel; +/* */ private JScrollPane newScrollPane; +/* */ private JScrollPane oldScrollPane; +/* 87 */ private JTabbedPane tabbedPane = null; +/* */ +/* */ private Map> map; +/* */ +/* */ private List listProcessRevMasters; +/* */ +/* */ private boolean isDepartmentNull = false; +/* */ +/* */ private static String erpPreference = "connor_tc_to_erp_url"; +/* */ private String msgString; +/* */ public ProcessChgTransferToERPDialog(TCSession pSession, AbstractAIFUIApplication app, List plistRowDatas, Map> pmap, List plistProcessRevMasters, boolean isDepartmentNull) { +/* 97 */ super(false); +/* 98 */ this.session = pSession; +/* 99 */ this.application = app; +/* 100 */ this.listRowDatas = plistRowDatas; +/* 101 */ this.map = pmap; +/* 102 */ this.listProcessRevMasters = plistProcessRevMasters; +/* 103 */ this.isDepartmentNull = isDepartmentNull; +/* 104 */ initUI(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ private void initUI() { +/* 111 */ setTitle("变更工艺路线"); +this.setLayout(new PropertyLayout()); +/* 112 */ String[] colName = { "装配件号", "工序号", "工序说明", "部门", "标准工时", "辅助工时", "状态" }; +/* 113 */ this.newTable = new TCTable(this.session, colName) +/* */ { +/* */ private static final long serialVersionUID = 1L; +/* */ +/* */ +/* */ +/* */ +/* */ public boolean isCellEditable(int i, int j) { +/* 121 */ return false; +/* */ } +/* */ }; +/* */ +/* 125 */ String[] colName2 = { "装配件号", "工序号", "工序说明", "部门", "标准工时", "辅助工时" }; +/* 126 */ this.oldTable = new TCTable(this.session, colName2) +/* */ { +/* */ private static final long serialVersionUID = 1L; +/* */ +/* */ +/* */ +/* */ +/* */ public boolean isCellEditable(int i, int j) { +/* 134 */ return false; +/* */ } +/* */ }; +/* */ +/* */ +/* 139 */ fillData(); +/* */ +/* 141 */ int totalWidth = UtilApi.FitTableColumns((JTable)this.newTable); +/* 142 */ this.btnValidate = new JButton("工艺路线导入验证"); +/* 143 */ this.btnValidate.addActionListener(this); +/* */ +/* 145 */ this.btnImport = new JButton("工艺路线导入ERP系统"); +/* 146 */ this.btnImport.addActionListener(this); +/* 147 */ this.btnImport.setEnabled(false); +/* */ +/* 149 */ this.btnCancel = new JButton("取消"); +/* 150 */ this.btnCancel.addActionListener(this); +/* */ +/* 152 */ JPanel paneButton = new JPanel(); +/* 153 */ paneButton.add(this.btnValidate); +/* 154 */ paneButton.add(this.btnImport); +/* 155 */ paneButton.add(this.btnCancel); +/* */ +/* 157 */ this.newScrollPane = new JScrollPane((Component)this.newTable); +/* */ +/* 159 */ this.oldScrollPane = new JScrollPane((Component)this.oldTable); +/* */ +/* 161 */ this.tabbedPane = new JTabbedPane(1); +/* 162 */ this.tabbedPane.setTabPlacement(1); +/* 163 */ Icon icon = new ImageIcon("projectobject_16.png"); +/* 164 */ this.tabbedPane.addTab("PLM新工艺", icon, this.newScrollPane, "PLM新工艺"); +/* 165 */ this.tabbedPane.addTab("ERP老工艺", icon, this.oldScrollPane, "ERP老工艺"); +/* 166 */ this.tabbedPane.setEnabledAt(1, false); +/* 167 */ JPanel paneMain = new JPanel(new BorderLayout()); +/* 168 */ paneMain.add("Center", this.tabbedPane); +/* 169 */ paneMain.add("South", paneButton); +/* 170 */ this.add("1.1.left.top",paneMain); +/* 171 */ setPreferredSize(new Dimension(500, 600)); +showDialog(); +this.setVisible(true); +/* */ } +/* */ +/* */ public void fillData() { +/* 175 */ int vecSize = this.listRowDatas.size(); +/* 176 */ Collections.sort((List)this.listRowDatas, (Comparator)new Comparator() +/* */ { +/* */ public int compare(String[] o1, String[] o2) +/* */ { +/* 180 */ if (o1[0].equals(o2[0])) { +/* 181 */ return o1[1].compareTo(o2[1]); +/* */ } +/* 183 */ return o1[0].compareTo(o2[0]); +/* */ } +/* */ }); +/* */ +/* 187 */ for (int i = 0; i < vecSize; i++) { +/* 188 */ this.newTable.addRow(this.listRowDatas.get(i)); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ private ResourceBundle resource = ResourceBundle.getBundle("tcUser_erpUser"); + +/* */ private void doImport() throws TCException { +/* 197 */ String user_id = ""; +/* */ try { +/* 199 */ user_id = this.session.getUser().getProperty("user_id"); +/* 200 */ } catch (TCException ex) { +/* 201 */ ex.printStackTrace(); +/* */ } + + Map userMap=new HashMap(); + userMap.put("TCUser", user_id); + List doPost = DBUtils.doPost(userMap, session); + UserList userList = doPost.get(0); + +/* 203 */ List entryMap=new ArrayList(); + List> list=new ArrayList>(); + Map bomMap=new HashMap(); +// if(resource.containsKey(user_id)) { +// bomMap.put("creater", resource.getString(user_id)); +// }else { + bomMap.put("creater", userList.getERP_USER_CODE()); + System.out.println("creater"+userList.getERP_USER_CODE()); +// } + RootAddEnty rootEntry=new RootAddEnty(); + String assembly = newTable.getValueAt(0, 0).toString(); + int rowCount = this.newTable.getRowCount(); + int t=0; + for (int i = 0; i < rowCount; i++) { + String state = this.newTable.getValueAt(i, 6).toString(); + if(state.equals("删除")) { + System.out.println("跳过删除"); + if(rootEntry.getAssembly_item()!=null && !rootEntry.getAssembly_item().equals("")) { + if(i==rowCount-1) { + entryMap.add(rootEntry); + rootEntry.setRouteLine(list); + } + // rootEntry=new RootAddEnty(); + } + continue; + } + rootEntry.setAssembly_item(assembly); + TCComponentForm tcComponentForm = listProcessRevMasters.get(t); + AIFComponentContext[] whereReferenced = tcComponentForm.whereReferenced(); + TCComponent component = (TCComponent) whereReferenced[0].getComponent(); + rootEntry.setVersion(component.getStringProperty("item_revision_id")); + if(!assembly.equals(newTable.getValueAt(i, 0).toString())) { + System.out.println("new ArrayList?"+newTable.getValueAt(i, 0).toString()); + t++; + entryMap.add(rootEntry); + rootEntry.setRouteLine(list); + rootEntry=new RootAddEnty(); + assembly=newTable.getValueAt(i, 0).toString(); + list=new ArrayList>(); + } + if(i==rowCount-1) { + entryMap.add(rootEntry); + rootEntry.setRouteLine(list); + System.out.println("assembly"+assembly+"rootEntry"+rootEntry.getAssembly_item()); + } + Map jsonMap=new HashMap(); + jsonMap.put("operation_seq_num", newTable.getValueAt(i, 1).toString()); + jsonMap.put("operation_description", newTable.getValueAt(i, 2).toString()); + jsonMap.put("department_code", newTable.getValueAt(i, 3).toString()); + + String amount = newTable.getValueAt(i, 4).toString(); + if(amount.equals(" ") || amount.equals("0") || amount.equals("")) { + amount=null; + } + + String amount_auxiliary= newTable.getValueAt(i, 5).toString(); + if(amount_auxiliary.equals(" ")|| amount_auxiliary.equals("0") || amount.equals("")) { + amount_auxiliary=null; + } + + jsonMap.put("usage_rate_or_amount", amount); + jsonMap.put("usage_rate_or_amount_auxiliary", amount_auxiliary); + list.add(jsonMap); + } +// for(RootAddEnty bAdd:entryMap) { +// List entryMap2=new ArrayList(); +// entryMap2.add(bAdd); +// bomMap.put("ROUTE", entryMap2); +// String doPost = doPost1(bomMap,"ROUTEChg"); +// if (!msgString.equals("succ")) { +// /* 207 */ MessageBox.post(this.application.getDesktop().getShell(), msgString, "导入出现错误", 1); +// /* */ return; +// /* */ } +// DBUtils.InsertData(bAdd.getAssembly_item(), "工艺路线", doPost, user_id, bAdd.getVersion(), session); +// } + dispose(); + System.out.println("测试"+entryMap.size()); +// MessageBox.post("工艺路线任务已经成功发送给ERP,如果需要查询是否传递请在“ERP集成”—“ERP任务导入记录”中查找", "发送到ERP成功", 2); + ProcessChgTransferOperation operation=new ProcessChgTransferOperation(application,session,entryMap,bomMap,ProcessChgTransferToERPDialog.this); +/* 243 */ session.queueOperation(operation); +/* */ } +/* */ +/* */ +/* */ + +/* */ public void validateImport() { +/* 263 */ if (this.isDepartmentNull) { +/* 264 */ MessageBox.post(this.application.getDesktop().getShell(), "部分工艺的部门为空,请填写部门再进行导入!", "警告", 4); +/* */ return; +/* */ } +/* 267 */ String user_id = ""; +/* */ try { +/* 269 */ user_id = this.session.getUser().getProperty("user_id"); +/* 270 */ } catch (TCException ex) { +/* 271 */ ex.printStackTrace(); +/* */ } +/* 273 */ List entryMap=new ArrayList(); + List> list=new ArrayList>(); + Map bomMap=new HashMap(); + RootEntry rootEntry=new RootEntry(); + String assembly = newTable.getValueAt(0, 0).toString(); + int rowCount = this.newTable.getRowCount(); + for (int i = 0; i < rowCount; i++) { + rootEntry.setAssembly_item(assembly); + + if(assembly!=newTable.getValueAt(i, 0).toString()) { + entryMap.add(rootEntry); + rootEntry.setRouteLine(list); + rootEntry=new RootEntry(); + assembly=newTable.getValueAt(i, 0).toString(); + list=new ArrayList>(); + } + if(i==rowCount-1) { + entryMap.add(rootEntry); + rootEntry.setRouteLine(list); + // rootEntry=new RootEntry(); + } + Map jsonMap=new HashMap(); + jsonMap.put("department_code", newTable.getValueAt(i, 3).toString()); + jsonMap.put("operation_seq_num", newTable.getValueAt(i, 1).toString()); + list.add(jsonMap); +/* */ } + + bomMap.put("ROUTE", entryMap); + List doPost = doPost(bomMap,"RouteChgCheck"); + System.out.println(doPost.size()); +///* 288 */ String result = ""; +// UtilApi.getErrorInfoFromCode(PlmErpIntegration.validateData(xmlFilePath)); +/* 289 */ if (!msgString.equals("succ")) { +/* 290 */ MessageBox.post(this.application.getDesktop().getShell(), msgString, "验证出现错误", 1); +/* */ return; +/* */ } +/* 293 */ List listAll = new ArrayList(); +/* 294 */ List listAllAssAndOper = new ArrayList(); +/* 295 */ List listOld = (List)new ArrayList(); +/* 296 */ List listOldAssAndOper = new ArrayList(); +/* 297 */ String errorInfo = ""; + StringBuffer buffer=new StringBuffer(); + ProcessImportReadXMLStr.loadChgElements(doPost,buffer,listAll, listAllAssAndOper, listOld, listOldAssAndOper); + errorInfo=buffer.toString(); +/* 298 */ if (errorInfo.equals("")) { +/* */ +/* 300 */ Collections.sort((List)listOld, (Comparator)new Comparator() +/* */ { +/* */ public int compare(String[] o1, String[] o2) +/* */ { +/* 304 */ if (o1[0].equals(o2[0])) { +/* 305 */ return o1[1].compareTo(o2[1]); +/* */ } +/* 307 */ return o1[0].compareTo(o2[0]); +/* */ } +/* */ }); +/* */ +/* 311 */ this.oldTable.clear(); +/* 312 */ int listOldSize = listOld.size(); +/* 313 */ for (int i = 0; i < listOldSize; i++) { +/* 314 */ this.oldTable.addRow(listOld.get(i)); +/* */ } +/* 316 */ this.tabbedPane.setEnabledAt(1, true); +///* 317 */ int rowCount = this.newTable.getRowCount(); +/* */ +/* 319 */ List resultList = (List)new ArrayList(); +/* 320 */ int notChangeNum = 0; +/* 321 */ for (int row = 0; row < rowCount; row++) { +/* 322 */ String[] newRowData = new String[7]; +/* 323 */ String assembly_item_number = this.newTable.getValueAt(row, 0).toString(); +/* 324 */ String operation_seq_num = this.newTable.getValueAt(row, 1).toString(); +/* 325 */ String operation_description = this.newTable.getValueAt(row, 2).toString(); +/* 326 */ String department_code = this.newTable.getValueAt(row, 3).toString(); +/* 327 */ String usage_rate_or_amount = this.newTable.getValueAt(row, 4).toString(); +/* 328 */ String usage_rate_or_amount_auxiliary = this.newTable.getValueAt(row, 5).toString(); +/* 329 */ StringBuffer assAndOper = (new StringBuffer(assembly_item_number)).append(",").append(operation_seq_num); +/* 330 */ StringBuffer allSb = (new StringBuffer(assAndOper.toString())).append(",").append(operation_description).append(",").append(department_code).append(",").append(usage_rate_or_amount).append(",").append(usage_rate_or_amount_auxiliary); +/* 331 */ newRowData[0] = assembly_item_number; +/* 332 */ newRowData[1] = operation_seq_num; +/* 333 */ newRowData[2] = operation_description; +/* 334 */ newRowData[3] = department_code; +/* 335 */ newRowData[4] = usage_rate_or_amount; +/* 336 */ newRowData[5] = usage_rate_or_amount_auxiliary; +/* 337 */ if (!listOldAssAndOper.contains(assAndOper.toString())) { +/* 338 */ newRowData[6] = "新增"; +/* */ } +/* 340 */ else if (listAll.contains(allSb.toString())) { +/* 341 */ newRowData[6] = "未改"; +/* 342 */ notChangeNum++; +/* */ } else { +/* 344 */ newRowData[6] = "修改"; +/* */ } +/* */ +/* 347 */ int index = listAllAssAndOper.indexOf(assAndOper.toString()); +/* 348 */ if (index != -1) { +/* 349 */ listAll.remove(index); +/* 350 */ listAllAssAndOper.remove(assAndOper.toString()); +/* */ } +/* 352 */ resultList.add(newRowData); +/* */ } +/* 354 */ int listNewSize = listAll.size(); +/* 355 */ if (listNewSize > 0) { +/* 356 */ for (int k = 0; k < listNewSize; k++) { +/* 357 */ String[] newRowData = new String[7]; +/* 358 */ String[] str = ((String)listAll.get(k)).split(","); +/* 359 */ String oldAssAndOper = str[0] + "," + str[1]; +/* 360 */ //String[] oldStr = listOld.get(listOldAssAndOper.indexOf(oldAssAndOper)); + if(listOldAssAndOper!=null) { + System.out.println("listOldAssAndOper:"+listOldAssAndOper.toString()); + } + if(oldAssAndOper!=null) { + System.out.println("oldAssAndOper:"+oldAssAndOper.toString()); + } + + int index = listOldAssAndOper.indexOf(oldAssAndOper); + if (index >= 0 && index < listOld.size()) { + String[] oldStr = listOld.get(index); + newRowData[0] = str[0]; + /* 362 */ newRowData[1] = str[1]; + /* 363 */ newRowData[2] = oldStr[2]; + /* 364 */ newRowData[3] = oldStr[3]; + /* 365 */ newRowData[4] = oldStr[4]; + /* 366 */ newRowData[5] = oldStr[5]; + /* 367 */ newRowData[6] = "删除"; + /* 368 */ resultList.add(newRowData); + // do something + } else { + // 处理下标越界的情况 + continue; + } +/* 361 */ +/* */ } +/* */ } +/* 371 */ Collections.sort((List)resultList, (Comparator)new Comparator() +/* */ { +/* */ public int compare(String[] o1, String[] o2) +/* */ { +/* 375 */ if (o1[0].equals(o2[0])) { +/* 376 */ return o1[1].compareTo(o2[1]); +/* */ } +/* 378 */ return o1[0].compareTo(o2[0]); +/* */ } +/* */ }); +/* */ +/* 382 */ int newSize = resultList.size(); +/* 383 */ this.newTable.clear(); int j; +/* 384 */ for (j = 0; j < newSize; j++) { +/* 385 */ this.newTable.addRow(resultList.get(j)); +/* */ } +/* 387 */ for (j = 0; j < 7; j++) { +/* 388 */ this.newTable.getColumn(this.newTable.getColumnName(j)).setCellRenderer(new MyDefaultTableCellRenderer()); +/* */ } +/* 390 */ int oldWidth = UtilApi.FitTableColumns((JTable)this.oldTable); +/* 391 */ int newWidth = UtilApi.FitTableColumns((JTable)this.newTable); +/* 392 */ if (oldWidth > newWidth) { +/* 393 */ setPreferredSize(new Dimension(oldWidth, 400)); +/* */ } else { +/* 395 */ setPreferredSize(new Dimension(newWidth, 400)); +/* */ } +/* 397 */ if (notChangeNum == resultList.size()) { +/* 398 */ MessageBox.post(this.application.getDesktop().getShell(), "与ERP中的工艺路线(工序号、工序说明、部门、工时)一致,无需导入!", "警告", 4); +/* 399 */ int formNum = this.listProcessRevMasters.size(); +/* 400 */ Object[] obj = new Object[1]; +/* 401 */ obj[0] = Integer.valueOf(11); +/* 402 */ TCUserService service = this.session.getUserService(); +/* 403 */ for (int k = 0; k < formNum; k++) { +/* */ try { +/* 405 */ service.call("openByPass", obj); +/* 406 */ ((TCComponentForm)this.listProcessRevMasters.get(k)).setLogicalProperty("nhl8_ERPimpSucc", true); +/* 407 */ service.call("closeByPass", obj); +/* 408 */ } catch (TCException e) { +/* 409 */ e.printStackTrace(); +/* */ } +/* */ } +/* */ return; +/* */ } +/* 414 */ MessageBox.post(this.application.getDesktop().getShell(), "导入验证成功,可以执行导入操作!", "成功", 2); +/* 415 */ this.btnImport.setEnabled(true); +/* */ } else { +/* */ +/* 418 */ SwingUtilities.invokeLater((Runnable)new ValidateFailDialog("验证失败,请查看详细信息:", "警告", errorInfo)); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void actionPerformed(ActionEvent e) { +/* 429 */ if (e.getSource() == this.btnImport) { +/* 430 */ dispose(); +/* 431 */ try { + doImport(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } +/* 432 */ } else if (e.getSource() == this.btnValidate) { +/* 433 */ validateImport(); +/* 434 */ } else if (e.getSource() == this.btnCancel) { +/* 435 */ dispose(); +/* */ } +/* */ } +/* */ +/* */ +/* */ public class MyDefaultTableCellRenderer +/* */ extends DefaultTableCellRenderer +/* */ { +/* */ private static final long serialVersionUID = 1L; +/* */ +/* */ +/* */ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { +/* 447 */ String sixValue = table.getValueAt(row, 6).toString(); +/* 448 */ if (sixValue.equals("删除")) { +/* 449 */ setBackground(Color.RED); +/* 450 */ } else if (sixValue.equals("新增")) { +/* 451 */ setBackground(Color.GREEN); +/* 452 */ } else if (sixValue.equals("修改")) { +/* 453 */ setBackground(Color.YELLOW); +/* 454 */ } else if (sixValue.equals("未改")) { +/* 455 */ setBackground(Color.WHITE); +/* */ } +/* 457 */ return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); +/* */ } +/* */ } + +private List doPost(Map itemCheckMap, String svr) { + HashMap preferenceHashMap = TCPreferenceUitl.getPreferenceHashMap(session, TCPreferenceService.TC_preference_site, erpPreference); + String url = preferenceHashMap.get("url"); + String token = preferenceHashMap.get("token"); + String jsonString=new Gson().toJson(itemCheckMap); + JSONObject itemCheckJson = JSONObject.fromObject(jsonString); + String sid = null; + try { + System.out.println("开始发送请求"); + String args = itemCheckJson.toString(); + System.out.println(args); + token = URLEncoder.encode(token,"UTF-8"); + svr = URLEncoder.encode(svr,"UTF-8"); + args = URLEncoder.encode(args,"UTF-8"); + String param = "usr="+token+"&svr="+svr+"&args="+args; + + System.out.println("url=============="+url); + System.out.println("param==========="+args); + String response = HttpUtil.doPost(url, param); //.doGet(url+"?"+param) + +// System.out.println("请求结果================"+response); + + JSONObject jsonObject = JSONObject.fromObject(response); + System.out.println("json格式==============="+jsonObject); + if(svr.equals("RouteChgCheck")) { + msgString = jsonObject.getString("msg"); + if(jsonObject.has("cont")) { + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); + if(jsonObject2.has("checkResult")) { + JSONArray jsonObject3 = jsonObject2.getJSONArray("checkResult"); + Gson gson = new Gson(); + List list= gson.fromJson(jsonObject3.toString(), new TypeToken>() {}.getType()); + + return list; + } + } + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return null; +} +/* */ } + diff --git a/src/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPHandler.java b/src/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPHandler.java new file mode 100644 index 0000000..ed92802 --- /dev/null +++ b/src/com/connor/erp/ProcessImport/ProcessChgTransferToERP/ProcessChgTransferToERPHandler.java @@ -0,0 +1,50 @@ +/* */ package com.connor.erp.ProcessImport.ProcessChgTransferToERP; +/* */ +/* */ import com.connor.erp.ProcessImport.ProcessImportHandler; +/* */ import com.connor.erp.toolkit.AimType; +/* */ import com.teamcenter.rac.aif.AbstractAIFCommand; +/* */ import org.eclipse.core.commands.ExecutionEvent; +/* */ import org.eclipse.core.commands.ExecutionException; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class ProcessChgTransferToERPHandler +/* */ extends ProcessImportHandler +/* */ { +/* */ public Object execute(ExecutionEvent event) throws ExecutionException { +/* 35 */ if (!checkTarget(AimType.chg)) { +/* 36 */ return null; +/* */ } +/* 38 */ if (this.listProcessRevisions.size() > 0) { +/* */ try { +/* 40 */ AbstractAIFCommand command = new ProcessChgTransferToERPCommand(this.session, this.application, this.listProcessRevisions, this.detailInfo, this.isPrivilege); +/* 41 */ command.executeModal(); +/* 42 */ } catch (Exception e) { +/* 43 */ e.printStackTrace(); +/* */ } +/* */ } +/* */ +/* 47 */ return null; +/* */ } +/* */ } + diff --git a/src/com/connor/erp/ProcessImport/ProcessChgTransferToERP/projectobject_16.png b/src/com/connor/erp/ProcessImport/ProcessChgTransferToERP/projectobject_16.png new file mode 100644 index 0000000..e0f6c32 Binary files /dev/null and b/src/com/connor/erp/ProcessImport/ProcessChgTransferToERP/projectobject_16.png differ diff --git a/src/com/connor/erp/ProcessImport/ProcessImportApi.java b/src/com/connor/erp/ProcessImport/ProcessImportApi.java new file mode 100644 index 0000000..48f880f --- /dev/null +++ b/src/com/connor/erp/ProcessImport/ProcessImportApi.java @@ -0,0 +1,446 @@ + package com.connor.erp.ProcessImport; + + import com.connor.erp.processresource.EquipmentAcquiredFromERP.TCPreferenceUitl; +import com.connor.erp.toolkit.AimType; + import com.connor.erp.toolkit.FileType; +import com.connor.erp.toolkit.HttpUtil; + import com.connor.erp.toolkit.ReadResultXMLStr; + import com.connor.erp.toolkit.ResultInfo; + import com.connor.erp.toolkit.UtilApi; +import com.connor.erpintegration.entity.RouteCheckResult; +// import com.connor.tcerp.conn.PlmErpIntegration; + import com.teamcenter.rac.aif.AbstractAIFUIApplication; + import com.teamcenter.rac.kernel.TCComponent; + import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; + import com.teamcenter.rac.kernel.TCUserService; + import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import java.io.File; +import java.net.URLEncoder; +import java.util.ArrayList; + import java.util.HashMap; + import java.util.List; + import java.util.Map; +import java.util.ResourceBundle; + +import javax.swing.SwingUtilities; + + public class ProcessImportApi { + + private static String erpPreference = "connor_tc_to_erp_url"; + + private static ResourceBundle resource = ResourceBundle.getBundle("tcUser_erpUser"); + + public static boolean getTaskRouteAddResult(AbstractAIFUIApplication application, TCSession session, FileType fileType, String title, ProcessImportHandler handler, String dialogType) { +///* 46 */ ResultInfo addResultInfo = getRouteAddResult(application, session, FileType.route); +///* 47 */ if (addResultInfo == null) { + if (dialogType.equals("task")) { +/* 53 */ handler.postDialogForTask(false); +/* 54 */ } else if (dialogType.equals("route")) { +/* 55 */ handler.postDialogForRoute(false); + } +/* 57 */ return true; +// } +/* 48 */ +///* 50 */ String result = addResultInfo.getResult(); +///* 51 */ if (result.equals("新增工艺路线没有发现任务号!") || result.equals("新增工艺路线任务导入成功!")) { +///* 52 */ if (dialogType.equals("task")) { +///* 53 */ handler.postDialogForTask(false); +///* 54 */ } else if (dialogType.equals("route")) { +///* 55 */ handler.postDialogForRoute(false); +// } +///* 57 */ return true; +// } +///* 59 */ SwingUtilities.invokeLater((Runnable)new ValidateFailDialog(result, title, addResultInfo.getDetail(), handler, dialogType)); +///* 60 */ return false; + } + + public static boolean getTaskRouteChgResult(AbstractAIFUIApplication application, TCSession session, FileType fileType, String title, ProcessImportHandler handler, String dialogType) { +///* 67 */ ResultInfo chgResultInfo = getRouteChgResult(application, session, FileType.route); +///* 68 */ if (chgResultInfo == null) { + if (dialogType.equals("task")) { +/* 74 */ handler.postDialogForTask(false); +/* 75 */ } else if (dialogType.equals("route")) { +/* 76 */ handler.postDialogForRoute(false); + } +/* 78 */ return true; +// } +///* 71 */ String result = chgResultInfo.getResult(); +///* 72 */ if (result.equals("变更工艺路线没有发现任务号!") || result.equals("变更工艺路线任务导入成功!")) { +///* 73 */ if (dialogType.equals("task")) { +///* 74 */ handler.postDialogForTask(false); +///* 75 */ } else if (dialogType.equals("route")) { +///* 76 */ handler.postDialogForRoute(false); +// } +///* 78 */ return true; +// } +///* 80 */ SwingUtilities.invokeLater((Runnable)new ValidateFailDialog(chgResultInfo.getResult(), title, chgResultInfo.getDetail(), handler, dialogType)); +///* 81 */ return false; + } + +// public static void getTaskRouteResult(AbstractAIFUIApplication application, TCSession session, FileType fileType, String title) { +///* 89 */ ResultInfo addResultInfo = getRouteAddResult(application, session, FileType.route); +///* 90 */ ResultInfo chgResultInfo = getRouteChgResult(application, session, FileType.route); +///* 91 */ if (addResultInfo != null && chgResultInfo != null) { +///* 92 */ String RouteInfo = ""; +///* 93 */ String addResult = addResultInfo.getResult(); +///* 94 */ String chgResult = chgResultInfo.getResult(); +///* 95 */ if (addResult.equals("新增工艺路线没有发现任务号!") && chgResult.equals("变更工艺路线没有发现任务号!")) { +///* 96 */ MessageBox.post(application.getDesktop().getShell(), "新增和变更工艺路线没有发现任务号!", "信息", 2); +// return; +// } +///* 99 */ if (addResult.equals("新增工艺路线任务导入成功!") && chgResult.equals("变更工艺路线任务导入成功!")) { +///* 100 */ RouteInfo = "新增/变更工艺路线均导入成功!"; +// } else { +///* 102 */ RouteInfo = String.valueOf(addResult) + "
" + chgResult; +// } +///* 104 */ String detailInfo = String.valueOf(addResultInfo.getDetail()) + chgResultInfo.getDetail(); +///* 105 */ SwingUtilities.invokeLater((Runnable)new ValidateFailDialog(RouteInfo, title, detailInfo)); +// } +// } +// private ResourceBundle resource = ResourceBundle.getBundle("tcUser_erpUser"); + public static ResultInfo getRouteAddResult(AbstractAIFUIApplication application, TCSession session, FileType fileType) { + System.out.println("getRouteAddResult"); +/* 111 */ String user_id = ""; + try { +/* 113 */ user_id = session.getUser().getProperty("user_id"); +/* 114 */ } catch (TCException ex) { +/* 115 */ ex.printStackTrace(); + } +///* 117 */ String tempPath = System.getProperty("java.io.tmpdir") + File.separator; +///* 118 */ String xmlName = tempPath + user_id + "_" + UtilApi.getCurrentTime(); +///* 119 */ String xmlFilePath = xmlName + "_result.xml"; +///* 121 */ String addResult = UtilApi.getErrorInfoFromCode(PlmErpIntegration.getTaskResult(user_id, fileType.toString(), AimType.add.toString(), xmlFilePath, session)); +///* 121 */ String addResult = ""; +///* 122 */ if (addResult.equals("")) { +///* 123 */ MessageBox.post(application.getDesktop().getShell(), "获取上次导入结果导入超时,请联系管理员!", "超时", 1); +///* 124 */ return null; +// } +/* 126 */ StringBuffer addDetailInfo = new StringBuffer("新增工艺路线
"); +/* 127 */ String routeAddInfo = ""; + Map lastImpMap = new HashMap(); + if(resource.containsKey(user_id)) { + lastImpMap.put("creater", resource.getString(user_id)); + }else { + lastImpMap.put("creater", "ZX_COMM"); + } +// lastImpMap.put("creater", user_id); + lastImpMap.put("type","ROUTEADD"); + Map plmImpResultMap = doGet(lastImpMap, "PLMImpResult", session); +///* 128 */ if (!addResult.equals("成功")) { +///* 129 */ MessageBox.post(application.getDesktop().getShell(), addResult, "调用erp函数出现错误", 1); +///* 130 */ return null; +// } +///* 132 */ File xmlFile = new File(xmlFilePath); +///* 133 */ if (xmlFile.exists()) { +/* 134 */ Map map = new HashMap(); +/* 135 */ boolean isResultFile = ReadResultXMLStr.loadElements(plmImpResultMap, map); +///* 135 */ boolean isResultFile = true; +/* 136 */ if (isResultFile) { +/* 137 */ String taskSN = ""; +/* 138 */ if (map.get("taskSN") != null && !map.get("taskSN").equals("")) { +/* 139 */ taskSN = map.get("taskSN").toString(); + } else { +/* 141 */ ResultInfo resultInfo = new ResultInfo("新增工艺路线没有发现任务号!", ""); +/* 142 */ return resultInfo; + } +/* 144 */ addDetailInfo.append("任务号:").append(taskSN).append("
"); +/* 145 */ int currentStep = Integer.parseInt(map.get("currentStep").toString()); +/* 146 */ if (currentStep == 3) { +/* 148 */ TCComponent[] forms = UtilApi.query(session, "origin_searchMEProcessRevForm", new String[] { "nhl8_ERPTaskNum" }, new String[] { taskSN }); +if(forms!=null&&forms.length>0) { +/* 149 */ String taskResult = map.get("taskResult").toString(); +/* 150 */ if (taskResult.equals("0")) { +/* 151 */ routeAddInfo = "上次导入任务正在执行或排队,请稍候提交…"; +/* 152 */ } else if (taskResult.equals("1") || taskResult.equals("2")) { +/* 153 */ int formNum = forms.length; +/* 154 */ Object[] obj = new Object[1]; +/* 155 */ obj[0] = Integer.valueOf(11); +/* 156 */ TCUserService service = session.getUserService(); +///* 157 */ for (int i = 0; i < formNum; i++) { +// try { +///* 159 */ service.call("openByPass", obj); +///* 160 */ forms[i].setLogicalProperty("nhl8_ERPimpSucc", true); +///* 161 */ service.call("closeByPass", obj); +///* 162 */ } catch (TCException e) { +///* 163 */ e.printStackTrace(); +// } +// } +/* 166 */ routeAddInfo = "新增工艺路线任务导入成功!"; + } else { +/* 170 */ List listWronglineInfo = (List)map.get("wrongLine"); +/* 171 */ List listWrongProcessItemId = new ArrayList(); +/* 172 */ int listSize = listWronglineInfo.size(); +/* 173 */ for (int i = 0; i < listSize; i++) { +/* 174 */ String wronglineInfo = listWronglineInfo.get(i); +/* 175 */ listWrongProcessItemId.add(wronglineInfo.split(" ")[0] + "GY"); +/* 176 */ addDetailInfo.append(wronglineInfo).append("
"); + } +/* 178 */ int formNum = forms.length; +/* 179 */ Object[] obj = new Object[1]; +/* 180 */ obj[0] = Integer.valueOf(11); +/* 181 */ TCUserService service = session.getUserService(); +/* 182 */ for (int j = 0; j < formNum; j++) { +/* 183 */ String form_of_item_id = ""; + try { +/* 185 */ form_of_item_id = forms[j].getProperty("object_name").split("/")[0]; +/* 186 */ } catch (TCException e1) { +/* 187 */ e1.printStackTrace(); + } +///* 189 */ if (!listWrongProcessItemId.contains(form_of_item_id)) +// try { +///* 191 */ service.call("openByPass", obj); +///* 192 */ forms[j].setLogicalProperty("nhl8_ERPimpSucc", true); +///* 193 */ service.call("closeByPass", obj); +///* 194 */ } catch (TCException e) { +///* 195 */ e.printStackTrace(); +// } + } +/* 199 */ if (taskResult.equals("3")) { +/* 200 */ routeAddInfo = "新增工艺路线任务导入错误,请至ERP修改!"; +/* 201 */ } +// else if (taskResult.equals("4")) { +///* 202 */ routeAddInfo = "新增工艺路线部分数据导入失败,请修正后重新导入!"; +///* 203 */ } else if (taskResult.equals("5")) { +///* 204 */ routeAddInfo = "新增工艺路线任务失败,请修正后重新导入!"; +///* 205 */ } else if (taskResult.equals("6")) { +///* 206 */ routeAddInfo = "新增工艺路线任务导入失败,请修正!"; +// } + } +}else { + MessageBox.post("origin_searchItemRevForm查询器未找到表单属性nhl8_ERPTaskNum值为"+taskSN+"的表单","",MessageBox.INFORMATION); +} + } else { +/* 210 */ routeAddInfo = "上次导入任务正在执行或排队,请稍候提交…"; + } + } else { +/* 213 */ String taskSN = map.get("taskSN").toString(); +/* 214 */ addDetailInfo.append("任务号:").append(taskSN).append("
"); + List routeCheckResults = new ArrayList(); + Map requestMap = new HashMap(); + requestMap.put("sid", taskSN); + requestMap.put("needParameter", "false"); + Map responseMap = doGet(requestMap, "result", session); + JSONObject responseMapJSON = JSONObject.fromObject(responseMap); + JSONArray jsonArray = responseMapJSON.getJSONArray("checkResult"); + routeCheckResults = JSONArray.toList(jsonArray,RouteCheckResult.class); + String errorInfo = ProcessImportReadXMLStr.loadAddElements(routeCheckResults); +///* 215 */ String errorInfo = ProcessImportReadXMLStr.xmlAddElements(session, xmlFile); +///* 215 */ String errorInfo = ""; +/* 216 */ addDetailInfo.append(errorInfo).append("
"); +/* 217 */ routeAddInfo = "新增工艺路线任务导入失败,请修正!"; + } +// } else { +///* 220 */ System.out.println(xmlFile + "文件未找到!"); +// } +/* 223 */ ResultInfo result = new ResultInfo(routeAddInfo, addDetailInfo.toString()); +/* 224 */ return result; + } + + public static ResultInfo getRouteChgResult(AbstractAIFUIApplication application, TCSession session, FileType fileType) { + System.out.println("getRouteChgResult"); +/* 229 */ String user_id = ""; + try { +/* 231 */ user_id = session.getUser().getProperty("user_id"); +/* 232 */ } catch (TCException ex) { +/* 233 */ ex.printStackTrace(); + } +///* 235 */ String tempPath = System.getProperty("java.io.tmpdir") + File.separator; +///* 236 */ String xmlName = tempPath + user_id + "_" + UtilApi.getCurrentTime(); +///* 237 */ String xmlFilePath = xmlName + "_result.xml"; +///* 239 */ String chgResult = UtilApi.getErrorInfoFromCode(PlmErpIntegration.getTaskResult(user_id, fileType.toString(), AimType.chg.toString(), xmlFilePath, session)); +///* 239 */ String chgResult = ""; +///* 240 */ if (chgResult.equals("")) { +///* 241 */ MessageBox.post(application.getDesktop().getShell(), "获取上次导入结果导入超时,请联系管理员!", "超时", 1); +///* 242 */ return null; +// } +/* 244 */ StringBuffer chgDetailInfo = new StringBuffer("变更工艺路线
"); +/* 245 */ String routeChgInfo = ""; + Map lastImpMap = new HashMap(); + if(resource.containsKey(user_id)) { + lastImpMap.put("creater", resource.getString(user_id)); + }else { + lastImpMap.put("creater", "ZX_COMM"); + } +// lastImpMap.put("creater", user_id); + lastImpMap.put("type","ROUTECHG"); + Map plmImpResultMap = doGet(lastImpMap, "PLMImpResult", session); +///* 246 */ if (!chgResult.equals("成功")) { +///* 247 */ MessageBox.post(application.getDesktop().getShell(), chgResult, "调用erp函数出现错误", 1); +///* 248 */ return null; +// } +///* 250 */ File xmlFile = new File(xmlFilePath); +///* 251 */ if (xmlFile.exists()) { +/* 252 */ Map map = new HashMap(); +/* 253 */ boolean isResultFile = ReadResultXMLStr.loadElements(plmImpResultMap, map); +///* 253 */ boolean isResultFile = true; +/* 254 */ if (isResultFile) { +/* 255 */ String taskSN = ""; +/* 256 */ if (map.get("taskSN") != null && !map.get("taskSN").equals("")) { +/* 257 */ taskSN = map.get("taskSN").toString(); + } else { +/* 259 */ ResultInfo resultInfo = new ResultInfo("变更工艺路线没有发现任务号!", ""); +/* 260 */ return resultInfo; + } +/* 262 */ chgDetailInfo.append("任务号:").append(taskSN).append("
"); +/* 263 */ int currentStep = Integer.parseInt(map.get("currentStep").toString()); +/* 264 */ if (currentStep == 3) { +/* 266 */ TCComponent[] forms = UtilApi.query(session, "origin_searchMEProcessRevForm", new String[] { "nhl8_ERPTaskNum" }, new String[] { taskSN }); +if(forms!=null&&forms.length>0) { +/* 267 */ String taskResult = map.get("taskResult").toString(); +/* 268 */ if (taskResult.equals("0")) { +/* 269 */ routeChgInfo = "上次导入任务正在执行或排队,请稍候提交…"; +/* 270 */ } else if (taskResult.equals("1") || taskResult.equals("2")) { +/* 271 */ int formNum = forms.length; +/* 272 */ Object[] obj = new Object[1]; +/* 273 */ obj[0] = Integer.valueOf(11); +/* 274 */ TCUserService service = session.getUserService(); +/* 275 */ for (int i = 0; i < formNum; i++) { +// try { +///* 277 */ service.call("openByPass", obj); +///* 278 */ forms[i].setLogicalProperty("nhl8_ERPimpSucc", true); +///* 279 */ service.call("closeByPass", obj); +///* 280 */ } catch (TCException e) { +///* 281 */ e.printStackTrace(); +// } + } +/* 284 */ routeChgInfo = "变更工艺路线任务导入成功!"; + } else { +/* 288 */ List listWronglineInfo = (List)map.get("wrongLine"); +/* 289 */ List listWrongProcessItemId = new ArrayList(); +/* 290 */ int listSize = listWronglineInfo.size(); +/* 291 */ for (int i = 0; i < listSize; i++) { +/* 292 */ String wronglineInfo = listWronglineInfo.get(i); +/* 293 */ listWrongProcessItemId.add(wronglineInfo.split(" ")[0] + "GY"); +/* 294 */ chgDetailInfo.append(wronglineInfo).append("
"); + } +/* 296 */ int formNum = forms.length; +/* 297 */ Object[] obj = new Object[1]; +/* 298 */ obj[0] = Integer.valueOf(11); +/* 299 */ TCUserService service = session.getUserService(); +/* 300 */ for (int j = 0; j < formNum; j++) { +/* 301 */ String form_of_item_id = ""; + try { +/* 303 */ form_of_item_id = forms[j].getProperty("object_name").split("/")[0]; +/* 304 */ } catch (TCException e1) { +/* 305 */ e1.printStackTrace(); + } +///* 307 */ if (!listWrongProcessItemId.contains(form_of_item_id)) +// try { +///* 309 */ service.call("openByPass", obj); +///* 310 */ forms[j].setLogicalProperty("nhl8_ERPimpSucc", true); +///* 311 */ service.call("closeByPass", obj); +///* 312 */ } catch (TCException e) { +///* 313 */ e.printStackTrace(); +// } + } + } +/* 318 */ if (taskResult.equals("3")) { +/* 319 */ routeChgInfo = "变更工艺路线任务导入错误,请至ERP修改!"; +/* 320 */ } +// else if (taskResult.equals("4")) { +///* 321 */ routeChgInfo = "变更工艺路线部分数据导入失败,请修正后重新导入!"; +///* 322 */ } else if (taskResult.equals("5")) { +///* 323 */ routeChgInfo = "变更工艺路线任务失败,请修正后重新导入!"; +///* 324 */ } else if (taskResult.equals("6")) { +///* 325 */ routeChgInfo = "变更工艺路线任务导入失败,请修正!"; +// } +}else { + MessageBox.post("origin_searchItemRevForm查询器未找到表单属性nhl8_ERPTaskNum值为"+taskSN+"的表单","",MessageBox.INFORMATION); +} + } else { +/* 328 */ routeChgInfo = "上次导入任务正在执行或排队,请稍候提交…"; + } + } else { +/* 331 */ String taskSN = map.get("taskSN").toString(); +/* 332 */ chgDetailInfo.append("任务号:").append(taskSN).append("
"); + List routeCheckResults = new ArrayList(); + Map requestMap = new HashMap(); + requestMap.put("sid", taskSN); + requestMap.put("needParameter", "false"); + Map responseMap = doGet(requestMap, "result", session); + JSONObject responseMapJSON = JSONObject.fromObject(responseMap); + JSONArray jsonArray = responseMapJSON.getJSONArray("checkResult"); + routeCheckResults = JSONArray.toList(jsonArray,RouteCheckResult.class); + String errorInfo = ProcessImportReadXMLStr.loadAddElements(routeCheckResults); +///* 333 */ String errorInfo = ProcessImportReadXMLStr.xmlChgElements(session, xmlFile); +/* 334 */ chgDetailInfo.append(errorInfo); +/* 335 */ routeChgInfo = "变更工艺路线任务导入失败,请修正!"; + } +// } else { +///* 339 */ System.out.println(xmlFile + "文件未找到!"); +// } +/* 342 */ ResultInfo result = new ResultInfo(routeChgInfo, chgDetailInfo.toString()); +/* 343 */ return result; + } + + public static Map doGet(Map map, String svr, TCSession session) { + HashMap preferenceHashMap = TCPreferenceUitl.getPreferenceHashMap(session, TCPreferenceService.TC_preference_site, erpPreference); + String url = preferenceHashMap.get("url"); + String token = preferenceHashMap.get("token"); + JSONObject itemCheckJson = JSONObject.fromObject(map); +// List checkResults =null; + Map resultMap = new HashMap(); + try { + System.out.println("开始发送请求"); + String args = itemCheckJson.toString(); + if(svr.equals("PLMImpResult")) { + token = URLEncoder.encode(token,"UTF-8"); + svr = URLEncoder.encode(svr,"UTF-8"); + args = URLEncoder.encode(args,"UTF-8"); + String param = "usr="+token+"&svr="+svr+"&args="+args; + System.out.println("url=============="+url); + System.out.println("param==========="+param); + String response = HttpUtil.doGet(url+"?"+param); + System.out.println("请求结果================"+response); + + JSONObject jsonObject = JSONObject.fromObject(response); + System.out.println("json格式==============="+jsonObject); + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); + System.out.println("cont==============="+jsonObject2); + + String last_task_sid = jsonObject2.getString("last_task_sid"); + if(last_task_sid.contains("NOTEXIST")) { + System.out.println("位置process"); +// MessageBox.post("不存在上一次导入结果","",MessageBox.INFORMATION); + return null; + }else { + resultMap = (Map)JSONObject.toBean(jsonObject2,Map.class); + } + }else if(svr.equals("result")){ + token = URLEncoder.encode(token,"UTF-8"); + svr = URLEncoder.encode(svr,"UTF-8"); + args = URLEncoder.encode(args,"UTF-8"); + String param = "usr="+token+"&svr="+svr+"&args="+args; + System.out.println("url=============="+url); + System.out.println("param==========="+param); + String response = HttpUtil.doGet(url+"?"+param); + System.out.println("请求结果================"+response); + + JSONObject jsonObject = JSONObject.fromObject(response); + System.out.println("json格式==============="+jsonObject); + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); + System.out.println("cont==============="+jsonObject2); + JSONObject jsonObject3 = jsonObject2.getJSONObject("output"); + + resultMap = (Map)JSONObject.toBean(jsonObject3,Map.class); + } + +// JSONArray checkResult = jsonObject2.getJSONArray("checkResult"); +// canAllImport = jsonObject2.getBoolean("canAllImport"); +// checkResults = JSONArray.toList(checkResult,CheckResult.class); + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return resultMap; + } + + } + diff --git a/src/com/connor/erp/ProcessImport/ProcessImportHandler.java b/src/com/connor/erp/ProcessImport/ProcessImportHandler.java new file mode 100644 index 0000000..2b3987c --- /dev/null +++ b/src/com/connor/erp/ProcessImport/ProcessImportHandler.java @@ -0,0 +1,371 @@ + package com.connor.erp.ProcessImport; + + import com.connor.erp.ProcessImport.ProcessAddTransferToERP.ProcessAddTransferToERPCommand; + import com.connor.erp.ProcessImport.ProcessChgTransferToERP.ProcessChgTransferToERPCommand; + import com.connor.erp.toolkit.AimType; + import com.connor.erp.toolkit.FileType; + import com.teamcenter.rac.aif.AbstractAIFUIApplication; + import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; + import com.teamcenter.rac.aifrcp.AIFUtility; + import com.teamcenter.rac.kernel.TCComponent; + import com.teamcenter.rac.kernel.TCComponentItemRevision; + import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; + import com.teamcenter.rac.kernel.TCComponentSignoff; + import com.teamcenter.rac.kernel.TCComponentTask; + import com.teamcenter.rac.kernel.TCComponentUser; + import com.teamcenter.rac.kernel.TCException; + import com.teamcenter.rac.kernel.TCPreferenceService; + import com.teamcenter.rac.kernel.TCSession; + import com.teamcenter.rac.util.MessageBox; + import java.util.ArrayList; + import java.util.List; + import org.eclipse.core.commands.AbstractHandler; + import org.eclipse.core.commands.ExecutionEvent; + import org.eclipse.core.commands.ExecutionException; + + public class ProcessImportHandler extends AbstractHandler { + private static final String NHL_ROUTEIMPERP_MENUAUTH = "NHL_RouteimpERP_MenuAuth"; + + private static final String NHL_ROUTEIMPERP_PRIVILEGES = "NHL_RouteimpERP_Privileges"; + +/* 52 */ public List listProcessRevisions = new ArrayList(); + +/* 54 */ public StringBuffer detailInfo = new StringBuffer(""); + + public AbstractAIFUIApplication application; + + public TCSession session; + + public boolean isPrivilege = false; + + TCPreferenceService preferenceService; + + TCComponentUser currentUser; + + int targetComLen; + + InterfaceAIFComponent[] targetComponents; + + public AimType aimType; + + public Object execute(ExecutionEvent event) throws ExecutionException { +/* 80 */ return null; + } + + public boolean checkTarget(AimType aimType) { +/* 84 */ this.aimType = aimType; +/* 85 */ this.application = AIFUtility.getCurrentApplication(); +/* 86 */ this.session = (TCSession)this.application.getSession(); +/* 87 */ if (this.application.getTargetComponent() == null || (this.application.getTargetComponents()).length == 0) { +/* 88 */ MessageBox.post(this.application.getDesktop().getShell(), "请您选择流程中的任务或工艺版本对象!", "警告", 4); +/* 89 */ return false; + } +/* 91 */ if (!this.listProcessRevisions.isEmpty()) +/* 92 */ this.listProcessRevisions.clear(); +/* 94 */ if (!this.detailInfo.equals("")) +/* 95 */ this.detailInfo = new StringBuffer(""); +/* 97 */ this.preferenceService = this.session.getPreferenceService(); +/* 98 */ this.targetComponents = this.application.getTargetComponents(); +/* 99 */ InterfaceAIFComponent targetComponent = this.targetComponents[0]; +/* 100 */ this.targetComLen = this.targetComponents.length; +/* 102 */ String[] userNames = this.preferenceService.getStringArray(4, "NHL_RouteimpERP_Privileges"); +/* 103 */ this.currentUser = this.session.getUser(); +/* 104 */ String userID = ""; + try { +/* 106 */ userID = this.currentUser.getProperty("user_id"); +/* 107 */ } catch (TCException e1) { +/* 108 */ e1.printStackTrace(); + } +/* 110 */ if (userNames != null && userNames.length > 0) { +/* 111 */ int nameLen = userNames.length; +/* 112 */ for (int i = 0; i < nameLen; i++) { +/* 113 */ if (userNames[i].trim().equals(userID)) { +/* 114 */ this.isPrivilege = true; + break; + } + } + } else { +/* 119 */ MessageBox.post(this.application.getDesktop().getShell(), "请配置首选项NHL_RouteimpERP_Privileges!!", "警告", 4); +/* 120 */ return false; + } +/* 122 */ if (targetComponent instanceof TCComponentTask) { +/* 123 */ if (this.isPrivilege) { +/* 124 */ for (int i = 0; i < this.targetComLen; i++) { +/* 125 */ if (this.targetComponents[i] instanceof TCComponentTask) { +/* 126 */ TCComponentTask task = (TCComponentTask)this.targetComponents[i]; + try { +/* 128 */ TCComponent[] attachmentComponents = task.getRelatedComponents("root_target_attachments"); +/* 129 */ int attachmentsLen = attachmentComponents.length; +/* 130 */ for (int j = 0; j < attachmentsLen; j++) { +/* 131 */ if (attachmentComponents[j] instanceof TCComponentMEProcessRevision) { +/* 132 */ TCComponentMEProcessRevision processRev = (TCComponentMEProcessRevision)attachmentComponents[j]; +/* 133 */ if (processRev.getTCClass().getSuperClass().toString().equals("NHL8_MeprocessRevision") && !processRev.getType().equals("NHL8_RigOutGXRevision") ) { +/* 134 */ if ((processRev.getReferenceListProperty("release_status_list")).length == 0) +/* 135 */ this.detailInfo.append(processRev + " 对象未发布
"); +/* 137 */ if ((processRev.getRelatedComponents("IMAN_METarget")).length == 0) { + + if(!processRev.getType().equals("NHL8_RigOutGXRevision")) { + this.detailInfo.append(processRev + " 制造目标关系没有关联任何零组件
"); + } + } +/* 138 */ +/* 140 */ if (!this.listProcessRevisions.contains(processRev)) +/* 141 */ this.listProcessRevisions.add(processRev); + } + } + } +/* 146 */ } catch (TCException e) { +/* 147 */ e.printStackTrace(); +/* 148 */ } catch (Exception e) { +/* 149 */ e.printStackTrace(); + } + } else { +/* 152 */ MessageBox.post(this.application.getDesktop().getShell(), "请确认选中的是任务对象!!", "警告", 4); +/* 153 */ return false; + } + } +/* 157 */ } else if (aimType.toString().equals("add")) { +/* 158 */ if (!ProcessImportApi.getTaskRouteAddResult(this.application, this.session, FileType.route, "工艺路线新增结果", this, "task")) +/* 159 */ return false; +/* 161 */ } else if (aimType.toString().equals("chg") && +/* 162 */ !ProcessImportApi.getTaskRouteChgResult(this.application, this.session, FileType.route, "工艺路线变更结果", this, "task")) { +/* 163 */ return false; + } +/* 169 */ } else if (targetComponent instanceof TCComponentMEProcessRevision) { +/* 170 */ TCComponentMEProcessRevision processRev = (TCComponentMEProcessRevision)targetComponent; + try { +/* 172 */ if (processRev.getTCClass().getSuperClass().toString().equals("NHL8_MeprocessRevision") && !processRev.getType().equals("NHL8_RigOutGXRevision")) { +/* 173 */ if (this.isPrivilege) { +/* 174 */ for (int i = 0; i < this.targetComLen; i++) { +/* 175 */ if (this.targetComponents[i] instanceof TCComponentMEProcessRevision) { +/* 176 */ TCComponentMEProcessRevision revision = (TCComponentMEProcessRevision)this.targetComponents[i]; + try { +/* 178 */ if ((revision.getReferenceListProperty("release_status_list")).length == 0) +/* 179 */ this.detailInfo.append(revision + " 对象未发布
"); +/* 181 */ if ((revision.getRelatedComponents("IMAN_METarget")).length == 0) { + if(!processRev.getType().equals("NHL8_RigOutGXRevision")) { + this.detailInfo.append(processRev + " 制造目标关系没有关联任何零组件
"); + } + } +/* 182 */ +/* 184 */ this.listProcessRevisions.add(revision); +/* 185 */ } catch (TCException e) { +/* 186 */ e.printStackTrace(); + } + } else { +/* 189 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中正确的工艺路线版本对象!!", "警告", 4); +/* 190 */ return false; + } + } +/* 194 */ } else if (aimType.toString().equals("add")) { +/* 195 */ if (!ProcessImportApi.getTaskRouteAddResult(this.application, this.session, FileType.route, "工艺路线新增结果", this, "route")) +/* 196 */ return false; +/* 198 */ } else if (aimType.toString().equals("chg") && +/* 199 */ !ProcessImportApi.getTaskRouteChgResult(this.application, this.session, FileType.route, "工艺路线变更结果", this, "route")) { +/* 200 */ return false; + } + } else { +/* 205 */ MessageBox.post(this.application.getDesktop().getShell(), "请您选择流程中的任务或工艺版本对象!!", "警告", 4); +/* 206 */ return false; + } +/* 208 */ } catch (TCException e) { +/* 209 */ e.printStackTrace(); + } + } else { +/* 212 */ MessageBox.post(this.application.getDesktop().getShell(), "请您选择流程中的任务或工艺版本对象!!!", "警告", 4); +/* 213 */ return false; + } +/* 216 */ return true; + } + + public void postDialogForTask(boolean isNeedPost) { +/* 220 */ String[] processAndTaskNames = this.preferenceService.getStringArray(4, "NHL_RouteimpERP_MenuAuth"); +/* 221 */ List listProcessAndTaskNames = new ArrayList(); +/* 222 */ if (processAndTaskNames != null && processAndTaskNames.length > 0) { +/* 223 */ int nameLen = processAndTaskNames.length; +/* 224 */ for (int j = 0; j < nameLen; j++) +/* 225 */ listProcessAndTaskNames.add(processAndTaskNames[j].trim().replace(":", ":")); + } else { +/* 228 */ MessageBox.post(this.application.getDesktop().getShell(), "请配置首选项NHL_RouteimpERP_MenuAuth!!", "警告", 4); + return; + } +/* 232 */ for (int i = 0; i < this.targetComLen; i++) { +/* 233 */ if (this.targetComponents[i] instanceof TCComponentTask) { +/* 234 */ TCComponentTask task = (TCComponentTask)this.targetComponents[i]; +/* 235 */ String taskType = task.getType(); +/* 236 */ String processAndTaskName = ""; +/* 237 */ boolean isTaskPerformer = false; + try { +/* 239 */ if (taskType.equals("EPMPerformSignoffTask")) { +/* 240 */ processAndTaskName = task.getRoot().getProcessDefinition().getName() + ":" + task.getParent().getName(); +/* 241 */ TCComponentSignoff[] signoffs = task.getPredecessors()[0].getValidSignoffs(); +/* 242 */ int signoffNum = signoffs.length; +/* 243 */ for (int j = 0; j < signoffNum; j++) { +/* 244 */ if (signoffs[j].getGroupMember().getUser().equals(this.currentUser)) { +/* 245 */ isTaskPerformer = true; + break; + } + } + } +/* 250 */ if (listProcessAndTaskNames.contains(processAndTaskName) && isTaskPerformer) { +/* 251 */ TCComponent[] attachmentComponents = task.getRelatedComponents("root_target_attachments"); +/* 252 */ int attachmentsLen = attachmentComponents.length; +/* 253 */ for (int j = 0; j < attachmentsLen; j++) { +/* 254 */ if (attachmentComponents[j] instanceof TCComponentMEProcessRevision) { +/* 255 */ TCComponentMEProcessRevision processRev = (TCComponentMEProcessRevision)attachmentComponents[j]; +/* 256 */ if (processRev.getTCClass().getSuperClass().toString().equals("NHL8_MeprocessRevision")) { +/* 257 */ if ((processRev.getReferenceListProperty("release_status_list")).length == 0) { +/* 258 */ MessageBox.post(processRev + " 对象未发布", "警告", 4); + return; + } +/* 261 */ if ((processRev.getRelatedComponents("IMAN_METarget")).length == 0) { + + if(!processRev.getType().equals("NHL8_RigOutGXRevision")) { + MessageBox.post(processRev + "制造目标关系没有关联任何零组件!", "提示", 4); +// this.detailInfo.append(processRev + " 制造目标关系没有关联任何零组件
"); + } +/* 262 */ + return; + } +/* 266 */ if (!this.listProcessRevisions.contains(processRev)) +/* 267 */ this.listProcessRevisions.add(processRev); + } + } + } + } else { +/* 273 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中有权限的任务对象!!", "警告", 4); + return; + } +/* 276 */ } catch (TCException e) { +/* 277 */ e.printStackTrace(); +/* 278 */ } catch (Exception e) { +/* 279 */ e.printStackTrace(); + } + } else { +/* 282 */ MessageBox.post(this.application.getDesktop().getShell(), "请确认选中的是任务对象!!", "警告", 4); + return; + } + } +/* 286 */ if (isNeedPost && +/* 287 */ this.listProcessRevisions.size() > 0) +/* 288 */ if (this.aimType.toString().equals("add")) { + try { +/* 290 */ ProcessAddTransferToERPCommand processAddTransferToERPCommand = new ProcessAddTransferToERPCommand(this.session, this.application, this.listProcessRevisions, this.detailInfo, this.isPrivilege); +/* 291 */ processAddTransferToERPCommand.executeModal(); +/* 292 */ } catch (Exception e) { +/* 293 */ e.printStackTrace(); + } +/* 295 */ } else if (this.aimType.toString().equals("chg")) { + try { +/* 297 */ ProcessChgTransferToERPCommand processChgTransferToERPCommand = new ProcessChgTransferToERPCommand(this.session, this.application, this.listProcessRevisions, this.detailInfo, this.isPrivilege); +/* 298 */ processChgTransferToERPCommand.executeModal(); +/* 299 */ } catch (Exception e) { +/* 300 */ e.printStackTrace(); + } + } + } + + public void postDialogForRoute(boolean isNeedPost) { +/* 308 */ String[] processAndTaskNames = this.preferenceService.getStringArray(4, "NHL_RouteimpERP_MenuAuth"); +/* 309 */ List listProcessAndTaskNames = new ArrayList(); +/* 310 */ if (processAndTaskNames != null && processAndTaskNames.length > 0) { +/* 311 */ int nameLen = processAndTaskNames.length; +/* 312 */ for (int j = 0; j < nameLen; j++) +/* 313 */ listProcessAndTaskNames.add(processAndTaskNames[j].trim().replace(":", ":")); + } else { +/* 316 */ MessageBox.post(this.application.getDesktop().getShell(), "请配置首选项NHL_RouteimpERP_MenuAuth!!", "警告", 4); + return; + } +/* 319 */ for (int i = 0; i < this.targetComLen; i++) { +/* 320 */ if (this.targetComponents[i] instanceof TCComponentMEProcessRevision) { +/* 321 */ TCComponentMEProcessRevision revision = (TCComponentMEProcessRevision)this.targetComponents[i]; +/* 322 */ if (!revRefRightProcess((TCComponentItemRevision)revision, listProcessAndTaskNames, this.currentUser)) + return; + try { +/* 326 */ if ((revision.getRelatedComponents("IMAN_METarget")).length == 0 && !revision.getType().equals("NHL8_RigOutGXRevision")) { +/* 327 */ MessageBox.post(this.application.getDesktop().getShell(), revision + " 制造目标关系没有关联任何零组件!!", "警告", 4); + return; + } +/* 330 */ this.listProcessRevisions.add(revision); +/* 331 */ } catch (TCException e) { +/* 332 */ e.printStackTrace(); + } + } else { +/* 335 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中正确的工艺路线版本对象!!", "警告", 4); + return; + } + } +/* 339 */ if (isNeedPost && +/* 340 */ this.listProcessRevisions.size() > 0) +/* 341 */ if (this.aimType.toString().equals("add")) { + try { +/* 343 */ ProcessAddTransferToERPCommand processAddTransferToERPCommand = new ProcessAddTransferToERPCommand(this.session, this.application, this.listProcessRevisions, this.detailInfo, this.isPrivilege); +/* 344 */ processAddTransferToERPCommand.executeModal(); +/* 345 */ } catch (Exception e) { +/* 346 */ e.printStackTrace(); + } +/* 348 */ } else if (this.aimType.toString().equals("chg")) { + try { +/* 350 */ ProcessChgTransferToERPCommand processChgTransferToERPCommand = new ProcessChgTransferToERPCommand(this.session, this.application, this.listProcessRevisions, this.detailInfo, this.isPrivilege); +/* 351 */ processChgTransferToERPCommand.executeModal(); +/* 352 */ } catch (Exception e) { +/* 353 */ e.printStackTrace(); + } + } + } + + private boolean revRefRightProcess(TCComponentItemRevision revision, List listProcessAndTaskNames, TCComponentUser currentUser) { + try { +/* 369 */ if ((revision.getReferenceListProperty("release_status_list")).length == 0) { +/* 370 */ MessageBox.post(this.application.getDesktop().getShell(), revision + " 对象未发布!!", "警告", 4); +/* 371 */ return false; + } +/* 373 */ TCComponent[] processStageList = revision.getReferenceListProperty("fnd0StartedWorkflowTasks"); +/* 374 */ int listSize = processStageList.length; +/* 375 */ TCComponentTask referenceTask = null; +/* 376 */ if (listSize > 0) { +/* 377 */ String rootTaskName = processStageList[0].getProperty("object_name"); +/* 378 */ for (int j = 1; j < listSize; j++) { +/* 379 */ if (listProcessAndTaskNames.contains(rootTaskName + ":" + processStageList[j].getProperty("object_name"))) { +/* 380 */ referenceTask = (TCComponentTask)processStageList[j]; + break; + } + } +/* 384 */ if (referenceTask != null) { +/* 385 */ TCComponentTask[] subTasks = referenceTask.getSubtasks(); +/* 386 */ int subTaskNum = subTasks.length; +/* 387 */ boolean isTaskPerformer = false; +/* 388 */ for (int i = 0; i < subTaskNum; i++) { +/* 389 */ TCComponentTask subTask = subTasks[i]; +/* 390 */ String taskType = subTask.getType(); +/* 391 */ if (taskType.equals("EPMPerformSignoffTask")) { +/* 392 */ TCComponentSignoff[] signoffs = subTask.getPredecessors()[0].getValidSignoffs(); +/* 393 */ int signoffNum = signoffs.length; +/* 394 */ for (int k = 0; k < signoffNum; k++) { +/* 395 */ if (signoffs[k].getGroupMember().getUser().equals(currentUser)) { +/* 396 */ isTaskPerformer = true; + break; + } + } + break; + } + } +/* 403 */ if (!isTaskPerformer) { +/* 404 */ MessageBox.post(this.application.getDesktop().getShell(), "请确定对Item版本对象的操作权限!!", "警告", 4); +/* 405 */ return false; + } + } else { +/* 408 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中在正确流程节点中的Item版本对象!!", "警告", 4); +/* 409 */ return false; + } + } else { +/* 412 */ MessageBox.post(this.application.getDesktop().getShell(), "请选中在流程中的Item版本对象!!", "警告", 4); +/* 413 */ return false; + } +/* 416 */ } catch (TCException e) { +/* 417 */ e.printStackTrace(); + } +/* 419 */ return true; + } + } + diff --git a/src/com/connor/erp/ProcessImport/ProcessImportReadXMLStr.java b/src/com/connor/erp/ProcessImport/ProcessImportReadXMLStr.java new file mode 100644 index 0000000..3e1fa3e --- /dev/null +++ b/src/com/connor/erp/ProcessImport/ProcessImportReadXMLStr.java @@ -0,0 +1,450 @@ + package com.connor.erp.ProcessImport; + + import com.connor.erp.ProcessImport.ProcessAddTransferToERP.RootCheckResult; +import com.connor.erp.ProcessImport.ProcessAddTransferToERP.RouteLineCheck; +import com.connor.erpintegration.entity.BOMLineEntity; +import com.connor.erpintegration.entity.BomCheckResult; +import com.connor.erpintegration.entity.RouteCheckResult; +import com.connor.erpintegration.entity.RouteLineEntity; +import com.teamcenter.rac.kernel.TCSession; + +import net.sf.json.JSONObject; + +import java.io.File; + import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.jdom.Attribute; + import org.jdom.Document; + import org.jdom.Element; + import org.jdom.JDOMException; + import org.jdom.input.SAXBuilder; + + public class ProcessImportReadXMLStr { +// public static String xmlAddElements(File xmlFilePath, StringBuffer errorInfo) { +///* 41 */ SAXBuilder sb = new SAXBuilder(); +///* 42 */ Element root = null; +// try { +///* 45 */ Document doc = sb.build(xmlFilePath); +///* 47 */ root = doc.getRootElement(); +///* 48 */ if (root.getAttribute("hasWrong").getValue().equals("false")) +///* 49 */ return "成功"; +///* 51 */ } catch (JDOMException e) { +///* 52 */ e.printStackTrace(); +///* 53 */ } catch (IOException e) { +///* 54 */ e.printStackTrace(); +// } +///* 56 */ return loadAddElements(root.getChildren(), errorInfo); +// } + + public static String xmlAddElements(TCSession session, File xmlFilePath) { +/* 60 */ StringBuffer errorInfo = new StringBuffer(""); +/* 62 */ SAXBuilder sb = new SAXBuilder(); + try { +/* 65 */ Document doc = sb.build(xmlFilePath); +/* 67 */ Element root = doc.getRootElement(); +///* 68 */ loadAddElements(root.getChildren(), errorInfo); +/* 69 */ } catch (JDOMException e) { +/* 70 */ e.printStackTrace(); +/* 71 */ } catch (IOException e) { +/* 72 */ e.printStackTrace(); + } +/* 74 */ return errorInfo.toString(); + } + +// public static String xmlChgElements(File xmlFilePath, List listAll, List listAllAssAndOper, List listOld, List listOldAssAndOper) { +///* 78 */ StringBuffer errorInfo = new StringBuffer(""); +///* 81 */ SAXBuilder sb = new SAXBuilder(); +// try { +///* 84 */ Document doc = sb.build(xmlFilePath); +///* 86 */ Element root = doc.getRootElement(); +///* 87 */ loadChgElements(root.getChildren(), errorInfo, listAll, listAllAssAndOper, listOld, listOldAssAndOper); +///* 88 */ } catch (JDOMException e) { +///* 89 */ e.printStackTrace(); +///* 90 */ } catch (IOException e) { +///* 91 */ e.printStackTrace(); +// } +///* 93 */ return errorInfo.toString(); +// } + + public static String xmlChgElements(TCSession session, File xmlFilePath) { +/* 97 */ StringBuffer errorInfo = new StringBuffer(""); +/* 100 */ SAXBuilder sb = new SAXBuilder(); + try { +/* 103 */ Document doc = sb.build(xmlFilePath); +/* 105 */ Element root = doc.getRootElement(); +///* 106 */ loadChgElements(root.getChildren(), errorInfo); +/* 107 */ } catch (JDOMException e) { +/* 108 */ e.printStackTrace(); +/* 109 */ } catch (IOException e) { +/* 110 */ e.printStackTrace(); + } +/* 112 */ return errorInfo.toString(); + } + + public static String loadAddElements(List list) { +/* 116 */ int listSize = list.size(); +/* 117 */ if (listSize == 0) +/* 118 */ return ""; + StringBuffer errorInfo = new StringBuffer(""); +/* 120 */ int routeExistNum = 0; +/* 121 */ for (int i = 0; i < listSize; i++) { +/* 122 */ RootCheckResult routeCheckResult =(RootCheckResult) list.get(i); +//List routeLine = routeCheckResult.getRouteLine(); + +// Map classMap = new HashMap(); +// classMap.put("RouteLine", RouteLineCheck.class); +// RootCheckResult r =(RootCheckResult)JSONObject.toBean(JSONObject.fromObject(routeCheckResult),RootCheckResult.class,classMap); +// if(r.getCanRouteImport().equals("true"))return "成功"; +///* 123 */ List listRouteInfoChild = routeInfo_et.getChildren(); +///* 124 */ int listRouteInfoChildSize = listRouteInfoChild.size(); +/* 125 */ String item_number_et = ""; +/* 126 */ List processes_et = routeCheckResult.getRouteLine(); +System.out.println(routeCheckResult.getAssembly_item()); +/* 131 */ item_number_et = routeCheckResult.getAssembly_item(); +///* 132 */ } else if (etName.equals("processes")) { +/* 133 */ processes_et = routeCheckResult.getRouteLine(); +// } +// } +/* 136 */ boolean isContinue = false; +/* 137 */ String item_number = ""; +/* 138 */ if (item_number_et != null&&item_number_et.length()>0) { +/* 139 */ item_number = item_number_et; +///* 140 */ List attrList = item_number_et.getAttributes(); +///* 141 */ int attrNum = attrList.size(); +/* 142 */ boolean isExist = false; +/* 143 */ boolean isRouteExist = false; +///* 144 */ for (int m = 0; m < attrNum; m++) { +///* 145 */ Attribute attr = item_number_et.getAttributes().get(m); +///* 146 */ String attr_name = attr.getName(); +///* 147 */ String attr_value = attr.getValue(); + if(routeCheckResult.getAssembly_item_exist().equals("true")) + isExist = true; + if(routeCheckResult.getRoute_exist().equals("true")) { + routeExistNum++; + isRouteExist = true; + } +/* 159 */ if (isExist) { +/* 160 */ if (isRouteExist) { +/* 161 */ errorInfo.append(String.valueOf(item_number) + "装配件的工艺路线已经存在
"); + } else { +/* 163 */ isContinue = true; + } + } else { +/* 166 */ errorInfo.append(String.valueOf(item_number) + " 装配件不存在或已失效
"); + } + } +/* 169 */ if (isContinue) { +/* 170 */ StringBuffer errorInfo2 = new StringBuffer(String.valueOf(item_number) + " 装配件已经存在,但"); +///* 171 */ List listProcessesChild = processes_et.getChildren(); +///* 172 */ int listSize2 = listProcessesChild.size(); +/* 173 */ for (int k = 0; k < processes_et.size(); k++) { +/* 174 */ RouteLineCheck process_et = processes_et.get(k); + + +///* 175 */ Element department_code_et = process_et.getChild("department_code"); +///* 176 */ List listDepartmentAttr = department_code_et.getAttributes(); +///* 177 */ if (listDepartmentAttr != null && listDepartmentAttr.size() > 0) { +/* 178 */ String isExist_at = process_et.getDepartment_exist(); +/* 179 */ if (isExist_at.equals("false")) +/* 180 */ errorInfo2.append(process_et.getDepartment_code()).append(","); +// } + } +/* 184 */ if (!errorInfo2.toString().endsWith(",但")) { +/* 185 */ String errorInfoStr = errorInfo2.toString(); +/* 186 */ errorInfo2 = errorInfo2.replace(errorInfoStr.length() - 1, errorInfoStr.length(), ""); +/* 187 */ errorInfo2.append(" 部门不存在
"); +/* 188 */ errorInfo.append(errorInfo2.toString()); + } + } + } +System.out.println(listSize+"listSize"+routeExistNum); +/* 192 */ if (routeExistNum == listSize) +/* 193 */ return "所有的工艺路线都已经存在"; +/* 195 */ return errorInfo.toString(); + } + + public static void loadChgElements(List list, StringBuffer errorInfo, List listAll, List listAllAssAndOper, List listOld, List listOldAssAndOper) { +/* 199 */ int listSize = list.size(); +/* 200 */ if (listSize == 0) + return; +int routeExistNum = 0; +/* 203 */ for (int i = 0; i < listSize; i++) { +/* 204 */ RouteCheckResult routeInfo_et = (RouteCheckResult)list.get(i); +///* 205 */ List listRouteInfoChild = routeInfo_et.getChildren(); +///* 206 */ int listRouteInfoChildSize = listRouteInfoChild.size(); +///* 207 */ Element item_number_et = null; +///* 208 */ Element processes_et = null; +///* 210 */ for (int j = 0; j < listRouteInfoChildSize; j++) { +///* 211 */ Element childEt = (Element)listRouteInfoChild.get(j); +///* 212 */ String etName = childEt.getName(); +///* 213 */ if (etName.equals("assembly_item_number")) { +///* 214 */ item_number_et = childEt; +///* 215 */ } else if (etName.equals("processes")) { +///* 216 */ processes_et = childEt; +// } +// } +/* 219 */ boolean isContinue = false; +/* 220 */ String item_number = ""; +/* 221 */ if (routeInfo_et != null) { +/* 225 */ boolean isExist = false; +/* 226 */ boolean isRouteExist = false; + item_number=routeInfo_et.getAssembly_item(); +/* 227 */ if(routeInfo_et.getAssembly_item_exist().equals("true")) + isExist = true; + if(routeInfo_et.getRoute_exist().equals("true")) { + routeExistNum++; + isRouteExist = true; + } +/* 241 */ if (isExist) { +/* 242 */ if (isRouteExist) { +/* 243 */ isContinue = true; + } else { +/* 245 */ errorInfo.append(String.valueOf(item_number) + " 装配件存在,但工艺路线不存在
"); + } + } else { +/* 248 */ errorInfo.append(String.valueOf(item_number) + " 装配件不存在或已失效
"); + } + } +/* 251 */ if (isContinue) { +/* 252 */ StringBuffer errorInfo2 = (new StringBuffer(item_number)).append(" 装配件已经存在,但"); +///* 253 */ List processesChildList = processes_et.getChildren(); +///* 254 */ int processesChildNum = processesChildList.size(); +/* 255 */ int operationNum = 0; + List routeLine = routeInfo_et.getRouteLine(); +/* 256 */ for (int k = 0; k < routeLine.size(); k++) { +/* 257 */ StringBuffer allAssAndOperStr = new StringBuffer(""); +/* 258 */ StringBuffer oldAssAndOperStr = new StringBuffer(""); +/* 259 */ String[] oldStr = new String[6]; +/* 260 */ String[] allStr = new String[6]; +/* 261 */ allAssAndOperStr.append(item_number).append(","); +/* 262 */ oldAssAndOperStr.append(item_number).append(","); +/* 263 */ oldStr[0] = item_number; +/* 264 */ allStr[0] = item_number; +/* 265 */ RouteLineEntity process_et = (RouteLineEntity)routeLine.get(k); +///* 266 */ List processChildList = process_et.getChildren(); +///* 267 */ int processChildNum = processChildList.size(); +/* 268 */ boolean isDepartmentExist = false; +/* 269 */ boolean isOperationExist = false; +/* 270 */ String departmentValue = ""; + + String operation_seq_num = process_et.getOperation_seq_num(); + String seq_num_exist = process_et.getSeq_num_exist(); + if(seq_num_exist!=null && seq_num_exist.equals("true")) { + isOperationExist = true; + oldStr[1] = operation_seq_num; + oldAssAndOperStr.append(operation_seq_num); + }else if(seq_num_exist ==null || seq_num_exist.equals("")){ + isOperationExist = true; + oldStr[1] = operation_seq_num; + oldAssAndOperStr.append(operation_seq_num); + }else { + oldStr[1] = ""; + } + allStr[1] = operation_seq_num; + allAssAndOperStr.append(operation_seq_num); + String department_code_exist = process_et.getDepartment_code_exist(); + if(department_code_exist!=null && department_code_exist.equals("true")) { + isDepartmentExist = true; + }else if (department_code_exist==null || department_code_exist.equals("")) { + isDepartmentExist = true; + }else { + departmentValue=process_et.getDepartment_code_erp();//20231018改动 + } + String department_code = process_et.getDepartment_code_erp();//20231018改动 + oldStr[3] = department_code; + allStr[3] = department_code; + String operation_description = process_et.getOperation_description(); + oldStr[2] = operation_description; + allStr[2] = operation_description; + + String usage_rate_or_amount = process_et.getUsage_rate_or_amount(); + oldStr[4] = usage_rate_or_amount; + allStr[4] = usage_rate_or_amount; + String usage_rate_or_amount_auxiliary = process_et.getUsage_rate_or_amount_auxiliary(); + oldStr[5] = usage_rate_or_amount_auxiliary; + allStr[5] = usage_rate_or_amount_auxiliary; + +///* 272 */ Element child_et = (Element)processChildList.get(n); +///* 273 */ String et_name = child_et.getName(); +///* 274 */ String et_value = child_et.getValue(); +///* 275 */ if (et_name.equals("operation_seq_num")) { +// +// } else if (et_name.equals("department_code_new")) { +///* 308 */ } else if (et_name.equals("department_code")) { +///* 309 */ oldStr[3] = et_value; +///* 310 */ allStr[3] = et_value; +///* 311 */ } else if (et_name.equals("operation_description")) { +///* 312 */ oldStr[2] = et_value; +///* 313 */ allStr[2] = et_value; +///* 314 */ } else if (et_name.equals("usage_rate_or_amount")) { +// } else if (et_name.equals("usage_rate_or_amount_auxiliary")) { +///* 323 */ if (et_value.trim().equals("")) { +///* 324 */ oldStr[5] = "0"; +///* 325 */ allStr[5] = "0"; +// } else { +///* 327 */ oldStr[5] = et_value; +///* 328 */ allStr[5] = et_value; +// } +// } + + System.out.println("isDepartmentExist"+isDepartmentExist); +/* 332 */ if (!isDepartmentExist) { +/* 333 */ errorInfo2.append(departmentValue).append(","); +/* 335 */ } else if (isOperationExist) { +/* 336 */ operationNum++; + } +/* 339 */ listAllAssAndOper.add(allAssAndOperStr.toString()); +/* 340 */ StringBuffer allStrBuf = new StringBuffer(""); +/* 341 */ for (int m = 0; m < 6; m++) { +/* 342 */ if (m == 5) { +/* 343 */ allStrBuf.append(allStr[m]); + break; + } +/* 346 */ allStrBuf.append(allStr[m]).append(","); + } +/* 348 */ listAll.add(allStrBuf.toString()); +System.out.println(allStrBuf.toString()); +System.out.println(oldStr[0]); +System.out.println(oldAssAndOperStr.toString()); +/* 349 */ if (!oldStr[1].equals("")) { +/* 350 */ listOld.add(oldStr); +/* 351 */ listOldAssAndOper.add(oldAssAndOperStr.toString()); + } + } +/* 354 */ if (!errorInfo2.toString().endsWith(",但")) { +/* 355 */ String errorInfoStr = errorInfo2.toString(); +/* 356 */ errorInfo2 = errorInfo2.replace(errorInfoStr.length() - 1, errorInfoStr.length(), ""); +/* 357 */ errorInfo2.append(" 部门不存在
"); +/* 358 */ errorInfo.append(errorInfo2.toString()); +/* 360 */ } else if (operationNum == 0) { +/* 361 */ errorInfo.append((new StringBuffer(String.valueOf(item_number) + " 装配件和部门已经存在,但工序号都不存在
")).toString()); + } + } + } + } + + public static String loadChgElements(List list) { +/* 370 */ int listSize = list.size(); +/* 371 */ if (listSize == 0) + return ""; + StringBuffer errorInfo = new StringBuffer(""); +/* 374 */ for (int i = 0; i < listSize; i++) { +/* 375 */ RouteCheckResult routeCheckResult = list.get(i); + Map classMap = new HashMap(); + classMap.put("RouteLine", RouteLineEntity.class); + RouteCheckResult r =(RouteCheckResult)JSONObject.toBean(JSONObject.fromObject(routeCheckResult),RouteCheckResult.class,classMap); +///* 376 */ List listRouteInfoChild = routeInfo_et.getChildren(); +///* 377 */ int listRouteInfoChildSize = listRouteInfoChild.size(); +/* 378 */ String item_number_et = null; +/* 379 */ List processes_et = null; +///* 381 */ for (int j = 0; j < listRouteInfoChildSize; j++) { +///* 382 */ Element childEt = (Element)listRouteInfoChild.get(j); +///* 383 */ String etName = childEt.getName(); +///* 384 */ if (etName.equals("assembly_item_number")) { +/* 385 */ item_number_et = r.getAssembly_item(); +///* 386 */ } else if (etName.equals("processes")) { +/* 387 */ processes_et = r.getRouteLine(); +// } +// } +/* 390 */ boolean isContinue = false; +/* 391 */ String item_number = ""; +/* 392 */ if (item_number_et != null&&item_number_et.length()>0) { +/* 393 */ item_number = item_number_et; +///* 394 */ List attrList = item_number_et.getAttributes(); +///* 395 */ int attrNum = attrList.size(); +/* 396 */ boolean isExist = false; +/* 397 */ boolean isRouteExist = false; + if(r.getAssembly_item_exist().equals("true")) + isExist = true; + else if(r.getRoute_exist().equals("true")) { + isRouteExist = true; + } +///* 398 */ for (int m = 0; m < attrNum; m++) { +///* 399 */ Attribute attr = item_number_et.getAttributes().get(m); +/////* 400 */ String attr_name = attr.getName(); +///* 401 */ String attr_value = attr.getValue(); +///* 402 */ if (attr_name.equals("isExist")) { +///* 403 */ if (attr_value.equals("true")) +///* 404 */ isExist = true; +///* 406 */ } else if (attr_name.equals("isROUTEExist") && +///* 407 */ attr_value.equals("true")) { +///* 408 */ isRouteExist = true; +// } +// } +/* 412 */ if (isExist) { +/* 413 */ if (isRouteExist) { +/* 414 */ isContinue = true; + } else { +/* 416 */ errorInfo.append(String.valueOf(item_number) + " 装配件存在,但工艺路线不存在
"); + } + } else { +/* 419 */ errorInfo.append(String.valueOf(item_number) + " 装配件不存在或已失效
"); + } + } +/* 422 */ if (isContinue) { +/* 423 */ StringBuffer errorInfo2 = (new StringBuffer(item_number)).append(" 装配件已经存在,但"); +///* 424 */ List processesChildList = processes_et.getChildren(); +///* 425 */ int processesChildNum = processesChildList.size(); +/* 426 */ int operationNum = 0; +/* 427 */ for (int k = 0; k < processes_et.size(); k++) { +/* 428 */ RouteLineEntity process_et = processes_et.get(k); +///* 429 */ List processChildList = process_et.getChildren(); +///* 430 */ int processChildNum = processChildList.size(); +/* 431 */ boolean isDepartmentExist = false; +/* 432 */ boolean isOperationExist = false; +/* 433 */ String departmentValue = process_et.getDepartment_code(); +///* 434 */ for (int m = 0; m < processChildNum; m++) { +///* 435 */ Element child_et = (Element)processChildList.get(m); +///* 436 */ String et_name = child_et.getName(); +///* 437 */ String et_value = child_et.getValue(); +///* 438 */ if (et_name.equals("operation_seq_num")) { +///* 439 */ List arrList = child_et.getAttributes(); +///* 440 */ if (arrList != null && arrList.size() > 0) { +///* 441 */ Attribute isExist_at = child_et.getAttributes().get(0); +///* 442 */ if (isExist_at.getValue().equals("true")) +///* 443 */ isOperationExist = true; +// } else { + if("true".equals(process_et.getSeq_num_exist())) +/* 446 */ isOperationExist = true; +// } +///* 448 */ } +//else if (et_name.equals("department_code_new")) { +///* 449 */ if (!et_value.equals("")) { +///* 450 */ departmentValue = et_value; +///* 451 */ List arrList = child_et.getAttributes(); +///* 452 */ if (arrList != null && arrList.size() > 0) { +///* 453 */ Attribute isExist_at = child_et.getAttributes().get(0); +///* 454 */ if (isExist_at.getValue().equals("true")) +///* 455 */ isDepartmentExist = true; +// } else { +///* 458 */ isDepartmentExist = true; +// } +// } else { + if("true".equals(process_et.getDepartment_code_exist())) +/* 461 */ isDepartmentExist = true; +// } +// } +// } +/* 465 */ if (!isDepartmentExist) { +/* 466 */ errorInfo2.append(departmentValue).append(","); +/* 468 */ } else if (isOperationExist) { +/* 469 */ operationNum++; + } + } +/* 473 */ if (!errorInfo2.toString().endsWith(",但")) { +/* 474 */ String errorInfoStr = errorInfo2.toString(); +/* 475 */ errorInfo2 = errorInfo2.replace(errorInfoStr.length() - 1, errorInfoStr.length(), ""); +/* 476 */ errorInfo2.append(" 部门不存在
"); +/* 477 */ errorInfo.append(errorInfo2.toString()); +/* 479 */ } else if (operationNum == 0) { +/* 480 */ errorInfo.append((new StringBuffer(String.valueOf(item_number) + " 装配件和部门已经存在,但工序号都不存在
")).toString()); + } + } + } + return errorInfo.toString(); + } + } + diff --git a/src/com/connor/erp/ProcessImport/TransferRouteXMLWriter.java b/src/com/connor/erp/ProcessImport/TransferRouteXMLWriter.java new file mode 100644 index 0000000..a4bf8ef --- /dev/null +++ b/src/com/connor/erp/ProcessImport/TransferRouteXMLWriter.java @@ -0,0 +1,124 @@ +/* */ package com.connor.erp.ProcessImport; +/* */ +/* */ import com.connor.erp.toolkit.ActionType; +/* */ import com.connor.erp.toolkit.AimType; +/* */ import com.connor.erp.toolkit.FileType; +/* */ import com.connor.erp.toolkit.UtilApi; +/* */ import java.io.FileNotFoundException; +/* */ import java.io.FileOutputStream; +/* */ import java.io.PrintWriter; +/* */ import java.util.Iterator; +/* */ import java.util.List; +/* */ import java.util.Map; +/* */ import javax.xml.parsers.DocumentBuilder; +/* */ import javax.xml.parsers.DocumentBuilderFactory; +/* */ import javax.xml.parsers.ParserConfigurationException; +/* */ import javax.xml.transform.Transformer; +/* */ import javax.xml.transform.TransformerException; +/* */ import javax.xml.transform.TransformerFactory; +/* */ import javax.xml.transform.dom.DOMSource; +/* */ import javax.xml.transform.stream.StreamResult; +/* */ import org.w3c.dom.Document; +/* */ import org.w3c.dom.Element; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class TransferRouteXMLWriter +/* */ { +/* */ public static void createXML(String user_id, String file, ActionType actionType, FileType fileType, AimType aimType, Map> map) throws ParserConfigurationException, FileNotFoundException, TransformerException { +/* 42 */ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); +/* 43 */ DocumentBuilder db = dbf.newDocumentBuilder(); +/* 44 */ Document doc = db.newDocument(); +/* */ +/* 46 */ Element root = doc.createElement("ERPFramework"); +/* 47 */ root.setAttribute("userId", user_id); +/* 48 */ root.setAttribute("time", UtilApi.getCurrentTime()); +/* 49 */ root.setAttribute("actionType", actionType.toString()); +/* 50 */ root.setAttribute("fileType", fileType.toString()); +/* 51 */ root.setAttribute("aimType", aimType.toString()); +/* 52 */ doc.appendChild(root); +/* */ +/* 54 */ Iterator iterator = map.keySet().iterator(); +/* */ +/* 56 */ while (iterator.hasNext()) { +/* 57 */ String item_number = iterator.next(); +/* */ +/* 59 */ Element routeInfo = doc.createElement("RouteInfo"); +/* */ +/* 61 */ Element assembly_item_number = doc.createElement("assembly_item_number"); +/* */ +/* 63 */ assembly_item_number.setTextContent(item_number); +/* */ +/* 65 */ Element processes = doc.createElement("processes"); +/* */ +/* 67 */ List list = map.get(item_number); +/* 68 */ int listSize = list.size(); +/* 69 */ for (int i = 0; i < listSize; i++) { +/* 70 */ String[] arrStr = list.get(i); +/* 71 */ String operation_seq_num_str = arrStr[0]; +/* 72 */ String department_code_str = arrStr[1]; +/* 73 */ String operation_description_str = arrStr[2]; +/* 74 */ String usage_rate_or_amount_str = arrStr[3]; +/* 75 */ String usage_rate_or_amount_auxiliary_str = arrStr[4]; +/* */ +/* 77 */ Element process = doc.createElement("process"); +/* 78 */ Element operation_seq_num = doc.createElement("operation_seq_num"); +/* 79 */ Element department_code_new = doc.createElement("department_code_new"); +/* 80 */ if (aimType.equals(AimType.chg)) { +/* 81 */ department_code_new = doc.createElement("department_code_new"); +/* */ } else { +/* 83 */ department_code_new = doc.createElement("department_code"); +/* */ } +/* 85 */ Element operation_description = doc.createElement("operation_description"); +/* 86 */ Element usage_rate_or_amount = doc.createElement("usage_rate_or_amount"); +/* 87 */ Element usage_rate_or_amount_auxiliary = doc.createElement("usage_rate_or_amount_auxiliary"); +/* */ +/* 89 */ operation_seq_num.setTextContent(operation_seq_num_str); +/* 90 */ department_code_new.setTextContent(department_code_str); +/* 91 */ operation_description.setTextContent(operation_description_str); +/* 92 */ usage_rate_or_amount.setTextContent(usage_rate_or_amount_str); +/* 93 */ usage_rate_or_amount_auxiliary.setTextContent(usage_rate_or_amount_auxiliary_str); +/* */ +/* 95 */ process.appendChild(operation_seq_num); +/* 96 */ process.appendChild(department_code_new); +/* 97 */ process.appendChild(operation_description); +/* 98 */ process.appendChild(usage_rate_or_amount); +/* 99 */ process.appendChild(usage_rate_or_amount_auxiliary); +/* */ +/* 101 */ processes.appendChild(process); +/* */ } +/* 103 */ routeInfo.appendChild(assembly_item_number); +/* 104 */ routeInfo.appendChild(processes); +/* 105 */ root.appendChild(routeInfo); +/* */ } +/* */ +/* 108 */ TransformerFactory tf = TransformerFactory.newInstance(); +/* 109 */ Transformer transformer = tf.newTransformer(); +/* 110 */ DOMSource source = new DOMSource(doc); +/* 111 */ transformer.setOutputProperty("encoding", "GB2312"); +/* 112 */ transformer.setOutputProperty("indent", "yes"); +/* 113 */ PrintWriter pw = new PrintWriter(new FileOutputStream(file)); +/* 114 */ StreamResult result = new StreamResult(pw); +/* 115 */ transformer.transform(source, result); +/* 116 */ pw.close(); +/* */ } +/* */ } + + +/* Location: C:\Users\cyh\Documents\WeChat Files\wxid_ztg4pdvd5bjn12\FileStorage\File\2022-03\com.origin.erpintegration_1.0.0.jar!\com\origin\erp\ProcessImport\TransferRouteXMLWriter.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 1.1.3 + */ \ No newline at end of file diff --git a/src/com/connor/erp/ProcessImport/ValidateFailDialog.java b/src/com/connor/erp/ProcessImport/ValidateFailDialog.java new file mode 100644 index 0000000..199881f --- /dev/null +++ b/src/com/connor/erp/ProcessImport/ValidateFailDialog.java @@ -0,0 +1,380 @@ + package com.connor.erp.ProcessImport; + + import com.connor.erp.BomImport.BomTransferCommand; + import com.connor.erp.ItemAddTransferSendToERP.SendToERPCommand; + import com.connor.erp.toolkit.AimType; + import com.teamcenter.rac.aif.AbstractAIFCommand; + import com.teamcenter.rac.aif.AbstractAIFDialog; + import com.teamcenter.rac.util.HyperLink; + import com.teamcenter.rac.util.Utilities; + import com.teamcenter.rac.util.VerticalLayout; + import java.awt.BorderLayout; + import java.awt.Component; + import java.awt.Dimension; + import java.awt.LayoutManager; + import java.awt.Rectangle; + import java.awt.Toolkit; + import java.awt.event.ActionEvent; + import java.awt.event.ActionListener; + import java.io.File; + import java.io.FileWriter; + import java.io.IOException; + import java.util.Enumeration; + import java.util.Hashtable; + import javax.swing.JButton; + import javax.swing.JFileChooser; + import javax.swing.JLabel; + import javax.swing.JPanel; + import javax.swing.JScrollPane; + import javax.swing.filechooser.FileFilter; + + public class ValidateFailDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + + private JButton btnConfirm; + + private JButton btnReport; + + private String errorInfo; + + private String title; + + private String labelInfo; + + private boolean isVisibleErrorInfo = false; + + private JPanel parentPanel; + + private JPanel paneButton; + + private JPanel infoPanel; + + private JPanel detailPanel; + + private JPanel additionalInfoPanel; + + private HyperLink moreButton; + + private HyperLink lessButton; + + protected JScrollPane scroller; + +/* 79 */ protected AbstractAIFCommand command = null; + +/* 81 */ protected ProcessImportHandler handler = null; + + protected String dialogType; + + AimType aimType; + + public boolean isVisibleErrorInfo() { +/* 91 */ return this.isVisibleErrorInfo; + } + + public void setVisibleErrorInfo(boolean isVisibleErrorInfo) { +/* 98 */ this.isVisibleErrorInfo = isVisibleErrorInfo; + } + + public ValidateFailDialog(String perrorInfo, String ptitle) { +/* 102 */ super(false); +/* 103 */ this.errorInfo = perrorInfo; +/* 104 */ this.title = ptitle; +/* 105 */ initUI(); + } + + public ValidateFailDialog(String plabelInfo, String ptitle, String perrorInfo) { +/* 109 */ super(false); +/* 110 */ this.labelInfo = plabelInfo; +/* 111 */ this.title = ptitle; +/* 112 */ this.errorInfo = perrorInfo; +/* 113 */ initUI(); + } + + public ValidateFailDialog(String plabelInfo, String ptitle, String perrorInfo, ProcessImportHandler handler, String dialogType) { +/* 117 */ super(false); +/* 118 */ this.labelInfo = plabelInfo; +/* 119 */ this.title = ptitle; +/* 120 */ this.errorInfo = perrorInfo; +/* 121 */ this.handler = handler; +/* 122 */ this.dialogType = dialogType; +/* 123 */ initUI(); + } + + public ValidateFailDialog(String plabelInfo, String ptitle, String perrorInfo, AbstractAIFCommand command, String dialogType) { +/* 127 */ super(false); +/* 128 */ this.labelInfo = plabelInfo; +/* 129 */ this.title = ptitle; +/* 130 */ this.errorInfo = perrorInfo; +/* 131 */ this.command = command; +/* 132 */ this.dialogType = dialogType; +/* 133 */ initUI(); + } + + public ValidateFailDialog(String plabelInfo, String ptitle, String perrorInfo, AbstractAIFCommand command, String dialogType, AimType aimType) { +/* 137 */ super(false); +/* 138 */ this.labelInfo = plabelInfo; +/* 139 */ this.title = ptitle; +/* 140 */ this.errorInfo = perrorInfo; +/* 141 */ this.command = command; +/* 142 */ this.dialogType = dialogType; +/* 143 */ this.aimType = aimType; +/* 144 */ initUI(); + } + + public void initUI() { +/* 151 */ setTitle(this.title); +/* 152 */ this.parentPanel = new JPanel((LayoutManager)new VerticalLayout(4, 2, 2, 2, 2)); +/* 153 */ this.moreButton = new HyperLink("更多..."); +/* 154 */ this.moreButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionevent) { +/* 157 */ ValidateFailDialog.this.resizeDialog(-1); +/* 158 */ ValidateFailDialog.this.setShowDetails(true); + } + }); +/* 161 */ this.lessButton = new HyperLink("更少..."); +/* 162 */ this.lessButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionevent) { +/* 165 */ ValidateFailDialog.this.setShowDetails(false); + } + }); +/* 169 */ JLabel errorInfolabel = new JLabel("" + this.errorInfo + ""); +/* 171 */ this.detailPanel = new JPanel(); +/* 172 */ this.detailPanel.setVisible(false); +/* 179 */ if (this.labelInfo.equals("所要导入的数据在主组织中已经存在,请查看详细!")) { +/* 180 */ this.parentPanel.add("top.nobind", new JLabel("验证失败!
" + this.labelInfo + "")); + } else { +/* 182 */ this.parentPanel.add("top.nobind", new JLabel("" + this.labelInfo + "")); + } +/* 186 */ this.parentPanel.add("top.nobind.right", (Component)this.moreButton); +/* 187 */ this.parentPanel.add("top.nobind.right", (Component)this.lessButton); +/* 188 */ this.scroller = new JScrollPane(); +/* 189 */ this.infoPanel = new JPanel(); +/* 190 */ this.scroller.getViewport().add(this.infoPanel); +/* 191 */ this.infoPanel.add(errorInfolabel); +/* 192 */ String s = Utilities.getCookie("ValidateFailDialog", getClass().getName() + "." + "ShowDetails", true); +/* 193 */ setShowDetails((s != null && s.equalsIgnoreCase("true"))); +/* 194 */ this.parentPanel.add("unbound.bind.center.top", this.scroller); +/* 196 */ this.btnConfirm = new JButton("确认"); +/* 197 */ this.btnConfirm.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { +/* 201 */ ValidateFailDialog.this.dispose(); +/* 202 */ if (!ValidateFailDialog.this.labelInfo.contains("排队")) +/* 203 */ if (ValidateFailDialog.this.command != null) { +/* 204 */ if (ValidateFailDialog.this.command instanceof SendToERPCommand) { +/* 205 */ if (ValidateFailDialog.this.dialogType.equals("task")) { +/* 206 */ ((SendToERPCommand)ValidateFailDialog.this.command).postDialogForTask(); +/* 207 */ } else if (ValidateFailDialog.this.dialogType.equals("item")) { +/* 208 */ ((SendToERPCommand)ValidateFailDialog.this.command).postDialogForItem(); +/* 209 */ } else if (ValidateFailDialog.this.dialogType.equals("process")) { +/* 210 */ ((SendToERPCommand)ValidateFailDialog.this.command).postDialogForMeProcess(); + } +/* 212 */ } else if (ValidateFailDialog.this.command instanceof BomTransferCommand) { +/* 213 */ if (ValidateFailDialog.this.dialogType.equals("task")) { +/* 214 */ ((BomTransferCommand)ValidateFailDialog.this.command).postDialogForTask(ValidateFailDialog.this.aimType); +/* 215 */ } else if (ValidateFailDialog.this.dialogType.equals("bom")) { +/* 216 */ ((BomTransferCommand)ValidateFailDialog.this.command).postDialogForBom(ValidateFailDialog.this.aimType); + } + } +/* 219 */ } else if (ValidateFailDialog.this.handler != null) { +/* 220 */ if (ValidateFailDialog.this.dialogType.equals("task")) { +/* 221 */ ValidateFailDialog.this.handler.postDialogForTask(true); +/* 222 */ } else if (ValidateFailDialog.this.dialogType.equals("route")) { +/* 223 */ ValidateFailDialog.this.handler.postDialogForRoute(true); + } + } + } + }); +/* 230 */ this.btnReport = new JButton("生成TXT报告"); +/* 231 */ this.btnReport.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { +/* 235 */ ValidateFailDialog.this.createTxt(); + } + }); +/* 240 */ this.paneButton = new JPanel(); +/* 241 */ this.paneButton.add(this.btnConfirm); +/* 242 */ this.paneButton.add(this.btnReport); +/* 243 */ this.parentPanel.add("bottom.bind.center.top", this.paneButton); +/* 244 */ getContentPane().setLayout(new BorderLayout()); +/* 245 */ getContentPane().add("Center", this.parentPanel); + } + + private void resizeDialog(int i) { +/* 249 */ if (i != 0) { +/* 250 */ Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); +/* 251 */ this.infoPanel.revalidate(); +/* 252 */ Rectangle rectangle = this.scroller.getViewport().getBounds(); +/* 253 */ Rectangle rectangle1 = getBounds(); +/* 254 */ Rectangle rectangle2 = null; +/* 255 */ if (rectangle.height <= 0) +/* 256 */ rectangle2 = rectangle1; +/* 257 */ rectangle.height = this.infoPanel.getHeight(); +/* 258 */ this.scroller.getViewport().setBounds(rectangle); +/* 259 */ this.scroller.setBounds(rectangle); +/* 260 */ this.scroller.setPreferredSize(new Dimension(rectangle.width, rectangle.height)); +/* 261 */ rectangle.height += i; +/* 262 */ if (rectangle2 != null) +/* 263 */ i = rectangle.height; +/* 264 */ rectangle1.height += i; +/* 265 */ int j = 0; +/* 266 */ if (this.additionalInfoPanel != null) +/* 267 */ j = (this.additionalInfoPanel.getSize()).height; +/* 268 */ if (rectangle1.height < rectangle.height + j + 50) +/* 269 */ rectangle1.height = rectangle.height + j + 50; +/* 270 */ if (rectangle1.height > (int)(0.75D * dimension.getHeight())) +/* 271 */ rectangle1.height = (int)(0.75D * dimension.getHeight()); +/* 272 */ setBounds(rectangle1); +/* 273 */ validate(); +/* 274 */ repaint(); + } + } + + public void setShowDetails(boolean flag) { +/* 279 */ this.scroller.setVisible(flag); +/* 280 */ if (flag) { +/* 281 */ this.moreButton.setVisible(false); +/* 282 */ this.lessButton.setVisible(true); + } else { +/* 284 */ this.moreButton.setVisible(true); +/* 285 */ this.lessButton.setVisible(false); + } +/* 287 */ validate(); +/* 288 */ repaint(); +/* 289 */ String s = getClass().getName(); +/* 290 */ if (isShowing()) +/* 291 */ Utilities.setCookie("ValidateFailDialog", true, s + "." + "ShowDetails", String.valueOf(flag)); + } + + private void createTxt() { +/* 299 */ JFileChooser jfc = new JFileChooser(); +/* 300 */ ExampleFileFilter filter = new ExampleFileFilter(); +/* 301 */ filter.addExtension("txt"); +/* 302 */ filter.setDescription("txt File"); +/* 303 */ jfc.setFileFilter(filter); +/* 304 */ int ret = jfc.showSaveDialog(null); +/* 306 */ if (ret == 0) { +/* 307 */ File file = jfc.getSelectedFile(); +/* 308 */ String fname = jfc.getName(file); +/* 309 */ if (!fname.endsWith(".log") && !fname.endsWith(".LOG") && +/* 310 */ !fname.endsWith(".txt") && !fname.endsWith(".TXT")) +/* 311 */ fname = fname.concat(".txt"); +/* 314 */ file = jfc.getCurrentDirectory(); +/* 315 */ String saveFilePath = file.getPath().concat(File.separator).concat(fname); +/* 316 */ file = new File(saveFilePath); +/* 317 */ FileWriter fw = null; + try { +/* 319 */ fw = new FileWriter(file); +/* 320 */ } catch (IOException e) { +/* 321 */ e.printStackTrace(); + return; + } +/* 324 */ String newStr = this.errorInfo.replace("
", "\r\n"); + try { +/* 326 */ fw.write(newStr); +/* 327 */ fw.flush(); +/* 328 */ fw.close(); +/* 329 */ } catch (IOException e) { +/* 330 */ e.printStackTrace(); + } + } + } + + public class ExampleFileFilter extends FileFilter { +/* 336 */ private Hashtable filters = null; + +/* 337 */ private String description = null; + +/* 338 */ private String fullDescription = null; + + private boolean useExtensionsInDescription = true; + + public ExampleFileFilter() { +/* 348 */ this.filters = new Hashtable(); + } + + public ExampleFileFilter(String extension) { +/* 358 */ this(extension, (String)null); + } + + public ExampleFileFilter(String extension, String description) { +/* 371 */ this(); +/* 372 */ if (extension != null) +/* 373 */ addExtension(extension); +/* 374 */ if (description != null) +/* 375 */ setDescription(description); + } + + public ExampleFileFilter(String[] filters) { +/* 387 */ this(filters, (String)null); + } + + public ExampleFileFilter(String[] filters, String description) { +/* 400 */ this(); +/* 401 */ for (int i = 0; i < filters.length; i++) +/* 403 */ addExtension(filters[i]); +/* 405 */ if (description != null) +/* 406 */ setDescription(description); + } + + public boolean accept(File f) { +/* 419 */ if (f != null) { +/* 420 */ if (f.isDirectory()) +/* 421 */ return true; +/* 423 */ String extension = getExtension(f); +/* 424 */ if (extension != null && this.filters.get(getExtension(f)) != null) +/* 425 */ return true; + } +/* 429 */ return false; + } + + public String getExtension(File f) { +/* 439 */ if (f != null) { +/* 440 */ String filename = f.getName(); +/* 441 */ int i = filename.lastIndexOf('.'); +/* 442 */ if (i > 0 && i < filename.length() - 1) +/* 443 */ return filename.substring(i + 1).toLowerCase(); + } +/* 447 */ return null; + } + + public void addExtension(String extension) { +/* 462 */ if (this.filters == null) +/* 463 */ this.filters = new Hashtable(5); +/* 465 */ this.filters.put(extension.toLowerCase(), this); +/* 466 */ this.fullDescription = null; + } + + public String getDescription() { +/* 479 */ if (this.fullDescription == null) +/* 480 */ if (this.description == null || isExtensionListInDescription()) { +/* 481 */ this.fullDescription = (this.description == null) ? "(" : (String.valueOf(this.description) + +/* 482 */ " ("); +/* 484 */ Enumeration extensions = this.filters.keys(); +/* 485 */ if (extensions != null) { +/* 486 */ this.fullDescription = String.valueOf(this.fullDescription) + "." + (String)extensions.nextElement(); +/* 487 */ while (extensions.hasMoreElements()) +/* 488 */ this +/* 489 */ .fullDescription = String.valueOf(this.fullDescription) + ", ." + (String)extensions.nextElement(); + } +/* 492 */ this.fullDescription = String.valueOf(this.fullDescription) + ")"; + } else { +/* 494 */ this.fullDescription = this.description; + } +/* 497 */ return this.fullDescription; + } + + public void setDescription(String description) { +/* 509 */ this.description = description; +/* 510 */ this.fullDescription = null; + } + + public void setExtensionListInDescription(boolean b) { +/* 525 */ this.useExtensionsInDescription = b; +/* 526 */ this.fullDescription = null; + } + + public boolean isExtensionListInDescription() { +/* 541 */ return this.useExtensionsInDescription; + } + } + } + diff --git a/src/com/connor/erp/ProcessImport/ValidateRouteXMLWriter.java b/src/com/connor/erp/ProcessImport/ValidateRouteXMLWriter.java new file mode 100644 index 0000000..6320cab --- /dev/null +++ b/src/com/connor/erp/ProcessImport/ValidateRouteXMLWriter.java @@ -0,0 +1,129 @@ +/* */ package com.connor.erp.ProcessImport; +/* */ +/* */ import com.connor.erp.toolkit.ActionType; +/* */ import com.connor.erp.toolkit.AimType; +/* */ import com.connor.erp.toolkit.FileType; +/* */ import com.connor.erp.toolkit.UtilApi; +/* */ import java.io.FileNotFoundException; +/* */ import java.io.FileOutputStream; +/* */ import java.io.PrintWriter; +/* */ import java.util.Iterator; +/* */ import java.util.List; +/* */ import java.util.Map; +/* */ import javax.xml.parsers.DocumentBuilder; +/* */ import javax.xml.parsers.DocumentBuilderFactory; +/* */ import javax.xml.parsers.ParserConfigurationException; +/* */ import javax.xml.transform.Transformer; +/* */ import javax.xml.transform.TransformerException; +/* */ import javax.xml.transform.TransformerFactory; +/* */ import javax.xml.transform.dom.DOMSource; +/* */ import javax.xml.transform.stream.StreamResult; +/* */ import org.w3c.dom.Document; +/* */ import org.w3c.dom.Element; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class ValidateRouteXMLWriter +/* */ { +/* */ public static void createXML(String user_id, String file, ActionType actionType, FileType fileType, AimType aimType, Map> map) throws ParserConfigurationException, FileNotFoundException, TransformerException { +/* 42 */ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); +/* 43 */ DocumentBuilder db = dbf.newDocumentBuilder(); +/* 44 */ Document doc = db.newDocument(); +/* */ +/* */ +/* 47 */ Element root = doc.createElement("ERPFramework"); +/* 48 */ root.setAttribute("userId", user_id); +/* 49 */ root.setAttribute("time", UtilApi.getCurrentTime()); +/* 50 */ root.setAttribute("actionType", actionType.toString()); +/* 51 */ root.setAttribute("fileType", fileType.toString()); +/* 52 */ root.setAttribute("aimType", aimType.toString()); +/* 53 */ doc.appendChild(root); +/* */ +/* 55 */ Iterator iterator = map.keySet().iterator(); +/* 56 */ if (aimType.equals(AimType.chg)) { +/* 57 */ while (iterator.hasNext()) { +/* 58 */ String item_number = iterator.next(); +/* */ +/* 60 */ Element routeInfo = doc.createElement("RouteInfo"); +/* */ +/* 62 */ Element assembly_item_number = doc.createElement("assembly_item_number"); +/* */ +/* 64 */ assembly_item_number.setTextContent(item_number); +/* */ +/* 66 */ Element processes = doc.createElement("processes"); +/* */ +/* 68 */ List list = map.get(item_number); +/* 69 */ int listSize = list.size(); +/* 70 */ for (int i = 0; i < listSize; i++) { +/* 71 */ String operation_seq_num_str = ((String)list.get(i)).split(";")[0]; +/* 72 */ String department_code_new_str = ((String)list.get(i)).split(";")[1]; +/* 73 */ Element process = doc.createElement("process"); +/* 74 */ Element operation_seq_num = doc.createElement("operation_seq_num"); +/* 75 */ Element department_code_new = doc.createElement("department_code_new"); +/* 76 */ operation_seq_num.setTextContent(operation_seq_num_str); +/* 77 */ department_code_new.setTextContent(department_code_new_str); +/* 78 */ process.appendChild(operation_seq_num); +/* 79 */ process.appendChild(department_code_new); +/* 80 */ processes.appendChild(process); +/* */ } +/* 82 */ routeInfo.appendChild(assembly_item_number); +/* 83 */ routeInfo.appendChild(processes); +/* 84 */ root.appendChild(routeInfo); +/* */ } +/* */ } else { +/* 87 */ while (iterator.hasNext()) { +/* 88 */ String item_number = iterator.next(); +/* */ +/* 90 */ Element routeInfo = doc.createElement("RouteInfo"); +/* */ +/* 92 */ Element assembly_item_number = doc.createElement("assembly_item_number"); +/* */ +/* 94 */ assembly_item_number.setTextContent(item_number); +/* */ +/* 96 */ Element processes = doc.createElement("processes"); +/* */ +/* 98 */ List list = map.get(item_number); +/* 99 */ int listSize = list.size(); +/* 100 */ for (int i = 0; i < listSize; i++) { +/* 101 */ Element process = doc.createElement("process"); +/* 102 */ Element department_code = doc.createElement("department_code"); +/* 103 */ department_code.setTextContent(list.get(i)); +/* 104 */ process.appendChild(department_code); +/* 105 */ processes.appendChild(process); +/* */ } +/* 107 */ routeInfo.appendChild(assembly_item_number); +/* 108 */ routeInfo.appendChild(processes); +/* 109 */ root.appendChild(routeInfo); +/* */ } +/* */ } +/* */ +/* 113 */ TransformerFactory tf = TransformerFactory.newInstance(); +/* 114 */ Transformer transformer = tf.newTransformer(); +/* 115 */ DOMSource source = new DOMSource(doc); +/* 116 */ transformer.setOutputProperty("encoding", "GB2312"); +/* 117 */ transformer.setOutputProperty("indent", "yes"); +/* 118 */ PrintWriter pw = new PrintWriter(new FileOutputStream(file)); +/* 119 */ StreamResult result = new StreamResult(pw); +/* 120 */ transformer.transform(source, result); +/* 121 */ pw.close(); +/* */ } +/* */ } + + +/* Location: C:\Users\cyh\Documents\WeChat Files\wxid_ztg4pdvd5bjn12\FileStorage\File\2022-03\com.origin.erpintegration_1.0.0.jar!\com\origin\erp\ProcessImport\ValidateRouteXMLWriter.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 1.1.3 + */ \ No newline at end of file diff --git a/src/com/connor/erp/materialquery/InProcessReadXMLStr.java b/src/com/connor/erp/materialquery/InProcessReadXMLStr.java new file mode 100644 index 0000000..4b493e9 --- /dev/null +++ b/src/com/connor/erp/materialquery/InProcessReadXMLStr.java @@ -0,0 +1,115 @@ +package com.connor.erp.materialquery; + +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.JDOMException; +import org.jdom.input.SAXBuilder; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +public class InProcessReadXMLStr { + public static void xmlElements(File xmlFilePath, List tableDataList) { + SAXBuilder sb = new SAXBuilder(); + try { + Document doc = sb.build(xmlFilePath); + Element root = doc.getRootElement(); +// loadElements(root.getChildren(), tableDataList); + } catch (JDOMException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static void loadElements(Map inprocessInfoMap, List tableDataList) { + int inprocessInfoMapSize = inprocessInfoMap.size(); + if (inprocessInfoMapSize == 0) + return; + for(Entry entry:inprocessInfoMap.entrySet()) { + JSONObject jsonObject = JSONObject.fromObject(entry.getValue()); + /* 59 */ String segment1_value = entry.getKey(); +// /* 60 */ String name_value = jsonObject.getString("itemName"); + JSONArray jsonArray = jsonObject.getJSONArray("WIP"); + String[] tableData = new String[11]; + tableData[0] = segment1_value; + tableData[1] = jsonObject.getString("description"); + List wipList = (List)JSONArray.toList(jsonArray,WIPInfo.class); + for(WIPInfo w: wipList) { + tableData[2] = w.getWip_entyty_name(); + tableData[3] = w.getCreation_date(); + tableData[4] = w.getClass_code(); + tableData[5] = w.getStart_quantity(); + tableData[6] = w.getQuantity_completed(); + tableData[7] = w.getQuantity_scrapped(); + tableData[8] = w.getAssemblyNum(); + tableData[9] = w.getItemcount(); + tableData[10] = w.getItemquantity(); + + tableDataList.add(tableData); + } + } + +// for (int m = 0; m < inprocessInfoMapSize; m++) { +// Element inprocessInfoEle = (Element)inprocessInfoMap.get(m); +// List inprocessInfoChildlist = inprocessInfoEle.getChildren(); +// int inprocessInfoChildlistSize = inprocessInfoChildlist.size(); +// String segment1_value = ""; +// String description_value = ""; +// for (int i = 0; i < inprocessInfoChildlistSize; i++) { +// Element et = (Element)inprocessInfoChildlist.get(i); +// String et_name = et.getName(); +// String et_value = et.getValue(); +// if (et_name.equals("segment1")) { +// segment1_value = et_value; +// } else if (et_name.equals("description")) { +// description_value = et_value; +// } else if (et_name.equals("inprocesses")) { +// List children = et.getChildren(); +// int childNum = children.size(); +// for (int j = 0; j < childNum; j++) { +// Element childEt = (Element)children.get(j); +// if (childEt.getName().equals("inprocess")) { +// String[] tableData = new String[11]; +// tableData[0] = segment1_value; +// tableData[1] = description_value; +// List children2 = childEt.getChildren(); +// int childNum2 = children2.size(); +// for (int k = 0; k < childNum2; k++) { +// Element childEt2 = (Element)children2.get(k); +// String childEt2_name = childEt2.getName(); +// String childEt2_value = childEt2.getValue(); +// if (childEt2_name.equals("wip_entity_name")) { +// tableData[2] = childEt2_value; +// } else if (childEt2_name.equals("creation_date")) { +// tableData[3] = childEt2_value; +// } else if (childEt2_name.equals("class_code")) { +// tableData[4] = childEt2_value; +// } else if (childEt2_name.equals("Start_quantity")) { +// tableData[5] = childEt2_value; +// } else if (childEt2_name.equals("quantity_completed")) { +// tableData[6] = childEt2_value; +// } else if (childEt2_name.equals("quantity_scrapped")) { +// tableData[7] = childEt2_value; +// } else if (childEt2_name.equals("assemblyNum")) { +// tableData[8] = childEt2_value; +// } else if (childEt2_name.equals("itemcount")) { +// tableData[9] = childEt2_value; +// } else if (childEt2_name.equals("itemquantity")) { +// tableData[10] = childEt2_value; +// } +// } +// tableDataList.add(tableData); +// } +// } +// } +// } +// } + } +} diff --git a/src/com/connor/erp/materialquery/Quantity.java b/src/com/connor/erp/materialquery/Quantity.java new file mode 100644 index 0000000..8833ba8 --- /dev/null +++ b/src/com/connor/erp/materialquery/Quantity.java @@ -0,0 +1,25 @@ +package com.connor.erp.materialquery; + +public class Quantity { + + private String subInv; + private String qty; + public String getSubInv() { + return subInv; + } + public void setSubInv(String subInv) { + this.subInv = subInv; + } + public String getQty() { + return qty; + } + public void setQty(String qty) { + this.qty = qty; + } + @Override + public String toString() { + return "Quantity [subInv=" + subInv + ", qty=" + qty + "]"; + } + + +} diff --git a/src/com/connor/erp/materialquery/StockReadXMLStr.java b/src/com/connor/erp/materialquery/StockReadXMLStr.java new file mode 100644 index 0000000..8c0663f --- /dev/null +++ b/src/com/connor/erp/materialquery/StockReadXMLStr.java @@ -0,0 +1,114 @@ + package com.connor.erp.materialquery; + + import java.io.File; + import java.io.IOException; + import java.util.ArrayList; + import java.util.List; + import java.util.Map; +import java.util.Map.Entry; + +import org.jdom.Document; + import org.jdom.Element; + import org.jdom.JDOMException; + import org.jdom.input.SAXBuilder; + +import com.teamcenter.rac.appearanceconfiguration.ApprAttrPanel.listListener; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + + public class StockReadXMLStr { + public static void xmlElements(File xmlFilePath, Map> map) { +/* 36 */ SAXBuilder sb = new SAXBuilder(); + try { +/* 39 */ Document doc = sb.build(xmlFilePath); +/* 41 */ Element root = doc.getRootElement(); +///* 42 */ loadElements(root.getChildren(), map); +/* 43 */ } catch (JDOMException e) { +/* 44 */ e.printStackTrace(); +/* 45 */ } catch (IOException e) { +/* 46 */ e.printStackTrace(); + } + } + + public static void loadElements(Map inprocessInfoMap, Map> map) { +/* 51 */ int inprocessInfoMapSize = inprocessInfoMap.size(); +/* 52 */ if (inprocessInfoMapSize == 0) + return; + for(Entry entry:inprocessInfoMap.entrySet()) { + /* 62 */ List list = (List)new ArrayList(); + JSONObject jsonObject = JSONObject.fromObject(entry.getValue()); + /* 59 */ String segment1_value = entry.getKey(); + /* 60 */ String name_value = jsonObject.getString("itemName"); + JSONObject jsonObject2 = jsonObject.getJSONObject("itemQty"); + JSONArray jsonArray = jsonObject2.getJSONArray("ORG_NHL"); + if(!jsonArray.isEmpty()) { + for(int i=0;i quantityList = (List)JSONArray.toList(jsonArray,Quantity.class); + for(Quantity q:quantityList) { + /* 87 */ String[] tableData = new String[5]; + /* 88 */ tableData[0] = segment1_value; + /* 89 */ tableData[1] = name_value; + /* 90 */ tableData[2] = "主组织"; + /* 90 */ tableData[3] = q.getSubInv(); + /* 90 */ tableData[4] = q.getQty(); + list.add(tableData); + + } + } + } + jsonArray = jsonObject2.getJSONArray("ORG_NSC"); + if(!jsonArray.isEmpty()) { + for(int i=0;i quantityList = (List)JSONArray.toList(jsonArray,Quantity.class); + for(Quantity q:quantityList) { + /* 87 */ String[] tableData = new String[5]; + /* 88 */ tableData[0] = segment1_value; + /* 89 */ tableData[1] = name_value; + /* 90 */ tableData[2] = "生产组织"; + /* 90 */ tableData[3] = q.getSubInv(); + /* 90 */ tableData[4] = q.getQty(); + list.add(tableData); + + } + } + } + jsonArray = jsonObject2.getJSONArray("ORG_NBJ"); + if(!jsonArray.isEmpty()) { + for(int i=0;i quantityList = (List)JSONArray.toList(jsonArray,Quantity.class); + for(Quantity q:quantityList) { + /* 87 */ String[] tableData = new String[5]; + /* 88 */ tableData[0] = segment1_value; + /* 89 */ tableData[1] = name_value; + /* 90 */ tableData[2] = "备件组织"; + /* 90 */ tableData[3] = q.getSubInv(); + /* 90 */ tableData[4] = q.getQty(); + list.add(tableData); + + } + } + } + jsonArray = jsonObject2.getJSONArray("ORG_NSC"); + if(!jsonArray.isEmpty()) { + for(int i=0;i quantityList = (List)JSONArray.toList(jsonArray,Quantity.class); + for(Quantity q:quantityList) { + /* 87 */ String[] tableData = new String[5]; + /* 88 */ tableData[0] = segment1_value; + /* 89 */ tableData[1] = name_value; + /* 90 */ tableData[2] = "非生产组织"; + /* 90 */ tableData[3] = q.getSubInv(); + /* 90 */ tableData[4] = q.getQty(); + list.add(tableData); + + } + } + } +/* 192 */ map.put(segment1_value, list); +// } +// } + } + } + } + diff --git a/src/com/connor/erp/materialquery/ViewStockOfERP/CMap.java b/src/com/connor/erp/materialquery/ViewStockOfERP/CMap.java new file mode 100644 index 0000000..0a4a7cf --- /dev/null +++ b/src/com/connor/erp/materialquery/ViewStockOfERP/CMap.java @@ -0,0 +1,9 @@ +package com.connor.erp.materialquery.ViewStockOfERP; + +import javax.swing.JTable; + +public interface CMap { + int span(JTable paramJTable, int paramInt1, int paramInt2); + + int visibleCell(JTable paramJTable, int paramInt1, int paramInt2); +} diff --git a/src/com/connor/erp/materialquery/ViewStockOfERP/CMap1.java b/src/com/connor/erp/materialquery/ViewStockOfERP/CMap1.java new file mode 100644 index 0000000..5627583 --- /dev/null +++ b/src/com/connor/erp/materialquery/ViewStockOfERP/CMap1.java @@ -0,0 +1,25 @@ +package com.connor.erp.materialquery.ViewStockOfERP; + +import javax.swing.JTable; + +class CMap1 implements CMap { + public int span(JTable table, int row, int column) { + int rowCount = table.getRowCount(); + if (column == 0 || column == 1 || column == 2) { + int reRow = 1; + for (int i = row; i < rowCount - 1 && + table.getValueAt(i, column).toString().equals(table.getValueAt(i + 1, column).toString()); i++) + reRow++; + return reRow; + } + return 1; + } + + public int visibleCell(JTable table, int row, int column) { + if ((column == 0 || column == 1 || column == 2) && + row > 0 && + table.getValueAt(row, column).toString() == table.getValueAt(row - 1, column).toString()) + return row - 1; + return row; + } +} diff --git a/src/com/connor/erp/materialquery/ViewStockOfERP/CMap2.java b/src/com/connor/erp/materialquery/ViewStockOfERP/CMap2.java new file mode 100644 index 0000000..a6a8ae1 --- /dev/null +++ b/src/com/connor/erp/materialquery/ViewStockOfERP/CMap2.java @@ -0,0 +1,25 @@ +package com.connor.erp.materialquery.ViewStockOfERP; + +import javax.swing.JTable; + +public class CMap2 implements CMap { + public int span(JTable table, int row, int column) { + int rowCount = table.getRowCount(); + if (column == 0 || column == 1) { + int reRow = 1; + for (int i = row; i < rowCount - 1 && + table.getValueAt(i, column).toString().equals(table.getValueAt(i + 1, column).toString()); i++) + reRow++; + return reRow; + } + return 1; + } + + public int visibleCell(JTable table, int row, int column) { + if ((column == 0 || column == 1) && + row > 0 && + table.getValueAt(row, column).toString() == table.getValueAt(row - 1, column).toString()) + return row - 1; + return row; + } +} diff --git a/src/com/connor/erp/materialquery/ViewStockOfERP/CTUI.java b/src/com/connor/erp/materialquery/ViewStockOfERP/CTUI.java new file mode 100644 index 0000000..7aae176 --- /dev/null +++ b/src/com/connor/erp/materialquery/ViewStockOfERP/CTUI.java @@ -0,0 +1,54 @@ +package com.connor.erp.materialquery.ViewStockOfERP; +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; +import javax.swing.JComponent; +import javax.swing.plaf.basic.BasicTableUI; +import javax.swing.table.TableCellRenderer; + +public class CTUI extends BasicTableUI { + public void paint(Graphics g, JComponent c) { + Rectangle r = g.getClipBounds(); + int firstCol = this.table.columnAtPoint(new Point(r.x, 0)); + int lastCol = this.table.columnAtPoint(new Point(r.x + r.width, 0)); + if (lastCol < 0) + lastCol = this.table.getColumnCount() - 1; + for (int i = firstCol; i <= lastCol; i++) + paintCol(i, g); + } + + private void paintCol(int col, Graphics g) { + Rectangle r = g.getClipBounds(); + for (int i = 0; i < this.table.getRowCount(); i++) { + Rectangle r1 = this.table.getCellRect(i, col, true); + if (r1.intersects(r)) { + int sk = ((CTable)this.table).map.visibleCell(this.table, i, col); + paintCell(sk, col, g, r1); + i += ((CTable)this.table).map.span(this.table, sk, col) - 1; + } + } + } + + private void paintCell(int row, int column, Graphics g, Rectangle area) { + int verticalMargin = this.table.getRowMargin(); + int horizontalMargin = this.table.getColumnModel().getColumnMargin(); + Color c = g.getColor(); + g.setColor(this.table.getGridColor()); + g.drawRect(area.x, area.y, area.width - 1, area.height - 1); + g.setColor(c); + area.setBounds(area.x + horizontalMargin / 2, area.y + verticalMargin / 2, area.width - horizontalMargin, area.height - verticalMargin); + if (this.table.isEditing() && this.table.getEditingRow() == row && this.table.getEditingColumn() == column) { + Component component = this.table.getEditorComponent(); + component.setBounds(area); + component.validate(); + } else { + TableCellRenderer renderer = this.table.getCellRenderer(row, column); + Component component = this.table.prepareRenderer(renderer, row, column); + if (component.getParent() == null) + this.rendererPane.add(component); + this.rendererPane.paintComponent(g, component, this.table, area.x, area.y, area.width, area.height, true); + } + } +} diff --git a/src/com/connor/erp/materialquery/ViewStockOfERP/CTable.java b/src/com/connor/erp/materialquery/ViewStockOfERP/CTable.java new file mode 100644 index 0000000..2d1730e --- /dev/null +++ b/src/com/connor/erp/materialquery/ViewStockOfERP/CTable.java @@ -0,0 +1,38 @@ +package com.connor.erp.materialquery.ViewStockOfERP; + +import java.awt.Point; +import java.awt.Rectangle; +import javax.swing.JTable; +import javax.swing.plaf.TableUI; +import javax.swing.table.TableModel; + +public class CTable extends JTable { + private static final long serialVersionUID = 1L; + + public CMap map; + + public CTable(CMap cMap2, TableModel tbl) { + super(tbl); + this.map = cMap2; + setUI((TableUI)new CTUI()); + } + + public Rectangle getCellRect(int row, int column, boolean includeSpacing) { + if (this.map == null) + return super.getCellRect(row, column, includeSpacing); + int sk = this.map.visibleCell(this, row, column); + Rectangle r1 = super.getCellRect(sk, column, includeSpacing); + if (this.map.span(this, sk, column) != 1) + for (int i = 1; i < this.map.span(this, sk, column); i++) + r1.height += getRowHeight(sk + i); + return r1; + } + + public int rowAtPoint(Point p) { + int x = columnAtPoint(p); + if (x < 0) + return x; + int y = super.rowAtPoint(p); + return this.map.visibleCell(this, y, x); + } +} diff --git a/src/com/connor/erp/materialquery/ViewStockOfERP/Test.java b/src/com/connor/erp/materialquery/ViewStockOfERP/Test.java new file mode 100644 index 0000000..bd25000 --- /dev/null +++ b/src/com/connor/erp/materialquery/ViewStockOfERP/Test.java @@ -0,0 +1,102 @@ +package com.connor.erp.materialquery.ViewStockOfERP; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.text.html.parser.Entity; + +import com.connor.erpintegration.entity.BOMLineEntity; +import com.connor.erpintegration.entity.BomCheckResult; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +public class Test { + + public static void main(String[] args) { + String json = "{\r\n" + + " \"ret\": 88,\r\n" + + " \"msg\": \"succ\",\r\n" + + " \"cont\": {\r\n" + + " \"canAllImport\": false,\r\n" + + " \"checkResult\": [\r\n" + + " {\r\n" + + " \"assembly_item\": \"CAL1600A01\",\r\n" + + " \"assembly_item_exist\": true,\r\n" + + " \"locator_integrity\": false,\r\n" + + " \"bom_exist\": true,\r\n" + + " \"route_exist\": true,\r\n" + + " \"BOMLine\": [\r\n" + + " {\r\n" + + " \"item\": \"15229504\",\r\n" + + " \"operation_seq_num\": 10,\r\n" + + " \"item_exist\": true,\r\n" + + " \"item_valid\": true,\r\n" + + " \"locator_integrity\": true,\r\n" + + " \"operation_seq_num_exist_in_route\": false\r\n" + + " },\r\n" + + " {\r\n" + + " \"item\": \"09015394\",\r\n" + + " \"operation_seq_num\": 20,\r\n" + + " \"item_exist\": true,\r\n" + + " \"item_valid\": true,\r\n" + + " \"locator_integrity\": true,\r\n" + + " \"operation_seq_num_exist_in_route\": false\r\n" + + " }\r\n" + + " ],\r\n" + + " \"canBOMImport\": false\r\n" + + " }\r\n" + + " ]\r\n" + + " }\r\n" + + "}"; + JSONObject jsonObject = JSONObject.fromObject(json); + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); + JSONArray jsonArray = jsonObject2.getJSONArray("checkResult"); + List bomCheckResults = JSONArray.toList(jsonArray,BomCheckResult.class); + + for(BomCheckResult b:bomCheckResults) { + Map classMap = new HashMap(); + classMap.put("BOMLine", BOMLineEntity.class); + BomCheckResult r =(BomCheckResult)JSONObject.toBean(JSONObject.fromObject(b),BomCheckResult.class,classMap); + System.out.println("-------------checkResult-------------"); + System.out.println("assembly_item============="+r.getAssembly_item()); + System.out.println("assembly_item_exist============="+r.getAssembly_item_exist()); + System.out.println("locator_integrity============="+r.getLocator_integrity()); + System.out.println("bom_exist============="+r.getBom_exist()); + System.out.println("route_exist============="+r.getRoute_exist()); + System.out.println("canBOMImport============="+r.getCanBOMImport()); + System.out.println("-------------checkResult-------------"); +// String bomLine = b.getBOMLine(); + + List bomline = r.getBOMLine(); + for(BOMLineEntity boMline: bomline) { + System.out.println("-------------bomline-------------"); + System.out.println("item============"+boMline.getItem()); + System.out.println("operation_seq_num============"+boMline.getOperation_seq_num()); + System.out.println("item_exist============"+boMline.getItem_exist()); + System.out.println("item_valid============"+boMline.getItem_valid()); + System.out.println("locator_integrity============"+boMline.getLocator_integrity()); + System.out.println("operation_seq_num_exist_in_route============"+boMline.getOperation_seq_num_exist_in_route()); + System.out.println("-------------bomline-------------"); + } + } +// Map itemMap = (Map) JSONObject.toBean(jsonObject2, Map.class); +// +// for (Entry entry : itemMap.entrySet()) { +// +// System.out.println("key=============" + entry.getKey()); +// JSONObject jsonObject3 = JSONObject.fromObject(entry.getValue()); +// JSONObject jsonObject4 = jsonObject3.getJSONObject("itemQty"); +// JSONArray jsonArray1 = jsonObject4.getJSONArray("ORG_NHL"); +// JSONArray jsonArray2 = jsonObject4.getJSONArray("ORG_NSC"); +// JSONArray jsonArray3 = jsonObject4.getJSONArray("ORG_NBJ"); +// JSONArray jsonArray4 = jsonObject4.getJSONArray("ORG_NSJ"); +// System.out.println("ORG_NHL=========="+jsonArray1.isEmpty()); +// System.out.println("ORG_NSC=========="+jsonArray2.isEmpty()); +// System.out.println("ORG_NBJ=========="+jsonArray3.isEmpty()); +// System.out.println("ORG_NSJ=========="+jsonArray4.isEmpty()); +// } + } +} diff --git a/src/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPCommand.java b/src/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPCommand.java new file mode 100644 index 0000000..36fdb3c --- /dev/null +++ b/src/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPCommand.java @@ -0,0 +1,111 @@ + package com.connor.erp.materialquery.ViewStockOfERP; + + import com.connor.erp.materialquery.StockReadXMLStr; +import com.connor.erp.processresource.EquipmentAcquiredFromERP.TCPreferenceUitl; +import com.connor.erp.toolkit.HttpUtil; + import com.teamcenter.rac.aif.AbstractAIFCommand; + import com.teamcenter.rac.aif.AbstractAIFUIApplication; + import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; + import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONObject; + +import java.net.URLEncoder; +import java.util.HashMap; + import java.util.List; + import java.util.Map; + + public class ViewStockOfERPCommand extends AbstractAIFCommand { + private TCSession session; + + private AbstractAIFUIApplication application; + + private List listItemId; + + private String erpPreference = "connor_tc_to_erp_url"; + + public ViewStockOfERPCommand(TCSession pSession, AbstractAIFUIApplication app, List plistItemId) { +/* 53 */ this.session = pSession; +/* 54 */ this.application = app; +/* 55 */ this.listItemId = plistItemId; +/* 56 */ callERPDll(); + } + + private void callERPDll() { +/* 65 */ String user_id = ""; + try { +/* 67 */ user_id = this.session.getUser().getProperty("user_id"); +/* 68 */ } catch (TCException e) { +/* 69 */ e.printStackTrace(); + } +///* 71 */ String xmlFileName = +///* 72 */ System.getProperty("java.io.tmpdir") + +///* 73 */ File.separator + user_id + "_" + +///* 74 */ UtilApi.getCurrentTime() + +///* 75 */ "_query_item"; +///* 76 */ String xmlFilePath = xmlFileName + ".xml"; +// try { +///* 78 */ MaterialQueryXMLWriter.createXML(user_id, xmlFilePath, this.listItemId, ActionType.query, FileType.item); +///* 79 */ } catch (FileNotFoundException e) { +///* 81 */ e.printStackTrace(); +///* 82 */ } catch (ParserConfigurationException e) { +///* 84 */ e.printStackTrace(); +///* 85 */ } catch (TransformerException e) { +///* 87 */ e.printStackTrace(); +// } +///* 89 */ String result = UtilApi.getErrorInfoFromCode(PlmErpIntegration.getItemInfo(xmlFilePath)); +///* 90 */ if (!result.equals("成功")) { +///* 91 */ MessageBox.post(this.application.getDesktop().getShell(), result, "验证出现错误", 1); +// return; +// } +/* 94 */ Map> map = new HashMap>(); + Map requestMap = new HashMap(); + requestMap.put("items", listItemId); + Map responseMap = doGet(requestMap, "MTLINVOnhandQty"); +/* 95 */ StockReadXMLStr.loadElements(responseMap, map); +/* 96 */ if (map.size() == 0) { +/* 97 */ MessageBox.post(this.application.getDesktop().getShell(), "未找到可以展示的库存物料!!", "警告", 4); + return; + } +/* 100 */ setRunnable((Runnable)new ViewStockOfERPDialog(map)); + } + + private Map doGet(Map itemCheckMap, String svr) { + HashMap preferenceHashMap = TCPreferenceUitl.getPreferenceHashMap(session, TCPreferenceService.TC_preference_site, erpPreference); + String url = preferenceHashMap.get("url"); + String token = preferenceHashMap.get("token"); + JSONObject itemCheckJson = JSONObject.fromObject(itemCheckMap); + Map resultMap = new HashMap(); +// List checkResults =null; + try { + System.out.println("开始发送请求"); + String args = itemCheckJson.toString(); + token = URLEncoder.encode(token,"UTF-8"); + svr = URLEncoder.encode(svr,"UTF-8"); + args = URLEncoder.encode(args,"UTF-8"); + String param = "usr="+token+"&svr="+svr+"&args="+args; + System.out.println("url=============="+url); + System.out.println("param==========="+param); + String response = HttpUtil.doGet(url+"?"+param); + System.out.println("请求结果================"+response); + + JSONObject jsonObject = JSONObject.fromObject(response); + System.out.println("json格式==============="+jsonObject); + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); + resultMap = (Map)JSONObject.toBean(jsonObject2,Map.class); +// System.out.println("cont==============="+jsonObject2); +// JSONArray checkResult = jsonObject2.getJSONArray("checkResult"); +// canAllImport = jsonObject2.getBoolean("canAllImport"); +// checkResults = JSONArray.toList(checkResult,CheckResult.class); + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return resultMap; + } + + } + diff --git a/src/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPDialog.java b/src/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPDialog.java new file mode 100644 index 0000000..5d79981 --- /dev/null +++ b/src/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPDialog.java @@ -0,0 +1,82 @@ + package com.connor.erp.materialquery.ViewStockOfERP; + + import com.connor.erp.toolkit.UtilApi; + import com.teamcenter.rac.aif.AbstractAIFDialog; + import java.util.ArrayList; + import java.util.Collections; + import java.util.Comparator; + import java.util.Iterator; + import java.util.List; + import java.util.Map; + import java.util.Set; + import javax.swing.JScrollPane; + import javax.swing.JTable; + import javax.swing.table.DefaultTableModel; + + public class ViewStockOfERPDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + + private JTable table; + + private Map> map; + + private JScrollPane scrollPane; + + public ViewStockOfERPDialog(Map> pmap) { +/* 46 */ super(false); +/* 47 */ this.map = pmap; +/* 48 */ initUI(); + } + + private void initUI() { +/* 55 */ setTitle("ERP物料库存"); +/* 56 */ String[] colName = { "序号", "物料编号", "物料名称", "组织", "子库", "库存数量" }; +/* 57 */ CMap m = new CMap1(); +/* 58 */ DefaultTableModel tm = new DefaultTableModel((Object[][])fillData(), (Object[])colName) { + private static final long serialVersionUID = 1L; + + public boolean isCellEditable(int indexRow, int indexColumn) { +/* 65 */ return false; + } + }; +/* 68 */ this.table = new CTable(m, tm); +/* 69 */ UtilApi.FitTableColumns(this.table); +/* 71 */ this.scrollPane = new JScrollPane(this.table); +/* 72 */ getContentPane().add(this.scrollPane); + } + + public String[][] fillData() { +/* 76 */ Set set = this.map.keySet(); +/* 77 */ Iterator iterator = set.iterator(); +/* 78 */ List materialList = new ArrayList(); +/* 79 */ while (iterator.hasNext()) { +/* 80 */ String material = ((String)iterator.next()).toString(); +/* 81 */ materialList.add(material); + } +/* 83 */ Collections.sort(materialList, new Comparator() { + public int compare(String o1, String o2) { +/* 87 */ return o1.compareTo(o2); + } + }); +/* 91 */ int listSize = materialList.size(); +/* 92 */ List dataList = (List)new ArrayList(); +/* 93 */ for (int i = 0; i < listSize; i++) { +/* 94 */ List list = this.map.get(materialList.get(i)); +/* 95 */ int listSize2 = list.size(); +/* 96 */ for (int j = 0; j < listSize2; j++) { +/* 97 */ String[] arrStr = list.get(j); +/* 98 */ String[] arrayOfString1 = new String[6]; +/* 99 */ arrayOfString1[0] = String.valueOf(i + 1); +/* 100 */ arrayOfString1[1] = arrStr[0]; +/* 101 */ arrayOfString1[2] = arrStr[1]; +/* 102 */ arrayOfString1[3] = arrStr[2]; +/* 103 */ arrayOfString1[4] = arrStr[3]; +/* 104 */ arrayOfString1[5] = arrStr[4]; +/* 105 */ dataList.add(arrayOfString1); + } + } +/* 108 */ String[][] tableData = new String[dataList.size()][]; +/* 109 */ tableData = dataList.toArray(tableData); +/* 110 */ return tableData; + } + } diff --git a/src/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPHandler.java b/src/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPHandler.java new file mode 100644 index 0000000..dc5b13b --- /dev/null +++ b/src/com/connor/erp/materialquery/ViewStockOfERP/ViewStockOfERPHandler.java @@ -0,0 +1,115 @@ + package com.connor.erp.materialquery.ViewStockOfERP; + + import com.teamcenter.rac.aif.AbstractAIFCommand; + import com.teamcenter.rac.aif.AbstractAIFUIApplication; + import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; + import com.teamcenter.rac.aifrcp.AIFUtility; + import com.teamcenter.rac.kernel.TCComponentItem; + import com.teamcenter.rac.kernel.TCComponentItemRevision; + import com.teamcenter.rac.kernel.TCException; + import com.teamcenter.rac.kernel.TCPreferenceService; + import com.teamcenter.rac.kernel.TCSession; + import com.teamcenter.rac.util.MessageBox; + import java.util.ArrayList; + import java.util.List; + import java.util.Vector; + import org.eclipse.core.commands.AbstractHandler; + import org.eclipse.core.commands.ExecutionEvent; + import org.eclipse.core.commands.ExecutionException; + + public class ViewStockOfERPHandler extends AbstractHandler { + private static final String NHL_ERPQUERY_MENUAUTH = "NHL_ERPQuery_MenuAuth"; + + private static final String NHL_ERPQUERY_INVENTORYITEM = "NHL_ERPQuery_InventoryItem"; + + public Object execute(ExecutionEvent event) throws ExecutionException { +/* 51 */ AbstractAIFUIApplication application = AIFUtility.getCurrentApplication(); +/* 52 */ TCSession session = (TCSession)application.getSession(); +/* 53 */ if (application == null || application.getTargetComponent() == null) { +/* 54 */ MessageBox.post(application.getDesktop().getShell(), "请选中需要查询的物料!", "警告", 4); +/* 55 */ return null; + } +/* 57 */ String user_id = ""; + try { +/* 59 */ user_id = session.getUser().getProperty("user_id"); +/* 60 */ } catch (TCException e1) { +/* 61 */ e1.printStackTrace(); + } +/* 63 */ TCPreferenceService preferenceService = session.getPreferenceService(); +/* 64 */ String[] users = preferenceService.getStringArray(4, "NHL_ERPQuery_MenuAuth"); +/* 65 */ if (users != null && users.length > 0) { +/* 66 */ int roleLen = users.length; +/* 67 */ boolean hasRight = false; +/* 68 */ for (int i = 0; i < roleLen; i++) { +/* 69 */ if (user_id.equals(users[i].trim())) { +/* 70 */ hasRight = true; + break; + } + } +/* 74 */ if (hasRight) { +/* 75 */ String[] itemTypes = preferenceService.getStringArray(4, "NHL_ERPQuery_InventoryItem"); +/* 76 */ Vector vecItemTypes = new Vector(); +/* 77 */ if (itemTypes != null && itemTypes.length > 0) { +/* 78 */ int itemTypesLen = itemTypes.length; +/* 79 */ for (int k = 0; k < itemTypesLen; k++) +/* 80 */ vecItemTypes.add(itemTypes[k].trim()); + } else { +/* 83 */ MessageBox.post(application.getDesktop().getShell(), "请配置首选项NHL_ERPQuery_InventoryItem!!", "警告", 4); +/* 84 */ return null; + } +/* 86 */ List listItemId = new ArrayList(); +/* 87 */ InterfaceAIFComponent[] targetComponents = application.getTargetComponents(); +/* 88 */ int targetComLen = targetComponents.length; +/* 89 */ for (int j = 0; j < targetComLen; j++) { +/* 90 */ if (targetComponents[j] instanceof TCComponentItemRevision) { + try { +/* 92 */ if (vecItemTypes.contains(((TCComponentItemRevision)targetComponents[j]).getItem().getType())) { + try { +/* 94 */ String item_id = targetComponents[j].getProperty("item_id"); +/* 95 */ if (!listItemId.contains(item_id)) +/* 96 */ listItemId.add(item_id); +/* 98 */ } catch (Exception e) { +/* 99 */ e.printStackTrace(); + } + } else { +/* 102 */ MessageBox.post(application.getDesktop().getShell(), "请选中请选中首选项中存在的物料!!", "警告", 4); +/* 103 */ return null; + } +/* 105 */ } catch (TCException e) { +/* 106 */ e.printStackTrace(); + } +/* 108 */ } else if (targetComponents[j] instanceof TCComponentItem) { +/* 109 */ if (vecItemTypes.contains(((TCComponentItem)targetComponents[j]).getType())) { + try { +/* 111 */ String item_id = targetComponents[j].getProperty("item_id"); +/* 112 */ if (!listItemId.contains(item_id)) +/* 113 */ listItemId.add(item_id); +/* 115 */ } catch (Exception e) { +/* 116 */ e.printStackTrace(); + } + } else { +/* 119 */ MessageBox.post(application.getDesktop().getShell(), "请选中请选中首选项中存在的物料!!", "警告", 4); +/* 120 */ return null; + } + } else { +/* 123 */ MessageBox.post(application.getDesktop().getShell(), "请选中查询的物料!!", "警告", 4); +/* 124 */ return null; + } + } + try { +/* 128 */ AbstractAIFCommand command = new ViewStockOfERPCommand(session, application, listItemId); +/* 129 */ command.executeModal(); +/* 130 */ } catch (Exception e) { +/* 131 */ e.printStackTrace(); + } + } else { +/* 134 */ MessageBox.post(application.getDesktop().getShell(), "你没有权限进行当前操作!!", "警告", 4); +/* 135 */ return null; + } + } else { +/* 138 */ MessageBox.post(application.getDesktop().getShell(), "请配置首选项NHL_ERPQuery_MenuAuth!!", "警告", 4); +/* 139 */ return null; + } +/* 141 */ return null; + } + } diff --git a/src/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPCommand.java b/src/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPCommand.java new file mode 100644 index 0000000..4613c28 --- /dev/null +++ b/src/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPCommand.java @@ -0,0 +1,122 @@ + package com.connor.erp.materialquery.ViewWorkInProcessOfERP; + + import com.connor.erp.materialquery.InProcessReadXMLStr; +import com.connor.erp.processresource.EquipmentAcquiredFromERP.TCPreferenceUitl; +// import com.connor.erp.materialquery.MaterialQueryXMLWriter; + import com.connor.erp.toolkit.ActionType; + import com.connor.erp.toolkit.FileType; +import com.connor.erp.toolkit.HttpUtil; +import com.connor.erp.toolkit.UtilApi; +// import com.origin.tcerp.conn.PlmErpIntegration; + import com.teamcenter.rac.aif.AbstractAIFCommand; + import com.teamcenter.rac.aif.AbstractAIFUIApplication; + import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; + import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONObject; + +import java.io.File; + import java.io.FileNotFoundException; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.xml.parsers.ParserConfigurationException; + import javax.xml.transform.TransformerException; + + public class ViewWorkInProcessOfERPCommand extends AbstractAIFCommand { + private TCSession session; + + private AbstractAIFUIApplication application; + + private List listItemId; + + private String erpPreference = "connor_tc_to_erp_url"; + + public ViewWorkInProcessOfERPCommand(TCSession pSession, AbstractAIFUIApplication app, List plistItemId) { +/* 52 */ this.session = pSession; +/* 53 */ this.application = app; +/* 54 */ this.listItemId = plistItemId; +/* 55 */ callERPDll(); + } + + private void callERPDll() { +/* 64 */ String user_id = ""; + try { +/* 66 */ user_id = this.session.getUser().getProperty("user_id"); +/* 67 */ } catch (TCException e) { +/* 68 */ e.printStackTrace(); + } +///* 70 */ String xmlFileName = +///* 71 */ System.getProperty("java.io.tmpdir") + +///* 72 */ File.separator + user_id + "_" + +///* 73 */ UtilApi.getCurrentTime() + +///* 74 */ "_query_inprocess"; +///* 75 */ String xmlFilePath = xmlFileName + ".xml"; +// try { +///* 77 */ MaterialQueryXMLWriter.createXML(user_id, xmlFilePath, this.listItemId, ActionType.query, FileType.inprocess); +///* 78 */ } catch (FileNotFoundException e) { +///* 80 */ e.printStackTrace(); +///* 81 */ } catch (ParserConfigurationException e) { +///* 83 */ e.printStackTrace(); +///* 84 */ } catch (TransformerException e) { +///* 86 */ e.printStackTrace(); +// } +///* 88 */ String result = UtilApi.getErrorInfoFromCode(PlmErpIntegration.getInprocessInfo(xmlFilePath)); +///* 89 */ if (!result.equals("成功")) { +///* 90 */ MessageBox.post(this.application.getDesktop().getShell(), result, "验证出现错误", 1); +// return; +// } +/* 93 */ List tableDataList = (List)new ArrayList(); + Map requstMap = new HashMap(); + requstMap.put("items", listItemId); + Map responseMap = doGet(requstMap, "MTLWIPInfo"); +/* 94 */ InProcessReadXMLStr.loadElements(responseMap, tableDataList); +/* 96 */ if (tableDataList.size() == 0) { +/* 97 */ MessageBox.post(this.application.getDesktop().getShell(), "未找到可以展示的物料在制品!!", "警告", 4); + return; + } +/* 100 */ setRunnable((Runnable)new ViewWorkInProcessOfERPDialog(this.session, tableDataList)); + } + + private Map doGet(Map itemCheckMap, String svr) { + HashMap preferenceHashMap = TCPreferenceUitl.getPreferenceHashMap(session, TCPreferenceService.TC_preference_site, erpPreference); + String url = preferenceHashMap.get("url"); + String token = preferenceHashMap.get("token"); + JSONObject itemCheckJson = JSONObject.fromObject(itemCheckMap); + Map resultMap = new HashMap(); +// List checkResults =null; + try { + System.out.println("开始发送请求"); + String args = itemCheckJson.toString(); + token = URLEncoder.encode(token,"UTF-8"); + svr = URLEncoder.encode(svr,"UTF-8"); + args = URLEncoder.encode(args,"UTF-8"); + String param = "usr="+token+"&svr="+svr+"&args="+args; + System.out.println("url=============="+url); + System.out.println("param==========="+param); + String response = HttpUtil.doGet(url+"?"+param); + System.out.println("请求结果================"+response); + + JSONObject jsonObject = JSONObject.fromObject(response); + System.out.println("json格式==============="+jsonObject); + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); + resultMap = (Map)JSONObject.toBean(jsonObject2,Map.class); +// System.out.println("cont==============="+jsonObject2); +// JSONArray checkResult = jsonObject2.getJSONArray("checkResult"); +// canAllImport = jsonObject2.getBoolean("canAllImport"); +// checkResults = JSONArray.toList(checkResult,CheckResult.class); + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return resultMap; + } + + } + diff --git a/src/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPDialog.java b/src/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPDialog.java new file mode 100644 index 0000000..c4a418a --- /dev/null +++ b/src/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPDialog.java @@ -0,0 +1,75 @@ + package com.connor.erp.materialquery.ViewWorkInProcessOfERP; + + import com.connor.erp.toolkit.UtilApi; + import com.teamcenter.rac.aif.AbstractAIFDialog; + import com.teamcenter.rac.common.TCTable; + import com.teamcenter.rac.kernel.TCSession; + import java.awt.Component; + import java.util.Collections; + import java.util.Comparator; + import java.util.List; + import javax.swing.JScrollPane; + import javax.swing.JTable; + + public class ViewWorkInProcessOfERPDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + + private TCSession session; + + private TCTable table; + + private List tableDataList; + + private JScrollPane scrollPane; + + public ViewWorkInProcessOfERPDialog(TCSession pSession, List ptableDataList) { +/* 43 */ super(false); +/* 44 */ this.tableDataList = ptableDataList; +/* 45 */ initUI(); + } + + private void initUI() { +/* 52 */ setTitle("ERP库存在制品"); +/* 53 */ String[] colName = { +/* 53 */ "序号", "制造件号", "制造名称", "任务号", "生产日期", "车型分类", "计划件数", +/* 54 */ "完成件数", "报废件数", "配套件数", +/* 54 */ "部件种数", "部件总个数" }; +/* 55 */ this.table = new TCTable(this.session, colName) { + private static final long serialVersionUID = 1L; + + public boolean isCellEditable(int i, int j) { +/* 63 */ return false; + } + }; +/* 66 */ fillData(); +/* 67 */ UtilApi.FitTableColumns((JTable)this.table); +/* 68 */ this.scrollPane = new JScrollPane((Component)this.table); +/* 72 */ getContentPane().add(this.scrollPane); + } + + public void fillData() { +/* 77 */ Collections.sort((List)this.tableDataList, (Comparator)new Comparator() { + public int compare(String[] o1, String[] o2) { +/* 81 */ return o1[0].compareTo(o2[0]); + } + }); +/* 85 */ int tableSize = this.tableDataList.size(); +/* 86 */ for (int i = 0; i < tableSize; i++) { +/* 87 */ String[] arrStr = this.tableDataList.get(i); +/* 88 */ String[] tableData = new String[12]; +/* 89 */ tableData[0] = String.valueOf(i + 1); +/* 90 */ tableData[1] = arrStr[0]; +/* 91 */ tableData[2] = arrStr[1]; +/* 92 */ tableData[3] = arrStr[2]; +/* 93 */ tableData[4] = arrStr[3]; +/* 94 */ tableData[5] = arrStr[4]; +/* 95 */ tableData[6] = arrStr[5]; +/* 96 */ tableData[7] = arrStr[6]; +/* 97 */ tableData[8] = arrStr[7]; +/* 98 */ tableData[9] = arrStr[8]; +/* 99 */ tableData[10] = arrStr[9]; +/* 100 */ tableData[11] = arrStr[10]; +/* 101 */ this.table.addRow(tableData); + } + } + } diff --git a/src/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPHandler.java b/src/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPHandler.java new file mode 100644 index 0000000..65e7dcd --- /dev/null +++ b/src/com/connor/erp/materialquery/ViewWorkInProcessOfERP/ViewWorkInProcessOfERPHandler.java @@ -0,0 +1,116 @@ + package com.connor.erp.materialquery.ViewWorkInProcessOfERP; + + import com.teamcenter.rac.aif.AbstractAIFCommand; + import com.teamcenter.rac.aif.AbstractAIFUIApplication; + import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; + import com.teamcenter.rac.aifrcp.AIFUtility; + import com.teamcenter.rac.kernel.TCComponentItem; + import com.teamcenter.rac.kernel.TCComponentItemRevision; + import com.teamcenter.rac.kernel.TCException; + import com.teamcenter.rac.kernel.TCPreferenceService; + import com.teamcenter.rac.kernel.TCSession; + import com.teamcenter.rac.util.MessageBox; + import java.util.ArrayList; + import java.util.List; + import java.util.Vector; + import org.eclipse.core.commands.AbstractHandler; + import org.eclipse.core.commands.ExecutionEvent; + import org.eclipse.core.commands.ExecutionException; + + public class ViewWorkInProcessOfERPHandler extends AbstractHandler { + private static final String NHL_ERPQUERY_MENUAUTH = "NHL_ERPQuery_MenuAuth"; + + private static final String NHL_ERPQUERY_PRODUCEITEM = "NHL_ERPQuery_ProduceItem"; + + public Object execute(ExecutionEvent event) throws ExecutionException { +/* 51 */ AbstractAIFUIApplication application = AIFUtility.getCurrentApplication(); +/* 52 */ TCSession session = (TCSession)application.getSession(); +/* 53 */ if (application == null || application.getTargetComponent() == null) { +/* 54 */ MessageBox.post(application.getDesktop().getShell(), "请选中需要查询的在制品!", "警告", 4); +/* 55 */ return null; + } +/* 57 */ String user_id = ""; + try { +/* 59 */ user_id = session.getUser().getProperty("user_id"); +/* 60 */ } catch (TCException e1) { +/* 61 */ e1.printStackTrace(); + } +/* 63 */ TCPreferenceService preferenceService = session.getPreferenceService(); +/* 64 */ String[] users = preferenceService.getStringArray(4, "NHL_ERPQuery_MenuAuth"); +/* 65 */ if (users != null && users.length > 0) { +/* 66 */ int roleLen = users.length; +/* 67 */ boolean hasRight = false; +/* 68 */ for (int i = 0; i < roleLen; i++) { +/* 69 */ if (user_id.equals(users[i].trim())) { +/* 70 */ hasRight = true; + break; + } + } +/* 74 */ if (hasRight) { +/* 75 */ String[] itemTypes = preferenceService.getStringArray(4, "NHL_ERPQuery_ProduceItem"); +/* 76 */ Vector vecItemTypes = new Vector(); +/* 77 */ if (itemTypes != null && itemTypes.length > 0) { +/* 78 */ int itemTypesLen = itemTypes.length; +/* 79 */ for (int k = 0; k < itemTypesLen; k++) +/* 80 */ vecItemTypes.add(itemTypes[k].trim()); + } else { +/* 83 */ MessageBox.post(application.getDesktop().getShell(), "请配置首选项NHL_ERPQuery_ProduceItem!!", "警告", 4); +/* 84 */ return null; + } +/* 86 */ List listItemId = new ArrayList(); +/* 87 */ InterfaceAIFComponent[] targetComponents = application.getTargetComponents(); +/* 88 */ int targetComLen = targetComponents.length; +/* 89 */ for (int j = 0; j < targetComLen; j++) { +/* 90 */ if (targetComponents[j] instanceof TCComponentItemRevision) { + try { +/* 92 */ if (vecItemTypes.contains(((TCComponentItemRevision)targetComponents[j]).getItem().getType())) { + try { +/* 94 */ String item_id = targetComponents[j].getProperty("item_id"); +/* 95 */ if (!listItemId.contains(item_id)) +/* 96 */ listItemId.add(item_id); +/* 98 */ } catch (Exception e) { +/* 99 */ e.printStackTrace(); + } + } else { +/* 102 */ MessageBox.post(application.getDesktop().getShell(), "请选中首选项中存在的物料在制品!!", "警告", 4); +/* 103 */ return null; + } +/* 105 */ } catch (TCException e) { +/* 106 */ e.printStackTrace(); + } +/* 108 */ } else if (targetComponents[j] instanceof TCComponentItem) { +/* 109 */ if (vecItemTypes.contains(((TCComponentItem)targetComponents[j]).getType())) { + try { +/* 111 */ String item_id = targetComponents[j].getProperty("item_id"); +/* 112 */ if (!listItemId.contains(item_id)) +/* 113 */ listItemId.add(item_id); +/* 115 */ } catch (Exception e) { +/* 116 */ e.printStackTrace(); + } + } else { +/* 119 */ MessageBox.post(application.getDesktop().getShell(), "请选中首选项中存在的物料在制品!!", "警告", 4); +/* 120 */ return null; + } + } else { +/* 123 */ MessageBox.post(application.getDesktop().getShell(), "请选中物料在制品对象!!", "警告", 4); +/* 124 */ return null; + } + } + try { +/* 128 */ AbstractAIFCommand command = new ViewWorkInProcessOfERPCommand(session, application, listItemId); +/* 129 */ command.executeModal(); +/* 130 */ } catch (Exception e) { +/* 131 */ e.printStackTrace(); + } + } else { +/* 134 */ MessageBox.post(application.getDesktop().getShell(), "你没有权限进行当前操作!!", "警告", 4); +/* 135 */ return null; + } + } else { +/* 138 */ MessageBox.post(application.getDesktop().getShell(), "请配置首选项NHL_ERPQuery_MenuAuth!!", "警告", 4); +/* 139 */ return null; + } +/* 141 */ return null; + } + } + diff --git a/src/com/connor/erp/materialquery/WIPInfo.java b/src/com/connor/erp/materialquery/WIPInfo.java new file mode 100644 index 0000000..b612ac8 --- /dev/null +++ b/src/com/connor/erp/materialquery/WIPInfo.java @@ -0,0 +1,78 @@ +package com.connor.erp.materialquery; + +public class WIPInfo { + + private String wip_entyty_name; + private String creation_date; + private String class_code; + private String start_quantity; + private String quantity_completed; + private String quantity_scrapped; + private String assemblyNum; + private String itemcount; + private String itemquantity; + public String getWip_entyty_name() { + return wip_entyty_name; + } + public void setWip_entyty_name(String wip_entyty_name) { + this.wip_entyty_name = wip_entyty_name; + } + public String getCreation_date() { + return creation_date; + } + public void setCreation_date(String creation_date) { + this.creation_date = creation_date; + } + public String getClass_code() { + return class_code; + } + public void setClass_code(String class_code) { + this.class_code = class_code; + } + public String getStart_quantity() { + return start_quantity; + } + public void setStart_quantity(String start_quantity) { + this.start_quantity = start_quantity; + } + public String getQuantity_completed() { + return quantity_completed; + } + public void setQuantity_completed(String quantity_completed) { + this.quantity_completed = quantity_completed; + } + public String getQuantity_scrapped() { + return quantity_scrapped; + } + public void setQuantity_scrapped(String quantity_scrapped) { + this.quantity_scrapped = quantity_scrapped; + } + public String getAssemblyNum() { + return assemblyNum; + } + public void setAssemblyNum(String assemblyNum) { + this.assemblyNum = assemblyNum; + } + public String getItemcount() { + return itemcount; + } + public void setItemcount(String itemcount) { + this.itemcount = itemcount; + } + public String getItemquantity() { + return itemquantity; + } + public void setItemquantity(String itemquantity) { + this.itemquantity = itemquantity; + } + @Override + public String toString() { + return "WIPInfo [wip_entyty_name=" + wip_entyty_name + ", creation_date=" + creation_date + ", class_code=" + + class_code + ", start_quantity=" + start_quantity + ", quantity_completed=" + quantity_completed + + ", quantity_scrapped=" + quantity_scrapped + ", assemblyNum=" + assemblyNum + ", itemcount=" + + itemcount + ", itemquantity=" + itemquantity + "]"; + } + + + +} diff --git a/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/CreateClassificationPropertyPanel.java b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/CreateClassificationPropertyPanel.java new file mode 100644 index 0000000..55fae92 --- /dev/null +++ b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/CreateClassificationPropertyPanel.java @@ -0,0 +1,174 @@ +package com.connor.erp.processresource.EquipmentAcquiredFromERP; + +import com.teamcenter.rac.aifrcp.AifrcpPlugin; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSApplicationObject; +import com.teamcenter.rac.kernel.ics.ICSFormat; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.kernel.ics.ICSView; +import com.teamcenter.rac.util.Painter; +import com.teamcenter.rac.util.VerticalLayout; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.GridLayout; +import java.awt.LayoutManager; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +public class CreateClassificationPropertyPanel { + JPanel mainPanel; + + JScrollPane scrollPane; + + ICSApplicationObject icsapplicationobject; + + ICSView icsView; + + List notNullClassificationPropTextField; + + HashMap propHashMap; + + HashMap nameToIdHashMap; + + TCClassificationService classificationService; + + public TCSession getSession() { + TCSession session = (TCSession)AifrcpPlugin.getSessionService().getDefaultSession(); + return session; + } + + public CreateClassificationPropertyPanel() { + this.propHashMap = new HashMap(); + this.nameToIdHashMap = new HashMap(); + this.notNullClassificationPropTextField = new ArrayList(); + this.mainPanel = new JPanel(new BorderLayout()); + this.scrollPane = new JScrollPane(); + this.scrollPane.getViewport().setView(this.mainPanel); + this.scrollPane.setHorizontalScrollBarPolicy(32); + this.scrollPane.setVerticalScrollBarPolicy(22); + this.classificationService = getSession().getClassificationService(); + try { + this.icsapplicationobject = this.classificationService.newICSApplicationObject("ICM"); + } catch (TCException e) { + e.printStackTrace(); + } + } + + public JScrollPane getPropertyPanel() { + return this.scrollPane; + } + + public ICSApplicationObject getICSApplicationObject() { + return this.icsapplicationobject; + } + + public ICSView getICSView() { + return this.icsView; + } + + public TCClassificationService getClassificationService() { + return this.classificationService; + } + + public List getNotNullClassificationPropTextField() { + return this.notNullClassificationPropTextField; + } + + public void setNotNullClassificationPropTextField(List notNullClassificationPropTextField) { + this.notNullClassificationPropTextField = notNullClassificationPropTextField; + } + + public JScrollPane createPropertyPanel(String icsName, String icsID) { + this.mainPanel.removeAll(); + try { + this.icsapplicationobject.setView("Base", icsID); + } catch (TCException e1) { + e1.printStackTrace(); + } + this.icsView = this.icsapplicationobject.getView(); + if (this.icsView == null) + return this.scrollPane; + ICSPropertyDescription[] aicspropertydescription = this.icsapplicationobject.getView().getPropertyDescriptions(); + JLabel jlabel = new JLabel(icsName); + JPanel formPanel = new JPanel(); + if (aicspropertydescription != null && aicspropertydescription.length > 0) { + formPanel.setLayout((LayoutManager)new VerticalLayout(aicspropertydescription.length)); + for (int i = 0; i < aicspropertydescription.length; i++) { + String dispalayName = aicspropertydescription[i].getDisplayName(); + boolean isMandatory = aicspropertydescription[i].isMandatory(); + ICSFormat isformat = aicspropertydescription[i].getFormat(); + JPanel panel = new JPanel(new GridLayout(1, 3, 2, 2)); + panel.setPreferredSize(new Dimension(0, 25)); + JLabel labelDisplayName = new JLabel(dispalayName); + JLabel labelUnit = new JLabel(aicspropertydescription[i].getUnit()); + int lenth = (isformat.getSize() <= 20) ? isformat.getSize() : 20; + Object jtextField = null; + if (isformat.isList()) { + String[] keyLovs = isformat.getKeyLov().getKeyValues(); + if (isMandatory) { + jtextField = (Object)new JComboBox((Object[])keyLovs) { + public void paint(Graphics g) { + super.paint(g); + Painter.paintIsRequired(this, g); + } + }; + } else { + jtextField = (Object)new JComboBox(keyLovs); + } + } else if (isMandatory) { + jtextField = (Object)new JTextField(lenth) { + public void paint(Graphics g) { + super.paint(g); + Painter.paintIsRequired(this, g); + } + }; + } else { + jtextField = (Object)new JTextField(lenth); + } + panel.add(labelDisplayName); + if (isMandatory) + this.notNullClassificationPropTextField.add(jtextField); + if (jtextField instanceof JTextField) { + panel.add((JTextField)jtextField); + } else if (jtextField instanceof JComboBox) { + panel.add((JComboBox)jtextField); + } + panel.add(labelUnit); + if (this.icsapplicationobject.getView().isAbstract()) { + Component[] components = panel.getComponents(); + for (int m = 0; m < components.length; m++) + components[m].setEnabled(false); + } + formPanel.add("top.bind.left.top", panel); + String propName = aicspropertydescription[i].getName(); + this.propHashMap.put(propName, jtextField); + this.nameToIdHashMap.put(propName, Integer.valueOf(aicspropertydescription[i].getId())); + } + } + this.mainPanel.add(jlabel, "North"); + this.mainPanel.add(formPanel, "Center"); + this.mainPanel.repaint(); + this.mainPanel.validate(); + this.scrollPane.repaint(); + this.scrollPane.validate(); + return this.scrollPane; + } + + public HashMap getPropertyInfos() { + return this.propHashMap; + } + + public HashMap getNameToIdPropertyInfos() { + return this.nameToIdHashMap; + } +} diff --git a/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPCommand.java b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPCommand.java new file mode 100644 index 0000000..f129a2b --- /dev/null +++ b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPCommand.java @@ -0,0 +1,156 @@ +package com.connor.erp.processresource.EquipmentAcquiredFromERP; + +import com.connor.erp.toolkit.HttpUtil; +import com.connor.erp.toolkit.UtilApi; +import com.connor.erpintegration.entity.DepResEntity; +//import com.origin.tcerp.conn.PlmErpIntegration; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import java.io.File; +import java.net.URLEncoder; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +//import javax.activation.MailcapCommandMap; + +public class EquipmentAcquiredFromERPCommand extends AbstractAIFCommand { + private TCSession session; + + private AbstractAIFUIApplication application; + + private TCComponentFolder targetFolder; + public String erpPreference = "connor_tc_to_erp_url"; + private String svr = "DepRes"; + + public EquipmentAcquiredFromERPCommand(TCSession pSession, AbstractAIFUIApplication app, + TCComponentFolder ptargetFolder) { + this.session = pSession; + this.application = app; + this.targetFolder = ptargetFolder; + callERPDll(); + } + + @SuppressWarnings("deprecation") + private void callERPDll(){ + TCComponent[] components; + Vector vecNo = new Vector(); + try { + components = session.search("零组件 ID", new String[] { "零组件 ID" }, + new String[] { "NHLM*" }); + int componentLen = components.length; + for (int i = 0; i < componentLen; i++) { + try { + String item_id = components[i].getProperty("item_id"); + vecNo.add(item_id.substring(4)); + } catch (TCException e) { + e.printStackTrace(); + } + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + String user_id = ""; + try { + user_id = this.session.getUser().getProperty("user_id"); + } catch (TCException e) { + e.printStackTrace(); + } + List depResList = doGet(); +// String xmlFilePath = System.getProperty("java.io.tmpdir") + File.separator + user_id + "_" + UtilApi.getCurrentTime() + "_query_device.xml"; +// String result = UtilApi.getErrorInfoFromCode(PlmErpIntegration.getAllDeviceInfo(xmlFilePath)); +// if (!result.equals("成功")) { +// MessageBox.post(this.application.getDesktop().getShell(), result, "验证出现错误", 1); +// return; +// } +// ReadXMLStr doc = new ReadXMLStr(); +// File xmlFile = new File(xmlFilePath); + Vector vecCanImp = new Vector(); + if (depResList!=null&&depResList.size()>0) { + for(DepResEntity t:depResList) { + if(!vecNo.contains(t.getDEPARTMENT_CODE())) + vecCanImp.add(t.getDEPARTMENT_CODE()+","+t.getDESCRIPTION()); + } +// if (xmlFile.exists()) { +// List infoList = doc.xmlElements(xmlFile, "ERPFramework|SegmentInfo"); +// int listSize = infoList.size(); +// for (int j = 0; j < listSize; j++) { +// String[] str = ((String)infoList.get(j)).split("%#%"); +// String resource_code = str[1].split("=")[1]; +// if (!vecNo.contains(resource_code)) +// vecCanImp.add(String.valueOf(resource_code) + "," + str[2].split("=")[1]); +// } + } else { + MessageBox.post("ERP中未找到设备","警告",MessageBox.WARNING); +// MessageBox.post(this.application.getDesktop().getShell(), String.valueOf(xmlFilePath) + "文件未找到!!", "警告", 4); + return; + } + if (vecCanImp.size() == 0) { + MessageBox.post(this.application.getDesktop().getShell(), "未找到可以导入PLM系统的设备!!", "警告", 4); + return; + } + setRunnable((Runnable) new EquipmentAcquiredFromERPDialog(this.session, this.targetFolder, vecCanImp)); + } + + private List doGet() { + HashMap preferenceHashMap = TCPreferenceUitl.getPreferenceHashMap(session, TCPreferenceService.TC_preference_site, erpPreference); + String url = preferenceHashMap.get("url"); + String token = preferenceHashMap.get("token"); + List depResList = null; + try { + System.out.println("开始发送请求"); + String args = "{}"; + token = URLEncoder.encode(token,"UTF-8"); + svr = URLEncoder.encode(svr,"UTF-8"); + args = URLEncoder.encode(args,"UTF-8"); + String param = "usr="+token+"&svr="+svr+"&args="+args; + System.out.println("url=============="+url); + System.out.println("param==========="+param); + String response = HttpUtil.doGet(url+"?"+param); + System.out.println("请求结果================"+response); + + JSONObject jsonObject = JSONObject.fromObject(response); + System.out.println("json格式==============="+jsonObject); +// Map classMap = new HashMap(); +// classMap.put("DepRes", DepResEntity.class); +// classMap.put("cont", DepResListClass.class); + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); + System.out.println("cont==============="+jsonObject2); + JSONArray jsonArray = jsonObject2.getJSONArray("DepRes"); +// for(int i=0;i map2 = (Map)jsonObject2.toBean(jsonObject2, Map.class); +// String depRes = map2.get("DepRes"); +// List depResList = JSONArray.fromObject(depRes); +// System.out.println("位置7"); +// for(DepResEntity dep:depResList) { +// System.out.println("DEPARTMENT_CODE============"+dep.getDEPARTMENT_CODE()); +// System.out.println("DEPARTMENT_ID============"+dep.getDEPARTMENT_ID()); +// System.out.println("DESCRIPTION============"+dep.getDESCRIPTION()); +// } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return depResList; + } +} diff --git a/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPDialog.java b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPDialog.java new file mode 100644 index 0000000..7a871b6 --- /dev/null +++ b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPDialog.java @@ -0,0 +1,218 @@ +package com.connor.erp.processresource.EquipmentAcquiredFromERP; + +import com.connor.erp.toolkit.UtilApi; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.List; +import java.util.Vector; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; + +public class EquipmentAcquiredFromERPDialog extends AbstractAIFDialog implements ActionListener { + private static final long serialVersionUID = 1L; + + private TCSession session; + + private TCComponentFolder targetFolder; + + private JTable table; + + private Vector vecCanImp; + + private JButton btnImport; + + private JButton btnCancel; + + private JScrollPane scrollPane; + + public class CheckHeaderCellRenderer implements TableCellRenderer { + EquipmentAcquiredFromERPDialog.CheckTableModle tableModel; + + JTableHeader tableHeader; + + final JCheckBox selectBox; + + public CheckHeaderCellRenderer(JTable table) { + this.tableModel = (EquipmentAcquiredFromERPDialog.CheckTableModle)table.getModel(); + this.tableHeader = table.getTableHeader(); + this.selectBox = new JCheckBox(this.tableModel.getColumnName(2)); + this.selectBox.setSelected(true); + this.tableHeader.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() > 0) { + int selectColumn = EquipmentAcquiredFromERPDialog.CheckHeaderCellRenderer.this.tableHeader.columnAtPoint(e.getPoint()); + if (selectColumn == 2) { + boolean value = !EquipmentAcquiredFromERPDialog.CheckHeaderCellRenderer.this.selectBox.isSelected(); + EquipmentAcquiredFromERPDialog.CheckHeaderCellRenderer.this.selectBox.setSelected(value); + EquipmentAcquiredFromERPDialog.CheckHeaderCellRenderer.this.tableModel.selectAllOrNull(value); + EquipmentAcquiredFromERPDialog.CheckHeaderCellRenderer.this.tableHeader.repaint(); + } + } + } + }); + } + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + String valueStr = (String)value; + JLabel label = new JLabel(valueStr); + label.setHorizontalAlignment(0); + this.selectBox.setHorizontalAlignment(0); + this.selectBox.setBorderPainted(true); + JComponent component = (column == 2) ? this.selectBox : label; + component.setForeground(this.tableHeader.getForeground()); + component.setBackground(this.tableHeader.getBackground()); + component.setFont(this.tableHeader.getFont()); + component.setBorder(UIManager.getBorder("TableHeader.cellBorder")); + return component; + } + } + + private StringBuffer errorInfo = new StringBuffer("错误信息如下:"); + + private List listNotEditableRow = new ArrayList(); + + public EquipmentAcquiredFromERPDialog(TCSession pSession, TCComponentFolder ptargetFolder, Vector pVecCanImp) { + super(false); + this.session = pSession; + this.targetFolder = ptargetFolder; + this.vecCanImp = pVecCanImp; + initUI(); + } + + private void initUI() { + setTitle("导入新设备"); + this.table = new JTable() { + private static final long serialVersionUID = 1L; + + public boolean isCellEditable(int row, int column) { + if (column == 0 || column == 1) + return false; + int NotEditableRowCount = EquipmentAcquiredFromERPDialog.this.listNotEditableRow.size(); + if (NotEditableRowCount > 0) + for (int i = 0; i < NotEditableRowCount; i++) { + if (row == ((Integer)EquipmentAcquiredFromERPDialog.this.listNotEditableRow.get(i)).intValue()) + return false; + } + return true; + } + }; + Vector headerNames = new Vector(); + headerNames.add("设备编号"); + headerNames.add("设备名称"); + headerNames.add("是否导入ERP系统"); + this.table.setModel(new CheckTableModle(getData(), headerNames)); + this.table.getTableHeader().setDefaultRenderer(new CheckHeaderCellRenderer(this.table)); + int totalWidth = UtilApi.FitTableColumns(this.table); + this.btnImport = new JButton("新设备导入PLM系统"); + this.btnImport.addActionListener(this); + this.btnCancel = new JButton("取消"); + this.btnCancel.addActionListener(this); + JPanel paneButton = new JPanel(); + paneButton.add(this.btnImport); + paneButton.add(this.btnCancel); + this.scrollPane = new JScrollPane(this.table); + JPanel paneMain = new JPanel(new BorderLayout()); + paneMain.add("North", new JLabel("ERP新增设备明细如下:")); + paneMain.add("Center", this.scrollPane); + paneMain.add("South", paneButton); + getContentPane().add(paneMain); + setPreferredSize(new Dimension(totalWidth, 400)); + } + + public class CheckTableModle extends DefaultTableModel { + private static final long serialVersionUID = 1L; + + public CheckTableModle(Vector data, Vector columnNames) { + super(); + } + + public Class getColumnClass(int c) { + return getValueAt(0, c).getClass(); + } + + public void selectAllOrNull(boolean value) { + int rowNum = getRowCount(); + for (int row = 0; row < rowNum; row++) { + if (!EquipmentAcquiredFromERPDialog.this.listNotEditableRow.contains(Integer.valueOf(row))) + setValueAt(Boolean.valueOf(value), row, 2); + } + } + } + + public List getListNotEditableRow() { + return this.listNotEditableRow; + } + + public void setListNotEditableRow(List listNotEditableRow) { + this.listNotEditableRow = listNotEditableRow; + } + + private Vector getData() { + Vector data = new Vector(); + int vecSize = this.vecCanImp.size(); + for (int i = 0; i < vecSize; i++) { + Vector rowVector = new Vector(); + String[] str = ((String)this.vecCanImp.get(i)).split(","); + rowVector.add(str[0]); + rowVector.add(str[1]); + rowVector.add(Boolean.valueOf(true)); + data.add(rowVector); + } + return data; + } + + private boolean doImport() { + int rowNum = this.table.getRowCount(); + List list = (List)new ArrayList(); + for (int row = 0; row < rowNum; row++) { + if (((Boolean)this.table.getValueAt(row, 2)).booleanValue() && !this.listNotEditableRow.contains(Integer.valueOf(row))) { + String[] str = new String[3]; + str[0] = this.table.getValueAt(row, 0).toString(); + str[1] = this.table.getValueAt(row, 1).toString(); + str[2] = String.valueOf(row); + list.add(str); + } + } + if (list.size() == 0) { + MessageBox.post((Window)this, "请选择需要导入的设备", "警告", 4); + return false; + } + postDialog(list); + if (!this.errorInfo.toString().equals("错误信息如下:")) + return false; + return true; + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == this.btnImport) { + doImport(); + } else if (e.getSource() == this.btnCancel) { + dispose(); + } + } + + protected void postDialog(List list) { + SwingUtilities.invokeLater((Runnable)new ORNewEquipmentDialog(this, this.session, list, this.targetFolder)); + } +} diff --git a/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPHandler.java b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPHandler.java new file mode 100644 index 0000000..eecfd58 --- /dev/null +++ b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/EquipmentAcquiredFromERPHandler.java @@ -0,0 +1,73 @@ +package com.connor.erp.processresource.EquipmentAcquiredFromERP; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +public class EquipmentAcquiredFromERPHandler extends AbstractHandler { + private static final String NHL_ACHIEVEERPEQM_ADMIN = "NHL_AchieveERPEqM_Admin"; + + public Object execute(ExecutionEvent event) throws ExecutionException { + AbstractAIFUIApplication application = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)application.getSession(); + if (application == null || application.getTargetComponent() == null) { + MessageBox.post(application.getDesktop().getShell(), "请选中设备文件夹!!", "警告", 4); + return null; + } + String user_id = ""; + try { + user_id = session.getUser().getProperty("user_id"); + } catch (TCException e1) { + e1.printStackTrace(); + } + TCPreferenceService preferenceService = session.getPreferenceService(); + String[] users = preferenceService.getStringArray(4, "NHL_AchieveERPEqM_Admin"); + if (users != null && users.length > 0) { + int groupLen = users.length; + boolean hasRight = false; + for (int i = 0; i < groupLen; i++) { + if (user_id.equals(users[i].trim())) { + hasRight = true; + break; + } + } + if (hasRight) { + if (application.getTargetComponent() instanceof TCComponentFolder) { + TCComponentFolder targetFolder = (TCComponentFolder)application.getTargetComponent(); + try { + if (!targetFolder.getProperty("object_name").equals("设备")) { + MessageBox.post(application.getDesktop().getShell(), "请选中设备文件夹!!", "警告", 4); + return null; + } + } catch (TCException e1) { + e1.printStackTrace(); + } + try { + AbstractAIFCommand command = new EquipmentAcquiredFromERPCommand(session, application, targetFolder); + command.executeModal(); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + MessageBox.post(application.getDesktop().getShell(), "请选中设备文件夹!!", "警告", 4); + return null; + } + } else { + MessageBox.post(application.getDesktop().getShell(), "你没有权限进行当前操作", "警告", 4); + return null; + } + } else { + MessageBox.post(application.getDesktop().getShell(), "请配置首选项NHL_AchieveERPEqM_Admin!!", "警告", 4); + return null; + } + return null; + } +} diff --git a/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateClassificationPanel.java b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateClassificationPanel.java new file mode 100644 index 0000000..363a4ce --- /dev/null +++ b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateClassificationPanel.java @@ -0,0 +1,156 @@ +package com.connor.erp.processresource.EquipmentAcquiredFromERP; + +import cn.com.origin.autocode.classification.ClassificationPropertyNames; +import cn.com.origin.autocode.classification.panels.ClassificationTreeData; +import com.teamcenter.rac.aifrcp.AifrcpPlugin; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSApplicationObject; +import com.teamcenter.rac.kernel.ics.ICSHierarchyNodeDescriptor; +import java.awt.Component; +import java.net.URL; +import javax.swing.ImageIcon; +import javax.swing.JScrollPane; +import javax.swing.JTree; +import javax.swing.event.TreeExpansionEvent; +import javax.swing.event.TreeExpansionListener; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreePath; + +public class ORCreateClassificationPanel { + JScrollPane classificationPropertyPanel; + + CreateClassificationPropertyPanel createClassificationPropertyPanel; + + TCClassificationService classificationService; + + ICSApplicationObject icsapplicationobject; + + ORNewEquipmentDialog dialog; + + ClassificationTreeData treeData; + + public TCSession getSession() { + TCSession session = (TCSession)AifrcpPlugin.getSessionService().getDefaultSession(); + return session; + } + + public ORCreateClassificationPanel(ORNewEquipmentDialog dialog) { + this.classificationService = getSession().getClassificationService(); + this.dialog = dialog; + try { + this.icsapplicationobject = this.classificationService.newICSApplicationObject("ICM"); + } catch (TCException e) { + e.printStackTrace(); + } + } + + public JScrollPane createPropertyInfoPanel() { + this.createClassificationPropertyPanel = new CreateClassificationPropertyPanel(); + this.classificationPropertyPanel = this.createClassificationPropertyPanel.getPropertyPanel(); + return this.classificationPropertyPanel; + } + + public JScrollPane CreateClassificationInfoPanel(String rootID, String rootName, String type) { + JScrollPane scrollPane = new JScrollPane(); + try { + ClassificationTreeData rootTreeData = new ClassificationTreeData(rootID, rootName, type, null, null); + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(rootTreeData); + setChildrenNode(1, rootID, rootNode, rootTreeData); + DefaultTreeModel treeModel = new DefaultTreeModel(rootNode); + JTree tree = new JTree(treeModel); + tree.addTreeSelectionListener(new treeSelectedListener()); + tree.setCellRenderer(new MyRenderer()); + tree.addTreeExpansionListener(new TreeExpandedListener()); + scrollPane.setVerticalScrollBarPolicy(22); + scrollPane.setHorizontalScrollBarPolicy(32); + scrollPane.getViewport().setView(tree); + } catch (Exception e) { + e.printStackTrace(); + } + return scrollPane; + } + + private class MyRenderer extends DefaultTreeCellRenderer { + private static final long serialVersionUID = 1L; + + ImageIcon imageIcon; + + public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { + super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); + DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)value; + ClassificationTreeData treeData = (ClassificationTreeData)treeNode.getUserObject(); + setText(treeData.getName()); + String type = treeData.getType(); + URL url = null; + if (type.equals(ClassificationPropertyNames.icsGroupType)) { + url = getClass().getResource("images/inclassgroup_16.png"); + } else if (type.equals(ClassificationPropertyNames.icsAbstractType)) { + url = getClass().getResource("images/inclassabstractclass_16.png"); + } else if (type.equals(ClassificationPropertyNames.icsInstanceType)) { + url = getClass().getResource("images/inclassstorageclass_16.png"); + } + if (url != null) { + this.imageIcon = new ImageIcon(url); + setIcon(this.imageIcon); + } + return this; + } + } + + private void setChildrenNode(int expandNum, String parentIcsID, DefaultMutableTreeNode parentNode, ClassificationTreeData parentClassificationTreeData) { + ICSHierarchyNodeDescriptor[] icsnode = this.classificationService.getChildren(parentIcsID, false, true, 0, 0); + if (icsnode != null) { + expandNum++; + for (int i = 0; i < icsnode.length; i++) { + String node_id = icsnode[i].getId(); + String node_name = icsnode[i].getName(); + String type = icsnode[i].getType(); + if (icsnode[i].isStorageClass()) + type = ClassificationPropertyNames.icsInstanceType; + ClassificationTreeData classificationTreeData = new ClassificationTreeData(node_id, node_name, type, parentClassificationTreeData, null); + parentClassificationTreeData.addChildrenTreeNodes(classificationTreeData); + DefaultMutableTreeNode node = new DefaultMutableTreeNode(classificationTreeData); + parentNode.add(node); + setChildrenNode(expandNum, node_id, node, classificationTreeData); + } + } + } + + private class TreeExpandedListener implements TreeExpansionListener { + private TreeExpandedListener() {} + + public void treeCollapsed(TreeExpansionEvent treeexpansionevent) {} + + public void treeExpanded(TreeExpansionEvent treeexpansionevent) {} + } + + private class treeSelectedListener implements TreeSelectionListener { + private treeSelectedListener() {} + + public void valueChanged(TreeSelectionEvent tse) { + TreePath selectedPath = tse.getNewLeadSelectionPath(); + if (selectedPath == null) + return; + DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)selectedPath.getLastPathComponent(); + if (selectedNode == null) + return; + ORCreateClassificationPanel.this.treeData = (ClassificationTreeData)selectedNode.getUserObject(); + ORCreateClassificationPanel.this.createClassificationPropertyPanel.createPropertyPanel(ORCreateClassificationPanel.this.treeData.getName(), ORCreateClassificationPanel.this.treeData.getId()); + PackClassificationInfos classificationInfos = new PackClassificationInfos(); + classificationInfos.setIcsID(ORCreateClassificationPanel.this.treeData.getId()); + classificationInfos.setPropertyMaps(ORCreateClassificationPanel.this.createClassificationPropertyPanel.getPropertyInfos()); + classificationInfos.setNameToIdHashMap(ORCreateClassificationPanel.this.createClassificationPropertyPanel.getNameToIdPropertyInfos()); + ORCreateClassificationPanel.this.dialog.setFolderName(ORCreateClassificationPanel.this.treeData.getName()); + ORCreateClassificationPanel.this.dialog.setClassificationInfos(classificationInfos); + ORCreateClassificationPanel.this.dialog.setClassificationService(ORCreateClassificationPanel.this.createClassificationPropertyPanel.getClassificationService()); + ORCreateClassificationPanel.this.dialog.setIcsView(ORCreateClassificationPanel.this.createClassificationPropertyPanel.getICSView()); + ORCreateClassificationPanel.this.dialog.setIcsapplicationobject(ORCreateClassificationPanel.this.createClassificationPropertyPanel.getICSApplicationObject()); + } + } +} diff --git a/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateICOObj.java b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateICOObj.java new file mode 100644 index 0000000..7aac01b --- /dev/null +++ b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORCreateICOObj.java @@ -0,0 +1,159 @@ +package com.connor.erp.processresource.EquipmentAcquiredFromERP; + +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import com.teamcenter.rac.aifrcp.AifrcpPlugin; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSView; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import javax.swing.JComboBox; +import javax.swing.JTextField; + +public class ORCreateICOObj { + private TCSession session; + + private String rootICSID = "ICM"; + + private String parentICSName = ""; + + private String parentICSID = ""; + + public ORCreateICOObj() { + this.session = getSession(); + } + + public TCSession getSession() { + if (this.session == null) + this.session = (TCSession)AifrcpPlugin.getSessionService().getDefaultSession(); + return this.session; + } + + private String getClassificationNode(AbstractTreeData treeData, String icsID) { + AbstractTreeData parentNode = treeData.getParentTreeData(); + if (parentNode != null && parentNode.getPackCodeNodeInfo().getNodeComponent() != null) { + icsID = getClassificationNode(parentNode, icsID); + icsID = searchClassification(parentNode.getPackCodeNodeInfo().getNode_name(), icsID); + } + return icsID; + } + + private String getParentClassificationNode(AbstractTreeData treeData, String icsID) { + String parentICSID = getClassificationNode(treeData, icsID); + icsID = searchClassification(treeData.getPackCodeNodeInfo().getNode_name(), parentICSID); + return icsID; + } + + public void createTreeNodeICObject(AbstractTreeData parentTreeData, AbstractTreeData treeData, TCComponentItem item, Map icoPropertyMap) { + String parentICSID = getParentClassificationNode(parentTreeData, this.rootICSID); + String icsID = searchClassification(treeData.getPackCodeNodeInfo().getNode_name(), parentICSID); + if (icsID.trim().length() == 0) { + MessageBox.post("物料创建成功,但没有找到特征码为:【"+ treeData.getPackCodeNodeInfo().getNode_name() + "】的分类", "提示", 2); + return; + } + createICObject(treeData.getPackCodeNodeInfo().getNode_name(), icsID, (TCComponent)item, icoPropertyMap); + } + + public void createListNodeICObject(AbstractTreeData parentTreeData, String firstICOName, String currentICSName, TCComponentItem item, Map icoPropertyMap) { + String parentICSID = getParentClassificationNode(parentTreeData, this.rootICSID); + String icsID = searchClassification(firstICOName.trim(), parentICSID); + if (icsID.trim().length() == 0) { + MessageBox.post("物料创建成功,但没有找到特征码为:【"+ currentICSName + "】的分类", "提示", 2); + return; + } + createICObject(firstICOName, icsID, (TCComponent)item, icoPropertyMap); + } + + public boolean createICObject(ICSView icsView, PackClassificationInfos classificationInfos, TCComponent item) { + if (classificationInfos == null) + classificationInfos = new PackClassificationInfos(); + HashMap propHashMap = classificationInfos.getPropertyMaps(); + HashMap nameToIdHashMap = classificationInfos.getNameToIdHashMap(); + HashMap propHashMap2 = new HashMap(); + HashMap propHashMap3 = new HashMap(); + String icsId = classificationInfos.getIcsID(); + if (propHashMap != null) { + Set propSet = propHashMap.keySet(); + Object[] keys = propSet.toArray(); + for (int i = 0; i < keys.length; i++) { + if (keys[i] != null && keys[i].toString().trim().length() > 0) { + Object propComponent = propHashMap.get(keys[i]); + String value = ""; + if (propComponent instanceof JTextField) { + value = ((JTextField)propComponent).getText(); + } else if (propComponent instanceof JComboBox) { + value = ((JComboBox)propComponent).getSelectedItem().toString(); + if (value == null) + continue; + String[] values = value.trim().split(" "); + if (values.length == 3) + value = values[0]; + } else if (propComponent instanceof DateButton) { + value = ((DateButton)propComponent).getDate().toString(); + } + if (value != null) { + propHashMap2.put((String)keys[i], value); + propHashMap3.put(nameToIdHashMap.get(keys[i]), value); + } + } + continue; + } + } + classificationInfos.setPropertyMaps2(propHashMap3); + try { + boolean isSuccess = false; + if (propHashMap2 == null || propHashMap2.size() == 0) { + String[] names = new String[0]; + String[] values = new String[0]; + isSuccess = (new ORSendToIcsOperation()).sendItemToClassification((TCComponentItem)item, icsId, (Object[])names, values); + } else { + Set set = propHashMap2.keySet(); + Object[] names = set.toArray(); + String[] values = new String[names.length]; + for (int i = 0; i < names.length; i++) + values[i] = (String)propHashMap2.get(names[i]); + isSuccess = (new ORSendToIcsOperation()).sendItemToClassification((TCComponentItem)item, icsId, names, values); + } + if (!isSuccess) + return false; + } catch (Exception e1) { + e1.printStackTrace(); + MessageBox.post("物料创建成功,但对象发送到分类失败!", "提示", 2); + return false; + } + return true; + } + + public void createICObject(String currentICSName, String icsId, TCComponent item, Map icoPropertyMap) { + try { + if (icoPropertyMap.size() == 0 || icoPropertyMap == null) { + String[] names = new String[0]; + String[] values = new String[0]; + (new ORSendToIcsOperation()).sendItemToClassification((TCComponentItem)item, icsId, (Object[])names, values); + } else { + Set set = icoPropertyMap.keySet(); + Object[] names = set.toArray(); + String[] values = new String[names.length]; + for (int i = 0; i < names.length; i++) + values[i] = icoPropertyMap.get(names[i]); + (new ORSendToIcsOperation()).sendItemToClassification((TCComponentItem)item, icsId, names, values); + } + } catch (Exception e1) { + e1.printStackTrace(); + MessageBox.post("物料创建成功,但对象发送到分类失败!", "提示", 2); + } + } + + public String searchClassification(String icsName, String rootId) { + String icsId = (new ORSendToIcsOperation()).getClassificationByName(rootId, icsName); + if (this.parentICSName.equals(icsName) && icsId.trim().length() == 0) + icsId = this.parentICSID; + this.parentICSName = icsName; + this.parentICSID = icsId; + return icsId; + } +} diff --git a/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORNewEquipmentDialog.java b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORNewEquipmentDialog.java new file mode 100644 index 0000000..9425eb8 --- /dev/null +++ b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORNewEquipmentDialog.java @@ -0,0 +1,544 @@ +package com.connor.erp.processresource.EquipmentAcquiredFromERP; + +import cn.com.origin.autocode.classification.ClassificationPropertyNames; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.commands.newitem.NewItemDialog; +import com.teamcenter.rac.commands.newitem.NewItemPanel; +import com.teamcenter.rac.common.TCConstants; +import com.teamcenter.rac.common.controls.LOVUIComponent; +import com.teamcenter.rac.kernel.ItemValidationInfo; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSApplicationObject; +import com.teamcenter.rac.kernel.ics.ICSView; +import com.teamcenter.rac.util.FilterDocument; +import com.teamcenter.rac.util.HorizontalLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Registry; +import com.teamcenter.rac.util.Separator; +import com.teamcenter.rac.util.VerticalLayout; +import com.teamcenter.rac.util.iTextArea; +import com.teamcenter.rac.util.iTextField; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.LayoutManager; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.border.TitledBorder; +import javax.swing.text.Document; + +public class ORNewEquipmentDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + + public Frame parentFrame; + + public TCSession session; + + public NewItemPanel itemPanel; + + public JPanel textPanel; + + public JPanel itemInfoPanel; + + public JPanel namingAndNumberingPanel; + + public JPanel itemIdPanel; + + public JPanel revisionIdPanel; + + public JComboBox itemIdCombobox; + + public JComboBox revisionIdCombobox; + + public JPanel revIdPanel; + + public JPanel namePanel; + + public JPanel otherPropertyPanel; + + public JPanel nonPropertiesPanel; + + public JLabel infoLabel; + + public JLabel itemLabel; + + public JLabel descLabel; + + public JLabel uomLabel; + + public iTextField idTextField; + + public iTextField revTextField; + + public iTextField nameTextField; + + public LOVUIComponent nameLOVUI; + + public iTextArea descTextArea; + + public JScrollPane descScrollPane; + + public LOVUIComponent uomLovComboBox; + + public iTextField uomTextField; + + public JCheckBox classifyCheckBox; + + public TCComponentType[] preLoadTypes; + + public ItemValidationInfo valObj; + + public String classifyPref; + + public String classifyNewPref; + + public String[] classifiableTypes; + + public String allowCopyAsRevisionPref; + + public String idRevSeparator; + + public String revNameSeparator; + + public static final String IDREV_SEPARATOR_PREF = "FLColumnCatIVFSeparatorPref"; + + public static final String REVNAME_SEPARATOR_PREF = "FLColumnCatObjSeparatorPref"; + + public static final String DISPLAY_ITEM_ID_NAME_MAX_COLUMNS_PREF = "TC_UI_DisplayMaxColumnsForItemIDNameFields"; + + public static final String ICS_CLASSIFY_NEW = "ICS_classify_new"; + + public static final String CLASSIFY_IMMEDIATE_PREFERENCE = "ICS_classify_immediately"; + + public static final String ICS_CLASSIFIABLE_TYPES = "ICS_classifiable_types"; + + public static final String CLASSIFY_ON = "1"; + + public static final String CLASSIFY_OFF = "0"; + + public boolean showUOM; + + public boolean showQuantity; + + private boolean displayMaxColumnsForItemIDNameFields; + + public JPanel quantityPanel; + + protected Registry packageReg; + + public static final String PROPERTY_ITEM_ID = "item_id"; + + public static final String PROPERTY_ITEM_REVISION_ID = "item_revision_id"; + + public static final String PROPERTY_OBJECT_NAME = "object_name"; + + public static final String PROPERTY_OBJECT_DESCRIPTION = "object_desc"; + + public static final String PROPERTY_UOM = "uom_tag"; + + public static final String PROPERTY_OBJECT_TYPE = "object_type"; + + protected boolean revDescRequired; + + public boolean isRevRuleAttached; + + private JSplitPane classificationPanel; + + private JScrollPane tclassificationScrollPane; + + public JButton finishButton; + + public JButton closeButton; + + private JPanel buttonPanel; + + private PackClassificationInfos classificationInfos = null; + + private ICSApplicationObject icsapplicationobject; + + private ICSView icsView; + + private TCClassificationService classificationService; + + private List list; + + private TCComponentItemType item_type; + + private TCComponentFolder equipmentFolder; + + private String folderName = null; + + private EquipmentAcquiredFromERPDialog dialog; + + private ORCreateClassificationPanel createClassificationPanel; + + private String origin_classificationMatchItemProperties = "origin_classificationMatchItemProperties"; + + public ORNewEquipmentDialog(EquipmentAcquiredFromERPDialog dialog, TCSession session, List list, TCComponentFolder equipmentFolder) { + super(true); + this.session = session; + this.list = list; + this.equipmentFolder = equipmentFolder; + this.dialog = dialog; + initUI(); + } + + public void initUI() { + this.packageReg = Registry.getRegistry(NewItemDialog.class); + setTitle("新建设备"); + getPreferenceSettings(); + JPanel mainPanel = new JPanel(); + setLayout(new BorderLayout()); + mainPanel.setLayout((LayoutManager)new VerticalLayout(5, 2, 2, 2, 2)); + JLabel infoLabel = new JLabel(getPageTitle(), getPageIcon(), 2); + infoLabel.setForeground(Color.BLUE); + buildBaseItemInfoPanel(); + this.otherPropertyPanel = buildStaticPropertiesPanel(); + mainPanel.add("top.bind.left.top", infoLabel); + mainPanel.add("top.bind", (Component)new Separator()); + mainPanel.add("top.bind.left.top", this.itemInfoPanel); + mainPanel.add("top.bind.left.top", this.otherPropertyPanel); + this.classificationPanel = buildItemClassficationPanel(); + this.tclassificationScrollPane = new JScrollPane(); + this.tclassificationScrollPane.setHorizontalScrollBarPolicy(32); + this.tclassificationScrollPane.setVerticalScrollBarPolicy(22); + this.tclassificationScrollPane.getViewport().setView(this.classificationPanel); + Dimension dimension = this.classificationPanel.getPreferredSize(); + this.tclassificationScrollPane.setPreferredSize(new Dimension(dimension.width, dimension.height)); + buildButtonPanel(); + mainPanel.add("top.bind.left.top", this.tclassificationScrollPane); + add("Center", mainPanel); + add("South", this.buttonPanel); + setPreferredSize(new Dimension(700, 600)); + pack(); + validate(); + centerToScreen(); + } + + public String getPageTitle() { + String s = getClass().getName() + "." + "TITLE"; + String s1 = this.packageReg.getString(s, null); + if (s1 == null || s1.length() <= 0) + s1 = this.packageReg.getString("itemInfo.LABEL"); + return s1; + } + + public Icon getPageIcon() { + String s = getClass().getName() + "." + "ICON"; + ImageIcon imageicon = this.packageReg.getImageIcon(s, null); + if (imageicon == null) + imageicon = this.packageReg.getImageIcon("info.ICON"); + return imageicon; + } + + public void buildButtonPanel() { + this.buttonPanel = new JPanel(); + this.finishButton = new JButton("完成"); + this.finishButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + List listFolder = new ArrayList(); + if (ORNewEquipmentDialog.this.folderName != null) { + ORNewEquipmentDialog.this.getFolder(ORNewEquipmentDialog.this.equipmentFolder, listFolder, ORNewEquipmentDialog.this.folderName); + } else { + MessageBox.post((Window)ORNewEquipmentDialog.this, "请选择要发送的分类对象", "警告", 1); + return; + } + int folderSize = listFolder.size(); + if (folderSize == 0) { + MessageBox.post((Window)ORNewEquipmentDialog.this, "未找到"+ ORNewEquipmentDialog.this.folderName + "文件夹!", "出现问题", 1); + return; + } + if (folderSize > 1) { + MessageBox.post((Window)ORNewEquipmentDialog.this, "找到多个"+ ORNewEquipmentDialog.this.folderName + "文件夹!", "出现问题", 1); + return; + } + TCComponentItem item = null; + try { + item = ORNewEquipmentDialog.this.item_type.create(ORNewEquipmentDialog.this.idTextField.getText(), ORNewEquipmentDialog.this.revTextField.getText(), "NHL8_Equipments", ORNewEquipmentDialog.this.nameTextField.getText(), ORNewEquipmentDialog.this.descTextArea.getText(), null); + } catch (TCException e2) { + e2.printStackTrace(); + } + if (item != null) { + TCComponentFolder parentFolder = listFolder.get(0); + try { + parentFolder.add("contents", (TCComponent)item); + parentFolder.refresh(); + } catch (TCException e1) { + e1.printStackTrace(); + } + boolean isSuccess = false; + HashMap icsPorpertyMap = null; + if (ORNewEquipmentDialog.this.classificationInfos != null) { + isSuccess = (new ORCreateICOObj()).createICObject(ORNewEquipmentDialog.this.getIcsView(), ORNewEquipmentDialog.this.classificationInfos, (TCComponent)item); + icsPorpertyMap = ORNewEquipmentDialog.this.classificationInfos.getPropertyMaps2(); + } + if (isSuccess) { + ORNewEquipmentDialog.this.dialog.getListNotEditableRow().add(Integer.valueOf(Integer.parseInt(((String[])ORNewEquipmentDialog.this.list.get(0))[2]))); + ORNewEquipmentDialog.this.list.remove(0); + if (ORNewEquipmentDialog.this.list.size() > 0) { + ORNewEquipmentDialog.this.idTextField.setText("NHLM" + ((String[])ORNewEquipmentDialog.this.list.get(0))[0]); + ORNewEquipmentDialog.this.nameTextField.setText(((String[])ORNewEquipmentDialog.this.list.get(0))[1]); + ORNewEquipmentDialog.this.setRevMasterProperties(item, icsPorpertyMap); + MessageBox.post((Window)ORNewEquipmentDialog.this, item + "创建成功!", "成功", 2); + } else { + ORNewEquipmentDialog.this.setRevMasterProperties(item, icsPorpertyMap); + ORNewEquipmentDialog.this.dispose(); + MessageBox.post((Window)ORNewEquipmentDialog.this, "所选设备全部创建成功!", "成功", 2); + return; + } + } + } + } + }); + this.closeButton = new JButton("关闭"); + this.closeButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + ORNewEquipmentDialog.this.dispose(); + } + }); + this.buttonPanel.add(this.finishButton); + this.buttonPanel.add(this.closeButton); + } + + public void setRevMasterProperties(TCComponentItem item, HashMap icsPorpertyMap) { + HashMap cfghm = TCPreferenceUitl.getPreferenceHashMap(this.session, 0, this.origin_classificationMatchItemProperties); + if (cfghm == null) + return; + String revisionMasterProps = cfghm.get("NHL8_Equipments_RevisionMaster"); + if (revisionMasterProps != null && revisionMasterProps.length() > 0) { + TCComponentForm form = null; + try { + form = (TCComponentForm)item.getLatestItemRevision().getRelatedComponent("IMAN_master_form_rev"); + } catch (TCException e2) { + e2.printStackTrace(); + } + String[] str1 = revisionMasterProps.split(";"); + Map propMap = new HashMap(); + for (int i = 0; i < str1.length; i++) { + String[] str2 = str1[i].split("&&"); + propMap.put(str2[1], icsPorpertyMap.get(Integer.valueOf(str2[0]))); + } + try { + form.setProperties(propMap); + form.save(); + form.refresh(); + } catch (TCException e1) { + e1.printStackTrace(); + } + } + } + + public void getFolder(TCComponentFolder parentFolder, List listFolder, String folderName) { + try { + AIFComponentContext[] children = parentFolder.getChildren(); + int childCount = children.length; + for (int i = 0; i < childCount; i++) { + if (children[i].getComponent() instanceof TCComponentFolder) { + TCComponentFolder childFolder = (TCComponentFolder)children[i].getComponent(); + try { + if (children[i].getComponent().getProperty("object_name").equals(folderName)) + listFolder.add(childFolder); + } catch (Exception e) { + e.printStackTrace(); + } + getFolder(childFolder, listFolder, folderName); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + public void buildBaseItemInfoPanel() { + String s = this.packageReg.getString("itemId") + " " + this.idRevSeparator + " " + this.packageReg.getString("rev") + " " + this.revNameSeparator + " " + this.packageReg.getString("name"); + this.itemLabel = new JLabel(s); + String s1 = TCSession.getServerEncodingName(this.session); + FilterDocument filterdocument = new FilterDocument(TCConstants.getDefaultMaxNameSize(this.session), s1); + this.idTextField = new iTextField((Document)filterdocument, "", this.displayMaxColumnsForItemIDNameFields ? 32 : 15, TCConstants.getDefaultMaxNameSize(this.session), true, null); + filterdocument = new FilterDocument(32, s1); + this.revTextField = new iTextField((Document)filterdocument, "", 5, 32, true, null); + filterdocument = new FilterDocument(TCConstants.getDefaultMaxNameSize(this.session), s1); + this.nameTextField = new iTextField((Document)filterdocument, "", this.displayMaxColumnsForItemIDNameFields ? 32 : 10, TCConstants.getDefaultMaxNameSize(this.session), true, null); + this.namePanel = new JPanel((LayoutManager)new HorizontalLayout()); + if (this.list.size() > 0) { + this.idTextField.setText("NHLM" + ((String[])this.list.get(0))[0]); + this.idTextField.setEnabled(false); + try { + this.item_type = (TCComponentItemType)this.session.getTypeComponent("NHL8_Equipments"); + this.revTextField.setText(this.item_type.getNewRev(null)); + } catch (TCException e1) { + e1.printStackTrace(); + } + this.revTextField.setEnabled(false); + this.nameTextField.setText(((String[])this.list.get(0))[1]); + this.nameTextField.setEnabled(false); + } + this.namePanel.add("unbound.bind.left.center", (Component)this.nameTextField); + this.revIdPanel = new JPanel((LayoutManager)new HorizontalLayout()); + this.revIdPanel.add("left.bind.left.center", (Component)this.revTextField); + this.textPanel = new JPanel((LayoutManager)new HorizontalLayout()); + this.textPanel.add("left.nobind", (Component)this.idTextField); + this.textPanel.add("left", new JLabel(this.idRevSeparator)); + this.textPanel.add("left.nobind", this.revIdPanel); + this.textPanel.add("left", new JLabel(this.revNameSeparator)); + this.textPanel.add("unbound.bind", this.namePanel); + this.itemIdCombobox = new JComboBox(); + Dimension dimension = new Dimension(100, 20); + this.itemIdCombobox.setPreferredSize(dimension); + this.itemIdCombobox.setSelectedIndex(-1); + this.itemIdPanel = new JPanel((LayoutManager)new HorizontalLayout()); + this.itemIdPanel.add("left", new JLabel(this.packageReg.getString("itemId"))); + this.itemIdPanel.add("left", this.itemIdCombobox); + this.revisionIdCombobox = new JComboBox(); + this.revisionIdCombobox.setPreferredSize(dimension); + this.revisionIdCombobox.setSelectedIndex(-1); + this.revisionIdPanel = new JPanel((LayoutManager)new HorizontalLayout()); + this.revisionIdPanel.add("left", new JLabel(this.packageReg.getString("rev"))); + this.revisionIdPanel.add("left", this.revisionIdCombobox); + this.itemInfoPanel = new JPanel((LayoutManager)new VerticalLayout()); + this.itemInfoPanel.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), this.packageReg.getString("itemInformation"))); + this.itemInfoPanel.add("top", this.itemLabel); + this.itemInfoPanel.add("top.bind", this.textPanel); + } + + public void getPreferenceSettings() { + TCPreferenceService tcpreferenceservice = this.session.getPreferenceService(); + int[] ai = { 0, 0, 4, 4, 4 }; + String[] as = { "FLColumnCatIVFSeparatorPref", "FLColumnCatObjSeparatorPref", "ICS_classify_new", "ICS_classify_immediately", "TC_UI_DisplayMaxColumnsForItemIDNameFields" }; + String[] as1 = tcpreferenceservice.getStrings(ai, as); + if (as1 != null && as1.length > 0) { + this.idRevSeparator = as1[0]; + } else { + this.idRevSeparator = tcpreferenceservice.getString(0, "FLColumnCatIVFSeparatorPref"); + } + if (as1 != null && as1.length > 1) { + this.revNameSeparator = as1[1]; + } else { + this.revNameSeparator = tcpreferenceservice.getString(0, "FLColumnCatObjSeparatorPref"); + } + if (as1 != null && as1.length > 2) { + this.classifyNewPref = as1[2]; + } else { + this.classifyNewPref = tcpreferenceservice.getString(4, "ICS_classify_new"); + } + if (as1 != null && as1.length > 3) { + this.classifyPref = as1[3]; + } else { + this.classifyPref = tcpreferenceservice.getString(4, "ICS_classify_immediately"); + } + this.displayMaxColumnsForItemIDNameFields = tcpreferenceservice.isTrue(4, "TC_UI_DisplayMaxColumnsForItemIDNameFields"); + this.allowCopyAsRevisionPref = tcpreferenceservice.getString(3, "Allow_Copy_As_Revision"); + this.classifiableTypes = tcpreferenceservice.getStringArray(4, "ICS_classifiable_types", null); + } + + public JPanel buildStaticPropertiesPanel() { + String s = TCSession.getServerEncodingName(this.session); + this.descLabel = new JLabel(this.packageReg.getString("description")); + FilterDocument filterdocument = new FilterDocument(240, s); + this.descTextArea = new iTextArea((Document)filterdocument, "", 3, 30, 240, false, null); + this.descTextArea.setLineWrap(true); + this.descTextArea.setWrapStyleWord(true); + this.descScrollPane = new JScrollPane((Component)this.descTextArea); + this.uomLabel = new JLabel(this.packageReg.getString("unitOfMeasure")); + this.uomTextField = new iTextField(); + this.uomTextField.setText("每个"); + this.uomTextField.setEnabled(false); + JPanel jpanel = new JPanel((LayoutManager)new PropertyLayout()); + jpanel.add("1.1.left.top", this.descLabel); + jpanel.add("1.2.center.center.resizable.resizable", this.descScrollPane); + jpanel.add("2.1.right.top", this.uomLabel); + jpanel.add("2.2", (Component)this.uomTextField); + return jpanel; + } + + public JSplitPane buildItemClassficationPanel() { + JSplitPane jsp = new JSplitPane(); + this.createClassificationPanel = new ORCreateClassificationPanel(this); + try { + JScrollPane treePanel = this.createClassificationPanel.CreateClassificationInfoPanel("ICM", "Classification root", ClassificationPropertyNames.icsGroupType); + JScrollPane propertyPanel = this.createClassificationPanel.createPropertyInfoPanel(); + jsp.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "请选择分类")); + jsp.setOrientation(1); + jsp.setDividerLocation(0.5D); + jsp.setDividerSize(7); + jsp.setLeftComponent(treePanel); + jsp.setRightComponent(propertyPanel); + jsp.setAutoscrolls(true); + } catch (Exception e) { + e.printStackTrace(); + } + return jsp; + } + + public PackClassificationInfos getClassificationInfos() { + return this.classificationInfos; + } + + public void setClassificationInfos(PackClassificationInfos classificationInfos) { + this.classificationInfos = classificationInfos; + } + + public ICSApplicationObject getIcsapplicationobject() { + return this.icsapplicationobject; + } + + public void setIcsapplicationobject(ICSApplicationObject icsapplicationobject) { + this.icsapplicationobject = icsapplicationobject; + } + + public ICSView getIcsView() { + return this.icsView; + } + + public void setIcsView(ICSView icsView) { + this.icsView = icsView; + } + + public TCClassificationService getClassificationService() { + return this.classificationService; + } + + public void setClassificationService(TCClassificationService classificationService) { + this.classificationService = classificationService; + } + + public static long getSerialVersionUID() { + return 1L; + } + + public String getFolderName() { + return this.folderName; + } + + public void setFolderName(String folderName) { + this.folderName = folderName; + } +} diff --git a/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORSendToIcsOperation.java b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORSendToIcsOperation.java new file mode 100644 index 0000000..4b50089 --- /dev/null +++ b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/ORSendToIcsOperation.java @@ -0,0 +1,58 @@ +package com.connor.erp.processresource.EquipmentAcquiredFromERP; + +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; + +public class ORSendToIcsOperation { + private TCUserService userService; + + private TCSession session = null; + + public String parentStr = ""; + + public ORSendToIcsOperation() { + this.session = (TCSession)AIFUtility.getCurrentApplication().getSession(); + try { + this.userService = this.session.getUserService(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public boolean sendItemToClassification(TCComponentItem item, String icsID, Object[] names, String[] values) { + try { + if (icsID == null || icsID.length() == 0) { + MessageBox.post("物料创建成功,未找到对应分类节点!", "提示", 2); + return false; + } + if (item == null) + return false; + Object[] params = { item, icsID, names, values }; + Object returnValue = this.userService.call("sendItemToClassification", params); + if (returnValue.equals("isAbstract")) { + MessageBox.post("所选节点为抽象类,发送到分类失败!", "提示", 2); + return false; + } + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post("物料创建成功但发送分类出错", "提示", 2); + return false; + } + return true; + } + + public String getClassificationByName(String parentID, String childName) { + String returnValue = ""; + try { + Object[] params = { parentID, childName }; + Object obj = this.userService.call("getClassificationID", params); + returnValue = obj.toString(); + } catch (Exception e) { + e.printStackTrace(); + } + return returnValue; + } +} diff --git a/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/PackClassificationInfos.java b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/PackClassificationInfos.java new file mode 100644 index 0000000..9bd5529 --- /dev/null +++ b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/PackClassificationInfos.java @@ -0,0 +1,45 @@ +package com.connor.erp.processresource.EquipmentAcquiredFromERP; + +import java.util.HashMap; + +public class PackClassificationInfos { + private String icsID = ""; + + private HashMap propertyMaps; + + private HashMap propertyMaps2; + + private HashMap nameToIdHashMap; + + public String getIcsID() { + return this.icsID; + } + + public void setIcsID(String icsID) { + this.icsID = icsID; + } + + public HashMap getPropertyMaps() { + return this.propertyMaps; + } + + public void setPropertyMaps(HashMap propertyMaps) { + this.propertyMaps = propertyMaps; + } + + public HashMap getNameToIdHashMap() { + return this.nameToIdHashMap; + } + + public void setNameToIdHashMap(HashMap nameToIdHashMap) { + this.nameToIdHashMap = nameToIdHashMap; + } + + public HashMap getPropertyMaps2() { + return this.propertyMaps2; + } + + public void setPropertyMaps2(HashMap propertyMaps2) { + this.propertyMaps2 = propertyMaps2; + } +} diff --git a/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/TCPreferenceUitl.java b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/TCPreferenceUitl.java new file mode 100644 index 0000000..47508cf --- /dev/null +++ b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/TCPreferenceUitl.java @@ -0,0 +1,117 @@ +package com.connor.erp.processresource.EquipmentAcquiredFromERP; + +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Vector; + +public class TCPreferenceUitl { + public String getEnv(String name) { + String str = ""; + Iterator> it = System.getenv().entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + if (entry.getKey().toString().equals(name)) { + str = (String)entry.getValue(); + if (!str.endsWith("\\")) + str = String.valueOf(str) + "\\"; + break; + } + } + return str; + } + + public static boolean isSelectExsitToTCPreferenceValues(TCSession tcsession, String preferenceName, String isSelectName) { + boolean flag = false; + TCPreferenceService preferenceService = tcsession.getPreferenceService(); + String[] preferenceValues = preferenceService.getStringArray(4, preferenceName); + if (preferenceValues == null) + return false; + if (preferenceValues != null && preferenceValues.length > 0) + for (int i = 0; i < preferenceValues.length; i++) { + if (preferenceValues[i].trim().equals(isSelectName)) { + flag = true; + return flag; + } + } + return flag; + } + + private static boolean isWriteExpire = false; + + public static synchronized boolean isWriteExpire() { + return isWriteExpire; + } + + public static synchronized void setWriteExpire(boolean isWriteExpire) { + TCPreferenceUitl.isWriteExpire = isWriteExpire; + } + + public static boolean isTrueTCPreferenceValue(TCSession tcsession, String preferenceName) { + boolean flag = false; + TCPreferenceService preferenceService = tcsession.getPreferenceService(); + String value = preferenceService.getString(4, preferenceName); + if (value == null) + return false; + if (value.equalsIgnoreCase("true")) + flag = true; + return flag; + } + + public static String getTCPreferenceValue(TCSession tcsession, String preferenceName) { + TCPreferenceService preferenceService = tcsession.getPreferenceService(); + String value = preferenceService.getString(4, preferenceName); + return value; + } + + public static String[] getListPreference(TCSession session, int scope, String pid) { + try { + String[] options = session.getPreferenceService().getStringArray(scope, pid); + return options; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public static HashMap getPreferenceHashMap(TCSession pSession, int pScope, String pid) { + HashMap hm = new HashMap(); + Vector preferencekeyNames = new Vector(); + try { + String[] options = getPreference(pSession, pScope, pid); + if (options == null) + return hm; + if (options == null || options.length == 0) + return null; + String key = ""; + String value = ""; + for (int i = 0; i < options.length; i++) { + if (options[i].indexOf("=") > 0) { + key = options[i].substring(0, options[i].indexOf("=")); + value = options[i].substring(options[i].indexOf("=") + 1); + hm.put(key, value); + preferencekeyNames.add(key); + } else { + hm.put(i+"", options[i]); + } + } + } catch (Exception e) { + e.printStackTrace(); + return null; + } + return hm; + } + + public static String[] getPreference(TCSession session, int scope, String pid) { + try { + String[] options = session.getPreferenceService().getStringArray(scope, pid); + return options; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } +} diff --git a/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/image/inclassabstractclass_16.png b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/image/inclassabstractclass_16.png new file mode 100644 index 0000000..d28e0f0 Binary files /dev/null and b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/image/inclassabstractclass_16.png differ diff --git a/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/image/inclassgroup_16.png b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/image/inclassgroup_16.png new file mode 100644 index 0000000..3f39188 Binary files /dev/null and b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/image/inclassgroup_16.png differ diff --git a/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/image/inclassstorageclass_16.png b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/image/inclassstorageclass_16.png new file mode 100644 index 0000000..780fcdb Binary files /dev/null and b/src/com/connor/erp/processresource/EquipmentAcquiredFromERP/image/inclassstorageclass_16.png differ diff --git a/src/com/connor/erp/searchImpResult/DateChooser.java b/src/com/connor/erp/searchImpResult/DateChooser.java new file mode 100644 index 0000000..1b40746 --- /dev/null +++ b/src/com/connor/erp/searchImpResult/DateChooser.java @@ -0,0 +1,1391 @@ +package com.connor.erp.searchImpResult; + +import java.awt.BasicStroke; + +import java.awt.BorderLayout; + +import java.awt.Color; + +import java.awt.Component; + +import java.awt.Cursor; + +import java.awt.Dimension; + +import java.awt.Font; + +import java.awt.Graphics; + +import java.awt.Graphics2D; + +import java.awt.GridLayout; + +import java.awt.Point; + +import java.awt.Polygon; + +import java.awt.Stroke; + +import java.awt.Toolkit; + +import java.awt.event.FocusEvent; + +import java.awt.event.FocusListener; + +import java.awt.event.MouseAdapter; + +import java.awt.event.MouseEvent; + +import java.awt.event.MouseListener; + +import java.awt.event.MouseMotionListener; + +import java.text.SimpleDateFormat; + +import java.util.ArrayList; + +import java.util.Calendar; + +import java.util.Comparator; + +import java.util.Date; + +import java.util.List; + + + +import javax.swing.BorderFactory; + +import javax.swing.JComponent; + +import javax.swing.JFrame; + +import javax.swing.JLabel; + +import javax.swing.JPanel; + +import javax.swing.JTextField; + +import javax.swing.Popup; + +import javax.swing.PopupFactory; + +import javax.swing.SwingUtilities; + +import javax.swing.event.AncestorEvent; + +import javax.swing.event.AncestorListener; + + + +/** + + * 日期选择器,可以指定日期的显示格式 + + */ + +public class DateChooser extends JPanel { + + + + private static final long serialVersionUID = 4529266044762990227L; + + + + private Date initDate; + + private Calendar now = Calendar.getInstance(); + + private Calendar select; + + private JPanel monthPanel;//月历 + + private JP1 jp1;//四块面板,组成 + + private JP2 jp2; + + private JP3 jp3; + + private JP4 jp4; + + private Font font = new Font("宋体", Font.PLAIN, 12); + + private final LabelManager lm = new LabelManager(); + + private SimpleDateFormat sdf; + + private boolean isShow = false; + + private Popup pop; + + + + private JComponent showDate; + + + + public static DateChooser getInstance() { + + return new DateChooser(); + + } + + + + public static DateChooser getInstance(Date date) { + + return new DateChooser(date); + + } + + + + public static DateChooser getInstance(String format) { + + return new DateChooser(format); + + } + + + + public static DateChooser getInstance(Date date, String format) { + + return new DateChooser(date, format); + + } + + + + /** + + * Creates a new instance of DateChooser + + */ + + private DateChooser() { + + this(new Date()); + + } + + + + private DateChooser(Date date) { + + this(date, "yyyy年MM月dd日"); + + } + + + + private DateChooser(String format) { + + this(new Date(), format); + + } + + + + private DateChooser(Date date, String format) { + + initDate = date; + + sdf = new SimpleDateFormat(format); + + select = Calendar.getInstance(); + + select.setTime(initDate); + + initPanel(); + + } + + + + /** + + * 是否允许用户选择 + + */ + + public void setEnabled(boolean b) { + + super.setEnabled(b); + + showDate.setEnabled(b); + + } + + + + /** + + *得到当前选择框的日期 + + */ + + public Date getDate() { + + return select.getTime(); + + } + + + + public String getStrDate() { + + return sdf.format(select.getTime()); + + } + + + + public String getStrDate(String format) { + + sdf = new SimpleDateFormat(format); + + return sdf.format(select.getTime()); + + } + + + + //根据初始化的日期,初始化面板 + + private void initPanel() { + + monthPanel = new JPanel(new BorderLayout()); + + monthPanel.setBorder(BorderFactory.createLineBorder(Color.BLUE)); + + JPanel up = new JPanel(new BorderLayout()); + + up.add(jp1 = new JP1(), BorderLayout.NORTH); + + up.add(jp2 = new JP2(), BorderLayout.CENTER); + + monthPanel.add(jp3 = new JP3(), BorderLayout.CENTER); + + monthPanel.add(up, BorderLayout.NORTH); + + monthPanel.add(jp4 = new JP4(), BorderLayout.SOUTH); + + this.addAncestorListener(new AncestorListener() { + + public void ancestorAdded(AncestorEvent event) { + + + + } + + + + public void ancestorRemoved(AncestorEvent event) { + + + + } + + + + //只要祖先组件一移动,马上就让popup消失 + + public void ancestorMoved(AncestorEvent event) { + + hidePanel(); + + } + + }); + + } + + + + public void register(final JComponent showDate) { + + this.showDate = showDate; + + + + showDate.setRequestFocusEnabled(true); + + showDate.addMouseListener(new MouseAdapter() { + + public void mousePressed(MouseEvent me) { + + showDate.requestFocusInWindow(); + + } + + }); + + this.setBackground(Color.WHITE); + + this.add(showDate, BorderLayout.CENTER); + + this.setPreferredSize(new Dimension(90, 25)); + + this.setBorder(BorderFactory.createLineBorder(Color.GRAY)); + + showDate.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + if (showDate.isEnabled()) { + + showDate.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + showDate.setForeground(Color.RED); + + } + + } + + + + public void mouseExited(MouseEvent me) { + + if (showDate.isEnabled()) { + + showDate.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + showDate.setForeground(Color.BLACK); + + } + + } + + + + public void mousePressed(MouseEvent me) { + + if (showDate.isEnabled()) { + + showDate.setForeground(Color.CYAN); + + if (isShow) { + + hidePanel(); + + } else { + + showPanel(showDate); + + } + + } + + } + + + + public void mouseReleased(MouseEvent me) { + + if (showDate.isEnabled()) { + + showDate.setForeground(Color.BLACK); + + } + + } + + }); + + showDate.addFocusListener(new FocusListener() { + + public void focusLost(FocusEvent e) { + + hidePanel(); + + } + + + + public void focusGained(FocusEvent e) { + + + + } + + }); + + } + + + + //根据新的日期刷新 + + private void refresh() { + + jp1.updateDate(); + + jp2.updateDate(); + + jp3.updateDate(); + + jp4.updateDate(); + + SwingUtilities.updateComponentTreeUI(this); + + } + + + + //提交日期 + + private void commit() { + + //TODO add other components here + + if (showDate instanceof JTextField) { + + ((JTextField) showDate).setText(sdf.format(select.getTime())); + + }else if (showDate instanceof JLabel) { + + ((JLabel) showDate).setText(sdf.format(select.getTime())); + + } + + + + hidePanel(); + + } + + + + //隐藏日期选择面板 + + private void hidePanel() { + + if (pop != null) { + + isShow = false; + + pop.hide(); + + pop = null; + + } + + } + + + + //显示日期选择面板 + + private void showPanel(Component owner) { + + if (pop != null) { + + pop.hide(); + + } + + Point show = new Point(0, showDate.getHeight()); + + SwingUtilities.convertPointToScreen(show, showDate); + + Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); + + int x = show.x; + + int y = show.y; + + if (x < 0) { + + x = 0; + + } + + if (x > size.width - 295) { + + x = size.width - 295; + + } + + if (y < size.height - 170) { + + } else { + + y -= 188; + + } + + pop = PopupFactory.getSharedInstance().getPopup(owner, monthPanel, x, y); + + pop.show(); + + isShow = true; + + } + + + + /** + + * 最上面的面板用来显示月份的增减 + + */ + + private class JP1 extends JPanel { + + private static final long serialVersionUID = -5638853772805561174L; + + JLabel yearleft, yearright, monthleft, monthright, center, centercontainer; + + + + public JP1() { + + super(new BorderLayout()); + + this.setBackground(new Color(160, 185, 215)); + + initJP1(); + + } + + + + private void initJP1() { + + yearleft = new JLabel(" <<", JLabel.CENTER); + + yearleft.setToolTipText("上一年"); + + yearright = new JLabel(">> ", JLabel.CENTER); + + yearright.setToolTipText("下一年"); + + yearleft.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); + + yearright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); + + + + monthleft = new JLabel(" <", JLabel.RIGHT); + + monthleft.setToolTipText("上一月"); + + monthright = new JLabel("> ", JLabel.LEFT); + + monthright.setToolTipText("下一月"); + + monthleft.setBorder(BorderFactory.createEmptyBorder(2, 30, 0, 0)); + + monthright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 30)); + + + + centercontainer = new JLabel("", JLabel.CENTER); + + centercontainer.setLayout(new BorderLayout()); + + center = new JLabel("", JLabel.CENTER); + + + + centercontainer.add(monthleft, BorderLayout.WEST); + + centercontainer.add(center, BorderLayout.CENTER); + + centercontainer.add(monthright, BorderLayout.EAST); + + + + this.add(yearleft, BorderLayout.WEST); + + this.add(centercontainer, BorderLayout.CENTER); + + this.add(yearright, BorderLayout.EAST); + + this.setPreferredSize(new Dimension(295, 25)); + + + + updateDate(); + + + + yearleft.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + yearleft.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + yearleft.setForeground(Color.RED); + + } + + + + public void mouseExited(MouseEvent me) { + + yearleft.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + yearleft.setForeground(Color.BLACK); + + } + + + + public void mousePressed(MouseEvent me) { + + select.add(Calendar.YEAR, -1); + + yearleft.setForeground(Color.WHITE); + + refresh(); + + } + + + + public void mouseReleased(MouseEvent me) { + + yearleft.setForeground(Color.BLACK); + + } + + }); + + yearright.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + yearright.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + yearright.setForeground(Color.RED); + + } + + + + public void mouseExited(MouseEvent me) { + + yearright.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + yearright.setForeground(Color.BLACK); + + } + + + + public void mousePressed(MouseEvent me) { + + select.add(Calendar.YEAR, 1); + + yearright.setForeground(Color.WHITE); + + refresh(); + + } + + + + public void mouseReleased(MouseEvent me) { + + yearright.setForeground(Color.BLACK); + + } + + }); + + monthleft.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + monthleft.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + monthleft.setForeground(Color.RED); + + } + + + + public void mouseExited(MouseEvent me) { + + monthleft.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + monthleft.setForeground(Color.BLACK); + + } + + + + public void mousePressed(MouseEvent me) { + + select.add(Calendar.MONTH, -1); + + monthleft.setForeground(Color.WHITE); + + refresh(); + + } + + + + public void mouseReleased(MouseEvent me) { + + monthleft.setForeground(Color.BLACK); + + } + + }); + + monthright.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + monthright.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + monthright.setForeground(Color.RED); + + } + + + + public void mouseExited(MouseEvent me) { + + monthright.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + monthright.setForeground(Color.BLACK); + + } + + + + public void mousePressed(MouseEvent me) { + + select.add(Calendar.MONTH, 1); + + monthright.setForeground(Color.WHITE); + + refresh(); + + } + + + + public void mouseReleased(MouseEvent me) { + + monthright.setForeground(Color.BLACK); + + } + + }); + + } + + + + private void updateDate() { + + center.setText(select.get(Calendar.YEAR) + "年" + (select.get(Calendar.MONTH) + 1) + "月"); + + } + + } + + + + private class JP2 extends JPanel { + + private static final long serialVersionUID = -8176264838786175724L; + + + + public JP2() { + + this.setPreferredSize(new Dimension(295, 20)); + + } + + + + protected void paintComponent(Graphics g) { + + g.setFont(font); + + g.drawString("星期日 星期一 星期二 星期三 星期四 星期五 星期六", 5, 10); + + g.drawLine(0, 15, getWidth(), 15); + + } + + + + private void updateDate() { + + + + } + + } + + + + private class JP3 extends JPanel { + + private static final long serialVersionUID = 43157272447522985L; + + + + public JP3() { + + super(new GridLayout(6, 7)); + + this.setPreferredSize(new Dimension(295, 100)); + + initJP3(); + + } + + + + private void initJP3() { + + updateDate(); + + } + + + + public void updateDate() { + + this.removeAll(); + + lm.clear(); + + Date temp = select.getTime(); + + Calendar select = Calendar.getInstance(); + + select.setTime(temp); + + select.set(Calendar.DAY_OF_MONTH, 1); + + int index = select.get(Calendar.DAY_OF_WEEK); + + int sum = (index == 1 ? 8 : index); + + select.add(Calendar.DAY_OF_MONTH, 0 - sum); + + for (int i = 0; i < 42; i++) { + + select.add(Calendar.DAY_OF_MONTH, 1); + + lm.addLabel(new MyLabel(select.get(Calendar.YEAR), select.get(Calendar.MONTH), select.get(Calendar.DAY_OF_MONTH))); + + } + + for (MyLabel my : lm.getLabels()) { + + this.add(my); + + } + + select.setTime(temp); + + } + + } + + + + private class MyLabel extends JLabel implements Comparator, MouseListener, MouseMotionListener { + + private static final long serialVersionUID = 3668734399227577214L; + + private int year, month, day; + + private boolean isSelected; + + + + public MyLabel(int year, int month, int day) { + + super("" + day, JLabel.CENTER); + + this.year = year; + + this.day = day; + + this.month = month; + + this.addMouseListener(this); + + this.addMouseMotionListener(this); + + this.setFont(font); + + if (month == select.get(Calendar.MONTH)) { + + this.setForeground(Color.BLACK); + + } else { + + this.setForeground(Color.LIGHT_GRAY); + + } + + if (day == select.get(Calendar.DAY_OF_MONTH)) { + + this.setBackground(new Color(160, 185, 215)); + + } else { + + this.setBackground(Color.WHITE); + + } + + } + + + + public boolean getIsSelected() { + + return isSelected; + + } + + + + public void setSelected(boolean b, boolean isDrag) { + + isSelected = b; + + if (b && !isDrag) { + + int temp = select.get(Calendar.MONTH); + + select.set(year, month, day); + + if (temp == month) { + + SwingUtilities.updateComponentTreeUI(jp3); + + } else { + + refresh(); + + } + + } + + this.repaint(); + + } + + + + protected void paintComponent(Graphics g) { + + if (day == select.get(Calendar.DAY_OF_MONTH) && month == select.get(Calendar.MONTH)) { + + //如果当前日期是选择日期,则高亮显示 + + g.setColor(new Color(160, 185, 215)); + + g.fillRect(0, 0, getWidth(), getHeight()); + + } + + if (year == now.get(Calendar.YEAR) && month == now.get(Calendar.MONTH) && day == now.get(Calendar.DAY_OF_MONTH)) { + + //如果日期和当前日期一样,则用红框 + + Graphics2D gd = (Graphics2D) g; + + gd.setColor(Color.RED); + + Polygon p = new Polygon(); + + p.addPoint(0, 0); + + p.addPoint(getWidth() - 1, 0); + + p.addPoint(getWidth() - 1, getHeight() - 1); + + p.addPoint(0, getHeight() - 1); + + gd.drawPolygon(p); + + } + + if (isSelected) {//如果被选中了就画出一个虚线框出来 + + Stroke s = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL, 1.0f, new float[] { 2.0f, 2.0f }, 1.0f); + + Graphics2D gd = (Graphics2D) g; + + gd.setStroke(s); + + gd.setColor(Color.BLACK); + + Polygon p = new Polygon(); + + p.addPoint(0, 0); + + p.addPoint(getWidth() - 1, 0); + + p.addPoint(getWidth() - 1, getHeight() - 1); + + p.addPoint(0, getHeight() - 1); + + gd.drawPolygon(p); + + } + + super.paintComponent(g); + + } + + + + public boolean contains(Point p) { + + return this.getBounds().contains(p); + + } + + + + private void update() { + + repaint(); + + } + + + + public void mouseClicked(MouseEvent e) { + + } + + + + public void mousePressed(MouseEvent e) { + + isSelected = true; + + update(); + + } + + + + public void mouseReleased(MouseEvent e) { + + Point p = SwingUtilities.convertPoint(this, e.getPoint(), jp3); + + lm.setSelect(p, false); + + commit(); + + } + + + + public void mouseEntered(MouseEvent e) { + + } + + + + public void mouseExited(MouseEvent e) { + + } + + + + public void mouseDragged(MouseEvent e) { + + Point p = SwingUtilities.convertPoint(this, e.getPoint(), jp3); + + lm.setSelect(p, true); + + } + + + + public void mouseMoved(MouseEvent e) { + + } + + + + public int compare(MyLabel o1, MyLabel o2) { + + Calendar c1 = Calendar.getInstance(); + + c1.set(o1.year, o2.month, o1.day); + + Calendar c2 = Calendar.getInstance(); + + c2.set(o2.year, o2.month, o2.day); + + return c1.compareTo(c2); + + } + + } + + + + private class LabelManager { + + private List list; + + + + public LabelManager() { + + list = new ArrayList(); + + } + + + + public List getLabels() { + + return list; + + } + + + + public void addLabel(MyLabel my) { + + list.add(my); + + } + + + + public void clear() { + + list.clear(); + + } + + + + @SuppressWarnings("unused") + + public void setSelect(MyLabel my, boolean b) { + + for (MyLabel m : list) { + + if (m.equals(my)) { + + m.setSelected(true, b); + + } else { + + m.setSelected(false, b); + + } + + } + + } + + + + public void setSelect(Point p, boolean b) { + + //如果是拖动,则要优化一下,以提高效率 + + if (b) { + + //表示是否能返回,不用比较完所有的标签,能返回的标志就是把上一个标签和 + + //将要显示的标签找到了就可以了 + + boolean findPrevious = false, findNext = false; + + for (MyLabel m : list) { + + if (m.contains(p)) { + + findNext = true; + + if (m.getIsSelected()) { + + findPrevious = true; + + } else { + + m.setSelected(true, b); + + } + + } else if (m.getIsSelected()) { + + findPrevious = true; + + m.setSelected(false, b); + + } + + if (findPrevious && findNext) { + + return; + + } + + } + + } else { + + MyLabel temp = null; + + for (MyLabel m : list) { + + if (m.contains(p)) { + + temp = m; + + } else if (m.getIsSelected()) { + + m.setSelected(false, b); + + } + + } + + if (temp != null) { + + temp.setSelected(true, b); + + } + + } + + } + + + + } + + + + private class JP4 extends JPanel { + + private static final long serialVersionUID = -6391305687575714469L; + + + + public JP4() { + + super(new BorderLayout()); + + this.setPreferredSize(new Dimension(295, 20)); + + this.setBackground(new Color(160, 185, 215)); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日"); + + final JLabel jl = new JLabel("今天: " + sdf.format(new Date())); + + jl.setToolTipText("点击选择今天日期"); + + this.add(jl, BorderLayout.CENTER); + + jl.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + jl.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + jl.setForeground(Color.RED); + + } + + + + public void mouseExited(MouseEvent me) { + + jl.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + jl.setForeground(Color.BLACK); + + } + + + + public void mousePressed(MouseEvent me) { + + jl.setForeground(Color.WHITE); + + select.setTime(new Date()); + + refresh(); + + commit(); + + } + + + + public void mouseReleased(MouseEvent me) { + + jl.setForeground(Color.BLACK); + + } + + }); + + } + + + + private void updateDate() { + + + + } + + } + + + + public static void main(String[] args) { + + DateChooser dateChooser1 = DateChooser.getInstance("yyyy-MM-dd HH:mm"); + + DateChooser dateChooser2 = DateChooser.getInstance("yyyy-MM-dd"); + + JTextField showDate1 = new JTextField("单击选择日期"); + + JLabel showDate2 = new JLabel("单击选择日期"); + +// dateChooser1.sett.setTimePanleVisible(true); + + dateChooser1.register(showDate1); + + dateChooser2.register(showDate2); + + + + JFrame jf = new JFrame("测试日期选择器"); + + jf.add(showDate1, BorderLayout.NORTH); + + jf.add(showDate2, BorderLayout.SOUTH); + + jf.pack(); + + jf.setLocationRelativeTo(null); + + jf.setVisible(true); + + jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + } + +} \ No newline at end of file diff --git a/src/com/connor/erp/searchImpResult/SearchImpResultDialog.java b/src/com/connor/erp/searchImpResult/SearchImpResultDialog.java new file mode 100644 index 0000000..d6f1ff2 --- /dev/null +++ b/src/com/connor/erp/searchImpResult/SearchImpResultDialog.java @@ -0,0 +1,188 @@ +package com.connor.erp.searchImpResult; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.GridLayout; +import java.awt.Label; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.ScrollPaneConstants; +import javax.swing.border.EmptyBorder; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.common.actions.NewAddressListAction; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + + +public class SearchImpResultDialog extends AbstractAIFDialog implements ActionListener{ + + private AbstractAIFUIApplication application; + private TCSession session; + private JTextField userField; + private JTextField fromDate; + private JTextField toDate; + private JButton searchButton; + private JPanel panel; + private JPanel panel1; + private JPanel panel2; + private JScrollPane scrollPane; + private DateChooser dateChooser1; + private DateChooser dateChooser2; + private JTable table; + private JComboBox taskTypeBox; + private JComboBox impResultBox; + private SimpleDateFormat df = new SimpleDateFormat("yyyy-M-dd HH:mm"); + + public SearchImpResultDialog() { + + } + + public SearchImpResultDialog(AbstractAIFUIApplication application,TCSession session) { + this.application = application; + this.session = session; + } + + @Override + public void run() { + // TODO Auto-generated method stub +// super.run(); + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void init() throws TCException { + panel = new JPanel(new BorderLayout()); + panel1 = new JPanel(new GridLayout(3,4,10,20)); + panel2 = new JPanel(new BorderLayout()); + scrollPane = new JScrollPane(); + userField = new JTextField(10); + fromDate = new JTextField(10); + toDate = new JTextField(10); + searchButton = new JButton("查询"); + taskTypeBox = new JComboBox(); + impResultBox = new JComboBox(); + + taskTypeBox.addItem(""); + taskTypeBox.addItem("基础物料"); + taskTypeBox.addItem("PBOM"); + taskTypeBox.addItem("工艺路线"); + impResultBox.addItem(""); + impResultBox.addItem("成功"); + impResultBox.addItem("警告"); + impResultBox.addItem("错误"); + impResultBox.addItem("正在执行"); + + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + calendar.add(Calendar.MONTH, -1); + dateChooser1 = DateChooser.getInstance(calendar.getTime(),"yyyy-M-dd HH:mm"); + dateChooser2 = DateChooser.getInstance(new Date(),"yyyy-M-dd HH:mm"); + dateChooser1.register(fromDate); + dateChooser2.register(toDate); + fromDate.setText(df.format(calendar.getTime())); + toDate.setText(df.format(new Date())); + String[] property = new String[] { "序号", "导入对象", "任务类型 ", "任务号", "导入时间", "导入人", "导入结果","错误信息","对象版本"}; + String[][] data = new String[][] {}; + + DefaultTableModel model = new DefaultTableModel(data, property); + table = new JTable(model) { + public boolean isCellEditable(int row, int column) { + return false;// 表格不允许被编辑 + } + }; + table.setColumnModel(getColumn(table, new int[] { 70, 70, 70, 70,70,70,70,70})); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); +// scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + +// panel1.add("1.1.left.top",new Label("导入人")); +// panel1.add("1.2.left.top",userField); +// panel1.add("1.3.left.top",new Label()); +// panel1.add("1.4.right.top",searchButton); +// panel1.add("2.1.left.top",new Label("任务类型")); +// panel1.add("2.2.left.top",taskTypeBox); +// panel1.add("2.3.left.top",new Label("导入结果")); +// panel1.add("2.4.left.top",impResultBox); +// panel1.add("3.1.left.top",new Label("传递时间从")); +// panel1.add("3.2.left.top",fromDate); +// panel1.add("3.3.left.top",new Label("传递时间至")); +// panel1.add("3.4.left.top",toDate); + panel1.add(new Label("导入人")); + panel1.add(userField); + panel1.add(new Label()); + panel1.add(searchButton); + panel1.add(new Label("任务类型")); + panel1.add(taskTypeBox); + panel1.add(new Label("导入结果")); + panel1.add(impResultBox); + panel1.add(new Label("传递时间从")); + panel1.add(fromDate); + panel1.add(new Label("传递时间至")); + panel1.add(toDate); + panel1.setBorder(new EmptyBorder(0,0,30,0)); + searchButton.addActionListener(this); + userField.setText(session.getUser().getProperty("user_id")); + + panel.add(panel1,BorderLayout.NORTH); + panel.add(panel2,BorderLayout.CENTER); + panel.setBorder(new EmptyBorder(20,20,20,20)); + panel2.add(scrollPane,BorderLayout.CENTER); + scrollPane.setViewportView(table); + + setLayout(new BorderLayout()); + add(panel,BorderLayout.CENTER); + setTitle("ERP导入任务记录"); + pack(); + setLocationRelativeTo(null); + setVisible(true); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if(source.equals(searchButton)) { + if(userField.getText().trim()!=null&&userField.getText().trim().length()>0) { + String taskType = taskTypeBox.getSelectedItem().toString().trim().equals("")?null:taskTypeBox.getSelectedItem().toString().trim(); + String impResult = impResultBox.getSelectedItem().toString().trim().equals("")?null:impResultBox.getSelectedItem().toString().trim(); + SearchImpResultOperation operation = new SearchImpResultOperation(application,session,table,userField.getText().trim(),fromDate.getText().trim(),toDate.getText().trim(),taskType,impResult); + session.queueOperation(operation); + }else { + MessageBox.post("请填写导入人","",MessageBox.INFORMATION); + } + } + } + + /** + * JTable设置列宽 + */ + public static TableColumnModel getColumn(JTable table, int[] width) { + TableColumnModel columns = table.getColumnModel(); + for (int i = 0; i < width.length; i++) { + TableColumn column = columns.getColumn(i); + column.setPreferredWidth(width[i]); + } + return columns; + } +} diff --git a/src/com/connor/erp/searchImpResult/SearchImpResultHandler.java b/src/com/connor/erp/searchImpResult/SearchImpResultHandler.java new file mode 100644 index 0000000..afc6208 --- /dev/null +++ b/src/com/connor/erp/searchImpResult/SearchImpResultHandler.java @@ -0,0 +1,22 @@ +package com.connor.erp.searchImpResult; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class SearchImpResultHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFUIApplication application = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)application.getSession(); + new Thread(new SearchImpResultDialog(application, session)).start(); + return null; + } + +} diff --git a/src/com/connor/erp/searchImpResult/SearchImpResultOperation.java b/src/com/connor/erp/searchImpResult/SearchImpResultOperation.java new file mode 100644 index 0000000..f8666bc --- /dev/null +++ b/src/com/connor/erp/searchImpResult/SearchImpResultOperation.java @@ -0,0 +1,318 @@ +package com.connor.erp.searchImpResult; + +import java.net.URLEncoder; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JTable; +import javax.swing.table.DefaultTableModel; + +import com.connor.erp.processresource.EquipmentAcquiredFromERP.TCPreferenceUitl; +import com.connor.erp.toolkit.HttpUtil; +import com.connor.erpintegration.entity.ERPResultEntity; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +public class SearchImpResultOperation extends AbstractAIFOperation{ + private AbstractAIFUIApplication application; + private TCSession session; + private JTable table; + private String user; + private String fromDate; + private String toDate; + private String taskType; + private String impResult; + private SimpleDateFormat df = new SimpleDateFormat("yyyy-M-dd HH:mm"); + private static String erpPreference = "connor_tc_to_erp_url"; + + public SearchImpResultOperation() { + super(); + } + + public SearchImpResultOperation(AbstractAIFUIApplication application,TCSession session,JTable table,String user,String from,String to,String taskType,String impResult) { + this.application = application; + this.session = session; + this.table = table; + this.user = user; + this.fromDate = from; + this.toDate = to; + this.taskType = taskType; + this.impResult = impResult; +// try { +// this.fromDate = df.parse(from); +// this.toDate = df.parse(to); +// } catch (ParseException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + List list = getData(); + if(list.size()<1) { + MessageBox.post("未查到相关任务记录","",MessageBox.INFORMATION); + table.setModel(new DefaultTableModel()); + return; + } + String [][] data = new String[list.size()][9]; + for(int i =0;i0&&!"正在执行".equals(impResult2)) { + System.out.println("导入结果不为空或正在执行"); + data[i][0] = i+""; + data[i][1] = list.get(i).getItemId(); + data[i][2] = list.get(i).getTaskType(); + data[i][3] = list.get(i).getTaskNumber(); + + data[i][4] = list.get(i).getImpDate(); + data[i][5] = list.get(i).getUserName(); + data[i][6] = list.get(i).getImpResult(); + data[i][7] = list.get(i).getErrorInfo(); + data[i][8] = list.get(i).getVersion(); + }else { + System.out.println("导入结果为空或正在执行"); + String taskNumber = list.get(i).getTaskNumber(); + Map requestMap = new HashMap(); + requestMap.put("sid", taskNumber); + requestMap.put("needParameter", "false"); + String[] result = doGet(requestMap, "result"); + String taskNumber2 = list.get(i).getTaskNumber(); + updateResult(result, taskNumber2); + data[i][0] = i+""; + data[i][1] = list.get(i).getItemId(); + data[i][2] = list.get(i).getTaskType(); + data[i][3] = list.get(i).getTaskNumber(); + data[i][4] = list.get(i).getImpDate(); + data[i][5] = list.get(i).getUserName(); + if(result!=null&&result.length>0&&result[0]!=null&&result[0].length()>0) { + data[i][6] = result[0]; + }else { + data[i][6] = "正在执行"; + } + if(result!=null&&result.length>1) { + System.out.println("errorinfo==========="+result[1]); + data[i][7] = result[1]; + }else { + data[i][7] = ""; + } + data[i][8] = list.get(i).getVersion(); + } + } + String[] property = new String[] { "序号", "导入对象", "任务类型 ", "任务号", "导入时间", "导入人", "导入结果","错误信息","对象版本"}; + table.setModel(new DefaultTableModel(data,property)); + } + + public void updateResult(String[] result,String taskNumber) { + Connection con = null; + PreparedStatement stmt = null; + String sql = null; + if(result!=null&&result.length>0) { + try { + if(result.length>1) { + sql = "update connor_ERP_record set ImpResult=?,ErrorInfo=? where TaskNumber=?";// + con = ConnectionFun(); + stmt = con.prepareStatement(sql); + stmt.setString(1, result[0]); + stmt.setString(2, result[1]); + stmt.setString(3, taskNumber); + stmt.executeUpdate(); + }else { + sql = "update connor_ERP_record set ImpResult=? where TaskNumber=?";// + con = ConnectionFun(); + stmt = con.prepareStatement(sql); + stmt.setString(1, result[0]); + stmt.setString(2, taskNumber); + stmt.executeUpdate(); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + + public List getData() { + List list = new ArrayList(); + + ResultSet r = null; + Connection con = null; + PreparedStatement stmt = null; + StringBuffer sb = new StringBuffer("select ItemId,TaskType,TaskNumber,to_char(ImpDate,'yyyy-fmmm-dd hh24:mi'),UserName,ImpResult,ErrorInfo,Rev_Id from connor_ERP_record where UserName=? and ImpDate>=to_date(?,'yyyy-fmmm-dd hh24:mi') and ImpDate<=to_date(?,'yyyy-fmmm-dd hh24:mi')"); + if(taskType!=null) { + sb.append(" and TaskType=?"); + } + if(impResult!=null) { + sb.append(" and ImpResult=?"); + } + sb.append(" order by ImpDate desc"); + String sql = sb.toString(); + try { + con = ConnectionFun(); + stmt = con.prepareStatement(sql); + stmt.setString(1, user); + stmt.setString(2, fromDate); + stmt.setString(3, toDate); + if(taskType!=null) { + stmt.setString(4, taskType); + if(impResult!=null)stmt.setString(5, impResult); + }else if(impResult!=null){ + stmt.setString(4, impResult); + } + System.out.println("sql===="+sql); + r = stmt.executeQuery(); + while (r.next()) { + ERPResultEntity entity = new ERPResultEntity(); +// System.out.println(r.getString(1)); + entity.setItemId(r.getString(1)); + entity.setTaskType(r.getString(2)); + entity.setTaskNumber(r.getString(3)); + entity.setImpDate(r.getString(4)); + entity.setUserName(r.getString(5)); + entity.setImpResult(r.getString(6)); + entity.setErrorInfo(r.getString(7)); + entity.setVersion(r.getString(8)); + list.add(entity); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + try { + r.close(); + stmt.close(); + con.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + return list; + } + + + public Connection ConnectionFun() throws SQLException { + String[] stringArray = session.getPreferenceService().getStringValues("connor_oracle_connection"); + + String url = "jdbc:oracle:thin:@" + stringArray[0];// + + String oracleUser = stringArray[1];// + + String password = stringArray[2];// + + Connection conn = null;// + + try { + System.out.println(url); + System.out.println(oracleUser); + System.out.println(password); + Class.forName("oracle.jdbc.driver.OracleDriver"); + System.out.println("驱动加载成功"); + } catch (ClassNotFoundException e) { + System.out.println("驱动加载失败"); + } + + conn = DriverManager.getConnection(url, oracleUser, password); + + System.out.println("数据库连接成功"); + return conn; + + } + + public String[] doGet(Map map, String svr) { + HashMap preferenceHashMap = TCPreferenceUitl.getPreferenceHashMap(session, TCPreferenceService.TC_preference_site, erpPreference); + String url = preferenceHashMap.get("url"); + String token = preferenceHashMap.get("token"); + JSONObject itemCheckJson = JSONObject.fromObject(map); +// List checkResults =null; + Map resultMap = new HashMap(); + try { + System.out.println("开始发送请求"); + String args = itemCheckJson.toString(); + token = URLEncoder.encode(token,"UTF-8"); + svr = URLEncoder.encode(svr,"UTF-8"); + args = URLEncoder.encode(args,"UTF-8"); + String param = "usr="+token+"&svr="+svr+"&args="+args; + System.out.println("url=============="+url); + System.out.println("param==========="+param); + String response = HttpUtil.doGet(url+"?"+param); + System.out.println("请求结果================"+response); + + JSONObject jsonObject = JSONObject.fromObject(response); +// System.out.println("json格式==============="+jsonObject); + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); +// int status = jsonObject2.getInt("status"); + String result = jsonObject2.getString("result"); + String output = jsonObject2.getString("output"); + + System.out.println("result============"+result); + System.out.println("output============"+output); + if(result.equals("0"))return new String[] {"正在执行"}; + else if(result.equals("1"))return new String[] {"成功"}; + else if(result.equals("2"))return new String[] {"警告",output}; + else if(result.equals("3")) { + if(output!=null&&output.length()>=14&&output.substring(0,14).equals("{\"checkResult\"")) { + JSONObject json = JSONObject.fromObject(output); + JSONArray jsonArray = json.getJSONArray("checkResult"); + StringBuffer sb = new StringBuffer(); + for(int i =0;i)JSONObject.toBean(jsonObject3,Map.class); + + + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return null; + } +} diff --git a/src/com/connor/erp/searchImpResult/Test.java b/src/com/connor/erp/searchImpResult/Test.java new file mode 100644 index 0000000..07fa750 --- /dev/null +++ b/src/com/connor/erp/searchImpResult/Test.java @@ -0,0 +1,39 @@ +package com.connor.erp.searchImpResult; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +public class Test { + + public static void main(String[] args) { + String output = "{\"checkResult\":[{\"item\":\"012759\",\"uom\":\"件\",\"existInNHL\":true,\"existInNSC\":false,\"existInNBJ\":false,\"existInNSJ\":true,\"uomExist\":true,\"canImport\":false}],\"canAllImport\":false}"; + if(output!=null&&output.length()>=14&&output.substring(0,14).equals("{\"checkResult\"")) { + JSONObject json = JSONObject.fromObject(output); + JSONArray jsonArray = json.getJSONArray("checkResult"); + System.out.println("jsonarray==="+jsonArray); + StringBuffer sb = new StringBuffer(); + for(int i =0;i" + this.errorInfo + ""); +/* 172 */ this.detailPanel = new JPanel(); +/* 173 */ this.detailPanel.setVisible(false); +/* 174 */ this.parentPanel.add("top.nobind.left", new JLabel("验证所选对象结果")); +/* 175 */ this.parentPanel.add("top.bind", (Component)new Separator()); +/* 176 */ this.parentPanel.add("top.bind", new JLabel("" + this.labelInfo + "")); +/* 177 */ this.parentPanel.add("top.bind", (Component)new Separator()); +/* 178 */ this.parentPanel.add("top.nobind.right", (Component)this.moreButton); +/* 179 */ this.parentPanel.add("top.nobind.right", (Component)this.lessButton); +/* 180 */ this.scroller = new JScrollPane(); +/* 181 */ this.infoPanel = new JPanel(); +/* 182 */ this.scroller.getViewport().add(this.infoPanel); +/* 183 */ this.infoPanel.add(errorInfolabel); +/* 184 */ String s = Utilities.getCookie("ValidateFailDialog", getClass().getName() + "." + "ShowDetails", true); +/* 185 */ setShowDetails((s != null && s.equalsIgnoreCase("true"))); +/* 186 */ this.parentPanel.add("unbound.bind.center.top", this.scroller); +/* 188 */ this.btnConfirm = new JButton("是"); +/* 189 */ this.btnConfirm.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { +/* 193 */ dispose(); +/* 194 */ if ( bomCommand != null) { +/* 195 */ if ( callBack != null) { +/* 196 */ if ("loadDataForPrivilege1".equals( callBack)) { +/* 197 */ bomCommand.loadDataForPrivilege1( aimType); +/* 198 */ } else if ("loadData1".equals( callBack)) { +/* 199 */ bomCommand.loadData1( aimType); + } + } else { + /* 202 */ bomCommand.postDialog2( aimType); + } +/* 204 */ } else if ( processChgCommand != null) { +/* 205 */ processChgCommand.postDialog2(); +/* 206 */ } else if ( processAddCommand != null) { +/* 207 */ processAddCommand.postDialog2(); +/* 208 */ } else if ( sendToERPCommand != null) { +/* 209 */ sendToERPCommand.postDialog(); + } + } + }); +/* 215 */ this.btnReport = new JButton("否"); +/* 216 */ this.btnReport.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { +/* 220 */ dispose(); + } + }); +/* 225 */ this.paneButton = new JPanel(); +/* 226 */ this.paneButton.add(this.btnConfirm); +/* 227 */ this.paneButton.add(this.btnReport); +/* 228 */ this.parentPanel.add("bottom.bind.center.top", this.paneButton); +/* 229 */ getContentPane().setLayout(new BorderLayout()); +/* 230 */ getContentPane().add("Center", this.parentPanel); + } + + private void resizeDialog(int i) { +/* 234 */ if (i != 0) { +/* 235 */ Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); +/* 236 */ this.infoPanel.revalidate(); +/* 237 */ Rectangle rectangle = this.scroller.getViewport().getBounds(); +/* 238 */ Rectangle rectangle1 = getBounds(); +/* 239 */ Rectangle rectangle2 = null; +/* 240 */ if (rectangle.height <= 0) +/* 241 */ rectangle2 = rectangle1; +/* 242 */ rectangle.height = this.infoPanel.getHeight(); +/* 243 */ this.scroller.getViewport().setBounds(rectangle); +/* 244 */ this.scroller.setBounds(rectangle); +/* 245 */ this.scroller.setPreferredSize(new Dimension(rectangle.width, rectangle.height)); +/* 246 */ rectangle.height += i; +/* 247 */ if (rectangle2 != null) +/* 248 */ i = rectangle.height; +/* 249 */ rectangle1.height += i; +/* 250 */ int j = 0; +/* 251 */ if (this.additionalInfoPanel != null) +/* 252 */ j = (this.additionalInfoPanel.getSize()).height; +/* 253 */ if (rectangle1.height < rectangle.height + j + 50) +/* 254 */ rectangle1.height = rectangle.height + j + 50; +/* 255 */ if (rectangle1.height > (int)(0.75D * dimension.getHeight())) +/* 256 */ rectangle1.height = (int)(0.75D * dimension.getHeight()); +/* 257 */ setBounds(rectangle1); +/* 258 */ validate(); +/* 259 */ repaint(); + } + } + + public void setShowDetails(boolean flag) { +/* 264 */ this.scroller.setVisible(flag); +/* 265 */ if (flag) { +/* 266 */ this.moreButton.setVisible(false); +/* 267 */ this.lessButton.setVisible(true); + } else { +/* 269 */ this.moreButton.setVisible(true); +/* 270 */ this.lessButton.setVisible(false); + } +/* 272 */ validate(); +/* 273 */ repaint(); +/* 274 */ String s = getClass().getName(); +/* 275 */ if (isShowing()) +/* 276 */ Utilities.setCookie("ValidateFailDialog", true, s + "." + "ShowDetails", String.valueOf(flag)); + } + + private void createTxt() { +/* 284 */ JFileChooser jfc = new JFileChooser(); +/* 285 */ ExampleFileFilter filter = new ExampleFileFilter(); +/* 286 */ filter.addExtension("txt"); +/* 287 */ filter.setDescription("txt File"); +/* 288 */ jfc.setFileFilter(filter); +/* 289 */ int ret = jfc.showSaveDialog(null); +/* 291 */ if (ret == 0) { +/* 292 */ File file = jfc.getSelectedFile(); +/* 293 */ String fname = jfc.getName(file); +/* 294 */ if (!fname.endsWith(".log") && !fname.endsWith(".LOG") && +/* 295 */ !fname.endsWith(".txt") && !fname.endsWith(".TXT")) +/* 296 */ fname = fname.concat(".txt"); +/* 299 */ file = jfc.getCurrentDirectory(); +/* 300 */ String saveFilePath = file.getPath().concat(File.separator).concat(fname); +/* 301 */ file = new File(saveFilePath); +/* 302 */ FileWriter fw = null; + try { +/* 304 */ fw = new FileWriter(file); +/* 305 */ } catch (IOException e) { +/* 306 */ e.printStackTrace(); + } +/* 308 */ String newStr = this.errorInfo.replace("
", "\r\n"); + try { +/* 310 */ fw.write(newStr); +/* 311 */ fw.flush(); +/* 312 */ fw.close(); +/* 313 */ } catch (IOException e) { +/* 314 */ e.printStackTrace(); + } + } + } + + public class ExampleFileFilter extends FileFilter { +/* 320 */ private Hashtable filters = null; + +/* 321 */ private String description = null; + +/* 322 */ private String fullDescription = null; + + private boolean useExtensionsInDescription = true; + + public ExampleFileFilter() { +/* 332 */ this.filters = new Hashtable(); + } + + public ExampleFileFilter(String extension) { +/* 342 */ this(extension, (String)null); + } + + public ExampleFileFilter(String extension, String description) { +/* 355 */ this(); +/* 356 */ if (extension != null) +/* 357 */ addExtension(extension); +/* 358 */ if (description != null) +/* 359 */ setDescription(description); + } + + public ExampleFileFilter(String[] filters) { +/* 371 */ this(filters, (String)null); + } + + public ExampleFileFilter(String[] filters, String description) { +/* 384 */ this(); +/* 385 */ for (int i = 0; i < filters.length; i++) +/* 387 */ addExtension(filters[i]); +/* 389 */ if (description != null) +/* 390 */ setDescription(description); + } + + public boolean accept(File f) { +/* 403 */ if (f != null) { +/* 404 */ if (f.isDirectory()) +/* 405 */ return true; +/* 407 */ String extension = getExtension(f); +/* 408 */ if (extension != null && this.filters.get(getExtension(f)) != null) +/* 409 */ return true; + } +/* 413 */ return false; + } + + public String getExtension(File f) { +/* 423 */ if (f != null) { +/* 424 */ String filename = f.getName(); +/* 425 */ int i = filename.lastIndexOf('.'); +/* 426 */ if (i > 0 && i < filename.length() - 1) +/* 427 */ return filename.substring(i + 1).toLowerCase(); + } +/* 431 */ return null; + } + + public void addExtension(String extension) { +/* 446 */ if (this.filters == null) +/* 447 */ this.filters = new Hashtable(5); +/* 449 */ this.filters.put(extension.toLowerCase(), this); +/* 450 */ this.fullDescription = null; + } + + public String getDescription() { +/* 463 */ if (this.fullDescription == null) +/* 464 */ if (this.description == null || isExtensionListInDescription()) { +/* 465 */ this.fullDescription = (this.description == null) ? "(" : (String.valueOf(this.description) + +/* 466 */ " ("); +/* 468 */ Enumeration extensions = this.filters.keys(); +/* 469 */ if (extensions != null) { +/* 470 */ this.fullDescription = String.valueOf(this.fullDescription) + "." + (String)extensions.nextElement(); +/* 471 */ while (extensions.hasMoreElements()) +/* 472 */ this +/* 473 */ .fullDescription = String.valueOf(this.fullDescription) + ", ." + (String)extensions.nextElement(); + } +/* 476 */ this.fullDescription = String.valueOf(this.fullDescription) + ")"; + } else { +/* 478 */ this.fullDescription = this.description; + } +/* 481 */ return this.fullDescription; + } + + public void setDescription(String description) { +/* 493 */ this.description = description; +/* 494 */ this.fullDescription = null; + } + + public void setExtensionListInDescription(boolean b) { +/* 509 */ this.useExtensionsInDescription = b; +/* 510 */ this.fullDescription = null; + } + + public boolean isExtensionListInDescription() { +/* 525 */ return this.useExtensionsInDescription; + } + } + } diff --git a/src/com/connor/erp/toolkit/ReadResultXMLStr.java b/src/com/connor/erp/toolkit/ReadResultXMLStr.java new file mode 100644 index 0000000..c2f9b7a --- /dev/null +++ b/src/com/connor/erp/toolkit/ReadResultXMLStr.java @@ -0,0 +1,100 @@ + package com.connor.erp.toolkit; + + import java.io.File; + import java.io.IOException; + import java.util.ArrayList; + import java.util.List; + import java.util.Map; + import org.jdom.Attribute; + import org.jdom.Document; + import org.jdom.Element; + import org.jdom.JDOMException; + import org.jdom.input.SAXBuilder; + + public class ReadResultXMLStr { + public static boolean xmlElements(File xmlFilePath, Map map) { +/* 37 */ SAXBuilder sb = new SAXBuilder(); + try { +/* 40 */ Document doc = sb.build(xmlFilePath); +/* 42 */ Element root = doc.getRootElement(); +/* 43 */ List attributes = root.getAttributes(); +/* 44 */ int attrSize = attributes.size(); +/* 45 */ for (int j = 0; j < attrSize; j++) { +/* 46 */ Attribute attr = (Attribute)attributes.get(j); +/* 47 */ String attr_name = attr.getName(); +/* 48 */ String attr_value = attr.getValue(); +/* 49 */ if (attr_name.equals("fileType") && attr_value.equals("result")) { +///* 50 */ loadElements(root.getChildren(), map); +/* 51 */ return true; + } + } +/* 54 */ } catch (JDOMException e) { +/* 55 */ e.printStackTrace(); +/* 56 */ } catch (IOException e) { +/* 57 */ e.printStackTrace(); + } +/* 59 */ return false; + } + + public static Boolean loadElements(Map resultMap, Map map) { +/* 64 */ if (resultMap == null) + return true; +///* 67 */ for (int m = 0; m < resultlistSize; m++) { +///* 68 */ Element childEle = (Element)resultMap.get(m); +///* 69 */ String childEle_name = childEle.getName(); +///* 70 */ String childEle_value = childEle.getValue(); +///* 71 */ if (childEle_name.equals("taskSN")) { +///* 72 */ map.put(childEle_name, childEle_value); +///* 73 */ } else if (childEle_name.equals("taskResult")) { +///* 74 */ map.put(childEle_name, childEle_value); +///* 75 */ } else if (childEle_name.equals("currentStep")) { +///* 76 */ map.put(childEle_name, childEle_value); +///* 77 */ } else + map.put("taskSN", resultMap.get("sid")); + map.put("taskResult", resultMap.get("result")); + map.put("currentStep", resultMap.get("status")); +// if (childEle_name.equals("executeLog")) { +///* 78 */ List wronglinelist = childEle.getChildren(); +///* 79 */ int wronglinelistSize = wronglinelist.size(); +///* 80 */ List listWronglineInfo = new ArrayList(); +///* 81 */ if (wronglinelistSize > 0) +///* 82 */ for (int i = 0; i < wronglinelistSize; i++) { +///* 83 */ Element wronglineEle = (Element)wronglinelist.get(i); +///* 84 */ String wrongItem = wronglineEle.getValue(); +///* 85 */ List attributes = wronglineEle.getAttributes(); +///* 86 */ int attrSize = attributes.size(); +///* 87 */ String wrongType = ""; +///* 88 */ for (int j = 0; j < attrSize; j++) { +///* 89 */ Attribute attr = (Attribute)attributes.get(j); +///* 90 */ String attr_name = attr.getName(); +///* 91 */ String attr_value = attr.getValue(); +///* 92 */ if (attr_name.equals("wrongType")) { +///* 93 */ wrongType = UtilApi.getWrongType(Integer.parseInt(attr_value)); +// break; +// } +// } +///* 97 */ listWronglineInfo.add(wrongItem + " " + wrongType); +// } +///* 100 */ map.put("wrongLine", listWronglineInfo); +// } +// } + return true; + } + + public static String getFileType(File xmlFilePath) { +/* 107 */ SAXBuilder sb = new SAXBuilder(); +/* 108 */ String fileType = ""; + try { +/* 111 */ Document doc = sb.build(xmlFilePath); +/* 113 */ Element root = doc.getRootElement(); +/* 114 */ if (root.getAttribute("fileType") != null) +/* 115 */ fileType = root.getAttribute("fileType").getValue(); +/* 117 */ } catch (JDOMException e) { +/* 118 */ e.printStackTrace(); +/* 119 */ } catch (IOException e) { +/* 120 */ e.printStackTrace(); + } +/* 122 */ return fileType; + } + } + diff --git a/src/com/connor/erp/toolkit/ResultInfo.java b/src/com/connor/erp/toolkit/ResultInfo.java new file mode 100644 index 0000000..1d94618 --- /dev/null +++ b/src/com/connor/erp/toolkit/ResultInfo.java @@ -0,0 +1,28 @@ +package com.connor.erp.toolkit; + +public class ResultInfo { + private String result; + + private String detail; + + public ResultInfo(String result, String detail) { + this.result = result; + this.detail = detail; + } + + public String getResult() { + return this.result; + } + + public void setResult(String result) { + this.result = result; + } + + public String getDetail() { + return this.detail; + } + + public void setDetail(String detail) { + this.detail = detail; + } +} diff --git a/src/com/connor/erp/toolkit/TCPreferenceUitl.java b/src/com/connor/erp/toolkit/TCPreferenceUitl.java new file mode 100644 index 0000000..c4d5639 --- /dev/null +++ b/src/com/connor/erp/toolkit/TCPreferenceUitl.java @@ -0,0 +1,155 @@ +package com.connor.erp.toolkit; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Vector; + +import cn.com.origin.autocodemanager.common.encrypt.EncryptOperations; +import cn.com.origin.autocodemanager.common.operations.TreeAndListCodeOperation; + +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; + +public class TCPreferenceUitl { + + public static String origin_isListValueCanFilter = "origin_isListValueCanFilter"; + + public String getEnv(String name) { + String str = ""; + Iterator it = System.getenv().entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = (Map.Entry) it.next(); + // logger.info("entry-" + entry.getKey() + ":" + entry.getValue()); + if (entry.getKey().toString().equals(name)) { + str = entry.getValue() + ""; + if (!str.endsWith("\\")) { + str = str + "\\"; + } + break; + } + } + return str; + } + + /** + * @param tcsession + * @param preferenceName + * @param isSelectName + * @return + */ + public static boolean isSelectExsitToTCPreferenceValues(TCSession tcsession, String preferenceName, String isSelectName) { + boolean flag = false; + TCPreferenceService preferenceService = tcsession.getPreferenceService(); + String preferenceValues[] = preferenceService.getStringArray(TCPreferenceService.TC_preference_site, preferenceName); + if (preferenceValues == null) { + return false; + } + if (preferenceValues != null && preferenceValues.length > 0) { + for (int i = 0; i < preferenceValues.length; i++) { + // System.out.println(preferenceValues[i]); + if (preferenceValues[i].trim().equals(isSelectName)) { + flag = true; + return flag; + } + } + } + return flag; + } + + private static boolean isWriteExpire = false; + + public static synchronized boolean isWriteExpire() { + return isWriteExpire; + } + + public static synchronized void setWriteExpire(boolean isWriteExpire) { + TCPreferenceUitl.isWriteExpire = isWriteExpire; + } + + public static boolean isExpire() { + // tyl + boolean isExpire = true; + if (!TCPreferenceUitl.isWriteExpire) { + TCPreferenceUitl.setWriteExpire(true); + int value = new TreeAndListCodeOperation().isDateExpire(); + if (value == 0) { + isExpire = false; + } else { + isExpire = true; + } + EncryptOperations.setLicenseExpire(isExpire); + } + return (EncryptOperations.isLicenseExpire()); + // tyl + // return false; + } + + public static boolean isTrueTCPreferenceValue(TCSession tcsession, String preferenceName) { + boolean flag = false; + TCPreferenceService preferenceService = tcsession.getPreferenceService(); + String value = preferenceService.getString(TCPreferenceService.TC_preference_site, preferenceName); + if (value == null) { + return false; + } + if (value.equalsIgnoreCase("true")) { + flag = true; + } + return flag; + } + + public static String getTCPreferenceValue(TCSession tcsession, String preferenceName) { + TCPreferenceService preferenceService = tcsession.getPreferenceService(); + String value = preferenceService.getString(TCPreferenceService.TC_preference_site, preferenceName); + return value; + } + + public static String[] getListPreference(TCSession session, int scope, String pid) { + try { + String options[] = session.getPreferenceService().getStringArray(scope, pid); + return options; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static HashMap getPreferenceHashMap(TCSession session, int scope, String preferenceName) { + HashMap hm = new HashMap(); + Vector preferencekeyNames = new Vector(); + try { + String options[] = getPreference(session, scope, preferenceName); + if (options == null) { + return hm; + } + if (options.length == 0) { + return null; + } + String key = ""; + String value = ""; + for (int i = 0; i < options.length; i++) + if (options[i].indexOf("=") > 0) { + key = options[i].substring(0, options[i].indexOf("=")); + value = options[i].substring(options[i].indexOf("=") + 1); + hm.put(key, value); + preferencekeyNames.add(key); + } else { + hm.put((new StringBuilder()).append(i).toString(), options[i]); + } + } catch (Exception e) { + e.printStackTrace(); + return null; + } + return hm; + } + + public static String[] getPreference(TCSession session, int scope, String pid) { + try { + String options[] = session.getPreferenceService().getStringArray(scope, pid); + return options; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/src/com/connor/erp/toolkit/Test.java b/src/com/connor/erp/toolkit/Test.java new file mode 100644 index 0000000..c9e2bdc --- /dev/null +++ b/src/com/connor/erp/toolkit/Test.java @@ -0,0 +1,14 @@ +package com.connor.erp.toolkit; + +import java.util.HashMap; +import java.util.Map; + +public class Test { + + public static void main(String[] args) { + Map map = new HashMap(); + map.put("1", "1"); + map.put("2", "1"); + System.out.println(map.size()); + } +} diff --git a/src/com/connor/erp/toolkit/UtilApi.java b/src/com/connor/erp/toolkit/UtilApi.java new file mode 100644 index 0000000..5cfd89b --- /dev/null +++ b/src/com/connor/erp/toolkit/UtilApi.java @@ -0,0 +1,979 @@ +package com.connor.erp.toolkit; + +// import com.connor.erp.BomAddTransferToERP.BomAddImportXMLReader; + import com.connor.erp.BomChgTransferToERP.BomChgImportXMLReader; + import com.connor.erp.BomImport.BomTransferCommand; + import com.connor.erp.ItemAddTransferSendToERP.SendToERPCommand; + import com.connor.erp.ItemImport.ItemImportXMLReader; + import com.connor.erp.ProcessImport.ValidateFailDialog; +import com.connor.erp.processresource.EquipmentAcquiredFromERP.TCPreferenceUitl; +import com.connor.erpintegration.entity.BomCheckResult; +import com.connor.erpintegration.entity.CheckResult; +// import com.connor.tcerp.conn.PlmErpIntegration; + import com.teamcenter.rac.aif.AbstractAIFCommand; + import com.teamcenter.rac.aif.AbstractAIFUIApplication; + import com.teamcenter.rac.aif.kernel.AIFComponentContext; + import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; + import com.teamcenter.rac.kernel.TCComponent; + import com.teamcenter.rac.kernel.TCComponentBOMLine; + import com.teamcenter.rac.kernel.TCComponentBOMViewRevision; + import com.teamcenter.rac.kernel.TCComponentBOMWindow; + import com.teamcenter.rac.kernel.TCComponentBOMWindowType; + import com.teamcenter.rac.kernel.TCComponentContextList; + import com.teamcenter.rac.kernel.TCComponentForm; + import com.teamcenter.rac.kernel.TCComponentItemRevision; + import com.teamcenter.rac.kernel.TCComponentQuery; + import com.teamcenter.rac.kernel.TCComponentQueryType; + import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; + import com.teamcenter.rac.kernel.TCSession; + import com.teamcenter.rac.kernel.TCTextService; + import com.teamcenter.rac.kernel.TCUserService; + import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import java.io.File; + import java.io.IOException; + import java.math.BigDecimal; +import java.net.URLEncoder; +import java.text.SimpleDateFormat; + import java.util.ArrayList; + import java.util.Date; + import java.util.Enumeration; + import java.util.HashMap; + import java.util.List; + import java.util.Map; +import java.util.ResourceBundle; + +import javax.swing.JTable; + import javax.swing.SwingUtilities; + import javax.swing.table.JTableHeader; + import javax.swing.table.TableColumn; + import org.jdom.Document; + import org.jdom.Element; + import org.jdom.JDOMException; + import org.jdom.input.SAXBuilder; + + public class UtilApi { + private static final int DEF_DIV_SCALE = 10; + private static String erpPreference = "connor_tc_to_erp_url"; + private static ResourceBundle resource = ResourceBundle.getBundle("tcUser_erpUser"); + + public static TCComponent[] query(TCSession session, String query_name, String[] arg1, String[] arg2) { +/* 77 */ TCComponentContextList imancomponentcontextlist = null; +/* 78 */ TCComponent[] component = null; + try { +/* 80 */ TCComponentQueryType imancomponentquerytype = (TCComponentQueryType)session.getTypeComponent("ImanQuery"); +/* 81 */ TCComponentQuery imancomponentquery = (TCComponentQuery)imancomponentquerytype.find(query_name); +/* 82 */ if (imancomponentquery == null) { +/* 83 */ System.out.println("未找到查询构建器" + query_name + "!!"); +/* 84 */ return null; + } +/* 86 */ TCTextService imantextservice = session.getTextService(); +/* 87 */ int keyNum = arg1.length; +/* 88 */ String[] queryAttribute = new String[keyNum]; +/* 89 */ for (int i = 0; i < keyNum; i++) +/* 90 */ queryAttribute[i] = imantextservice.getTextValue(arg1[i]); +/* 93 */ String[] queryValues = new String[keyNum]; +/* 94 */ for (int j = 0; j < keyNum; j++) +/* 95 */ queryValues[j] = imantextservice.getTextValue(arg2[j]); +/* 97 */ imancomponentcontextlist = imancomponentquery.getExecuteResultsList(queryAttribute, queryValues); +/* 98 */ component = imancomponentcontextlist.toTCComponentArray(); +/* 99 */ } catch (Exception ex) { +/* 100 */ ex.printStackTrace(); + } +/* 102 */ return component; + } + + public static TCComponentForm getItemRelationForm(TCComponentItemRevision revision, String relation) throws TCException { +/* 112 */ if (revision != null) { +/* 113 */ AIFComponentContext[] contexts = revision.getChildren(relation); +/* 114 */ if (contexts != null && contexts.length > 0) { +/* 115 */ InterfaceAIFComponent component = contexts[0].getComponent(); +/* 116 */ if (component instanceof TCComponentForm) { +/* 117 */ TCComponentForm form = (TCComponentForm)component; +/* 118 */ return form; + } + } + } +/* 122 */ return null; + } + + public static TCComponentBOMLine getNewBOMLine(TCSession session, TCComponentItemRevision itemR, TCComponentBOMViewRevision tcBomView) { + try { +/* 128 */ TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType)session.getTypeComponent("BOMWindow"); +/* 129 */ TCComponentBOMWindow win = bomWinType.create(null); +/* 130 */ win.lock(); +/* 131 */ win.setWindowTopLine(itemR.getItem(), itemR, null, (TCComponent)tcBomView); +/* 132 */ TCComponentBOMLine componentbomline = win.getTopBOMLine(); +/* 133 */ return componentbomline; +/* 134 */ } catch (TCException e) { +/* 135 */ e.printStackTrace(); +/* 136 */ return null; + } + } + + public static String getCurrentTime() { +/* 141 */ return (new SimpleDateFormat("yyyyMMddHHmmssSSS")).format(new Date()); + } + + public static String getErrorInfoFromCode(int result) { +/* 145 */ String errorInfo = ""; +/* 146 */ switch (result) { + case 1: +/* 148 */ errorInfo = "本地文件读取错误"; +/* 174 */ return errorInfo; + case 2: + errorInfo = "初始化TCP错误"; +/* 174 */ return errorInfo; + case 3: + errorInfo = "发送请求数据错误"; +/* 174 */ return errorInfo; + case 4: + errorInfo = "服务端获取结果错误"; +/* 174 */ return errorInfo; + case 5: + errorInfo = "回传文件错误"; +/* 174 */ return errorInfo; + case 6: + errorInfo = "关闭连接错误"; +/* 174 */ return errorInfo; + case 7: + errorInfo = "其他错误"; +/* 174 */ return errorInfo; + case 8: + errorInfo = "成功"; +/* 174 */ return errorInfo; + } + errorInfo = ""; +/* 174 */ return errorInfo; + } + + public static String getTaskStatus(int result) { +/* 178 */ String status = ""; +/* 179 */ switch (result) { + case 1: +/* 181 */ status = "文件上传完成"; +/* 201 */ return status; + case 2: + status = "加入任务队列"; +/* 201 */ return status; + case 3: + status = "开始任务"; +/* 201 */ return status; + case 4: + status = "开始二次验证文件"; +/* 201 */ return status; + case 5: + status = "二次验证通过开始API执行导入"; +/* 201 */ return status; + case 6: + status = "导入过程完成任务结束"; +/* 201 */ return status; + } + status = ""; +/* 201 */ return status; + } + + public static String getTaskResult(int code) { +/* 205 */ String result = ""; +/* 206 */ switch (code) { + case 1: +/* 208 */ result = "任务成功"; +/* 225 */ return result; + case 2: + result = "任务成功但有忽略"; +/* 225 */ return result; + case 3: + result = "任务成功但有需用户注意"; +/* 225 */ return result; + case 4: + result = "任务成功但子项目有严重错误"; +/* 225 */ return result; + case 5: + result = "严重错误任务失败"; +/* 225 */ return result; + } + result = ""; +/* 225 */ return result; + } + + public static String getWrongLevel(int code) { +/* 229 */ String result = ""; +/* 230 */ switch (code) { + case 1: +/* 232 */ result = "可忽略错误"; +/* 240 */ return result; + case 2: + result = "严重错误"; +/* 240 */ return result; + } + result = ""; +/* 240 */ return result; + } + + public static String getWrongType(int code) { +/* 244 */ String result = ""; +/* 245 */ switch (code) { + case 1: +/* 247 */ result = "对象不存在错误"; +/* 261 */ return result; + case 2: + result = "对象已存在错误"; +/* 261 */ return result; + case 3: + result = "对象属性不正确错误"; +/* 261 */ return result; + case 4: + result = "其它错误"; +/* 261 */ return result; + } + result = ""; +/* 261 */ return result; + } + + public static int FitTableColumns(JTable myTable) { +/* 268 */ JTableHeader header = myTable.getTableHeader(); +/* 269 */ int rowCount = myTable.getRowCount(); +/* 270 */ Enumeration columns = myTable.getColumnModel().getColumns(); +/* 271 */ int totalWidth = 15; +/* 272 */ while (columns.hasMoreElements()) { +/* 273 */ TableColumn column = (TableColumn)columns.nextElement(); +/* 274 */ int col = header.getColumnModel().getColumnIndex(column.getIdentifier()); +/* 275 */ int width = (int)myTable.getTableHeader().getDefaultRenderer().getTableCellRendererComponent(myTable, column.getIdentifier(), false, false, -1, col).getPreferredSize().getWidth(); +/* 276 */ for (int row = 0; row < rowCount; row++) { +/* 277 */ int preferedWidth = (int)myTable.getCellRenderer(row, col).getTableCellRendererComponent(myTable, myTable.getValueAt(row, col), false, false, row, col).getPreferredSize().getWidth(); +/* 278 */ width = Math.max(width, preferedWidth); + } +/* 280 */ header.setResizingColumn(column); +/* 281 */ column.setWidth(width + (myTable.getIntercellSpacing()).width); +/* 282 */ totalWidth = totalWidth + width + (myTable.getIntercellSpacing()).width; + } +/* 284 */ return totalWidth; + } + + public static boolean getTaskItemAddResult(AbstractAIFUIApplication application, TCSession session, FileType fileType, String title, Boolean isView, AbstractAIFCommand command, String dialogType) { +///* 290 */ String user_id = ""; +// try { +///* 292 */ user_id = session.getUser().getProperty("user_id"); +///* 293 */ } catch (TCException ex) { +///* 294 */ ex.printStackTrace(); +// } +/////* 296 */ String xmlFilePath = System.getProperty("java.io.tmpdir") + File.separator + user_id + "_" + getCurrentTime() + "_result.xml"; +/////* 297 */ String addResult = getErrorInfoFromCode(PlmErpIntegration.getTaskResult(user_id, fileType.toString(), AimType.add.toString(), xmlFilePath, session)); +// Map lastImpMap = new HashMap(); +//// if(resource.containsKey(user_id)) { +//// lastImpMap.put("creater", resource.getString(user_id)); +//// }else { +//// lastImpMap.put("creater", "ZX_COMM"); +//// } +// lastImpMap.put("creater", user_id); +// lastImpMap.put("type","ITEMADD"); +// Map plmImpResultMap = doGet(lastImpMap, "PLMImpResult", session); +// +/////* 298 */ if (addResult.equals("")) { +/////* 299 */ MessageBox.post(application.getDesktop().getShell(), "获取上次导入结果导入超时,请联系管理员!", "超时", 1); +/////* 300 */ return false; +//// } +///* 302 */ String ItemInfo = ""; +///* 303 */ StringBuffer detailInfo = new StringBuffer("新增基础数据
"); +/////* 304 */ if (!addResult.equals("成功")) { +/////* 305 */ MessageBox.post(application.getDesktop().getShell(), addResult, "调用erp函数出现错误", 1); +/////* 306 */ return false; +//// } +/////* 308 */ File xmlFile = new File(xmlFilePath); +/////* 309 */ if (xmlFile.exists()) { +///* 310 */ Map map = new HashMap(); +///* 311 */ boolean isResultFile = ReadResultXMLStr.loadElements(plmImpResultMap, map); +///* 312 */ if (isResultFile) { +///* 313 */ String taskSN = ""; +///* 314 */ if (map.get("taskSN") != null && !map.get("taskSN").equals("")) { +///* 315 */ taskSN = map.get("taskSN").toString(); +// } else { +///* 317 */ if (isView.booleanValue()) { +///* 318 */ MessageBox.post(application.getDesktop().getShell(), "新增基础数据未找到任务号!", "信息", 2); +///* 320 */ } else if (dialogType.equals("task")) { +///* 321 */ ((SendToERPCommand)command).postDialogForTask(); +///* 322 */ } else if (dialogType.equals("item")) { +///* 323 */ ((SendToERPCommand)command).postDialogForItem(); +///* 324 */ } else if (dialogType.equals("process")) { +///* 325 */ ((SendToERPCommand)command).postDialogForMeProcess(); +// } +///* 328 */ return true; +// } +///* 330 */ detailInfo.append("任务号:").append(taskSN).append("
"); +///* 331 */ int currentStep = Integer.parseInt(map.get("currentStep").toString()); +///* 332 */ if (currentStep == 3) { +///* 334 */ TCComponent[] forms = query(session, "origin_searchItemRevForm", new String[] { "nhl8_ERPTaskNum" }, new String[] { taskSN }); +///* 335 */ String taskResult = map.get("taskResult").toString(); +//if(forms!=null&&forms.length>0) { +///* 336 */ if (taskResult.equals("0")) { +///* 337 */ ItemInfo = "上次导入任务正在执行或排队,请稍候提交…"; +///* 338 */ } else if (taskResult.equals("1") || taskResult.equals("2")) { +///* 339 */ int formNum = forms.length; +///* 340 */ Object[] obj = new Object[1]; +///* 341 */ obj[0] = Integer.valueOf(11); +///* 342 */ TCUserService service = session.getUserService(); +///* 343 */ for (int i = 0; i < formNum; i++) { +// try { +///* 345 */ service.call("openByPass", obj); +///* 346 */ forms[i].setLogicalProperty("nhl8_ItemimpSucc", true); +///* 347 */ service.call("closeByPass", obj); +///* 348 */ } catch (TCException e) { +///* 349 */ e.printStackTrace(); +// } +// } +///* 352 */ ItemInfo = "新增基础数据导入成功!"; +// } else { +///* 354 */ List listWronglineInfo = (List)map.get("wrongLine"); +///* 355 */ List listWrongProcessItemId = new ArrayList(); +///* 356 */ if (listWronglineInfo != null) { +///* 357 */ int listSize = listWronglineInfo.size(); +///* 358 */ for (int j = 0; j < listSize; j++) { +///* 359 */ String wronglineInfo = listWronglineInfo.get(j); +///* 360 */ listWrongProcessItemId.add((new StringBuffer(wronglineInfo.split(" ")[0])).toString()); +///* 361 */ detailInfo.append(wronglineInfo).append("
"); +// } +// } +///* 365 */ int formNum = forms.length; +///* 366 */ Object[] obj = new Object[1]; +///* 367 */ obj[0] = Integer.valueOf(11); +///* 368 */ TCUserService service = session.getUserService(); +///* 369 */ for (int i = 0; i < formNum; i++) { +///* 370 */ String form_of_item_id = ""; +// try { +///* 372 */ form_of_item_id = forms[i].getProperty("object_name").split("/")[0]; +///* 373 */ } catch (TCException e1) { +///* 374 */ e1.printStackTrace(); +// } +///* 376 */ if (!listWrongProcessItemId.contains(form_of_item_id)) +// try { +///* 378 */ service.call("openByPass", obj); +///* 379 */ forms[i].setLogicalProperty("nhl8_ItemimpSucc", true); +///* 380 */ service.call("closeByPass", obj); +///* 381 */ } catch (TCException e) { +///* 382 */ e.printStackTrace(); +// } +// } +///* 386 */ if (taskResult.equals("3")) { +///* 387 */ ItemInfo = "新增基础数据任务错误"; +///* 388 */ } +//// else if (taskResult.equals("4")) { +/////* 389 */ ItemInfo = "新增基础数据部分数据导入失败,请修正后重新导入!"; +/////* 390 */ } else if (taskResult.equals("5")) { +/////* 391 */ ItemInfo = "新增基础数据任务失败,请修正后重新导入!"; +/////* 392 */ } else if (taskResult.equals("6")) { +/////* 393 */ ItemInfo = "新增基础数据任务导入失败,请修正!"; +//// } +// } +//}else { +// MessageBox.post("origin_searchItemRevForm查询器未找到表单属性nhl8_ERPTaskNum值为"+taskSN+"的表单","",MessageBox.INFORMATION); +//} +// } else { +///* 397 */ ItemInfo = "上次导入任务正在执行或排队,请稍候提交…"; +// } +// } else { +///* 400 */ String taskSN = (String) map.get("taskSN"); +///* 401 */ detailInfo.append("任务号:").append(taskSN).append("
"); +///* 402 */ TCComponent[] forms = query(session, "origin_searchItemRevForm", new String[] { "nhl8_ERPTaskNum" }, new String[] { taskSN }); +//if(forms!=null&&forms.length>0) { +///* 403 */ int formNum = forms.length; +///* 404 */ Map idmap = new HashMap(); +///* 405 */ Map idToFormmap = new HashMap(); +///* 406 */ String[] formProNames = { "nhl8_ProdrOrg", "nhl8_SpareOrg", "nhl8_UnprodrOrg" }; +///* 407 */ for (int i = 0; i < formNum; i++) { +///* 408 */ TCComponentForm form = (TCComponentForm)forms[i]; +///* 409 */ AIFComponentContext[] referenceComs = null; +// try { +///* 411 */ referenceComs = form.whereReferenced(); +///* 412 */ } catch (TCException e) { +///* 413 */ e.printStackTrace(); +// } +///* 415 */ int referenceNum = referenceComs.length; +///* 416 */ String itemId = ""; +///* 417 */ for (int j = 0; j < referenceNum; j++) { +///* 418 */ if (referenceComs[j].getComponent() instanceof TCComponentItemRevision) { +// try { +///* 420 */ itemId = referenceComs[j].getComponent().getProperty("item_id"); +///* 421 */ } catch (Exception e) { +///* 422 */ e.printStackTrace(); +// } +// break; +// } +// } +///* 427 */ idToFormmap.put(itemId, form); +///* 429 */ TCProperty[] formProperties = null; +// try { +///* 431 */ formProperties = form.getTCProperties(formProNames); +///* 432 */ idmap.put(itemId, String.valueOf(formProperties[0].getLogicalValue()) + "-" + formProperties[1].getLogicalValue() + "-" + formProperties[2].getLogicalValue()); +///* 433 */ } catch (TCException e) { +///* 434 */ e.printStackTrace(); +// } +// } +///* 437 */ List orgExistRightItems = new ArrayList(); +///* 438 */ List orgExistWrongItems = new ArrayList(); +///* 439 */ List Info = new ArrayList(); +// List checkResults = new ArrayList(); +// Map requestMap = new HashMap(); +// requestMap.put("sid", taskSN); +// requestMap.put("needParameter", "false"); +// Map responseMap = doGet(requestMap, "result", session); +// JSONObject responseMapJSON = JSONObject.fromObject(responseMap); +// JSONArray jsonArray = responseMapJSON.getJSONArray("checkResult"); +// checkResults = JSONArray.toList(jsonArray,CheckResult.class); +// +///* 440 */ ItemImportXMLReader.loadElements(checkResults, Info, orgExistRightItems, orgExistWrongItems, idmap); +///* 441 */ String errorInfo = Info.get(0); +///* 443 */ if (errorInfo.equals("")) { +///* 444 */ int orgExistRightItemNum = orgExistRightItems.size(); +///* 445 */ if (orgExistRightItemNum > 0) { +///* 446 */ if (orgExistRightItemNum == formNum) { +///* 447 */ ItemInfo = "成功:所要导入数据在ERP均已经存在,无需导入!"; +// } else { +///* 449 */ Object[] obj = new Object[1]; +///* 450 */ obj[0] = Integer.valueOf(11); +///* 451 */ TCUserService service = session.getUserService(); +///* 452 */ for (int k = 0; k < orgExistRightItemNum; k++) { +// try { +///* 454 */ service.call("openByPass", obj); +///* 455 */ ((TCComponentForm)idToFormmap.get(orgExistRightItems.get(k))).setLogicalProperty("nhl8_ItemimpSucc", true); +///* 456 */ service.call("closeByPass", obj); +///* 457 */ } catch (TCException e) { +///* 458 */ e.printStackTrace(); +// } +// } +///* 461 */ ItemInfo = "成功但有忽略"; +// } +// } else { +///* 464 */ ItemInfo = "验证成功"; +///* 465 */ return true; +// } +// } else { +///* 468 */ detailInfo.append(errorInfo).append("
"); +///* 469 */ int orgExistWrongItemNum = orgExistWrongItems.size(); +///* 470 */ if (orgExistWrongItemNum > 0) { +///* 471 */ if (orgExistWrongItemNum == formNum) { +///* 472 */ ItemInfo = "成功但有忽略"; +// } else { +///* 474 */ ItemInfo = "成功但有忽略"; +///* 475 */ Object[] obj = new Object[1]; +///* 476 */ obj[0] = Integer.valueOf(11); +///* 477 */ TCUserService service = session.getUserService(); +///* 478 */ for (int k = 0; k < orgExistWrongItemNum; k++) { +// try { +///* 480 */ service.call("openByPass", obj); +///* 481 */ ((TCComponentForm)idToFormmap.get(orgExistWrongItems.get(k))).setLogicalProperty("nhl8_ItemimpSucc", true); +///* 482 */ service.call("closeByPass", obj); +///* 483 */ } catch (TCException e) { +///* 484 */ e.printStackTrace(); +// } +// } +// } +// } else { +///* 489 */ ItemInfo = "新增基础物料任务导入失败,请修正!"; +// } +// } +// }else { +// MessageBox.post("origin_searchItemRevForm查询器未找到表单属性nhl8_ERPTaskNum值为"+taskSN+"的表单","",MessageBox.INFORMATION); +// } +// } +//// } else { +/////* 494 */ System.out.println(String.valueOf(xmlFilePath) + "文件不存在!"); +//// } +///* 497 */ System.out.println("401 ItemInfo=" + ItemInfo); +///* 498 */ if (!ItemInfo.contains("成功")) { +///* 499 */ SwingUtilities.invokeLater((Runnable)new ValidateFailDialog(ItemInfo.toString(), title, detailInfo.toString(), command, dialogType)); +///* 500 */ return false; +// } if (isView.booleanValue()) { +// /* 503 */ SwingUtilities.invokeLater((Runnable)new ValidateFailDialog(ItemInfo.toString(), title, detailInfo.toString())); +// /* 505 */ } else +/* 502 */ if (dialogType.equals("task")) { +/* 506 */ ((SendToERPCommand)command).postDialogForTask(); +/* 507 */ } else if (dialogType.equals("item")) { +/* 508 */ ((SendToERPCommand)command).postDialogForItem(); +/* 509 */ } else if (dialogType.equals("process")) { +/* 510 */ ((SendToERPCommand)command).postDialogForMeProcess(); + } +/* 513 */ return true; + } + + public static Map doGet(Map map, String svr, TCSession session) { + HashMap preferenceHashMap = TCPreferenceUitl.getPreferenceHashMap(session, TCPreferenceService.TC_preference_site, erpPreference); + String url = preferenceHashMap.get("url"); + String token = preferenceHashMap.get("token"); + JSONObject itemCheckJson = JSONObject.fromObject(map); +// List checkResults =null; + Map resultMap = new HashMap(); + try { + System.out.println("开始发送请求"); + String args = itemCheckJson.toString(); + if(svr.equals("PLMImpResult")) { + token = URLEncoder.encode(token,"UTF-8"); + svr = URLEncoder.encode(svr,"UTF-8"); + args = URLEncoder.encode(args,"UTF-8"); + String param = "usr="+token+"&svr="+svr+"&args="+args; + System.out.println("url=============="+url); + System.out.println("param==========="+param); + String response = HttpUtil.doGet(url+"?"+param); + System.out.println("请求结果================"+response); + + JSONObject jsonObject = JSONObject.fromObject(response); + if(jsonObject==null || response==null) { + return null; + } + System.out.println("json格式==============="+jsonObject); + + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); + System.out.println("cont==============="+jsonObject2); + + String last_task_sid = jsonObject2.getString("last_task_sid"); + if(last_task_sid.contains("NOTEXIST")) { + System.out.println("位置utilapi"); +// MessageBox.post("不存在上一次导入结果","",MessageBox.INFORMATION); + return null; + }else { + resultMap = (Map)JSONObject.toBean(jsonObject2,Map.class); + } + }else if(svr.equals("result")){ + token = URLEncoder.encode(token,"UTF-8"); + svr = URLEncoder.encode(svr,"UTF-8"); + args = URLEncoder.encode(args,"UTF-8"); + String param = "usr="+token+"&svr="+svr+"&args="+args; + System.out.println("url=============="+url); + System.out.println("param==========="+param); + String response = HttpUtil.doGet(url+"?"+param); + System.out.println("请求结果================"+response); + + JSONObject jsonObject = JSONObject.fromObject(response); + System.out.println("json格式==============="+jsonObject); + JSONObject jsonObject2 = jsonObject.getJSONObject("cont"); + System.out.println("cont==============="+jsonObject2); + JSONObject jsonObject3 = jsonObject2.getJSONObject("output"); + + resultMap = (Map)JSONObject.toBean(jsonObject3,Map.class); + } + +// JSONArray checkResult = jsonObject2.getJSONArray("checkResult"); +// canAllImport = jsonObject2.getBoolean("canAllImport"); +// checkResults = JSONArray.toList(checkResult,CheckResult.class); + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return resultMap; + } + + public static boolean getTaskBomAddResult(AbstractAIFUIApplication application, TCSession session, FileType fileType, String title) { +/* 519 */ ResultInfo addResultInfo = getBomaddResult(application, session, FileType.bom); +/* 520 */ if (addResultInfo == null) +/* 521 */ return false; +/* 523 */ String result = addResultInfo.getResult(); +/* 524 */ if (result.equals("新增BOM没有发现任务号!")) +/* 525 */ return true; +/* 526 */ if (!result.equals("新增BOM任务导入成功!")) { +/* 527 */ SwingUtilities.invokeLater((Runnable)new ValidateFailDialog(result, title, addResultInfo.getDetail())); +/* 528 */ return false; + } +/* 531 */ return true; + } + + public static boolean getTaskBomAddResult(AbstractAIFUIApplication application, TCSession session, FileType fileType, String title, AbstractAIFCommand command, String dialogType, AimType aimType) { +///* 536 */ ResultInfo addResultInfo = getBomaddResult(application, session, FileType.bom); +///* 537 */ if (addResultInfo == null) { + + if (dialogType.equals("task")) { + /* 543 */ ((BomTransferCommand)command).postDialogForTask(aimType); + /* 544 */ } else if (dialogType.equals("bom")) { + /* 545 */ ((BomTransferCommand)command).postDialogForBom(aimType); + } + return true; +// } +///* 538 */ +///* 540 */ String result = addResultInfo.getResult(); +///* 541 */ if (result.equals("新增BOM没有发现任务号!") || result.equals("新增BOM任务导入成功!")) { +///* 542 */ if (dialogType.equals("task")) { +///* 543 */ ((BomTransferCommand)command).postDialogForTask(aimType); +///* 544 */ } else if (dialogType.equals("bom")) { +///* 545 */ ((BomTransferCommand)command).postDialogForBom(aimType); +// } +///* 547 */ return true; +// } +///* 549 */ SwingUtilities.invokeLater((Runnable)new ValidateFailDialog(result, title, addResultInfo.getDetail(), command, dialogType, aimType)); +///* 550 */ return false; + } + + public static boolean getTaskBomChgResult(AbstractAIFUIApplication application, TCSession session, FileType fileType, String title) { +/* 557 */ ResultInfo chgResultInfo = getBomchgResult(application, session, FileType.bom); +/* 558 */ if (chgResultInfo == null) +/* 559 */ return false; +/* 561 */ String result = chgResultInfo.getResult(); +/* 562 */ if (result.equals("变更BOM没有发现任务号!")) +/* 563 */ return true; +/* 564 */ if (!result.equals("变更BOM任务导入成功!")) { +/* 565 */ SwingUtilities.invokeLater((Runnable)new ValidateFailDialog(chgResultInfo.getResult(), title, chgResultInfo.getDetail())); +/* 566 */ return false; + } +/* 569 */ return true; + } + + public static boolean getTaskBomChgResult(AbstractAIFUIApplication application, TCSession session, FileType fileType, String title, AbstractAIFCommand command, String dialogType, AimType aimType) { +///* 573 */ ResultInfo chgResultInfo = getBomchgResult(application, session, FileType.bom); +///* 574 */ if (chgResultInfo == null) { +// if (dialogType.equals("task")) { +///* 580 */ ((BomTransferCommand)command).postDialogForTask(aimType); +///* 581 */ } else if (dialogType.equals("bom")) { +///* 582 */ ((BomTransferCommand)command).postDialogForBom(aimType); +// } +///* 584 */ return true; +// } +/* 577 */ String result = "变更BOM没有发现任务号!"; +/* 578 */ if (result.equals("变更BOM没有发现任务号!") || result.equals("变更BOM任务导入成功!")) { +/* 579 */ if (dialogType.equals("task")) { +/* 580 */ ((BomTransferCommand)command).postDialogForTask(aimType); +/* 581 */ } else if (dialogType.equals("bom")) { +/* 582 */ ((BomTransferCommand)command).postDialogForBom(aimType); + } +/* 584 */ return true; + } +///* 586 */ SwingUtilities.invokeLater((Runnable)new ValidateFailDialog(chgResultInfo.getResult(), title, chgResultInfo.getDetail(), command, dialogType, aimType)); +/* 587 */ return false; + } + +// public static void getTaskBomResult(AbstractAIFUIApplication application, TCSession session, FileType fileType, String title) { +///* 595 */ ResultInfo addResultInfo = getBomaddResult(application, session, FileType.bom); +///* 596 */ ResultInfo chgResultInfo = getBomchgResult(application, session, FileType.bom); +///* 597 */ if (addResultInfo != null && chgResultInfo != null) { +///* 598 */ String BomInfo = ""; +///* 599 */ String addResult = addResultInfo.getResult(); +///* 600 */ String chgResult = chgResultInfo.getResult(); +///* 601 */ if (addResult.equals("新增BOM没有发现任务号!") && chgResult.equals("变更BOM没有发现任务号!")) { +///* 602 */ MessageBox.post(application.getDesktop().getShell(), "新增和更改BOM没有发现任务号!", "信息", 2); +// return; +// } +///* 605 */ if (addResult.equals("新增BOM任务导入成功!") && chgResult.equals("变更BOM任务导入成功!")) { +///* 606 */ BomInfo = "新增/变更BOM均导入成功!"; +// } else { +///* 608 */ BomInfo = String.valueOf(addResult) + "
" + chgResult; +// } +///* 610 */ String detailInfo = String.valueOf(addResultInfo.getDetail()) + chgResultInfo.getDetail(); +///* 611 */ SwingUtilities.invokeLater((Runnable)new ValidateFailDialog(BomInfo, title, detailInfo)); +// } +// } + + public static ResultInfo getBomaddResult(AbstractAIFUIApplication application, TCSession session, FileType fileType) { +/* 618 */ String user_id = ""; + try { + user_id = session.getUser().getProperty("user_id"); + } catch (TCException ex) { + ex.printStackTrace(); + } +///* 624 */ String xmlFilePath = System.getProperty("java.io.tmpdir") + File.separator + user_id + "_" + getCurrentTime() + "_result.xml"; +/* 625 */ String BomaddInfo = ""; +///* 627 */ String addResult = getErrorInfoFromCode(PlmErpIntegration.getTaskResult(user_id, fileType.toString(), AimType.add.toString(), xmlFilePath, session)); +///* 627 */ String addResult = ""; +///* 628 */ if (addResult.equals("")) { +///* 629 */ MessageBox.post(application.getDesktop().getShell(), "获取上次导入结果导入超时,请联系管理员!", "超时", 1); +///* 630 */ return null; +// } +/* 632 */ StringBuffer addDetailInfo = new StringBuffer("新增BOM
"); +Map lastImpMap = new HashMap(); +//if(resource.containsKey(user_id)) { +// lastImpMap.put("creater", resource.getString(user_id)); +//}else { +// lastImpMap.put("creater", "ZX_COMM"); +//} +lastImpMap.put("creater", user_id); +lastImpMap.put("type","BOMADD"); + Map plmImpResultMap = doGet(lastImpMap, "PLMImpResult", session); +///* 633 */ if (!addResult.equals("成功")) { +///* 634 */ MessageBox.post(application.getDesktop().getShell(), addResult, "调用erp函数出现错误", 1); +///* 635 */ return null; +// } +///* 637 */ File xmlFile = new File(xmlFilePath); +///* 638 */ if (xmlFile.exists()) { + if(plmImpResultMap==null) { + return null; + } +/* 639 */ Map map = new HashMap(); +/* 640 */ boolean isResultFile = ReadResultXMLStr.loadElements(plmImpResultMap, map); +///* 640 */ boolean isResultFile = true; +/* 641 */ if (isResultFile) { +/* 642 */ String taskSN = ""; +/* 643 */ if (map.get("taskSN") != null && !map.get("taskSN").equals("")) { +/* 644 */ taskSN = map.get("taskSN").toString(); + } else { +/* 646 */ ResultInfo resultInfo = new ResultInfo("新增BOM没有发现任务号!", ""); +/* 647 */ return resultInfo; + } +/* 649 */ addDetailInfo.append("任务号:").append(taskSN).append("
"); +/* 650 */ int currentStep = Integer.parseInt(map.get("currentStep").toString()); +/* 651 */ if (currentStep == 3) { +/* 653 */ TCComponent[] forms = query(session, "origin_searchItemRevForm", new String[] { "nhl8_ERPTaskNum" }, new String[] { taskSN }); +if(forms!=null&&forms.length>0) { +/* 654 */ String taskResult = map.get("taskResult").toString(); +/* 655 */ if (taskResult.equals("0")) { +/* 656 */ BomaddInfo = "上次导入任务正在执行或排队,请稍候提交…"; +/* 657 */ } else if (taskResult.equals("1") || taskResult.equals("2")) { +/* 658 */ int formNum = forms.length; +/* 659 */ Object[] obj = new Object[1]; +/* 660 */ obj[0] = Integer.valueOf(11); +/* 661 */ TCUserService service = session.getUserService(); +/* 662 */ for (int i = 0; i < formNum; i++) { + try { +/* 664 */ service.call("openByPass", obj); +/* 665 */ forms[i].setLogicalProperty("nhl8_BOMimpSucc", true); +/* 666 */ service.call("closeByPass", obj); +/* 667 */ } catch (TCException e) { +/* 668 */ e.printStackTrace(); + } + } +/* 671 */ BomaddInfo = "新增BOM任务导入成功!"; + } else { +/* 673 */ List listWronglineInfo = (List)map.get("wrongLine"); +/* 674 */ List listWrongProcessItemId = new ArrayList(); +/* 675 */ int listSize = listWronglineInfo.size(); +/* 676 */ for (int i = 0; i < listSize; i++) { +/* 677 */ String wronglineInfo = listWronglineInfo.get(i); +/* 678 */ listWrongProcessItemId.add((new StringBuffer(wronglineInfo.split(" ")[0])).toString()); +/* 679 */ addDetailInfo.append(wronglineInfo).append("
"); + } +/* 681 */ int formNum = forms.length; +/* 682 */ Object[] obj = new Object[1]; +/* 683 */ obj[0] = Integer.valueOf(11); +/* 684 */ TCUserService service = session.getUserService(); +/* 685 */ for (int j = 0; j < formNum; j++) { +/* 686 */ String form_of_item_id = ""; + try { +/* 688 */ form_of_item_id = forms[j].getProperty("object_name").split("/")[0]; +/* 689 */ } catch (TCException e1) { +/* 690 */ e1.printStackTrace(); + } +/* 692 */ if (!listWrongProcessItemId.contains(form_of_item_id)) + try { +/* 694 */ service.call("openByPass", obj); +/* 695 */ forms[j].setLogicalProperty("nhl8_BOMimpSucc", true); +/* 696 */ service.call("closeByPass", obj); +/* 697 */ } catch (TCException e) { +/* 698 */ e.printStackTrace(); + } + } +/* 702 */ if (taskResult.equals("3")) { +/* 703 */ BomaddInfo = "新增BOM任务错误"; +/* 704 */ } +//else if (taskResult.equals("4")) { +///* 705 */ BomaddInfo = "新增BOM部分数据导入失败,请修正后重新导入!"; +///* 706 */ } else if (taskResult.equals("5")) { +///* 707 */ BomaddInfo = "新增BOM任务失败,请修正后重新导入!"; +///* 708 */ } else if (taskResult.equals("6")) { +///* 709 */ BomaddInfo = "新增BOM任务导入失败,请修正!"; +// } + } +}else { + MessageBox.post("origin_searchItemRevForm查询器未找到表单属性nhl8_ERPTaskNum值为"+taskSN+"的表单","",MessageBox.INFORMATION); +} + } else { +/* 713 */ BomaddInfo = "上次导入任务正在执行或排队,请稍候提交…"; + } + } else { +/* 716 */ String taskSN = (String) map.get("taskSN"); +/* 717 */ addDetailInfo.append("任务号:").append(taskSN).append("
"); +/* 719 */ StringBuffer errorInfo = new StringBuffer(""); + List checkResults = new ArrayList(); + Map requestMap = new HashMap(); + requestMap.put("sid", taskSN); + requestMap.put("needParameter", "false"); + Map responseMap = doGet(requestMap, "result", session); + JSONObject responseMapJSON = JSONObject.fromObject(responseMap); + JSONArray jsonArray = responseMapJSON.getJSONArray("checkResult"); + checkResults = JSONArray.toList(jsonArray,BomCheckResult.class); +// BomAddImportXMLReader.loadElements(checkResults, errorInfo); +/* 721 */ addDetailInfo.append(errorInfo.toString()).append("
"); +/* 722 */ BomaddInfo = "新增BOM任务导入失败,请修正!"; + } +// } else { +///* 725 */ System.out.println(String.valueOf(xmlFilePath) + "文件不存在!"); +// } +/* 728 */ ResultInfo result = new ResultInfo(BomaddInfo, addDetailInfo.toString()); +/* 729 */ return result; + } + + public static ResultInfo getBomchgResult(AbstractAIFUIApplication application, TCSession session, FileType fileType) { +/* 735 */ String user_id = ""; + try { +/* 737 */ user_id = session.getUser().getProperty("user_id"); +/* 738 */ } catch (TCException ex) { +/* 739 */ ex.printStackTrace(); + } +///* 741 */ String xmlFilePath = System.getProperty("java.io.tmpdir") + File.separator + user_id + "_" + getCurrentTime() + "_result.xml"; +/* 743 */ String BomchgInfo = ""; +///* 745 */ String chgResult = getErrorInfoFromCode(PlmErpIntegration.getTaskResult(user_id, fileType.toString(), AimType.chg.toString(), xmlFilePath, session)); +///* 745 */ String chgResult = ""; +///* 746 */ if (chgResult.equals("")) { +///* 747 */ MessageBox.post(application.getDesktop().getShell(), "获取上次导入结果导入超时,请联系管理员!", "超时", 1); +///* 748 */ return null; +// } +/* 750 */ StringBuffer chgDetailInfo = new StringBuffer("变更BOM
"); +///* 751 */ if (!chgResult.equals("成功")) { +///* 752 */ MessageBox.post(application.getDesktop().getShell(), chgResult, "调用erp函数出现错误", 1); +///* 753 */ return null; +// } + Map lastImpMap = new HashMap(); +// if(resource.containsKey(user_id)) { +// lastImpMap.put("creater", resource.getString(user_id)); +// }else { +// lastImpMap.put("creater", "ZX_COMM"); +// } + lastImpMap.put("creater", user_id); + lastImpMap.put("type","BOMCHG"); + Map plmImpResultMap = doGet(lastImpMap, "PLMImpResult", session); +///* 755 */ File xmlFile = new File(xmlFilePath); +///* 756 */ if (xmlFile.exists()) { +/* 757 */ Map map = new HashMap(); +/* 758 */ boolean isResultFile = ReadResultXMLStr.loadElements(plmImpResultMap, map); +///* 758 */ boolean isResultFile = true; +/* 759 */ if (isResultFile) { +/* 760 */ String taskSN = ""; +/* 761 */ if (map.get("taskSN") != null && !map.get("taskSN").equals("")) { +/* 762 */ taskSN = map.get("taskSN").toString(); + } else { +/* 764 */ ResultInfo resultInfo = new ResultInfo("变更BOM没有发现任务号!", ""); +/* 765 */ return resultInfo; + } +/* 767 */ chgDetailInfo.append("任务号:").append(taskSN).append("
"); +/* 768 */ int currentStep = Integer.parseInt(map.get("currentStep").toString()); +/* 769 */ if (currentStep == 3) { +/* 771 */ TCComponent[] forms = query(session, "origin_searchItemRevForm", new String[] { "nhl8_ERPTaskNum" }, new String[] { taskSN }); +/* 772 */ String taskResult = map.get("taskResult").toString(); +if(forms!=null&&forms.length>0) { +/* 773 */ if (taskResult.equals("0")) { +/* 774 */ BomchgInfo = "上次导入任务正在执行或排队,请稍候提交…"; +/* 775 */ } else if (taskResult.equals("1") || taskResult.equals("2")) { +/* 776 */ int formNum = forms.length; +/* 777 */ Object[] obj = new Object[1]; +/* 778 */ obj[0] = Integer.valueOf(11); +/* 779 */ TCUserService service = session.getUserService(); +/* 780 */ for (int i = 0; i < formNum; i++) { + try { +/* 782 */ service.call("openByPass", obj); +/* 783 */ forms[i].setLogicalProperty("nhl8_BOMimpSucc", true); +/* 784 */ service.call("closeByPass", obj); +/* 785 */ } catch (TCException e) { +/* 786 */ e.printStackTrace(); + } + } +/* 789 */ BomchgInfo = "变更BOM任务导入成功!"; + } else { +/* 791 */ List listWronglineInfo = (List)map.get("wrongLine"); +/* 792 */ List listWrongProcessItemId = new ArrayList(); +/* 793 */ int listSize = listWronglineInfo.size(); +/* 794 */ for (int i = 0; i < listSize; i++) { +/* 795 */ String wronglineInfo = listWronglineInfo.get(i); +/* 796 */ listWrongProcessItemId.add((new StringBuffer(wronglineInfo.split(" ")[0])).toString()); +/* 797 */ chgDetailInfo.append(wronglineInfo).append("
"); + } +/* 799 */ int formNum = forms.length; +/* 800 */ Object[] obj = new Object[1]; +/* 801 */ obj[0] = Integer.valueOf(11); +/* 802 */ TCUserService service = session.getUserService(); +/* 803 */ for (int j = 0; j < formNum; j++) { +/* 804 */ String form_of_item_id = ""; + try { +/* 806 */ form_of_item_id = forms[j].getProperty("object_name").split("/")[0]; +/* 807 */ } catch (TCException e1) { +/* 808 */ e1.printStackTrace(); + } +/* 811 */ if (!listWrongProcessItemId.contains(form_of_item_id)) + try { +/* 813 */ service.call("openByPass", obj); +/* 814 */ forms[j].setLogicalProperty("nhl8_BOMimpSucc", true); +/* 815 */ service.call("closeByPass", obj); +/* 816 */ } catch (TCException e) { +/* 817 */ e.printStackTrace(); + } + } +/* 821 */ if (taskResult.equals("3")) { +/* 822 */ BomchgInfo = "变更BOM任务导入错误,请至ERP修改!"; +/* 823 */ } +// else if (taskResult.equals("4")) { +///* 824 */ BomchgInfo = "变更BOM部分数据导入失败,请修正后重新导入!"; +///* 825 */ } else if (taskResult.equals("5")) { +///* 826 */ BomchgInfo = "变更BOM任务失败,请修正后重新导入!"; +///* 827 */ } else if (taskResult.equals("6")) { +///* 828 */ BomchgInfo = "变更BOM任务导入失败,请修正!"; +// } + } +}else { + MessageBox.post("origin_searchItemRevForm查询器未找到表单属性nhl8_ERPTaskNum值为"+taskSN+"的表单","",MessageBox.INFORMATION); +} + } else { +/* 832 */ BomchgInfo = "上次导入任务正在执行或排队,请稍候提交…"; + } + } else { +/* 835 */ String taskSN = map.get("taskSN").toString(); +/* 836 */ chgDetailInfo.append("任务号:").append(taskSN).append("
"); + List checkResults = new ArrayList(); + Map requestMap = new HashMap(); + requestMap.put("sid", taskSN); + requestMap.put("needParameter", "false"); + Map responseMap = doGet(requestMap, "result", session); + JSONObject responseMapJSON = JSONObject.fromObject(responseMap); + JSONArray jsonArray = responseMapJSON.getJSONArray("checkResult"); + checkResults = JSONArray.toList(jsonArray,BomCheckResult.class); + String errorInfo = BomChgImportXMLReader.loadElements(checkResults); +/* 838 */ chgDetailInfo.append(errorInfo).append("
"); +/* 840 */ BomchgInfo = "变更BOM任务导入失败,请修正!"; + } +// } else { +///* 844 */ System.out.println(String.valueOf(xmlFilePath) + "文件不存在!"); +// } +/* 847 */ ResultInfo result = new ResultInfo(BomchgInfo, chgDetailInfo.toString()); +/* 848 */ return result; + } + + public static String getTaskSN(File xmlFile) { +/* 853 */ SAXBuilder sb = new SAXBuilder(); +/* 854 */ String taskSN = null; + try { +/* 857 */ Document doc = sb.build(xmlFile); +/* 859 */ Element root = doc.getRootElement(); +/* 861 */ taskSN = root.getAttribute("taskSN").getValue(); +/* 863 */ } catch (JDOMException e) { +/* 864 */ e.printStackTrace(); +/* 865 */ } catch (IOException e) { +/* 866 */ e.printStackTrace(); + } +/* 868 */ return taskSN; + } + + public static String subZeroAndDot(String s) { +/* 877 */ if (s.indexOf(".") > 0) { +/* 878 */ s = s.replaceAll("0+?$", ""); +/* 879 */ s = s.replaceAll("[.]$", ""); + } +/* 881 */ return s; + } + + public static double div(double v1, double v2) { +/* 892 */ return div(v1, v2, 10); + } + + public static double div(double v1, double v2, int scale) { +/* 904 */ if (scale < 0) +/* 905 */ throw new IllegalArgumentException( +/* 906 */ "The scale must be a positive integer or zero"); +/* 908 */ BigDecimal b1 = new BigDecimal(Double.toString(v1)); +/* 909 */ BigDecimal b2 = new BigDecimal(Double.toString(v2)); +/* 910 */ return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue(); + } + + public static double add(double v1, double v2) { +/* 920 */ BigDecimal b1 = new BigDecimal(Double.toString(v1)); +/* 921 */ BigDecimal b2 = new BigDecimal(Double.toString(v2)); +/* 922 */ return b1.add(b2).doubleValue(); + } + } + diff --git a/src/com/connor/erpintegration/entity/BOMLineEntity.java b/src/com/connor/erpintegration/entity/BOMLineEntity.java new file mode 100644 index 0000000..421412d --- /dev/null +++ b/src/com/connor/erpintegration/entity/BOMLineEntity.java @@ -0,0 +1,57 @@ +package com.connor.erpintegration.entity; + +public class BOMLineEntity { + + private String item; + private String operation_seq_num; + private String item_exist; + private String item_valid; + private String locator_integrity; + private String operation_seq_num_exist_in_route; + public String getItem() { + return item; + } + public void setItem(String item) { + this.item = item; + } + public String getOperation_seq_num() { + return operation_seq_num; + } + public void setOperation_seq_num(String operation_seq_num) { + this.operation_seq_num = operation_seq_num; + } + public String getItem_exist() { + return item_exist; + } + public void setItem_exist(String item_exist) { + this.item_exist = item_exist; + } + public String getItem_valid() { + return item_valid; + } + public void setItem_valid(String item_valid) { + this.item_valid = item_valid; + } + public String getLocator_integrity() { + return locator_integrity; + } + public void setLocator_integrity(String locator_integrity) { + this.locator_integrity = locator_integrity; + } + public String getOperation_seq_num_exist_in_route() { + return operation_seq_num_exist_in_route; + } + public void setOperation_seq_num_exist_in_route(String operation_seq_num_exist_in_route) { + this.operation_seq_num_exist_in_route = operation_seq_num_exist_in_route; + } + @Override + public String toString() { + return "BOMLine [item=" + item + ", operation_seq_num=" + operation_seq_num + ", item_exist=" + item_exist + + ", item_valid=" + item_valid + ", locator_integrity=" + locator_integrity + + ", operation_seq_num_exist_in_route=" + operation_seq_num_exist_in_route + "]"; + } + + + + +} diff --git a/src/com/connor/erpintegration/entity/BomCheckResult.java b/src/com/connor/erpintegration/entity/BomCheckResult.java new file mode 100644 index 0000000..f1ff37d --- /dev/null +++ b/src/com/connor/erpintegration/entity/BomCheckResult.java @@ -0,0 +1,66 @@ +package com.connor.erpintegration.entity; + +import java.util.List; + +public class BomCheckResult { + + private String assembly_item; + private String assembly_item_exist; + private String locator_integrity; + private String bom_exist; + private String route_exist; + private String canBOMImport; + private List BOMLine; + public String getAssembly_item() { + return assembly_item; + } + public void setAssembly_item(String assembly_item) { + this.assembly_item = assembly_item; + } + public String getAssembly_item_exist() { + return assembly_item_exist; + } + public void setAssembly_item_exist(String assembly_item_exist) { + this.assembly_item_exist = assembly_item_exist; + } + public String getLocator_integrity() { + return locator_integrity; + } + public void setLocator_integrity(String locator_integrity) { + this.locator_integrity = locator_integrity; + } + public String getBom_exist() { + return bom_exist; + } + public void setBom_exist(String bom_exist) { + this.bom_exist = bom_exist; + } + public String getRoute_exist() { + return route_exist; + } + public void setRoute_exist(String route_exist) { + this.route_exist = route_exist; + } + + public List getBOMLine() { + return BOMLine; + } + public void setBOMLine(List bOMline) { + BOMLine = bOMline; + } + + public String getCanBOMImport() { + return canBOMImport; + } + public void setCanBOMImport(String canBOMImport) { + this.canBOMImport = canBOMImport; + } + @Override + public String toString() { + return "BomCheckResult [assembly_item=" + assembly_item + ", assembly_item_exist=" + assembly_item_exist + + ", locator_integrity=" + locator_integrity + ", bom_exist=" + bom_exist + ", route_exist=" + + route_exist + ", canBOMImport=" + canBOMImport + ", BOMLine=" + BOMLine + "]"; + } + + +} diff --git a/src/com/connor/erpintegration/entity/CheckResult.java b/src/com/connor/erpintegration/entity/CheckResult.java new file mode 100644 index 0000000..db2c81c --- /dev/null +++ b/src/com/connor/erpintegration/entity/CheckResult.java @@ -0,0 +1,66 @@ +package com.connor.erpintegration.entity; + +public class CheckResult { + + private String item; + private String uom; + private Boolean existInNHL; + private Boolean existInNSC; + private Boolean existInNBJ; + private Boolean existInNSJ; + private Boolean uomExist; + private Boolean canImport; + public String getItem() { + return item; + } + public void setItem(String item) { + this.item = item; + } + public String getUom() { + return uom; + } + public void setUom(String uom) { + this.uom = uom; + } + public Boolean getExistInNHL() { + return existInNHL; + } + public void setExistInNHL(Boolean existInNHL) { + this.existInNHL = existInNHL; + } + public Boolean getExistInNSC() { + return existInNSC; + } + public void setExistInNSC(Boolean existInNSC) { + this.existInNSC = existInNSC; + } + public Boolean getExistInNBJ() { + return existInNBJ; + } + public void setExistInNBJ(Boolean existInNBJ) { + this.existInNBJ = existInNBJ; + } + public Boolean getExistInNSJ() { + return existInNSJ; + } + public void setExistInNSJ(Boolean existInNSJ) { + this.existInNSJ = existInNSJ; + } + public Boolean getUomExist() { + return uomExist; + } + public void setUomExist(Boolean uomExist) { + this.uomExist = uomExist; + } + public Boolean getCanImport() { + return canImport; + } + public void setCanImport(Boolean canImport) { + this.canImport = canImport; + } + public CheckResult() { + super(); + } + + +} diff --git a/src/com/connor/erpintegration/entity/DepResEntity.java b/src/com/connor/erpintegration/entity/DepResEntity.java new file mode 100644 index 0000000..a958db1 --- /dev/null +++ b/src/com/connor/erpintegration/entity/DepResEntity.java @@ -0,0 +1,44 @@ +package com.connor.erpintegration.entity; + +public class DepResEntity { + + private int DEPARTMENT_ID; + private String DESCRIPTION; + private String DEPARTMENT_CODE; + + public DepResEntity() { + super(); + } + + public int getDEPARTMENT_ID() { + return DEPARTMENT_ID; + } + + public void setDEPARTMENT_ID(int dEPARTMENT_ID) { + DEPARTMENT_ID = dEPARTMENT_ID; + } + + public String getDESCRIPTION() { + return DESCRIPTION; + } + + public void setDESCRIPTION(String dESCRIPTION) { + DESCRIPTION = dESCRIPTION; + } + + public String getDEPARTMENT_CODE() { + return DEPARTMENT_CODE; + } + + public void setDEPARTMENT_CODE(String dEPARTMENT_CODE) { + DEPARTMENT_CODE = dEPARTMENT_CODE; + } + + @Override + public String toString() { + return "DepRes [DEPARTMENT_ID=" + DEPARTMENT_ID + ", DESCRIPTION=" + DESCRIPTION + ", DEPARTMENT_CODE=" + + DEPARTMENT_CODE + "]"; + } + + +} diff --git a/src/com/connor/erpintegration/entity/ERPResultEntity.java b/src/com/connor/erpintegration/entity/ERPResultEntity.java new file mode 100644 index 0000000..e86e8ce --- /dev/null +++ b/src/com/connor/erpintegration/entity/ERPResultEntity.java @@ -0,0 +1,86 @@ +package com.connor.erpintegration.entity; + +import java.sql.Date; + +public class ERPResultEntity { + + private String ItemId;//导入对象 + private String TaskType;//任务类型 + private String TaskNumber;//任务号 + private String ImpDate;//导入时间 + private String UserName;//导入人 + private String ImpResult;//导入结果 + private String ErrorInfo;//错误信息 + private String Version;//错误信息 + public String getErrorInfo() { + return ErrorInfo; + } + public String getVersion() { + return Version; + } + public void setVersion(String version) { + Version = version; + } + public void setErrorInfo(String errorInfo) { + ErrorInfo = errorInfo; + } + public String getItemId() { + return ItemId; + } + public void setItemId(String itemId) { + ItemId = itemId; + } + public String getTaskType() { + return TaskType; + } + public void setTaskType(String taskType) { + TaskType = taskType; + } + public String getTaskNumber() { + return TaskNumber; + } + public void setTaskNumber(String taskNumber) { + TaskNumber = taskNumber; + } + public String getImpDate() { + return ImpDate; + } + public void setImpDate(String impDate) { + ImpDate = impDate; + } + public String getUserName() { + return UserName; + } + public void setUserName(String userName) { + UserName = userName; + } + public String getImpResult() { + return ImpResult; + } + public void setImpResult(String impResult) { + ImpResult = impResult; + } + + @Override + public String toString() { + return "ERPResultEntity [ItemId=" + ItemId + ", TaskType=" + TaskType + ", TaskNumber=" + TaskNumber + + ", ImpDate=" + ImpDate + ", UserName=" + UserName + ", ImpResult=" + ImpResult + ", ErrorInfo=" + + ErrorInfo + "]"; + } + public ERPResultEntity(String itemId, String taskType, String taskNumber, String impDate, String userName, + String impResult, String errorInfo) { + super(); + ItemId = itemId; + TaskType = taskType; + TaskNumber = taskNumber; + ImpDate = impDate; + UserName = userName; + ImpResult = impResult; + ErrorInfo = errorInfo; + } + public ERPResultEntity() { + super(); + } + + +} diff --git a/src/com/connor/erpintegration/entity/RouteCheckResult.java b/src/com/connor/erpintegration/entity/RouteCheckResult.java new file mode 100644 index 0000000..b4c8434 --- /dev/null +++ b/src/com/connor/erpintegration/entity/RouteCheckResult.java @@ -0,0 +1,50 @@ +package com.connor.erpintegration.entity; + +import java.util.List; + +public class RouteCheckResult { + + private String assembly_item; + private String assembly_item_exist; + private String route_exist; + private List RouteLine; + private String canRouteImport; + public String getAssembly_item() { + return assembly_item; + } + public void setAssembly_item(String assembly_item) { + this.assembly_item = assembly_item; + } + public String getAssembly_item_exist() { + return assembly_item_exist; + } + public void setAssembly_item_exist(String assembly_item_exist) { + this.assembly_item_exist = assembly_item_exist; + } + public String getRoute_exist() { + return route_exist; + } + public void setRoute_exist(String route_exist) { + this.route_exist = route_exist; + } + public List getRouteLine() { + return RouteLine; + } + public void setRouteLine(List routeLine) { + RouteLine = routeLine; + } + public String getCanRouteImport() { + return canRouteImport; + } + public void setCanRouteImport(String canRouteImport) { + this.canRouteImport = canRouteImport; + } + @Override + public String toString() { + return "RouteCheckResult [assembly_item=" + assembly_item + ", assembly_item_exist=" + assembly_item_exist + + ", route_exist=" + route_exist + ", RouteLine=" + RouteLine + ", canRouteImport=" + canRouteImport + + "]"; + } + + +} diff --git a/src/com/connor/erpintegration/entity/RouteLineEntity.java b/src/com/connor/erpintegration/entity/RouteLineEntity.java new file mode 100644 index 0000000..a7bc039 --- /dev/null +++ b/src/com/connor/erpintegration/entity/RouteLineEntity.java @@ -0,0 +1,72 @@ +package com.connor.erpintegration.entity; + +public class RouteLineEntity { + + private String operation_seq_num; + private String department_code; + private String seq_num_exist; + private String department_code_erp; + private String operation_description; + private String usage_rate_or_amount; + private String usage_rate_or_amount_auxiliary; + private String department_code_exist; + public String getOperation_seq_num() { + return operation_seq_num; + } + public void setOperation_seq_num(String operation_seq_num) { + this.operation_seq_num = operation_seq_num; + } + public String getDepartment_code() { + return department_code; + } + public void setDepartment_code(String department_code) { + this.department_code = department_code; + } + public String getSeq_num_exist() { + return seq_num_exist; + } + public void setSeq_num_exist(String seq_num_exist) { + this.seq_num_exist = seq_num_exist; + } + public String getDepartment_code_erp() { + return department_code_erp; + } + public void setDepartment_code_erp(String department_code_erp) { + this.department_code_erp = department_code_erp; + } + public String getOperation_description() { + return operation_description; + } + public void setOperation_description(String operation_description) { + this.operation_description = operation_description; + } + public String getUsage_rate_or_amount() { + return usage_rate_or_amount; + } + public void setUsage_rate_or_amount(String usage_rate_or_amount) { + this.usage_rate_or_amount = usage_rate_or_amount; + } + public String getUsage_rate_or_amount_auxiliary() { + return usage_rate_or_amount_auxiliary; + } + public void setUsage_rate_or_amount_auxiliary(String usage_rate_or_amount_auxiliary) { + this.usage_rate_or_amount_auxiliary = usage_rate_or_amount_auxiliary; + } + public String getDepartment_code_exist() { + return department_code_exist; + } + public void setDepartment_code_exist(String department_code_exist) { + this.department_code_exist = department_code_exist; + } +// @Override +// public String toString() { +// return "RouteLineEntity [operation_seq_num=" + operation_seq_num + ", department_code=" + department_code +// + ", seq_num_exist=" + seq_num_exist + ", department_code_erp=" + department_code_erp +// + ", operation_description=" + operation_description + ", usage_rate_or_amount=" + usage_rate_or_amount +// + ", usage_rate_or_amount_auxiliary=" + usage_rate_or_amount_auxiliary + ", department_code_exist=" +// + department_code_exist + "]"; +// } + + + +} diff --git a/src/com/connor/touliao/MessageDialog.java b/src/com/connor/touliao/MessageDialog.java new file mode 100644 index 0000000..834e9d7 --- /dev/null +++ b/src/com/connor/touliao/MessageDialog.java @@ -0,0 +1,191 @@ +package com.connor.touliao; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; + +import com.connor.erp.BomChgTransferToERP.DBUtils; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + + + +public class MessageDialog extends AbstractAIFDialog{ + + private JFileChooser jFileChooser; + private DefaultTableModel model; + private List difBomline=new ArrayList(); + private TCSession session; + private Map quantityNull; + private Map quantityNullBom; + + public MessageDialog(TCSession session,List difBomline,Map quantityNull, Map quantityNullBom) throws TCException { + super(); + this.session=session; + this.difBomline=difBomline; + this.quantityNull=quantityNull; + this.quantityNullBom=quantityNullBom; + model = new DefaultTableModel(new Object[][] {}, + new String[] { "序号","BOM子件号","子件名称","BOM数量","工艺投料件号","投料名称","工艺用量"}); + + int xh= difBomline.size(); + for(Map.Entry key:quantityNull.entrySet()) { + TCComponentItem key2 = key.getKey(); + String value = key.getValue(); + String item_id = key2.getStringProperty("item_id"); + String revision_id = key2.getStringProperty("object_name"); + String type = key2.getType(); + xh=xh+1; + if(value.equals("process")) { + difBomline.add(new String[] {String.valueOf(xh),"","","",item_id,revision_id,""}); + } + } + + for(Map.Entry key:quantityNullBom.entrySet()) { + TCComponentItem key2 = key.getKey(); + String value = key.getValue(); + String item_id = key2.getStringProperty("item_id"); + String revision_id = key2.getStringProperty("object_name"); + String type = key2.getType(); + xh=xh+1; + if(value.equals("bom")) { + difBomline.add(new String[] {String.valueOf(xh),item_id,revision_id,"","","",""}); + } + } + + if(quantityNull.size()>0 || quantityNullBom.size()>0) { + MessageBox.post(MessageDialog.this,"设计BOM或工艺BOM中存在数量为空的零组件,请修正后再进行投料检查","提示",2); + } + + initDialog(); + } + private void initDialog() { + // TODO Auto-generated method stub + for(String[] row:difBomline) { + System.out.println(row[1]); + model.addRow(row); + } + + + this.setModal(true); + this.setSize(1000, 500); + // this.getContentPane().setBackground(bgColor); + setTitle("投料检查结果"); + setLayout(null); + jFileChooser = new JFileChooser(); + // this.jFileChooser.setCurrentDirectory(new File()); + this.jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + JScrollPane scrollPane = new JScrollPane(); + scrollPane.setBounds(0, 0, 1000, 400); + + + + JTable table = new JTable(); + table.setEnabled(false); + table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + table.setSurrendersFocusOnKeystroke(true); + table.setColumnSelectionAllowed(true); + table.setCellSelectionEnabled(true); + table.setRowHeight(30); + // table.setForeground(Color.DARK_GRAY); + table.setModel(model); + // TableModel model2 = table.getModel(); + // System.out.println(model2.getRowCount()+"model"+model2.getValueAt(0, 0)); + + // table.getTableHeader().setBackground(bgColor); + table.getColumnModel().getColumn(0).setPreferredWidth(50); + table.getColumnModel().getColumn(1).setPreferredWidth(100); + table.getColumnModel().getColumn(2).setPreferredWidth(150); + table.getColumnModel().getColumn(3).setPreferredWidth(50); + table.getColumnModel().getColumn(4).setPreferredWidth(100); + table.getColumnModel().getColumn(5).setPreferredWidth(150); + table.getColumnModel().getColumn(6).setPreferredWidth(50); + MyRenderer myRender = new MyRenderer(); + table.setDefaultRenderer(Object.class, myRender); + + JTableHeader header1 = new JTableHeader(); + header1.setTable(table); + scrollPane.setViewportView(table); + // scrollPane.getViewport().setBackground(bgColor); + + this.add(scrollPane); + + JButton cancelBtn=new JButton("关闭"); + cancelBtn.setBounds(550, 410, 100, 30); + + cancelBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + dispose(); + + } + }); + + + this.add(cancelBtn); + JButton outBtn = new JButton("导出"); + outBtn.setBounds(400, 410, 100, 30); + // outBtn.setBackground(bgColor); + + + outBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + selectFileButtonEvent(); +// Date now = new Date(); +// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); +// File saveExcelChooser = DBUtils.saveExcelChooser("使用于机型清单" + sdf.format(now)); +// +// System.out.println(saveExcelChooser.getAbsolutePath()); + } + }); + this.add(outBtn); + // JButton okBtn = new JButton("关闭"); + // okBtn.setBounds(500, 410, 60, 30); + //// okBtn.setBackground(bgColor); + // scrollPane.add(okBtn); + // + // okBtn.addActionListener(new ActionListener() { + // @Override + // public void actionPerformed(ActionEvent e) { + // // TODO Auto-generated method stub + // dispose(); + // } + // }); + + this.setLocationRelativeTo(null); + this.setVisible(true); + } + public void selectFileButtonEvent(){ + int state = jFileChooser.showOpenDialog(null); + if(state == 1) { + return; + }else{ + File f = jFileChooser.getSelectedFile(); + TouliaoOperation operation=new TouliaoOperation(f,difBomline); + session.queueOperation(operation); + System.out.println(f.getAbsolutePath()); + } + } + +} diff --git a/src/com/connor/touliao/MyRenderer.java b/src/com/connor/touliao/MyRenderer.java new file mode 100644 index 0000000..dc12bdf --- /dev/null +++ b/src/com/connor/touliao/MyRenderer.java @@ -0,0 +1,38 @@ +package com.connor.touliao; + +import java.awt.Color; +import java.awt.Component; + +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.table.TableCellRenderer; + +public class MyRenderer implements TableCellRenderer { + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { +// if (column != 1) { + JTextField editor = new JTextField(); + editor.setHorizontalAlignment(JLabel.CENTER); + if (value != null) { + editor.setText(value.toString()); + } +// editor.setBackground((row % 2 == 0) ? Color.white : Color.cyan); + return editor; +// } else { +// JCheckBox editor = new JCheckBox(); +// editor.setEnabled(true); +// editor.setHorizontalAlignment(JLabel.CENTER); +// if (value instanceof Boolean) { +// if ((Boolean) value == false) { +// editor.setSelected(false); +// } else if ((Boolean) value == false) { +// editor.setSelected(true); +// } +// } +// editor.setBackground((row % 2 == 0) ? Color.white : Color.cyan); +// return editor; +// } + } +} diff --git a/src/com/connor/touliao/TouliaoDialog.java b/src/com/connor/touliao/TouliaoDialog.java new file mode 100644 index 0000000..ddf7019 --- /dev/null +++ b/src/com/connor/touliao/TouliaoDialog.java @@ -0,0 +1,597 @@ +package com.connor.touliao; + +import java.awt.Color; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableModel; + +//import com.connor.zcbb.sb.handlers.SbjxbDialog; +import com.sun.corba.se.impl.encoding.EncapsOutputStream; +import com.sun.corba.se.impl.protocol.giopmsgheaders.Message; +//import com.sun.xml.internal.bind.v2.schemagen.xmlschema.List; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.pse.graphics.actions.Export3DFileAction; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.soaictstubs.booleanSeq_tHolder; +//import com.ufc.masterform.JButtonMargin; +//import com.ufc.util.MyRenderer; + +public class TouliaoDialog extends AbstractAIFOperation{ + + private Color bgColor = new Color(241, 250, 255); + private JFileChooser jFileChooser; + + private int xhFlag=1; + + private List difBomline=new ArrayList(); + + private boolean sameFlag=false; + + private boolean flagCal = true; + + private DefaultTableModel model; + + private TCSession session; + + private TCComponentItemRevision itemRevision; + + private TCComponent meTarget; + + private Map touliaoMap; + + private Map bomLineMap; + + private Map quantityNull; + + private Map quantityNullBom; + +// public TouliaoDialog(TCSession session,Map bomLineMap,Map touliaoMap,TCComponentForm master){ +// this.session = session; +// this.touliaoMap=touliaoMap; +// this.bomLineMap=bomLineMap; +// //this.nameString="test"; +// model = new DefaultTableModel(new Object[][] {}, +// new String[] { "序号","BOM子件号","子件名称","BOM数量","工艺投料件号","投料名称","工艺用量"}); +// } + + public TouliaoDialog(TCSession session,TCComponentItemRevision itemRevision, TCComponent meTarget) { + this.session = session; + this.itemRevision=itemRevision; + this.meTarget=meTarget; + model = new DefaultTableModel(new Object[][] {}, + new String[] { "序号","BOM子件号","子件名称","BOM数量","工艺投料件号","投料名称","工艺用量"}); + } + + @Override + public void executeOperation() { + + //显示窗口 + try { + TCComponentForm master = (TCComponentForm)itemRevision.getRelatedComponent("IMAN_master_form_rev"); + boolean isFcheck = master.getLogicalProperty("nhl8_isFcheck"); + Object obj[] = new Object[1]; + obj[0] = 1; + TCUserService service = session.getUserService(); + touliaoMap=new HashMap(); + + bomLineMap=new HashMap(); + + quantityNull=new HashMap(); + quantityNullBom=new HashMap(); + TCComponentItemRevision meTargetRev =(TCComponentItemRevision) meTarget; + service.call("openByPass", obj); + + if(!isFcheck) { + + getProcessItem(session, itemRevision); + System.out.println("bomLineMap"+touliaoMap.size()); + if(flagCal) { + getMeTargetItem(session,meTargetRev); + } + }else { + boolean isfPass = false; +// String isfPassString="false"; + try { + isfPass = master.getLogicalProperty("nhl8_isfPass"); + int option=1; + if(isfPass) { + option = JOptionPane.showOptionDialog(null, itemRevision+"已经进行过投料检查,检查结果为“投料检查通过”。是否再次进行投料检查?", "", 0, 1, null, null, + Integer.valueOf(0)); + }else { + option = JOptionPane.showOptionDialog(null, itemRevision+"已经进行过投料检查,检查结果为“投料检查不通过”。是否再次进行投料检查?", "", 0, 1, null, null, + Integer.valueOf(0)); + } + if(option==1 || option==-1) { + return; + } + + } catch (Exception e3) { + // TODO Auto-generated catch block + e3.printStackTrace(); + } + getProcessItem(session, itemRevision); + if(flagCal) { + getMeTargetItem(session,meTargetRev); + } + + + } + service.call("closeByPass", obj); + + if(flagCal) { + if(quantityNull.size()==0 && quantityNullBom.size()==0) { + compareBomline(); + }else { + sameFlag=false; + } + + + bomLineMap.clear(); + touliaoMap.clear(); + if(!sameFlag) { + + service.call("openByPass", obj); + System.out.println("表单"+master.toString()); + + master.setLogicalProperty("nhl8_isFcheck", true); + + master.setLogicalProperty("nhl8_isfPass", false); + service.call("closeByPass", obj); + init(); + + + + }else { + service.call("openByPass", obj); + + master.setLogicalProperty("nhl8_isFcheck", true); + master.setLogicalProperty("nhl8_isfPass", true); + service.call("closeByPass", obj); + MessageBox.post(itemRevision+"投料检查通过","提示",MessageBox.INFORMATION); + } + } + + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + //启用查询按钮 +// qryBtn.setEnabled(true); + } + + private void compareBomline() throws TCException { + // TODO Auto-generated method stub + + System.out.println("touliao"+touliaoMap.size()); +// System.out.println("bom"); + + for(Map.Entry key:touliaoMap.entrySet()) { + TCComponentItem key2 = key.getKey(); + if(bomLineMap.containsKey(key2)) { + String tcComponentBOMLine = bomLineMap.get(key2); + if(tcComponentBOMLine==null) { + System.out.println("???"); + continue; + } + } + } + + for(Map.Entry key:touliaoMap.entrySet()) { + TCComponentItem key2 = key.getKey(); + String value = key.getValue(); + String bl_quantity = String.valueOf(value); + String item_id = key2.getStringProperty("item_id"); + String revision_id = key2.getStringProperty("object_name"); + if(bomLineMap.containsKey(key2)) { + String tcComponentBOMLine = bomLineMap.get(key2); + if(tcComponentBOMLine==null) { + continue; + } + String stringProperty = tcComponentBOMLine; + if(stringProperty==null || stringProperty.equals("")) { +// quantityNull.put(bomLine.getItem(), ""); +// continue; +// stringProperty="0"; + } + if(!stringProperty.equals(bl_quantity)) { + System.out.println("不同"+key2.getStringProperty("object_string")); + difBomline.add(new String[] {String.valueOf(xhFlag),item_id,revision_id,stringProperty,item_id,revision_id,bl_quantity}); + xhFlag++; + } + }else { + System.out.println("缺少"+key2.getStringProperty("object_string")); + difBomline.add(new String[] {String.valueOf(xhFlag),"","","",item_id,revision_id,bl_quantity}); + xhFlag++; + } + } + + for(Map.Entry key:bomLineMap.entrySet()) { + TCComponentItem key2 = key.getKey(); + String value = key.getValue(); + String bl_quantity = value; + String item_id = key2.getStringProperty("item_id"); + String revision_id = key2.getStringProperty("object_name"); + if(!touliaoMap.containsKey(key2)) { + System.out.println("投料缺少"+key2.getStringProperty("object_string")); + difBomline.add(new String[] {String.valueOf(xhFlag),item_id,revision_id,bl_quantity,"","",""}); + xhFlag++; + } + + } + System.out.println(difBomline.size()); + if(difBomline.size()==0) { + sameFlag=true; + } + + } + + private void init() { + + Thread t=new Thread(new Runnable(){ + public void run(){ + + try { + MessageDialog dialog=new MessageDialog(session,difBomline,quantityNull,quantityNullBom); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + +// System.out.println("modelExcel"+modelExcel.getAbsolutePath()); +// SbjxbDialog sbjxbDialog = new SbjxbDialog(session,writeSheet.pxList,modelExcel,docRev,docName,dsType,dsRef, "IMAN_specification",modelExcel.getAbsolutePath()); + } + }); + t.start(); + // TODO Auto-generated method stub +// for(String[] row:difBomline) { +// System.out.println(row[1]); +// model.addRow(row); +// } +// +// +// this.setModal(true); +// this.setSize(1000, 500); +//// this.getContentPane().setBackground(bgColor); +// setTitle("投料检查结果"); +// setLayout(null); +// jFileChooser = new JFileChooser(); +//// this.jFileChooser.setCurrentDirectory(new File()); +// this.jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); +// JScrollPane scrollPane = new JScrollPane(); +// scrollPane.setBounds(0, 0, 1000, 400); +// +// +// +// JTable table = new JTable(); +// table.setEnabled(false); +// table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); +// table.setSurrendersFocusOnKeystroke(true); +// table.setColumnSelectionAllowed(true); +// table.setCellSelectionEnabled(true); +// table.setRowHeight(30); +//// table.setForeground(Color.DARK_GRAY); +// table.setModel(model); +//// TableModel model2 = table.getModel(); +//// System.out.println(model2.getRowCount()+"model"+model2.getValueAt(0, 0)); +// +//// table.getTableHeader().setBackground(bgColor); +// table.getColumnModel().getColumn(0).setPreferredWidth(50); +// table.getColumnModel().getColumn(1).setPreferredWidth(100); +// table.getColumnModel().getColumn(2).setPreferredWidth(150); +// table.getColumnModel().getColumn(3).setPreferredWidth(50); +// table.getColumnModel().getColumn(4).setPreferredWidth(100); +// table.getColumnModel().getColumn(5).setPreferredWidth(150); +// table.getColumnModel().getColumn(6).setPreferredWidth(50); +// MyRenderer myRender = new MyRenderer(); +// table.setDefaultRenderer(Object.class, myRender); +// +// JTableHeader header1 = new JTableHeader(); +// header1.setTable(table); +// scrollPane.setViewportView(table); +//// scrollPane.getViewport().setBackground(bgColor); +// +// this.add(scrollPane); +// +// JButton cancelBtn=new JButton("关闭"); +// cancelBtn.setBounds(550, 410, 100, 30); +// +// cancelBtn.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// dispose(); +// } +// }); +// +// +// this.add(cancelBtn); +// JButton outBtn = new JButton("导出"); +// outBtn.setBounds(400, 410, 100, 30); +//// outBtn.setBackground(bgColor); +// +// +// outBtn.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// selectFileButtonEvent(); +// } +// }); +// this.add(outBtn); +//// JButton okBtn = new JButton("关闭"); +//// okBtn.setBounds(500, 410, 60, 30); +////// okBtn.setBackground(bgColor); +//// scrollPane.add(okBtn); +//// +//// okBtn.addActionListener(new ActionListener() { +//// @Override +//// public void actionPerformed(ActionEvent e) { +//// // TODO Auto-generated method stub +//// dispose(); +//// } +//// }); +// +// this.setLocationRelativeTo(null); +// this.setVisible(true); + } + +// public void selectFileButtonEvent(){ +// int state = jFileChooser.showOpenDialog(null); +// if(state == 1) { +// return; +// }else{ +// File f = jFileChooser.getSelectedFile(); +// TouliaoOperation operation=new TouliaoOperation(f,difBomline); +// session.queueOperation(operation); +// System.out.println(f.getAbsolutePath()); +// } +// } + + private void getMeTargetItem(TCSession session, TCComponentItemRevision meTargetRev) throws TCException { + // TODO Auto-generated method stub + Map packMap=new HashMap(); + TCTypeService service = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service + .getTypeComponent("BOMWindow"); + System.out.println("获取制造目标下的item"); + + TCComponentBOMWindow window = winType.create(null); + window.lock(); + TCComponentBOMLine topLine = window.setWindowTopLine( + meTargetRev.getItem(), meTargetRev, null, null); + + AIFComponentContext[] children = topLine.getChildren(); + for(AIFComponentContext context:children) { + TCComponentBOMLine bomLine = (TCComponentBOMLine)context.getComponent(); + System.out.println("制造目标bomline"+bomLine.getStringProperty("object_string")); + + TCComponentItemRevision itemRevision = bomLine.getItemRevision(); + String bl_sequence_no = bomLine.getStringProperty("bl_sequence_no"); +// boolean containsKey = packMap.containsKey(itemRevision); +// if(containsKey) { +//// bomLine.setStringProperty("bl_sequence_no", packMap.get(itemRevision)); +//// bomLine.pack(); +// }else { +// packMap.put(itemRevision, bl_sequence_no); +// } + String stringProperty = bomLine.getStringProperty("bl_quantity"); + if(stringProperty==null || stringProperty.equals("")) { + + if(bomLine.getItem().getStringProperty("item_id").contains("GB")) { + continue; + } + quantityNullBom.put(bomLine.getItem(), "bom"); + continue; +// stringProperty="0"; + + } + BigDecimal bigDecimal = new BigDecimal(stringProperty); + System.out.println(bigDecimal.toString() ); + if(bomLineMap.containsKey(bomLine.getItem())) { + String string = bomLineMap.get(bomLine.getItem()); + BigDecimal big2 = new BigDecimal(string); + BigDecimal add = big2.add(bigDecimal); + bomLineMap.put(bomLine.getItem(),add.toString() ); + }else { + bomLineMap.put(bomLine.getItem(),bigDecimal.toString() ); + } + + } + + window.save(); + window.unlock(); + window.close(); + } + + private void getProcessItem(TCSession session,TCComponentItemRevision revision) throws TCException { + // TODO Auto-generated method stub + Map packMap=new HashMap(); + + TCTypeService service = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service + .getTypeComponent("BOMWindow"); + System.out.println("获取工艺对象下的工步"); + + TCComponentBOMWindow window = winType.create(null); + window.lock(); + TCComponentBOMLine topLine = window.setWindowTopLine( + revision.getItem(), revision, null, null); + AIFComponentContext[] children = topLine.getChildren(); + for(AIFComponentContext child:children) { + TCComponentBOMLine component =(TCComponentBOMLine) child.getComponent(); +// System.out.println(component.getStringProperty("object_string")); + AIFComponentContext[] children2 = component.getChildren(); + for(AIFComponentContext gbdxContext:children2) { + TCComponentBOMLine GBComponent =(TCComponentBOMLine) gbdxContext.getComponent(); + String bomType = GBComponent.getItem().getType(); +// && && bl_occ_type.equals("MEConsumed") +// System.out.println("类型"+bomType); +// if(bomType.equals("NHL8_RigOutAC") || 1==1) { + AIFComponentContext[] touLiaos = GBComponent.getChildren(); + for(AIFComponentContext touLiao:touLiaos) { + TCComponentBOMLine touLiaoLine =(TCComponentBOMLine) touLiao.getComponent(); + String bl_occ_type = touLiaoLine.getStringProperty("bl_occ_type"); + System.out.println(touLiaoLine.getStringProperty("object_string")+"投料事例类型"+bl_occ_type); + + if(bl_occ_type.equals("MEDisassemble")) { + MessageBox.post("非CAL号工艺不允许存在拆卸件的业务","提示",2); + + flagCal=false; + + return; + } + + if(bl_occ_type.equals("MEConsumed") ) { //|| bl_occ_type.equals("MEDisassemble") + TCComponentItemRevision itemRevision = touLiaoLine.getItemRevision(); + String bl_sequence_no = touLiaoLine.getStringProperty("bl_sequence_no"); + boolean containsKey = packMap.containsKey(itemRevision); + if(containsKey) { +// touLiaoLine.setStringProperty("bl_sequence_no", packMap.get(itemRevision)); +// touLiaoLine.pack(); + }else { + packMap.put(itemRevision, bl_sequence_no); + } + + } +// System.out.println("打包完成"); + } +// } + + } + } + window.save(); + window.unlock(); + window.close(); + getProcessItem2(session,revision); + } + + + private void getProcessItem2(TCSession session,TCComponentItemRevision revision) throws TCException { + // TODO Auto-generated method stub + Map packMap=new HashMap(); + + TCTypeService service = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service + .getTypeComponent("BOMWindow"); + System.out.println("获取工艺对象下的工步"); + + TCComponentBOMWindow window = winType.create(null); + window.lock(); + TCComponentBOMLine topLine = window.setWindowTopLine( + revision.getItem(), revision, null, null); + + AIFComponentContext[] children = topLine.getChildren(); + for(AIFComponentContext child:children) { + TCComponentBOMLine component =(TCComponentBOMLine) child.getComponent(); +// System.out.println(component.getStringProperty("object_string")); + AIFComponentContext[] children2 = component.getChildren(); + for(AIFComponentContext gbdxContext:children2) { + TCComponentBOMLine GBComponent =(TCComponentBOMLine) gbdxContext.getComponent(); +// String bomType = GBComponent.getItem().getType(); +// && && bl_occ_type.equals("MEConsumed") +// System.out.println("类型"+bomType); +// if(bomType.equals("NHL8_RigOutAC") || 1==1) { + AIFComponentContext[] touLiaos = GBComponent.getChildren(); + + String stringProperty = GBComponent.getStringProperty("bl_occ_type"); + + if(stringProperty.equals("MEDisassemble")) { + MessageBox.post("非CAL号工艺不允许存在拆卸件的业务","提示",2); + + flagCal=false; + + return; + } + + if(stringProperty.equals("MEConsumed")) { + String stringProperty2 = GBComponent.getStringProperty("bl_quantity"); + if(stringProperty2==null ||stringProperty2.equals("")){ + +// quantityNull.put(GBComponent.getItem(), "process"); +// continue; +// stringProperty2="0"; + }else { + BigDecimal bigDecimal = new BigDecimal(stringProperty2); + if(touliaoMap.containsKey(GBComponent.getItem())) { +// BigDecimal bigDecimal = new BigDecimal(stringProperty2); + BigDecimal bigDecimal2 = new BigDecimal(String.valueOf(touliaoMap.get(GBComponent.getItem()))); + bigDecimal= bigDecimal.add(bigDecimal2); +// valueOf=Double.valueOf(bigDecimal.toString()); + } + System.out.println(GBComponent.getItemRevision().getStringProperty("object_string")+"222value"+bigDecimal.toString()); + touliaoMap.put(GBComponent.getItem(), bigDecimal.toString()); + } + + continue; + } + + for(AIFComponentContext touLiao:touLiaos) { + TCComponentBOMLine touLiaoLine =(TCComponentBOMLine) touLiao.getComponent(); + String bl_occ_type = touLiaoLine.getStringProperty("bl_occ_type"); + + if(bl_occ_type.equals("MEConsumed") || bl_occ_type.equals("MEDisassemble")) { + TCComponentItemRevision itemRevision = touLiaoLine.getItemRevision(); + String stringProperty2 = touLiaoLine.getStringProperty("bl_quantity"); + if(stringProperty2==null ||stringProperty2.equals("")){ + quantityNull.put(touLiaoLine.getItem(), "process"); +// stringProperty2="0"; + }else { + BigDecimal bigDecimal = new BigDecimal(stringProperty2); +// Double valueOf = Double.valueOf(stringProperty2); + if(touliaoMap.containsKey(touLiaoLine.getItem())) { +// bigDecimal = new BigDecimal(stringProperty2); + BigDecimal bigDecimal2 = new BigDecimal(String.valueOf(touliaoMap.get(touLiaoLine.getItem()))); + bigDecimal= bigDecimal.add(bigDecimal2); +// valueOf=Double.valueOf(bigDecimal.toString()); + } + System.out.println(itemRevision.getStringProperty("object_string")+"value"+bigDecimal.toString()); + touliaoMap.put(touLiaoLine.getItem(), bigDecimal.toString()); + } + + } + } +// } + + } + } + window.save(); + window.unlock(); + window.close(); + + } + + +} diff --git a/src/com/connor/touliao/TouliaoHandler.java b/src/com/connor/touliao/TouliaoHandler.java new file mode 100644 index 0000000..a59eb5f --- /dev/null +++ b/src/com/connor/touliao/TouliaoHandler.java @@ -0,0 +1,216 @@ +package com.connor.touliao; + +import java.io.IOException; +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JOptionPane; + +import org.apache.commons.collections.map.HashedMap; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.Bullet; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.List; +import org.omg.CORBA.PRIVATE_MEMBER; + +import com.sun.corba.se.impl.encoding.EncapsOutputStream; +import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.kernel.TCComponentBOMLineType.BOMCompareListBomlinesObject; +import com.teamcenter.rac.util.MessageBox; + +public class TouliaoHandler extends AbstractHandler { + + private Map touliaoMap=new HashMap(); + + private Map bomLineMap=new HashMap(); + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent comp; + comp=app.getTargetComponent(); + + +// List<> + + if(comp instanceof TCComponentBOMLine) { + TCComponentBOMLine bomLine=(TCComponentBOMLine)comp; + try { + TCComponentItemRevision itemRevision = bomLine.getItemRevision(); + comp=itemRevision; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + + if( comp instanceof TCComponentItemRevision) { + TCComponentItemRevision revision=(TCComponentItemRevision)comp; //工艺对象 +// TCComponent[] whereUsed = null; +// try { +// whereUsed = revision.whereUsed((short) 0); +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// System.out.println(whereUsed.length); +// for(TCComponent component:whereUsed) { +// try { +// System.out.println(component.getStringProperty("object_string")); +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// +// TCComponent[] whereUsed2 = null; +// try { +// whereUsed2 = revision.whereUsed((short) 1); +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// for(TCComponent component:whereUsed2) { +// try { +// System.out.println("1"+component.getStringProperty("object_string")); +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } + if(revision.getType().equals("NHL8_AssemblyProRevision") + ||revision.getType().equals("NHL8_PartsProRevision") + ||revision.getType().equals("NHL8_DivergeProRevision") + ){ + + try { + revision.refresh(); + System.out.println("刷新对象"); + TCComponent meTarget = revision.getRelatedComponent("IMAN_METarget"); //制造目标的bom + String type = ""; + if(meTarget!=null) { + TCComponentItemRevision meTargetRev =(TCComponentItemRevision) meTarget; + + type = meTargetRev.getItem().getType(); + + System.out.println(type); + } + + if(type.equals("NHL8_Product") || type.equals("NHL8_Parts") + || type.equals("NHL8_Fixture") || type.equals("NHL8_FixParts")) { + + TouliaoDialog dialog=new TouliaoDialog(session,revision,meTarget); + session.queueOperation(dialog); +// new Thread(dialog).start(); + + + }else { + + MessageBox.post("请选择正确的产品或零组件工艺","提示",1); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + }else { + MessageBox.post("请选择正确的产品或零组件工艺","提示",1); + } + + + + } + + if(comp instanceof TCComponentTask) { + TCComponentTask task = (TCComponentTask) comp; + try { + TCComponent[] targets = task.getRelatedComponents("root_target_attachments"); + for( int i = 0;i entry : bomLineMap.entrySet()) { +// System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue()); +// } +// +// +// +// } + + + + +} diff --git a/src/com/connor/touliao/TouliaoOperation.java b/src/com/connor/touliao/TouliaoOperation.java new file mode 100644 index 0000000..5bf29ce --- /dev/null +++ b/src/com/connor/touliao/TouliaoOperation.java @@ -0,0 +1,60 @@ +package com.connor.touliao; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.util.List; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.util.MessageBox; + +public class TouliaoOperation extends AbstractAIFOperation{ + + private File outPathFile; + + private List difBomline; + public TouliaoOperation(File f, List difBomline) { + this.outPathFile=f; + this.difBomline=difBomline; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + InputStream itemMoudel=TouliaoOperation.class.getResourceAsStream("投料导出模板.xlsx"); + XSSFWorkbook wb2 = null; + wb2 = new XSSFWorkbook(itemMoudel); + int t=1; + XSSFSheet sheetItem = wb2.getSheetAt(0); + + + for(String[] message : difBomline) { + XSSFRow row = sheetItem.getRow(t); + if(row==null) { + row = sheetItem.createRow(t); + } + + for(int i=0;i changeTypes = new ArrayList<>(); + List partsProTypes = new ArrayList<>(); + String[] prefValues = session.getPreferenceService().getStringValues("connor_taskType"); + for(String pre:prefValues) { + if(pre.contains(":")) { + String[] name = pre.split(":"); + if(name[0].equals("工艺变更")) { +// changeTypes.add(); + if(name[1].contains(";")) { + String[] split = name[1].split(";"); + changeTypes = new ArrayList<>(Arrays.asList(split)); + }else { + changeTypes.add(name[1]); + } +// + }else if (name[0].equals("操作卡")) { + if(name[1].contains(";")) { + String[] split = name[1].split(";"); + partsProTypes = new ArrayList<>(Arrays.asList(split)); + }else { + changeTypes.add(name[1]); + } + } + } + } + System.out.println(partsProTypes.toString()+"partsProTypes"); + System.out.println(changeTypes.toString()+"changeTypes"); + for(TCComponentActionHandler actionHandler:actionHandlers) { + String name = actionHandler.getName(); + System.out.println("actionHandler"+name); + if(name.equals("connor_check_for_menu")) { + + System.out.println(" start get plugins "); + + TCComponent[] attachments = task.getAttachments(TCAttachmentScope.GLOBAL, 1); + List partsProList = new ArrayList<>(); +// List pChangeProList = new ArrayList<>(); + for(TCComponent component : attachments) { + System.out.println(" paramInt ==1 " + component.getStringProperty("object_name")); + if(partsProTypes.contains(component.getType())) { +// component.getType().equals("NHL8_PartsProRevision") || +// component.getType().equals("NHL8_AssemblyProRevision")||component.getType().equals("NHL8_DivergeProRevision") + partsProList.add(component); +// ExportOperation operation = new ExportOperation(component,session); +// session.queueOperation(operation); + }else if (changeTypes.contains(component.getType())) { // +// pChangeProList.add(component); + FindPzOperation operation = new FindPzOperation(session,(TCComponentItemRevision)component); + session.queueOperation(operation); + } + } + if(partsProList.size()>0) { + InterfaceAIFComponent[] array1 = partsProList.toArray(new InterfaceAIFComponent[0]); + ExportOperation operation = new ExportOperation(array1,session); + session.queueOperation(operation); + + } + + + TCComponent[] attachments9 = task.getAttachments(TCAttachmentScope.GLOBAL, 9); + + + for(TCComponent component : attachments9) { + + System.out.println(" paramInt ==9 " + component.getStringProperty("object_name")); + + } + } + + } + if (!DoTaskPanel.this.updateProcessDescription()) + return; + DoTaskPanel.this.startDoTaskOperation(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + } + }); + this.okButton.setEnabled(false); + this.okButton.setVisible(false); + jPanel2.add(this.okButton); + if (this.parent != null) { + this.cancelButton = new JButton(this.registry.getString("cancel")); + this.cancelButton.setMnemonic(this.registry.getString("cancel.MNEMONIC").charAt(0)); + this.cancelButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent param1ActionEvent) { + DoTaskPanel.this.parent.disposeDialog(); + } + }); + this.cancelButton.setEnabled(true); + this.cancelButton.setVisible(true); + jPanel2.add(this.cancelButton); + } + this.oldComment = this.task.getProperty("comments"); + this.commentsTextArea.setText(this.oldComment); + try { + this.is_secure_task = this.task.isSecureTask(); + if (this.is_secure_task) { + this.userPassword = new JLabel(this.registry.getString("passwordLabel")); + this.passwordTextField = new JPasswordField(20) { + public void paint(Graphics param1Graphics) { + super.paint(param1Graphics); + Painter.paintIsRequired(this, param1Graphics); + } + }; + } + } catch (TCException tCException) {} + add("top.nobind.left", jLabel1); + add("top.bind", (Component)new Separator()); + jPanel1.add("1.1.right.top.preferred.preferred", jLabel2); + jPanel1.add("1.2.center.center.resizable.preferred", new JScrollPane(this.taskName)); + jPanel1.add("2.1.right.top.preferred.preferred", jLabel3); + jPanel1.add("2.2.center.center.resizable.resizable", new JScrollPane(this.taskInstructions)); + jPanel1.add("3.1.right.top.preferred.preferred", jLabel4); + jPanel1.add("3.2.center.center.resizable.preferred", new JScrollPane((Component)this.processDesc)); + jPanel1.add("4.1.right.top.preferred.preferred", this.commentsLabel); + jPanel1.add("4.2.center.center.resizable.resizable", new JScrollPane(this.commentsTextArea)); + jPanel1.add("5.1.right.top.preferred.preferred", jLabel5); + jPanel1.add("5.2.center.center.preferred.preferred", jPanel3); + if (this.is_secure_task) { + jPanel1.add("6.1.right.top.preferred.preferred", this.userPassword); + jPanel1.add("6.2.center.center.preferred.preferred", this.passwordTextField); + } + add("bottom.bind.center.top", jPanel2); + add("bottom.bind", (Component)new Separator()); + add("unbound.bind.center.top", jPanel1); + TCSession tCSession = this.task.getSession(); + TCPreferenceService tCPreferenceService = tCSession.getPreferenceService(); + String str3 = tCPreferenceService.getStringValue("WRKFLW_task_complete"); + if (Boolean.valueOf(str3).booleanValue() && this.task.isValidPerformer()) { + String str = this.task.getStringProperty("task_result"); + if (str.equalsIgnoreCase(this.UnsetResult)) + this.task.setStringProperty("task_result", "Completed"); + } + setState(); + } catch (Exception exception) { + displayEx(exception); + return; + } + } + + public void displayEx(Exception paramException) { + MessageBox messageBox = null; + if (this.parent != null) { + messageBox = new MessageBox((Window)this.parent, paramException); + messageBox.setModal(true); + } else { + messageBox = new MessageBox(Utilities.getCurrentFrame(), paramException); + messageBox.setModal(true); + } + messageBox.setVisible(true); + } + + public void setFocus() { + if (this.completeRadioButton.isEnabled()) { + this.completeRadioButton.requestFocus(); + } else if (this.unableToCompleteRadioButton.isEnabled()) { + this.unableToCompleteRadioButton.requestFocus(); + } else if (this.parent != null) { + this.cancelButton.requestFocus(); + } + } + + public void setState() { + try { + TCTaskState tCTaskState = this.task.getState(); + this.commentsTextArea.setEditable(false); + if (tCTaskState == TCTaskState.STARTED) { + this.completeButtonGroup.remove(this.completeRadioButton); + this.completeButtonGroup.remove(this.unableToCompleteRadioButton); + this.completeRadioButton.setSelected(false); + this.unableToCompleteRadioButton.setSelected(false); + this.completeButtonGroup.add(this.completeRadioButton); + this.completeButtonGroup.add(this.unableToCompleteRadioButton); + this.commentsTextArea.setEditable(true); + TCProperty tCProperty = this.task.getTCProperty("task_result"); + String str = tCProperty.getStringValue(); + if (str.equals("Completed")) { + this.completeRadioButton.setSelected(true); + this.completeRadioButton.setEnabled(true); + this.unableToCompleteRadioButton.setEnabled(true); + this.okButton.setEnabled(true); + this.okButton.setVisible(true); + if (this.task.isValidPerformer()) { + if (this.is_secure_task) + this.passwordTextField.setEnabled(true); + } else if (this.is_secure_task) { + this.passwordTextField.setEnabled(false); + } + } else if (str.equals("UnableToComplete")) { + this.completeRadioButton.setSelected(false); + this.completeRadioButton.setEnabled(true); + this.unableToCompleteRadioButton.setSelected(true); + this.unableToCompleteRadioButton.setEnabled(true); + this.okButton.setEnabled(true); + this.okButton.setVisible(true); + if (this.task.isValidPerformer()) { + if (this.is_secure_task) + this.passwordTextField.setEnabled(true); + } else if (this.is_secure_task) { + this.passwordTextField.setEnabled(false); + } + } else if (this.task.isValidPerformer()) { + if (this.is_secure_task) + this.passwordTextField.setEnabled(true); + this.completeRadioButton.setEnabled(true); + this.unableToCompleteRadioButton.setEnabled(true); + this.okButton.setEnabled(false); + this.okButton.setVisible(true); + } else { + if (this.is_secure_task) + this.passwordTextField.setEnabled(false); + this.completeRadioButton.setEnabled(false); + this.unableToCompleteRadioButton.setEnabled(false); + this.okButton.setVisible(false); + } + } else if (tCTaskState == TCTaskState.FAILED) { + this.completeRadioButton.setSelected(false); + this.unableToCompleteRadioButton.setSelected(true); + this.completeRadioButton.setSelected(false); + this.completeRadioButton.setEnabled(false); + this.unableToCompleteRadioButton.setEnabled(false); + this.unableToCompleteRadioButton.setSelected(true); + this.okButton.setEnabled(false); + this.okButton.setVisible(true); + if (this.is_secure_task) + this.passwordTextField.setEnabled(false); + } else if (tCTaskState == TCTaskState.COMPLETED) { + this.completeRadioButton.setEnabled(false); + this.unableToCompleteRadioButton.setEnabled(false); + this.okButton.setEnabled(false); + this.okButton.setVisible(true); + } else { + if (this.is_secure_task) + this.passwordTextField.setEnabled(false); + this.completeRadioButton.setEnabled(false); + this.unableToCompleteRadioButton.setEnabled(false); + this.okButton.setVisible(false); + if (tCTaskState == TCTaskState.COMPLETED) { + this.completeRadioButton.setSelected(true); + } else { + this.completeRadioButton.setSelected(false); + } + } + if (this.parent != null) + this.cancelButton.setEnabled(true); + } catch (Exception exception) { + displayEx(exception); + return; + } + } + + public void startOperation(String paramString) { + if (this.parent != null) + this.cancelButton.setEnabled(false); + this.okButton.setEnabled(false); + this.commentsTextArea.setEditable(false); + revalidate(); + repaint(); + } + + public void endOperation() { + boolean bool = true; + if (this.performTask != null) { + AbstractAIFOperation abstractAIFOperation = this.performTask.getOperation(); + Object object = abstractAIFOperation.getOperationResult(); + if (object != null) + bool = false; + abstractAIFOperation.removeOperationListener(this); + this.performTask = null; + } + if (this.parent != null && bool) { + this.parent.disposeDialog(); + } else { + setState(); + setFocus(); + revalidate(); + repaint(); + } + } + + private void startDoTaskOperation() { + AbstractAIFDialog abstractAIFDialog = null; + AIFDesktop aIFDesktop = this.desktop; + String str = null; + if (this.parent != null) + abstractAIFDialog = this.parent; + if (this.is_secure_task) + str = getPassword(); + if (this.completeRadioButton.isSelected()) { + initiateOperation((Window)abstractAIFDialog, str, "Completed", "COMPLETE_OPERATION"); + } else if (this.unableToCompleteRadioButton.isSelected()) { + initiateOperation((Window)abstractAIFDialog, str, "UnableToComplete", "FAILURE_OPERATION"); + } else if (this.parent != null) { + this.parent.disposeDialog(); + } + } + + private void initiateOperation(Window paramWindow, String paramString1, String paramString2, String paramString3) { + this.performTask = new PerformTaskUtil(paramWindow, this.task, this.commentsTextArea.getText(), paramString1, paramString2, this, paramString3); + this.performTask.executeOperation(); + } + + private boolean updateProcessDescription() { + try { + String str = this.processDesc.getText(); + if (this.oldDesc == null) { + if (str != null) + this.task.getProcess().setStringProperty("object_desc", str); + } else if (!this.oldDesc.equals(str)) { + this.task.getProcess().setStringProperty("object_desc", str); + } + } catch (Exception exception) { + displayEx(exception); + return false; + } + return true; + } + + public String getPassword() { + return new String(this.passwordTextField.getPassword()); + } + + public void processComponentEvents(final AIFComponentEvent[] componentEvents) { + String str = this.registry.getString("refreshDisplayMessage"); + this.session.setReadyStatus(); + this.session.queueOperation((Job)new AbstractAIFOperation(str) { + public void executeOperation() throws Exception { + DoTaskPanel.this.processComponentEventsRequest(componentEvents); + } + }); + } + + private void processComponentEventsRequest(AIFComponentEvent[] paramArrayOfAIFComponentEvent) { + try { + if (this.task != null) { + AIFComponentEvent[] arrayOfAIFComponentEvent = paramArrayOfAIFComponentEvent; + int i = arrayOfAIFComponentEvent.length; + for (byte b = 0; b < i; b++) { + AIFComponentEvent aIFComponentEvent = arrayOfAIFComponentEvent[b]; + InterfaceAIFComponent interfaceAIFComponent = aIFComponentEvent.getComponent(); + if (interfaceAIFComponent instanceof TCComponentTask && aIFComponentEvent instanceof com.teamcenter.rac.aif.kernel.AIFComponentChangeEvent && interfaceAIFComponent.equals(this.task)) { + updateDoTaskPanel(this.task); + revalidate(); + repaint(); + break; + } + } + } + } catch (Exception exception) { +// MessageBox.post(exception); + } + } + + private void updateDoTaskPanel(TCComponentTask paramTCComponentTask) throws TCException { + String str1 = paramTCComponentTask.getName(); + String str2 = paramTCComponentTask.getStringProperty("comments"); + this.taskInstructions.setText(paramTCComponentTask.getInstructions()); + this.taskName.setText(str1); + if (!this.oldComment.equals(str2)) { + this.oldComment = str2; + this.commentsTextArea.setText(this.oldComment); + } + } + + public void closeSignaled() { + detachListeners(); + } + + protected void detachListeners() { + this.session.removeAIFComponentEventListener(this); + } + + public boolean isFailurePathPresent() { + return this.failurePathPresent; + } + + public void setFailurePathPresent(boolean paramBoolean) { + this.failurePathPresent = paramBoolean; + } + + public void setResult(boolean paramBoolean) { + try { + String str = null; + if (paramBoolean) { + str = "Completed"; + } else { + str = "UnableToComplete"; + } + this.task.setStringProperty("task_result", str); + } catch (TCException tCException) { + TcLogger.getLogger(DoTaskPanel.class).error(tCException.getLocalizedMessage(), (Throwable)tCException); + } + } +} + + +/* Location: D:\plugins tc13\plugins\com.teamcenter.rac.tcapps_13000.1.0.jar!\com\teamcenter\rac\workflow\commands\dotask\DoTaskPanel.class + * Java compiler version: 8 (52.0) + * JD-Core Version: 1.1.3 + */ \ No newline at end of file diff --git a/src/com/teamcenter/rac/workflow/commands/dotask/ExportOperation.java b/src/com/teamcenter/rac/workflow/commands/dotask/ExportOperation.java new file mode 100644 index 0000000..d2d57e6 --- /dev/null +++ b/src/com/teamcenter/rac/workflow/commands/dotask/ExportOperation.java @@ -0,0 +1,308 @@ +package com.teamcenter.rac.workflow.commands.dotask; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOPWindowType; +import com.teamcenter.rac.kernel.TCComponentCfgAttachmentLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; + +//import cn.net.connor.std.aifrcp.KOperation; +import cn.net.connor.std.aifrcp.util.KSWTProgressDialog; +import cn.net.connor.std.aifrcp.util.KUtil; +import cn.net.connor.std.word.word.KWordCategory; +import cn.net.connor.std.word.word.KWordUtil; + +public class ExportOperation extends AbstractAIFOperation { + + protected static final Registry REG = Registry.getRegistry(ExportOperation.class); + public static final String PREF_FILTER = "Connor_NHL_ProessCard"; + + protected KSWTProgressDialog progressDialog; + protected List kWordCategories = new ArrayList<>(); + protected List filterInfos = new ArrayList<>(); + protected List windowToClose = new ArrayList<>(); + private TCComponentBOPWindowType bopWindowType; + + protected TCSession session; + private InterfaceAIFComponent[] targetsInters; + public ExportOperation(InterfaceAIFComponent[] app, TCSession session) { +// super(app, REG.getString("op.Name")); + this.session = session; + this.targetsInters = app; + } + + public static class FilterInfo { + + private String itemType_METarget; + private String itemType_MEProcess; + private String itemType_MEOP; + private String itemName_MEOP; + + public FilterInfo(String itemType_METarget, String itemType_MEProcess, String itemType_MEOP, String itemName_MEOP) { + super(); + this.itemType_METarget = itemType_METarget; + this.itemType_MEProcess = itemType_MEProcess; + this.itemType_MEOP = itemType_MEOP; + this.itemName_MEOP = itemName_MEOP; + } + + @Override + public String toString() { + if (KUtil.isEmpty(itemName_MEOP)) { + return String.format("GY[%s][%s][%s]", itemType_METarget, itemType_MEProcess, itemName_MEOP); + } + return String.format("GX[%s][%s][%s]", itemType_METarget, itemType_MEOP, itemName_MEOP); + } + + } + + public boolean init() throws Exception { + InterfaceAIFComponent[] targets = targetsInters ; + System.out.println("Select: " + Arrays.toString(targets)); + int targetCnt = KUtil.getLen(targets); + if (targetCnt == 0) { + return false; + } + bopWindowType = (TCComponentBOPWindowType) session.getTypeComponent("BOPWindow"); + String msg = REG.getString("init.Name") + " "; + this.progressDialog = new KSWTProgressDialog(AIFDesktop.getActiveDesktop().getShell(), "", msg, 0, false, true); + progressDialog.openDialog(); + readFilterConfig(); + // 瀵归?変腑鐨勫璞¤繘琛岃繃婊? + targets = reloadTargetsByFilter(targets); + System.out.println("After Filter: " + Arrays.toString(targets)); + targetCnt = KUtil.getLen(targets); + if (targetCnt == 0) { + throw new Exception(REG.getString("novalidtarget.Error")); + } + TCComponentUser owner = session.getUser(); + boolean isDba = owner.getLogicalProperty(TCComponentUser.PROP_IS_MEMBER_OF_DBA); + System.out.println("Current User:" + owner + " DBA: " + isDba); + List unsupportedTargets = new ArrayList<>(); + for (int i = 0; i < targetCnt; i++) { + TCComponent target = (TCComponent) targets[i]; + KWordCategory wordCategory = KWordCategory.parse(session, target); + if (wordCategory != null) { + TCComponent targetOwner; + if (target instanceof TCComponentBOMLine) { + targetOwner = ((TCComponentBOMLine) target).getItemRevision().getReferenceProperty("owning_user"); + } else if (target instanceof TCComponentCfgAttachmentLine) { + targetOwner = target.getUnderlyingComponent().getReferenceProperty("owning_user"); + } else { + targetOwner = target.getReferenceProperty("owning_user"); + } + System.out.println("Check Owner [" + target + "]: " + targetOwner); + if (!owner.equals(targetOwner) && !isDba) { + System.out.println(">> Skip"); + // throw new TCException(REG.getString("notowner.Error")); + continue; + } + this.kWordCategories.add(wordCategory); + } else { + System.out.println("No valid config: " + target); + unsupportedTargets.add(target); + } + } + if (unsupportedTargets.size() > 0) { + throw new TCException(String.format(REG.getString("unsupportedtargets.Error1"), unsupportedTargets.toString())); + } + if (this.kWordCategories.size() == 0) { + throw new TCException(REG.getString("novalidconfig.Error")); + } + return true; + } + + private InterfaceAIFComponent[] reloadTargetsByFilter(InterfaceAIFComponent[] targets) throws Exception { + List res = new ArrayList<>(); + int len = KUtil.getLen(targets); + for (int i = 0; i < len; i++) { + InterfaceAIFComponent target = targets[i]; + if (target instanceof TCComponentBOMLine) { + reloadTarget((TCComponentBOMLine) target, res, null); + } else if(target instanceof TCComponentItemRevision){ + TCComponentItemRevision rev = (TCComponentItemRevision) target; + TCComponentBOMWindow bopWindow = bopWindowType.create(null); + this.windowToClose.add(bopWindow); + TCComponentBOMLine bopLine = bopWindow.setWindowTopLine(rev.getItem(), rev, null, null); + reloadTarget(bopLine, res, null); + }else { + System.out.println(">> Not BOMLine Or Revision: " + target); + } + } + return res.toArray(new InterfaceAIFComponent[] {}); + } + + private void reloadTarget(TCComponentBOMLine target, List res, List matargetTypes) throws Exception { + int filterCnt = this.filterInfos.size(); + String targetType = target.getStringProperty("bl_item_object_type"); + System.out.println("Filter > " + target + " >> " + targetType); + if (res.contains(target)) { + System.out.println(">> Skip Duplicate"); + return; + } + for (int i = 0; i < filterCnt; i++) { + FilterInfo info = this.filterInfos.get(i); + TCComponentItemRevision procRev = null; + boolean cycleChildren = false; + if (targetType.equals(info.itemType_MEProcess)) { + System.out.println(">> Check: " + info); + procRev = target.getItemRevision(); + cycleChildren = true; + } else if (targetType.equals(info.itemType_MEOP)) { + System.out.println(">> Check: " + info); + String itemName = target.getStringProperty("bl_item_object_name"); + if (!itemName.equals(info.itemName_MEOP)) { + System.out.println(">> Skip By Name [" + itemName + "]"); + continue; + } + if(matargetTypes==null) { + for (TCComponentBOMLine pLine = target.parent(); pLine != null; pLine = pLine.parent()) { + procRev = pLine.getItemRevision(); + } + System.out.println("Proc: " + procRev); + } + } else { + continue; + } + if(matargetTypes==null) { + if (procRev == null) { + System.out.println(">> Process Revision Not Found"); + continue; + } + matargetTypes = new ArrayList<>(); + TCComponent[] meTargets = procRev.getRelatedComponents("IMAN_METarget"); + System.out.println(">> METargets: " + Arrays.toString(meTargets)); + int len = KUtil.getLen(meTargets); + for (int j = 0; j < len; j++) { + TCComponent meTarget = meTargets[j]; + if (meTarget instanceof TCComponentItemRevision) { + String meTargetType = ((TCComponentItemRevision) meTarget).getItem().getType(); + if(!matargetTypes.contains(meTargetType)) { + matargetTypes.add(meTargetType); + } + } + } + } + if (!matargetTypes.contains(info.itemType_METarget)) { + System.out.println(">> Skip By METarget"); + continue; + } + if (!res.contains(target)) { + res.add(target); + } + if (cycleChildren) { + AIFComponentContext[] cc = target.getChildren(); + int childCnt = KUtil.getLen(cc); + for (int j = 0; j < childCnt; j++) { + TCComponentBOMLine cLine = (TCComponentBOMLine) cc[j].getComponent(); + reloadTarget(cLine, res, matargetTypes); + } + } + } + } + + private void readFilterConfig() throws Exception { + String[] prefValues = KUtil.getPrefVals(session, PREF_FILTER); + int len = KUtil.getLen(prefValues); + for (int i = 0; i < len; i++) { + String[] split = prefValues[i].split("=", -1); + if (KUtil.getLen(split) != 4) { + continue; + } + String itemType_METarget = split[0].trim(); + String typeName = split[1].trim(); + String itemName_MEOP = split[2].trim(); + boolean export = "Y".equalsIgnoreCase(split[3].trim()); + if (!export || KUtil.isEmpty(itemType_METarget) || KUtil.isEmpty(typeName)) { + continue; + } + String itemType_MEProcess = null; + String itemType_MEOP = null; + if (KUtil.isEmpty(itemName_MEOP)) { + itemType_MEProcess = typeName; + } else { + itemType_MEOP = typeName; + } + FilterInfo filterInfo = new FilterInfo(itemType_METarget, itemType_MEProcess, itemType_MEOP, itemName_MEOP); + this.filterInfos.add(filterInfo); + } + System.out.println("FilterInfos: " + this.filterInfos); + if (this.filterInfos.size() == 0) { + throw new Exception("Preference Error: " + PREF_FILTER); + } + } + +// @Override + public void execute() throws Exception { + int wordCnt = this.kWordCategories.size(); + KWordUtil.startWord(); + for (int i = 0; i < wordCnt; i++) { + KWordCategory wordCate = this.kWordCategories.get(i); + String msg; + if (wordCnt == 1) { + msg = String.format("%s %s", REG.getString("exporting"), wordCate.toString()); + } else { + msg = String.format("( %d / %d ) %s %s", i + 1, wordCnt, REG.getString("exporting"), wordCate.toString()); + } + progressDialog.updateMessage(msg); + wordCate.export(session, progressDialog); + } + session.refreshComponentsByType("CfgBlAttachmentLine"); + } +// +// @Override + public void clearCache() throws Exception { + if (progressDialog != null) { + progressDialog.closeDialog(); + } + KWordUtil.closeWord(); + int wordCnt = this.kWordCategories.size(); + for (int i = 0; i < wordCnt; i++) { + KWordCategory wordCate = this.kWordCategories.get(i); + wordCate.clearCache(); + } + for (TCComponentBOMWindow w : windowToClose) { + try { + w.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + @Override + public void executeOperation() throws Exception { +/* */ +/* 29 */ try { if (!init()) { +/* */ return; +/* */ } + execute(); + } +/* */ +/* 33 */ catch (Exception e) +/* 34 */ { e.printStackTrace(); +/* 35 */ MessageBox.post(e); } +/* */ finally +/* */ { +/* 38 */ try { clearCache(); } +/* 39 */ catch (Exception e) +/* 40 */ { e.printStackTrace(); +/* 41 */ MessageBox.post(e); } } try { clearCache(); } catch (Exception e) { e.printStackTrace(); MessageBox.post(e); } +/* */ + } + +} diff --git a/src/com/teamcenter/rac/workflow/commands/dotask/FindPzBean.java b/src/com/teamcenter/rac/workflow/commands/dotask/FindPzBean.java new file mode 100644 index 0000000..9b5e9b1 --- /dev/null +++ b/src/com/teamcenter/rac/workflow/commands/dotask/FindPzBean.java @@ -0,0 +1,137 @@ +package com.teamcenter.rac.workflow.commands.dotask; + +import java.util.List; + +//import com.teamcenter.rac.stylesheet.DesignChange; + +public class FindPzBean { + + private String partID;// 修改号 + private String partNub;// 件号 + private String changeName;// 名称 + private String drawingRev;// 图纸版本 + private String processType;// 工艺类型 + private String processCod;// 工艺编码 + private String processRev;// 工艺版本 + private String changeReason;// 修改原因描述 + private String treatSug;// 成品处理意见 + private String articleSug;// 在制品处理意见 + private List descs; + private List changes; + public FindPzBean() { + super(); + // Auto-generated constructor stub + } + + public FindPzBean(String partID,String partNub, String changeName, String drawingRev, String processType, String processCod, + String processRev, String changeReason, String treatSug, String articleSug) { + super(); + this.partID = partID; + this.partNub = partNub; + this.changeName = changeName; + this.drawingRev = drawingRev; + this.processType = processType; + this.processCod = processCod; + this.processRev = processRev; + this.changeReason = changeReason; + this.treatSug = treatSug; + this.articleSug = articleSug; + } + + public String getPartNub() { + return partNub; + } + + public void setPartNub(String partNub) { + this.partNub = partNub; + } + + public String getChangeName() { + return changeName; + } + + public void setChangeName(String changeName) { + this.changeName = changeName; + } + + public String getDrawingRev() { + return drawingRev; + } + + public void setDrawingRev(String drawingRev) { + this.drawingRev = drawingRev; + } + + public String getProcessType() { + return processType; + } + + public void setProcessType(String processType) { + this.processType = processType; + } + + public String getProcessCod() { + return processCod; + } + + public void setProcessCod(String processCod) { + this.processCod = processCod; + } + + public String getProcessRev() { + return processRev; + } + + public void setProcessRev(String processRev) { + this.processRev = processRev; + } + + public String getChangeReason() { + return changeReason; + } + + public void setChangeReason(String changeReason) { + this.changeReason = changeReason; + } + + public String getTreatSug() { + return treatSug; + } + + public void setTreatSug(String treatSug) { + this.treatSug = treatSug; + } + + public String getArticleSug() { + return articleSug; + } + + public void setArticleSug(String articleSug) { + this.articleSug = articleSug; + } + + public void setDescs(List descs) { + this.descs = descs; + } + + public List getDescs() { + return descs; + } + + public void setChanges(List changes) { + this.changes = changes; + } + + public List getChanges() { + return changes; + } + + public String getPartID() { + return partID; + } + + public void setPartID(String partID) { + this.partID = partID; + } + +} diff --git a/src/com/teamcenter/rac/workflow/commands/dotask/FindPzOperation.java b/src/com/teamcenter/rac/workflow/commands/dotask/FindPzOperation.java new file mode 100644 index 0000000..f0b8f11 --- /dev/null +++ b/src/com/teamcenter/rac/workflow/commands/dotask/FindPzOperation.java @@ -0,0 +1,262 @@ +package com.teamcenter.rac.workflow.commands.dotask; + +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.connor.nhjs.gy.findpz.WordBean; +import com.connor.nhjs.gy.findpz.WordCache; +//import com.jacob.activeX.ActiveXComponent; +//import com.jacob.com.ComThread; +//import com.jacob.com.Dispatch; +//import com.jacob.com.Variant; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class FindPzOperation extends AbstractAIFOperation { + + private TCSession session; + private FindPzBean bean; + private File file; + private ProgressBarThread wait; + private String wjjname = "工艺更改单"; + private TCComponentItemRevision rev; + public FindPzOperation(TCSession session, TCComponentItemRevision rev) { + // Auto-generated constructor stub + this.session = session; +// this.bean = bean; + this.rev = rev; + +// TCComponentItemRevision rev = (TCComponentItemRevision) target; +// String type = this.rev.getType(); +// if("NHL8_PChangeRevision".equals(type)) { +// try { +// ActiveXComponent word = new ActiveXComponent("Word.Application"); +// word.setProperty("Visible", new Variant(false)); +// word.setProperty("DisplayAlerts", new Variant(false)); +// Dispatch documents = word.getProperty("Documents").toDispatch(); +//// Dispatch.call(documents, "Open", docPath).toDispatch(); +// ComThread.InitMTA(); + this.bean = this.loadBean(rev); +//// FindPzOperation operation = new FindPzOperation(session,bean,rev); +//// session.queueOperation(operation); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// }else { +// MessageBox.post("请选中工艺更改单版本对象执行操作!!!!", "提示", MessageBox.INFORMATION); +// return null; +// } + + } + + + private FindPzBean loadBean(TCComponentItemRevision rev) { + FindPzBean bean = null; + try { + TCComponent form = rev.getReferenceListProperty("IMAN_master_form_rev")[0]; + String[] props = new String[] {"nhl8_PartNub","nhl8_ChangeName","nhl8_DrawingRev", + "nhl8_ProcessType","nhl8_ProcessCode","nhl8_ProcessRev","nhl8_ReviseReason", + "nhl8_ProductSolution","nhl8_ProductionSolution"}; + String[] propValues = form.getProperties(props); + String id = rev.getStringProperty("item_id"); + bean = new FindPzBean(id,propValues[0],propValues[1],propValues[2], + propValues[3],propValues[4],propValues[5], + propValues[6],propValues[7],propValues[8]); + + String[] prop1 = new String[] {"nhl8_SerialNub", "nhl8_ChangeNub", "nhl8_ChangeName"}; + List list1 = getTableValue(form, "nhl8_DesignChange", prop1); + bean.setChanges(list1); + + String[] prop2 = new String[] {"nhl8_Mark", "nhl8_BeforeChange", "nhl8_AfterChange"};//TODO nhl8_SerialNub + List list2 = getTableValue(form, "nhl8_ChangeDesc", prop2); + + bean.setDescs(list2); + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + } + + // Auto-generated method stub + return bean; + } + public List getTableValue(TCComponent item, String prop, String[] propNames) { + List list = new ArrayList(); + try { + TCComponent[] com = item.getTCProperty(prop).getReferenceValueArray(); + for (int i = 0; i < com.length; ++i) { + TCComponent tableValue = com[i]; + String[] value = new String[propNames.length]; + for (int j = 0; j < propNames.length; ++j) { + value[j] = tableValue.getProperty(propNames[j]); +// System.out.println("value==="+value[j]); + } + DesignChange bean = new DesignChange(value[0], value[1], value[2]); + list.add(bean); + } + } catch (Exception e) { + e.printStackTrace(); + } + return list; + } + + @Override + public void executeOperation() throws Exception { + // Auto-generated method stub + WordCache.init(); + file = getSXX(); + if (file != null) { + wait = new ProgressBarThread("生成word", "生成数据中,请稍等..."); + wait.start();// 开启进度条 + // getVal(); + try { + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");// 设置日期格式 + String time = df.format(new Date()); + wjjname = "工艺更改单" + time; + writeWord(bean); + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + MessageBox.post("生成失败" + e.getMessage(), "错误", MessageBox.ERROR); + Thread thread = new Thread() { + public void run() { + WordCache.clear(); + } + }; + thread.start(); + return; + } + wait.setBool(true);// 关闭进度条 + wait.interrupt(); +// MessageBox.post("工艺更改单生成完成,请查看", "完成", MessageBox.INFORMATION); + } + Thread thread = new Thread() { + public void run() { + WordCache.clear(); + } + }; + thread.start(); + + } + + public File getSXX() { + TCPreferenceService pref = session.getPreferenceService(); + String puid = pref.getStringValue("Connor_Word_Pz_Puid");// 首选项查puid QKlJVPqKphnsxD wdjJGQe1phnsxD + if (puid != null && !("".equals(puid))) { + try { + TCComponentDataset dataset = (TCComponentDataset) session.stringToComponent(puid); + if (dataset == null) { + return null; + } + TCComponentTcFile[] file = dataset.getTcFiles(); + if (file.length == 0 || file.length != 1) { + MessageBox.post("数据集没有命名引用的文件或文件过多,请检查!", "WARNING", MessageBox.WARNING); + return null; + } else { + File fmsFile = file[0].getFmsFile(); + return fmsFile; + } + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + } + + } else { + MessageBox.post("未找到首选项[Connor_Word_Pz_Puid]或首选项配置错误", "错误", MessageBox.ERROR); + return null; + } + return null; + } + + private void writeWord(FindPzBean bean) { + // TODO writeWord +// FileSystemView fsv = FileSystemView.getFileSystemView(); // 得到系统的fileview +// String deskPath = fsv.getHomeDirectory().getPath(); // 当前用户的桌面路径 + + try { + String itemname = bean.getChangeName(); + String filepath = System.getProperty("java.io.tmpdir"); + File tempwjjfile = new File(filepath + File.separator + wjjname); + if (!tempwjjfile.exists()) {// 如果文件夹不存在 + tempwjjfile.mkdir();// 创建文件夹 + } + String parentpath = filepath + File.separator + wjjname + File.separator + itemname; + String temppath = parentpath + ".doc"; + String ystemppath = parentpath + "模板.doc"; + String pdfpath = parentpath + ".pdf"; + + + Util.copyFile(file.getPath(), temppath); + Util.copyFile(file.getPath(), ystemppath); + WordBean word = null; + PzCard card = new PzCard(bean, new File(temppath),new File(ystemppath), session); + word = card.writeDataToWord(); + if (word != null) { + word.save(temppath); + word.saveToPDF(pdfpath); + word.closeDocument(); + word.close(); + // String filePathtoSave = deskPath + File.separator + wjjname + File.separator + itemname + ".doc"; + // File wjjfile = new File(deskPath + File.separator + wjjname); + // if (!wjjfile.exists()) {// 如果文件夹不存在 + // wjjfile.mkdir();// 创建文件夹 + // } + // Util.copyFile(temppath, filePathtoSave); + String name = rev.getStringProperty("object_name"); + TCComponent[] datas = rev.getReferenceListProperty("IMAN_Rendering"); + for (int i = 0; i < datas.length; i++) { + String type = datas[i].getType(); + String data_name = datas[i].getStringProperty("object_name"); + if("PDF".equals(type) && name.equals(data_name)) { + rev.remove("IMAN_Rendering", datas[i]); + datas[i].delete(); + break; + } + } + TCComponentDataset dataset = createDataset(name, "PDF"); + String[] path = new String[1]; + String[] ref_type = new String[1]; +// path[0] = temppath; +// ref_type[0] = "word"; + path[0] = pdfpath; + ref_type[0] = "PDF_Reference"; + dataset.setFiles(path, ref_type); + rev.add("IMAN_Rendering", dataset); + } + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + } + } + /** + * 方法描述 + * 根据参数创建模板文件数据集。 + * @param + * CPTID :需要创建的数据集id + * 返回值描述 + * 返回创建的模板数据集对象 + */ + private TCComponentDataset createDataset(String name, String type) { + TCComponentDataset mbDataset = null; +// String type = "MSWord"; + try { + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset"); + mbDataset = datasetType.create(name, "", type); + } catch (Exception e) { + e.printStackTrace(); + } + return mbDataset; + } +} diff --git a/src/com/teamcenter/rac/workflow/commands/dotask/ProgressBar.java b/src/com/teamcenter/rac/workflow/commands/dotask/ProgressBar.java new file mode 100644 index 0000000..65c1542 --- /dev/null +++ b/src/com/teamcenter/rac/workflow/commands/dotask/ProgressBar.java @@ -0,0 +1,174 @@ +/** + * @file ProgressBar.java + * + * @brief Create progress bar + * + * @author Yanghui + * + * @history + * ================================================================ + * Date Name Description of Change + * 25-July-2008 Yanghui this class is used to create + * progress bar. + */ +package com.teamcenter.rac.workflow.commands.dotask; + +import java.awt.Container; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.Timer; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Registry; + +/** + * @class ProgressBar + * @brief Create progress bar + * @author Yanghui + */ +public class ProgressBar extends AbstractAIFDialog implements ActionListener { + /** + * @var ProgressBar.progressbar + * @brief JProgressBar + */ + private JProgressBar progressbar; + + /** + * @var ProgressBar.label + * @brief label used to tips + */ + private JLabel label; + + /** + * @var ProgressBar.timer + * @brief timer used to timing operation + */ + private Timer timer; + + /** + * @var ProgressBar.bool + * @brief bool used to flag thread return + */ + private boolean bool = false; + + /** + * @var Progressbar.registry + * @brief Registry + */ + private Registry registry; + + /** + * @fn public ProgressBar() + * @brief constructor + * @param[in] null + */ + private String showLable = null ; + public ProgressBar(String showlable) { + super(true); + showLable = showlable; + this.setAlwaysOnTop(true); + } + + /** + * @fn public void setBool(boolean bool) + * @brief set bool value + * @param[in] bool + * @param[out] null + */ + public void setBool(boolean bool) { + this.bool = bool; + } + + /** + * @fn private void initUI() + * @brief createDialog method + * @param[in] null + * @param[out] null + */ + public void initUI() { + Container container = getContentPane(); + JPanel mainPanel = new JPanel(new PropertyLayout()); + this.label = new JLabel(showLable, JLabel.CENTER); + this.progressbar = new JProgressBar(); + this.progressbar.setOrientation(JProgressBar.HORIZONTAL); + this.progressbar.setMinimum(0); + this.progressbar.setMaximum(100); + this.progressbar.setValue(0); + this.progressbar.setPreferredSize(new Dimension(200, 15)); + this.progressbar.setBorderPainted(true); + this.timer = new Timer(50, (ActionListener) this); + this.timer.setRepeats(false); + mainPanel.add("1.1.center", new JLabel(" ")); + mainPanel.add("2.1.center", label); + mainPanel.add("3.1.center", progressbar); + mainPanel.add("4.1.center", new JLabel(" ")); + container.add(mainPanel); + pack(); + setLocation(500, 200); + TaskThread thread = new TaskThread(this); + thread.start(); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + bool = true; + } + }); + this.setVisible(true); + } + + /** + * @class TaskThread + * @brief Create progressbar + * + */ + class TaskThread extends Thread { + private ProgressBar bar; + + public TaskThread(ProgressBar bar) { + this.bar = bar; + } + + public void run() { + if (bool == false) { + // Set Status is running. + // session.setStatus(registry.getString("export Running")); + } + for (int i = 0; i < i + 1; i++) { + timer.start(); + int value = progressbar.getValue(); + if (value < 100) { + value = value + 5; + progressbar.setValue(value); + } else { + timer.stop(); + progressbar.setValue(0); + } + try { + sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (bool == true) { + this.bar.setVisible(false); + this.bar.disposeDialog(); + this.bar.dispose(); + this.interrupt(); + return; + + } + + } + } + } + + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + + } +} diff --git a/src/com/teamcenter/rac/workflow/commands/dotask/ProgressBarThread.java b/src/com/teamcenter/rac/workflow/commands/dotask/ProgressBarThread.java new file mode 100644 index 0000000..170e4e5 --- /dev/null +++ b/src/com/teamcenter/rac/workflow/commands/dotask/ProgressBarThread.java @@ -0,0 +1,42 @@ +/** + * @file ProgressBarThread.java + * + * @brief control progressBar. + * + * @author Yanghui + * + * @history + * ================================================================ + * Date Name Description of Change + * 08-Auguest-2008 Yanghui this class is used to control + * progress bar. + */ +package com.teamcenter.rac.workflow.commands.dotask; + + +/** + * @class ProgressBarThread + * @brief Create progress bar thread + * @author Yanghui + */ +public class ProgressBarThread extends Thread { + + private ProgressBar bar; + + private String title; + + public ProgressBarThread(String title,String showLable) { + this.title = title; + bar = new ProgressBar(showLable); + } + + public void run() { + bar.setTitle(title); + bar.initUI(); + } + + public void setBool(boolean bool) { + bar.setBool(true); + bar.setAlwaysOnTop(false); + } +} diff --git a/src/com/teamcenter/rac/workflow/commands/dotask/PzCard.java b/src/com/teamcenter/rac/workflow/commands/dotask/PzCard.java new file mode 100644 index 0000000..e7a4fba --- /dev/null +++ b/src/com/teamcenter/rac/workflow/commands/dotask/PzCard.java @@ -0,0 +1,232 @@ +package com.teamcenter.rac.workflow.commands.dotask; + +import java.io.File; +import java.util.ArrayList; + +import java.util.List; + +import com.connor.nhjs.gy.findpz.WordBean; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.stylesheet.DesignChange; + +public class PzCard { + + private static final int START = 6; + private static final int MAX = 24; + + private WordBean Word; + private String partID;// 修改号 + private String partNub;// 件号 + private String changeName;// 名称 + private String drawingRev;// 图纸版本 + private String processType;// 工艺类型 + private String processCod;// 工艺编码 + private String processRev;// 工艺版本 + private String changeReason;// 修改原因描述 + private String treatSug;// 成品处理意见 + private String articleSug;// 在制品处理意见 + private List list1 = new ArrayList(); + private List list = new ArrayList(); + private File file; + private File file2; + + public FindPzBean bean; + + public PzCard(FindPzBean bean, File file, File file2,TCSession session) throws TCException { + // Auto-generated constructor stub + //System.out.println(bean); + this.bean = bean; + this.file = file; + this.file2 = file2; + initValue(); + } + + /** + * 初始化值 + * + * @throws TCException + */ + private void initValue() throws TCException { + // Auto-generated method stub + this.partID = bean.getPartID() == null ? "":bean.getPartID(); + this.partNub = bean.getPartNub() == null ? "" : bean.getPartNub(); + this.changeName = bean.getChangeName()== null ? "" : bean.getChangeName(); + this.drawingRev = bean.getDrawingRev()== null ? "" : bean.getDrawingRev(); + this.processType = bean.getProcessType()== null ? "" : bean.getProcessType(); + this.processCod = bean.getProcessCod()== null ? "" : bean.getProcessCod(); + this.processRev = bean.getProcessRev()== null ? "" : bean.getProcessRev(); + this.changeReason = bean.getChangeReason()== null ? "" : bean.getChangeReason(); + this.treatSug = bean.getTreatSug()== null ? "" : bean.getTreatSug(); + this.articleSug = bean.getArticleSug()== null ? "" : bean.getArticleSug(); + this.list1 = bean.getChanges(); + this.list = bean.getDescs(); + + System.out.println("partID=====" + partID); + System.out.println("partNub=====" + partNub); + System.out.println("changeName=====" + changeName); + System.out.println("drawingRev=====" + drawingRev); + System.out.println("processType=====" + processType); + System.out.println("processCod=====" + processCod); + System.out.println("processRev=====" + processRev); + System.out.println("changeReason=====" + changeReason); + + System.out.println("treatSug=====" + treatSug); + System.out.println("articleSug=" + articleSug); + System.out.println("******************************************************"); + + } + + public WordBean writeDataToWord() { + Word = new WordBean(); + boolean openFlag = Word.openDocument(file.getAbsolutePath()); + if (!openFlag) { + return null; + } + writeData(); + //Word.deleteNullPage(); + //页数 + + Word.moveDocEnd(); + Word.deleteNullPage(); + int pages = Word.getPages(); + Word.replaceAllText("#pa", pages+""); + // 输出内容到word + return Word; + } + + /** + * 输出内容到word + */ + private void writeData() { + // TODO Auto-generated method stub + + System.out.println("==========================更改内容=========" + list.size()); + int allRow = 0; + int row = START;// 第2行开始 + int row1 = START;// 第2行开始 + int row2 = START;// 第2行开始 + int row3 = START;// 第2行开始 + int table_num = 1; + int table_num1 = 1; + int table_num2 = 1; + int table_num3 = 1; + int size = list.size(); + for (int i = 0; i < size; i++) { + Word.moveStart(); + DesignChange descBean = list.get(i); +// Word.putTxtToCell(table_num1, row1, 1, descBean.getSerialNub()+""); + String markSTR = descBean.getSerialNub(); + List markList = Util.list2map(markSTR, 50); + String beforeSTR = descBean.getChangeNub(); + List beforeList = Util.list2map(beforeSTR, 360); + String afterSTR = descBean.getChangeName(); + List afterList = Util.list2map(afterSTR, 360); + + if(beforeList.size()>=afterList.size() && beforeList.size()>=markList.size()) { + allRow = row + beforeList.size() - 1; + }else if(afterList.size()>=beforeList.size() && afterList.size()>=markList.size()) { + allRow = row + afterList.size() - 1; + }else { + allRow = row + markList.size() - 1; + } + if(i==size-1) { + allRow--; + } + if(allRow > MAX) { + int page = allRow/MAX ; + for (int j = 0; j < page; j++) { + Word.moveDocEnd(); + Word.insertFile(file2.getAbsolutePath()); + } + row = allRow%MAX + 2 + START; + table_num++; + }else { + row = allRow + 2; + } + if(i==size-1) { + row--; + } + for (int j = 0; j < markList.size(); j++) { +// System.out.println("row2===="+row2); + Word.putHtmlToCell(table_num1, row1, 1, markList.get(j)); + row1++; + if(row1 > MAX) { + table_num1 += 1; + row1 = START; + } + } + for (int j = 0; j < beforeList.size(); j++) { +// System.out.println(j+"===="+beforeList.get(j)); + Word.putHtmlToCell(table_num2, row2, 2, beforeList.get(j)); + row2++; + if(row2 > MAX) { + table_num2 += 1; + row2 = START; + } + } +// System.out.println("row2===="+KGenerateGDTHTML.generatePage(beforeList.get(0))); + for (int j = 0; j < afterList.size(); j++) { +// System.out.println("row3===="+row3); + Word.putHtmlToCell(table_num3, row3, 3, afterList.get(j)); + row3++; + if(row3 > MAX) { + table_num3 += 1; + row3 = START; + } + } + if(row > MAX) { + table_num += 1; + row = START; + Word.moveDocEnd(); + Word.insertFile(file2.getAbsolutePath()); + } + row1 = row; + row2 = row; + row3 = row; + table_num1 = table_num; + table_num2 = table_num; + table_num3 = table_num; + } + for(int i = 1; i <= table_num; i++) { + Word.putTxtToCell(i, MAX + 4, 2, "第"+i+"页"); + } + for (int i = 0; i < list1.size(); i++) {//TODO + if(i>5) + break; + Word.moveStart(); + DesignChange descBean = list1.get(i); + Word.putTxtToCell(1, 4, i+2, descBean.getChangeNub()); + } + + // 修改号 + Word.replaceAllText("#partID", partID); + // 件号 + Word.replaceAllText("#partNub", partNub); + + // 名称 + Word.replaceAllText("#changeName", changeName); + + // 图纸版本 + Word.replaceAllText("#drawingRev", drawingRev); + + // 工艺类型 + Word.replaceAllText("#processType", processType); + + // 工艺编码 + Word.replaceAllText("#processCod", processCod); + + // 工艺版本 + Word.replaceAllText("#processRev", processRev); + + // 修改原因描述 + Word.replaceAllText("#changeReason", changeReason); + + // 成品处理意见 + Word.replaceAllText("#treatSug", treatSug); + + // 在制品处理意见 + Word.replaceAllText("#articleSug", articleSug); + + } +} diff --git a/src/com/teamcenter/rac/workflow/commands/dotask/TestDoTaskDialog.java b/src/com/teamcenter/rac/workflow/commands/dotask/TestDoTaskDialog.java new file mode 100644 index 0000000..4055870 --- /dev/null +++ b/src/com/teamcenter/rac/workflow/commands/dotask/TestDoTaskDialog.java @@ -0,0 +1,88 @@ +package com.teamcenter.rac.workflow.commands.dotask; + +import java.awt.Frame; + +//import com.teamcenter.rac.workflow.commands.digitalsign +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentActionHandler; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.workflow.commands.newprocess.NewProcessCommand; +import com.teamcenter.rac.workflow.commands.newprocess.NewProcessDialog; + +public class TestDoTaskDialog extends DoTaskDialog{ + + public TestDoTaskDialog(Frame arg0, InterfaceAIFComponent arg1) { + super(arg0, arg1); + // TODO Auto-generated constructor stub + } + +// public TestDoTaskDialog(NewProcessCommand arg0) { +// super(arg0); +// +// System.out.println("NewProcessDialog"); +// +// // TODO Auto-generated constructor stub +// } + +// public TestDoTaskDialog(InterfaceAIFComponent paramInterfaceAIFComponent) { +// +// super(paramInterfaceAIFComponent); +// // TODO Auto-generated constructor stub +// TCComponentTask paramTCComponentTask = (TCComponentTask) paramInterfaceAIFComponent; +// try { +// TCComponentActionHandler[] actionHandlers = paramTCComponentTask.getActionHandlers(4); +// MessageBox.post("test","1",2); +// System.out.println(actionHandlers.length + "actionHandlers"); +// for(TCComponentActionHandler actionHandler:actionHandlers) { +// String name = actionHandler.getName(); +// System.out.println("actionHandler"+name); +// } +// +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// initDialog(); +// } + +// public TestDoTaskDialog(AIFDesktop paramAIFDesktop, AbstractAIFDialog paramAbstractAIFDialog, +// TCComponentTask paramTCComponentTask) { +// +// super(paramAIFDesktop, paramAbstractAIFDialog, paramTCComponentTask); +// +// try { +// TCComponentActionHandler[] actionHandlers = paramTCComponentTask.getActionHandlers(4); +// +// for(TCComponentActionHandler actionHandler:actionHandlers) { +// String name = actionHandler.getName(); +// System.out.println("actionHandler"+name); +// } +// +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// +//// DoTaskPanel.okButton.setEnabled(true); +//// initPanel(); +// // TODO Auto-generated constructor stub +// } + +// public TestDoTaskDialog(Frame paramFrame, InterfaceAIFComponent paramInterfaceAIFComponent) { +// super(paramFrame, paramInterfaceAIFComponent); +// +// +//// this.registry.getString("command.TITLE"); +//// parent. +// System.out.println("getDotaskDialog"); +// +// this +// +// // TODO Auto-generated constructor stub +// } + +} diff --git a/src/com/teamcenter/rac/workflow/commands/dotask/TestHandler.java b/src/com/teamcenter/rac/workflow/commands/dotask/TestHandler.java new file mode 100644 index 0000000..f3c303e --- /dev/null +++ b/src/com/teamcenter/rac/workflow/commands/dotask/TestHandler.java @@ -0,0 +1,28 @@ +//package com.teamcenter.rac.workflow.commands.dotask; +// +//import org.eclipse.core.commands.AbstractHandler; +//import org.eclipse.core.commands.ExecutionEvent; +//import org.eclipse.core.commands.ExecutionException; +// +//import com.teamcenter.rac.aif.AbstractAIFApplication; +//import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +//import com.teamcenter.rac.aifrcp.AIFUtility; +//import com.teamcenter.rac.kernel.TCSession; +// +//public class TestHandler extends AbstractHandler { +// +// @Override +// public Object execute(ExecutionEvent arg0) throws ExecutionException { +// // TODO Auto-generated method stub +// +// AbstractAIFApplication app = AIFUtility.getCurrentApplication(); +// TCSession session = (TCSession) app.getSession(); +// InterfaceAIFComponent comp; +// comp=app.getTargetComponent(); +// +// TestDoTaskDialog dialog = new TestDoTaskDialog(comp); +// +// return null; +// } +// +//} diff --git a/src/com/teamcenter/rac/workflow/commands/dotask/Util.java b/src/com/teamcenter/rac/workflow/commands/dotask/Util.java new file mode 100644 index 0000000..6ceaf6a --- /dev/null +++ b/src/com/teamcenter/rac/workflow/commands/dotask/Util.java @@ -0,0 +1,812 @@ +package com.teamcenter.rac.workflow.commands.dotask; + +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.imageio.ImageIO; + +import com.connor.nhjs.gy.findpz.WordBean; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; + +public class Util { + + + /** + * 文件名格式化,不允许的字符替换为空格 + * @param s + * @return + */ + public static String formatString( String s) + { + + if(s.contains(":") + ||s.contains("*") + ||s.contains("?") + ||s.contains("\"") + ||s.contains("|") + ||s.contains("<") + ||s.contains(">") + ||s.contains(" ") + ||s.contains("\\") + ||s.contains("\\\\") + ||s.contains("/")) + { + s = s.replace(" " , ""); + s = s.replace("\\\\" , ""); + s = s.replace("\\" , ""); + s = s.replace("/" , ""); + s = s.replace("<" , ""); + s = s.replace(">" , ""); + + s = s.replace("?" , ""); + s = s.replace("\"" , ""); + + s = s.replace(":" , ""); + s = s.replace("*" , ""); + s = s.replace("|" , ""); + s = s.replace(">" , ""); + + } + + return s; + } + +// /** +// * list转Map,获取指定长度的内容和图片 +// * @param list +// * @param width +// * @return +// */ + //76 + public static List list2map(String str, int width) { + List list2 = new ArrayList(); + Font font = new Font("宋体", Font.PLAIN, 11); + FontMetrics fm = sun.font.FontDesignMetrics.getMetrics(font); +// System.out.println("FontMetrics:"+fm.stringWidth("一二")+"=="+fm.stringWidth("QW")); + + String tmp_str = ""; +// int tmp_width = 0; +// int tmp_pic_width = 0; + Pattern pattern = Pattern.compile("w{1}(\\+)?(\\-)?(\\d+\\.\\d+)|(\\d+)"); + Pattern patternt = Pattern.compile("<.{1,}>+?"); + Pattern patternL = Pattern.compile("[A-Z]"); + + String[] values = str.split("\n"); +// int index = 0; + for(String value : values) { + Matcher m = patternt.matcher(value); + if(m.find()) { +// System.out.println("patternt:"+value+"::"+patternCount(patternt, value)+"=="+m.end(0)); + } + for (int j = 0; j < value.length(); j++) { + tmp_str = tmp_str+value.charAt(j); +// System.out.println("tmp width="+tmp_str+"=="+patternCount(patternL, tmp_str)); +// if(((fm.stringWidth(tmp_str)+tmp_pic_width)-tmp_width)>=width) { + if(fm.stringWidth(tmp_str) + patternCount(patternL, tmp_str)*4 >= width) { + //如果有数字、规格、公差等字符时,需要在同一行输出 + int len = tmp_str.length(); + Matcher matcherBall = pattern.matcher(tmp_str); + boolean flag = false; + while (matcherBall.find()) { + //System.out.println("matcherBall.find"); + int beginIndex = matcherBall.start(); + int endIndex = matcherBall.end(); + + if(endIndex==len) { + //判断下一个值 + if(j0) + { + for (int i = 0; i < contexts.length; i++) { + TCComponentBOMLine child = (TCComponentBOMLine) contexts[i].getComponent(); + if(typeList.get(0).equals("*")) + { + list.add(child); + }else + { + String childType = child.getItem().getType(); + if(typeList.contains(childType)||child.getItem().isTypeOf(childTypes)) + { + list.add(child); + } + } + } + } + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + } + + + return list; + } + + + /** + * 创建数据集 + * @param session + * @param name + * @param type + * @return + */ + public static TCComponentDataset createDataset(TCSession session, String name,String type) { + // 自动生成的方法存根 + TCComponentDataset dataset = null; + try { + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset"); + dataset = datasetType.create(name, "", type); + } catch (Exception e) { + // 自动生成的 catch 块 + e.printStackTrace(); + } + return dataset; + } + + + /** + * 获取关系对象数组 + * @param comp + * @param relation + * @return + */ + public static TCComponent[] getRelComponents(TCComponent comp, String relation) + { + TCComponent[] comps = null; + try { + if(comp==null) + { + return comps; + } + comps = comp.getRelatedComponents(relation); + } catch (Exception e) { + // Auto-generated catch block + System.out.println("ERROR:"+comp.toString()); + e.printStackTrace(); + } + + return comps; + } + + + /** + * 获取关系对象 + * @param comp + * @param relation + * @return + */ + public static TCComponent getRelComponent(TCComponent comp, String relation) + { + TCComponent component = null; + try { + + if(comp==null) + { + return component; + } + + TCComponent[] comps = comp.getRelatedComponents(relation); + if (comps!=null&&comps.length > 0) { + component = comps[0];// 如果存在多个制造目标怎么解决 ??? + } + } catch (Exception e) { + // Auto-generated catch block + System.out.println("ERROR:"+comp.toString()); + e.printStackTrace(); + } + + + return component; + } + + + /** + * 获取对象的属性 + * + * @param target2 + * @param string + * @return + */ + public static String getObjectProperty(TCComponent comp, String string) { + // 自动生成的方法存根 + String value = ""; + try { + if(comp==null) + { + return value; + } + value = comp.getProperty(string); + } catch (Exception e) { + // 自动生成的 catch 块 + System.out.println("ERROR:"+comp.toString()); + e.printStackTrace(); + } + return value; + } + + + /** + * 获取对象规范关系下名称相同的数据集 + * @param comp + * @param name + * @param type + * @return + */ + public static TCComponent[] getDatasetsByType(TCComponent comp,String[] types) + { + TCComponent[] datasets = null; + try { + TCComponent[] components = comp.getRelatedComponents("IMAN_specification"); + if(components==null||components.length<=0){ + return null; + } + + ArrayList list = new ArrayList(); + for (int i = 0; i < components.length; i++) { + String type1 = components[i].getType(); + for (int j = 0; j < types.length; j++) { + if(components[i] instanceof TCComponentDataset &&type1.equals(types[j])) + { + list.add(components[i]); + break; + } + } + } + + datasets = (TCComponent[]) list.toArray(new TCComponent[list.size()]); + } catch (Exception e) { + // Auto-generated catch block + System.out.println("ERROR:"+comp.toString()); + e.printStackTrace(); + } + + return datasets; + } + + + /** + * 获取对象规范关系下名称相同的数据集 + * @param comp + * @param name + * @param type + * @return + */ + public static TCComponent[] getDatasetByNames(TCComponent comp,String[] names,String type) + { + TCComponent[] datasets = null; + try { + TCComponent[] components = comp.getRelatedComponents("IMAN_specification"); + if(components==null||components.length<=0){ + return null; + } + List nameList = (List) Arrays.asList(names); + + ArrayList list = new ArrayList(); + for (int i = 0; i < components.length; i++) { + String name1 = components[i].getProperty("object_name"); + String type1 = components[i].getType(); + if(nameList.contains(name1)&&type1.equals(type)) + { + list.add(components[i]); +// break; + } + } + datasets = (TCComponent[]) list.toArray(new TCComponent[list.size()]); + + } catch (Exception e) { + // Auto-generated catch block + System.out.println("ERROR:"+comp.toString()); + e.printStackTrace(); + } + + return datasets; + } + + + /** + * 获取对象规范关系下名称相同的数据集 + * @param comp + * @param name + * @param type + * @return + */ + public static TCComponent getDatasetByName(TCComponent comp,String name,String type) + { + TCComponent dataset = null; + try { + TCComponent[] components = comp.getRelatedComponents("IMAN_specification"); + if(components==null||components.length<=0){ + return null; + } + for (int i = 0; i < components.length; i++) { + String name1 = components[i].getProperty("object_name"); + String type1 = components[i].getType(); + if(name1.equals(name)&&type1.equals(type)) + { + dataset = components[i]; + break; + } + } + } catch (Exception e) { + // Auto-generated catch block + System.out.println("ERROR:"+comp.toString()); + e.printStackTrace(); + } + + return dataset; + } + + + /** + * 检查对指定对象的写权限 + * @param session + * @param comp + * @return + */ + public static boolean hasWritePrivilege(TCSession session, TCComponent comp) { + try { + TCAccessControlService accessControlService = session.getTCAccessControlService(); + TCComponent component = (TCComponent) comp; + + if (comp instanceof TCComponentBOMLine) { + // 检查bomview + TCComponentBOMLine bomline = (TCComponentBOMLine) comp; + TCComponentItemRevision ir = bomline.getItemRevision(); + TCComponent[] bvs = ir.getRelatedComponents("structure_revisions"); + + if (bvs != null && bvs.length > 0) { + component = bvs[0]; + } + } + return accessControlService.checkPrivilege(component, "WRITE"); + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } + + + /** + * 获取BOM行对象的版本 + * @param partLine + * @return + */ + public static TCComponentItemRevision getBOMLineRev(TCComponentBOMLine partLine) { + // Auto-generated method stub + try { + TCComponentItemRevision rev = partLine.getItemRevision(); + if(rev==null) + { + System.out.println("WARNING:BOM行版本未加载 "+partLine.toString()); + } + return rev; + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + + /** + * 替换Word中的指定内容为图片 + * @param word + * @param map + */ + public static void replaceImage(WordBean word, HashMap map) { + // TODO Auto-generated method stub + + Iterator it = map.entrySet().iterator(); + while(it.hasNext()) + { + Map.Entry entry = (Entry) it.next(); + word.moveStart(); + word.replaceAllImage(entry.getKey(), entry.getValue()); + } + } + + /** + * 下载工程中的图片到本地 + * @param workDir + * @param picName + * @return + */ + public static String downloadPicture(String workDir, String picName) { + // Auto-generated method stub + InputStream inputStream= Util.class.getResourceAsStream(picName); + + if(!workDir.endsWith("\\")) + { + workDir = workDir+"\\"; + } + File file = new File(workDir+picName); + + if(file.exists()) + { + return file.getAbsolutePath(); + } + + try { + FileOutputStream output = new FileOutputStream(file); + byte[] b = new byte[1024 * 1024]; + int len; + while ((len = inputStream.read(b)) != -1) { + output.write(b, 0, len); + } + output.flush(); + output.close(); + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + } + + return file.getAbsolutePath(); + } + + + /** + * 获取布尔类型的属性值 + * @param component + * @param property + * @return + */ + public static boolean getLogicalProperty(TCComponent component, String property) { + // Auto-generated method stub + if(component==null) + { + return false; + } + try { + boolean flag = component.getLogicalProperty(property); + return flag; + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + } + + return false; + } + + + + /** + * 获取多个list中最大的大小值 + * @param lists + * @return + */ + public static int getMaxListNum(ArrayList lists) { + // TODO Auto-generated method stub + int max = 0; + for (int i = 0; i < lists.size(); i++) { + ArrayList list = (ArrayList) lists.get(i); + if (list.size()> max) { + max = list.size(); + } + } + return max; + } + + /** + * 获取工装值转为list + * @param compList + * @return + */ + public static ArrayList getToolingPropertyList(ArrayList compList) { + // TODO Auto-generated method stub + ArrayList list = new ArrayList(); + for (int i = 0; i < compList.size(); i++) { + TCComponentBOMLine bomLine = (TCComponentBOMLine) compList.get(i); + TCComponentItemRevision revision = Util.getBOMLineRev(bomLine); + String value = Util.getObjectProperty(revision, "object_name"); + TCComponent form = Util.getRelComponent(revision, "IMAN_master_form_rev"); + String value2 = Util.getObjectProperty(form, "t5_ToolNumber"); + list.add(value+" "+value2); + } + return list; + } + + + /** + * 获取属性值转为list + * @param compList + * @param property + * @return + */ + public static ArrayList getAccessoryPropertyList(ArrayList compList, String property) { + // Auto-generated method stub + ArrayList list = new ArrayList(); + for (int i = 0; i < compList.size(); i++) { + TCComponent component = (TCComponent) compList.get(i); + String value = Util.getObjectProperty(component, property); + + if(component instanceof TCComponentBOMLine) + { + try { + TCComponentBOMLine bomLine = (TCComponentBOMLine) component; + TCComponentItemRevision revision = bomLine.getItemRevision(); + TCComponent form = Util.getRelComponent(revision, "IMAN_master_form_rev"); + String paihao = Util.getObjectProperty(form, "t5_paihao"); + value = value+paihao; + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + } + + } + + list.add(value); + } + return list; + } + + + /** + * 获取属性值转为list + * @param compList + * @param property + * @return + */ + public static ArrayList getPropertyList(ArrayList compList, String property) { + // Auto-generated method stub + ArrayList list = new ArrayList(); + for (int i = 0; i < compList.size(); i++) { + TCComponent component = (TCComponent) compList.get(i); + String value = Util.getObjectProperty(component, property); + list.add(value); + } + return list; + } + + + /** + * list添加空值 + * @param list + * @param maxRow + * @return + */ + public static ArrayList addNullValue(ArrayList list, int maxRow) { + // Auto-generated method stub + if (list.size() < maxRow) { + int n = maxRow - list.size(); + for (int k = 0; k < n; k++) { + list.add(""); + } + } + return list; + } + + /** + * 获取对象上级(何处使用) + * @param rev + * @return + */ + public static TCComponent[] gewWhereUsed(TCComponentItemRevision rev) { + try { + TCComponent[] parentComps = rev.whereUsed(TCComponentItemRevision.WHERE_USED_ALL); + List parentList = new ArrayList(); + HashMap map = new HashMap(); + for (int i = 0; i < parentComps.length; i++) { + if (parentComps[i].getIntProperty("active_seq") == 1) { + String id = parentComps[i].getProperty("item_id"); + String revId = parentComps[i].getProperty("item_revision_id"); + if (map.containsKey(id)) { + TCComponent rev1 = (TCComponent) map.get(id); + String revId1 = rev1.getProperty("item_revision_id"); + if (revId.compareTo(revId1) > 0) { + parentList.remove(rev1); + parentList.add(parentComps[i]); + map.put(id, parentComps[i]); + } else { + continue; + } + } else { + parentList.add(parentComps[i]); + map.put(id, parentComps[i]); + } + } + } + + if (!parentList.isEmpty()) { + return (TCComponent[]) parentList.toArray(new TCComponent[parentList.size()]); + } + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + + + /** + * 判断对象是否已有状态 + * @param object + * @return + */ + public static boolean hasStatus(TCComponent object) { + try { + + object.refresh(); + TCComponent[] relStatus = object.getReferenceListProperty("release_status_list"); + if (relStatus == null || relStatus.length <= 0) { + // System.out.println("找不到状态"); + return false; + } else { + return true; + } + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + return false; + } + + } + + /** + * 复制文件 + * @param srcName + * @param targetName + * @return + * @throws IOException + */ + public static int copyFile(String srcName, String targetName) throws Exception { + File srcFile = new File(srcName); + File targetFile = new File(targetName); + File parentDir = new File(targetFile.getParent()); + if (!srcFile.isFile()) { + return 0; + } + + if (targetFile.isFile()) { + targetFile.delete(); + } + if (!parentDir.isDirectory()) { + parentDir.mkdirs(); + } + + FileInputStream input = new FileInputStream(srcFile); + FileOutputStream output = new FileOutputStream(targetFile); + + byte[] b = new byte[1024]; + int len; + while ((len = input.read(b)) != -1) { + output.write(b, 0, len); + } + output.flush(); + output.close(); + input.close(); + return 1; + } + +// /** +// * 根据内容宽度List转换 +// * @param list +// * @param width +// * @return +// */ +// public static ArrayList transList(ArrayList list,int width) { +// // Auto-generated method stub +// ArrayList resultList = new ArrayList(); +// +// for (int k = 0; k < list.size(); k++) { +// ArrayList tempList = new ArrayList(); +// tempList.add(list.get(k)); +// Object[] objs = Util.list2map(tempList,width); +// ArrayList list2 = (ArrayList) objs[0]; +// resultList.addAll(list2); +// } +// +// return resultList; +// } +} diff --git a/src/com/teamcenter/rac/workflow/commands/dotask/newprocess_user.properties b/src/com/teamcenter/rac/workflow/commands/dotask/newprocess_user.properties new file mode 100644 index 0000000..498d9d7 --- /dev/null +++ b/src/com/teamcenter/rac/workflow/commands/dotask/newprocess_user.properties @@ -0,0 +1,41 @@ +#*================================================================================================== +# +# Copyright (c) 1998 Unigraphics Solutions Inc., An EDS Company +# Unpublished - All rights reserved +# +#=================================================================================================== +# File description: This properties file contains all keys pertaining to the dotask package. This +# is an internal file so therefore only TC PBU developers should be modifying +# this file. To make changes please modify the dotask_user.properties file. Do +# NOT modify this file. This allows properties found in this file to be +# over-written but not destroyed. +# +# Filename: dotask.properties +# Module : com.teamcenter.rac.workflow.common.commands.dotask +# +#=================================================================================================== +#Date Name Description of Change +#04-Oct-1999 ROWLANDS created +#15-Oct-1999 ROWLANDS merge from lee_cs_15Sep99 tc_v60_cs latest +#11-Feb-2000 mccollr Remove the localization keys and place within the locale file. +#05-Mar-2000 chenm Merge from int_v6.2 to chenm_v62 +#27-Jan-2005 Zhixin Huang Change the icon from gif to png file. +#06-Feb-2006 Venkatesh Chitnis de-imanization +#$HISTORY$ +#=================================================================================================*/ + +#import=com.teamcenter.rac.workflow.common.common +#newProcessDialog=com.teamcenter.rac.workflow.commands.dotask.TestDoTaskDialog +#command.TITLE=\u6267\u884C Do \u4EFB\u52A1\u6D4B\u8BD5123 + +#taskNameLabel=\u4EFB\u52A1\u540D\uFF1A +#taskInstructionsLabel=\u4EFB\u52A1\u8BF4\u660E\uFF1A +#doTaskComplete.LABEL=\u5B8C\u6210 +#doTaskUnableToComplete.LABEL=\u65E0\u6CD5\u5B8C\u6210 +#processDescLabel=\u6D41\u7A0B\u63CF\u8FF0\uFF1A +# +## Messages +## ------------------------ +##xxxMessage=XXX +#completingDoTaskMessage=\u6B63\u5728\u5B8C\u6210 Do \u4EFB\u52A1 +#failedCompleteDoTaskMessage=\u672A\u80FD\u5B8C\u6210 Do \u4EFB\u52A1 \ No newline at end of file diff --git a/src/com/teamcenter/rac/workflow/commands/dotask/processcard.properties b/src/com/teamcenter/rac/workflow/commands/dotask/processcard.properties new file mode 100644 index 0000000..0ea9591 --- /dev/null +++ b/src/com/teamcenter/rac/workflow/commands/dotask/processcard.properties @@ -0,0 +1,7 @@ +op.Name=\u751F\u6210\u5DE5\u827A\u5361\u7247 +novalidconfig.Error=\u6CA1\u6709\u627E\u5230\u6709\u6548\u7684\u914D\u7F6E\uFF0C\u8BF7\u68C0\u67E5\u3002 +exporting=\u6B63\u5728\u5BFC\u51FA +unsupportedtargets.Error1=\u4EE5\u4E0B\u5BF9\u8C61\u4E0D\u652F\u6301\u5BFC\u51FA\uFF1A\n%s +init.Name=\u51C6\u5907\u5BFC\u51FA... +notowner.Error=\u975E\u5F53\u524D\u5BF9\u8C61\u7684\u6240\u6709\u8005\uFF0C\u4E0D\u80FD\u6267\u884C\u5361\u7247\u751F\u6210\u64CD\u4F5C +novalidtarget.Error=\u672A\u627E\u5230\u53EF\u5BFC\u51FA\u7684\u5BF9\u8C61\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u3002 diff --git a/src/tcUser_erpUser.properties b/src/tcUser_erpUser.properties new file mode 100644 index 0000000..a139502 --- /dev/null +++ b/src/tcUser_erpUser.properties @@ -0,0 +1,58 @@ +admin=IT_PLM +24294=ZX_LWZ +70094=ZX_YHJ +24649=YYG_KLX +70284=ZX_HJ +70399=ZX_DJF +70491=ZX_DF +70132=ZX_HQP +70403=ZX_LXW +70199=ZX_WCM +01157=JS_wxl +23466=JS_LRF +22873=JS_WJB +22295=ZX_WJ +70285=ZX_MTY +70286=ZX_WQC +70538=ZX_WPC +70532=ZX_BY +75398=ZX_ZGL +70550=ZX_BYET +70099=ZX_LLP +01425=ZX_WMS +70090=ZX_GLJ +70091=ZX_GHQ +70311=ZX_JZJ +70458=ZX_ZXF +70068=ZX_ZCY +70495=ZX_JY +70407=ZX_PJ +70498=ZX_CL +70152=ZX_YZ +70446=ZX_DZM +70460=ZX_SLM +70528=ZX_LZG +70463=ZX_LJ +70489=ZX_LXJ +70088=ZX_YJL +70194=ZX_FM +70201=ZX_WSQ +70287=ZX_WYJ +70400=ZX_CPB +70442=ZX_LGP +70443=ZX_GJC +70472=ZX_GYY +70244=ZX_WFQ +70086=ZX_ZQX +70276=ZX_WXL +70200=ZX_SMD +70447=ZX_MYP +70444=ZX_LQ +70465=ZX_WRZ +70462=ZX_DZH +70237=ZX_WXG +70195=ZX_ZB +70518=ZX_LT +70504=ZX_WW +70560=ZX_GSX +70552=ZX_COMM \ No newline at end of file diff --git a/src/test/WorkFlowTest.java b/src/test/WorkFlowTest.java new file mode 100644 index 0000000..8d29f9f --- /dev/null +++ b/src/test/WorkFlowTest.java @@ -0,0 +1,13 @@ +package test; + +import com.teamcenter.rac.workflow.commands.newprocess.NewProcessDialog; +import com.teamcenter.rac.workflow.commands.dotask.DoTaskCommand; +import com.teamcenter.rac.workflow.commands.design.DesignCommand; + +public class WorkFlowTest { + + + + +// NewProcessDialog +}