commit ddfb96e5a1ee4c4754b8716f54728d7063ff12c7 Author: hongcj Date: Mon Dec 18 17:16:24 2023 +0800 鎻愪氦 diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..ab8d28e --- /dev/null +++ b/.classpath @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..bf758ad --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/applauncher.xml b/.idea/libraries/applauncher.xml new file mode 100644 index 0000000..96785cd --- /dev/null +++ b/.idea/libraries/applauncher.xml @@ -0,0 +1,443 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/plugins.xml b/.idea/libraries/plugins.xml new file mode 100644 index 0000000..1dff864 --- /dev/null +++ b/.idea/libraries/plugins.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..ba93b15 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..88bd588 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 0000000..864ad79 --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + com.connor.ld.importSJ + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..9f6ece8 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +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..c035f2e --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,40 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: ImportSJ +Bundle-SymbolicName: com.connor.ld.importSJ;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Vendor: CONNOR +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime;bundle-version="3.15.100", + com.teamcenter.rac.util;bundle-version="13000.1.0", + com.teamcenter.rac.aifrcp;bundle-version="13000.1.0", + TcSoaCoreRac;bundle-version="13000.1.0", + TcSoaClient;bundle-version="13000.1.0", + com.teamcenter.rac.common;bundle-version="13000.1.0", + com.teamcenter.rac.ui;bundle-version="13000.1.0", + org.eclipse.osgi.services;bundle-version="3.7.100", + org.eclipse.osgi.util;bundle-version="3.5.100", + com.teamcenter.rac.tcapps;bundle-version="13000.1.0", + com.teamcenter.rac.kernel;bundle-version="13000.1.0", + com.teamcenter.rac.workflow.processdesigner;bundle-version="13000.1.0", + org.apache.poi.39;bundle-version="3.9.0" +Automatic-Module-Name: com.connor.ld.importSJ +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ClassPath: lib/fastjson-1.2.66.jar, + ., + lib/okhttp-2.7.4.jar, + lib/okio-1.13.0.jar, + lib/sqljdbc4.jar, + lib/sapjco3.jar, + lib/fastjson2-2.0.34.jar, + lib/jackson-annotations-2.15.0.jar, + lib/jackson-core-2.15.2.jar, + lib/jackson-databind-2.15.0.jar, + lib/mssql-jdbc-7.0.0.jre8.jar, + lib/ojdbc7.jar, + lib/poi-3.7-20101029.jar, + lib/poi-4.1.2.jar, + lib/poi-examples-3.7-20101029.jar, + lib/poi-ooxml-3.7-20101029.jar, + lib/poi-ooxml-schemas-3.7-20101029.jar, + lib/gson-2.8.5.jar diff --git a/bin/com/connor/ld/importsj/handlers/HistoryFolderDialog$1.class b/bin/com/connor/ld/importsj/handlers/HistoryFolderDialog$1.class new file mode 100644 index 0000000..56c25ea Binary files /dev/null and b/bin/com/connor/ld/importsj/handlers/HistoryFolderDialog$1.class differ diff --git a/bin/com/connor/ld/importsj/handlers/HistoryFolderDialog$2.class b/bin/com/connor/ld/importsj/handlers/HistoryFolderDialog$2.class new file mode 100644 index 0000000..ebf8924 Binary files /dev/null and b/bin/com/connor/ld/importsj/handlers/HistoryFolderDialog$2.class differ diff --git a/bin/com/connor/ld/importsj/handlers/HistoryFolderDialog$3.class b/bin/com/connor/ld/importsj/handlers/HistoryFolderDialog$3.class new file mode 100644 index 0000000..a3db696 Binary files /dev/null and b/bin/com/connor/ld/importsj/handlers/HistoryFolderDialog$3.class differ diff --git a/bin/com/connor/ld/importsj/handlers/HistoryFolderDialog$ExcelFileFilter.class b/bin/com/connor/ld/importsj/handlers/HistoryFolderDialog$ExcelFileFilter.class new file mode 100644 index 0000000..46d6bab Binary files /dev/null and b/bin/com/connor/ld/importsj/handlers/HistoryFolderDialog$ExcelFileFilter.class differ diff --git a/bin/com/connor/ld/importsj/handlers/HistoryFolderDialog.class b/bin/com/connor/ld/importsj/handlers/HistoryFolderDialog.class new file mode 100644 index 0000000..ccc32f2 Binary files /dev/null and b/bin/com/connor/ld/importsj/handlers/HistoryFolderDialog.class differ diff --git a/bin/com/connor/ld/importsj/handlers/ImpBean.class b/bin/com/connor/ld/importsj/handlers/ImpBean.class new file mode 100644 index 0000000..48b9cd7 Binary files /dev/null and b/bin/com/connor/ld/importsj/handlers/ImpBean.class differ diff --git a/bin/com/connor/ld/importsj/handlers/ImportGYLXMatnrHandler.class b/bin/com/connor/ld/importsj/handlers/ImportGYLXMatnrHandler.class new file mode 100644 index 0000000..89db6c2 Binary files /dev/null and b/bin/com/connor/ld/importsj/handlers/ImportGYLXMatnrHandler.class differ diff --git a/bin/com/connor/ld/importsj/handlers/ImportMatnrHandler.class b/bin/com/connor/ld/importsj/handlers/ImportMatnrHandler.class new file mode 100644 index 0000000..3d4fe46 Binary files /dev/null and b/bin/com/connor/ld/importsj/handlers/ImportMatnrHandler.class differ diff --git a/bin/com/connor/ld/importsj/handlers/SampleHandler.class b/bin/com/connor/ld/importsj/handlers/SampleHandler.class new file mode 100644 index 0000000..0e0108c Binary files /dev/null and b/bin/com/connor/ld/importsj/handlers/SampleHandler.class differ diff --git a/bin/com/connor/ld/importsj/handlers/SoaUtils.class b/bin/com/connor/ld/importsj/handlers/SoaUtils.class new file mode 100644 index 0000000..0a496b7 Binary files /dev/null and b/bin/com/connor/ld/importsj/handlers/SoaUtils.class differ diff --git a/bin/com/connor/ld/importsj/handlers/TableBean.class b/bin/com/connor/ld/importsj/handlers/TableBean.class new file mode 100644 index 0000000..53da3b9 Binary files /dev/null and b/bin/com/connor/ld/importsj/handlers/TableBean.class differ diff --git a/bin/com/connor/ld/sendBOMMesJc/FbomAndCbom.class b/bin/com/connor/ld/sendBOMMesJc/FbomAndCbom.class new file mode 100644 index 0000000..2f5f538 Binary files /dev/null and b/bin/com/connor/ld/sendBOMMesJc/FbomAndCbom.class differ diff --git a/bin/com/connor/ld/sendBOMMesJc/Result.class b/bin/com/connor/ld/sendBOMMesJc/Result.class new file mode 100644 index 0000000..e454c10 Binary files /dev/null and b/bin/com/connor/ld/sendBOMMesJc/Result.class differ diff --git a/bin/com/connor/ld/sendBOMMesJc/SendBOMHandler$1.class b/bin/com/connor/ld/sendBOMMesJc/SendBOMHandler$1.class new file mode 100644 index 0000000..93cbbc3 Binary files /dev/null and b/bin/com/connor/ld/sendBOMMesJc/SendBOMHandler$1.class differ diff --git a/bin/com/connor/ld/sendBOMMesJc/SendBOMHandler.class b/bin/com/connor/ld/sendBOMMesJc/SendBOMHandler.class new file mode 100644 index 0000000..42a755b Binary files /dev/null and b/bin/com/connor/ld/sendBOMMesJc/SendBOMHandler.class differ diff --git a/bin/com/connor/ld/sendBOMMesJc/SendBOMOpertion$1.class b/bin/com/connor/ld/sendBOMMesJc/SendBOMOpertion$1.class new file mode 100644 index 0000000..c5b5b92 Binary files /dev/null and b/bin/com/connor/ld/sendBOMMesJc/SendBOMOpertion$1.class differ diff --git a/bin/com/connor/ld/sendBOMMesJc/SendBOMOpertion$2.class b/bin/com/connor/ld/sendBOMMesJc/SendBOMOpertion$2.class new file mode 100644 index 0000000..6337fcc Binary files /dev/null and b/bin/com/connor/ld/sendBOMMesJc/SendBOMOpertion$2.class differ diff --git a/bin/com/connor/ld/sendBOMMesJc/SendBOMOpertion.class b/bin/com/connor/ld/sendBOMMesJc/SendBOMOpertion.class new file mode 100644 index 0000000..d641d1b Binary files /dev/null and b/bin/com/connor/ld/sendBOMMesJc/SendBOMOpertion.class differ diff --git a/bin/com/connor/ld/sendBOMMesJc/SendObj.class b/bin/com/connor/ld/sendBOMMesJc/SendObj.class new file mode 100644 index 0000000..9d01033 Binary files /dev/null and b/bin/com/connor/ld/sendBOMMesJc/SendObj.class differ diff --git a/bin/com/connor/ld/sendBOMMesJc/UpperCaseSerializer$UpperSerializer.class b/bin/com/connor/ld/sendBOMMesJc/UpperCaseSerializer$UpperSerializer.class new file mode 100644 index 0000000..6fb671c Binary files /dev/null and b/bin/com/connor/ld/sendBOMMesJc/UpperCaseSerializer$UpperSerializer.class differ diff --git a/bin/com/connor/ld/sendBOMMesJc/UpperCaseSerializer.class b/bin/com/connor/ld/sendBOMMesJc/UpperCaseSerializer.class new file mode 100644 index 0000000..32f1344 Binary files /dev/null and b/bin/com/connor/ld/sendBOMMesJc/UpperCaseSerializer.class differ diff --git a/bin/com/connor/ld/sendBOMMesJc/accPojo/AccBean.class b/bin/com/connor/ld/sendBOMMesJc/accPojo/AccBean.class new file mode 100644 index 0000000..5507a71 Binary files /dev/null and b/bin/com/connor/ld/sendBOMMesJc/accPojo/AccBean.class differ diff --git a/bin/com/connor/ld/sendBOMMesJc/accPojo/OT_BOM.class b/bin/com/connor/ld/sendBOMMesJc/accPojo/OT_BOM.class new file mode 100644 index 0000000..24548e8 Binary files /dev/null and b/bin/com/connor/ld/sendBOMMesJc/accPojo/OT_BOM.class differ diff --git a/bin/com/connor/ld/sendBOMMesJc/accPojo/OT_WERKS.class b/bin/com/connor/ld/sendBOMMesJc/accPojo/OT_WERKS.class new file mode 100644 index 0000000..abc6c02 Binary files /dev/null and b/bin/com/connor/ld/sendBOMMesJc/accPojo/OT_WERKS.class differ diff --git a/bin/com/connor/ld/sendBOMMesJc/sendPojo/IT_BOM.class b/bin/com/connor/ld/sendBOMMesJc/sendPojo/IT_BOM.class new file mode 100644 index 0000000..897c5f6 Binary files /dev/null and b/bin/com/connor/ld/sendBOMMesJc/sendPojo/IT_BOM.class differ diff --git a/bin/com/connor/ld/sendBOMMesJc/sendPojo/IT_WERKS.class b/bin/com/connor/ld/sendBOMMesJc/sendPojo/IT_WERKS.class new file mode 100644 index 0000000..b191191 Binary files /dev/null and b/bin/com/connor/ld/sendBOMMesJc/sendPojo/IT_WERKS.class differ diff --git a/bin/com/connor/ld/sendBOMMesJc/sendPojo/I_ITEM.class b/bin/com/connor/ld/sendBOMMesJc/sendPojo/I_ITEM.class new file mode 100644 index 0000000..5d38fb7 Binary files /dev/null and b/bin/com/connor/ld/sendBOMMesJc/sendPojo/I_ITEM.class differ diff --git a/bin/com/connor/ld/sendBOMMesJc/sendPojo/SendBean.class b/bin/com/connor/ld/sendBOMMesJc/sendPojo/SendBean.class new file mode 100644 index 0000000..99b5a48 Binary files /dev/null and b/bin/com/connor/ld/sendBOMMesJc/sendPojo/SendBean.class differ diff --git a/bin/com/connor/ld/sendBOMMesJc/sendPojo/VirtuallyBom.class b/bin/com/connor/ld/sendBOMMesJc/sendPojo/VirtuallyBom.class new file mode 100644 index 0000000..5d525a5 Binary files /dev/null and b/bin/com/connor/ld/sendBOMMesJc/sendPojo/VirtuallyBom.class differ diff --git a/bin/com/connor/ld/sendMesJc/DbPool.class b/bin/com/connor/ld/sendMesJc/DbPool.class new file mode 100644 index 0000000..65a8b14 Binary files /dev/null and b/bin/com/connor/ld/sendMesJc/DbPool.class differ diff --git a/bin/com/connor/ld/sendMesJc/SAPConn.class b/bin/com/connor/ld/sendMesJc/SAPConn.class new file mode 100644 index 0000000..676129d Binary files /dev/null and b/bin/com/connor/ld/sendMesJc/SAPConn.class differ diff --git a/bin/com/connor/ld/sendMesJc/SendGylxFram$1.class b/bin/com/connor/ld/sendMesJc/SendGylxFram$1.class new file mode 100644 index 0000000..c513ce5 Binary files /dev/null and b/bin/com/connor/ld/sendMesJc/SendGylxFram$1.class differ diff --git a/bin/com/connor/ld/sendMesJc/SendGylxFram.class b/bin/com/connor/ld/sendMesJc/SendGylxFram.class new file mode 100644 index 0000000..8dbcf34 Binary files /dev/null and b/bin/com/connor/ld/sendMesJc/SendGylxFram.class differ diff --git a/bin/com/connor/ld/sendMesJc/SendGylxHandler$1.class b/bin/com/connor/ld/sendMesJc/SendGylxHandler$1.class new file mode 100644 index 0000000..20a1b04 Binary files /dev/null and b/bin/com/connor/ld/sendMesJc/SendGylxHandler$1.class differ diff --git a/bin/com/connor/ld/sendMesJc/SendGylxHandler.class b/bin/com/connor/ld/sendMesJc/SendGylxHandler.class new file mode 100644 index 0000000..e74ffe2 Binary files /dev/null and b/bin/com/connor/ld/sendMesJc/SendGylxHandler.class differ diff --git a/bin/com/connor/ld/sendMesJc/SendMesFram$1.class b/bin/com/connor/ld/sendMesJc/SendMesFram$1.class new file mode 100644 index 0000000..5e13b46 Binary files /dev/null and b/bin/com/connor/ld/sendMesJc/SendMesFram$1.class differ diff --git a/bin/com/connor/ld/sendMesJc/SendMesFram.class b/bin/com/connor/ld/sendMesJc/SendMesFram.class new file mode 100644 index 0000000..c6d63ed Binary files /dev/null and b/bin/com/connor/ld/sendMesJc/SendMesFram.class differ diff --git a/bin/com/connor/ld/sendMesJc/SendMesHandler$1.class b/bin/com/connor/ld/sendMesJc/SendMesHandler$1.class new file mode 100644 index 0000000..014cffa Binary files /dev/null and b/bin/com/connor/ld/sendMesJc/SendMesHandler$1.class differ diff --git a/bin/com/connor/ld/sendMesJc/SendMesHandler.class b/bin/com/connor/ld/sendMesJc/SendMesHandler.class new file mode 100644 index 0000000..168c27c Binary files /dev/null and b/bin/com/connor/ld/sendMesJc/SendMesHandler.class differ diff --git a/bin/com/connor/ld/sendMesJc/Test.class b/bin/com/connor/ld/sendMesJc/Test.class new file mode 100644 index 0000000..9df9c40 Binary files /dev/null and b/bin/com/connor/ld/sendMesJc/Test.class differ diff --git a/bin/sapconnect.properties b/bin/sapconnect.properties new file mode 100644 index 0000000..760f864 --- /dev/null +++ b/bin/sapconnect.properties @@ -0,0 +1,18 @@ +#\u6D4B\u8BD5\u7CFB\u7EDF +JCO_ASHOST_STR=10.10.22.15 +JCO_SYSNR_STR=00 +JCO_CLIENT_STR=800 +JCO_USER_STR=LDIT001 +JCO_PASSWD_STR=AlliedIT@2022 +#JCO_ASHOST_STR=10.10.22.14 +#JCO_SYSNR_STR=00 +#JCO_CLIENT_STR=400 +#JCO_USER_STR=LDIT001 +#JCO_PASSWD_STR=LDIT@2022 +#JCO_ASHOST_STR=10.200.1.192 +#JCO_SYSNR_STR=00 +#JCO_CLIENT_STR=800 +#JCO_USER_STR=SAP_TC +#JCO_PASSWD_STR=Sap_RFC2020 + + diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..f0e35fd --- /dev/null +++ b/build.properties @@ -0,0 +1,23 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + lib/fastjson-1.2.66.jar,\ + lib/okhttp-2.7.4.jar,\ + lib/okio-1.13.0.jar,\ + lib/sqljdbc4.jar,\ + lib/sapjco3.jar,\ + lib/fastjson2-2.0.34.jar,\ + lib/jackson-annotations-2.15.0.jar,\ + lib/jackson-core-2.15.2.jar,\ + lib/jackson-databind-2.15.0.jar,\ + lib/mssql-jdbc-7.0.0.jre8.jar,\ + lib/ojdbc7.jar,\ + lib/poi-3.7-20101029.jar,\ + lib/poi-4.1.2.jar,\ + lib/poi-examples-3.7-20101029.jar,\ + lib/poi-ooxml-3.7-20101029.jar,\ + lib/poi-ooxml-schemas-3.7-20101029.jar,\ + lib/gson-2.8.5.jar diff --git a/com.connor.ld.importSJ.iml b/com.connor.ld.importSJ.iml new file mode 100644 index 0000000..aaefd4a --- /dev/null +++ b/com.connor.ld.importSJ.iml @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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/fastjson-1.2.66.jar b/lib/fastjson-1.2.66.jar new file mode 100644 index 0000000..048bdc8 Binary files /dev/null and b/lib/fastjson-1.2.66.jar differ diff --git a/lib/fastjson2-2.0.34.jar b/lib/fastjson2-2.0.34.jar new file mode 100644 index 0000000..a0b4d9f Binary files /dev/null and b/lib/fastjson2-2.0.34.jar differ diff --git a/lib/gson-2.8.5.jar b/lib/gson-2.8.5.jar new file mode 100644 index 0000000..0d5baf3 Binary files /dev/null and b/lib/gson-2.8.5.jar differ diff --git a/lib/jackson-annotations-2.15.0.jar b/lib/jackson-annotations-2.15.0.jar new file mode 100644 index 0000000..fc66d44 Binary files /dev/null and b/lib/jackson-annotations-2.15.0.jar differ diff --git a/lib/jackson-core-2.15.2.jar b/lib/jackson-core-2.15.2.jar new file mode 100644 index 0000000..a0e7486 Binary files /dev/null and b/lib/jackson-core-2.15.2.jar differ diff --git a/lib/jackson-databind-2.15.0.jar b/lib/jackson-databind-2.15.0.jar new file mode 100644 index 0000000..b4d9383 Binary files /dev/null and b/lib/jackson-databind-2.15.0.jar differ diff --git a/lib/mssql-jdbc-7.0.0.jre8.jar b/lib/mssql-jdbc-7.0.0.jre8.jar new file mode 100644 index 0000000..9f68c4d Binary files /dev/null and b/lib/mssql-jdbc-7.0.0.jre8.jar differ diff --git a/lib/ojdbc7.jar b/lib/ojdbc7.jar new file mode 100644 index 0000000..fd38a6c Binary files /dev/null and b/lib/ojdbc7.jar differ diff --git a/lib/okhttp-2.7.4.jar b/lib/okhttp-2.7.4.jar new file mode 100644 index 0000000..be7249f Binary files /dev/null and b/lib/okhttp-2.7.4.jar differ diff --git a/lib/okio-1.13.0.jar b/lib/okio-1.13.0.jar new file mode 100644 index 0000000..02c302f Binary files /dev/null and b/lib/okio-1.13.0.jar differ diff --git a/lib/poi-3.7-20101029.jar b/lib/poi-3.7-20101029.jar new file mode 100644 index 0000000..a08d953 Binary files /dev/null and b/lib/poi-3.7-20101029.jar differ diff --git a/lib/poi-4.1.2.jar b/lib/poi-4.1.2.jar new file mode 100644 index 0000000..3803353 Binary files /dev/null and b/lib/poi-4.1.2.jar differ diff --git a/lib/poi-examples-3.7-20101029.jar b/lib/poi-examples-3.7-20101029.jar new file mode 100644 index 0000000..914243d Binary files /dev/null and b/lib/poi-examples-3.7-20101029.jar differ diff --git a/lib/poi-ooxml-3.7-20101029.jar b/lib/poi-ooxml-3.7-20101029.jar new file mode 100644 index 0000000..5f36eb4 Binary files /dev/null and b/lib/poi-ooxml-3.7-20101029.jar differ diff --git a/lib/poi-ooxml-schemas-3.7-20101029.jar b/lib/poi-ooxml-schemas-3.7-20101029.jar new file mode 100644 index 0000000..82282b5 Binary files /dev/null and b/lib/poi-ooxml-schemas-3.7-20101029.jar differ diff --git a/lib/sapjco3.jar b/lib/sapjco3.jar new file mode 100644 index 0000000..8f12391 Binary files /dev/null and b/lib/sapjco3.jar differ diff --git a/lib/sqljdbc4.jar b/lib/sqljdbc4.jar new file mode 100644 index 0000000..d6b7f6d Binary files /dev/null and b/lib/sqljdbc4.jar differ diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..4cc6fa2 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/connor/ld/importsj/handlers/HistoryFolderDialog.java b/src/com/connor/ld/importsj/handlers/HistoryFolderDialog.java new file mode 100644 index 0000000..5081560 --- /dev/null +++ b/src/com/connor/ld/importsj/handlers/HistoryFolderDialog.java @@ -0,0 +1,321 @@ +package com.connor.ld.importsj.handlers; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Label; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTextField; +import javax.swing.filechooser.FileFilter; + +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.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentFormType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class HistoryFolderDialog extends AbstractAIFDialog{ + private AbstractAIFApplication app; + private TCSession session; + + + private JButton jButton; + private JFileChooser jFileChooser; + private JLabel jLabel; + private TCComponentFolder folder; + private String getType; + + public HistoryFolderDialog(TCSession session,String type) { + this.session=session; + this.getType = type; + } + private String relation; + private String formType; + private Map beanMap = new HashMap(); + private File selectFile; + @Override + public void run() { + //显示窗口 + String[] value = null; + if("WL".equals(getType)) { + value = session.getPreferenceService().getStringValues("LD_CompanyFormTable_Mapping"); + if(value==null || value.length<2) { + MessageBox.post("首选项LD_CompanyFormTable_Mapping配置有误,请检查。","提示",2); + return; + } + }else if("GYLX".equals(getType)) { + value = session.getPreferenceService().getStringValues("LD_GYLXCompanyFormTable_Mapping"); + if(value==null || value.length<2) { + MessageBox.post("首选项LD_GYLXCompanyFormTable_Mapping配置有误,请检查。","提示",2); + return; + } + } + String[] split = value[0].split("\\."); + relation = split[0]; + formType = split[1]; + //单元格3=ml8_gcxxb.ML8_FormTable.ml8_tscgl + for(int i=1;i + FileInputStream fis = new FileInputStream(selectFile); + XSSFWorkbook wb = new XSSFWorkbook(fis); + XSSFSheet sheetAt = wb.getSheetAt(0); + int cnt = sheetAt.getPhysicalNumberOfRows(); + List> valsList = new ArrayList>(); //存属性值 + List idRevList = new ArrayList(); //不存在的版本对象 + List nameList = new ArrayList(); //不存在的版本对象 + List revList = new ArrayList();//要处理表单的版本 + int numCell = 2; + while(true) { + String name1 = getCellValue(sheetAt,0,numCell); //第一行单元格名称,对应首选项 + if(name1 == null || name1.equals("")) { + break; + } + numCell = numCell + 1; + nameList.add(name1); + } + for(int i=1;i valList = new ArrayList(); //不存在的版本对象 + for(int j = 2;j0) { + MessageBox.post("以下对象不存在:\n"+idRevList.toString(),"提示",2); + return; + } + for(int t=0;t props = new ArrayList(); + for(int j=0;j list = valsList.get(t); + int len = 0; + for(int j=0;j"+token); + Request request = new Request.Builder().url(url) + .method("POST", body) +// .addHeader("Authorization", "Bearer "+token) +// .addHeader("send", "PLM") +// .addHeader("ET_AUTH_TYPE", "JWT") +// .addHeader("ET_AUTH_TOKEN", token) +// .addHeader("transID", getDate1()) + .addHeader("Content-Type", "application/json") + .build(); + Response response = client.newCall(request).execute(); +// response.body().byteStream() +// System.out.println(response.body().string()); + JSONObject parseObject = JSON.parseObject(response.body().string()); +// System.out.println("result2==>"+parseObject); +// Boolean bool = parseObject.getBoolean("success"); +// if(!bool) { +// String msg = parseObject.getString("msg"); +// return msg; +// }else { + return parseObject; +// } + } + 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 boolean isEmpty(String str) { + return str == null || "".equals(str.trim()); + } + + public static String getIp() throws UnknownHostException { + InetAddress addr = InetAddress.getLocalHost(); + String hostname = addr.getHostName(); + System.out.println("Local host name: "+hostname); + return hostname; + } +// public static File getDatasetFile(TCComponentDataset dataset, String refName) throws Exception { +// String dir = "D:\\Siemens\\IIS\\web\\file"; +// if (dir != null) { +// File filePath=new File(dir); +// if(!filePath.isDirectory()) { +// filePath.mkdirs(); +// } +// String[] fileNames = dataset.getFileNames(refName); +// if (fileNames.length == 0) { +// return null; +// } else { +// File file = dataset.getFile(refName, fileNames[0], dir); +// return file; +//// return file; +// } +// } else { +// throw new TCException("Directory not found."); +// } +// } + 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 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 void setTableValue(String[] propNames , String[][] values, + TCSession session, TCComponent rev,String tableType,String formProp) { + try { + System.out.println("tabletype:"+tableType); + System.out.println("formProp:"+formProp); + System.out.println("rev:"+rev); + List c = new ArrayList(); + + DataManagementService service = DataManagementService.getService(session); + + CreateIn[] newIn = new CreateIn[values.length]; + + for (int i = 0; i < values.length ; ++i) { + String[] vals = values[i]; + CreateIn in = new CreateIn(); + Map propMap = new HashMap(); + + for(int p=0;p 0) { + + System.out.println(response.serviceData.getPartialError(0).getMessages()[0]); + + } + if (response.serviceData.sizeOfCreatedObjects() > 0) { +// int length = response.serviceData.sizeOfCreatedObjects(); +// int sizeOfCreatedObjects = response.serviceData.sizeOfCreatedObjects(); +// System.out.println("create + "+sizeOfCreatedObjects); + int length = response.output.length; + for (int i = 0; i < length; ++i) { + c.add(response.output[i].objects[0]); + } + } + +// TCComponent[] referenceValueArray = rev.getTCProperty(formProp).getReferenceValueArray(); +// +// for(TCComponent ref:referenceValueArray) { +// c.add(ref); +// } + rev.getTCProperty(formProp).setReferenceValueArray((TCComponent[]) c.toArray(new TCComponent[c.size()])); + +// item.getTCProperty(prop).setReferenceValueArray((TCComponent[]) c.toArray(new TCComponent[c.size()])); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/com/connor/ld/importsj/handlers/TableBean.java b/src/com/connor/ld/importsj/handlers/TableBean.java new file mode 100644 index 0000000..7438732 --- /dev/null +++ b/src/com/connor/ld/importsj/handlers/TableBean.java @@ -0,0 +1,46 @@ +package com.connor.ld.importsj.handlers; + +import java.util.ArrayList; +import java.util.List; + +public class TableBean { + + public static void main(String[] args) { + String prop = "1000;2000;"; + String[] split = prop.split(";"); + for(String string:split) { + System.out.println(string+"111"); + } + } + + private String formProp; + private String tableType; + private String[] tableProp; + private List tableVals = new ArrayList(); + public String getFormProp() { + return formProp; + } + public void setFormProp(String formProp) { + this.formProp = formProp; + } + public String getTableType() { + return tableType; + } + public void setTableType(String tableType) { + this.tableType = tableType; + } + public String[] getTableProp() { + return tableProp; + } + public void setTableProp(String[] tableProp) { + this.tableProp = tableProp; + } + public List getTableVals() { + return tableVals; + } + public void setTableVals(List tableVals) { + this.tableVals = tableVals; + } + + +} diff --git a/src/com/connor/ld/sendBOMMesJc/FbomAndCbom.java b/src/com/connor/ld/sendBOMMesJc/FbomAndCbom.java new file mode 100644 index 0000000..50cb5dd --- /dev/null +++ b/src/com/connor/ld/sendBOMMesJc/FbomAndCbom.java @@ -0,0 +1,69 @@ +package com.connor.ld.sendBOMMesJc; + +import java.util.ArrayList; + +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.TCException; + +public class FbomAndCbom { + + private TCComponentItemRevision topRev; + + private ArrayList parentRecision; + + private ArrayList> groupRecision; + + private ArrayList>> childrenRecision; + + public FbomAndCbom(TCComponentItemRevision topRev, ArrayList parentRecision, ArrayList> groupRecision, ArrayList>> childrenRecision) { + this.topRev = topRev; + this.parentRecision = parentRecision; + this.groupRecision = groupRecision; + this.childrenRecision = childrenRecision; + } + + public TCComponentItemRevision getTopRev() { + return topRev; + } + + public void setTopRev(TCComponentItemRevision topRev) { + this.topRev = topRev; + } + + public ArrayList getParentRecision() { + return parentRecision; + } + + public void setParentRecision(ArrayList parentRecision) { + this.parentRecision = parentRecision; + } + + public ArrayList> getGroupRecision() { + return groupRecision; + } + + public void setGroupRecision(ArrayList> groupRecision) { + this.groupRecision = groupRecision; + } + + public ArrayList>> getChildrenRecision() { + return childrenRecision; + } + + public void setChildrenRecision(ArrayList>> childrenRecision) { + this.childrenRecision = childrenRecision; + } + + @Override + public String toString() { + return "FbomAndCbom{" + + "topRev=" + topRev + + ", parentRecision=" + parentRecision + + ", groupRecision=" + groupRecision + + ", childrenRecision=" + childrenRecision + + '}'; + } +} diff --git a/src/com/connor/ld/sendBOMMesJc/Result.java b/src/com/connor/ld/sendBOMMesJc/Result.java new file mode 100644 index 0000000..1ffd30e --- /dev/null +++ b/src/com/connor/ld/sendBOMMesJc/Result.java @@ -0,0 +1,49 @@ +package com.connor.ld.sendBOMMesJc; + +public class Result { + private String id; + private String mas; + private String code; + + public Result() { + } + + public Result(String id, String mas, String code) { + this.id = id; + this.mas = mas; + this.code = code; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getMas() { + return mas; + } + + public void setMas(String mas) { + this.mas = mas; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + @Override + public String toString() { + return "Result{" + + "id='" + id + '\'' + + ", mas='" + mas + '\'' + + ", code='" + code + '\'' + + '}'; + } +} diff --git a/src/com/connor/ld/sendBOMMesJc/SendBOMHandler.java b/src/com/connor/ld/sendBOMMesJc/SendBOMHandler.java new file mode 100644 index 0000000..7636688 --- /dev/null +++ b/src/com/connor/ld/sendBOMMesJc/SendBOMHandler.java @@ -0,0 +1,64 @@ +package com.connor.ld.sendBOMMesJc; + +import java.util.ArrayList; + +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.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class SendBOMHandler extends AbstractHandler{ + private TCSession session; + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + try { + new Thread() { + @Override + public void run() { + // 获取tc当前选择的操作 + InterfaceAIFComponent[] targets = app.getTargetComponents(); + ArrayList bomList = new ArrayList(); + for(InterfaceAIFComponent target : targets) { + if (target instanceof TCComponentItemRevision) { + TCComponentItemRevision bomLine = (TCComponentItemRevision) target; + session = bomLine.getSession(); + TCComponentBOMWindowType winType = null; + TCComponentBOMWindow view = null; + TCComponentBOMLine line = null; + try { + winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + view = winType.create(null); + line = view.setWindowTopLine((bomLine).getItem(), bomLine, null, null); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + bomList.add(line); + }else { + MessageBox.post("请选择物料版本对象", "提示", MessageBox.INFORMATION); + return; + } + } + + SendBOMOpertion sendBOMOpertion = new SendBOMOpertion(session, bomList); + session.queueOperation(sendBOMOpertion); + } + }.start(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/com/connor/ld/sendBOMMesJc/SendBOMOpertion.java b/src/com/connor/ld/sendBOMMesJc/SendBOMOpertion.java new file mode 100644 index 0000000..187db97 --- /dev/null +++ b/src/com/connor/ld/sendBOMMesJc/SendBOMOpertion.java @@ -0,0 +1,1485 @@ +package com.connor.ld.sendBOMMesJc; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.net.HttpURLConnection; +import java.net.URL; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.*; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.WindowConstants; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.connor.ld.sendBOMMesJc.sendPojo.*; +import com.connor.ld.sendMesJc.DbPool; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.sap.conn.jco.JCoDestination; +import com.sap.conn.jco.JCoException; +import com.sap.conn.jco.JCoFunction; +import com.sap.conn.jco.JCoParameterList; +import com.sap.conn.jco.JCoTable; +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.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.util.MessageBox; + + +public class SendBOMOpertion extends AbstractAIFOperation{ + private String[] header = new String[] {"物料ID","物料版本","传递SAP状态","传递MES状态"}; + private ArrayList bomList = new ArrayList(); + private static ArrayList resultList = new ArrayList(); + /** + * 如选中类型为组合刀具版本(LD6_ComtooldesRevision), + * 则只需要传递给MES,无需传递给SAP,传递状态对话框中 + * 传递SAP状态中显示“无需传递SAP + */ + private static ArrayList flag1List = new ArrayList(); + private static TCSession session; + private static String MESURL; + private static ArrayList valueList; + private ArrayList typeList; + private ArrayList childTypesFlag; + private static ArrayList dateConnList = new ArrayList(); + //private static ResourceBundle resource = ResourceBundle.getBundle("db"); + private static ArrayList> BZFSrevisions = new ArrayList>(); + private static Map> changDateByLineMap= new HashMap>(); + private Boolean falgIsOne = true; + private static String insertQuery = "INSERT INTO OA_LOG (NAME,[DESC],[IN],OUT,CALLER,PROVIDER,ITEM_ID,TIME) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; + public SendBOMOpertion(TCSession session, ArrayList bomList) { + // TODO Auto-generated constructor stub + this.session = session; + this.bomList = bomList; + } + + @Override + public void executeOperation() throws Exception { + //清空全局变量 + try { + System.out.println("开始清空变量"); + resultList.clear(); + + }catch(Exception e) { + System.out.println("清空变量完毕"); + } + //获取连接数据库信息 + String[] value2 = session.getPreferenceService().getStringValues("LD_dbinfo2"); + if(value2==null || value2.length==0) { + MessageBox.post("首选项LD_dbinfo配置有误,请检查。","提示",2); + return; + }else { + Collections.addAll(dateConnList, value2); + } + + // 获取url首选项的值 + String[] url = getSYX("LD_PLM2MES_BOM_Config"); + if(url !=null && url.length>0) { + MESURL = url[0]; + }else { + MessageBox.post("首选项LD_PLM2MES_BOM_Config设置有误", "提示", MessageBox.INFORMATION); + return; + } + // 获取参数列表首选项的值 + String[] argValues = getSYX("LD_SendBOM_Config"); + if(argValues !=null && argValues !=null && argValues.length>0) { + valueList = new ArrayList<>(Arrays.asList(argValues)); + }else { + MessageBox.post("首选项LD_SendBOM_Config设置有误", "提示", MessageBox.INFORMATION); + return; + } + //获取选中类型是否在首选项中 + String[] types = getSYX("LD_SendBOM_PartType"); + if(types !=null && types.length>0) { + typeList = new ArrayList<>(Arrays.asList(types)); + for(TCComponentBOMLine bomLine : bomList) { + String bomType = getItemRevisionValue(bomLine.getItemRevision(), "object_type"); + System.out.println("获取的类型为:"+bomType); + if(!typeList.contains(bomType)) { + MessageBox.post("编号" + getItemRevisionValue(bomLine.getItemRevision(), "item_id") + "的数据不能执行发送BOM到SAP/MES", "提示", MessageBox.INFORMATION); + return; + } + if(!"LD6_ComtooldesRevision".equals(bomType)){ + flag1List.add(true); + }else{ + flag1List.add(false); + } + } + }else { + MessageBox.post("首选项LD_SendBOM_PartType设置有误", "提示", MessageBox.INFORMATION); + return; + } + + //如选中类型为工装版本(LD6_EquipmentRevision),子件类型从首选项LD6_SendBOM_EquipmentChildType中获取 + String[] childTypes = getSYX("LD6_SendBOM_EquipmentChildType"); + if(childTypes !=null && childTypes.length>0) { + childTypesFlag = new ArrayList<>(Arrays.asList(childTypes)); + }else { + MessageBox.post("首选项LD6_SendBOM_EquipmentChildType设置有误", "提示", MessageBox.INFORMATION); + return; + } + + + //递归选中bom,获取发送bom组合 + //多父多组多子 + for(TCComponentBOMLine bomline : bomList) { + //父级对象 + ArrayList fathers = new ArrayList(); + //组级对象 + ArrayList> groupRecision = new ArrayList>(); + //子集对象 + ArrayList>> childrens = new ArrayList>>(); + //选中类型工装版本(LD6_EquipmentRevision)开关数组 + ArrayList falgQBJList = new ArrayList(); + List bomLineNum = new ArrayList(); + ArrayList falgQBJNameList = new ArrayList(); + //添加选中类型工装版本(LD6_EquipmentRevision)开关 + Boolean selectFlagIsGZ = false; + String selectFlagType = getItemRevisionValue(bomline.getItemRevision(), "object_type"); + //构建简易BOM + if("LD6_EquipmentRevision".equals(selectFlagType)){ + selectFlagIsGZ = true; + flagBomLine(bomline,falgQBJList,bomLineNum,0); + System.out.println("企标件和首选项配置对象的个数为:"+falgQBJList.size()); + //构建虚拟bom + VirtuallyBom virtuallyBom = new VirtuallyBom(bomline,falgQBJList,bomLineNum); + for(TCComponentBOMLine e : falgQBJList){ + falgQBJNameList.add(getItemRevisionValue(e.getItemRevision(),"object_string")); + } + collectAllBomLine2(virtuallyBom,fathers,groupRecision,childrens,selectFlagIsGZ); + + //还原合并数据 + for(TCComponentBOMLine key : changDateByLineMap.keySet()){ + for(String name : changDateByLineMap.get(key).keySet()){ + key.setStringProperty(name,changDateByLineMap.get(key).get(name)); + } + } + } + //构建企标件结构bom + collectAllBomLine(bomline,fathers,groupRecision,childrens,selectFlagIsGZ,falgQBJNameList); + FbomAndCbom fbomAndCbom = new FbomAndCbom(bomline.getItemRevision(), fathers,groupRecision,childrens); + resultList.add(fbomAndCbom); + } + //遍历resultList判断是否有重复的NO + List> rowsList = new ArrayList>(); + for(int a=0;a rows = new ArrayList(); + rows.add(getItemRevisionValue(f.getTopRev(), "item_id")); + rows.add(getItemRevisionValue(f.getTopRev(), "item_revision_id")); + System.out.println("是否传递SAP:"+flag1List.get(a)); + if(flag1List.get(a)){ + rows.add(""); + }else{ + rows.add("无需传递SAP"); + } + rows.add(""); + rowsList.add(rows); + } + //获取发送的数据 + //获取发送的数据,创建窗口 + Vector vector = new Vector<>(Arrays.asList(header)); + JTable table = new JTable(buildTableModel(rowsList,vector)); // 创建一个 JTable,并将查询结果放到其中 + //JTable jTable = mergeCells(table); + createAndShowFrame(table); + } + public void flagBomLine(TCComponentBOMLine topBomLine,ArrayList falgQBJList ,List bomLineNum,int depth) throws TCException { + if (topBomLine.hasChildren()) { + AIFComponentContext[] childrens = topBomLine.getChildren(); + depth++; + if(!"LD6_EquipCompRevision".equals(getItemRevisionValue(topBomLine.getItemRevision(),"object_type"))){ + for (AIFComponentContext aifComponentContext : childrens) { + TCComponentBOMLine bomLine = (TCComponentBOMLine) aifComponentContext.getComponent(); + String object_type = getItemRevisionValue(bomLine.getItemRevision(), "object_type"); + if("LD6_EquipCompRevision".equals(object_type) || childTypesFlag.contains(object_type)){ + falgQBJList.add(bomLine); + bomLineNum.add(depth); + } + flagBomLine(bomLine,falgQBJList,bomLineNum,depth); + } + } + } + } + public JTable mergeCells(JTable table) { + int rowCount = table.getRowCount(); + int columnCount = table.getColumnCount(); + DefaultTableModel mergedModel = new DefaultTableModel(); + for (int i = 0; i < rowCount; i++) { + Object[] rowData = new Object[columnCount]; + boolean merged = false; + for (int j = 0; j < columnCount; j++) { + rowData[j] = table.getValueAt(i, j); + if (j > 0 && j < 2 && rowData[j].equals(rowData[j - 1])) { + merged = true; + rowData[j] = ""; + } + } + if (merged) { + mergedModel.addRow(rowData); + } else { + mergedModel.addRow(rowData); + } + } + return new JTable(mergedModel); + } + + public static void createAndShowFrame(JTable table) { + // 创建 JFrame + JFrame frame = new JFrame("传递状态"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setSize(1000, 600); + // 获取屏幕的尺寸 + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + // 计算 JFrame 的居中位置 + int x = (screenSize.width - frame.getWidth()) / 2; + int y = (screenSize.height - frame.getHeight()) / 2; + // 设置 JFrame 的位置 + frame.setLocation(x, y); + // 创建一个面板用于放置组件 + JPanel panel = new JPanel(new BorderLayout()); + // 在面板上方放置 + JScrollPane scrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); // 创建一个带滚动条的 JScrollPane,并将 JTable 放到其中 + panel.add(scrollPane, BorderLayout.NORTH); + // 在面板下方放置确定按钮和取消按钮 + JButton confirmButton = new JButton("确定"); + JButton cancelButton = new JButton("取消"); + JPanel buttonPanel = new JPanel(); + buttonPanel.add(confirmButton); + buttonPanel.add(cancelButton); + panel.add(buttonPanel, BorderLayout.CENTER); + // 将面板添加到 + frame.getContentPane().add(panel); + frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);//关闭窗口不退出 + // 显示 JFrame + frame.setVisible(true); + // 添加确定按钮的点击事件监听器 + confirmButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // 在这里编写确定按钮点击后的逻辑 + //遍历结果集获取一父多字结构 + for(int i=0;i sendBeans = sendValueToBean(bean); + for(SendBean sendBean : sendBeans){ + System.out.println("LD_SendBOM_Config:"+sendBean.toString()); + } + if(flag1List.get(i)){ + //传递SAP + Result result = sendSAP(sendBeans, bean); + String valueAt = table.getValueAt(i, 0).toString(); + if(result.getId().equals(valueAt)){ + table.setValueAt(result.getCode(), i, 2); + } + } + + //传递MES + table.setValueAt(sendMES(sendBeans,bean), i, 3); + + //还原合并数据 + for(TCComponentBOMLine key : changDateByLineMap.keySet()){ + for(String name : changDateByLineMap.get(key).keySet()){ + key.setStringProperty(name,changDateByLineMap.get(key).get(name)); + } + } + + } catch (JsonProcessingException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + } + + + }); + // 添加取消按钮的点击事件监听器 + cancelButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + frame.dispose(); + } + }); + } + public static String sendMES(ArrayList sendBean, FbomAndCbom bean) throws JsonProcessingException, TCException { + // TODO Auto-generated method stub + // 将Java Bean对象转换为JSON字符串 + // 创建ObjectMapper对象 + + + + ObjectMapper mapper = new ObjectMapper(); + Gson gson = new Gson(); + String json = gson.toJson(sendBean); + System.out.println("json:"+json); + + + String getPostRequest = sendPostRequest(MESURL,json); + System.out.println("getPostRequest:"+getPostRequest); + //解析返回结果 + //JSONArray jsonArray = JSONArray.parseArray(getPostRequest); + JsonNode jsonNode = mapper.readTree(getPostRequest); + System.out.println(jsonNode); + String resutl = ""; + resutl = jsonNode.get("msg").asText(); + + //传递数据库日志 + System.out.println("开始传递数据库日志"); + Date date = new Date(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + // 将时间转换为字符串 + String dateString = dateFormat.format(date); + //SAP:写入数据库 + Connection conn = getConn(); + //MES:写入数据库 + try (PreparedStatement stmt = conn.prepareStatement(insertQuery)) { + stmt.setString(1,"MES_002"); + stmt.setString(2, "物料BOM"); + stmt.setString(3, json); + stmt.setString(4, jsonNode.toString()); + stmt.setString(5, "PLM"); + stmt.setString(6, "MES"); + stmt.setString(7, getItemRevisionValue(bean.getTopRev(), "item_id")); + stmt.setString(8, dateString); + // 执行插入语句 + stmt.executeUpdate(); + System.out.println("插入成功"); + } catch (SQLException e) { + e.printStackTrace(); + } + System.out.println("数据库日志传递成功"); + return resutl; + + } + + public static Result sendSAP(ArrayList sendBean, FbomAndCbom bean) throws TCException, JsonProcessingException { + // TODO Auto-generated method stub + // 获取SAP连接 + JCoDestination destination = com.connor.ld.sendMesJc.SAPConn.connect(); + JCoFunction function = null; + try { + function = destination.getRepository().getFunction("ZFM_PLM_003"); + } catch (JCoException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + // 设置函数模块的输入参数 + JCoParameterList input = function.getImportParameterList(); + JCoTable inputTab = input.getTable("INPUT"); + System.out.println(inputTab.toXML()); + JsonNode jsonNode = null; + String json = ""; + try { + + ObjectMapper mapper = new ObjectMapper(); + //String writeValueAsString = mapper.writeValueAsString(sendBean); + Gson gson = new Gson(); + json = gson.toJson(sendBean); + System.out.println("json:"+json); + jsonNode = mapper.readTree(json); + } catch (JsonMappingException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (JsonProcessingException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + System.out.println("jsonNode:"+jsonNode); + // 遍历 JsonNode 对象 + System.out.println("json的长度为:"+jsonNode.size()); + for(int a=0;a> fields = factoryNode.fields(); + while (fields.hasNext()) { + Map.Entry field = fields.next(); + String fieldName = field.getKey(); + String fieldValue = field.getValue().asText(); + System.out.println("field.getKey():" + fieldName); + System.out.println("field.getValue().asText():" + fieldValue); + IT_WERKS.setValue(fieldName, fieldValue); + } + } + inputTab.setValue("IT_WERKS", IT_WERKS); + } + // 处理 IT_BOM 字段 + JsonNode iMarcNode1 = node.get("IT_BOM"); + if (iMarcNode1 != null && iMarcNode1.isArray()) { + JCoTable IT_BOM = inputTab.getTable("IT_BOM"); + for (JsonNode factoryNode : iMarcNode1) { + IT_BOM.appendRow(); + //处理I_ITEM字段 + JsonNode iMarcNode11 = factoryNode.get("I_ITEM"); + if (iMarcNode11 != null && iMarcNode11.isArray()) { + JCoTable I_ITEM = IT_BOM.getTable("I_ITEM"); + for (JsonNode factoryNode1 : iMarcNode11) { + I_ITEM.appendRow(); + Iterator> fields = factoryNode1.fields(); + while (fields.hasNext()) { + Map.Entry field = fields.next(); + String fieldName = field.getKey(); + String fieldValue = field.getValue().asText(); + System.out.println("field.getKey():" + fieldName); + System.out.println("field.getValue().asText():" + fieldValue); + I_ITEM.setValue(fieldName, fieldValue); + } + } + IT_BOM.setValue("I_ITEM", I_ITEM); + } + + Iterator> fields = factoryNode.fields(); + while (fields.hasNext()) { + Map.Entry field = fields.next(); + String fieldName = field.getKey(); + String fieldValue = field.getValue().asText(); + System.out.println("field.getKey():" + fieldName); + System.out.println("field.getValue().asText():" + fieldValue); + IT_BOM.setValue(fieldName, fieldValue); + } + } + inputTab.setValue("IT_BOM", IT_BOM); + } + } + + System.out.println("输入值:"+inputTab.toXML()); + //调用函数模块 + try { + function.execute(destination); + } catch (JCoException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // 获取函数模块的输出参数 + JCoTable returnTable = function.getExportParameterList().getTable("OUTPUT"); + System.out.println("获取的返回值:"+returnTable.toXML()); + JSONObject returnjson = new JSONObject(); + String array = "["; + for(int n=0;n results = new ArrayList(); + for(int i=0;i sendValueToBean(FbomAndCbom bean) throws TCException { + // TODO Auto-generated method stub + //resultList + ArrayList sendBeans = new ArrayList(); + for(int i=0;i iT_WERKS = new ArrayList(); + TCComponentBOMLine father = bean.getParentRecision().get(i); + ArrayList tcComponentBOMLines = bean.getGroupRecision().get(i); + List iT_BOMs = new ArrayList(); + Boolean falg = true; + if(tcComponentBOMLines.size()>0){ //当前对象有多个bom可选序号 + System.out.println("当前对象有多个bom可选序号"); + for(int j=0;j tcComponentBOMLines1 = bean.getChildrenRecision().get(i).get(j); + List i_ITEMs = new ArrayList(); + for(int n=0;n1) { + if(right[0].equals("f")) { + String getAttrValue = ""; + if("Item".equals(right[1])) { + getAttrValue = getItemValue(father.getItem(), right[2]); + System.out.println("获取的值"+right[2]+":"+getAttrValue); + setvalue(father.getItem(),left[0],left[1],getAttrValue,sendBean,it_BOM,i_ITEM,BZFSrevisions.get(j)); + }else if("Rev".equals(right[1])) { + getAttrValue = getItemRevisionValue(father.getItemRevision(), right[2]); + System.out.println("获取的值"+right[2]+":"+getAttrValue); + setvalue(father.getItemRevision(),left[0],left[1],getAttrValue,sendBean,it_BOM,i_ITEM,BZFSrevisions.get(j)); + } + else if("Form".equals(right[1])) { + getAttrValue = getFormValue(getForm(father.getItemRevision()), right[2]); + System.out.println("获取的值"+right[2]+":"+getAttrValue); + setvalue(getForm(father.getItemRevision()),left[0],left[1],getAttrValue,sendBean,it_BOM,i_ITEM,BZFSrevisions.get(j)); + } + else if("Table".equals(right[1]) && falg) { + TCComponent[] table = getTable(father.getItemRevision()); + System.out.println("获取的值"+right[2]+":"+table); + for(TCComponent compTable : table) { + getAttrValue = compTable.getStringProperty(right[2]); + //特殊处理it_werks + IT_WERKS it_WERKS = new IT_WERKS(); + it_WERKS.setWERKS(getAttrValue); + iT_WERKS.add(it_WERKS); + //setvalue(compTable,left[0],left[1],getAttrValue,sendBean,it_WERKS,it_BOM,i_ITEM,BZFSrevisions.get(0)); + } + falg = false; + } + else if("BomLine".equals(right[1])) { + getAttrValue = getBomLineValue(father, right[2]); + System.out.println("获取的值"+right[2]+":"+getAttrValue); + setvalue(father,left[0],left[1],getAttrValue,sendBean,it_BOM,i_ITEM,BZFSrevisions.get(j)); + } + }else { + String getAttrValue = ""; + if("Item".equals(right[1])) { + getAttrValue = getItemValue(children.getItem(), right[2]); + System.out.println("获取的值"+right[2]+":"+getAttrValue); + setvalue(children.getItem(),left[0],left[1],getAttrValue,sendBean,it_BOM,i_ITEM,BZFSrevisions.get(j)); + }else if("Rev".equals(right[1])) { + getAttrValue = getItemRevisionValue(children.getItemRevision(), right[2]); + System.out.println("获取的值"+right[2]+":"+getAttrValue); + setvalue(children.getItemRevision(),left[0],left[1],getAttrValue,sendBean,it_BOM,i_ITEM,BZFSrevisions.get(j)); + } + else if("Form".equals(right[1])) { + getAttrValue = getFormValue(getForm(children.getItemRevision()), right[2]); + System.out.println("获取的值"+right[2]+":"+getAttrValue); + setvalue(getForm(children.getItemRevision()),left[0],left[1],getAttrValue,sendBean,it_BOM,i_ITEM,BZFSrevisions.get(j)); + } + else if("Table".equals(right[1]) && falg) { + TCComponent[] table = getTable(children.getItemRevision()); + System.out.println("获取的值"+right[2]+":"+table); + for(TCComponent compTable : table) { + getAttrValue = compTable.getStringProperty(right[2]); + //特殊处理it_werks + IT_WERKS it_WERKS = new IT_WERKS(); + it_WERKS.setWERKS(getAttrValue); + iT_WERKS.add(it_WERKS); + //setvalue(compTable,left[0],left[1],getAttrValue,sendBean,it_WERKS,it_BOM,i_ITEM,BZFSrevisions.get(j)); + } + falg = false; + } + else if("BomLine".equals(right[1])) { + getAttrValue = getBomLineValue(children, right[2]); + System.out.println("获取的值"+right[2]+":"+getAttrValue); + setvalue(children,left[0],left[1],getAttrValue,sendBean,it_BOM,i_ITEM,BZFSrevisions.get(j)); + } + } + }else { + //直接赋值给bean + setvalue(children,left[0],left[1],right[0],sendBean,it_BOM,i_ITEM,BZFSrevisions.get(j)); + } + } + i_ITEMs.add(i_ITEM); + } + + it_BOM.setI_ITEM(i_ITEMs); + iT_BOMs.add(it_BOM); + } + //iT_WERKS.add(it_WERKS); + sendBean.setIT_BOM(iT_BOMs); + }else{ //当前对象没有bom可选序号 + System.out.println("当前对象没有bom可选序号"); + ArrayList tcComponentBOMLines1 = bean.getChildrenRecision().get(i).get(0); + IT_BOM it_BOM = new IT_BOM(); + List i_ITEMs = new ArrayList(); + for(int n=0;n1) { + if(right[0].equals("f")) { + String getAttrValue = ""; + if("Item".equals(right[1])) { + getAttrValue = getItemValue(father.getItem(), right[2]); + System.out.println("获取的值"+right[2]+":"+getAttrValue); + setvalue(father.getItem(),left[0],left[1],getAttrValue,sendBean,it_BOM,i_ITEM,BZFSrevisions.get(0)); + }else if("Rev".equals(right[1])) { + getAttrValue = getItemRevisionValue(father.getItemRevision(), right[2]); + System.out.println("获取的值"+right[2]+":"+getAttrValue); + setvalue(father.getItemRevision(),left[0],left[1],getAttrValue,sendBean,it_BOM,i_ITEM,BZFSrevisions.get(0)); + } + else if("Form".equals(right[1])) { + getAttrValue = getFormValue(getForm(father.getItemRevision()), right[2]); + System.out.println("获取的值"+right[2]+":"+getAttrValue); + setvalue(getForm(father.getItemRevision()),left[0],left[1],getAttrValue,sendBean,it_BOM,i_ITEM,BZFSrevisions.get(0)); + } + else if("Table".equals(right[1]) && falg) { + TCComponent[] table = getTable(father.getItemRevision()); + System.out.println("获取的值"+right[2]+":"+table); + for(TCComponent compTable : table) { + getAttrValue = compTable.getStringProperty(right[2]); + //特殊处理it_werks + IT_WERKS it_WERKS = new IT_WERKS(); + it_WERKS.setWERKS(getAttrValue); + iT_WERKS.add(it_WERKS); + //setvalue(compTable,left[0],left[1],getAttrValue,sendBean,it_WERKS,it_BOM,i_ITEM,BZFSrevisions.get(0)); + } + falg = false; + } + else if("BomLine".equals(right[1])) { + getAttrValue = getBomLineValue(father, right[2]); + System.out.println("获取的值"+right[2]+":"+getAttrValue); + setvalue(father,left[0],left[1],getAttrValue,sendBean,it_BOM,i_ITEM,BZFSrevisions.get(0)); + } + }else { + String getAttrValue = ""; + if("Item".equals(right[1])) { + getAttrValue = getItemValue(children.getItem(), right[2]); + System.out.println("获取的值"+right[2]+":"+getAttrValue); + setvalue(children.getItem(),left[0],left[1],getAttrValue,sendBean,it_BOM,i_ITEM,BZFSrevisions.get(0)); + }else if("Rev".equals(right[1])) { + getAttrValue = getItemRevisionValue(children.getItemRevision(), right[2]); + System.out.println("获取的值"+right[2]+":"+getAttrValue); + setvalue(children.getItemRevision(),left[0],left[1],getAttrValue,sendBean,it_BOM,i_ITEM,BZFSrevisions.get(0)); + } + else if("Form".equals(right[1])) { + getAttrValue = getFormValue(getForm(children.getItemRevision()), right[2]); + System.out.println("获取的值"+right[2]+":"+getAttrValue); + setvalue(getForm(children.getItemRevision()),left[0],left[1],getAttrValue,sendBean,it_BOM,i_ITEM,BZFSrevisions.get(0)); + } + else if("Table".equals(right[1]) && falg) { + TCComponent[] table = getTable(children.getItemRevision()); + System.out.println("获取的值"+right[2]+":"+table); + for(TCComponent compTable : table) { + getAttrValue = compTable.getStringProperty(right[2]); + //特殊处理it_werks + IT_WERKS it_WERKS = new IT_WERKS(); + it_WERKS.setWERKS(getAttrValue); + iT_WERKS.add(it_WERKS); + //setvalue(compTable,left[0],left[1],getAttrValue,sendBean,it_WERKS,it_BOM,i_ITEM,BZFSrevisions.get(0)); + } + falg = false; + } + else if("BomLine".equals(right[1])) { + getAttrValue = getBomLineValue(children, right[2]); + System.out.println("获取的值"+right[2]+":"+getAttrValue); + setvalue(children,left[0],left[1],getAttrValue,sendBean,it_BOM,i_ITEM,BZFSrevisions.get(0)); + } + } + }else { + //直接赋值给bean + setvalue(children,left[0],left[1],right[0],sendBean,it_BOM,i_ITEM,BZFSrevisions.get(0)); + } + } + i_ITEMs.add(i_ITEM); + + + } + it_BOM.setI_ITEM(i_ITEMs); + //iT_WERKS.add(it_WERKS); + iT_BOMs.add(it_BOM); + } + sendBean.setIT_WERKS(iT_WERKS); + sendBean.setIT_BOM(iT_BOMs); + sendBeans.add(sendBean); + } + + return sendBeans; + } + + + + public static void setvalue(TCComponent comp,String title,String value,String name,SendBean sendBean,IT_BOM it_BOM,I_ITEM i_ITEM,ArrayList BZFSRevision) throws TCException { + if("SendBean".equals(title)) { + reflexSendBean(comp,value, name, sendBean); + }else if("IT_WERKS".equals(title)) { + //reflexIT_WERKS(comp,value, name, it_WERKS); + }else if("IT_BOM".equals(title)) { + reflexIT_BOM(comp,value, name, it_BOM); + }else if("I_ITEM".equals(title)) { + reflexI_ITEM(comp,value, name, i_ITEM,BZFSRevision); + } + } + + //获取表格数据 + public static TableModel buildTableModel(List> rowsList,Vector columnNames) throws SQLException { + Vector> data = new Vector>(); + for (List colum :rowsList) { + int columnCount = colum.size(); + Vector row = new Vector(); + for (int columnIndex = 1; columnIndex <= columnCount; columnIndex++) { + row.add(colum.get(columnIndex-1)); + } + data.add(row); + } + return new DefaultTableModel(data, columnNames); + } + + //获取Item上的属性 + public static String getItemValue(TCComponentItem item,String key) throws TCException { + return item.getStringProperty(key) == null ? "" : item.getStringProperty(key); + } + //获取ItemRevision上的属性 + public static String getItemRevisionValue(TCComponentItemRevision itemRevision,String key) throws TCException { + return itemRevision.getStringProperty(key) == null ? "" : itemRevision.getStringProperty(key); + } + //获取表单上的属性 + public static String getFormValue(TCComponentForm form,String key) throws TCException { + return form.getStringProperty(key) == null ? "" : form.getStringProperty(key); + } + //获取表格上的属性 + public static String getTableValue(TCComponentItem table,String key) throws TCException { + return table.getStringProperty(key) == null ? "" : table.getStringProperty(key); + } + //获取bomLine上的属性 + public static String getBomLineValue(TCComponentBOMLine bomLine,String key) throws TCException { + return bomLine.getStringProperty(key) == null ? "" : bomLine.getStringProperty(key); + } + //获取首选项的值 + public String[] getSYX(String name) { + String[] value = session.getPreferenceService().getStringValues(name); + return value; + } + //获取数据库连接 + public static Connection getConn(){ + Connection conn = null; + try { + conn = DbPool.getConnection(dateConnList.get(0),dateConnList.get(1)); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return conn; + } + //递归BOM结构 + public void collectAllBomLine(TCComponentBOMLine bomline1, ArrayList fathers,ArrayList> groupRecision, + ArrayList>> childrens,Boolean selectFlagIsGZ,ArrayList QBJNameList) + throws TCException { + if (bomline1.hasChildren()) { + //构建单父 多组 多子结构 + ArrayList groups = new ArrayList(); + ArrayList> childs = new ArrayList>(); + ArrayList child = new ArrayList(); + //同层级可选bom序号 + ArrayList bomNoList = new ArrayList(); + ArrayList ch = new ArrayList(); + //同层级包装方案 + ArrayList BZFARevision = new ArrayList(); + AIFComponentContext[] children = bomline1.getChildren(); + + //单层下的相同编号的子件合并数量,不同层级部件下的相同编号子件不合并数量 + Set BomLineLists = new HashSet(); + //记录name,查看是否存在 + Map BOMLineMap = new HashMap(); + for(int i=0;i dateMap = new HashMap<>(); + dateMap.put("LD6_partQuan",String.valueOf(num2)); + changDateByLineMap.put(line,dateMap); + continue; + } + BOMLineMap.put(getItemRevisionValue(bomLine.getItemRevision(),"object_string"),bomLine); + BomLineLists.add(bomLine); + } + int falgnum = 0; + for(TCComponentBOMLine bomLine : BomLineLists){ + if(selectFlagIsGZ){ + if(falgIsOne && QBJNameList.contains(getItemRevisionValue(bomLine.getItemRevision(),"object_string"))){ + falgnum++; + continue; + } + if(falgIsOne && !"LD6_EquipCompRevision".equals(getItemRevisionValue(bomLine.getItemRevision(),"object_type"))){ + System.out.println(getItemRevisionValue(bomLine.getItemRevision(), "object_string")+"选择对象为工装,但是子件类型不是企标件"); + falgnum++; + continue; + } + } + String type = getItemValue(bomLine.getItem(), "object_type"); + if("LD6_PackPlan".equals(type)) { + BZFARevision.add(bomLine); + } + String no = getBomLineValue(bomLine, "LD6_KXBomNo"); + if(no!=null && !"".equals(no)) { + groups.add(bomLine); + System.out.println("获取的可选序号:"+no); + Integer valueOf = Integer.valueOf(no); + if(bomNoList!=null && bomNoList.contains(valueOf)) { + MessageBox.post(getItemRevisionValue(bomline1.getItemRevision(), "item_id")+"物料下存在相同可选BOM编号的子行,请修正后重新执行传递", "提示", MessageBox.INFORMATION); + return; + } + bomNoList.add(valueOf); + ch.add(bomLine); + }else{ + child.add(bomLine); + } + } + //添加子物料 + if(ch.size()>0){ + //筛选发送bom组合 + for(TCComponentBOMLine getline : ch){ + ArrayList childss = new ArrayList(); + childss.addAll(child); + childss.add(getline); + childs.add(childss); + } + + }else{ + childs.add(child); + } + //父物料下有多个包装方案(LD6_PackPlan)时,检查BOMLine属性 + if(BZFARevision.size()>0) { + ArrayList BZFAFlag = new ArrayList(); + int bzflag = 0; + for(TCComponentBOMLine line : BZFARevision) { + String bomLineValue = getBomLineValue(line, "LD6_PrefPack"); + if(bomLineValue==null || "".equals(bomLineValue) ) { + BZFAFlag.add(line); + } + if("是".equals(bomLineValue) ) { + bzflag++; + } + } + if(BZFARevision.size()>1 && BZFAFlag.size() == BZFARevision.size() || bzflag>1) { + MessageBox.post("请选择唯一的优选包装方案BOM", "提示", MessageBox.INFORMATION); + return; + } + } + //开始赋值 + if(falgnum != BomLineLists.size()){ + fathers.add(bomline1); + groupRecision.add(groups); + childrens.add(childs); + BZFSrevisions.add(BZFARevision); + } + falgIsOne = false; + for (TCComponentBOMLine bomLine : BomLineLists) { + if(selectFlagIsGZ) { + if (!"LD6_EquipCompRevision".equals(getItemRevisionValue(bomLine.getItemRevision(), "object_type"))) { + System.out.println(getItemRevisionValue(bomLine.getItemRevision(), "object_string")+"子件不为企标件"); + continue; + } + } + collectAllBomLine(bomLine,fathers,groupRecision,childrens,selectFlagIsGZ,QBJNameList); + } + } + } + + //递归BOM结构 + public void collectAllBomLine2(VirtuallyBom bomline1, ArrayList fathers,ArrayList> groupRecision,ArrayList>> childrens,Boolean selectFlagIsGZ) throws TCException { + if (bomline1.hasChildren()) { + //构建单父 多组 多子结构 + ArrayList groups = new ArrayList(); + ArrayList> childs = new ArrayList>(); + ArrayList child = new ArrayList(); + //同层级可选bom序号 + ArrayList bomNoList = new ArrayList(); + ArrayList ch = new ArrayList(); + //同层级包装方案 + ArrayList BZFARevision = new ArrayList(); + Listchildren = bomline1.getChildren(); + + //单层下的相同编号的子件合并数量,不同层级部件下的相同编号子件不合并数量 + Set BomLineLists = new HashSet(); + //记录name,查看是否存在 + Map BOMLineMap = new HashMap(); + //记录bom层级,查看是否是同级BOM + Map BOMLineNumMap = new HashMap(); + for(int i=0;i dateMap = new HashMap<>(); + dateMap.put("LD6_partQuan",String.valueOf(num2)); + changDateByLineMap.put(line,dateMap); + continue; + } + BOMLineMap.put(getItemRevisionValue(bomLine.getItemRevision(),"object_string"),bomLine); + BOMLineNumMap.put(bomLine,deppn); + BomLineLists.add(bomLine); + } + for(TCComponentBOMLine bomLine : BomLineLists){ + String type = getItemValue(bomLine.getItem(), "object_type"); + if("LD6_PackPlan".equals(type)) { + BZFARevision.add(bomLine); + } + String no = getBomLineValue(bomLine, "LD6_KXBomNo"); + if(no!=null && !"".equals(no)) { + groups.add(bomLine); + System.out.println("获取的可选序号:"+no); + Integer valueOf = Integer.valueOf(no); + if(bomNoList!=null && bomNoList.contains(valueOf)) { + MessageBox.post(getItemRevisionValue(bomline1.getItemRevision(), "item_id")+"物料下存在相同可选BOM编号的子行,请修正后重新执行传递", "提示", MessageBox.INFORMATION); + return; + } + bomNoList.add(valueOf); + ch.add(bomLine); + }else{ + child.add(bomLine); + } + } + //添加子物料 + if(ch.size()>0){ + //筛选发送bom组合 + for(TCComponentBOMLine getline : ch){ + ArrayList childss = new ArrayList(); + childss.addAll(child); + childss.add(getline); + childs.add(childss); + } + + }else{ + childs.add(child); + } + //父物料下有多个包装方案(LD6_PackPlan)时,检查BOMLine属性 + if(BZFARevision.size()>0) { + ArrayList BZFAFlag = new ArrayList(); + int bzflag = 0; + for(TCComponentBOMLine line : BZFARevision) { + String bomLineValue = getBomLineValue(line, "LD6_PrefPack"); + if(bomLineValue==null || "".equals(bomLineValue) ) { + BZFAFlag.add(line); + } + if("是".equals(bomLineValue) ) { + bzflag++; + } + } + if(BZFARevision.size()>1 && BZFAFlag.size() == BZFARevision.size() || bzflag>1) { + MessageBox.post("请选择唯一的优选包装方案BOM", "提示", MessageBox.INFORMATION); + return; + } + } + //开始赋值 + fathers.add(bomline1.getTopline()); + groupRecision.add(groups); + childrens.add(childs); + BZFSrevisions.add(BZFARevision); + /*for (TCComponentBOMLine bomLine : BomLineLists) { + if("LD6_EquipCompRevision".equals(getItemRevisionValue(bomLine.getItemRevision(), "object_type"))){ + continue; + } + if(selectFlagIsGZ) { + if (!childTypesFlag.contains(getItemRevisionValue(bomLine.getItemRevision(), "object_type"))) { + System.out.println(getItemRevisionValue(bomLine.getItemRevision(), "object_string")+"不在首选项配置中"); + continue; + } + } + AIFComponentContext[] children1 = bomLine.getChildren(); + List childLines = new ArrayList(); + for(AIFComponentContext aifComponentContext : children1){ + TCComponent component = (TCComponent)aifComponentContext.getComponent(); + if (component instanceof TCComponentBOMLine){ + childLines.add((TCComponentBOMLine) component); + } + } + VirtuallyBom virtuallyBom = new VirtuallyBom(bomLine,childLines); + collectAllBomLine2(virtuallyBom,fathers,groupRecision,childrens,null,false); + }*/ + } + } + + //将获取到的属性通过反射赋值 + public static void reflexSendBean(TCComponent comp,String propertyName,String propertyValue,SendBean sendBean) { + try { + Field field = SendBean.class.getDeclaredField(propertyName); + if(field!=null) { + field.setAccessible(true); + field.set(sendBean, propertyValue); + System.out.println("属性"+propertyName+"值已成功赋给sendBean对象"); + }else { + MessageBox.post("属性值"+propertyName+"与发送请求的对象无法映射,请联系管理员", "提示", MessageBox.INFORMATION); + return; + } + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + } + public static void reflexIT_WERKS(TCComponent comp,String propertyName,String propertyValue,IT_WERKS it_WERKS) { + try { + Field field = IT_WERKS.class.getDeclaredField(propertyName); + if(field!=null) { + field.setAccessible(true); + field.set(it_WERKS, propertyValue); + System.out.println("属性"+propertyName+"值已成功赋给IT_WERKS对象"); + }else { + MessageBox.post("属性值"+propertyName+"与发送请求的对象无法映射,请联系管理员", "提示", MessageBox.INFORMATION); + return; + } + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + } + public static void reflexIT_BOM(TCComponent comp,String propertyName,String propertyValue,IT_BOM it_BOM) throws TCException { + try { + Field field = IT_BOM.class.getDeclaredField(propertyName); + if(field!=null) { + //特殊处理STLAL + if("STLAL".equals(propertyName)) { + if(propertyValue==null || "".equals(propertyValue)) { + propertyValue = "1"; + } + } + //特殊处理ZJTZBC + if("ZJTZBC".equals(propertyName)){ + /** + * 如果类型是成品/机加半成品,则获取此物料在影响分析中引用关系的二维设计版本, + * 如存在相同编号不同版本的二维设计版本,检查是否都为发布,如未发布,则禁止传递, + * 否则取最新版本上的图纸版次(ld6_)属性; + * 如果类型是铸件,则获取此铸件版本上的铸模版次 + */ + if("LD6_ProductRevision".equals(getItemRevisionValue((TCComponentItemRevision)comp,"object_type")) + || "LD6_MachinesPRevision".equals(getItemRevisionValue((TCComponentItemRevision)comp,"object_type"))){ + AIFComponentContext[] aifComponentContexts = ((TCComponentItemRevision)comp).whereReferenced(); + ArrayList conLists = new ArrayList(); + ArrayList conRevLists = new ArrayList(); + for(AIFComponentContext aifComponentContext : aifComponentContexts){ + InterfaceAIFComponent component = aifComponentContext.getComponent(); + if(component instanceof TCComponentItemRevision){ + if("LD6_2DdesignRevision".equals(getItemRevisionValue((TCComponentItemRevision)component,"object_type"))){ + conLists.add(((TCComponentItemRevision) component).getItem()); + conRevLists.add(((TCComponentItemRevision) component)); + } + } + } + //给conLists去重 + HashSet set = new HashSet<>(); + for (TCComponentItem i : conLists) { + set.add(i); + } + conLists.clear(); + conLists.addAll(set); + if(conLists.size()>1){ + //提示 + MessageBox.post("成品/机加半成品引用二维图纸不唯一,请确认后传递", "提示", MessageBox.INFORMATION); + return; + }else if(conLists.size()==1){ + int count = 0; + for(TCComponentItemRevision revision:conRevLists){ + Date status1 = revision.getDateProperty("date_released"); + if(status1 == null) { + count++; + } + } + if(count == conRevLists.size()) { + propertyValue = ""; + }else { + //选择引用的最新版本 + TCComponent[] revision_lists = conLists.get(0).getReferenceListProperty("revision_list"); + for(int i=revision_lists.length-1;i>=0;i--){ + Date status1 = revision_lists[i].getDateProperty("date_released"); + if(conRevLists.contains((TCComponentItemRevision)revision_lists[i]) && status1!=null){ + propertyValue = getItemRevisionValue((TCComponentItemRevision)revision_lists[i],"ld6_DrawingVer"); + break; + } + } + } + + } + }else if("LD6_CastingPRevision".equals(getItemRevisionValue((TCComponentItemRevision)comp,"object_type"))){ + propertyValue = getItemRevisionValue((TCComponentItemRevision)comp,"ld6_castingMoldVer"); + } + } + field.setAccessible(true); + field.set(it_BOM, propertyValue); + System.out.println("属性"+propertyName+"值已成功赋给IT_BOM对象"); + }else { + MessageBox.post("属性值"+propertyName+"与发送请求的对象无法映射,请联系管理员", "提示", MessageBox.INFORMATION); + return; + } + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + } + public static void reflexI_ITEM(TCComponent comp,String propertyName,String propertyValue,I_ITEM i_ITEM,ArrayList BZFSRevision) throws TCException { + try { + Field field = I_ITEM.class.getDeclaredField(propertyName); + if(field!=null) { + if("ZSFKX".equals(propertyName)) { + //特殊处理ZSFKX + String ld6_kxBomNo = getBomLineValue((TCComponentBOMLine) comp, "LD6_KXBomNo"); + if(ld6_kxBomNo!=null && !"".equals(ld6_kxBomNo)) { + propertyValue = "Y"; + }else { + propertyValue = ""; + } + } + if("ZBXBS".equals(propertyName)) { + //特殊处理ZBXBS + String object_type = getItemValue(((TCComponentBOMLine)comp).getItem(),"object_type"); + if(BZFSRevision.size()==1 || !"LD6_PackPlan".equals(object_type)) { + propertyValue = ""; + }else { + String ld6_prefPack = getBomLineValue((TCComponentBOMLine) comp, "LD6_PrefPack"); + if("是".equals(ld6_prefPack)) { + propertyValue = ""; + }else { + propertyValue = "Y"; + } + } + } + //特殊处理ZJTZBC_S + if("ZJTZBC_S".equals(propertyName)){ + /** + * 如果类型是成品/机加半成品,则获取此物料在影响分析中引用关系的二维设计版本, + * 如存在相同编号不同版本的二维设计版本,检查是否都为发布,如未发布,则禁止传递, + * 否则取最新版本上的图纸版次(ld6_)属性; + * 如果类型是铸件,则获取此铸件版本上的铸模版次 + */ + if("LD6_ProductRevision".equals(getItemRevisionValue((TCComponentItemRevision)comp,"object_type")) + || "LD6_MachinesPRevision".equals(getItemRevisionValue((TCComponentItemRevision)comp,"object_type"))){ + System.out.println("获取到了成品几家半成品类型"); + AIFComponentContext[] aifComponentContexts = ((TCComponentItemRevision)comp).whereReferenced(); + ArrayList conLists = new ArrayList(); + ArrayList conRevLists = new ArrayList(); + for(AIFComponentContext aifComponentContext : aifComponentContexts){ + InterfaceAIFComponent component = aifComponentContext.getComponent(); + if(component instanceof TCComponentItemRevision){ + if("LD6_2DdesignRevision".equals(getItemRevisionValue((TCComponentItemRevision)component,"object_type"))){ + conLists.add(((TCComponentItemRevision) component).getItem()); + conRevLists.add(((TCComponentItemRevision) component)); + } + } + } + //给conLists去重 + HashSet set = new HashSet<>(); + for (TCComponentItem i : conLists) { + set.add(i); + } + conLists.clear(); + conLists.addAll(set); + if(conLists.size()>1){ + //提示 + MessageBox.post("成品/机加半成品引用二维图纸不唯一,请确认后传递", "提示", MessageBox.INFORMATION); + return; + }else if(conLists.size()==1){ + int count = 0; + for(TCComponentItemRevision revision:conRevLists){ + Date status1 = revision.getDateProperty("date_released"); + if(status1 == null) { + count++; + } + } + if(count == conRevLists.size()) { + propertyValue = ""; + }else { + //选择引用的最新版本 + TCComponent[] revision_lists = conLists.get(0).getReferenceListProperty("revision_list"); + for(int i=revision_lists.length-1;i>=0;i--){ + Date status1 = revision_lists[i].getDateProperty("date_released"); + if(conRevLists.contains((TCComponentItemRevision)revision_lists[i]) && status1!=null){ + propertyValue = getItemRevisionValue((TCComponentItemRevision)revision_lists[i],"ld6_DrawingVer"); + break; + } + } + } + } + }else if("LD6_CastingPRevision".equals(getItemRevisionValue((TCComponentItemRevision)comp,"object_type"))){ + System.out.println("获取到了铸件版本"); + propertyValue = getItemRevisionValue((TCComponentItemRevision)comp,"ld6_castingMoldVer"); + } + } + field.setAccessible(true); + field.set(i_ITEM, propertyValue); + System.out.println("属性"+propertyName+"值已成功赋给I_ITEM对象"); + }else { + MessageBox.post("属性值"+propertyName+"与发送请求的对象无法映射,请联系管理员", "提示", MessageBox.INFORMATION); + return; + } + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + } + //获取表格 + public static TCComponent[] getTable(TCComponentItemRevision itemRevision) { + TCComponent[] referenceListProperty = null; + try { + referenceListProperty = itemRevision.getReferenceListProperty("LD6_CompanyFormRelation"); + for(TCComponent comp:referenceListProperty) { + System.out.println("匹配表单类型:"+comp.getStringProperty("object_type")); + if("LD6_CompanyForm".equals(comp.getStringProperty("object_type"))) { + TCComponent[] referenceListProperty2 = comp.getReferenceListProperty("ld6_CompanyTable"); + System.out.println("获取到的表单数组:"+referenceListProperty2); + return referenceListProperty2; + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + + //获取表单 + public static TCComponentForm getForm(TCComponentItemRevision itemRevision) { + TCComponent[] referenceListProperty = null; + try { + referenceListProperty = itemRevision.getReferenceListProperty("IMAN_master_form_rev"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (referenceListProperty != null) { + TCComponentForm form = (TCComponentForm) referenceListProperty[0]; + return form; + } + return null; + } + //发送请求 + private static String sendPostRequest(String url, String json) { + try { + URL apiUrl = new URL(url); + HttpURLConnection connection = (HttpURLConnection) apiUrl.openConnection(); + connection.setRequestMethod("POST"); + connection.setRequestProperty("Content-Type", "application/json"); + connection.setDoOutput(true); + OutputStream outputStream = connection.getOutputStream(); + outputStream.write(json.getBytes("UTF-8")); + outputStream.flush(); + int statusCode = connection.getResponseCode(); + if (statusCode == 200) { + try (InputStream inputStream = connection.getInputStream(); + InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF-8"); + BufferedReader reader = new BufferedReader(inputStreamReader)) { + StringBuilder response = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + System.out.println(line.toString()); + response.append(line); + } + return response.toString(); + } + } else { + return null; + } + } catch (Exception ex) { + ex.printStackTrace(); + return null; + } + } +} diff --git a/src/com/connor/ld/sendBOMMesJc/SendObj.java b/src/com/connor/ld/sendBOMMesJc/SendObj.java new file mode 100644 index 0000000..97d185e --- /dev/null +++ b/src/com/connor/ld/sendBOMMesJc/SendObj.java @@ -0,0 +1,41 @@ +package com.connor.ld.sendBOMMesJc; + +import java.util.ArrayList; + +import com.teamcenter.rac.common.propertyicon.binding.Item; +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.pse.commands.RevEffectivityCommand; + +public class SendObj { + private TCComponentItemRevision fatheRevision; + + private ArrayList childrenRecision; + + public SendObj(TCComponentItemRevision fatheRevision, ArrayList childrenRecision) { + super(); + this.fatheRevision = fatheRevision; + this.childrenRecision = childrenRecision; + } + + public TCComponentItemRevision getFatheRevision() { + return fatheRevision; + } + + public void setFatheRevision(TCComponentItemRevision fatheRevision) { + this.fatheRevision = fatheRevision; + } + + public ArrayList getChildrenRecision() { + return childrenRecision; + } + + public void setChildrenRecision(ArrayList childrenRecision) { + this.childrenRecision = childrenRecision; + } + + +} diff --git a/src/com/connor/ld/sendBOMMesJc/UpperCaseSerializer.java b/src/com/connor/ld/sendBOMMesJc/UpperCaseSerializer.java new file mode 100644 index 0000000..04da864 --- /dev/null +++ b/src/com/connor/ld/sendBOMMesJc/UpperCaseSerializer.java @@ -0,0 +1,31 @@ +package com.connor.ld.sendBOMMesJc; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.module.SimpleModule; + +public class UpperCaseSerializer extends SimpleModule { + + /** + * 自定义序列化,大写JSON属性值 + */ + private static final long serialVersionUID = 1L; + + public void setupBeforeObjectSerializing() throws Exception { + addSerializer(Object.class, new UpperCaseSerializer.UpperSerializer()); + } + + private static class UpperSerializer extends JsonSerializer { + @Override + public void serialize(Object value, JsonGenerator gen, SerializerProvider serializers) throws IOException { + gen.writeString(value.toString().toUpperCase()); + } + + } +} diff --git a/src/com/connor/ld/sendBOMMesJc/accPojo/AccBean.java b/src/com/connor/ld/sendBOMMesJc/accPojo/AccBean.java new file mode 100644 index 0000000..bfc34c4 --- /dev/null +++ b/src/com/connor/ld/sendBOMMesJc/accPojo/AccBean.java @@ -0,0 +1,47 @@ +/** + * Copyright 2023 bejson.com + */ +package com.connor.ld.sendBOMMesJc.accPojo; +import java.util.List; + +/** + * Auto-generated: 2023-07-21 9:40:9 + * + * @author bejson.com (i@bejson.com) + * @website http://www.bejson.com/java2pojo/ + */ +public class AccBean { + + private String MATNR; + private String CODE; + private String MSG; + private List OT_WERKS; + public void setMATNR(String MATNR) { + this.MATNR = MATNR; + } + public String getMATNR() { + return MATNR; + } + + public void setCODE(String CODE) { + this.CODE = CODE; + } + public String getCODE() { + return CODE; + } + + public void setMSG(String MSG) { + this.MSG = MSG; + } + public String getMSG() { + return MSG; + } + + public void setOT_WERKS(List OT_WERKS) { + this.OT_WERKS = OT_WERKS; + } + public List getOT_WERKS() { + return OT_WERKS; + } + +} \ No newline at end of file diff --git a/src/com/connor/ld/sendBOMMesJc/accPojo/OT_BOM.java b/src/com/connor/ld/sendBOMMesJc/accPojo/OT_BOM.java new file mode 100644 index 0000000..1288b5b --- /dev/null +++ b/src/com/connor/ld/sendBOMMesJc/accPojo/OT_BOM.java @@ -0,0 +1,45 @@ +/** + * Copyright 2023 bejson.com + */ +package com.connor.ld.sendBOMMesJc.accPojo; +/** + * Auto-generated: 2023-07-21 9:40:9 + * + * @author bejson.com (i@bejson.com) + * @website http://www.bejson.com/java2pojo/ + */ +public class OT_BOM { + + private String MATNR; + private String ZMATNR; + private String CODE; + private String MSG; + public void setMATNR(String MATNR) { + this.MATNR = MATNR; + } + public String getMATNR() { + return MATNR; + } + + public void setZMATNR(String ZMATNR) { + this.ZMATNR = ZMATNR; + } + public String getZMATNR() { + return ZMATNR; + } + + public void setCODE(String CODE) { + this.CODE = CODE; + } + public String getCODE() { + return CODE; + } + + public void setMSG(String MSG) { + this.MSG = MSG; + } + public String getMSG() { + return MSG; + } + +} \ No newline at end of file diff --git a/src/com/connor/ld/sendBOMMesJc/accPojo/OT_WERKS.java b/src/com/connor/ld/sendBOMMesJc/accPojo/OT_WERKS.java new file mode 100644 index 0000000..c877a0c --- /dev/null +++ b/src/com/connor/ld/sendBOMMesJc/accPojo/OT_WERKS.java @@ -0,0 +1,47 @@ +/** + * Copyright 2023 bejson.com + */ +package com.connor.ld.sendBOMMesJc.accPojo; +import java.util.List; + +/** + * Auto-generated: 2023-07-21 9:40:9 + * + * @author bejson.com (i@bejson.com) + * @website http://www.bejson.com/java2pojo/ + */ +public class OT_WERKS { + + private String WERKS; + private String CODE; + private String MSG; + private List OT_BOM; + public void setWERKS(String WERKS) { + this.WERKS = WERKS; + } + public String getWERKS() { + return WERKS; + } + + public void setCODE(String CODE) { + this.CODE = CODE; + } + public String getCODE() { + return CODE; + } + + public void setMSG(String MSG) { + this.MSG = MSG; + } + public String getMSG() { + return MSG; + } + + public void setOT_BOM(List OT_BOM) { + this.OT_BOM = OT_BOM; + } + public List getOT_BOM() { + return OT_BOM; + } + +} \ No newline at end of file diff --git a/src/com/connor/ld/sendBOMMesJc/sendPojo/IT_BOM.java b/src/com/connor/ld/sendBOMMesJc/sendPojo/IT_BOM.java new file mode 100644 index 0000000..175dc72 --- /dev/null +++ b/src/com/connor/ld/sendBOMMesJc/sendPojo/IT_BOM.java @@ -0,0 +1,168 @@ +/** + * Copyright 2023 bejson.com + */ +package com.connor.ld.sendBOMMesJc.sendPojo; +import java.util.ArrayList; +import java.util.List; + +import com.alibaba.fastjson2.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.gson.annotations.SerializedName; + +/** + * Auto-generated: 2023-07-21 9:46:45 + * + * @author bejson.com (i@bejson.com) + * @website http://www.bejson.com/java2pojo/ + */ +public class IT_BOM { + + @SerializedName("MATNR") + private String MATNR = ""; + + @SerializedName("STLAN") + private String STLAN = ""; + + @SerializedName("ZTEXT") + private String ZTEXT = ""; + + @SerializedName("STLAL") + private String STLAL = ""; + + @SerializedName("ZVERSION") + private String ZVERSION = ""; + + @SerializedName("MATEREV") + private String MATEREV = ""; + + @SerializedName("ZJTZBC") + private String ZJTZBC = ""; + + @SerializedName("BMENG") + private String BMENG = ""; + + @SerializedName("ALPGR") + private String ALPGR = ""; + + @SerializedName("ALPRF") + private String ALPRF = ""; + + @SerializedName("ALPST") + private String ALPST = ""; + + @SerializedName("EWAHR") + private String EWAHR = ""; + + @SerializedName("I_ITEM") + private List I_ITEM = new ArrayList(); + public void setMATNR(String MATNR) { + this.MATNR = MATNR; + } + public String getMATNR() { + return MATNR; + } + + public void setSTLAN(String STLAN) { + this.STLAN = STLAN; + } + public String getSTLAN() { + return STLAN; + } + + public void setZTEXT(String ZTEXT) { + this.ZTEXT = ZTEXT; + } + public String getZTEXT() { + return ZTEXT; + } + + public void setSTLAL(String STLAL) { + this.STLAL = STLAL; + } + public String getSTLAL() { + return STLAL; + } + + public void setZVERSION(String ZVERSION) { + this.ZVERSION = ZVERSION; + } + public String getZVERSION() { + return ZVERSION; + } + + public void setMATEREV(String MATEREV) { + this.MATEREV = MATEREV; + } + public String getMATEREV() { + return MATEREV; + } + + public String getZJTZBC() { + return ZJTZBC; + } + + public void setZJTZBC(String ZJTZBC) { + this.ZJTZBC = ZJTZBC; + } + + public void setBMENG(String BMENG) { + this.BMENG = BMENG; + } + public String getBMENG() { + return BMENG; + } + + public void setALPGR(String ALPGR) { + this.ALPGR = ALPGR; + } + public String getALPGR() { + return ALPGR; + } + + public void setALPRF(String ALPRF) { + this.ALPRF = ALPRF; + } + public String getALPRF() { + return ALPRF; + } + + public void setALPST(String ALPST) { + this.ALPST = ALPST; + } + public String getALPST() { + return ALPST; + } + + public void setEWAHR(String EWAHR) { + this.EWAHR = EWAHR; + } + public String getEWAHR() { + return EWAHR; + } + + public void setI_ITEM(List I_ITEM) { + this.I_ITEM = I_ITEM; + } + public List getI_ITEM() { + return I_ITEM; + } + + @Override + public String toString() { + return "IT_BOM{" + + "MATNR='" + MATNR + '\'' + + ", STLAN='" + STLAN + '\'' + + ", ZTEXT='" + ZTEXT + '\'' + + ", STLAL='" + STLAL + '\'' + + ", ZVERSION='" + ZVERSION + '\'' + + ", MATEREV='" + MATEREV + '\'' + + ", ZJTZBC='" + ZJTZBC + '\'' + + ", BMENG='" + BMENG + '\'' + + ", ALPGR='" + ALPGR + '\'' + + ", ALPRF='" + ALPRF + '\'' + + ", ALPST='" + ALPST + '\'' + + ", EWAHR='" + EWAHR + '\'' + + ", I_ITEM=" + I_ITEM + + '}'; + } +} \ No newline at end of file diff --git a/src/com/connor/ld/sendBOMMesJc/sendPojo/IT_WERKS.java b/src/com/connor/ld/sendBOMMesJc/sendPojo/IT_WERKS.java new file mode 100644 index 0000000..ee32007 --- /dev/null +++ b/src/com/connor/ld/sendBOMMesJc/sendPojo/IT_WERKS.java @@ -0,0 +1,32 @@ +/** + * Copyright 2023 bejson.com + */ +package com.connor.ld.sendBOMMesJc.sendPojo; + +import com.alibaba.fastjson2.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.gson.annotations.SerializedName; + +/** + * Auto-generated: 2023-07-21 9:46:45 + * + * @author bejson.com (i@bejson.com) + * @website http://www.bejson.com/java2pojo/ + */ +public class IT_WERKS { + + @SerializedName("WERKS") + private String WERKS = ""; + + public void setWERKS(String WERKS) { + this.WERKS = WERKS; + } + public String getWERKS() { + return WERKS; + } + @Override + public String toString() { + return "IT_WERKS [WERKS=" + WERKS + "]"; + } + +} \ No newline at end of file diff --git a/src/com/connor/ld/sendBOMMesJc/sendPojo/I_ITEM.java b/src/com/connor/ld/sendBOMMesJc/sendPojo/I_ITEM.java new file mode 100644 index 0000000..aa3ed67 --- /dev/null +++ b/src/com/connor/ld/sendBOMMesJc/sendPojo/I_ITEM.java @@ -0,0 +1,114 @@ +/** + * Copyright 2023 bejson.com + */ +package com.connor.ld.sendBOMMesJc.sendPojo; + +import com.alibaba.fastjson2.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.gson.annotations.SerializedName; + +/** + * Auto-generated: 2023-07-21 9:46:45 + * + * @author bejson.com (i@bejson.com) + * @website http://www.bejson.com/java2pojo/ + */ +public class I_ITEM { + + @SerializedName("POSTP") + private String POSTP = ""; + + @SerializedName("IDNRK") + private String IDNRK = ""; + + @SerializedName("MENGE") + private String MENGE = ""; + + @SerializedName("ZVERSION_S") + private String ZVERSION_S = ""; + + @SerializedName("MATEREV_S") + private String MATEREV_S = ""; + + @SerializedName("ZJTZBC_S") + private String ZJTZBC_S = ""; + + @SerializedName("ZBXBS") + private String ZBXBS = ""; + + @SerializedName("ZSFKX") + private String ZSFKX = ""; + + @SerializedName("SORTF") + private String SORTF = ""; + + public void setPOSTP(String POSTP) { + this.POSTP = POSTP; + } + public String getPOSTP() { + return POSTP; + } + + public void setIDNRK(String IDNRK) { + this.IDNRK = IDNRK; + } + public String getIDNRK() { + return IDNRK; + } + + public void setMENGE(String MENGE) { + this.MENGE = MENGE; + } + public String getMENGE() { + return MENGE; + } + + public void setZVERSION_S(String ZVERSION_S) { + this.ZVERSION_S = ZVERSION_S; + } + public String getZVERSION_S() { + return ZVERSION_S; + } + + public void setMATEREV_S(String MATEREV_S) { + this.MATEREV_S = MATEREV_S; + } + public String getMATEREV_S() { + return MATEREV_S; + } + + public String getZJTZBC_S() { + return ZJTZBC_S; + } + + public void setZJTZBC_S(String ZJTZBC_S) { + this.ZJTZBC_S = ZJTZBC_S; + } + + public void setZBXBS(String ZBXBS) { + this.ZBXBS = ZBXBS; + } + public String getZBXBS() { + return ZBXBS; + } + + public void setZSFKX(String ZSFKX) { + this.ZSFKX = ZSFKX; + } + public String getZSFKX() { + return ZSFKX; + } + + public void setSORTF(String SORTF) { + this.SORTF = SORTF; + } + public String getSORTF() { + return SORTF; + } + @Override + public String toString() { + return "I_ITEM [POSTP=" + POSTP + ", IDNRK=" + IDNRK + ", MENGE=" + MENGE + ", ZVERSION_S=" + ZVERSION_S + + ", MATEREV_S=" + MATEREV_S + ", ZBXBS=" + ZBXBS + ", ZSFKX=" + ZSFKX + ", SORTF=" + SORTF + "]"; + } + +} \ No newline at end of file diff --git a/src/com/connor/ld/sendBOMMesJc/sendPojo/SendBean.java b/src/com/connor/ld/sendBOMMesJc/sendPojo/SendBean.java new file mode 100644 index 0000000..6d73b86 --- /dev/null +++ b/src/com/connor/ld/sendBOMMesJc/sendPojo/SendBean.java @@ -0,0 +1,54 @@ +/** + * Copyright 2023 bejson.com + */ +package com.connor.ld.sendBOMMesJc.sendPojo; +import java.util.ArrayList; +import java.util.List; + +import com.alibaba.fastjson2.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.gson.annotations.SerializedName; + +/** + * Auto-generated: 2023-07-21 9:46:45 + * + * @author bejson.com (i@bejson.com) + * @website http://www.bejson.com/java2pojo/ + */ +public class SendBean { + + @SerializedName("MATNR") + private String MATNR = ""; + + @SerializedName("IT_WERKS") + private List IT_WERKS = new ArrayList(); + + @SerializedName("IT_BOM") + private List IT_BOM = new ArrayList(); + + public void setMATNR(String MATNR) { + this.MATNR = MATNR; + } + public String getMATNR() { + return MATNR; + } + + public void setIT_WERKS(List IT_WERKS) { + this.IT_WERKS = IT_WERKS; + } + public List getIT_WERKS() { + return IT_WERKS; + } + + public void setIT_BOM(List IT_BOM) { + this.IT_BOM = IT_BOM; + } + public List getIT_BOM() { + return IT_BOM; + } + @Override + public String toString() { + return "SendBean [MATNR=" + MATNR + ", IT_WERKS=" + IT_WERKS + ", IT_BOM=" + IT_BOM + "]"; + } + +} \ No newline at end of file diff --git a/src/com/connor/ld/sendBOMMesJc/sendPojo/VirtuallyBom.java b/src/com/connor/ld/sendBOMMesJc/sendPojo/VirtuallyBom.java new file mode 100644 index 0000000..976e1af --- /dev/null +++ b/src/com/connor/ld/sendBOMMesJc/sendPojo/VirtuallyBom.java @@ -0,0 +1,51 @@ +package com.connor.ld.sendBOMMesJc.sendPojo; + +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; + +import java.util.ArrayList; +import java.util.List; + +public class VirtuallyBom { + TCComponentBOMLine topline; + List childLines = new ArrayList(); + List bomLine = new ArrayList(); + public VirtuallyBom(TCComponentBOMLine topline, List childLines,List bomLine) { + this.topline = topline; + this.childLines = childLines; + this.bomLine = bomLine; + } + + public List getBomLine() { + return bomLine; + } + + public void setBomLine(List bomLine) { + this.bomLine = bomLine; + } + + public TCComponentBOMLine getTopline() { + return topline; + } + public boolean hasChildren(){ + return childLines.size()>0; + } + public List getChildren(){ + return childLines; + } + public TCComponentItemRevision getItemRevision() throws TCException { + return topline.getItemRevision(); + } + public void setTopline(TCComponentBOMLine topline) { + this.topline = topline; + } + + public List getChildLines() { + return childLines; + } + + public void setChildLines(List childLines) { + this.childLines = childLines; + } +} diff --git a/src/com/connor/ld/sendMesJc/DbPool.java b/src/com/connor/ld/sendMesJc/DbPool.java new file mode 100644 index 0000000..bc1b58f --- /dev/null +++ b/src/com/connor/ld/sendMesJc/DbPool.java @@ -0,0 +1,246 @@ +package com.connor.ld.sendMesJc; + +import java.io.InputStream; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; + +public class DbPool { + + public static Connection connection = null; + public static PreparedStatement ps = null; + public static ResultSet rs = null; + + private static DbPool instance = null; + + public static synchronized Connection getConnection(String url,String name) { + if (instance == null) { + instance = new DbPool(); + } + return instance._getConnection(url,name); + } + + private Connection _getConnection(String url,String name) { + try { + String sDBDriver = null; + String sConnection = null; + String sUser = null; + String sPassword = null; + Properties p = new Properties(); +// InputStream is = getClass().getResourceAsStream( +// "/sqlconn.properties"); +// p.load(is); + sDBDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; + sConnection = "jdbc:sqlserver://"+url+":1433; DatabaseName="+name;//p.getProperty("Connection", "2"); + sUser = "infodba";//p.getProperty("User", ""); + sPassword = "infodba";//p.getProperty("Password", ""); + + if (sDBDriver == null || sConnection == null || sUser == null + || sPassword == null) { + + System.out.println("请检查数据库首选项是否配置正确"); + + } + + Class.forName(sDBDriver); + connection = DriverManager.getConnection(sConnection, sUser, + sPassword); + return connection; + } catch (Exception se) { + System.out.println(se); + } + return null; + } + + public final static ResultSet read(String sql, Object[] argments) throws SQLException { + return DbPool.rs = DbPool.getPs(argments, sql).executeQuery(); + } + /** + * 得到Statement + */ + public final static PreparedStatement getPs(Object[] argments, String sql) throws SQLException { + return getPs(sql, argments); + } + /** + * 得到Statement + */ + public final static PreparedStatement getPs(String sql, Object[] argments) throws SQLException { + DbPool.ps = DbPool.connection.prepareStatement(sql); + if (argments != null) { + for (int i = 0; i < argments.length; i++) { + DbPool.ps.setObject(i + 1, argments[i]); + } + } + return DbPool.ps; + } + /** + * 查询 + */ + public final static ResultSet read(String sql) throws SQLException { + return read(sql, null); + } + public static void executeUpdateSql(String sql) throws SQLException { + Statement st = connection.createStatement(); + try { + connection.setAutoCommit(false); + //System.out.println("sql===" + sql); + int i = st.executeUpdate(sql); + } catch (SQLException e) { + System.out.println(e.getMessage()); + if (st != null) + st.close(); + connection.rollback(); + connection.close(); + } finally { + if (st != null) + st.close(); + // connection.close(); + } + + } + + public static void executeDeleteSql(String sql) throws SQLException { + Statement st = connection.createStatement(); + try { + connection.setAutoCommit(false); + //System.out.println("sql===" + sql); + st.executeUpdate(sql); + connection.commit(); + } catch (SQLException e) { + if (st != null) + st.close(); + connection.rollback(); + connection.close(); + } finally { + if (st != null) + st.close(); + connection.close(); + } + + } + /** + * 增加 + */ + public final static int write(String sql, Object[] argments) { + + return update(sql, argments); + } + /** + * 修改(增删改最终都要调用此方法,此处进行异常处理,关闭除Connection以为的对象) + */ + public final static int update(String sql, Object[] argments) { + int i = -1; + try { + i = DbPool.getPs(argments, sql).executeUpdate(); + DbPool.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(DbPool.rs, DbPool.ps); + } + return i; + } + public static ResultSet executeSelectSql(String sql) throws SQLException { + Statement st = connection.createStatement(); + try { + connection.setAutoCommit(false); + //System.out.println("sql===" + sql); + rs = st.executeQuery(sql); + // conn.commit(); + } catch (SQLException e) { + if (st != null) + st.close(); + connection.rollback(); + connection.close(); + } + return rs; + + } + + /** + * 释放资源 + */ + public final static void free(ResultSet resultSet) { + free(resultSet, null, null); + } + + /** + * 释放资源 + */ + public final static void free(Statement statement) { + free(null, statement, null); + } + + /** + * 释放资源 + */ + public final static void free(Connection connection) { + free(null, null, connection); + } + + /** + * 释放资源 + */ + public final static void free(ResultSet resultSet, Statement statement) { + free(resultSet, statement, null); + } + + /** + * 释放资源 + */ + public final static void free(Statement statement, Connection connection) { + free(null, statement, connection); + } + + /** + * 释放资源(不传参数默认部分) + */ + public final static void free() { + free(DbPool.rs, DbPool.ps); + } + + /** + * 释放资源(全部释放) + */ + public final static void freeAll() { + free(DbPool.rs, DbPool.ps, DbPool.connection); + } + + /** + * 释放资源(传满参数也要全部释放) + */ + public final static void free(ResultSet resultSet, Statement statement, + Connection connection) { + try { + if (resultSet != null) { + try { + resultSet.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + try { + if (statement != null) { + try { + statement.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + if (connection != null) { + try { + connection.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + } +} diff --git a/src/com/connor/ld/sendMesJc/SAPConn.java b/src/com/connor/ld/sendMesJc/SAPConn.java new file mode 100644 index 0000000..cf93927 --- /dev/null +++ b/src/com/connor/ld/sendMesJc/SAPConn.java @@ -0,0 +1,82 @@ + +package com.connor.ld.sendMesJc; + +import java.io.File; +import java.io.FileOutputStream; +import java.util.Properties; +import java.util.ResourceBundle; + +import com.sap.conn.jco.JCoDestination; +import com.sap.conn.jco.JCoDestinationManager; +import com.sap.conn.jco.JCoException; +import com.sap.conn.jco.ext.DestinationDataProvider; + +/** + * 与SAP连接配置 + * + * @author jay + */ +public class SAPConn { + private static final String ABAP_AS_POOLED = "ABAP_AS_WITH_POOL"; + private static ResourceBundle resourceBundle = ResourceBundle.getBundle("sapconnect"); + static { + Properties connectProperties = new Properties(); + connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, resourceBundle.getString("JCO_ASHOST_STR")); // 服务器10.200.1.192 + // JKS4PRD02.JINKA.CN + connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, resourceBundle.getString("JCO_SYSNR_STR")); // 系统编号 + // 10 + connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, resourceBundle.getString("JCO_CLIENT_STR")); // SAP集团 + connectProperties.setProperty(DestinationDataProvider.JCO_USER, resourceBundle.getString("JCO_USER_STR")); // SAP用户名 + connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, resourceBundle.getString("JCO_PASSWD_STR")); // 密码 + connectProperties.setProperty(DestinationDataProvider.JCO_LANG, "ZH"); // 登录语言 +// connectProperties.setProperty(DestinationDataProvider.JCO_SAPROUTER, "/H/124.160.67.42"); // +// connectProperties.setProperty(DestinationDataProvider.JCO_SAPROUTER, "H/124.160.67.42"); // +// connectProperties.setProperty(DestinationDataProvider.JCO_SAPROUTER, "10.10.22.39/H/124.160.67.42"); // +// connectProperties.setProperty(DestinationDataProvider.JCO_SAPROUTER, "124.160.67.42"); // + // connectProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY, + // "3"); //最大连接数 + // connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, "10"); + // //最大连接线程 + + createDataFile(ABAP_AS_POOLED, "jcoDestination", connectProperties); + } + + /** + * 创建SAP接口属性文件。 + * + * @param name ABAP管道名称 + * @param suffix 属性文件后缀 + * @param properties 属性文件内容 + */ + private static void createDataFile(String name, String suffix, Properties properties) { + File cfg = new File(name + "." + suffix); + if (cfg.exists()) { + cfg.deleteOnExit(); + } + try { + FileOutputStream fos = new FileOutputStream(cfg, false); + properties.store(fos, "for tests only !"); + fos.close(); + } catch (Exception e) { + // log.error("Create Data file fault, error msg: " + e.toString()); + throw new RuntimeException("Unable to create the destination file " + cfg.getName(), e); + } + } + + /** + * 获取SAP连接 + * + * @return SAP连接对象 + */ + public static JCoDestination connect() { + JCoDestination destination = null; + try { + destination = JCoDestinationManager.getDestination(ABAP_AS_POOLED); + } catch (JCoException e) { + e.printStackTrace(); + // log.error("Connect SAP fault, error msg: " + e.toString()); + } + return destination; + } + // private static Logger log = Logger.getLogger(SAPConn.class); // 初始化日志对象 +} \ No newline at end of file diff --git a/src/com/connor/ld/sendMesJc/SendGylxFram.java b/src/com/connor/ld/sendMesJc/SendGylxFram.java new file mode 100644 index 0000000..5b961bf --- /dev/null +++ b/src/com/connor/ld/sendMesJc/SendGylxFram.java @@ -0,0 +1,1036 @@ +package com.connor.ld.sendMesJc; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.table.DefaultTableModel; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.connor.ld.importsj.handlers.ImpBean; +import com.connor.ld.importsj.handlers.SoaUtils; +import com.sap.conn.jco.JCoDestination; +import com.sap.conn.jco.JCoException; +import com.sap.conn.jco.JCoFunction; +import com.sap.conn.jco.JCoParameterList; +import com.sap.conn.jco.JCoTable; +import com.teamcenter.rac.aif.AIFClipboard; +import com.teamcenter.rac.aif.AIFPortal; +import com.teamcenter.rac.aif.AIFTransferable; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.*; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class SendGylxFram extends JFrame implements ActionListener{ + + private TCSession session; + private JTable table; + private String[] header = new String[] {"工艺路线ID","工艺路线版本","传递SAP状态","传递MES状态"}; +// protected DefaultTableModel tm_part; + private Map beanMap = new HashMap(); + private String urlString; + private Boolean topFlag = false; + private TCComponent[] METargets; + private List mantrRev = new ArrayList(); //不存在的版本对象 + public SendGylxFram(TCSession session,InterfaceAIFComponent[] targetComponents) { + // TODO Auto-generated constructor stub + this.session = session; + String value = session.getPreferenceService().getStringValue("LD_PLM2MES_GYLX_Config"); + if(value==null) { + MessageBox.post("首选项LD_PLM2MES_GYLX_Config配置有误,请检查。","提示",2); + return; + } + urlString = value; + String[] value2 = session.getPreferenceService().getStringValues("LD_SendGYLX_Config"); + if(value2==null || value2.length==0) { + MessageBox.post("首选项LD_SendGYLX_Config配置有误,请检查。","提示",2); + return; + } + for(String val:value2) { + String[] split = val.split(":"); + String[] split2 = split[1].split(";"); //物料版本类型 + beanMap.put(split[0], split2); + } + try { + for(InterfaceAIFComponent targetComponent:targetComponents) { + String type = targetComponent.getType(); + if(!beanMap.containsKey(type)) { + if(targetComponent instanceof TCComponentItemRevision) { + String stringProperty = ((TCComponentItemRevision)targetComponent).getStringProperty("item_id"); + MessageBox.post("编号"+stringProperty+"的数据不能执行发送工艺路线到SAP/MES。","提示",2); + return; + } + }else if(targetComponent instanceof TCComponentItemRevision) { + TCComponent relatedComponent = ((TCComponentItemRevision)targetComponent).getRelatedComponent("IMAN_METarget"); + if(relatedComponent ==null) { + MessageBox.post("工艺路线版本下制造目标关系的物料为空,请关联后重新传递.","提示",2); + return; + } + + //检查工艺路线下一层工序BOM的工序版本上序列号属性ld6_plnfl是否为空 + METargets = ((TCComponentItemRevision)targetComponent).getReferenceListProperty("IMAN_METarget"); + + if(METargets!=null && METargets.length>0){ + for(int a=0;a valMap = new HashMap(); + TCComponentBOMLine newBOMLine = getNewBOMLine((TCComponentItemRevision)targetComponent); + AIFComponentContext[] children = newBOMLine.getChildren(); + for(AIFComponentContext child:children) { + TCComponentBOMLine component = (TCComponentBOMLine) child.getComponent(); + TCComponentItemRevision rev = component.getItemRevision(); + + String property = rev.getProperty("ld6_plnfl"); + System.out.println("property:"+property); + String ld6_LTXA1 = rev.getProperty("ld6_ltxa1"); + System.out.println("ld6_LTXA1:"+ld6_LTXA1); + System.out.println("判断是否为空"); + if( SoaUtils.isEmpty(property)) { + MessageBox.post("请维护工序上的序列属性后重新传递.","提示",2); + return; + } + System.out.println("判断是否已经包含"); + if(valMap.containsKey(property)) { + String string = valMap.get(property); + if(!string.equals(ld6_LTXA1) && !SoaUtils.isEmpty(ld6_LTXA1)) { + MessageBox.post("请确保工序上相同序列对应唯一的序列描述值后重新传递.","提示",2); + return; + } + }else { + valMap.put(property, ld6_LTXA1); + + } + } + for(String key:valMap.keySet()) { + String val = valMap.get(key); + if(SoaUtils.isEmpty(val)) { + MessageBox.post("请确保工序上相同序列对应唯一的序列描述值后重新传递.","提示",2); + return; + } + } + + newBOMLine.window().close(); + } + + mantrRev.add((TCComponentItemRevision)targetComponent); + } + } + initUI(); + addRows(); + }catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + } + + private void addRows() throws TCException { + // TODO Auto-generated method stub + for(TCComponentItemRevision rev:mantrRev) { + String item_id = rev.getStringProperty("item_id"); + String item_revision_id = rev.getStringProperty("item_revision_id"); + map.addRow(new String[] {item_id,item_revision_id,"",""}); + } +// table.repaint(); + } + // 获得BOMLine + public TCComponentBOMLine getNewBOMLine(TCComponentItemRevision itemR) { + TCComponentBOMWindowType bomWinType; + try { + bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow win = bomWinType.create(null); + win.lock(); + win.setWindowTopLine(itemR.getItem(), itemR, null, null); + + TCComponentBOMLine componentbomline = win.getTopBOMLine(); + return componentbomline; + } catch (TCException e) { + e.printStackTrace(); + return null; + } + } + private List getMapByPref(String prefName,String jsonName,TCComponent currentRev) throws TCException { + // TODO Auto-generated method stub + List mapLists = new ArrayList(); + Map map = new HashMap<>(); + System.out.println("prefName==>"+prefName); + mapLists.add(map); + String[] value2 = session.getPreferenceService().getStringValues(prefName); + if(jsonName.equals("IT_MATREIAL")) { //工艺路线版本 + //组计数器 + String zjsq = currentRev.getStringProperty("ld6_gylxSyncMES"); + if(SoaUtils.isEmpty(zjsq) || zjsq.equals("失败")) { + map.put("ZSTATS", "1"); +// map.put("ZZSTATS", "1"); + }else { + map.put("ZSTATS", "2"); +// map.put("ZZSTATS", "2"); + } + //发布状态STATU 4 1 + TCComponent[] status = currentRev.getReferenceListProperty("release_status_list"); + if(status.length>0) { + map.put("ZSTATU", "发布"); + map.put("STATU", "4"); + }else { + map.put("ZSTATU", ""); + map.put("STATU", "4"); + } + List metargetList = new ArrayList(); + TCComponent[] metargets = currentRev.getRelatedComponents("IMAN_METarget"); + Map meMap = new HashMap(); + for(TCComponent metarget:metargets) { + String partRev = metarget.getStringProperty("ld6_clientPartRev"); + meMap.put("ZVERSON", partRev); + String item_rev_id = metarget.getStringProperty("item_revision_id"); + meMap.put("MATEREV", item_rev_id); + + /** + * 如果类型是成品/机加半成品,则获取此物料在影响分析中引用关系的二维设计版本, + * 如存在相同编号不同版本的二维设计版本,检查是否都为发布,如未发布,则禁止传递, + * 否则取最新版本上的图纸版次(ld6_)属性; + * 如果类型是铸件,则获取此铸件版本上的铸模版次 + */ + /*2023/12/12变更: + 则判定工艺路线下工厂信息表是否为空: + 为空时: + 获取此物料在影响分析中引用关系的二维设计版本,如存在相同编号不同版本的二维设计版本,取最新发布的版本上的图纸版次属性,如都未发布,则传空值即可 + 不为空时: + 获取此物料在影响分析中引用关系的二维设计版本,如存在相同编号不同版本的二维设计版本,检查是否都为发布,如未发布,则禁止传递,否则取最新版本上的图纸版次属性; + */ + + // 2023/12/14变更: + // 调整判断选中数据制造目标下是否是工装 磨具 工装组件 LD6_EquipmentRevision LD6_MoldRevision + System.out.println("获取ZJTZBC属性:"); + System.out.println(METargets.length); + if(METargets!=null && METargets.length>0){ + System.out.println(topFlag); + if("LD6_ProductRevision".equals(metarget.getStringProperty("object_type")) + || "LD6_MachinesPRevision".equals(metarget.getStringProperty("object_type")) + ){ + System.out.println("获取工艺路线表单"); + System.out.println(currentRev.getStringProperty("item_id")); + TCComponent[] referenceListProperty = currentRev.getReferenceListProperty("LD6_GYLXCompanyFormRelation"); + System.out.println(referenceListProperty.length); + for(TCComponent comp:referenceListProperty) { + System.out.println("匹配表单类型:"+comp.getStringProperty("object_type")); + if("LD6_GYLXCompanyForm".equals(comp.getStringProperty("object_type"))) { + //获取表单内容是否为空 + TCComponent[] tableObj = comp.getReferenceListProperty("ld6_GYLXCompanyTable"); + Boolean flag = false; + System.out.println("开始判断表单是否为空"); + if(tableObj!=null && tableObj.length>0){ + for(TCComponent table : tableObj){ + String company = table.getStringProperty("ld6_company"); + System.out.println("company:"+company); + if(company!=null && !"".equals(company)){ + System.out.println("表单不为空"); + flag = true; + break; + } + } + } + System.out.println("获取引用图纸"); + AIFComponentContext[] aifComponentContexts = ((TCComponentItemRevision)metarget).whereReferenced(); + ArrayList conLists = new ArrayList(); + ArrayList conRevLists = new ArrayList(); + for(AIFComponentContext aifComponentContext : aifComponentContexts){ + InterfaceAIFComponent component = aifComponentContext.getComponent(); + if(component instanceof TCComponentItemRevision){ + if("LD6_2DdesignRevision".equals(((TCComponentItemRevision)component).getStringProperty("object_type"))){ + conLists.add(((TCComponentItemRevision) component).getItem()); + conRevLists.add(((TCComponentItemRevision) component)); + } + } + } + System.out.println("去重"); + //给conLists去重 + HashSet set = new HashSet<>(); + for (TCComponentItem i : conLists) { + set.add(i); + } + conLists.clear(); + conLists.addAll(set); + if(conLists.size()>1){ + //提示 + MessageBox.post("成品/机加半成品引用二维图纸不唯一,请确认后传递", "提示", MessageBox.INFORMATION); + throw new RuntimeException("成品/机加半成品引用二维图纸不唯一"); // 抛出异常,退出程序 + }else if(conLists.size()==1){ + if(flag){ + //不为null + System.out.println("获取发布状态"); + for(TCComponentItemRevision revision:conRevLists){ + Date status1 = revision.getDateProperty("date_released"); + if(status1 == null) { + MessageBox.post("成品/机加半成品引用二维图纸版本有未发布状态,请确认后传递", "提示", MessageBox.INFORMATION); + return null; + } + } + //选择引用的最新版本 + TCComponent[] revision_lists = conLists.get(0).getReferenceListProperty("revision_list"); + for(int i=revision_lists.length-1;i>=0;i--){ + if(conRevLists.contains((TCComponentItemRevision)revision_lists[i])){ + String propertyValue = ((TCComponentItemRevision)revision_lists[i]).getStringProperty("ld6_DrawingVer"); + meMap.put("ZJTZBC", propertyValue); + break; + } + } + }else{ + //为null + //选择引用的最新版本 + TCComponent[] revision_lists = conLists.get(0).getReferenceListProperty("revision_list"); + //判断是否都发布了 + int countFlag = 0; + for(int i=revision_lists.length-1;i>=0;i--){ + Date status1 = revision_lists[i].getDateProperty("date_released"); + if(conRevLists.contains((TCComponentItemRevision)revision_lists[i]) && status1 !=null){ + String propertyValue = ((TCComponentItemRevision)revision_lists[i]).getStringProperty("ld6_DrawingVer"); + meMap.put("ZJTZBC", propertyValue); + break; + }else{ + countFlag++; + } + } + if(countFlag==revision_lists.length){ + meMap.put("ZJTZBC", ""); + } + } + } + + //tccomponentForm = (TCComponentForm)comp; + break; + } + } + + }else if("LD6_CastingPRevision".equals(((TCComponentItemRevision)metarget).getStringProperty("object_type"))){ + String propertyValue = ((TCComponentItemRevision)metarget).getStringProperty("ld6_castingMoldVer"); + meMap.put("ZJTZBC", propertyValue); + }else { + meMap.put("ZJTZBC", ""); + } + + }else{ + meMap.put("ZJTZBC", ""); + } + + + metargetList.add(meMap); + } + map.put("IT_VERS", metargetList); + String[] split2 = value2[0].split(";"); //物料版本类型 + for(String prop:split2) { + String[] split = prop.split("="); + if(split[1].startsWith("XSX.")) { + List mapByPref = getMapByPref(split[1].replaceAll("XSX.", ""),split[0],currentRev); + map.put(split[0], mapByPref); + }else { + String revVal = getRevVal(split[1],(TCComponentItemRevision)currentRev); + map.put(split[0], revVal); + } + } + }else if(jsonName.equals("IT_PLPO")) { //工序 + + mapLists.clear(); + + TCComponentBOMLine newBOMLine = getNewBOMLine((TCComponentItemRevision)currentRev); + AIFComponentContext[] children = newBOMLine.getChildren(); + System.out.println("行数"+children.length); + for(AIFComponentContext context:children) { + TCComponentBOMLine component = (TCComponentBOMLine) context.getComponent(); + TCComponentItemRevision itemRevision = component.getItemRevision(); + String ld6_MEprocessType = itemRevision.getProperty("ld6_MEprocessType"); + if(ld6_MEprocessType.equals("合德工序")) { + continue; + } + String property = itemRevision.getProperty("ld6_gxsynctoMES"); + + String[] split2 = value2[0].split(";"); //物料版本类型 + System.out.println(itemRevision+"工序行"); + Map valMap = new HashMap(); + mapLists.add(valMap); + if(SoaUtils.isEmpty(property) || property.equals("失败")) { + valMap.put("VSATUS", "1"); +// map.put("ZZSTATS", "1"); + }else { + valMap.put("VSATUS", "2"); +// map.put("ZZSTATS", "2"); + } + for(String prop:split2) { + String[] split = prop.split("="); + if(split[1].startsWith("XSX.")) { + List mapByPref = getMapByPref(split[1].replaceAll("XSX.", ""),split[0],itemRevision); + valMap.put(split[0], mapByPref); + }else { + String revVal = getRevValBm(split[1],component); + valMap.put(split[0], revVal); + } + } + } + newBOMLine.window().close(); + }else if(jsonName.equals("IT_PRT")) { //工序 + mapLists.clear(); + TCComponentBOMLine newBOMLine = getNewBOMLine((TCComponentItemRevision)currentRev); + AIFComponentContext[] children = newBOMLine.getChildren(); + for(AIFComponentContext context:children) { + TCComponentBOMLine component = (TCComponentBOMLine) context.getComponent(); + String[] split2 = value2[0].split(";"); //物料版本类型 + Map valMap = new HashMap(); + mapLists.add(valMap); + for(String prop:split2) { + String[] split = prop.split("="); + String revVal = getRevValBm(split[1],component); + valMap.put(split[0], revVal); + } + String gxtype = component.getItemRevision().getStringProperty("object_type"); + if("LD6_ComtooldesRevision".equals(gxtype)){ + valMap.put("MAKTX", component.getItemRevision().getStringProperty("object_name")); + }else if("LD6_EquipmentRevision".equals(gxtype) || "LD6_MoldRevision".equals(gxtype)){ + valMap.put("MAKTX", component.getItemRevision().getStringProperty("ld6_materialDesc")); + }else{ + valMap.put("MAKTX", ""); + } + } + newBOMLine.window().close(); + }else if(jsonName.equals("IT_PLANT")) { //工厂 + String[] split2 = value2[0].split(";"); //物料版本类型 +// List propList = new ArrayList(); + Map tableProps = new HashMap<>(); + TCComponent meTag = currentRev.getRelatedComponent("IMAN_METarget"); + TCComponent form = meTag.getRelatedComponent("LD6_CompanyFormRelation"); + TCComponent[] companyTables = form.getTCProperty("ld6_CompanyTable").getReferenceValueArray(); + for(String prop:split2) { + String[] split = prop.split("="); + if(split[1].startsWith("Table.")) { + tableProps.put(split[0], split[1].replaceAll("Table.", "")); +// propList.add(split[1].replaceAll("Table.", "")); + } + } + String ZZSTATS = "1"; + String zjsq = currentRev.getStringProperty("ld6_gylxSyncMES"); + if(SoaUtils.isEmpty(zjsq) || zjsq.equals("失败")) { + ZZSTATS = "1"; + }else { + ZZSTATS = "2"; + } + mapLists.clear(); + for(TCComponent companyTable : companyTables) { + Map map2 = new HashMap<>(); + for(String key:tableProps.keySet()) { + String property = companyTable.getProperty(tableProps.get(key)); + map2.put(key, property); + } + map2.put("ZZSTATS", ZZSTATS); + mapLists.add(map2); + } + }else if(jsonName.equals("IT_SAP_PK")){ + String[] split2 = value2[0].split(";"); //物料版本类型 +// List propList = new ArrayList(); + Map tableProps = new HashMap<>(); + TCComponent[] referenceListProperty = null; + try { + referenceListProperty = currentRev.getReferenceListProperty("LD6_GYLXCompanyFormRelation"); + for(TCComponent comp:referenceListProperty) { + System.out.println("匹配表单类型:"+comp.getStringProperty("object_type")); + if("LD6_GYLXCompanyForm".equals(comp.getStringProperty("object_type"))) { + TCComponent[] referenceListProperty2 = comp.getReferenceListProperty("ld6_GYLXCompanyTable"); + System.out.println("获取到的表单数组:"+referenceListProperty2); + for(String prop:split2) { + String[] split = prop.split("="); + if(split[1].startsWith("GYLXTable.")) { + tableProps.put(split[0], split[1].replaceAll("GYLXTable.", "")); + //propList.add(split[1].replaceAll("Table.", "")); + } + } + mapLists.clear(); + for(TCComponent companyTable : referenceListProperty2) { + Map map2 = new HashMap<>(); + for(String key:tableProps.keySet()) { + String property = companyTable.getProperty(tableProps.get(key)); + map2.put(key, property); + } + mapLists.add(map2); + } + break; + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + }else if(jsonName.equals("IT_PLFL")) { //工序 + mapLists.clear(); + TCComponentBOMLine newBOMLine = getNewBOMLine((TCComponentItemRevision)currentRev); + AIFComponentContext[] children = newBOMLine.getChildren(); + List plnaList = new ArrayList(); + for(AIFComponentContext context:children) { + TCComponentBOMLine component = (TCComponentBOMLine) context.getComponent(); + TCComponentItemRevision rev = component.getItemRevision(); + String ld6_plnfl = rev.getProperty("ld6_plnfl"); + String ld6_ltxa1 = rev.getProperty("ld6_ltxa1"); + if(!SoaUtils.isEmpty(ld6_ltxa1)) { + System.out.println("plnaList===>"+plnaList); + if(!plnaList.contains(ld6_plnfl)) { + Map valMap = new HashMap(); + mapLists.add(valMap); + valMap.put("PLNFL", ld6_plnfl); + valMap.put("LTXA1", ld6_ltxa1); + plnaList.add(ld6_plnfl); + } + } + } + newBOMLine.window().close(); + } + else { + String[] split2 = value2[0].split(";"); //物料版本类型 + for(String prop:split2) { + String[] split = prop.split("="); + + if(split[1].startsWith("XSX.")) { + List mapByPref = getMapByPref(split[1].replaceAll("XSX.", ""),split[0],currentRev); + map.put(split[0], mapByPref); + }else { + String revVal = getRevVal(split[1],(TCComponentItemRevision)currentRev); + map.put(split[0], revVal); + } + } + } + return mapLists; + } + private Map sapMap; + private String getJsonByType(String[] strings,TCComponentItemRevision rev) throws TCException { +// // TODO Auto-generated method stub + Map map = new HashMap<>(); + sapMap = map; + for(String string:strings) { + String[] split = string.split("="); + + if(split[1].startsWith("XSX")) { + List mapByPref = getMapByPref(split[1].replaceAll("XSX.", ""),split[0],rev); + if(mapByPref == null) { + return null; + } + map.put(split[0], mapByPref); + }else { + String revVal = getRevVal(split[1],rev); + map.put(split[0], revVal); + } + } + List fileList = new ArrayList(); + TCComponent[] specifications = currentRev.getRelatedComponents("IMAN_specification"); + for(TCComponent metarget:specifications) { + Map specMap = new HashMap(); +// String partRev = metarget.getStringProperty("ld6_clientPartRev"); + TCComponentDataset ds = (TCComponentDataset)metarget; + TCComponent[] ref_list = ds.getReferenceListProperty("ref_list"); + String refName = null; + String ext = ref_list[0].getStringProperty("file_ext"); + if(ext.equals("pdf")) { + refName = "PDF_Reference"; + }else if(ext.contains("xls")) { + refName = "excel"; + }else if(ext.contains("doc")) { + refName = "word"; + } + specMap.put("fileName", metarget.getProperty("object_name")); + String uploadFile = uploadFile(ds.getUid(), refName, ext); + File file = new File(uploadFile); + String name = file.getName(); + specMap.put("fileUrl", urlBuilder+name); + fileList.add(specMap); + }//uploadFile + map.put("FILE", fileList); + List mapList = new ArrayList(); + mapList.add(map); + String jsonString = JSON.toJSONString(mapList); + return jsonString; + } + private String getRevValBm(String prop,TCComponentBOMLine bmLine) throws TCException { + // TODO Auto-generated method stub + if(!prop.contains(".")) { + return prop; + } + TCComponentItemRevision rev = bmLine.getItemRevision(); + String[] split = prop.split("\\."); + System.out.println("BOM===>"+split[0]); + if(split[0].equals("Rev")) { + return rev.getProperty(split[1]); + }else if(split[0].equals("Item")) { + return rev.getItem().getProperty(split[1]); + }else if(split[0].equals("Form")) { + TCComponent form = rev.getRelatedComponent("IMAN_master_form_rev"); + if(form==null) + return ""; + return form.getProperty(split[1]); + }else if (split[0].equals("Bom")) { + return bmLine.getProperty(split[1]); + }else if(split[0].equals("MFGTarget")) { + TCComponent relatedComponent = rev.getRelatedComponent("IMAN_METarget"); + return relatedComponent.getProperty(split[1]); + }else if(split[0].equals("GYLXTable")){ + TCComponent[] referenceListProperty = null; + try { + referenceListProperty = rev.getReferenceListProperty("LD6_GYLXCompanyFormRelation"); + for(TCComponent comp:referenceListProperty) { + System.out.println("匹配表单类型:"+comp.getStringProperty("object_type")); + if("LD6_GYLXCompanyForm".equals(comp.getStringProperty("object_type"))) { + TCComponent[] referenceListProperty2 = comp.getReferenceListProperty("ld6_GYLXCompanyTable"); + System.out.println("获取到的表单数组:"+referenceListProperty2); + return referenceListProperty2[0].getProperty(split[1]); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return ""; + } + private String getRevVal(String prop,TCComponentItemRevision rev) throws TCException { + // TODO Auto-generated method stub + if(!prop.contains(".")) { + return prop; + } + String[] split = prop.split("\\."); + if(split[0].equals("Rev")) { + + TCProperty tcProperty = rev.getTCProperty(split[1]); + String valString = tcProperty.getDisplayValue(); + if(tcProperty.getPropertyType()==TCProperty.PROP_date) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); + String format = sdf.format(tcProperty.getDateValue()); + valString = format; + } + return valString; + }else if(split[0].equals("Item")) { + return rev.getItem().getProperty(split[1]); + }else if(split[0].equals("Form")) { + TCComponent form = rev.getRelatedComponent("IMAN_master_form_rev"); + if(form==null) + return ""; + return form.getProperty(split[1]); + }else if(split[0].equals("MFGTarget")) { + TCComponent relatedComponent = rev.getRelatedComponent("IMAN_METarget"); + return relatedComponent.getProperty(split[1]); + }else if(split[0].equals("GYLXTable")){ + TCComponent[] referenceListProperty = null; + try { + referenceListProperty = rev.getReferenceListProperty("LD6_GYLXCompanyFormRelation"); + for(TCComponent comp:referenceListProperty) { + System.out.println("匹配表单类型:"+comp.getStringProperty("object_type")); + if("LD6_GYLXCompanyForm".equals(comp.getStringProperty("object_type"))) { + TCComponent[] referenceListProperty2 = comp.getReferenceListProperty("ld6_GYLXCompanyTable"); + System.out.println("获取到的表单数组:"+referenceListProperty2); + return referenceListProperty2[0].getProperty(split[1]); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return ""; + } + + private void initUI() { + // TODO Auto-generated method stub + try { + this.setTitle("工艺路线同步SAP/MES"); + this.setLayout(new BorderLayout()); + +// JPanel topPanel = getTopPanel(); + + JScrollPane pane = getTablePanel(); + pane.setBorder(BorderFactory.createTitledBorder("")); +// JPanel btnPanel = getRightPanel(); + JPanel btnPanel = getBtnPanel(); + + this.add(pane,BorderLayout.CENTER); + this.add(btnPanel,BorderLayout.SOUTH); + + + this.createActionEvent(); + this.pack(); + this.setPreferredSize(new Dimension(800,400)); + this.validate(); + this.setVisible(true); +// this.setAlwaysOnTop(true); + int windowWidth = this.getWidth(); //获得窗口宽 + int windowHeight = this.getHeight(); //获得窗口高 + Toolkit kit = Toolkit.getDefaultToolkit(); //定义工具包 + Dimension screenSize = kit.getScreenSize(); //获取屏幕的尺寸 + int screenWidth = screenSize.width; //获取屏幕的宽 + int screenHeight = screenSize.height; //获取屏幕的高 + this.setLocation(screenWidth / 2 - windowWidth / 2, screenHeight / 2 - windowHeight / 2);//设置窗口居中显示 + } catch (Exception e) { + e.printStackTrace(); + return; + } + } +// private String sql = "insert into OA_LOG (NAME,\"DESC\",\"IN\",OUT,CALLER,PROVIDER,ITEM_ID,TIME) values('MES_003','工艺路线主数据',?,?,'PLM','MES',?)"; + private String sql = "insert into OA_LOG(NAME,\"DESC\",\"IN\",OUT,CALLER,PROVIDER,ITEM_ID,TIME) values('MES_003','工艺路线主数据',?,?,'PLM','MES',?,getdate())"; + private String sql2 = "insert into OA_LOG(NAME,\"DESC\",\"IN\",OUT,CALLER,PROVIDER,ITEM_ID,TIME) values('SAP_003','工艺路线主数据',?,?,'PLM','SAP',?,getdate())"; + private JButton btnOk; + private JButton btnDis; + private JPanel getBtnPanel() { + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + btnOk = new JButton("确定"); + btnDis = new JButton("取消"); + topPanel.add("1.1.center",btnOk); + + topPanel.add("1.2.center",btnDis); + return topPanel; + } + public String uploadFile(String uidString,String ref,String ext) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[3]; + obj[0] = uidString; + obj[1] = ref; + obj[2] = ext; + Object call = userservice.call("uploadFile", obj); + String data = (String)call; + return data; + } + private TCComponentItemRevision currentRev; +// private TCComponent form; + private StringBuilder urlBuilder = new StringBuilder("http://"); + private void createActionEvent() { + // TODO Auto-generated method stub + this.btnDis.addActionListener(this); + this.btnOk.addActionListener(this); + } + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if(this.btnDis.equals(source)){ + this.dispose(); + }else if(source.equals(this.btnOk)) { + try { + String[] value2 = session.getPreferenceService().getStringValues("LD_dbinfo2"); + if(value2==null || value2.length==0) { + MessageBox.post("首选项LD_dbinfo配置有误,请检查。","提示",2); + return; + } + int ind = 0; + DbPool.getConnection(value2[0],value2[1]); + urlBuilder = urlBuilder.append(value2[0]).append(":19090").append("/file/"); + //获取工厂信息,获取BOM信息,获取工序信息 + for(TCComponentItemRevision revision : mantrRev) { + currentRev = revision; +// form = currentRev.getRelatedComponent("LD6_CompanyFormRelation"); + String[] strings = beanMap.get(revision.getType()); + String jsonByType = getJsonByType(strings,revision); + if(jsonByType == null) { + return; + } + System.out.println(revision+"====>"+jsonByType); + JSONArray parseObject = JSON.parseArray(jsonByType); + //MES传递 + sendMes(jsonByType,revision,ind,parseObject); + //SAP传递 + sendSap(revision,parseObject,ind); + ind = ind + 1; + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + }finally { + DbPool.freeAll(); + } + } + } + private void sendMes(String jsonByType, TCComponentItemRevision revision, int ind, JSONArray parseObject) { + // TODO Auto-generated method stub + try { + JSONObject send = SoaUtils.send(jsonByType,urlString); + System.out.println(send); + Boolean bool = send.getBoolean("success"); + if(bool) { + table.setValueAt("成功", ind, 3); + revision.setStringProperty("ld6_gylxSyncMES", "成功"); + TCComponent[] psChildren = revision.getReferenceListProperty("ps_children"); + for(TCComponent child:psChildren) { + child.setStringProperty("ld6_gxsynctoMES", "成功"); + } + }else { + String ZFLAG = parseObject.getJSONObject(0).getJSONArray("IT_MATREIAL").getJSONObject(0).getString("ZSTATS"); + String string = send.getString("msg"); + if(ZFLAG.equals("1")) { + revision.setStringProperty("ld6_gylxSyncMES", "失败"); + TCComponent[] psChildren = revision.getReferenceListProperty("ps_children"); + for(TCComponent child:psChildren) { + child.setStringProperty("ld6_gxsynctoMES", "失败"); + } + }else { + revision.setStringProperty("ld6_gylxSyncMES", "更新失败"); + TCComponent[] psChildren = revision.getReferenceListProperty("ps_children"); + for(TCComponent child:psChildren) { + child.setStringProperty("ld6_gxsynctoMES", "更新失败"); + } + } + table.setValueAt("失败:"+string, ind, 3); + } + + DbPool.write(sql, new String[] {jsonByType,send.toJSONString(),revision.getStringProperty("item_id")}); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } + private DefaultTableModel map; + public JTable getJTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 150; +// int totleLen = 1000; + if (partsTable == null) { + map = new DefaultTableModel(values, titleNames) { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + + partsTable = new JTable(map); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + partsTable.setRowHeight(30); + // //设置显示器渲染 + partsTable.getTableHeader().setReorderingAllowed(false); + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } + + //++ + return partsTable; + } + private void sendSap(TCComponentItemRevision revision, JSONArray parseObject,int ind) throws TCException, JCoException { + // TODO Auto-generated method stub + TCComponent meTag = revision.getRelatedComponent("IMAN_METarget"); + TCComponent form = meTag.getRelatedComponent("LD6_CompanyFormRelation"); + JSONObject mesJson = parseObject.getJSONObject(0); + JSONObject jsonObject = mesJson.getJSONArray("IT_MATREIAL").getJSONObject(0); + mesJson.remove("FILE"); + jsonObject.put("ZSTATS", "1"); + String zjsq = revision.getProperty("ld6_groupCounter"); + //记录对应工厂的zzstatus + Map statuMap = new HashMap(); + //设置zstats + if(!zjsq.equals("") && zjsq!=null) { + jsonObject.put("ZSTATS", "2"); + } + if(form!=null) { + TCComponent[] companyTables = form.getTCProperty("ld6_CompanyTable").getReferenceValueArray(); + for(TCComponent companyTable:companyTables) { + String status = companyTable.getProperty("ld6_groupNum"); + String work = companyTable.getProperty("ld6_company"); + if(!status.equals("")) { + System.out.println("检查到了状态不为空,改为2"); + statuMap.put(work, "2"); + //jsonObject.put("ZSTATS", "2"); + } + } + } + JSONArray plants = mesJson.getJSONArray("IT_PLANT"); + for(int i=0;i beanMap = new HashMap(); + private Map vtwegMap = new HashMap(); + private String urlString; + private List mantrRev = new ArrayList(); //不存在的版本对象 + public SendMesFram(TCSession session,InterfaceAIFComponent[] targetComponents) { + // TODO Auto-generated constructor stub + this.session = session; + String value = session.getPreferenceService().getStringValue("LD_PLM2MES_Part_Config"); + if(value==null) { + MessageBox.post("首选项LD_PLM2MES_Part_Config配置有误,请检查。","提示",2); + return; + } + urlString = value; + String[] value2 = session.getPreferenceService().getStringValues("LD_SendPart_Config"); + if(value2==null || value2.length==0) { + MessageBox.post("首选项LD_SendPart_Config配置有误,请检查。","提示",2); + return; + } + String[] value3 = session.getPreferenceService().getStringValues("LD_SendPart_DistriChannel_Mapping"); + if(value3==null || value3.length==0) { + MessageBox.post("首选项LD_SendPart_DistriChannel_Mapping配置有误,请检查。","提示",2); + return; + } + for(String val:value3) { + String[] split = val.split("="); + vtwegMap.put(split[0], split[1]); + } +// 版本类型:接口字段名称1=属性位置(Item\Rev\Form\Table).TC中属性名称1; + //接口字段名称2=属性位置(Item\Rev\Form\Table).TC中属性名称2,如没有TC属性需要传递默认值,则=右侧直接填写默认值 + + for(String val:value2) { + String[] split = val.split(":"); + String[] split2 = split[1].split(";"); //物料版本类型 + beanMap.put(split[0], split2); + } + try { + for(InterfaceAIFComponent targetComponent:targetComponents) { + String type = targetComponent.getType(); + if(!beanMap.containsKey(type)) { + if(targetComponent instanceof TCComponentItemRevision) { + String stringProperty = ((TCComponentItemRevision)targetComponent).getStringProperty("item_id"); + MessageBox.post("编号"+stringProperty+"的数据不能执行发送物料到SAP/MES。","提示",2); + return; + } + }else if(targetComponent instanceof TCComponentItemRevision) { + mantrRev.add((TCComponentItemRevision)targetComponent); + } + } + initUI(); + addRows(); + }catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + } + + private void addRows() throws TCException { + // TODO Auto-generated method stub + for(TCComponentItemRevision rev:mantrRev) { + String item_id = rev.getStringProperty("item_id"); + String item_revision_id = rev.getStringProperty("item_revision_id"); + map.addRow(new String[] {item_id,item_revision_id,"",""}); + } +// table.repaint(); + } + + private String getJsonByType(String[] strings,TCComponentItemRevision rev) throws TCException { + // TODO Auto-generated method stub +// 接口字段名称1=属性位置(Item\Rev\Form\Table).TC中属性名称1 + Map tableProps = new HashMap<>(); + Map map = new HashMap<>(); + for(String string:strings) { + String[] split = string.split("="); + String revVal = getRevVal(split[0],split[1],rev); + if(revVal.startsWith("TableTest:")) { + tableProps.put(split[0], revVal.replaceAll("TableTest:", "")); + continue; + } + if(split[0].equals("VTWEG") && vtwegMap.containsKey(revVal)) { + revVal = vtwegMap.get(revVal); + } + map.put(split[0], revVal); + } +// Map> map2 = new HashMap<>(); + TCComponent form = rev.getRelatedComponent("LD6_CompanyFormRelation"); + List propList = new ArrayList(); + map.put("I_ZMMMARC", propList); + if(form!=null) { + System.out.println("tableProps==>"+tableProps); + TCComponent[] companyTables = form.getTCProperty("ld6_CompanyTable").getReferenceValueArray(); +// TCComponent[] companyTables = form.getReferenceListProperty("ld6_CompanyTable"); + for(TCComponent companyTable:companyTables) { + Map tableVals = new HashMap<>(); + for(String key:tableProps.keySet()) { + String property = companyTable.getProperty(tableProps.get(key)); + tableVals.put(key, property); + } + propList.add(tableVals); + } + } + List mapList = new ArrayList(); + mapList.add(map); + String sapinfo = ""; + /* + * 更改为取物料版本上的ICM_classification关系下的icm0数据,获取其cid属性,在分类库中找到分类id为获取到的cid的分类,取此分类库上的用户数据1属性上的值,传递时需要做特殊处理, + * 前四位作为物料类型传递,第五位到第八位作为物料组传递,第五位到第十位作为外部物料组传递(如不存在第九到第十位,则外部物料组字段为空) + */ + TCComponent[] classifications = rev.getReferenceListProperty("IMAN_classification"); + if(classifications == null || classifications.length<=0){ + + MessageBox.post("编号"+rev.getStringProperty("item_id")+"的物料未被发送到分类", "提示", MessageBox.INFORMATION); + throw new RuntimeException("没有找到IMAN_classification关系下的数据"); // 抛出异常,退出程序 + }else{ + String cid = classifications[0].getStringProperty("cid"); + //根据id找到分类 + // 获取分类ID对象的用户数据1属性 + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass adminClass = classificationService.newICSAdminClass(); + adminClass.load(cid); + String user1 = adminClass.getUser1(); + System.out.println("用户数据1:"+user1); + sapinfo = user1; + } + if(sapinfo.length()>=4) { + map.put("MTART", sapinfo.substring(0, 4)); + }else { + map.put("MTART", ""); + } + if(sapinfo.length()>=8){ + map.put("MATKL", sapinfo.substring(4, 8)); + }else { + map.put("MATKL", ""); + } + if(sapinfo.length()>=10){ + map.put("EXTWG", sapinfo.substring(4, 10)); + }else { + map.put("EXTWG", ""); + } + + String sync = rev.getProperty("ld6_partSyncMES"); + if(sync==null || sync.equals("") || sync.equals("失败")) { + map.put("ZFLAG", "I"); + }else { + map.put("ZFLAG", "U"); + } + + //获取SAP的状态 + + String jsonString = JSON.toJSONString(mapList); + return jsonString; + } + + private String getRevVal(String name,String prop,TCComponentItemRevision rev) throws TCException { + // TODO Auto-generated method stub + if(!prop.contains(".")) { + return prop; + } + String[] split = prop.split("\\."); + if(split[0].equals("Rev")) { + System.out.println("rev类型:"+rev.getProperty("object_type")); + String typestriString = rev.getStringProperty("object_type"); + + if("ZJTZBC".equals(name)&&( "LD6_ProductRevision".equals(typestriString) || "LD6_MachinesPRevision".equals(typestriString))){ + System.out.println("成品机加半成品获取影响分析引用关系中二维图纸上的图纸版次"); + System.out.println("开始获取引用对象》》》》》》》"); + AIFComponentContext[] aifComponentContexts = rev.whereReferenced(); + ArrayList conLists = new ArrayList(); + ArrayList conRevLists = new ArrayList(); + for(AIFComponentContext aifComponentContext : aifComponentContexts){ + InterfaceAIFComponent component = aifComponentContext.getComponent(); + if(component instanceof TCComponentItemRevision){ + if("LD6_2DdesignRevision".equals(((TCComponentItemRevision)component).getStringProperty("object_type"))){ + System.out.println("获取到了二维图纸版本"); + conLists.add(((TCComponentItemRevision) component).getItem()); + conRevLists.add(((TCComponentItemRevision) component)); + } + } + } + //给conLists去重 + HashSet set = new HashSet<>(); + for (TCComponentItem i : conLists) { + set.add(i); + } + conLists.clear(); + conLists.addAll(set); + if(conLists.size()>1){ + //提示 + MessageBox.post("成品/机加半成品引用二维图纸不唯一,请确认后传递", "提示", MessageBox.INFORMATION); + throw new RuntimeException("成品/机加半成品引用二维图纸不唯一"); // 抛出异常,退出程序 + }else if(conLists.size()==1){ + System.out.println("引用的版本数量为:"+conRevLists.size()); + + //选择引用的最新发布版本 + System.out.println("选择引用的最新版本"); + TCComponent[] revision_lists = conLists.get(0).getReferenceListProperty("revision_list"); + int count = 0; + System.out.println("当前二维图纸所有的版本数量为:"+revision_lists.length); + for(int i=revision_lists.length-1;i>=0;i--){ + Date status1 = revision_lists[i].getDateProperty("date_released"); + System.out.println("判断是否发布:"+status1==null + ",是否存在于引用的版本中:"+conRevLists.contains((TCComponentItemRevision)revision_lists[i])); + if(conRevLists.contains((TCComponentItemRevision)revision_lists[i]) && status1 != null){ + System.out.println("获取的:"+((TCComponentItemRevision)revision_lists[i]).getProperty("ld6_DrawingVer")); + return ((TCComponentItemRevision)revision_lists[i]).getProperty("ld6_DrawingVer"); + }else{ + count++; + } + if(count == revision_lists.length){ + return ""; + } + } + }else { + //提示 + return ""; + } + }else if("ZJTZBC".equals(name)&&( "LD6_CastingPRevision".equals(((TCComponentItemRevision)rev).getStringProperty("object_type")))){ + System.out.println("铸件获取铸件版本上的铸模版次"); + return rev.getProperty("ld6_castingMoldVer"); + } + return rev.getProperty(split[1]); + }else if(split[0].equals("Item")) { + return rev.getItem().getProperty(split[1]); + }else if(split[0].equals("Table")) { + +// TCComponent form = rev.getRelatedComponent("LD6_CompanyFormRelation"); +// if(form==null) +// return "TableTest"; +// TCComponent companyTable = form.getReferenceProperty("ld6_CompanyTable"); +// if(companyTable==null) { +// +// } + return "TableTest:"+split[1]; + +// return ""; +// return companyTable.getProperty(split[1]); + }else if(split[0].equals("Form")) { + TCComponent form = rev.getRelatedComponent("IMAN_master_form_rev"); + if(form==null) + return ""; + return form.getProperty(split[1]); + } + + return ""; + } + + private void initUI() { + // TODO Auto-generated method stub + try { + this.setTitle("主数据同步SAP/MES"); + this.setLayout(new BorderLayout()); + +// JPanel topPanel = getTopPanel(); + + JScrollPane pane = getTablePanel(); + pane.setBorder(BorderFactory.createTitledBorder("")); +// JPanel btnPanel = getRightPanel(); + JPanel btnPanel = getBtnPanel(); + + this.add(pane,BorderLayout.CENTER); + this.add(btnPanel,BorderLayout.SOUTH); + + + this.createActionEvent(); + this.pack(); + this.setPreferredSize(new Dimension(800,400)); + this.validate(); + this.setVisible(true); +// this.setAlwaysOnTop(true); + int windowWidth = this.getWidth(); //获得窗口宽 + int windowHeight = this.getHeight(); //获得窗口高 + Toolkit kit = Toolkit.getDefaultToolkit(); //定义工具包 + Dimension screenSize = kit.getScreenSize(); //获取屏幕的尺寸 + int screenWidth = screenSize.width; //获取屏幕的宽 + int screenHeight = screenSize.height; //获取屏幕的高 + this.setLocation(screenWidth / 2 - windowWidth / 2, screenHeight / 2 - windowHeight / 2);//设置窗口居中显示 + } catch (Exception e) { + e.printStackTrace(); + return; + } + } + private String sql = "insert into OA_LOG(NAME,\"DESC\",\"IN\",OUT,CALLER,PROVIDER,ITEM_ID,TIME) values('MES_001','物料主数据',?,?,'PLM','MES',?,getdate())"; + private String sql2 = "insert into OA_LOG(NAME,\"DESC\",\"IN\",OUT,CALLER,PROVIDER,ITEM_ID,TIME) values('SAP_001','物料主数据',?,?,'PLM','SAP',?,getdate())"; + private JButton btnOk; + private JButton btnDis; + private JPanel getBtnPanel() { + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + btnOk = new JButton("确定"); + btnDis = new JButton("取消"); + topPanel.add("1.1.center",btnOk); + + topPanel.add("1.2.center",btnDis); + return topPanel; + } + + private void createActionEvent() { + // TODO Auto-generated method stub + this.btnDis.addActionListener(this); + this.btnOk.addActionListener(this); + } + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if(this.btnDis.equals(source)){ + this.dispose(); + }else if(source.equals(this.btnOk)) { + try { + String[] value2 = session.getPreferenceService().getStringValues("LD_dbinfo2"); + if(value2==null || value2.length==0) { + MessageBox.post("首选项LD_dbinfo配置有误,请检查。","提示",2); + return; + } + DbPool.getConnection(value2[0],value2[1]); + int ind = 0; + for(TCComponentItemRevision revision : mantrRev) { + String[] strings = beanMap.get(revision.getType()); + String jsonByType = getJsonByType(strings,revision); + System.out.println(revision+"====>"+jsonByType); + JSONArray parseObject = JSON.parseArray(jsonByType); + //传递MES + JSONObject send = SoaUtils.send(jsonByType,urlString); + System.out.println(send); + Boolean bool = send.getBoolean("success"); + if(bool) { + table.setValueAt("成功", ind, 3); + revision.setStringProperty("ld6_partSyncMES", "成功"); + }else { + String ZFLAG = parseObject.getJSONObject(0).getString("ZFLAG"); + String string = send.getString("msg"); + if(ZFLAG.equals("I")) { + revision.setStringProperty("ld6_partSyncMES", "失败"); + }else { + revision.setStringProperty("ld6_partSyncMES", "更新失败"); + } + table.setValueAt("失败:"+string, ind, 3); + } + DbPool.write(sql, new String[] {jsonByType,send.toJSONString(),revision.getStringProperty("item_id")}); + //传递SAP + sendSap(revision,parseObject,ind); + ind = ind + 1; + + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + }finally { + DbPool.freeAll(); + } + } + } + private void sendSap(TCComponentItemRevision revision, JSONArray parseObject,int ind) throws TCException, JCoException { + // TODO Auto-generated method stub + TCComponent form = revision.getRelatedComponent("LD6_CompanyFormRelation"); + JSONObject mesJson = parseObject.getJSONObject(0); + mesJson.put("ZFLAG", "I"); + String prop = revision.getProperty("ld6_propertySyncSAP"); + if(prop.equals("更新失败")||prop.equals("成功")) { + mesJson.put("ZFLAG", "U"); + } + JCoDestination destination = SAPConn.connect(); + JCoFunction function = destination.getRepository().getFunction("ZFM_PLM_004"); + System.out.println(function.toXML()); +// JCoTable T_IN = function.getTableParameterList().getTable("INPUT"); + + JCoParameterList importParameterList = function.getImportParameterList(); + JCoTable inputTab = importParameterList.getTable("INPUT"); + System.out.println(inputTab.toXML()); +// JCoTable jCoTable = new Jc +// importParameterList.setValue("INPUT", parseObject.toJSONString()); + inputTab.appendRow(); + for(String string:mesJson.keySet()) { + if(string.equals("I_ZMMMARC")) { + JCoTable I_ZMMMARC = inputTab.getTable("I_ZMMMARC"); + JSONArray factorys = mesJson.getJSONArray(string); + for(int t=0;t workMap = new HashMap<>(); + for(int i = 0; i < table2.getNumRows(); i++){ + table2.setRow(i); + Object works = table2.getValue("WERKS"); + Object code = table2.getValue("CODE"); + workMap.put(works.toString(), code.toString()); + } + for(TCComponent companyTable:companyTables) { + String code = companyTable.getStringProperty("ld6_company"); + if(workMap.containsKey(code)) { + companyTable.setStringProperty("ld6_sendpartstatus",workMap.get(code)); + } + } + } + + DbPool.write(sql2, new String[] {function.toXML(),returnTable.toXML(),revision.getStringProperty("item_id")}); + + } + private DefaultTableModel map; + public JTable getJTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 150; +// int totleLen = 1000; + if (partsTable == null) { + map = new DefaultTableModel(values, titleNames) { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + + partsTable = new JTable(map); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); +// Adapter1 adapter = new Adapter1(partsTable); +// partsTable.getTableHeader().setDefaultRenderer(new CheckHeaderCellRenderer(partsTable)); +// setDefaultRenderer(new CheckHeaderCellRenderer(table)); + partsTable.setRowHeight(30); + // //设置显示器渲染 +// partsTable.getColumnModel().getColumn(0).setCellRenderer(new TableCellCheckboxRenderer(partsTable)); +// partsTable.setDefaultRenderer(Object.class, renderer); + partsTable.getTableHeader().setReorderingAllowed(false); + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } + + //++ + return partsTable; + } + private JScrollPane getTablePanel() { + // TODO Auto-generated method stub + table = getJTable(null, null, header, null); + table.setRowHeight(30); + table.setPreferredSize(new Dimension(800,380)); + table.getColumnModel().getColumn(2).setPreferredWidth(300); + table.getColumnModel().getColumn(3).setPreferredWidth(300); + table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); +// table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // 设置表格的自动调整模式为关闭自动调整 +// table.getColumnModel().getColumn(0).setPreferredWidth(50); + JScrollPane pane = new JScrollPane(table,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + pane.setPreferredSize(new Dimension(800,400)); + pane.setViewportView(table);//为scrollPane指定显示对象为table + return pane; + } +} diff --git a/src/com/connor/ld/sendMesJc/SendMesHandler.java b/src/com/connor/ld/sendMesJc/SendMesHandler.java new file mode 100644 index 0000000..246811e --- /dev/null +++ b/src/com/connor/ld/sendMesJc/SendMesHandler.java @@ -0,0 +1,35 @@ +package com.connor.ld.sendMesJc; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.ld.importsj.handlers.HistoryFolderDialog; +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 SendMesHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + try { + +// new Thread(new HistoryFolderDialog((TCSession)app.getSession())).start(); + new Thread() { + @Override + public void run() { + InterfaceAIFComponent[] targetComponents = app.getTargetComponents(); + new SendMesFram((TCSession)app.getSession(),targetComponents); + + } + }.start(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/com/connor/ld/sendMesJc/Test.java b/src/com/connor/ld/sendMesJc/Test.java new file mode 100644 index 0000000..9bdea8c --- /dev/null +++ b/src/com/connor/ld/sendMesJc/Test.java @@ -0,0 +1,14 @@ +package com.connor.ld.sendMesJc; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; + +public class Test { + + public static void main(String[] args) { + JSONObject teamObj = new JSONObject(); + JSONArray jsonArray = teamObj.getJSONArray("user"); + System.out.println(jsonArray.size()); + } + +} diff --git a/src/sapconnect.properties b/src/sapconnect.properties new file mode 100644 index 0000000..760f864 --- /dev/null +++ b/src/sapconnect.properties @@ -0,0 +1,18 @@ +#\u6D4B\u8BD5\u7CFB\u7EDF +JCO_ASHOST_STR=10.10.22.15 +JCO_SYSNR_STR=00 +JCO_CLIENT_STR=800 +JCO_USER_STR=LDIT001 +JCO_PASSWD_STR=AlliedIT@2022 +#JCO_ASHOST_STR=10.10.22.14 +#JCO_SYSNR_STR=00 +#JCO_CLIENT_STR=400 +#JCO_USER_STR=LDIT001 +#JCO_PASSWD_STR=LDIT@2022 +#JCO_ASHOST_STR=10.200.1.192 +#JCO_SYSNR_STR=00 +#JCO_CLIENT_STR=800 +#JCO_USER_STR=SAP_TC +#JCO_PASSWD_STR=Sap_RFC2020 + +