commit 978ff6c10d14cdd37e208a1aab0504f629614677 Author: lijh Date: Tue Mar 10 16:06:35 2026 +0800 first commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..6d1433f --- /dev/null +++ b/.classpath @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..8524f6b --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/git_toolbox_blame.xml b/.idea/git_toolbox_blame.xml new file mode 100644 index 0000000..7dc1249 --- /dev/null +++ b/.idea/git_toolbox_blame.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7da3b0e --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 0000000..3236b24 --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + com.connor.rb.plm + + + + + + 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.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..bb29a1d --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=GBK diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..0fee6a9 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,15 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..7103be7 --- /dev/null +++ b/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.ui.text.custom_code_templates= diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000..fb4354d --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,1308 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Plm +Bundle-SymbolicName: com.connor.rb.plm;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Localization: plugin +Bundle-Activator: com.connor.rb.plm.Activator +Bundle-Vendor: CONNOR +Require-Bundle: org.eclipse.ui;bundle-version="3.108.0", + org.eclipse.core.runtime;bundle-version="3.12.0", + org.apache.poi.39;bundle-version="3.9.0", + com.teamcenter.rac.activex;bundle-version="12000.1.0", + com.teamcenter.rac.aifrcp;bundle-version="12000.1.0", + com.teamcenter.rac.common;bundle-version="12000.1.0", + com.teamcenter.rac.kernel;bundle-version="12000.1.0", + com.teamcenter.rac.external;bundle-version="12000.1.0", + com.teamcenter.rac.tcapps;bundle-version="12000.1.0", + com.teamcenter.rac.ui;bundle-version="12000.1.0", + com.teamcenter.rac.ui.commands;bundle-version="12000.1.0", + TcSoaCadRac;bundle-version="12000.1.0", + TcSoaCommon;bundle-version="12000.1.0", + TcSoaCoreRac;bundle-version="12000.1.0", + TcSoaCoreLoose;bundle-version="12000.1.0", + com.teamcenter.rac.classification.icm;bundle-version="12000.1.0", + com.teamcenter.rac.util;bundle-version="12000.1.0", + com.teamcenter.rac.classification.icadmin;bundle-version="12000.1.0", + httpclient;bundle-version="4.5.2", + com.teamcenter.rac.workflow.processdesigner, + TcSoaWorkflowRac;bundle-version="12000.1.0", + TcSoaWorkflowLoose;bundle-version="12000.1.0", + com.teamcenter.rac.ui.views;bundle-version="12000.1.0", + cn.com.origin.autocode;bundle-version="1.0.0", + cn.com.origin.autocodemanager;bundle-version="1.0.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Automatic-Module-Name: com.connor.rb.plm +Bundle-ActivationPolicy: lazy +Bundle-ClassPath: src/, + lib/activation-1.1.jar, + lib/antlr-2.7.7.jar, + lib/apache-commons-codec-1.4.jar, + lib/apache-mime4j-core-0.7.2.jar, + lib/axiom-api-1.2.12.jar, + lib/axiom-dom-1.2.12.jar, + lib/axiom-impl-1.2.12.jar, + lib/axis2-adb-1.6.2.jar, + lib/axis2-adb-codegen-1.6.2.jar, + lib/axis2-ant-plugin-1.6.2.jar, + lib/axis2-clustering-1.6.2.jar, + lib/axis2-codegen-1.6.2.jar, + lib/axis2-corba-1.6.2.jar, + lib/axis2-fastinfoset-1.6.2.jar, + lib/axis2-java2wsdl-1.6.2.jar, + lib/axis2-jaxbri-1.6.2.jar, + lib/axis2-jaxws-1.6.2.jar, + lib/axis2-jibx-1.6.2.jar, + lib/axis2-json-1.6.2.jar, + lib/axis2-kernel-1.6.2.jar, + lib/axis2-metadata-1.6.2.jar, + lib/axis2-mtompolicy-1.6.2.jar, + lib/axis2-saaj-1.6.2.jar, + lib/axis2-soapmonitor-servlet-1.6.2.jar, + lib/axis2-spring-1.6.2.jar, + lib/axis2-transport-http-1.6.2.jar, + lib/axis2-transport-local-1.6.2.jar, + lib/axis2-xmlbeans-1.6.2.jar, + lib/bcel-5.1.jar, + lib/commons-beanutils-1.7.0.jar, + lib/commons-cli-1.2.jar, + lib/commons-codec-1.3.jar, + lib/commons-collections-3.2.jar, + lib/commons-fileupload-1.2.jar, + lib/commons-httpclient-3.1.jar, + lib/commons-io-1.4.jar, + lib/commons-lang-2.4.jar, + lib/commons-logging-1.1.1.jar, + lib/commons-logging-1.1.jar, + lib/dom4j-1.6.1.jar, + lib/ezmorph-1.0.4.jar, + lib/geronimo-annotation_1.0_spec-1.1.jar, + lib/geronimo-jaxws_2.2_spec-1.0.jar, + lib/geronimo-jta_1.1_spec-1.1.jar, + lib/geronimo-saaj_1.3_spec-1.0.1.jar, + lib/geronimo-stax-api_1.0_spec-1.0.1.jar, + lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar, + lib/itext-2.0.3.jar, + lib/iText-5.0.2.jar, + lib/iTextAsian.jar, + lib/jalopy-1.5rc3.jar, + lib/jaxb-api-2.1.jar, + lib/jaxb-impl-2.1.7.jar, + lib/jaxb-xjc-2.1.7.jar, + lib/jaxen-1.1.6.jar, + lib/jaxws-tools-2.1.3.jar, + lib/jdom.jar, + lib/jettison-1.0-RC2.jar, + lib/jibx-bind-1.2.jar, + lib/jibx-run-1.2.jar, + lib/json-lib-2.2.2-jdk15.jar, + lib/json-lib-2.2.3-jdk13.jar, + lib/jsr311-api-1.0.jar, + lib/juli-6.0.16.jar, + lib/log4j-1.2.15.jar, + lib/mail-1.4.jar, + lib/mex-1.6.2-impl.jar, + lib/mysql-connector-java-5.0.8-bin.jar, + lib/neethi-3.0.2.jar, + lib/ojdbc6.jar, + lib/regexp-1.2.jar, + lib/tribes-6.0.16.jar, + lib/woden-api-1.0M9.jar, + lib/woden-impl-commons-1.0M9.jar, + lib/woden-impl-dom-1.0M9.jar, + lib/wsdl4j-1.6.2.jar, + lib/wstx-asl-3.2.9.jar, + lib/xalan-2.7.0.jar, + lib/xml-resolver-1.2.jar, + lib/xmlbeans-2.3.0.jar, + lib/XmlSchema-1.4.7.jar, + ., + lib/commons-logging.jar, + lib/fontbox-2.0.11.jar, + lib/pdfbox-2.0.11.jar, + lib/pdfbox-debugger-2.0.11.jar, + lib/pdfbox-tools-2.0.11.jar, + lib/preflight-2.0.11.jar, + lib/xmpbox-2.0.11.jar, + lib/jacob.jar, + lib/Spire.Xls.jar, + lib/Spire.Office.jar, + lib/spire.pdf-3.4.2.jar, + bomupadte/Spire.Xls.jar, + lib/aspose-cells-18.9.jar, + lib/hutool-all-5.0.7.jar, + lib/datepicker.jar, + bomupadte/, + lib/logback-classic-1.2.10.jar, + lib/logback-core-1.2.10.jar, + lib/slf4j-api-1.7.30.jar, + lib/imageio-tiff-3.8.2.jar, + lib/itextpdf-5.5.5.jar, + lib/aspose-cad-21.8.jar, + lib/fastjson2-2.0.15.jar, + lib/swing2swt.jar, + lib/jxl_1.0.0.jar +Export-Package: ., + antlr, + antlr.ASdebug, + antlr.actions.cpp, + antlr.actions.csharp, + antlr.actions.java, + antlr.actions.python, + antlr.build, + antlr.collections, + antlr.collections.impl, + antlr.debug, + antlr.debug.misc, + antlr.preprocessor, + cn.hutool.json, + com.aspose.cad.internal.ac, + com.connor.rb.plm, + com.connor.rb.plm.exportBOM, + com.connor.rb.plm.handlers, + com.connor.rb.plm.openFastWorkflowLists, + com.connor.rb.plm.openFastWorkflowLists.common, + com.connor.rb.plm.rb001, + com.connor.rb.plm.rb004, + com.connor.rb.plm.rb007, + com.connor.rb.plm.rb011, + com.connor.rb.plm.rb012, + com.connor.rb.plm.rb013one, + com.connor.rb.plm.rb013two, + com.connor.rb.plm.rb015, + com.connor.rb.plm.rb016, + com.connor.rb.plm.rb018one, + com.connor.rb.plm.rb018two, + com.connor.rb.plm.rb019, + com.connor.rb.plm.rb020, + com.connor.rb.plm.rb021, + com.connor.rb.plm.rb022, + com.connor.rb.plm.util, + com.ctc.wstx.api, + com.ctc.wstx.cfg, + com.ctc.wstx.compat, + com.ctc.wstx.dom, + com.ctc.wstx.dtd, + com.ctc.wstx.ent, + com.ctc.wstx.evt, + com.ctc.wstx.exc, + com.ctc.wstx.io, + com.ctc.wstx.msv, + com.ctc.wstx.sax, + com.ctc.wstx.sr, + com.ctc.wstx.stax, + com.ctc.wstx.sw, + com.ctc.wstx.util, + com.ibm.wsdl, + com.ibm.wsdl.extensions, + com.ibm.wsdl.extensions.http, + com.ibm.wsdl.extensions.mime, + com.ibm.wsdl.extensions.schema, + com.ibm.wsdl.extensions.soap, + com.ibm.wsdl.extensions.soap12, + com.ibm.wsdl.factory, + com.ibm.wsdl.util, + com.ibm.wsdl.util.xml, + com.ibm.wsdl.xml, + com.itextpdf.text, + com.itextpdf.text.error_messages, + com.itextpdf.text.exceptions, + com.itextpdf.text.factories, + com.itextpdf.text.html, + com.itextpdf.text.html.simpleparser, + com.itextpdf.text.pdf, + com.itextpdf.text.pdf.codec, + com.itextpdf.text.pdf.codec.wmf, + com.itextpdf.text.pdf.collection, + com.itextpdf.text.pdf.crypto, + com.itextpdf.text.pdf.draw, + com.itextpdf.text.pdf.events, + com.itextpdf.text.pdf.fonts, + com.itextpdf.text.pdf.fonts.cmaps, + com.itextpdf.text.pdf.hyphenation, + com.itextpdf.text.pdf.interfaces, + com.itextpdf.text.pdf.internal, + com.itextpdf.text.pdf.parser, + com.itextpdf.text.pdf.qrcode, + com.itextpdf.text.pdf.richmedia, + com.itextpdf.text.xml, + com.itextpdf.text.xml.simpleparser, + com.itextpdf.text.xml.xmp, + com.jacob.activeX, + com.jacob.com, + com.lowagie.text, + com.lowagie.text.factories, + com.lowagie.text.html, + com.lowagie.text.html.simpleparser, + com.lowagie.text.pdf, + com.lowagie.text.pdf.codec, + com.lowagie.text.pdf.codec.wmf, + com.lowagie.text.pdf.collection, + com.lowagie.text.pdf.crypto, + com.lowagie.text.pdf.events, + com.lowagie.text.pdf.fonts, + com.lowagie.text.pdf.hyphenation, + com.lowagie.text.pdf.interfaces, + com.lowagie.text.pdf.internal, + com.lowagie.text.rtf, + com.lowagie.text.rtf.direct, + com.lowagie.text.rtf.document, + com.lowagie.text.rtf.document.output, + com.lowagie.text.rtf.field, + com.lowagie.text.rtf.graphic, + com.lowagie.text.rtf.headerfooter, + com.lowagie.text.rtf.list, + com.lowagie.text.rtf.style, + com.lowagie.text.rtf.table, + com.lowagie.text.rtf.text, + com.lowagie.text.xml, + com.lowagie.text.xml.simpleparser, + com.lowagie.text.xml.xmp, + com.lowagie.tools, + com.mysql.jdbc, + com.mysql.jdbc.exceptions, + com.mysql.jdbc.integration.c3p0, + com.mysql.jdbc.integration.jboss, + com.mysql.jdbc.jdbc2.optional, + com.mysql.jdbc.log, + com.mysql.jdbc.profiler, + com.mysql.jdbc.util, + com.spire.barcode, + com.spire.barcode.implementation, + com.spire.barcode.implementation.generator, + com.spire.barcode.implementation.generator.encoder, + com.spire.barcode.implementation.generator.generation, + com.spire.barcode.implementation.scanner.reader, + com.spire.barcode.implementation.scanner.reader.detector, + com.spire.compression, + com.spire.data.table, + com.spire.data.table.common, + com.spire.doc, + com.spire.doc.collections, + com.spire.doc.core, + com.spire.doc.documents, + com.spire.doc.documents.markup, + com.spire.doc.documents.rendering, + com.spire.doc.documents.xml, + com.spire.doc.fields, + com.spire.doc.fields.barcode, + com.spire.doc.fields.barcode.implementation, + com.spire.doc.fields.barcode.implementation.generator, + com.spire.doc.fields.barcode.implementation.generator.encoder, + com.spire.doc.fields.barcode.implementation.generator.generation, + com.spire.doc.fields.omath, + com.spire.doc.fields.shape, + com.spire.doc.formatting, + com.spire.doc.formatting.revisions, + com.spire.doc.interfaces, + com.spire.doc.reporting, + com.spire.license, + com.spire.ms.Printing, + com.spire.ms.System, + com.spire.ms.System.Collections, + com.spire.ms.System.Collections.Generic, + com.spire.ms.System.Collections.ObjectModel, + com.spire.ms.System.Collections.Specialized, + com.spire.ms.System.Diagnostics, + com.spire.ms.System.Reflection, + com.spire.ms.System.Security.Cryptography, + com.spire.ms.System.Security.Cryptography.X509Certificates, + com.spire.ms.System.Xml, + com.spire.ms.charsets, + com.spire.ms.charsets.euc_kr, + com.spire.ms.charsets.iso_8859_1, + com.spire.ms.charsets.iso_8859_8, + com.spire.ms.charsets.ms_936, + com.spire.ms.charsets.utf_7, + com.spire.ms.core.System.Security.Cryptography.X509Certificates, + com.spire.ms.imagecodecs.bmp.spi, + com.spire.ms.imagecodecs.gif.spi, + com.spire.ms.imagecodecs.ico.spi, + com.spire.ms.imagecodecs.jpeg.spi, + com.spire.ms.imagecodecs.png.spi, + com.spire.ms.imagecodecs.tiff.spi, + com.spire.ms.lang, + com.spire.office.packages, + com.spire.pdf, + com.spire.pdf.actions, + com.spire.pdf.annotations, + com.spire.pdf.annotations.appearance, + com.spire.pdf.attachments, + com.spire.pdf.automaticfields, + com.spire.pdf.barcode, + com.spire.pdf.bookmarks, + com.spire.pdf.collections, + com.spire.pdf.colorspace, + com.spire.pdf.conversion, + com.spire.pdf.exporting, + com.spire.pdf.exporting.text, + com.spire.pdf.exporting.xps.schema, + com.spire.pdf.fields, + com.spire.pdf.general, + com.spire.pdf.general.find, + com.spire.pdf.general.paper.drawing.fonts, + com.spire.pdf.general.paper.drawing.ps, + com.spire.pdf.general.paper.font.common, + com.spire.pdf.general.paper.font.postscript.path, + com.spire.pdf.general.paper.font.rendering.hinting, + com.spire.pdf.general.paper.font.ttf.internals, + com.spire.pdf.general.paper.font.type1.internals, + com.spire.pdf.general.paper.font.type1.internals.parsing.objects, + com.spire.pdf.graphics, + com.spire.pdf.graphics.fonts, + com.spire.pdf.graphics.layer, + com.spire.pdf.grid, + com.spire.pdf.htmlconverter, + com.spire.pdf.htmlconverter.qt, + com.spire.pdf.interfacess, + com.spire.pdf.lists, + com.spire.pdf.primitives, + com.spire.pdf.security, + com.spire.pdf.tables, + com.spire.pdf.tables.table, + com.spire.pdf.tables.table.common, + com.spire.pdf.tables.table.convert, + com.spire.pdf.tables.table.delegate, + com.spire.pdf.widget, + com.spire.pdf.xmp, + com.spire.presentation, + com.spire.presentation.charts, + com.spire.presentation.charts.entity, + com.spire.presentation.collections, + com.spire.presentation.converter.cells.charts.charts2003.general, + com.spire.presentation.converter.cells.charts.charts2007.general, + com.spire.presentation.converter.cells.charts.chartscommon, + com.spire.presentation.converter.entity.drawing, + com.spire.presentation.converter.openoffice, + com.spire.presentation.converter.openxml, + com.spire.presentation.converter.pptxml.openxml, + com.spire.presentation.diagrams, + com.spire.presentation.diagrams.colors, + com.spire.presentation.diagrams.data, + com.spire.presentation.diagrams.layout, + com.spire.presentation.diagrams.style, + com.spire.presentation.drawing, + com.spire.presentation.drawing.animation, + com.spire.presentation.drawing.timeline, + com.spire.presentation.drawing.transition, + com.spire.xls, + com.spire.xls.charts, + com.spire.xls.collections, + com.spire.xls.core, + com.spire.xls.core.converter, + com.spire.xls.core.converter.exporting, + com.spire.xls.core.converter.rendering.chart.charts.common, + com.spire.xls.core.converter.rendering.chart.charts.xlscharts.general, + com.spire.xls.core.converter.rendering.chart.charts.xlsxcharts.general, + com.spire.xls.core.converter.rendering.chart.shapes.xlsshaps.general, + com.spire.xls.core.converter.rendering.chart.shapes.xlsshaps.general.gradient, + com.spire.xls.core.converter.rendering.chart.shapes.xlsxshaps.general, + com.spire.xls.core.converter.rendering.chart.shapes.xlsxshaps.general.gradient, + com.spire.xls.core.converter.spreadsheet, + com.spire.xls.core.converter.spreadsheet.autofilter, + com.spire.xls.core.converter.spreadsheet.charts, + com.spire.xls.core.converter.spreadsheet.conditionalformatting, + com.spire.xls.core.converter.spreadsheet.conditionalformatting.xlsx, + com.spire.xls.core.converter.spreadsheet.excelstyle, + com.spire.xls.core.converter.spreadsheet.extensions, + com.spire.xls.core.converter.spreadsheet.formulaop, + com.spire.xls.core.converter.spreadsheet.pagesetup, + com.spire.xls.core.converter.spreadsheet.pivottable, + com.spire.xls.core.converter.spreadsheet.query, + com.spire.xls.core.converter.spreadsheet.revision, + com.spire.xls.core.converter.spreadsheet.shapes, + com.spire.xls.core.converter.spreadsheet.shapes.msodrawing, + com.spire.xls.core.converter.spreadsheet.sparkline, + com.spire.xls.core.converter.spreadsheet.xmlmapping, + com.spire.xls.core.converter.tables, + com.spire.xls.core.interfaces, + com.spire.xls.core.interfacess, + com.spire.xls.core.spreadsheet, + com.spire.xls.core.spreadsheet.autofilter, + com.spire.xls.core.spreadsheet.charts, + com.spire.xls.core.spreadsheet.collections, + com.spire.xls.core.spreadsheet.conditionalformatting, + com.spire.xls.core.spreadsheet.pivottables, + com.spire.xls.core.spreadsheet.shapes, + com.spire.xls.core.spreadsheet.sorting, + com.sun.activation.registries, + com.sun.activation.viewers, + com.sun.codemodel, + com.sun.codemodel.fmt, + com.sun.codemodel.util, + com.sun.codemodel.writer, + com.sun.dtdparser, + com.sun.istack, + com.sun.istack.localization, + com.sun.istack.tools, + com.sun.istack.ws, + com.sun.mail.handlers, + com.sun.mail.iap, + com.sun.mail.imap, + com.sun.mail.imap.protocol, + com.sun.mail.pop3, + com.sun.mail.smtp, + com.sun.mail.util, + com.sun.org.apache.xml.internal.resolver, + com.sun.org.apache.xml.internal.resolver.helpers, + com.sun.org.apache.xml.internal.resolver.readers, + com.sun.org.apache.xml.internal.resolver.tools, + com.sun.tools.jxc, + com.sun.tools.jxc.apt, + com.sun.tools.jxc.gen.config, + com.sun.tools.jxc.model.nav, + com.sun.tools.resourcegen, + com.sun.tools.ws, + com.sun.tools.ws.ant, + com.sun.tools.ws.api, + com.sun.tools.ws.api.wsdl, + com.sun.tools.ws.processor, + com.sun.tools.ws.processor.generator, + com.sun.tools.ws.processor.model, + com.sun.tools.ws.processor.model.exporter, + com.sun.tools.ws.processor.model.java, + com.sun.tools.ws.processor.model.jaxb, + com.sun.tools.ws.processor.modeler, + com.sun.tools.ws.processor.modeler.annotation, + com.sun.tools.ws.processor.modeler.wsdl, + com.sun.tools.ws.processor.util, + com.sun.tools.ws.resources, + com.sun.tools.ws.spi, + com.sun.tools.ws.util, + com.sun.tools.ws.util.xml, + com.sun.tools.ws.wscompile, + com.sun.tools.ws.wsdl.document, + com.sun.tools.ws.wsdl.document.http, + com.sun.tools.ws.wsdl.document.jaxws, + com.sun.tools.ws.wsdl.document.mime, + com.sun.tools.ws.wsdl.document.schema, + com.sun.tools.ws.wsdl.document.soap, + com.sun.tools.ws.wsdl.framework, + com.sun.tools.ws.wsdl.parser, + com.sun.tools.xjc, + com.sun.tools.xjc.addon.at_generated, + com.sun.tools.xjc.addon.code_injector, + com.sun.tools.xjc.addon.episode, + com.sun.tools.xjc.addon.locator, + com.sun.tools.xjc.addon.sync, + com.sun.tools.xjc.api, + com.sun.tools.xjc.api.impl.j2s, + com.sun.tools.xjc.api.impl.s2j, + com.sun.tools.xjc.api.util, + com.sun.tools.xjc.generator.annotation.ri, + com.sun.tools.xjc.generator.annotation.spec, + com.sun.tools.xjc.generator.bean, + com.sun.tools.xjc.generator.bean.field, + com.sun.tools.xjc.generator.util, + com.sun.tools.xjc.model, + com.sun.tools.xjc.model.nav, + com.sun.tools.xjc.outline, + com.sun.tools.xjc.reader, + com.sun.tools.xjc.reader.dtd, + com.sun.tools.xjc.reader.dtd.bindinfo, + com.sun.tools.xjc.reader.gbind, + com.sun.tools.xjc.reader.internalizer, + com.sun.tools.xjc.reader.relaxng, + com.sun.tools.xjc.reader.xmlschema, + com.sun.tools.xjc.reader.xmlschema.bindinfo, + com.sun.tools.xjc.reader.xmlschema.ct, + com.sun.tools.xjc.reader.xmlschema.parser, + com.sun.tools.xjc.runtime, + com.sun.tools.xjc.util, + com.sun.tools.xjc.writer, + com.sun.xml.bind, + com.sun.xml.bind.annotation, + com.sun.xml.bind.api, + com.sun.xml.bind.api.impl, + com.sun.xml.bind.marshaller, + com.sun.xml.bind.unmarshaller, + com.sun.xml.bind.util, + com.sun.xml.bind.v2, + com.sun.xml.bind.v2.bytecode, + com.sun.xml.bind.v2.model.annotation, + com.sun.xml.bind.v2.model.core, + com.sun.xml.bind.v2.model.impl, + com.sun.xml.bind.v2.model.nav, + com.sun.xml.bind.v2.model.runtime, + com.sun.xml.bind.v2.runtime, + com.sun.xml.bind.v2.runtime.output, + com.sun.xml.bind.v2.runtime.property, + com.sun.xml.bind.v2.runtime.reflect, + com.sun.xml.bind.v2.runtime.reflect.opt, + com.sun.xml.bind.v2.runtime.unmarshaller, + com.sun.xml.bind.v2.schemagen, + com.sun.xml.bind.v2.schemagen.episode, + com.sun.xml.bind.v2.schemagen.xmlschema, + com.sun.xml.bind.v2.util, + com.sun.xml.dtdparser, + com.sun.xml.txw2, + com.sun.xml.txw2.annotation, + com.sun.xml.txw2.output, + com.sun.xml.xsom, + com.sun.xml.xsom.impl, + com.sun.xml.xsom.impl.parser, + com.sun.xml.xsom.impl.parser.state, + com.sun.xml.xsom.impl.scd, + com.sun.xml.xsom.impl.util, + com.sun.xml.xsom.parser, + com.sun.xml.xsom.util, + com.sun.xml.xsom.visitor, + de.hunsicker.io, + de.hunsicker.jalopy, + de.hunsicker.jalopy.language, + de.hunsicker.jalopy.language.antlr, + de.hunsicker.jalopy.plugin, + de.hunsicker.jalopy.prefs, + de.hunsicker.jalopy.printer, + de.hunsicker.jalopy.storage, + de.hunsicker.jalopy.swing, + de.hunsicker.jalopy.swing.syntax, + de.hunsicker.swing, + de.hunsicker.swing.util, + de.hunsicker.util, + de.hunsicker.util.concurrent, + java_cup.runtime, + javax.activation, + javax.annotation, + javax.annotation.security, + javax.jws, + javax.jws.soap, + javax.mail, + javax.mail.event, + javax.mail.internet, + javax.mail.search, + javax.mail.util, + javax.transaction, + javax.transaction.xa, + javax.ws.rs, + javax.ws.rs.core, + javax.ws.rs.ext, + javax.wsdl, + javax.wsdl.extensions, + javax.wsdl.extensions.http, + javax.wsdl.extensions.mime, + javax.wsdl.extensions.schema, + javax.wsdl.extensions.soap, + javax.wsdl.extensions.soap12, + javax.wsdl.factory, + javax.wsdl.xml, + javax.xml.bind, + javax.xml.bind.annotation, + javax.xml.bind.annotation.adapters, + javax.xml.bind.attachment, + javax.xml.bind.helpers, + javax.xml.bind.util, + javax.xml.soap, + javax.xml.stream, + javax.xml.stream.events, + javax.xml.stream.util, + javax.xml.ws, + javax.xml.ws.handler, + javax.xml.ws.handler.soap, + javax.xml.ws.http, + javax.xml.ws.soap, + javax.xml.ws.spi, + javax.xml.ws.spi.http, + javax.xml.ws.wsaddressing, + net.sf.ezmorph, + net.sf.ezmorph.array, + net.sf.ezmorph.bean, + net.sf.ezmorph.object, + net.sf.ezmorph.primitive, + net.sf.ezmorph.test, + net.sf.json, + net.sf.json.filters, + net.sf.json.groovy, + net.sf.json.processors, + net.sf.json.regexp, + net.sf.json.test, + net.sf.json.util, + net.sf.json.xml, + oracle.core.lmx, + oracle.core.lvf, + oracle.jdbc, + oracle.jdbc.aq, + oracle.jdbc.babelfish, + oracle.jdbc.connector, + oracle.jdbc.dcn, + oracle.jdbc.diagnostics, + oracle.jdbc.driver, + oracle.jdbc.internal, + oracle.jdbc.oci, + oracle.jdbc.oracore, + oracle.jdbc.pool, + oracle.jdbc.proxy, + oracle.jdbc.proxy.annotation, + oracle.jdbc.replay, + oracle.jdbc.replay.driver, + oracle.jdbc.replay.internal, + oracle.jdbc.rowset, + oracle.jdbc.util, + oracle.jdbc.xa, + oracle.jdbc.xa.client, + oracle.jpub.runtime, + oracle.net.ano, + oracle.net.aso, + oracle.net.jdbc.TNSAddress, + oracle.net.jdbc.nl, + oracle.net.jdbc.nl.mesg, + oracle.net.jndi, + oracle.net.ns, + oracle.net.nt, + oracle.net.resolver, + oracle.security.o3logon, + oracle.security.o5logon, + oracle.sql, + oracle.sql.converter, + org.apache.axiom.attachments, + org.apache.axiom.attachments.impl, + org.apache.axiom.attachments.lifecycle, + org.apache.axiom.attachments.lifecycle.impl, + org.apache.axiom.attachments.utils, + org.apache.axiom.ext.activation, + org.apache.axiom.ext.io, + org.apache.axiom.ext.stax, + org.apache.axiom.ext.stax.datahandler, + org.apache.axiom.mime, + org.apache.axiom.mime.impl.axiom, + org.apache.axiom.mime.impl.javamail, + org.apache.axiom.om, + org.apache.axiom.om.ds, + org.apache.axiom.om.ds.custombuilder, + org.apache.axiom.om.impl, + org.apache.axiom.om.impl.builder, + org.apache.axiom.om.impl.dom, + org.apache.axiom.om.impl.dom.factory, + org.apache.axiom.om.impl.dom.jaxp, + org.apache.axiom.om.impl.exception, + org.apache.axiom.om.impl.jaxp, + org.apache.axiom.om.impl.llom, + org.apache.axiom.om.impl.llom.factory, + org.apache.axiom.om.impl.llom.util, + org.apache.axiom.om.impl.serialize, + org.apache.axiom.om.impl.traverse, + org.apache.axiom.om.impl.util, + org.apache.axiom.om.util, + org.apache.axiom.om.xpath, + org.apache.axiom.osgi, + org.apache.axiom.soap, + org.apache.axiom.soap.impl.builder, + org.apache.axiom.soap.impl.dom, + org.apache.axiom.soap.impl.dom.factory, + org.apache.axiom.soap.impl.dom.soap11, + org.apache.axiom.soap.impl.dom.soap12, + org.apache.axiom.soap.impl.llom, + org.apache.axiom.soap.impl.llom.soap11, + org.apache.axiom.soap.impl.llom.soap12, + org.apache.axiom.util, + org.apache.axiom.util.activation, + org.apache.axiom.util.base64, + org.apache.axiom.util.blob, + org.apache.axiom.util.namespace, + org.apache.axiom.util.sax, + org.apache.axiom.util.stax, + org.apache.axiom.util.stax.debug, + org.apache.axiom.util.stax.dialect, + org.apache.axiom.util.stax.wrapper, + org.apache.axiom.util.stax.xop, + org.apache.axis2, + org.apache.axis2.addressing, + org.apache.axis2.addressing.i18n, + org.apache.axis2.addressing.metadata, + org.apache.axis2.addressing.wsdl, + org.apache.axis2.builder, + org.apache.axis2.builder.unknowncontent, + org.apache.axis2.classloader, + org.apache.axis2.client, + org.apache.axis2.client.async, + org.apache.axis2.clustering, + org.apache.axis2.clustering.control, + org.apache.axis2.clustering.control.wka, + org.apache.axis2.clustering.management, + org.apache.axis2.clustering.management.commands, + org.apache.axis2.clustering.state, + org.apache.axis2.clustering.state.commands, + org.apache.axis2.clustering.tribes, + org.apache.axis2.context, + org.apache.axis2.context.externalize, + org.apache.axis2.corba.deployer, + org.apache.axis2.corba.exceptions, + org.apache.axis2.corba.idl, + org.apache.axis2.corba.idl.parser, + org.apache.axis2.corba.idl.types, + org.apache.axis2.corba.idl.values, + org.apache.axis2.corba.receivers, + org.apache.axis2.databinding, + org.apache.axis2.databinding.i18n, + org.apache.axis2.databinding.typemapping, + org.apache.axis2.databinding.types, + org.apache.axis2.databinding.types.soapencoding, + org.apache.axis2.databinding.types.xsd, + org.apache.axis2.databinding.utils, + org.apache.axis2.databinding.utils.reader, + org.apache.axis2.databinding.utils.writer, + org.apache.axis2.dataretrieval, + org.apache.axis2.dataretrieval.client, + org.apache.axis2.datasource, + org.apache.axis2.datasource.jaxb, + org.apache.axis2.deployment, + org.apache.axis2.deployment.repository.util, + org.apache.axis2.deployment.resolver, + org.apache.axis2.deployment.scheduler, + org.apache.axis2.deployment.util, + org.apache.axis2.description, + org.apache.axis2.description.java2wsdl, + org.apache.axis2.description.java2wsdl.bytecode, + org.apache.axis2.dispatchers, + org.apache.axis2.engine, + org.apache.axis2.extensions.spring.receivers, + org.apache.axis2.fastinfoset, + org.apache.axis2.handlers, + org.apache.axis2.i18n, + org.apache.axis2.java.security, + org.apache.axis2.jaxbri, + org.apache.axis2.jaxrs, + org.apache.axis2.jaxws, + org.apache.axis2.jaxws.addressing, + org.apache.axis2.jaxws.addressing.factory, + org.apache.axis2.jaxws.addressing.factory.impl, + org.apache.axis2.jaxws.addressing.migrator, + org.apache.axis2.jaxws.addressing.util, + org.apache.axis2.jaxws.api, + org.apache.axis2.jaxws.binding, + org.apache.axis2.jaxws.catalog, + org.apache.axis2.jaxws.catalog.impl, + org.apache.axis2.jaxws.client, + org.apache.axis2.jaxws.client.async, + org.apache.axis2.jaxws.client.config, + org.apache.axis2.jaxws.client.dispatch, + org.apache.axis2.jaxws.client.proxy, + org.apache.axis2.jaxws.common.config, + org.apache.axis2.jaxws.context, + org.apache.axis2.jaxws.context.factory, + org.apache.axis2.jaxws.context.listener, + org.apache.axis2.jaxws.context.utils, + org.apache.axis2.jaxws.core, + org.apache.axis2.jaxws.core.controller, + org.apache.axis2.jaxws.core.controller.impl, + org.apache.axis2.jaxws.core.util, + org.apache.axis2.jaxws.description, + org.apache.axis2.jaxws.description.builder, + org.apache.axis2.jaxws.description.builder.converter, + org.apache.axis2.jaxws.description.impl, + org.apache.axis2.jaxws.description.validator, + org.apache.axis2.jaxws.description.xml.handler, + org.apache.axis2.jaxws.dispatchers, + org.apache.axis2.jaxws.feature, + org.apache.axis2.jaxws.framework, + org.apache.axis2.jaxws.handler, + org.apache.axis2.jaxws.handler.factory, + org.apache.axis2.jaxws.handler.factory.impl, + org.apache.axis2.jaxws.handler.impl, + org.apache.axis2.jaxws.handler.lifecycle.factory, + org.apache.axis2.jaxws.handler.lifecycle.impl, + org.apache.axis2.jaxws.i18n, + org.apache.axis2.jaxws.injection, + org.apache.axis2.jaxws.lifecycle, + org.apache.axis2.jaxws.marshaller, + org.apache.axis2.jaxws.marshaller.factory, + org.apache.axis2.jaxws.marshaller.impl.alt, + org.apache.axis2.jaxws.message, + org.apache.axis2.jaxws.message.attachments, + org.apache.axis2.jaxws.message.databinding, + org.apache.axis2.jaxws.message.databinding.impl, + org.apache.axis2.jaxws.message.factory, + org.apache.axis2.jaxws.message.impl, + org.apache.axis2.jaxws.message.util, + org.apache.axis2.jaxws.message.util.impl, + org.apache.axis2.jaxws.registry, + org.apache.axis2.jaxws.runtime.description.injection, + org.apache.axis2.jaxws.runtime.description.injection.impl, + org.apache.axis2.jaxws.runtime.description.marshal, + org.apache.axis2.jaxws.runtime.description.marshal.impl, + org.apache.axis2.jaxws.server, + org.apache.axis2.jaxws.server.config, + org.apache.axis2.jaxws.server.dispatcher, + org.apache.axis2.jaxws.server.dispatcher.factory, + org.apache.axis2.jaxws.server.endpoint, + org.apache.axis2.jaxws.server.endpoint.injection, + org.apache.axis2.jaxws.server.endpoint.injection.factory, + org.apache.axis2.jaxws.server.endpoint.injection.impl, + org.apache.axis2.jaxws.server.endpoint.lifecycle, + org.apache.axis2.jaxws.server.endpoint.lifecycle.factory, + org.apache.axis2.jaxws.server.endpoint.lifecycle.factory.impl, + org.apache.axis2.jaxws.server.endpoint.lifecycle.impl, + org.apache.axis2.jaxws.spi, + org.apache.axis2.jaxws.spi.handler, + org.apache.axis2.jaxws.spi.migrator, + org.apache.axis2.jaxws.util, + org.apache.axis2.jaxws.utility, + org.apache.axis2.jaxws.wrapper, + org.apache.axis2.jaxws.wrapper.impl, + org.apache.axis2.jaxws.wsdl, + org.apache.axis2.jaxws.wsdl.impl, + org.apache.axis2.jibx, + org.apache.axis2.json, + org.apache.axis2.jsr181, + org.apache.axis2.metadata.factory, + org.apache.axis2.metadata.registry, + org.apache.axis2.metadata.resource, + org.apache.axis2.metadata.resource.impl, + org.apache.axis2.mex, + org.apache.axis2.mex.om, + org.apache.axis2.mex.util, + org.apache.axis2.modules, + org.apache.axis2.namespace, + org.apache.axis2.phaseresolver, + org.apache.axis2.policy.builders, + org.apache.axis2.policy.model, + org.apache.axis2.receivers, + org.apache.axis2.rpc.client, + org.apache.axis2.rpc.receivers, + org.apache.axis2.rpc.receivers.ejb, + org.apache.axis2.saaj, + org.apache.axis2.saaj.util, + org.apache.axis2.schema, + org.apache.axis2.schema.i18n, + org.apache.axis2.schema.typemap, + org.apache.axis2.schema.util, + org.apache.axis2.schema.writer, + org.apache.axis2.service, + org.apache.axis2.soapmonitor.applet, + org.apache.axis2.soapmonitor.servlet, + org.apache.axis2.tool.ant, + org.apache.axis2.transaction, + org.apache.axis2.transport, + org.apache.axis2.transport.http, + org.apache.axis2.transport.http.server, + org.apache.axis2.transport.http.util, + org.apache.axis2.transport.java, + org.apache.axis2.transport.local, + org.apache.axis2.util, + org.apache.axis2.util.threadpool, + org.apache.axis2.wsdl, + org.apache.axis2.wsdl.codegen, + org.apache.axis2.wsdl.codegen.emitter, + org.apache.axis2.wsdl.codegen.emitter.jaxws, + org.apache.axis2.wsdl.codegen.extension, + org.apache.axis2.wsdl.codegen.schema, + org.apache.axis2.wsdl.codegen.schema.exception, + org.apache.axis2.wsdl.codegen.writer, + org.apache.axis2.wsdl.databinding, + org.apache.axis2.wsdl.i18n, + org.apache.axis2.wsdl.util, + org.apache.axis2.xmlbeans, + org.apache.bcel, + org.apache.bcel.classfile, + org.apache.bcel.generic, + org.apache.bcel.util, + org.apache.bcel.verifier, + org.apache.bcel.verifier.exc, + org.apache.bcel.verifier.statics, + org.apache.bcel.verifier.structurals, + org.apache.catalina.tribes, + org.apache.catalina.tribes.group, + org.apache.catalina.tribes.group.interceptors, + org.apache.catalina.tribes.io, + org.apache.catalina.tribes.membership, + org.apache.catalina.tribes.tipis, + org.apache.catalina.tribes.transport, + org.apache.catalina.tribes.transport.bio, + org.apache.catalina.tribes.transport.bio.util, + org.apache.catalina.tribes.transport.nio, + org.apache.catalina.tribes.util, + org.apache.commons.beanutils, + org.apache.commons.beanutils.converters, + org.apache.commons.beanutils.locale, + org.apache.commons.beanutils.locale.converters, + org.apache.commons.cli, + org.apache.commons.codec, + org.apache.commons.codec.binary, + org.apache.commons.codec.digest, + org.apache.commons.codec.language, + org.apache.commons.codec.net, + org.apache.commons.collections, + org.apache.commons.collections.bag, + org.apache.commons.collections.bidimap, + org.apache.commons.collections.buffer, + org.apache.commons.collections.collection, + org.apache.commons.collections.comparators, + org.apache.commons.collections.functors, + org.apache.commons.collections.iterators, + org.apache.commons.collections.keyvalue, + org.apache.commons.collections.list, + org.apache.commons.collections.map, + org.apache.commons.collections.set, + org.apache.commons.fileupload, + org.apache.commons.fileupload.disk, + org.apache.commons.fileupload.portlet, + org.apache.commons.fileupload.servlet, + org.apache.commons.fileupload.util, + org.apache.commons.httpclient, + org.apache.commons.httpclient.auth, + org.apache.commons.httpclient.cookie, + org.apache.commons.httpclient.methods, + org.apache.commons.httpclient.methods.multipart, + org.apache.commons.httpclient.params, + org.apache.commons.httpclient.protocol, + org.apache.commons.httpclient.util, + org.apache.commons.io, + org.apache.commons.io.comparator, + org.apache.commons.io.filefilter, + org.apache.commons.io.input, + org.apache.commons.io.output, + org.apache.commons.lang, + org.apache.commons.lang.builder, + org.apache.commons.lang.enum, + org.apache.commons.lang.enums, + org.apache.commons.lang.exception, + org.apache.commons.lang.math, + org.apache.commons.lang.mutable, + org.apache.commons.lang.text, + org.apache.commons.lang.time, + org.apache.commons.logging, + org.apache.commons.logging.impl, + org.apache.fontbox, + org.apache.fontbox.afm, + org.apache.fontbox.cff, + org.apache.fontbox.cmap, + org.apache.fontbox.encoding, + org.apache.fontbox.pfb, + org.apache.fontbox.ttf, + org.apache.fontbox.type1, + org.apache.fontbox.util, + org.apache.fontbox.util.autodetect, + org.apache.geronimo.osgi.locator, + org.apache.james.mime4j, + org.apache.james.mime4j.codec, + org.apache.james.mime4j.io, + org.apache.james.mime4j.parser, + org.apache.james.mime4j.stream, + org.apache.james.mime4j.util, + org.apache.juli, + org.apache.juli.logging, + org.apache.log4j, + org.apache.log4j.chainsaw, + org.apache.log4j.config, + org.apache.log4j.helpers, + org.apache.log4j.jdbc, + org.apache.log4j.jmx, + org.apache.log4j.lf5, + org.apache.log4j.lf5.util, + org.apache.log4j.lf5.viewer, + org.apache.log4j.lf5.viewer.categoryexplorer, + org.apache.log4j.lf5.viewer.configure, + org.apache.log4j.net, + org.apache.log4j.nt, + org.apache.log4j.or, + org.apache.log4j.or.jms, + org.apache.log4j.or.sax, + org.apache.log4j.spi, + org.apache.log4j.varia, + org.apache.log4j.xml, + org.apache.neethi, + org.apache.neethi.builders, + org.apache.neethi.builders.converters, + org.apache.neethi.builders.xml, + org.apache.neethi.util, + org.apache.pdfbox.contentstream, + org.apache.pdfbox.contentstream.operator, + org.apache.pdfbox.contentstream.operator.color, + org.apache.pdfbox.contentstream.operator.graphics, + org.apache.pdfbox.contentstream.operator.markedcontent, + org.apache.pdfbox.contentstream.operator.state, + org.apache.pdfbox.contentstream.operator.text, + org.apache.pdfbox.cos, + org.apache.pdfbox.debugger, + org.apache.pdfbox.debugger.colorpane, + org.apache.pdfbox.debugger.flagbitspane, + org.apache.pdfbox.debugger.fontencodingpane, + org.apache.pdfbox.debugger.hexviewer, + org.apache.pdfbox.debugger.pagepane, + org.apache.pdfbox.debugger.streampane, + org.apache.pdfbox.debugger.streampane.tooltip, + org.apache.pdfbox.debugger.stringpane, + org.apache.pdfbox.debugger.treestatus, + org.apache.pdfbox.debugger.ui, + org.apache.pdfbox.debugger.ui.textsearcher, + org.apache.pdfbox.filter, + org.apache.pdfbox.io, + org.apache.pdfbox.multipdf, + org.apache.pdfbox.pdfparser, + org.apache.pdfbox.pdfwriter, + org.apache.pdfbox.pdmodel, + org.apache.pdfbox.pdmodel.common, + org.apache.pdfbox.pdmodel.common.filespecification, + org.apache.pdfbox.pdmodel.common.function, + org.apache.pdfbox.pdmodel.common.function.type4, + org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure, + org.apache.pdfbox.pdmodel.documentinterchange.markedcontent, + org.apache.pdfbox.pdmodel.documentinterchange.prepress, + org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf, + org.apache.pdfbox.pdmodel.encryption, + org.apache.pdfbox.pdmodel.fdf, + org.apache.pdfbox.pdmodel.font, + org.apache.pdfbox.pdmodel.font.encoding, + org.apache.pdfbox.pdmodel.graphics, + org.apache.pdfbox.pdmodel.graphics.blend, + org.apache.pdfbox.pdmodel.graphics.color, + org.apache.pdfbox.pdmodel.graphics.form, + org.apache.pdfbox.pdmodel.graphics.image, + org.apache.pdfbox.pdmodel.graphics.optionalcontent, + org.apache.pdfbox.pdmodel.graphics.pattern, + org.apache.pdfbox.pdmodel.graphics.shading, + org.apache.pdfbox.pdmodel.graphics.state, + org.apache.pdfbox.pdmodel.interactive.action, + org.apache.pdfbox.pdmodel.interactive.annotation, + org.apache.pdfbox.pdmodel.interactive.digitalsignature, + org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible, + org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination, + org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline, + org.apache.pdfbox.pdmodel.interactive.form, + org.apache.pdfbox.pdmodel.interactive.measurement, + org.apache.pdfbox.pdmodel.interactive.pagenavigation, + org.apache.pdfbox.pdmodel.interactive.viewerpreferences, + org.apache.pdfbox.preflight, + org.apache.pdfbox.preflight.action, + org.apache.pdfbox.preflight.annotation, + org.apache.pdfbox.preflight.annotation.pdfa, + org.apache.pdfbox.preflight.content, + org.apache.pdfbox.preflight.exception, + org.apache.pdfbox.preflight.font, + org.apache.pdfbox.preflight.font.container, + org.apache.pdfbox.preflight.font.descriptor, + org.apache.pdfbox.preflight.font.util, + org.apache.pdfbox.preflight.graphic, + org.apache.pdfbox.preflight.metadata, + org.apache.pdfbox.preflight.parser, + org.apache.pdfbox.preflight.process, + org.apache.pdfbox.preflight.process.reflect, + org.apache.pdfbox.preflight.utils, + org.apache.pdfbox.preflight.xobject, + org.apache.pdfbox.printing, + org.apache.pdfbox.rendering, + org.apache.pdfbox.text, + org.apache.pdfbox.tools, + org.apache.pdfbox.tools.imageio, + org.apache.pdfbox.util, + org.apache.pdfbox.util.filetypedetector, + org.apache.regexp, + org.apache.woden, + org.apache.woden.internal, + org.apache.woden.internal.resolver, + org.apache.woden.internal.schema, + org.apache.woden.internal.util, + org.apache.woden.internal.util.dom, + org.apache.woden.internal.wsdl20, + org.apache.woden.internal.wsdl20.assertions, + org.apache.woden.internal.wsdl20.extensions, + org.apache.woden.internal.wsdl20.extensions.http, + org.apache.woden.internal.wsdl20.extensions.rpc, + org.apache.woden.internal.wsdl20.extensions.soap, + org.apache.woden.internal.wsdl20.validation, + org.apache.woden.internal.xml, + org.apache.woden.internal.xpointer, + org.apache.woden.resolver, + org.apache.woden.schema, + org.apache.woden.types, + org.apache.woden.wsdl20, + org.apache.woden.wsdl20.enumeration, + org.apache.woden.wsdl20.extensions, + org.apache.woden.wsdl20.extensions.http, + org.apache.woden.wsdl20.extensions.rpc, + org.apache.woden.wsdl20.extensions.soap, + org.apache.woden.wsdl20.fragids, + org.apache.woden.wsdl20.validation, + org.apache.woden.wsdl20.xml, + org.apache.woden.xml, + org.apache.woden.xpointer, + org.apache.ws.commons.schema, + org.apache.ws.commons.schema.constants, + org.apache.ws.commons.schema.extensions, + org.apache.ws.commons.schema.resolver, + org.apache.ws.commons.schema.tools, + org.apache.ws.commons.schema.utils, + org.apache.ws.java2wsdl, + org.apache.ws.java2wsdl.utils, + org.apache.xalan, + org.apache.xalan.client, + org.apache.xalan.extensions, + org.apache.xalan.lib, + org.apache.xalan.lib.sql, + org.apache.xalan.processor, + org.apache.xalan.res, + org.apache.xalan.serialize, + org.apache.xalan.templates, + org.apache.xalan.trace, + org.apache.xalan.transformer, + org.apache.xalan.xslt, + org.apache.xalan.xsltc, + org.apache.xalan.xsltc.cmdline, + org.apache.xalan.xsltc.cmdline.getopt, + org.apache.xalan.xsltc.compiler, + org.apache.xalan.xsltc.compiler.util, + org.apache.xalan.xsltc.dom, + org.apache.xalan.xsltc.runtime, + org.apache.xalan.xsltc.runtime.output, + org.apache.xalan.xsltc.trax, + org.apache.xalan.xsltc.util, + org.apache.xml.dtm, + org.apache.xml.dtm.ref, + org.apache.xml.dtm.ref.dom2dtm, + org.apache.xml.dtm.ref.sax2dtm, + org.apache.xml.res, + org.apache.xml.resolver, + org.apache.xml.resolver.apps, + org.apache.xml.resolver.helpers, + org.apache.xml.resolver.readers, + org.apache.xml.resolver.tools, + org.apache.xml.serializer, + org.apache.xml.serializer.utils, + org.apache.xml.utils, + org.apache.xml.utils.res, + org.apache.xmlbeans, + org.apache.xmlbeans.impl.common, + org.apache.xmlbeans.impl.config, + org.apache.xmlbeans.impl.inst2xsd, + org.apache.xmlbeans.impl.inst2xsd.util, + org.apache.xmlbeans.impl.jam, + org.apache.xmlbeans.impl.jam.annotation, + org.apache.xmlbeans.impl.jam.internal, + org.apache.xmlbeans.impl.jam.internal.classrefs, + org.apache.xmlbeans.impl.jam.internal.elements, + org.apache.xmlbeans.impl.jam.internal.javadoc, + org.apache.xmlbeans.impl.jam.internal.parser, + org.apache.xmlbeans.impl.jam.internal.reflect, + org.apache.xmlbeans.impl.jam.mutable, + org.apache.xmlbeans.impl.jam.provider, + org.apache.xmlbeans.impl.jam.visitor, + org.apache.xmlbeans.impl.jam.xml, + org.apache.xmlbeans.impl.piccolo.io, + org.apache.xmlbeans.impl.piccolo.util, + org.apache.xmlbeans.impl.piccolo.xml, + org.apache.xmlbeans.impl.regex, + org.apache.xmlbeans.impl.richParser, + org.apache.xmlbeans.impl.schema, + org.apache.xmlbeans.impl.soap, + org.apache.xmlbeans.impl.store, + org.apache.xmlbeans.impl.tool, + org.apache.xmlbeans.impl.util, + org.apache.xmlbeans.impl.validator, + org.apache.xmlbeans.impl.values, + org.apache.xmlbeans.impl.xb.ltgfmt, + org.apache.xmlbeans.impl.xb.ltgfmt.impl, + org.apache.xmlbeans.impl.xb.substwsdl, + org.apache.xmlbeans.impl.xb.substwsdl.impl, + org.apache.xmlbeans.impl.xb.xmlconfig, + org.apache.xmlbeans.impl.xb.xmlconfig.impl, + org.apache.xmlbeans.impl.xb.xmlschema, + org.apache.xmlbeans.impl.xb.xmlschema.impl, + org.apache.xmlbeans.impl.xb.xsdownload, + org.apache.xmlbeans.impl.xb.xsdownload.impl, + org.apache.xmlbeans.impl.xb.xsdschema, + org.apache.xmlbeans.impl.xb.xsdschema.impl, + org.apache.xmlbeans.impl.xsd2inst, + org.apache.xmlbeans.soap, + org.apache.xmlbeans.xml.stream, + org.apache.xmlbeans.xml.stream.events, + org.apache.xmlbeans.xml.stream.utils, + org.apache.xmpbox, + org.apache.xmpbox.schema, + org.apache.xmpbox.type, + org.apache.xmpbox.xml, + org.apache.xpath, + org.apache.xpath.axes, + org.apache.xpath.compiler, + org.apache.xpath.domapi, + org.apache.xpath.functions, + org.apache.xpath.jaxp, + org.apache.xpath.objects, + org.apache.xpath.operations, + org.apache.xpath.patterns, + org.apache.xpath.res, + org.codehaus.jettison, + org.codehaus.jettison.badgerfish, + org.codehaus.jettison.json, + org.codehaus.jettison.mapped, + org.codehaus.jettison.util, + org.codehaus.stax2, + org.codehaus.stax2.evt, + org.codehaus.stax2.io, + org.codehaus.stax2.ri, + org.codehaus.stax2.validation, + org.dom4j, + org.dom4j.bean, + org.dom4j.datatype, + org.dom4j.dom, + org.dom4j.dtd, + org.dom4j.io, + org.dom4j.jaxb, + org.dom4j.rule, + org.dom4j.rule.pattern, + org.dom4j.swing, + org.dom4j.tree, + org.dom4j.util, + org.dom4j.xpath, + org.dom4j.xpp, + org.gjt.mm.mysql, + org.jaxen, + org.jaxen.dom, + org.jaxen.dom4j, + org.jaxen.expr, + org.jaxen.expr.iter, + org.jaxen.function, + org.jaxen.function.ext, + org.jaxen.function.xslt, + org.jaxen.javabean, + org.jaxen.jdom, + org.jaxen.pattern, + org.jaxen.saxpath, + org.jaxen.saxpath.base, + org.jaxen.saxpath.helpers, + org.jaxen.util, + org.jaxen.xom, + org.jdom, + org.jdom.adapters, + org.jdom.filter, + org.jdom.input, + org.jdom.output, + org.jdom.transform, + org.jdom.xpath, + org.jibx.binding, + org.jibx.binding.ant, + org.jibx.binding.classes, + org.jibx.binding.def, + org.jibx.binding.model, + org.jibx.binding.util, + org.jibx.runtime, + org.jibx.runtime.impl, + org.jibx.util, + org.kohsuke.rngom.ast.builder, + org.kohsuke.rngom.ast.om, + org.kohsuke.rngom.ast.util, + org.kohsuke.rngom.binary, + org.kohsuke.rngom.binary.visitor, + org.kohsuke.rngom.digested, + org.kohsuke.rngom.dt, + org.kohsuke.rngom.dt.builtin, + org.kohsuke.rngom.nc, + org.kohsuke.rngom.parse, + org.kohsuke.rngom.parse.compact, + org.kohsuke.rngom.parse.host, + org.kohsuke.rngom.parse.xml, + org.kohsuke.rngom.util, + org.kohsuke.rngom.xml.sax, + org.kohsuke.rngom.xml.util, + org.relaxng.datatype, + org.relaxng.datatype.helpers, + org.w3c.dom, + repackage, + schemaorg_apache_xmlbeans.system.sXMLCONFIG, + schemaorg_apache_xmlbeans.system.sXMLLANG, + schemaorg_apache_xmlbeans.system.sXMLSCHEMA, + schemaorg_apache_xmlbeans.system.sXMLTOOLS, + swing2swt.layout +Import-Package: com.teamcenter.rac.schedule.common.project, + com.teamcenter.rac.schedule.project.common.dataModel, + com.teamcenter.rac.schedule.project.scheduling, + com.teamcenter.rac.schedule.project.server.RACInterface diff --git a/beifen/rb25(3.22李义) b/beifen/rb25(3.22李义) new file mode 100644 index 0000000..6cf0af5 --- /dev/null +++ b/beifen/rb25(3.22李义) @@ -0,0 +1,433 @@ +package com.connor.rb.plm.rb025; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.client.Options; +import org.apache.axis2.client.ServiceClient; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCClassService; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONArray; + +/** + * ޸ķ + */ +public class EditClassificationDialog extends AbstractAIFDialog { + + private static final long serialVersionUID = 1L; + private AbstractAIFApplication app; + private TCSession session; + private TCComponent target; + private Map propMap; + private TCClassificationService myService; + final EditClassificationDialog DIALOG = this; + private TCComponentItemRevision rev; + private int[] ids; + private String[] values; + private String[] names; + private boolean finished; + private ICSPropertyDescription[] desc; + + public EditClassificationDialog(AbstractAIFApplication app) throws TCException { + this.app = app; + this.session = (TCSession) app.getSession(); + this.myService = session.getClassificationService(); + this.target = (TCComponent) AIFUtility.getCurrentApplication().getTargetComponent(); + System.out.println(target.getType()); + System.out.println(target instanceof TCComponentItemRevision ? "" : ""); + + if (target instanceof TCComponentItemRevision) { + try { + rev = (TCComponentItemRevision) target; + boolean isAccess = session.getTCAccessControlService().checkPrivilege(rev, "WRITE"); + if (!isAccess) { + JOptionPane.showMessageDialog(this, "ûа汾޸ȨޣϵϵͳԱ", "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } + initUI(); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + MessageBox.post("ѡ汾", "", MessageBox.ERROR); + } + } + + /** + * ȡLOVʾֵ + * @param icsD + * @return + */ + public static String getClassDisplayableValue(ICSPropertyDescription icsD) { + String result = ""; + ICSKeyLov lov = icsD.getFormat().getKeyLov(); + if (lov != null) { + String[] keys = lov.getKeys(); + for (String key : keys) { + result = lov.getValueOfKey(key); + return result; + } + } + return result; + } + + private void initUI() { + this.setTitle("޸ķ"); + + JPanel rootPanel = new JPanel(); + rootPanel.setLayout(null); + rootPanel.setPreferredSize(new Dimension(600, 350)); + + Map displayMap = new LinkedHashMap(); + propMap = new HashMap(); + + try { + if (rev.getClassificationClass() != null && !"".equals(rev.getClassificationClass())) { + try { + rev.refresh(); + System.out.println("rev.getClassificationClass()=" + rev.getClassificationClass()); + TCComponentICO ico = rev.getClassificationObjects()[0]; + ICSProperty[] props = ico.getICSProperties(true); + desc = ico.getICSPropertyDescriptors(); + for (int i = 0; i < props.length; i++) { +// System.out.println(props[i].getId() + "===>" + props[i].getValue());// 30101===> + // desc.getName=Type and size series ǷԵ||| desc.getId=30101ǷID +// System.out.println("desc.getName=" + desc[i].getName() + " desc.getId=" + desc[i].getId()); + displayMap.put(props[i], desc[i]); + } + } catch (TCException e1) { + e1.printStackTrace(); + } + } else { + this.disposeDialog(); + MessageBox.post("ǰ汾δ", "", MessageBox.ERROR); + return; + } + } catch (TCException e) { + e.printStackTrace(); + } + + if (displayMap.size() == 0) { + return; + } + + JPanel content = new JPanel(); + content.setLayout(null); + content.setPreferredSize(new Dimension(600, displayMap.size() * (25 + 10))); + + int num = 0; + // ͨȡеķԣȻ + for (Entry entry : displayMap.entrySet()) { + JLabel label = new JLabel(entry.getValue().getName() + ""); + label.setBounds(10, num * 35 + 10, 100, 25); + + ICSKeyLov lov = entry.getValue().getFormat().getKeyLov(); +// ArrayList list = new ArrayList<>(); + if (lov != null) { + String[] keys = lov.getKeys(); + JComboBox combo = new JComboBox(); + combo.addItem(new ClassPropBean("", "", "")); + for (String key : keys) { + combo.addItem(new ClassPropBean(key, lov.getValueOfKey(key), "")); + } + + String v = entry.getKey().getValue(); + for (int i = 0; i < combo.getItemCount(); i++) { + if (v.equals(combo.getItemAt(i).getId())) { + combo.setSelectedIndex(i); + break; + } + } +// combo.setSelectedItem(v); +// if (!Arrays.asList(lov.getDisplayValues()).contains(v)) { +// combo.addItem(v); +// combo.setSelectedItem(v); +// } + + combo.setBounds(130, num * 35 + 10, 350, 25); + + propMap.put(entry.getValue().getName(), combo); + content.add(combo); + } else { + JTextField text = new JTextField(entry.getKey().getValue()); + text.setBounds(130, num * 35 + 10, 350, 25); + propMap.put(entry.getValue().getName(), text); + content.add(text); + } + + content.add(label); + + num++; + } + + JButton okBtn = new JButton("ȷ"); + okBtn.setBounds(40, 310, 100, 25); + okBtn.setSelected(true); + okBtn.addActionListener(ok()); + JButton cancelBtn = new JButton("ȡ"); + cancelBtn.setBounds(160, 310, 100, 25); + cancelBtn.addActionListener(cancel()); + + JScrollPane jsp = new JScrollPane(content); + jsp.getVerticalScrollBar().setUnitIncrement(16); + jsp.setBounds(0, 0, 600, 300); + jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + rootPanel.add(jsp); + rootPanel.add(okBtn); + rootPanel.add(cancelBtn); + this.add(rootPanel); + this.pack(); + this.centerToScreen(); + this.setAutoRequestFocus(true); +// this.setResizable(false); + this.setAlwaysOnTop(true); + this.showDialog(); + } + + private ActionListener ok() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + ((JButton) e.getSource()).setEnabled(false); + rev = (TCComponentItemRevision) target; + + new Thread(new Runnable() { + + @Override + public void run() { + int i = 1; + while (!DIALOG.finished) { + try { + DIALOG.setTitle("޸ķ " + StringCreateUtil.createPoint(i++ % 3)); + Thread.sleep(200); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + }).start(); + + EditClassificationDialog.this.setAlwaysOnTop(false); + if (saveClassification(rev)) { + MessageBox.post("޸ķԳɹ", "", MessageBox.ERROR); + EditClassificationDialog.this.disposeDialog(); + } else { + MessageBox.post("޸ķʧܣ", "", MessageBox.ERROR); + } + + } + }; + } + + private ActionListener cancel() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + DIALOG.disposeDialog(); + } + }; + } + + @SuppressWarnings("unchecked") + private boolean saveClassification(TCComponentItemRevision rev) { + + try { + TCComponentForm form = (TCComponentForm) rev.getRelatedComponents("IMAN_master_form_rev")[0]; + TCComponent[] status = form.getRelatedComponents("release_status_list"); + for (TCComponent comp : status) { + if (comp.getProperty("object_name").contains("ʽ")) { + JOptionPane.showMessageDialog(this, "汾ʽ޸ķ", "ʾ", JOptionPane.WARNING_MESSAGE); + return false; + } + } + TCComponentICO[] icoS = rev.getClassificationObjects(); + System.out.println("======>ȡķ:" + icoS.length); + String classID = rev.getClassificationClass(); + if (icoS == null || icoS.length == 0) { + return false; + } + for (int i = 0; i < icoS.length; i++) { + List propList = new ArrayList<>(); + TCComponentICO ico = icoS[i]; + ICSPropertyDescription[] desc = ico.getICSPropertyDescriptors(); + ICSProperty[] oldICSProps = ico.getICSProperties(true); + ids = new int[oldICSProps.length]; + values = new String[oldICSProps.length]; + names = new String[oldICSProps.length]; + for (int j = 0; j < oldICSProps.length; j++) { + ids[j] = oldICSProps[j].getId(); + if (propMap.get(desc[j].getName()) instanceof JComboBox) { + ClassPropBean bean = (ClassPropBean) ((JComboBox) propMap.get(desc[j].getName())).getSelectedItem(); + String str = bean.getId(); + values[j] = " ".equals(str) ? "" : str; + } else { + values[j] = ((JTextField) propMap.get(desc[j].getName())).getText(); + } + names[j] = desc[j].getName(); + ClassProperty prop = new ClassProperty(ids[j], values[j]); + propList.add(prop); + } + String json = objectToJson(propList); + System.out.println("classID=" + classID); + System.out.println("json=" + json); + System.out.println("ɾ..."); + try { + deleteClass(getICO(rev, classID).getUid()); + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("ͷ..."); + if (sendToClass(rev.getUid(), classID, json)) { + return true; + } else { + return false; + } + } + } catch (TCException e1) { + e1.printStackTrace(); + JOptionPane.showMessageDialog(null, e1, "", JOptionPane.ERROR_MESSAGE); + return false; + } + return true; + } + + private TCComponentICO getICO(TCComponentItemRevision rev, String classId) throws Exception { + if (rev == null || classId.equals("")) { + return null; + } + TCComponentICO[] icos = rev.getClassificationObjects(); + System.out.println(rev + " -> Ѵڷࣺ" + Arrays.toString(icos)); + int len = icos.length; + if (len == 0) { + return null; + } + TCClassificationService classService = session.getClassificationService(); + for (int i = 0; i < len; i++) { + TCComponentICO ico = icos[i]; + classService.loadICOs(new String[] { ico.getUid() }, ""); + if (ico.getClassId() == null || ico.getClassId().equals("")) { + throw new Exception("쳣ϵԱ"); + } + if (classId.equals(ico.getClassId())) { + return ico; + } + } + return null; + } + + public void deleteClass(String icoPuid) { + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + String url = JDMethodUtil.getPrefStr("Autocode_SendClassServer_URL", session);// "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("DeleteClass"); + sc.setOptions(opts); + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("DeleteClass", omNs); + OMElement value = fac.createOMElement("icoPuid", omNs); + value.setText(icoPuid); + + method.addChild(value); + + OMElement res = sc.sendReceive(method); + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { + e.printStackTrace(); + } + + } + + public boolean sendToClass(String wsoPUID, String classID, String json) { + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + String url = JDMethodUtil.getPrefStr("Autocode_SendClassServer_URL", session); + // "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("SendToClass"); + sc.setOptions(opts); + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("SendToClass", omNs); + OMElement value = fac.createOMElement("wsoPuiid", omNs); + value.setText(wsoPUID); + OMElement value1 = fac.createOMElement("classID", omNs); + value1.setText(classID); + OMElement value2 = fac.createOMElement("JsonContainer", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + value2.setText(json); + + method.addChild(value); + method.addChild(value1); + method.addChild(value2); + + OMElement res = sc.sendReceive(method); + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { +// MessageBox.post("ͷʧܣ", "", MessageBox.ERROR); + e.printStackTrace(); + return false; + } + return true; + + } + + public static String objectToJson(List props) { + String str = null; + try { + JSONArray json = JSONArray.fromObject(props);// javaתΪjson + str = json.toString();// jsonתΪַ + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("JSON =>" + str); + return str; + } +} diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..6eb89de --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1,12 @@ +/com/ +/logback.xml +/rb25(李义替换)2022.3.10 +/临时 +/临时2 +/另存 +/另存2 +/编码器 +/隶属 +/隶属2 +/隶属创建 +/项目开发子对象属性名称.xlsx diff --git a/bin/GetNumberCommand改之前 b/bin/GetNumberCommand改之前 new file mode 100644 index 0000000..92702c0 --- /dev/null +++ b/bin/GetNumberCommand改之前 @@ -0,0 +1,106 @@ +package com.connor.rb.plm.rb027; + +import java.util.Iterator; +import java.util.Map; + +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + + +public class GetNumberCommand extends AbstractAIFCommand { + private AbstractAIFApplication app; + private TCSession session; + + + public GetNumberCommand(AbstractAIFApplication app, TCSession session) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + //ȡѡж + InterfaceAIFComponent comp = app.getTargetComponent(); + + if(!(comp instanceof TCComponentItemRevision)) + { + MessageBox.post("ѡа汾", "", MessageBox.ERROR); + return; + } + + TCComponentItemRevision itemRevision = (TCComponentItemRevision) comp; + String result = sendPost("http://10.20.7.27:9889/jde/getNumber"); + System.out.println(result); + //ȡؽ + JSONObject resultJson = JSONObject.fromObject(result); + + + JSONArray jsonArray = resultJson.getJSONArray("data"); + for (int i=0; i < jsonArray.size(); i++) { + + //ȡautoNextNumber + String autoNextNumber = ""; + JSONObject jsonObject = jsonArray.getJSONObject(i); + Iterator iter = jsonObject.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry entry = (Map.Entry) iter.next(); + System.out.println(entry.getKey().toString()); + switch (entry.getKey().toString()) { + case "autoNextNumber": + System.out.println(entry.getValue().toString()); + autoNextNumber = entry.getValue().toString(); + break; + default: + break; + } + } + itemRevision.setStringProperty("rb3_spm", autoNextNumber); + itemRevision.refresh(); + MessageBox.post("ȡƷɹ", "ɹ", MessageBox.INFORMATION); + return; + } + super.executeModal(); + } + public static String sendPost(String url) { + String response = null; + + try { + CloseableHttpClient httpclient = null; + CloseableHttpResponse httpresponse = null; + try { + httpclient = HttpClients.createDefault(); + HttpGet httpGet = new HttpGet(url); + httpresponse = httpclient.execute(httpGet); + response = EntityUtils.toString(httpresponse.getEntity()); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (httpclient != null) { + httpclient.close(); + } + if (httpresponse != null) { + httpresponse.close(); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return response; + } + +} diff --git a/bin/test.class b/bin/test.class new file mode 100644 index 0000000..c324523 Binary files /dev/null and b/bin/test.class differ diff --git a/bomupadte/classes12.jar b/bomupadte/classes12.jar new file mode 100644 index 0000000..9eaf0b4 Binary files /dev/null and b/bomupadte/classes12.jar differ diff --git a/bomupadte/commons-beanutils-1.9.2.jar b/bomupadte/commons-beanutils-1.9.2.jar new file mode 100644 index 0000000..289461d Binary files /dev/null and b/bomupadte/commons-beanutils-1.9.2.jar differ diff --git a/bomupadte/commons-codec-1.10.jar b/bomupadte/commons-codec-1.10.jar new file mode 100644 index 0000000..1d7417c Binary files /dev/null and b/bomupadte/commons-codec-1.10.jar differ diff --git a/bomupadte/commons-collections-3.2.1.jar b/bomupadte/commons-collections-3.2.1.jar new file mode 100644 index 0000000..c35fa1f Binary files /dev/null and b/bomupadte/commons-collections-3.2.1.jar differ diff --git a/bomupadte/commons-dbutils-1.5.jar b/bomupadte/commons-dbutils-1.5.jar new file mode 100644 index 0000000..b0c0e12 Binary files /dev/null and b/bomupadte/commons-dbutils-1.5.jar differ diff --git a/bomupadte/commons-lang-2.6.jar b/bomupadte/commons-lang-2.6.jar new file mode 100644 index 0000000..98467d3 Binary files /dev/null and b/bomupadte/commons-lang-2.6.jar differ diff --git a/bomupadte/commons-logging-1.1.3.jar b/bomupadte/commons-logging-1.1.3.jar new file mode 100644 index 0000000..ab51254 Binary files /dev/null and b/bomupadte/commons-logging-1.1.3.jar differ diff --git a/bomupadte/commons-logging-1.1.jar b/bomupadte/commons-logging-1.1.jar new file mode 100644 index 0000000..2ff9bbd Binary files /dev/null and b/bomupadte/commons-logging-1.1.jar differ diff --git a/bomupadte/dom4j-1.6.1.jar b/bomupadte/dom4j-1.6.1.jar new file mode 100644 index 0000000..c8c4dbb Binary files /dev/null and b/bomupadte/dom4j-1.6.1.jar differ diff --git a/bomupadte/ezmorph-1.0.6.jar b/bomupadte/ezmorph-1.0.6.jar new file mode 100644 index 0000000..30fad12 Binary files /dev/null and b/bomupadte/ezmorph-1.0.6.jar differ diff --git a/bomupadte/json-lib-2.4-jdk15.jar b/bomupadte/json-lib-2.4-jdk15.jar new file mode 100644 index 0000000..68d4f3b Binary files /dev/null and b/bomupadte/json-lib-2.4-jdk15.jar differ diff --git a/bomupadte/jsr173_1.0_api.jar b/bomupadte/jsr173_1.0_api.jar new file mode 100644 index 0000000..fef9a9c Binary files /dev/null and b/bomupadte/jsr173_1.0_api.jar differ diff --git a/bomupadte/jxl_1.0.0.jar b/bomupadte/jxl_1.0.0.jar new file mode 100644 index 0000000..cb144e4 Binary files /dev/null and b/bomupadte/jxl_1.0.0.jar differ diff --git a/bomupadte/ojdbc5.jar b/bomupadte/ojdbc5.jar new file mode 100644 index 0000000..13d7feb Binary files /dev/null and b/bomupadte/ojdbc5.jar differ diff --git a/bomupadte/ojdbc6.jar b/bomupadte/ojdbc6.jar new file mode 100644 index 0000000..aacbd97 Binary files /dev/null and b/bomupadte/ojdbc6.jar differ diff --git a/bomupadte/ojdbc8.jar b/bomupadte/ojdbc8.jar new file mode 100644 index 0000000..98a1a31 Binary files /dev/null and b/bomupadte/ojdbc8.jar differ diff --git a/bomupadte/poi-3.9-20121203.jar b/bomupadte/poi-3.9-20121203.jar new file mode 100644 index 0000000..0f46288 Binary files /dev/null and b/bomupadte/poi-3.9-20121203.jar differ diff --git a/bomupadte/poi-examples-3.9-20121203.jar b/bomupadte/poi-examples-3.9-20121203.jar new file mode 100644 index 0000000..a364cc2 Binary files /dev/null and b/bomupadte/poi-examples-3.9-20121203.jar differ diff --git a/bomupadte/poi-excelant-3.9-20121203.jar b/bomupadte/poi-excelant-3.9-20121203.jar new file mode 100644 index 0000000..cb403fa Binary files /dev/null and b/bomupadte/poi-excelant-3.9-20121203.jar differ diff --git a/bomupadte/poi-ooxml-3.9-20121203.jar b/bomupadte/poi-ooxml-3.9-20121203.jar new file mode 100644 index 0000000..8792d46 Binary files /dev/null and b/bomupadte/poi-ooxml-3.9-20121203.jar differ diff --git a/bomupadte/poi-ooxml-schemas-3.9-20121203.jar b/bomupadte/poi-ooxml-schemas-3.9-20121203.jar new file mode 100644 index 0000000..eda4ef4 Binary files /dev/null and b/bomupadte/poi-ooxml-schemas-3.9-20121203.jar differ diff --git a/bomupadte/poi-scratchpad-3.9-20121203.jar b/bomupadte/poi-scratchpad-3.9-20121203.jar new file mode 100644 index 0000000..1520855 Binary files /dev/null and b/bomupadte/poi-scratchpad-3.9-20121203.jar differ diff --git a/bomupadte/sqljdbc4.jar b/bomupadte/sqljdbc4.jar new file mode 100644 index 0000000..b26b1ec Binary files /dev/null and b/bomupadte/sqljdbc4.jar differ diff --git a/bomupadte/xmlbeans-2.5.0.jar b/bomupadte/xmlbeans-2.5.0.jar new file mode 100644 index 0000000..c368fb2 Binary files /dev/null and b/bomupadte/xmlbeans-2.5.0.jar differ diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..8d3834e --- /dev/null +++ b/build.properties @@ -0,0 +1,115 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + lib/activation-1.1.jar,\ + lib/antlr-2.7.7.jar,\ + lib/apache-commons-codec-1.4.jar,\ + lib/apache-mime4j-core-0.7.2.jar,\ + lib/axiom-api-1.2.12.jar,\ + lib/axiom-dom-1.2.12.jar,\ + lib/axiom-impl-1.2.12.jar,\ + lib/axis2-adb-1.6.2.jar,\ + lib/axis2-adb-codegen-1.6.2.jar,\ + lib/axis2-ant-plugin-1.6.2.jar,\ + lib/axis2-clustering-1.6.2.jar,\ + lib/axis2-codegen-1.6.2.jar,\ + lib/axis2-corba-1.6.2.jar,\ + lib/axis2-fastinfoset-1.6.2.jar,\ + lib/axis2-java2wsdl-1.6.2.jar,\ + lib/axis2-jaxbri-1.6.2.jar,\ + lib/axis2-jaxws-1.6.2.jar,\ + lib/axis2-jibx-1.6.2.jar,\ + lib/axis2-json-1.6.2.jar,\ + lib/axis2-kernel-1.6.2.jar,\ + lib/axis2-metadata-1.6.2.jar,\ + lib/axis2-mtompolicy-1.6.2.jar,\ + lib/axis2-saaj-1.6.2.jar,\ + lib/axis2-soapmonitor-servlet-1.6.2.jar,\ + lib/axis2-spring-1.6.2.jar,\ + lib/axis2-transport-http-1.6.2.jar,\ + lib/axis2-transport-local-1.6.2.jar,\ + lib/axis2-xmlbeans-1.6.2.jar,\ + lib/bcel-5.1.jar,\ + lib/commons-beanutils-1.7.0.jar,\ + lib/commons-cli-1.2.jar,\ + lib/commons-codec-1.3.jar,\ + lib/commons-collections-3.2.jar,\ + lib/commons-fileupload-1.2.jar,\ + lib/commons-httpclient-3.1.jar,\ + lib/commons-io-1.4.jar,\ + lib/commons-lang-2.4.jar,\ + lib/commons-logging-1.1.1.jar,\ + lib/commons-logging-1.1.jar,\ + lib/dom4j-1.6.1.jar,\ + lib/ezmorph-1.0.4.jar,\ + lib/geronimo-annotation_1.0_spec-1.1.jar,\ + lib/geronimo-jaxws_2.2_spec-1.0.jar,\ + lib/geronimo-jta_1.1_spec-1.1.jar,\ + lib/geronimo-saaj_1.3_spec-1.0.1.jar,\ + lib/geronimo-stax-api_1.0_spec-1.0.1.jar,\ + lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar,\ + lib/itext-2.0.3.jar,\ + lib/iText-5.0.2.jar,\ + lib/iTextAsian.jar,\ + lib/jalopy-1.5rc3.jar,\ + lib/jaxb-api-2.1.jar,\ + lib/jaxb-impl-2.1.7.jar,\ + lib/jaxb-xjc-2.1.7.jar,\ + lib/jaxen-1.1.6.jar,\ + lib/jaxws-tools-2.1.3.jar,\ + lib/jdom.jar,\ + lib/jettison-1.0-RC2.jar,\ + lib/jibx-bind-1.2.jar,\ + lib/jibx-run-1.2.jar,\ + lib/json-lib-2.2.2-jdk15.jar,\ + lib/json-lib-2.2.3-jdk13.jar,\ + lib/jsr311-api-1.0.jar,\ + lib/juli-6.0.16.jar,\ + lib/log4j-1.2.15.jar,\ + lib/mail-1.4.jar,\ + lib/mex-1.6.2-impl.jar,\ + lib/mysql-connector-java-5.0.8-bin.jar,\ + lib/neethi-3.0.2.jar,\ + lib/ojdbc6.jar,\ + lib/regexp-1.2.jar,\ + lib/tribes-6.0.16.jar,\ + lib/woden-api-1.0M9.jar,\ + lib/woden-impl-commons-1.0M9.jar,\ + lib/woden-impl-dom-1.0M9.jar,\ + lib/wsdl4j-1.6.2.jar,\ + lib/wstx-asl-3.2.9.jar,\ + lib/xalan-2.7.0.jar,\ + lib/xml-resolver-1.2.jar,\ + lib/xmlbeans-2.3.0.jar,\ + lib/XmlSchema-1.4.7.jar,\ + lib/commons-logging.jar,\ + lib/fontbox-2.0.11.jar,\ + lib/pdfbox-2.0.11.jar,\ + lib/pdfbox-debugger-2.0.11.jar,\ + lib/pdfbox-tools-2.0.11.jar,\ + lib/preflight-2.0.11.jar,\ + lib/xmpbox-2.0.11.jar,\ + lib/jacob.jar,\ + lib/Spire.Xls.jar,\ + lib/Spire.Office.jar,\ + lib/spire.pdf-3.4.2.jar,\ + bomupadte/Spire.Xls.jar,\ + lib/aspose-cells-18.9.jar,\ + lib/hutool-all-5.0.7.jar,\ + lib/datepicker.jar,\ + bomupadte/,\ + lib/logback-classic-1.2.10.jar,\ + lib/logback-core-1.2.10.jar,\ + lib/slf4j-api-1.7.30.jar,\ + lib/imageio-tiff-3.8.2.jar,\ + plugin.properties,\ + plugin_zh_CN.properties,\ + src/,\ + lib/itextpdf-5.5.5.jar,\ + lib/aspose-cad-21.8.jar,\ + lib/fastjson2-2.0.15.jar,\ + lib/swing2swt.jar,\ + lib/jxl_1.0.0.jar diff --git a/icons/inbox_16.png b/icons/inbox_16.png new file mode 100644 index 0000000..f28be80 Binary files /dev/null and b/icons/inbox_16.png differ 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/Spire.Office.jar b/lib/Spire.Office.jar new file mode 100644 index 0000000..56056f3 Binary files /dev/null and b/lib/Spire.Office.jar differ diff --git a/lib/XmlSchema-1.4.7.jar b/lib/XmlSchema-1.4.7.jar new file mode 100644 index 0000000..79251c6 Binary files /dev/null and b/lib/XmlSchema-1.4.7.jar differ diff --git a/lib/activation-1.1.jar b/lib/activation-1.1.jar new file mode 100644 index 0000000..53f82a1 Binary files /dev/null and b/lib/activation-1.1.jar differ diff --git a/lib/antlr-2.7.7.jar b/lib/antlr-2.7.7.jar new file mode 100644 index 0000000..5e5f14b Binary files /dev/null and b/lib/antlr-2.7.7.jar differ diff --git a/lib/apache-commons-codec-1.4.jar b/lib/apache-commons-codec-1.4.jar new file mode 100644 index 0000000..422c42b Binary files /dev/null and b/lib/apache-commons-codec-1.4.jar differ diff --git a/lib/apache-mime4j-core-0.7.2.jar b/lib/apache-mime4j-core-0.7.2.jar new file mode 100644 index 0000000..b5c225b Binary files /dev/null and b/lib/apache-mime4j-core-0.7.2.jar differ diff --git a/lib/aspose-cad-21.8.jar b/lib/aspose-cad-21.8.jar new file mode 100644 index 0000000..d14fc08 Binary files /dev/null and b/lib/aspose-cad-21.8.jar differ diff --git a/lib/aspose-cells-18.9.jar b/lib/aspose-cells-18.9.jar new file mode 100644 index 0000000..2cefe55 Binary files /dev/null and b/lib/aspose-cells-18.9.jar differ diff --git a/lib/axiom-api-1.2.12.jar b/lib/axiom-api-1.2.12.jar new file mode 100644 index 0000000..4ee047d Binary files /dev/null and b/lib/axiom-api-1.2.12.jar differ diff --git a/lib/axiom-dom-1.2.12.jar b/lib/axiom-dom-1.2.12.jar new file mode 100644 index 0000000..b2ff444 Binary files /dev/null and b/lib/axiom-dom-1.2.12.jar differ diff --git a/lib/axiom-impl-1.2.12.jar b/lib/axiom-impl-1.2.12.jar new file mode 100644 index 0000000..0929d8c Binary files /dev/null and b/lib/axiom-impl-1.2.12.jar differ diff --git a/lib/axis2-adb-1.6.2.jar b/lib/axis2-adb-1.6.2.jar new file mode 100644 index 0000000..6234fdb Binary files /dev/null and b/lib/axis2-adb-1.6.2.jar differ diff --git a/lib/axis2-adb-codegen-1.6.2.jar b/lib/axis2-adb-codegen-1.6.2.jar new file mode 100644 index 0000000..7d037d4 Binary files /dev/null and b/lib/axis2-adb-codegen-1.6.2.jar differ diff --git a/lib/axis2-ant-plugin-1.6.2.jar b/lib/axis2-ant-plugin-1.6.2.jar new file mode 100644 index 0000000..771b222 Binary files /dev/null and b/lib/axis2-ant-plugin-1.6.2.jar differ diff --git a/lib/axis2-clustering-1.6.2.jar b/lib/axis2-clustering-1.6.2.jar new file mode 100644 index 0000000..e45be99 Binary files /dev/null and b/lib/axis2-clustering-1.6.2.jar differ diff --git a/lib/axis2-codegen-1.6.2.jar b/lib/axis2-codegen-1.6.2.jar new file mode 100644 index 0000000..f742f19 Binary files /dev/null and b/lib/axis2-codegen-1.6.2.jar differ diff --git a/lib/axis2-corba-1.6.2.jar b/lib/axis2-corba-1.6.2.jar new file mode 100644 index 0000000..ee3c78e Binary files /dev/null and b/lib/axis2-corba-1.6.2.jar differ diff --git a/lib/axis2-fastinfoset-1.6.2.jar b/lib/axis2-fastinfoset-1.6.2.jar new file mode 100644 index 0000000..d10c36a Binary files /dev/null and b/lib/axis2-fastinfoset-1.6.2.jar differ diff --git a/lib/axis2-java2wsdl-1.6.2.jar b/lib/axis2-java2wsdl-1.6.2.jar new file mode 100644 index 0000000..0bb869d Binary files /dev/null and b/lib/axis2-java2wsdl-1.6.2.jar differ diff --git a/lib/axis2-jaxbri-1.6.2.jar b/lib/axis2-jaxbri-1.6.2.jar new file mode 100644 index 0000000..616eec9 Binary files /dev/null and b/lib/axis2-jaxbri-1.6.2.jar differ diff --git a/lib/axis2-jaxws-1.6.2.jar b/lib/axis2-jaxws-1.6.2.jar new file mode 100644 index 0000000..064351a Binary files /dev/null and b/lib/axis2-jaxws-1.6.2.jar differ diff --git a/lib/axis2-jibx-1.6.2.jar b/lib/axis2-jibx-1.6.2.jar new file mode 100644 index 0000000..75f9d1a Binary files /dev/null and b/lib/axis2-jibx-1.6.2.jar differ diff --git a/lib/axis2-json-1.6.2.jar b/lib/axis2-json-1.6.2.jar new file mode 100644 index 0000000..edd7936 Binary files /dev/null and b/lib/axis2-json-1.6.2.jar differ diff --git a/lib/axis2-kernel-1.6.2.jar b/lib/axis2-kernel-1.6.2.jar new file mode 100644 index 0000000..3ae5f7a Binary files /dev/null and b/lib/axis2-kernel-1.6.2.jar differ diff --git a/lib/axis2-metadata-1.6.2.jar b/lib/axis2-metadata-1.6.2.jar new file mode 100644 index 0000000..492f1ac Binary files /dev/null and b/lib/axis2-metadata-1.6.2.jar differ diff --git a/lib/axis2-mtompolicy-1.6.2.jar b/lib/axis2-mtompolicy-1.6.2.jar new file mode 100644 index 0000000..561e84a Binary files /dev/null and b/lib/axis2-mtompolicy-1.6.2.jar differ diff --git a/lib/axis2-saaj-1.6.2.jar b/lib/axis2-saaj-1.6.2.jar new file mode 100644 index 0000000..c14531d Binary files /dev/null and b/lib/axis2-saaj-1.6.2.jar differ diff --git a/lib/axis2-soapmonitor-servlet-1.6.2.jar b/lib/axis2-soapmonitor-servlet-1.6.2.jar new file mode 100644 index 0000000..276dac7 Binary files /dev/null and b/lib/axis2-soapmonitor-servlet-1.6.2.jar differ diff --git a/lib/axis2-spring-1.6.2.jar b/lib/axis2-spring-1.6.2.jar new file mode 100644 index 0000000..30b9baa Binary files /dev/null and b/lib/axis2-spring-1.6.2.jar differ diff --git a/lib/axis2-transport-http-1.6.2.jar b/lib/axis2-transport-http-1.6.2.jar new file mode 100644 index 0000000..b1dad78 Binary files /dev/null and b/lib/axis2-transport-http-1.6.2.jar differ diff --git a/lib/axis2-transport-local-1.6.2.jar b/lib/axis2-transport-local-1.6.2.jar new file mode 100644 index 0000000..34a7073 Binary files /dev/null and b/lib/axis2-transport-local-1.6.2.jar differ diff --git a/lib/axis2-xmlbeans-1.6.2.jar b/lib/axis2-xmlbeans-1.6.2.jar new file mode 100644 index 0000000..58fba9b Binary files /dev/null and b/lib/axis2-xmlbeans-1.6.2.jar differ diff --git a/lib/bcel-5.1.jar b/lib/bcel-5.1.jar new file mode 100644 index 0000000..524e375 Binary files /dev/null and b/lib/bcel-5.1.jar differ diff --git a/lib/commons-beanutils-1.7.0.jar b/lib/commons-beanutils-1.7.0.jar new file mode 100644 index 0000000..b1b89c9 Binary files /dev/null and b/lib/commons-beanutils-1.7.0.jar differ diff --git a/lib/commons-cli-1.2.jar b/lib/commons-cli-1.2.jar new file mode 100644 index 0000000..ce4b9ff Binary files /dev/null and b/lib/commons-cli-1.2.jar differ diff --git a/lib/commons-codec-1.3.jar b/lib/commons-codec-1.3.jar new file mode 100644 index 0000000..957b675 Binary files /dev/null and b/lib/commons-codec-1.3.jar differ diff --git a/lib/commons-collections-3.2.jar b/lib/commons-collections-3.2.jar new file mode 100644 index 0000000..75580be Binary files /dev/null and b/lib/commons-collections-3.2.jar differ diff --git a/lib/commons-fileupload-1.2.jar b/lib/commons-fileupload-1.2.jar new file mode 100644 index 0000000..12539f5 Binary files /dev/null and b/lib/commons-fileupload-1.2.jar differ diff --git a/lib/commons-httpclient-3.1.jar b/lib/commons-httpclient-3.1.jar new file mode 100644 index 0000000..7c59774 Binary files /dev/null and b/lib/commons-httpclient-3.1.jar differ diff --git a/lib/commons-io-1.4.jar b/lib/commons-io-1.4.jar new file mode 100644 index 0000000..133dc6c Binary files /dev/null and b/lib/commons-io-1.4.jar differ diff --git a/lib/commons-lang-2.4.jar b/lib/commons-lang-2.4.jar new file mode 100644 index 0000000..532939e Binary files /dev/null and b/lib/commons-lang-2.4.jar differ diff --git a/lib/commons-logging-1.1.1.jar b/lib/commons-logging-1.1.1.jar new file mode 100644 index 0000000..1deef14 Binary files /dev/null and b/lib/commons-logging-1.1.1.jar differ diff --git a/lib/commons-logging-1.1.jar b/lib/commons-logging-1.1.jar new file mode 100644 index 0000000..2ff9bbd Binary files /dev/null and b/lib/commons-logging-1.1.jar differ diff --git a/lib/commons-logging.jar b/lib/commons-logging.jar new file mode 100644 index 0000000..b99c937 Binary files /dev/null and b/lib/commons-logging.jar differ diff --git a/lib/datepicker.jar b/lib/datepicker.jar new file mode 100644 index 0000000..8304d36 Binary files /dev/null and b/lib/datepicker.jar differ diff --git a/lib/dom4j-1.6.1.jar b/lib/dom4j-1.6.1.jar new file mode 100644 index 0000000..c8c4dbb Binary files /dev/null and b/lib/dom4j-1.6.1.jar differ diff --git a/lib/ezmorph-1.0.4.jar b/lib/ezmorph-1.0.4.jar new file mode 100644 index 0000000..7625af6 Binary files /dev/null and b/lib/ezmorph-1.0.4.jar differ diff --git a/lib/fastjson2-2.0.15.jar b/lib/fastjson2-2.0.15.jar new file mode 100644 index 0000000..88997b5 Binary files /dev/null and b/lib/fastjson2-2.0.15.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/fontbox-2.0.11.jar b/lib/fontbox-2.0.11.jar new file mode 100644 index 0000000..8f38ac6 Binary files /dev/null and b/lib/fontbox-2.0.11.jar differ diff --git a/lib/geronimo-annotation_1.0_spec-1.1.jar b/lib/geronimo-annotation_1.0_spec-1.1.jar new file mode 100644 index 0000000..7a6f529 Binary files /dev/null and b/lib/geronimo-annotation_1.0_spec-1.1.jar differ diff --git a/lib/geronimo-jaxws_2.2_spec-1.0.jar b/lib/geronimo-jaxws_2.2_spec-1.0.jar new file mode 100644 index 0000000..888f839 Binary files /dev/null and b/lib/geronimo-jaxws_2.2_spec-1.0.jar differ diff --git a/lib/geronimo-jta_1.1_spec-1.1.jar b/lib/geronimo-jta_1.1_spec-1.1.jar new file mode 100644 index 0000000..bba9290 Binary files /dev/null and b/lib/geronimo-jta_1.1_spec-1.1.jar differ diff --git a/lib/geronimo-saaj_1.3_spec-1.0.1.jar b/lib/geronimo-saaj_1.3_spec-1.0.1.jar new file mode 100644 index 0000000..b2f6e81 Binary files /dev/null and b/lib/geronimo-saaj_1.3_spec-1.0.1.jar differ diff --git a/lib/geronimo-stax-api_1.0_spec-1.0.1.jar b/lib/geronimo-stax-api_1.0_spec-1.0.1.jar new file mode 100644 index 0000000..ab1ee3b Binary files /dev/null and b/lib/geronimo-stax-api_1.0_spec-1.0.1.jar differ diff --git a/lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar b/lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar new file mode 100644 index 0000000..c8a795a Binary files /dev/null and b/lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar differ diff --git a/lib/httpcore-4.0.jar b/lib/httpcore-4.0.jar new file mode 100644 index 0000000..37eb7d4 Binary files /dev/null and b/lib/httpcore-4.0.jar differ diff --git a/lib/hutool-all-5.0.7.jar b/lib/hutool-all-5.0.7.jar new file mode 100644 index 0000000..0ed0b10 Binary files /dev/null and b/lib/hutool-all-5.0.7.jar differ diff --git a/lib/iText-5.0.2.jar b/lib/iText-5.0.2.jar new file mode 100644 index 0000000..ed95653 Binary files /dev/null and b/lib/iText-5.0.2.jar differ diff --git a/lib/iTextAsian.jar b/lib/iTextAsian.jar new file mode 100644 index 0000000..3fa2157 Binary files /dev/null and b/lib/iTextAsian.jar differ diff --git a/lib/imageio-tiff-3.8.2.jar b/lib/imageio-tiff-3.8.2.jar new file mode 100644 index 0000000..b5d22dd Binary files /dev/null and b/lib/imageio-tiff-3.8.2.jar differ diff --git a/lib/itext-2.0.3.jar b/lib/itext-2.0.3.jar new file mode 100644 index 0000000..9c6179d Binary files /dev/null and b/lib/itext-2.0.3.jar differ diff --git a/lib/itextpdf-5.5.5.jar b/lib/itextpdf-5.5.5.jar new file mode 100644 index 0000000..02eed53 Binary files /dev/null and b/lib/itextpdf-5.5.5.jar differ diff --git a/lib/jacob.jar b/lib/jacob.jar new file mode 100644 index 0000000..35ce4fa Binary files /dev/null and b/lib/jacob.jar differ diff --git a/lib/jalopy-1.5rc3.jar b/lib/jalopy-1.5rc3.jar new file mode 100644 index 0000000..fe51ce2 Binary files /dev/null and b/lib/jalopy-1.5rc3.jar differ diff --git a/lib/jaxb-api-2.1.jar b/lib/jaxb-api-2.1.jar new file mode 100644 index 0000000..be3d6dc Binary files /dev/null and b/lib/jaxb-api-2.1.jar differ diff --git a/lib/jaxb-impl-2.1.7.jar b/lib/jaxb-impl-2.1.7.jar new file mode 100644 index 0000000..034c158 Binary files /dev/null and b/lib/jaxb-impl-2.1.7.jar differ diff --git a/lib/jaxb-xjc-2.1.7.jar b/lib/jaxb-xjc-2.1.7.jar new file mode 100644 index 0000000..ba2ec46 Binary files /dev/null and b/lib/jaxb-xjc-2.1.7.jar differ diff --git a/lib/jaxen-1.1.6.jar b/lib/jaxen-1.1.6.jar new file mode 100644 index 0000000..52f47a4 Binary files /dev/null and b/lib/jaxen-1.1.6.jar differ diff --git a/lib/jaxws-tools-2.1.3.jar b/lib/jaxws-tools-2.1.3.jar new file mode 100644 index 0000000..1006bfd Binary files /dev/null and b/lib/jaxws-tools-2.1.3.jar differ diff --git a/lib/jdom.jar b/lib/jdom.jar new file mode 100644 index 0000000..65a1b3f Binary files /dev/null and b/lib/jdom.jar differ diff --git a/lib/jettison-1.0-RC2.jar b/lib/jettison-1.0-RC2.jar new file mode 100644 index 0000000..3a00ed2 Binary files /dev/null and b/lib/jettison-1.0-RC2.jar differ diff --git a/lib/jibx-bind-1.2.jar b/lib/jibx-bind-1.2.jar new file mode 100644 index 0000000..c8d3887 Binary files /dev/null and b/lib/jibx-bind-1.2.jar differ diff --git a/lib/jibx-run-1.2.jar b/lib/jibx-run-1.2.jar new file mode 100644 index 0000000..6b467d3 Binary files /dev/null and b/lib/jibx-run-1.2.jar differ diff --git a/lib/json-lib-2.2.2-jdk15.jar b/lib/json-lib-2.2.2-jdk15.jar new file mode 100644 index 0000000..27e7c7c Binary files /dev/null and b/lib/json-lib-2.2.2-jdk15.jar differ diff --git a/lib/json-lib-2.2.3-jdk13.jar b/lib/json-lib-2.2.3-jdk13.jar new file mode 100644 index 0000000..a6513db Binary files /dev/null and b/lib/json-lib-2.2.3-jdk13.jar differ diff --git a/lib/jsr311-api-1.0.jar b/lib/jsr311-api-1.0.jar new file mode 100644 index 0000000..2bede66 Binary files /dev/null and b/lib/jsr311-api-1.0.jar differ diff --git a/lib/juli-6.0.16.jar b/lib/juli-6.0.16.jar new file mode 100644 index 0000000..c3fe977 Binary files /dev/null and b/lib/juli-6.0.16.jar differ diff --git a/lib/jxl_1.0.0.jar b/lib/jxl_1.0.0.jar new file mode 100644 index 0000000..cb144e4 Binary files /dev/null and b/lib/jxl_1.0.0.jar differ diff --git a/lib/log4j-1.2.15.jar b/lib/log4j-1.2.15.jar new file mode 100644 index 0000000..c930a6a Binary files /dev/null and b/lib/log4j-1.2.15.jar differ diff --git a/lib/logback-classic-1.2.10.jar b/lib/logback-classic-1.2.10.jar new file mode 100644 index 0000000..75898d2 Binary files /dev/null and b/lib/logback-classic-1.2.10.jar differ diff --git a/lib/logback-core-1.2.10.jar b/lib/logback-core-1.2.10.jar new file mode 100644 index 0000000..ab84db5 Binary files /dev/null and b/lib/logback-core-1.2.10.jar differ diff --git a/lib/mail-1.4.jar b/lib/mail-1.4.jar new file mode 100644 index 0000000..fd4555b Binary files /dev/null and b/lib/mail-1.4.jar differ diff --git a/lib/mex-1.6.2-impl.jar b/lib/mex-1.6.2-impl.jar new file mode 100644 index 0000000..ed67cf3 Binary files /dev/null and b/lib/mex-1.6.2-impl.jar differ diff --git a/lib/mysql-connector-java-5.0.8-bin.jar b/lib/mysql-connector-java-5.0.8-bin.jar new file mode 100644 index 0000000..0170c3e Binary files /dev/null and b/lib/mysql-connector-java-5.0.8-bin.jar differ diff --git a/lib/neethi-3.0.2.jar b/lib/neethi-3.0.2.jar new file mode 100644 index 0000000..383efde Binary files /dev/null and b/lib/neethi-3.0.2.jar differ diff --git a/lib/ojdbc6.jar b/lib/ojdbc6.jar new file mode 100644 index 0000000..ec3d6f1 Binary files /dev/null and b/lib/ojdbc6.jar differ diff --git a/lib/pdfbox-2.0.11.jar b/lib/pdfbox-2.0.11.jar new file mode 100644 index 0000000..4195d0e Binary files /dev/null and b/lib/pdfbox-2.0.11.jar differ diff --git a/lib/pdfbox-debugger-2.0.11.jar b/lib/pdfbox-debugger-2.0.11.jar new file mode 100644 index 0000000..4078bfd Binary files /dev/null and b/lib/pdfbox-debugger-2.0.11.jar differ diff --git a/lib/pdfbox-tools-2.0.11.jar b/lib/pdfbox-tools-2.0.11.jar new file mode 100644 index 0000000..34732c8 Binary files /dev/null and b/lib/pdfbox-tools-2.0.11.jar differ diff --git a/lib/preflight-2.0.11.jar b/lib/preflight-2.0.11.jar new file mode 100644 index 0000000..a048028 Binary files /dev/null and b/lib/preflight-2.0.11.jar differ diff --git a/lib/regexp-1.2.jar b/lib/regexp-1.2.jar new file mode 100644 index 0000000..713441c Binary files /dev/null and b/lib/regexp-1.2.jar differ diff --git a/lib/slf4j-api-1.7.30.jar b/lib/slf4j-api-1.7.30.jar new file mode 100644 index 0000000..29ac26f Binary files /dev/null and b/lib/slf4j-api-1.7.30.jar differ diff --git a/lib/spire.pdf-3.4.2.jar b/lib/spire.pdf-3.4.2.jar new file mode 100644 index 0000000..b60e701 Binary files /dev/null and b/lib/spire.pdf-3.4.2.jar differ diff --git a/lib/swing2swt.jar b/lib/swing2swt.jar new file mode 100644 index 0000000..25690c1 Binary files /dev/null and b/lib/swing2swt.jar differ diff --git a/lib/tribes-6.0.16.jar b/lib/tribes-6.0.16.jar new file mode 100644 index 0000000..bb85de1 Binary files /dev/null and b/lib/tribes-6.0.16.jar differ diff --git a/lib/woden-api-1.0M9.jar b/lib/woden-api-1.0M9.jar new file mode 100644 index 0000000..3b07e8e Binary files /dev/null and b/lib/woden-api-1.0M9.jar differ diff --git a/lib/woden-impl-commons-1.0M9.jar b/lib/woden-impl-commons-1.0M9.jar new file mode 100644 index 0000000..f99c8d7 Binary files /dev/null and b/lib/woden-impl-commons-1.0M9.jar differ diff --git a/lib/woden-impl-dom-1.0M9.jar b/lib/woden-impl-dom-1.0M9.jar new file mode 100644 index 0000000..0e3fff5 Binary files /dev/null and b/lib/woden-impl-dom-1.0M9.jar differ diff --git a/lib/wsdl4j-1.6.2.jar b/lib/wsdl4j-1.6.2.jar new file mode 100644 index 0000000..b9ffc36 Binary files /dev/null and b/lib/wsdl4j-1.6.2.jar differ diff --git a/lib/wstx-asl-3.2.9.jar b/lib/wstx-asl-3.2.9.jar new file mode 100644 index 0000000..ffdbd1f Binary files /dev/null and b/lib/wstx-asl-3.2.9.jar differ diff --git a/lib/xalan-2.7.0.jar b/lib/xalan-2.7.0.jar new file mode 100644 index 0000000..007be39 Binary files /dev/null and b/lib/xalan-2.7.0.jar differ diff --git a/lib/xml-resolver-1.2.jar b/lib/xml-resolver-1.2.jar new file mode 100644 index 0000000..e535bdc Binary files /dev/null and b/lib/xml-resolver-1.2.jar differ diff --git a/lib/xmlbeans-2.3.0.jar b/lib/xmlbeans-2.3.0.jar new file mode 100644 index 0000000..ccd8163 Binary files /dev/null and b/lib/xmlbeans-2.3.0.jar differ diff --git a/lib/xmpbox-2.0.11.jar b/lib/xmpbox-2.0.11.jar new file mode 100644 index 0000000..10f0dde Binary files /dev/null and b/lib/xmpbox-2.0.11.jar differ diff --git a/plugin.properties b/plugin.properties new file mode 100644 index 0000000..b54adea --- /dev/null +++ b/plugin.properties @@ -0,0 +1,39 @@ +rbPLMcd_display.TITLE=PLM Menu +tzbbxd_display.TITLE=Drawing version revision +plclbom_display.TITLE=Batch processing BOM +sb_display.TITLE=Upgrade +bbgh_display.TITLE=Version change +bmqcjzcdx_display.TITLE=Encoder creation assembly object +lscj_display.TITLE=Affiliate Creation +gnlscj_display.TITLE=GNK Affiliate Creation +wllc_display.TITLE=Material Save As +tgxzdxcjlswl_display.TITLE=create temporary material by selecting object +dkcadtz_display.TITLE=Open CAD drawings +dytz_display.TITLE=Print drawings +dytznosy_display.TITLE=Print drawings(remove watermark) +dysjj_display.TITLE=Print dataset +sxzt_display.TITLE=Paste in both directions +plpjbm_display.TITLE=Batch splice encoding +mssc_display.TITLE=Description generation +bjflsx_display.TITLE=Edit classification properties +dcbb_display.TITLE=Export report +hqspm_display.TITLE=Get product code +xhbzlc_display.TITLE=Small box packaging to save as +fzsx_display.TITLE=Assign property +cpumcjzdx_display.TITLE=CUPM creates child objects +bzjlscj_display.TITLE=Standard Parts Affiliation Creation +xmzp_display.TITLE=Assign project +dkgzlbkb_display.TITLE=Open worklist +copyBOM_display.TITLE=Copy Bom Attributes +copyID_display.TITLE=ID +copyCPH_display.TITLE=product number +copyTH_display.TITLE=drawing number +wthqsx_display.TITLE=Delegate to get properties +xzcpcj_display.TITLE=Xinzi finished product creation +xzlccj_display.TITLE=Xinzi Affiliation Creation +tzplzh_display.TITLE=Batch conversion of drawings +tzplxz_display.TITLE=Batch download of drawings +plclID_display.TITLE=Batch processing ID +zcquery_display.TITLE=Assembly search +bomsxplxg_display.TITLE=Batch modification of BOM attributes +txzrr_display.TITLE=Fill in the responsible person \ No newline at end of file diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..689fd5d --- /dev/null +++ b/plugin.xml @@ -0,0 +1,686 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugin_zh_CN.properties b/plugin_zh_CN.properties new file mode 100644 index 0000000..301e8cc --- /dev/null +++ b/plugin_zh_CN.properties @@ -0,0 +1,39 @@ +rbPLMcd_display.TITLE=PLM\u83DC\u5355 +tzbbxd_display.TITLE=\u56FE\u7EB8\u7248\u672C\u4FEE\u8BA2 +plclbom_display.TITLE=\u6279\u91CF\u5904\u7406BOM +sb_display.TITLE=\u5347\u7248 +bbgh_display.TITLE=\u7248\u672C\u66F4\u6362 +bmqcjzcdx_display.TITLE=\u7F16\u7801\u5668\u521B\u5EFA\u603B\u6210\u5BF9\u8C61 +lscj_display.TITLE=\u96B6\u5C5E\u521B\u5EFA +gnlscj_display.TITLE=\u56FA\u8010\u96B6\u5C5E\u521B\u5EFA +xzcpcj_display.TITLE=\u8f9b\u5b50\u6210\u54c1\u521b\u5efa +wllc_display.TITLE=\u7269\u6599\u53E6\u5B58 +tgxzdxcjlswl_display.TITLE=\u901A\u8FC7\u9009\u4E2D\u5BF9\u8C61\u521B\u5EFA\u4E34\u65F6\u7269\u6599 +dkcadtz_display.TITLE=\u6253\u5F00CAD\u56FE\u7EB8 +dytz_display.TITLE=\u6253\u5370\u56FE\u7EB8 +dytznosy_display.TITLE=\u6253\u5370\u56fe\u7eb8(\u53bb\u9664\u6c34\u5370) +dysjj_display.TITLE=\u6253\u5370\u6570\u636E\u96C6 +sxzt_display.TITLE=\u53CC\u5411\u9ECF\u8D34 +plpjbm_display.TITLE=\u6279\u91CF\u62FC\u63A5\u7F16\u7801 +mssc_display.TITLE=\u63CF\u8FF0\u751F\u6210 +bjflsx_display.TITLE=\u7F16\u8F91\u5206\u7C7B\u5C5E\u6027 +dcbb_display.TITLE=\u5BFC\u51FA\u62A5\u8868 +hqspm_display.TITLE=\u83B7\u53D6\u5546\u54C1\u7801 +xhbzlc_display.TITLE=\u5C0F\u76D2\u5305\u88C5\u53E6\u5B58 +fzsx_display.TITLE=\u8D4B\u503C\u5C5E\u6027 +cpumcjzdx_display.TITLE=CUPM\u521B\u5EFA\u5B50\u5BF9\u8C61 +bzjlscj_display.TITLE=\u6807\u51C6\u4EF6\u96B6\u5C5E\u521B\u5EFA +xmzp_display.TITLE=\u9879\u76EE\u6307\u6D3E +dkgzlbkb_display.TITLE=\u5DE5\u4F5C\u5217\u8868\u770B\u677F +copyBOM_display.TITLE=\u590D\u5236BOM\u884C\u5C5E\u6027 +copyID_display.TITLE=ID +copyCPH_display.TITLE=\u4EA7\u54C1\u53F7 +copyTH_display.TITLE=\u56FE\u53F7 +wthqsx_display.TITLE=\u59D4\u6258\u83B7\u53D6\u5C5E\u6027 +xzlccj_display.TITLE=\u8F9B\u5B50\u96B6\u5C5E\u521B\u5EFA +txzrr_display.TITLE=\u586b\u5199\u8d23\u4efb\u4eba +tzplzh_display.TITLE=\u56fe\u7eb8\u6279\u91cf\u8f6c\u6362 +tzplxz_display.TITLE=\u56fe\u7eb8\u6279\u91cf\u4e0b\u8f7d +plclID_display.TITLE=\u6279\u91cf\u5904\u7406ID +zcquery_display.TITLE=\u603b\u6210\u68c0\u7d22 +bomsxplxg_display.TITLE=BOM\u5c5e\u6027\u6279\u91cf\u4fee\u6539 \ No newline at end of file diff --git a/src/GetNumberCommand改之前 b/src/GetNumberCommand改之前 new file mode 100644 index 0000000..92702c0 --- /dev/null +++ b/src/GetNumberCommand改之前 @@ -0,0 +1,106 @@ +package com.connor.rb.plm.rb027; + +import java.util.Iterator; +import java.util.Map; + +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + + +public class GetNumberCommand extends AbstractAIFCommand { + private AbstractAIFApplication app; + private TCSession session; + + + public GetNumberCommand(AbstractAIFApplication app, TCSession session) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + //ȡѡж + InterfaceAIFComponent comp = app.getTargetComponent(); + + if(!(comp instanceof TCComponentItemRevision)) + { + MessageBox.post("ѡа汾", "", MessageBox.ERROR); + return; + } + + TCComponentItemRevision itemRevision = (TCComponentItemRevision) comp; + String result = sendPost("http://10.20.7.27:9889/jde/getNumber"); + System.out.println(result); + //ȡؽ + JSONObject resultJson = JSONObject.fromObject(result); + + + JSONArray jsonArray = resultJson.getJSONArray("data"); + for (int i=0; i < jsonArray.size(); i++) { + + //ȡautoNextNumber + String autoNextNumber = ""; + JSONObject jsonObject = jsonArray.getJSONObject(i); + Iterator iter = jsonObject.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry entry = (Map.Entry) iter.next(); + System.out.println(entry.getKey().toString()); + switch (entry.getKey().toString()) { + case "autoNextNumber": + System.out.println(entry.getValue().toString()); + autoNextNumber = entry.getValue().toString(); + break; + default: + break; + } + } + itemRevision.setStringProperty("rb3_spm", autoNextNumber); + itemRevision.refresh(); + MessageBox.post("ȡƷɹ", "ɹ", MessageBox.INFORMATION); + return; + } + super.executeModal(); + } + public static String sendPost(String url) { + String response = null; + + try { + CloseableHttpClient httpclient = null; + CloseableHttpResponse httpresponse = null; + try { + httpclient = HttpClients.createDefault(); + HttpGet httpGet = new HttpGet(url); + httpresponse = httpclient.execute(httpGet); + response = EntityUtils.toString(httpresponse.getEntity()); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (httpclient != null) { + httpclient.close(); + } + if (httpresponse != null) { + httpresponse.close(); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return response; + } + +} diff --git a/src/com/connor/rb/plm/Activator.java b/src/com/connor/rb/plm/Activator.java new file mode 100644 index 0000000..9a7052f --- /dev/null +++ b/src/com/connor/rb/plm/Activator.java @@ -0,0 +1,55 @@ +package com.connor.rb.plm; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "com.connor.rb.plm"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given plug-in relative + * path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } +} diff --git a/src/com/connor/rb/plm/biaozhunjian/Fenlei.java b/src/com/connor/rb/plm/biaozhunjian/Fenlei.java new file mode 100644 index 0000000..7c2c266 --- /dev/null +++ b/src/com/connor/rb/plm/biaozhunjian/Fenlei.java @@ -0,0 +1,30 @@ +package com.connor.rb.plm.biaozhunjian; + +import java.util.Arrays; + +public class Fenlei { + Integer[] classKeys; + String[] classVals; + + public Integer[] getClassKeys() { + return classKeys; + } + + public void setClassKeys(Integer[] classKeys) { + this.classKeys = classKeys; + } + + public String[] getClassVals() { + return classVals; + } + + public void setClassVals(String[] classVals) { + this.classVals = classVals; + } + + @Override + public String toString() { + return "Fenlei [classKeys=" + Arrays.toString(classKeys) + ", classVals=" + Arrays.toString(classVals) + "]"; + } + +} diff --git a/src/com/connor/rb/plm/biaozhunjian/G4MDialog.java b/src/com/connor/rb/plm/biaozhunjian/G4MDialog.java new file mode 100644 index 0000000..7cd9a1e --- /dev/null +++ b/src/com/connor/rb/plm/biaozhunjian/G4MDialog.java @@ -0,0 +1,194 @@ +package com.connor.rb.plm.biaozhunjian; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JPanel; + +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.classification.common.AbstractG4MApplication; +import com.teamcenter.rac.classification.common.G4MApplicationPanel; +import com.teamcenter.rac.classification.common.G4MUserAppContext; +import com.teamcenter.rac.classification.common.table.G4MTable; +import com.teamcenter.rac.classification.icm.ICMApplication; + +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItemRevision; + +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +@SuppressWarnings("serial") +public class G4MDialog extends AbstractAIFDialog { + + private JButton b_ok; + private JButton b_cel; + private ICMApplication app; + private MyG4MContext m_context; + protected TCComponentICO ico; + private String expandClass; + private List revList; + InterfaceAIFComponent iaf; + TCComponentForm form; + TCSession session; + + // public G4MDialog(String expandClass, InterfaceAIFComponent iaf, QZjsbjdBean + // jsbjdBean, TCSession session, TCComponentForm form) { + // super(AIFDesktop.getActiveDesktop(), true); + // this.jsbjdBean=jsbjdBean; + // this.expandClass = expandClass; + // this.iaf = iaf; + // this.session=session; + // this.form=form; + // try { + // this.app = new ICMApplication(); + // this.m_context = new MyG4MContext(app, "k0"); + // } catch (Exception e) { + // e.printStackTrace(); + // } + // initUI(); + // } + public G4MDialog(String expandClass, InterfaceAIFComponent iaf, List revList, + TCSession session) { + super(AIFDesktop.getActiveDesktop(), true); + this.expandClass = expandClass; + this.iaf = iaf; + this.revList = revList; + this.session = session; + try { + this.app = new ICMApplication(); + this.m_context = new MyG4MContext(app, "k0"); + } catch (Exception e) { + e.printStackTrace(); + } + initUI(); + } + + @Override + public void run() { + showDialog(); + } + + private void initUI() { + this.setTitle("ѡȡ"); + this.setLayout(new BorderLayout()); + this.setPreferredSize(new Dimension(1000, 600)); + this.setMinimumSize(new Dimension(640, 480)); + MyG4MPanel panel = new MyG4MPanel(null); + try { + m_context.openComponent(iaf); + panel.initialize(m_context); + this.add(BorderLayout.CENTER, panel); + m_context.getTree().expandToClass(expandClass); + // new Thread(m_context.getClassificationDialog()).start(); + } catch (Exception e) { + e.printStackTrace(); + } + // panel.open(iaf); + this.add(BorderLayout.SOUTH, initBtnPanel()); + addListeners(); + } + + private void addListeners() { + b_ok.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + G4MTable table = m_context.getTablePane().getG4MTable(); + List list = null; + if (table != null) { + ISelection sel = table.getSelection(); + if (sel != null && sel instanceof StructuredSelection) { + list = ((StructuredSelection) sel).toList(); + + } + } + if (list == null || list.size() == 0) { + MessageBox.post("ѡҪʹõĶ", "", MessageBox.INFORMATION); + // KUtil.info(G4MDialog.this, "ѡҪʹõĶ"); + return; + } + if (list.size() > 1) { + MessageBox.post("ѡ", "", MessageBox.INFORMATION); + // KUtil.info(G4MDialog.this, "ѡ"); + return; + } + Object target = list.get(0); + if (target != null && target instanceof TCComponentICO) { + ico = (TCComponentICO) target; + System.out.println(" ico.getClassId()=====" + ico.getClassId()); + + TCComponentItemRevision rev = (TCComponentItemRevision) ico.getClassifiedObject(); + revList.add(rev); + MessageBox.post("ͼֽóɹ", "ɹ", MessageBox.INFORMATION); + } else { + MessageBox.post("ѡݲICO", "", MessageBox.INFORMATION); + // KUtil.info(G4MDialog.this, "ѡݲICO"); + return; + } + } + }); + b_cel.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + } + + private JPanel initBtnPanel() { + JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 25, 5)); + this.b_ok = new JButton("ȷ"); + this.b_cel = new JButton("ȡ"); + panel.add(b_ok); + panel.add(b_cel); + return panel; + } + + public class MyG4MContext extends G4MUserAppContext { + + public MyG4MContext(AbstractAIFUIApplication paramAbstractAIFUIApplication, String paramString) + throws Exception { + super(paramAbstractAIFUIApplication, paramString); + } + + @Override + public void setBusy(String paramString) { + } + + @Override + public void setIdle(String paramString) { + } + + } + + public class MyG4MPanel extends G4MApplicationPanel { + + public MyG4MPanel(AbstractG4MApplication paramAbstractG4MApplication) { + super(paramAbstractG4MApplication); + } + + @Override + public void closeSignaled() { + try { + m_context.clear(); + } catch (Exception e) { + e.printStackTrace(); + } + // m_context.openComponent(iaf); + } + + } + +} diff --git a/src/com/connor/rb/plm/biaozhunjian/GZLiShuAction.java b/src/com/connor/rb/plm/biaozhunjian/GZLiShuAction.java new file mode 100644 index 0000000..14c20fe --- /dev/null +++ b/src/com/connor/rb/plm/biaozhunjian/GZLiShuAction.java @@ -0,0 +1,30 @@ +package com.connor.rb.plm.biaozhunjian; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +public class GZLiShuAction extends AbstractAIFAction { + private AbstractAIFApplication app; + private String name; + private String name1; + private String queryName; + private String preName; + private String attrs; + + public GZLiShuAction(AbstractAIFApplication arg0, String arg1, String name, String name1, String queryName, + String preName, String attrs) { + super(arg0, arg1); + // TODO Auto-generated constructor stub + this.app = arg0; + this.name = name; + this.name1 = name1; + this.queryName = queryName; + this.preName = preName; + this.attrs = attrs; + } + + public void run() { + GZLiShuDialog dialog = new GZLiShuDialog(app, name, name1, queryName, preName, attrs); + new Thread(dialog).start(); + } +} diff --git a/src/com/connor/rb/plm/biaozhunjian/GZLiShuDialog.java b/src/com/connor/rb/plm/biaozhunjian/GZLiShuDialog.java new file mode 100644 index 0000000..1a6a95c --- /dev/null +++ b/src/com/connor/rb/plm/biaozhunjian/GZLiShuDialog.java @@ -0,0 +1,1654 @@ +package com.connor.rb.plm.biaozhunjian; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.KeyStroke; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; + +import com.connor.rb.plm.util.ClassAttributeBean; +import com.connor.rb.plm.util.ClassProperty; +import com.connor.rb.plm.util.CodeBean; +import com.connor.rb.plm.util.GetCodeBean1; +import com.connor.rb.plm.util.MenuBean; +import com.connor.rb.plm.util.ParseXML; +import com.connor.rb.plm.util.PlmLocaleUtil; +import com.connor.rb.plm.util.SearchJComItem; +import com.connor.rb.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSKeyLov.KeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class GZLiShuDialog extends AbstractAIFDialog { + private Map> attrMap; + private Map> attrMap2; + private AbstractAIFApplication app; + private GetCodeBean1 getcode; + private TCSession session; + private MenuBean menuBean; + private String name, name1; + private TCPreferenceService service; + private List asList = new ArrayList(); + private List esList = new ArrayList(); + private TCComponentItemRevision targetItem; + private TCComponentItem tccItem; + private JButton okBut = new JButton("ȷ"); + private JButton button2 = new JButton("ͼֽ"); + private JButton celBut = new JButton("ȡ"); + private AIFComponentContext[] refs;// Ŀùϵ + private JPanel classJpanel; + private JPanel jp1; + private JPanel jp2; + private JScrollPane scr2; + private boolean classFlag; + private boolean classFlag2; + private Map objMap = new HashMap(); + private Map objMap2 = new HashMap(); + private Map lovMap = new HashMap(); + private Map lovMap2 = new HashMap(); + private List attrList = new ArrayList(); + private List esAttrList = new ArrayList(); + private String className2; + private List revList = new ArrayList(); + // TextField + private List fieldList = new ArrayList(); + // box + private List comboxList = new ArrayList(); + private Map fieldmap = new HashMap<>(); + private Map comboxmap = new HashMap<>(); + // private List objList = new ArrayList(); + // private List lovList = new ArrayList(); + private List attrList2 = new ArrayList(); + private List esAttrList2 = new ArrayList(); + // private List objList2 = new ArrayList(); + // private List lovList2 = new ArrayList(); + private List markList = new ArrayList(); + private List markList2 = new ArrayList(); + private List isNList = new ArrayList(); + private List isNList2 = new ArrayList(); + private List defaultValueList = new ArrayList(); + private List defaultValueList2 = new ArrayList(); + private List classList = new ArrayList(); + private List idList = new ArrayList(); + protected CodeBean selCodeBean; + private Map> boxMap = new HashMap>(); + protected JLabel revLabel; + protected JComboBox revBox; + private String productNumber = ""; + private String drawingNumber = ""; + // ƷŵIJѯ + private String cph_query = ""; + // 汾ѡ + private String rev_ids = "RB_Revision_id"; + // ѡ + private String gz_name = ""; + private String attrs = ""; + protected JLabel nameLabel; + protected JComboBox nameComb; + protected JLabel idLabel; + protected JTextField idField1; + protected JLabel[] labels1 = null; + private HashMap map2; + private List> values; + // + private int v = 0; + private String HeatTreatment = ""; + private List typeList = new ArrayList(); + private TCComponentFolder folder; + private StringBuilder build = new StringBuilder(); + private String url; + // λ + private Map tagMap = new HashMap(); + // λ + private JComboBox dl; + // lovֵԵmap + private Map> lovAttrs = new HashMap>(); + + public GZLiShuDialog(AbstractAIFApplication app, String name, String name1, String cph_query, String gz_name, + String attrs) { + super(false); + this.app = app; + this.name = name; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.values = new ArrayList>(); + this.name1 = name1; + this.cph_query = cph_query; + this.gz_name = gz_name; + this.attrs = attrs; + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + } + + @Override + public void run() { + // TODO Auto-generated method stub + getcode = new GetCodeBean1(session); + // if(getcode==null) System.out.println("================>getcode = new + // GetCodeBean1(session);;getcodeΪ"); + menuBean = getcode.getMenuBean(name); + // if(menuBean==null) System.out.println("================>menuBean = + // getcode.getMenuBean(name);;;menuBeanΪ"); + + String lovVal = service.getStringValue("RB3_lovVal_default"); + String esLovVal = service.getStringValue("RB3_esLovVal_default"); + + if (lovVal.contains(";")) { + String[] vals = lovVal.split(";"); + String[] esVals = esLovVal.split(";"); + for (int i = 0; i < vals.length; i++) { + asList.add(vals[i]); + esList.add(esVals[i]); + } + } + + ParseXML xml = new ParseXML(); + File file = xml.getSXX("RB3_CPHPJFS", session); + + attrMap = xml.parseXMLAttr(file); + if (attrMap == null || attrMap.size() <= 0) { + MessageBox.post("ѡRB3_CPHPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + + File file2 = xml.getSXX("RB3_THPJFS", session); + attrMap2 = xml.parseXMLAttr(file2); + if (attrMap2 == null || attrMap2.size() <= 0) { + MessageBox.post("ѡRB3_THPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + + InterfaceAIFComponent targetComp = app.getTargetComponent(); + if (targetComp instanceof TCComponentItemRevision) { + targetItem = (TCComponentItemRevision) targetComp; + try { + tccItem = targetItem.getItem(); + refs = tccItem.whereReferenced(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + init(); + } + + /** + * ƽ + */ + public void init() { + this.setTitle(name1); + this.setPreferredSize(new Dimension(860, 900)); + this.setLayout(new BorderLayout()); + classJpanel = new JPanel(new BorderLayout());// Խ + jp1 = new JPanel(new BorderLayout()); + jp2 = new JPanel(new PropertyLayout()); + jp1.setPreferredSize(new Dimension(200, 820)); + scr2 = new JScrollPane(jp2); + scr2.setPreferredSize(new Dimension(640, 820)); + classJpanel.add(scr2); + + // ṹ + JTree tree = null; + try { + tree = getTree(menuBean); + } catch (TCException e3) { + // TODO Auto-generated catch block + e3.printStackTrace(); + } + + // esc˳ + KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); + this.getRootPane().registerKeyboardAction(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int option = JOptionPane.showOptionDialog(null, "ȷ˳˵", "", 0, 1, null, null, Integer.valueOf(0)); + if (option == 0) { + System.out.println("˳"); + disposeDialog(); + } else { + return; + } + } + }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); + + // Ӽť + tree.addTreeSelectionListener(new TreeSelectionListener() { + public void valueChanged(TreeSelectionEvent e) { + // ˢ(е) + refreshMsg(); + // ȡѡеĽڵ + DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) e.getPath().getLastPathComponent(); + int childCount = treeNode.getChildCount(); + System.out.println("ǰѡеĽڵ: " + treeNode + " ӽڵ:" + childCount); + if (childCount > 0) { + jp2.setVisible(false); + } else { + String names = getNode(treeNode, ""); + selCodeBean = getcode.getCodebean(names); + if (selCodeBean == null) { + MessageBox.post("ѡײڵ㣡", "ʾ", MessageBox.INFORMATION); + return; + } + // --Ϣ + JTextField idfield = new JTextField(18); + idList.add(idfield); + JComboBox idbox = new JComboBox(); + idList.add(idbox); + idbox.addItem(" "); + String[] idstrs = new String[100]; + for (int j = 0; j < 100; j++) { + if (j < 10) { + idstrs[j] = "0" + j; + } else { + idstrs[j] = j + ""; + } + } + for (int j = 0; j < idstrs.length; j++) { + idbox.addItem(idstrs[j]); + } + boxMap.put(PlmLocaleUtil.getString("PartNumber"), idbox); + // --end + + // --汾Ϣ + revLabel = new JLabel("汾"); + revBox = new JComboBox(); + revBox.setEditable(false); + revBox.addItem("B1"); + + // ͨѡȡ汾 + String[] revs = service.getStringValues(rev_ids); + if (revs == null || revs.length <= 0) { + MessageBox.post("ѡRB_Revision_idδ,ϵԱ!!", "", MessageBox.ERROR); + return; + } + for (int i = 0; i < revs.length; i++) { + revBox.addItem(revs[i]); + } + // --end + + // --Ϣ + nameLabel = new JLabel(""); + nameComb = new JComboBox(); + nameComb.setEditable(false); + + nameComb.addItem(""); + // ͨѡȡ + String[] gzNames = service.getStringValues(gz_name); + if (gzNames == null || gzNames.length <= 0) { + MessageBox.post("ѡRB3_GZ_namesδ,ϵԱ!!", "", MessageBox.ERROR); + return; + } + for (int i = 0; i < gzNames.length; i++) { + nameComb.addItem(gzNames[i]); + } + nameComb.setSelectedIndex(1); + // --end + + // --ϱ + idLabel = new JLabel("ܳϱ"); + idField1 = new JTextField(18); + try { + idField1.setText(targetItem.getProperty("item_id")); + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + // --end + + jp2.add("1.1.center.center", new JLabel("")); + jp2.add("2.1.center.center", idLabel); + jp2.add("2.2.center.center", idField1); + jp2.add("3.1.center.center", nameLabel); + jp2.add("3.2.center.center", nameComb); + jp2.add("4.1.center.center", new JLabel(PlmLocaleUtil.getString("PartNumber"))); + jp2.add("4.2.center.center", idfield); + jp2.add("4.3.center.center", idbox); + jp2.add("5.1.center.center", revLabel); + jp2.add("5.2.center.center", revBox); + + // ȡ + try { + String className = targetItem.getClassificationClass(); + ICSAdminClassAttribute[] icsAttrs = getClassAttrs(className); + TCComponentICO[] icos = targetItem.getClassificationObjects(); + if (icos == null || icos.length <= 0) { + MessageBox.post("ѡеûз͵࣬뷢ͣ", "ʾ", MessageBox.INFORMATION); + return; + } + Map claMap = new HashMap(); + if (icos != null && icos.length > 0) { + + ICSProperty[] icss = icos[0].getICSProperties(true); + + for (ICSProperty ics : icss) { + for (ICSAdminClassAttribute icsa : icsAttrs) { + if (icsa.getAttributeId() == ics.getId()) { + System.out.print("icsa.getName():" + icsa.getName()); + claMap.put(icsa.getName(), ics.getValue()); + } + } + } + } + + // ѡеķ + className2 = selCodeBean.getClassID(); + if (attrMap.containsKey(className2)) { + List nameMarkList = attrMap.get(className2); + String attrNames = nameMarkList.get(0); + String marks = nameMarkList.get(1); + String defaultValues = nameMarkList.get(2); + String isN = nameMarkList.get(3); + if (attrNames.contains(";")) { + String[] attrs = attrNames.split(";"); + String[] markss = marks.split(";"); + String[] valuess = defaultValues.split(";"); + String[] isNs = isN.split(";"); + for (int i = 0; i < attrs.length; i++) { + System.out.println("attrs==============" + attrs[i]); + if (attrs[i].contains("+")) { + String[] attrss = attrs[i].split("\\+"); + attrList.add(attrss[0]); + esAttrList.add(attrss[1]); + markList.add(markss[i]); + defaultValueList.add(valuess[i]); + isNList.add(isNs[i]); + } + } + } + + List nameMarkList2 = attrMap2.get(className2); + String attrNames2 = nameMarkList2.get(0); + String marks2 = nameMarkList2.get(1); + String defaultValues2 = nameMarkList2.get(2); + String isNs2 = nameMarkList2.get(3); + System.out.println("attrNames2============" + attrNames2); + if (attrNames2.contains(";")) { + String[] attrs2 = attrNames2.split(";"); + String[] markss2 = marks2.split(";"); + String[] valuess = defaultValues2.split(";"); + String[] isNs2s = isNs2.split(";"); + for (int i = 0; i < attrs2.length; i++) { + if (attrs2[i].contains("+")) { + String[] attrss = attrs2[i].split("\\+"); + attrList2.add(attrss[0]); + esAttrList2.add(attrss[1]); + markList2.add(markss2[i]); + defaultValueList2.add(valuess[i]); + isNList2.add(isNs2s[i]); + } + } + } + } + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c2 = classificationService.newICSAdminClass(); + c2.load(className2); + String cName = c2.getName(); + ICSAdminClassAttribute[] icsAttrS2 = c2.getAttributes(); + if (PlmLocaleUtil.getString("BearingAccessories").equals(cName)) { + classFlag = false; + } else if (PlmLocaleUtil.getString("Cage").equals(cName)) { + classFlag2 = true; + } + System.out.println("cName===" + cName); + if (icsAttrS2 != null) { + for (ICSAdminClassAttribute attr : icsAttrS2) { + if (attr.isHidden()) { + continue; + } + ClassAttributeBean bean = new ClassAttributeBean(); + if (attr.isReferenceAttribute()) {// + continue; + } + if (attr.isReference()) { + continue; + } + int propID = attr.getAttributeId(); + bean.setId(propID); + String propDisName = attr.getName(); + System.out.print("propDisName:" + propDisName); + bean.setName(propDisName); + + int attrType = attr.getFormat1().getType(); + bean.setType(attrType); + // ÷ + if (claMap != null && claMap.containsKey(propDisName)) { + bean.setVal(claMap.get(propDisName)); + } else { + bean.setVal(""); + } + ICSKeyLov lov1 = attr.getFormat1().getKeyLov(); + lov1 = (lov1 == null ? attr.getFormat2().getKeyLov() : lov1); + if (lov1 != null) { + bean.setIslov(true); + String[] keys = lov1.getKeys(); + Map map1 = new HashMap(); + for (String key : keys) { + KeyLov lov_key = lov1.getKeyLovOfKey(key); + boolean deprecated = lov_key.isDeprecated(); + if (deprecated) { + if (key.equals(bean.getVal())) { + bean.setVal(""); + } + continue; + } + String value = lov1.getValueOfKey(key); + map1.put(value, key);// <ʾֵ,ʵֵ> + if (key.equals(bean.getVal()) && (!bean.getVal().equals(""))) { + bean.setVal(value); + } + } + bean.setLov(map1); + } else { + bean.setIslov(false); + } + + classList.add(bean); + + } + } + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + labels1 = new JLabel[classList.size()]; + jp2.add("6.1.center.top", new JLabel(" ")); + jp2.add("6.2.center.top", new JLabel("****************************")); + // + for (int i = 0; i < classList.size(); i++) { + ClassAttributeBean bean = classList.get(i); + String attrName = bean.getName(); + labels1[i] = new JLabel(attrName); + jp2.add(String.valueOf(i + 7) + ".1.center.top", labels1[i]); + labels1[i].setBounds(5, 5, 5, 5); + String value = bean.getVal(); + System.out.println("ĬֵΪ:" + value); + // jp2.add((i+6) + ".2.center.top", new + // JLabel("****************************")); + // жϷǷlov + if (bean.isIslov()) { + JComboBox comb = new JComboBox(); + comb.setEditable(false); + comb.setSize(new Dimension(60, 40)); + // -- + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + queryByButton(bu, jt, comb); + // --end + if (classFlag2) { + if ((PlmLocaleUtil.getString("heatTreatment")).equals(attrName)) { + comb.addItem(""); + HeatTreatment = value; + } else { + comb.addItem(value); + } + } else { + comb.addItem(value); + } + for (Entry entry : bean.getLov().entrySet()) { + // lovĵһֵɸѡ + if (i == 0) { + System.out.println("entry.getKey()====" + entry.getKey()); + } + if (!(value.equals(entry.getKey()))) { + comb.addItem(entry.getKey()); + } + } + map2 = new HashMap(); + map2.put("JComboBox", comb); + values.add(map2); + jp2.add((i + 7) + ".2.center.top", comb); + jp2.add((i + 7) + ".3.center.top", jt); + jp2.add((i + 7) + ".4.center.top", bu); + // --Ʒźͼƴӷʽݽƥ䣬ƥ䵽ӵmap + if (attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, comb); + lovMap.put(attrName, "yes"); + } + if (attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, comb); + lovMap2.put(attrName, "yes"); + } + // Ϊ⴦ + if ((PlmLocaleUtil.getString("Category")).equals(attrName)) { + typeList.add(comb); + } + // --end + } else { + JTextField field = new JTextField(18); + field.setText(value); + map2 = new HashMap(); + map2.put("JTextField", field); + values.add(map2); + jp2.add((i + 7) + ".2.center.top", field); + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName)) { + JComboBox box = new JComboBox(); + // -- + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + queryByButton(bu, jt, box); + // --end + box.addItem(" "); + String[] strs = new String[] { "C0", "C2", "C3", "C4", "C5" }; + for (int j = 0; j < strs.length; j++) { + box.addItem(strs[j]); + } + boxMap.put(attrName, box); + jp2.add((i + 7) + ".3.center.top", box); + jp2.add((i + 7) + ".4.center.top", jt); + jp2.add((i + 7) + ".5.center.top", bu); + } + + // --Ʒźͼƴӷʽݽƥ䣬ƥ䵽ӵmap + if (attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, field); + lovMap.put(attrName, "no"); + } + if (attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, field); + lovMap2.put(attrName, "no"); + } + // --end + + } + v = i + 8; + } + + // --ʼӶ + addObjectAttrs(v, attrs); + // --end + + jp2.setVisible(true); + try { + jp2.validate(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + jp2.repaint(); + scr2.validate(); + } + } + + }); + + // 岼// + JScrollPane scrollPane = new JScrollPane(tree); + scrollPane.setPreferredSize(new Dimension(250, 250)); + // ӹ嵽// + jp1.add(scrollPane, BorderLayout.CENTER); + classJpanel.add(scr2); + JSplitPane splitPane = new JSplitPane(); + splitPane.setOneTouchExpandable(true);// ÷ָʾͷ + splitPane.setContinuousLayout(true);// ͷػͼ + splitPane.setLeftComponent(new JScrollPane(jp1)); + splitPane.setRightComponent(new JScrollPane(classJpanel)); + JPanel titlePanel = new JPanel(new FlowLayout());// Խ + + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(button2); + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(okBut); + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(celBut); + this.add(splitPane, BorderLayout.CENTER); + this.add(titlePanel, BorderLayout.SOUTH); + + button2.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("׼"); + G4MDialog classDialog = new G4MDialog("˱", null, revList, session); + new Thread(classDialog).start(); + } + }); + + okBut.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + createItem(); + // setVisible(false); + } + + }); + celBut.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("ȡ"); + setVisible(false); + } + }); + this.setVisible(true); + this.centerToScreen(); + } + + /** + * + */ + private void createItem() { + String jhID = ""; + try { + if (idList != null && idList.size() > 0) { + JTextField idField = (JTextField) idList.get(0); + JComboBox idbox = (JComboBox) idList.get(1); + String id = idField.getText(); + String boxID = (String) idbox.getSelectedItem(); + if ("".equals(id.trim())) { + id = boxID.trim(); + } + jhID = id; + } + + String typeID = ""; + if (typeList != null && typeList.size() > 0) { + JComboBox idComb = typeList.get(0); + typeID = (String) idComb.getSelectedItem(); + if (typeID.indexOf("Ʒ") >= 0 || typeID.indexOf("Finished product") >= 0) { + typeID = ""; + } else if (typeID.indexOf("") >= 0 || typeID.indexOf("Turning workpiece") >= 0) { + typeID = "C"; + } else if (typeID.indexOf("ȴ") >= 0 || typeID.indexOf("Heat treatment parts") >= 0) { + typeID = "R"; + } else if (typeID.indexOf("շ伷") >= 0 + || typeID.indexOf("Cold rolled parts or cold extrusion parts") >= 0) { + typeID = "D"; + } else if (typeID.indexOf("ͼ") >= 0 || typeID.indexOf("Forge piece") >= 0) { + typeID = "D"; + } + } + String item_type = ""; + if (selCodeBean != null) { + item_type = selCodeBean.getType(); + } + String targetId = idField1.getText(); + if ("".equals(targetId.trim())) { + MessageBox.post("дϱţ", "ʾ", MessageBox.INFORMATION); + return; + } + String newID = targetId + jhID + typeID; + String revID = (String) revBox.getSelectedItem(); + String itemName = (String) nameComb.getSelectedItem(); + + if (classFlag) { + // --ƴӹвƷźͼŵƴ + productNumber = splicValue(defaultValueList, attrList, esAttrList, objMap, markList, isNList, lovMap); + drawingNumber = splicValue(defaultValueList2, attrList2, esAttrList2, objMap2, markList2, isNList2, + lovMap2); + // --end + System.out.println("productNumber============" + productNumber); + System.out.println("drawingNumber============" + drawingNumber); + if (productNumber == null || drawingNumber == null) { + return; + } + } else { + productNumber = targetItem.getStringProperty("rb3_th") + jhID; + drawingNumber = targetItem.getStringProperty("rb3_th") + jhID; + System.out.println("productNumber============" + productNumber); + System.out.println("drawingNumber============" + drawingNumber); + } + try { + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(item_type); + TCComponentItem find = itemType.find(newID); + // --TCǷѾڸID + if (find != null) { + MessageBox.post(":" + newID + "Ѵ,޷!", "", MessageBox.ERROR); + return; + } + // --end + // --ݲƷŲѯǷڲɹͼ + List compList = queryObject(cph_query, new String[] { "Ʒ" }, + new String[] { productNumber }); + if (compList != null) { + if (compList.size() > 0) { + MessageBox.post("ϵͳѴڲƷΪ" + productNumber + "ϣ룡", "", MessageBox.INFORMATION); + return; + } + } + // --end + + // -- + // --ǰȻȡλ + + String dlVal = (String) dl.getSelectedItem(); + TCComponent uom = tagMap.get(dlVal); + if (uom == null) { + MessageBox.post("λѡ", "", MessageBox.INFORMATION); + return; + } + // --end + TCComponentItem itemComp = itemType.create(newID, revID, item_type, itemName, null, uom); + // --ȡѡеڵļλ + getFolder(); + folder.add("contents", itemComp); + folder.refresh(); + // --end + // --end + + // --ɵIJİ汾ֵʼ + TCComponentItemRevision itemRev = itemComp.getLatestItemRevision(); + // --:״̬ + String statu = ""; + if ("A1".equals(revID)) { + statu = ":Conceptual design"; + } else if ("B1".equals(revID)) { + statu = ":Product design"; + } else if ("R1".equals(revID)) { + statu = ":Process design/Sample delivery"; + } else if ("P1".equals(revID)) { + statu = "P:Pilot production/small batch"; + } else if ("M1".equals(revID)) { + statu = "M:Mass production"; + } + itemRev.setStringProperty("rb3_smzqzt", statu); + // --end + + // --:Ʒ + itemRev.setStringProperty("rb3_cph", productNumber); + // --end + + // --: + itemRev.setStringProperty("rb3_jh", jhID); + // --end + + // --:ͼ + itemRev.setStringProperty("rb3_th", drawingNumber); + // --end + // -- + setObjectValues(itemRev); + // --end + // --end + + // --ɹͼ + createCGT(itemRev); + // --end + + // ɵIJӵBOM + TCTypeService typeService = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) typeService.getTypeComponent("BOMWindow"); + // һµwindow + TCComponentBOMWindow view = winType.create(null); + view.lock(); + // öbomline + TCComponentBOMLine line = view.setWindowTopLine(targetItem.getItem(), targetItem, null, null); + // bomline + TCComponentBOMLine childBomline = line.add(itemComp, itemRev, null, false, ""); + // + view.save(); + // + view.unlock(); + // ر + view.close(); + + Fenlei fenlei = getFenLeiAttr(); + Integer[] classKeys = fenlei.getClassKeys(); + String[] classVals = fenlei.getClassVals(); + // +++ + new Thread() { + @Override + public void run() { + sendObjToClassficationByWebService(className2, itemRev, classKeys, classVals, url); + MessageBox.post("ϴɹ", "", MessageBox.INFORMATION); + } + }.start(); + // +++ + setVisible(false); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + MessageBox.post("ϴʧܣ", "", MessageBox.INFORMATION); + } + } + + /** + * ͷ + * + * @param class_id + * @param rev + * @param keys + * @param vals + * @param url + */ + public void sendObjToClassficationByWebService(String class_id, TCComponentItemRevision rev, Integer[] keys, + String[] vals, String url) { + + try { + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList(); + + for (int i = 0; i < keys.length; i++) { + if (keys[i] != null && vals[i] != null) { + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + System.out.println("rev's uid is:" + rev.getUid()); + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Ϣ + * + * @return + */ + private Fenlei getFenLeiAttr() { + List vals = new ArrayList(); + for (Map value : values) { + for (Map.Entry entry : value.entrySet()) { + String type = entry.getKey(); + if (type.equals("JComboBox")) { + JComboBox comb1 = (JComboBox) entry.getValue(); + String val = (String) comb1.getSelectedItem(); + vals.add(val); + } else { + JTextField field1 = (JTextField) entry.getValue(); + String val = field1.getText(); + vals.add(val); + } + } + } + Integer[] classKeys = new Integer[classList.size()]; + String[] classVals = new String[classList.size()]; + System.out.println("size============================" + classList.size()); + for (int i = 0; i < labels1.length; i++) { + String val = vals.get(i); + if (val == null || val.trim() == "") { + continue; + } + String val2 = ""; + if (classList.get(i).isIslov()) { + val2 = classList.get(i).getLov().get(val);// ʵֵ + System.out.println("val2================" + val2); + System.out.println("val================" + val); + } else { + val2 = val; + } + classKeys[i] = classList.get(i).getId(); + String attrName = classList.get(i).getName(); + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName) + || (PlmLocaleUtil.getString("PartNumber")).equals(attrName)) { + if ("".equals(val2.trim())) { + JComboBox box = boxMap.get(attrName); + val2 = (String) box.getSelectedItem(); + } + } + classVals[i] = val2; + } + Fenlei fenlei = new Fenlei(); + fenlei.setClassKeys(classKeys); + fenlei.setClassVals(classVals); + System.out.println(fenlei.toString()); + return fenlei; + } + + private JTree getTree(MenuBean menuBean1) throws TCException { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(treenodename); + if (list != null && list.size() > 0) { + String id = targetItem.getProperty("item_id"); + String classID = "ZJ" + id.substring(0,6); + + System.out.println("classID"+classID); + //ݷIDȡ + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass adminClass = classificationService.newICSAdminClass(); + adminClass.load(classID); + String name = adminClass.getName(); + Boolean flag = true; + for (int i = 0; i < list.size(); i++) { + //ѡķIDɸѡҪѡĶ(δӢĻ) + if(name.contains("DZ")) { + if(list.get(i).getName().contains("DZ")) { + flag = false; + getRecursion(list.get(i), rootNode); + } + }else { + if(id.startsWith("22")) { + System.out.println("name1"+name); + System.out.println("name2"+list.get(i).getName()); + if(list.get(i).getName().startsWith("") && list.get(i).getName().endsWith(name)) { + flag = false; + getRecursion(list.get(i), rootNode); + } + }else if(id.startsWith("11")) { + System.out.println("name1"+name); + System.out.println("name2"+list.get(i).getName()); + if(list.get(i).getName().endsWith(name) && !list.get(i).getName().startsWith("")) { + flag = false; + getRecursion(list.get(i), rootNode); + } + } + } + + + } + if(flag) { + for (int i1 = 0; i1 < list.size(); i1++) { + getRecursion(list.get(i1), rootNode); + } + } + } + JTree tree = new JTree(rootNode); + tree.setShowsRootHandles(true); + + return tree; + } + + /** + * ˵ṹ + * + * @param menuBean1 + * @param rootNode + */ + private void getRecursion(MenuBean menuBean1, DefaultMutableTreeNode rootNode) { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode node = new DefaultMutableTreeNode(treenodename); + rootNode.add(node); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), node); + } + } + } + + /** + * ˢе + */ + private void refreshMsg() { + classFlag = true; + classFlag2 = false; + objMap.clear(); + objMap2.clear(); + fieldList.clear(); + comboxList.clear(); + fieldmap.clear(); + comboxmap.clear(); + lovMap.clear(); + lovMap2.clear(); + attrList.clear(); + esAttrList.clear(); + attrList2.clear(); + esAttrList2.clear(); + classList.clear(); + markList.clear(); + markList2.clear(); + isNList.clear(); + isNList2.clear(); + defaultValueList.clear(); + defaultValueList2.clear(); + jp2.removeAll(); + idList.clear(); + lovAttrs.clear(); + } + + /** + * ͨݹĸӽڵ + * + * @param treeNode + * @param names + * @return + */ + private String getNode(TreeNode treeNode, String names) { + // TODO Auto-generated method stub + if (!names.equals("")) { + names = "&" + names; + } + names = treeNode.toString() + names; + + TreeNode parent = treeNode.getParent(); + if (parent != null) { + return getNode(parent, names); + } + + return names; + } + + /** + * Ʒźͼŵɷ + * + * @param defaultValueList + * @param attrList + * @param esAttrList + * @param map + * @param markList + * @param isNList + * @param lovMap + * @return + */ + public String splicValue(List defaultValueList, List attrList, List esAttrList, + Map map, List markList, List isNList, Map lovMap) { + + List objList = new ArrayList(); + List lovList = new ArrayList(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < attrList.size(); i++) { + String attr = attrList.get(i); + System.out.println("attr======112" + attr); + String esAttr = esAttrList.get(i); + if (classFlag2) { + if ((PlmLocaleUtil.getString("heatTreatment")).equals(attr) + || (PlmLocaleUtil.getString("heatTreatment")).equals(esAttr)) { + objList.add(HeatTreatment); + lovList.add("string"); + continue; + } + } + if (map.get(attr) == null && map.get(esAttr) == null) { + if ((PlmLocaleUtil.getString("PartNumber")).equals(attr) + || (PlmLocaleUtil.getString("PartNumber")).equals(esAttr)) { + JComboBox idbox = boxMap.get(PlmLocaleUtil.getString("PartNumber")); + JTextField idfield = (JTextField) idList.get(0); + String fieldText = idfield.getText(); + String boxText = (String) idbox.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(PlmLocaleUtil.getString("PartNumber") + "ͬʱдֵ", "ʾ", + MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(fieldText); + lovList.add("string"); + } else { + objList.add(boxText); + lovList.add("string"); + } + continue; + } + objList.add(defaultValueList.get(i)); + lovList.add("string"); + continue; + } + if (!("".equals(attr.trim()))) { + Object obj = map.get(attr); + JComboBox box = null; + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attr) + || (PlmLocaleUtil.getString("RadialInternalClearance")).equals(esAttr)) { + box = boxMap.get(PlmLocaleUtil.getString("RadialInternalClearance")); + } + if (obj == null) { + obj = map.get(esAttr); + if (box != null) { + JTextField field = (JTextField) obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(esAttr + "ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(esAttr + "дһֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + } else { + objList.add(box); + lovList.add("yes"); + } + } else { + objList.add(obj); + lovList.add(lovMap.get(esAttr)); + } + } else { + if (box != null) { + JTextField field = (JTextField) obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(attr + "ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(attr + "дһֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + } else { + objList.add(box); + lovList.add("yes"); + } + } else { + objList.add(obj); + lovList.add(lovMap.get(attr)); + } + } + } + } + for (int i = 0; i < objList.size(); i++) { + String attrValue = ""; + Object obj = objList.get(i); + if (obj != null) { + if ("yes".equals(lovList.get(i))) { + String value = (String) ((JComboBox) obj).getSelectedItem(); + System.out.println("ֵΪ:" + value); + if (asList.contains(value) || esList.contains(value)) { + if (isNList.get(i).trim().contains(value)) { + if (value.contains(":")) { + System.out.println("value============" + value); + String[] values = value.split(":"); + value = values[0]; + } else if (value.contains("")) { + System.out.println("value============" + value); + String[] values = value.split(""); + value = values[0]; + } + } else { + value = ""; + } + } else { + if (value.contains(":")) { + System.out.println("value============" + value); + String[] values = value.split(":"); + value = values[0]; + } else if (value.contains("")) { + System.out.println("value============" + value); + String[] values = value.split(""); + value = values[0]; + } + } + if ("Ʒ".equals(value) || "Finished product".equals(value)) { + value = ""; + } else if ("".equals(value) || "Turning workpiece".equals(value)) { + value = "C"; + } else if ("ȴ".equals(value) || "Heat treatment parts".equals(value)) { + value = "R"; + } else if ("շ伷".equals(value) || "Cold rolled parts or cold extrusion parts".equals(value)) { + value = "D"; + } else if ("ͼ".equals(value) || "Forge piece".equals(value)) { + value = "D"; + } + attrValue = value; + } else if ("no".equals(lovList.get(i))) { + attrValue = ((JTextField) obj).getText(); + } else { + attrValue = (String) obj; + } + if (asList.contains(attrValue) || esList.contains(attrValue)) { + attrValue = ""; + } else { + if (attrValue.contains(":")) { + System.out.println("attrValue============" + attrValue); + String[] values = attrValue.split(":"); + attrValue = values[0]; + } else if (attrValue.contains("")) { + System.out.println("attrValue============" + attrValue); + String[] values = attrValue.split(""); + attrValue = values[0]; + } + } + String mark = markList.get(i); + if (!("".equals(attrValue.trim()))) { + sb.append(mark.trim()); + sb.append(attrValue); + } + } + } + return sb.toString(); + } + + /** + * ȡ + * + * @param className + * @return + */ + private ICSAdminClassAttribute[] getClassAttrs(String className) { + try { + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(className); + ICSAdminClassAttribute[] icsAttrs = c.getAttributes(); + return icsAttrs; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * ͨѯѯ + * + * @param queryName + * @param keys + * @param values + * @return + */ + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + return null; + } + } + + /** + * ȡѡֵ + * + * @param preName + * @return + */ + private Map getPrefValues(String preName) { + Map map = new HashMap(); + String[] preVal = service.getStringValues(preName); + if (preVal != null) { + for (String val : preVal) { + String[] split = val.split("="); + map.put(split[0], split[1]); + } + System.out.println(preName + "ѡֵΪ:" + map); + return map; + } else { + MessageBox.post(preName + "ѡû!", "", MessageBox.ERROR); + return null; + } + } + + /** + * ȡѡϵĸļ + */ + public void getFolder() { + boolean b = false; + if (refs.length > 0) { + for (AIFComponentContext ref : refs) { + InterfaceAIFComponent component = ref.getComponent(); + if (component instanceof TCComponentFolder) { + folder = (TCComponentFolder) component; + b = true; + break; + } + } + } + if (!b) { + try { + folder = session.getUser().getHomeFolder(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * ƷͼĴ + * + * @param itemRev汾 + */ + private void createCGT(TCComponentItemRevision itemRev) { + try { + if (revList.size() > 0) { + TCComponentItemRevision picItem = revList.get(0); + TCComponent[] pics; + + pics = picItem.getReferenceListProperty("TC_Is_Represented_By"); + for (int i = 0; i < pics.length; i++) { + itemRev.add("TC_Is_Represented_By", pics[i]); + } + + } else { + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent("RB3_CGT"); + // String revID = typeComponent.getNewRev(null); + // String drawID = typeComponent.getNewID(); + String item_id = targetItem.getProperty("item_id"); + String id = dealItemId(item_id); + if (id != null) { + build.append(id); + build.append(drawingNumber); + } + String[] keys = new String[] { " ID" }; + String[] values = new String[] { build.toString() }; + List tzList = queryObject(" ID", keys, values); + TCComponentItemRevision CPTRev = null; + if (tzList != null) { + if (tzList.size() > 0) { + if (tzList.get(0) instanceof TCComponentItem) { + TCComponentItem tcItem = (TCComponentItem) tzList.get(0); + CPTRev = tcItem.getLatestItemRevision(); + } + } + } else { + if (id != null) { + TCComponentItem CPTItem = typeComponent.create(build.toString(), "V1", "RB3_CGT", "", "", null); + CPTRev = CPTItem.getLatestItemRevision(); + if (CPTItem != null) { + // session.getUser().getHomeFolder().add("contents", CPTItem); + // session.getUser().getHomeFolder().refresh(); + if (build.toString().length() > 0) { + CPTRev.setStringProperty("rb3_th", build.toString()); + } else { + CPTRev.setStringProperty("rb3_th", drawingNumber); + } + folder.add("contents", CPTItem); + folder.refresh(); + } + } else { + TCComponentItem CPTItem = typeComponent.create(drawingNumber, "V1", "RB3_CGT", "", "", null); + CPTRev = CPTItem.getLatestItemRevision(); + if (CPTItem != null) { + // session.getUser().getHomeFolder().add("contents", CPTItem); + // session.getUser().getHomeFolder().refresh(); + folder.add("contents", CPTItem); + folder.refresh(); + } + } + } + itemRev.add("TC_Is_Represented_By", CPTRev); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * itemIDĴ + */ + public String dealItemId(String id) { + String subs = id.substring(0, 2); + if (subs.equals("XX")) { + + String sub = id.substring(2, 4); + if (sub.equals("22")) { + System.out.println("idXX22ͷ!"); + return "XX-"; + } + } else if (subs.equals("22")) { + System.out.println("id22ͷ!"); + return "SF-"; + } + return null; + } + + /** + * ͨťѯеֵ + * + * @param bu Ҫ󶨼İť + * @param jt + * @param box + */ + public void queryByButton(JButton bu, JTextField jt, JComboBox box) { + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + System.out.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(box, tip); + } + } + + }); + } + + /** + * ҳӶ + * + * @param v + * @param prefName + */ + public void addObjectAttrs(int v, String prefName) { + jp2.add(v + ".1.center.top", new JLabel(" ")); + jp2.add(v + ".2.center.top", new JLabel("****************************")); + v += 1; + // λ + jp2.add(v + ".1.center.top", new JLabel("λ")); + try { + tagMap.clear(); + dl = new JComboBox(); + dl.setSize(new Dimension(60, 40)); + dl.setName("uom_tag"); + TCProperty zclov1; + TCComponentItem oldItem = targetItem.getItem(); + zclov1 = oldItem.getTCProperty("uom_tag"); + + TCComponentListOfValues zcprolov1 = zclov1.getLOV(); + String[] comboxitems1; + JTextField jt1 = new JTextField(9); + JButton bu1 = new JButton(""); + if (zcprolov1 != null) { + comboxitems1 = zcprolov1.getListOfValues().getLOVDisplayValues(); + TCComponent[] tags = zcprolov1.getListOfValues().getTagListOfValues(); + for (int flag = 0; flag < comboxitems1.length; flag++) { + tagMap.put(comboxitems1[flag], tags[flag]); + } + ComboBoxModel model1 = new DefaultComboBoxModel(comboxitems1); + dl.setModel(model1); + queryByButton(bu1, jt1, dl); + } + dl.setSelectedItem(oldItem.getProperty("uom_tag")); + // if(!(ZC_LBJ_list.LBJDisPros.get(i)).equals("ʱϱʶ")) { + dl.setSelectedIndex(-1); + jp2.add(v + ".2.center.top", dl); + jp2.add((v) + ".3.center.top", jt1); + jp2.add((v) + ".4.center.top", bu1); + v += 1; + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + // end + // Եļֵ(ʾֵ--ʵֵ) + Map attrsMap = getPrefValues(prefName); + Set> entrySet = attrsMap.entrySet(); + for (Entry entry : entrySet) { + String disName = entry.getKey(); + String realname = entry.getValue(); + jp2.add(v + ".1.center.top", new JLabel(disName)); + + try { + String val = targetItem.getProperty(realname); + TCProperty tcProperty = targetItem.getTCProperty(realname); + TCComponentListOfValues lov = tcProperty.getLOV(); + // --жǷǸlov + if (lov != null) { + // --Ƕֵԣ⴦ + JComboBox box; + if (realname.equals("rb3_scgc1")) { + String[] comboxitems = lov.getListOfValues().getLOVDisplayValues(); + box = new RwJComboBox(comboxitems); + box.setEditable(true); + realname.replace("1", ""); + String lovname = "rb3_scgc"; + box.setName(lovname); + box.setSize(new Dimension(60, 40)); + box.setSelectedItem(val); + String[] realitems = lov.getListOfValues().getStringListOfValues(); + dealLovValues(lovname, comboxitems, realitems); + jp2.add(v + ".2.center.top", box); + } else { + + box = new JComboBox(); + box.setSize(new Dimension(60, 40)); + box.setName(realname); + String[] comboxitems = lov.getListOfValues().getLOVDisplayValues(); + ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + box.setModel(model); + box.setSelectedItem(val); + String[] realitems = lov.getListOfValues().getStringListOfValues(); + dealLovValues(realname, comboxitems, realitems); + JTextField jt1 = new JTextField(9); + JButton bu1 = new JButton(""); + queryByButton(bu1, jt1, box); + jp2.add(v + ".2.center.top", box); + jp2.add(v + ".3.center.top", jt1); + jp2.add(v + ".4.center.top", bu1); + } + // --end + comboxList.add(box); + + } else { + JTextField field = new JTextField(18); + field.setName(realname); + field.setText(val); + jp2.add(v + ".2.center.top", field); + fieldList.add(field); + } + // --end + v += 1; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * 洢lovʵֵʾֵ + * + * @param lovName + * @param disNames ʾֵ + * @param realNames ʵֵ + */ + private void dealLovValues(String lovName, String[] disNames, String[] realNames) { + HashMap map = new HashMap(); + for (int i = 0; i < disNames.length; i++) { + map.put(disNames[i], realNames[i]); + } + lovAttrs.put(lovName, map); + System.out.println("lovAttrsֵΪ:" + lovAttrs); + } + + private void setObjectValues(TCComponentItemRevision itemRev) { + Map map = new HashMap(); + for (Object obj : fieldList) { + JTextField text = (JTextField) obj; + String attrName = text.getName(); + String attrValue = text.getText(); + map.put(attrName, attrValue); + } + for (Object obj : comboxList) { + JComboBox box = (JComboBox) obj; + String attrName = box.getName(); + HashMap lovmap = lovAttrs.get(attrName); + String attrValue = (String) box.getSelectedItem(); + + if (attrName.equals("rb3_scgc")) { + System.out.println("ֵΪ:" + attrValue); + String[] split = attrValue.split(","); + List list = new ArrayList(); + for (String key : split) { + String val = lovmap.get(key); + if (val != null) { + list.add(val); + } + + } + String[] ss = list.toArray(new String[list.size()]); + try { + itemRev.getTCProperty(attrName).setStringValueArray(ss); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } else { + System.out.println("attrNameֵΪ:" + attrName); + System.out.println("attrValueֵΪ:" + attrValue); + + String realVal = lovmap.get(attrValue); + System.out.println("lovԵʵֵΪ:" + realVal); + map.put(attrName, realVal); + } + } + try { + System.out.println("ԵļֵΪ:" + map); + itemRev.setProperties(map); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/rb/plm/biaozhunjian/GZLiShuDialogtop.java b/src/com/connor/rb/plm/biaozhunjian/GZLiShuDialogtop.java new file mode 100644 index 0000000..3225176 --- /dev/null +++ b/src/com/connor/rb/plm/biaozhunjian/GZLiShuDialogtop.java @@ -0,0 +1,1601 @@ +package com.connor.rb.plm.biaozhunjian; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.KeyStroke; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; + +import com.connor.rb.plm.util.ClassAttributeBean; +import com.connor.rb.plm.util.ClassProperty; +import com.connor.rb.plm.util.CodeBean; +import com.connor.rb.plm.util.GetCodeBean1; +import com.connor.rb.plm.util.MenuBean; +import com.connor.rb.plm.util.ParseXML; +import com.connor.rb.plm.util.PlmLocaleUtil; +import com.connor.rb.plm.util.SearchJComItem; +import com.connor.rb.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSKeyLov.KeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class GZLiShuDialogtop extends AbstractAIFDialog { + private Map> attrMap; + private Map> attrMap2; + private AbstractAIFApplication app; + private GetCodeBean1 getcode; + private TCSession session; + private MenuBean menuBean; + private String name, name1; + private TCPreferenceService service; + private List asList = new ArrayList(); + private List esList = new ArrayList(); + private TCComponentItemRevision targetItem; + private TCComponentItem tccItem; + private JButton okBut = new JButton("ȷ"); + private JButton button2 = new JButton("ͼֽ"); + private JButton celBut = new JButton("ȡ"); + private AIFComponentContext[] refs;// Ŀùϵ + private JPanel classJpanel; + private JPanel jp1; + private JPanel jp2; + private JScrollPane scr2; + private boolean classFlag; + private boolean classFlag2; + private Map objMap = new HashMap(); + private Map objMap2 = new HashMap(); + private Map lovMap = new HashMap(); + private Map lovMap2 = new HashMap(); + private List attrList = new ArrayList(); + private List esAttrList = new ArrayList(); + private String className2; + private List revList = new ArrayList(); + // TextField + private List fieldList = new ArrayList(); + // box + private List comboxList = new ArrayList(); + private Map fieldmap = new HashMap<>(); + private Map comboxmap = new HashMap<>(); + // private List objList = new ArrayList(); + // private List lovList = new ArrayList(); + private List attrList2 = new ArrayList(); + private List esAttrList2 = new ArrayList(); + // private List objList2 = new ArrayList(); + // private List lovList2 = new ArrayList(); + private List markList = new ArrayList(); + private List markList2 = new ArrayList(); + private List isNList = new ArrayList(); + private List isNList2 = new ArrayList(); + private List defaultValueList = new ArrayList(); + private List defaultValueList2 = new ArrayList(); + private List classList = new ArrayList(); + private List idList = new ArrayList(); + protected CodeBean selCodeBean; + private Map> boxMap = new HashMap>(); + protected JLabel revLabel; + protected JComboBox revBox; + private String productNumber = ""; + private String drawingNumber = ""; + // ƷŵIJѯ + private String cph_query = ""; + // 汾ѡ + private String rev_ids = "RB_Revision_id"; + // ѡ + private String gz_name = ""; + private String attrs = ""; + protected JLabel nameLabel; + protected JComboBox nameComb; + protected JLabel idLabel; + protected JTextField idField1; + protected JLabel[] labels1 = null; + private HashMap map2; + private List> values; + // + private int v = 0; + private String HeatTreatment = ""; + private List typeList = new ArrayList(); + private TCComponentFolder folder; + private StringBuilder build = new StringBuilder(); + private String url; + // λ + private Map tagMap = new HashMap(); + // λ + private JComboBox dl; + // lovֵԵmap + private Map> lovAttrs = new HashMap>(); + + public GZLiShuDialogtop(AbstractAIFApplication app, String name, String name1, String cph_query, String gz_name, + String attrs) { + super(false); + this.app = app; + this.name = name; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.values = new ArrayList>(); + this.name1 = name1; + this.cph_query = cph_query; + this.gz_name = gz_name; + this.attrs = attrs; + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + } + + @Override + public void run() { + // TODO Auto-generated method stub + getcode = new GetCodeBean1(session); + // if(getcode==null) System.out.println("================>getcode = new + // GetCodeBean1(session);;getcodeΪ"); + menuBean = getcode.getMenuBean(name); + // if(menuBean==null) System.out.println("================>menuBean = + // getcode.getMenuBean(name);;;menuBeanΪ"); + + String lovVal = service.getStringValue("RB3_lovVal_default"); + String esLovVal = service.getStringValue("RB3_esLovVal_default"); + + if (lovVal.contains(";")) { + String[] vals = lovVal.split(";"); + String[] esVals = esLovVal.split(";"); + for (int i = 0; i < vals.length; i++) { + asList.add(vals[i]); + esList.add(esVals[i]); + } + } + + ParseXML xml = new ParseXML(); + File file = xml.getSXX("RB3_CPHPJFS", session); + + attrMap = xml.parseXMLAttr(file); + if (attrMap == null || attrMap.size() <= 0) { + MessageBox.post("ѡRB3_CPHPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + + File file2 = xml.getSXX("RB3_THPJFS", session); + attrMap2 = xml.parseXMLAttr(file2); + if (attrMap2 == null || attrMap2.size() <= 0) { + MessageBox.post("ѡRB3_THPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + + InterfaceAIFComponent targetComp = app.getTargetComponent(); + if (targetComp instanceof TCComponentItemRevision) { + targetItem = (TCComponentItemRevision) targetComp; + try { + tccItem = targetItem.getItem(); + refs = tccItem.whereReferenced(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + init(); + } + + /** + * ƽ + */ + public void init() { + this.setTitle(name1); + this.setPreferredSize(new Dimension(860, 900)); + this.setLayout(new BorderLayout()); + classJpanel = new JPanel(new BorderLayout());// Խ + jp1 = new JPanel(new BorderLayout()); + jp2 = new JPanel(new PropertyLayout()); + jp1.setPreferredSize(new Dimension(200, 820)); + scr2 = new JScrollPane(jp2); + scr2.setPreferredSize(new Dimension(640, 820)); + classJpanel.add(scr2); + + // ṹ + JTree tree = getTree(menuBean); + + // esc˳ + KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); + this.getRootPane().registerKeyboardAction(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int option = JOptionPane.showOptionDialog(null, "ȷ˳˵", "", 0, 1, null, null, Integer.valueOf(0)); + if (option == 0) { + System.out.println("˳"); + disposeDialog(); + } else { + return; + } + } + }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); + + // Ӽť + tree.addTreeSelectionListener(new TreeSelectionListener() { + public void valueChanged(TreeSelectionEvent e) { + // ˢ(е) + refreshMsg(); + // ȡѡеĽڵ + DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) e.getPath().getLastPathComponent(); + int childCount = treeNode.getChildCount(); + System.out.println("ǰѡеĽڵ: " + treeNode + " ӽڵ:" + childCount); + if (childCount > 0) { + jp2.setVisible(false); + } else { + String names = getNode(treeNode, ""); + selCodeBean = getcode.getCodebean(names); + if (selCodeBean == null) { + MessageBox.post("ѡײڵ㣡", "ʾ", MessageBox.INFORMATION); + return; + } + // --Ϣ + JTextField idfield = new JTextField(18); + idList.add(idfield); + JComboBox idbox = new JComboBox(); + idList.add(idbox); + idbox.addItem(" "); + String[] idstrs = new String[100]; + for (int j = 0; j < 100; j++) { + if (j < 10) { + idstrs[j] = "0" + j; + } else { + idstrs[j] = j + ""; + } + } + for (int j = 0; j < idstrs.length; j++) { + idbox.addItem(idstrs[j]); + } + boxMap.put(PlmLocaleUtil.getString("PartNumber"), idbox); + // --end + + // --汾Ϣ + revLabel = new JLabel("汾"); + revBox = new JComboBox(); + revBox.setEditable(false); + revBox.addItem("B1"); + + // ͨѡȡ汾 + String[] revs = service.getStringValues(rev_ids); + if (revs == null || revs.length <= 0) { + MessageBox.post("ѡRB_Revision_idδ,ϵԱ!!", "", MessageBox.ERROR); + return; + } + for (int i = 0; i < revs.length; i++) { + revBox.addItem(revs[i]); + } + // --end + + // --Ϣ + nameLabel = new JLabel(""); + nameComb = new JComboBox(); + nameComb.setEditable(false); + + nameComb.addItem(""); + // ͨѡȡ + String[] gzNames = service.getStringValues(gz_name); + if (gzNames == null || gzNames.length <= 0) { + MessageBox.post("ѡRB3_GZ_namesδ,ϵԱ!!", "", MessageBox.ERROR); + return; + } + for (int i = 0; i < gzNames.length; i++) { + nameComb.addItem(gzNames[i]); + } + nameComb.setSelectedIndex(1); + // --end + + // --ϱ + idLabel = new JLabel("ܳϱ"); + idField1 = new JTextField(18); + try { + idField1.setText(targetItem.getProperty("item_id")); + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + // --end + + jp2.add("1.1.center.center", new JLabel("")); + jp2.add("2.1.center.center", idLabel); + jp2.add("2.2.center.center", idField1); + jp2.add("3.1.center.center", nameLabel); + jp2.add("3.2.center.center", nameComb); + jp2.add("4.1.center.center", new JLabel(PlmLocaleUtil.getString("PartNumber"))); + jp2.add("4.2.center.center", idfield); + jp2.add("4.3.center.center", idbox); + jp2.add("5.1.center.center", revLabel); + jp2.add("5.2.center.center", revBox); + + // ȡ + try { + String className = targetItem.getClassificationClass(); + ICSAdminClassAttribute[] icsAttrs = getClassAttrs(className); + TCComponentICO[] icos = targetItem.getClassificationObjects(); + if (icos == null || icos.length <= 0) { + MessageBox.post("ѡеûз͵࣬뷢ͣ", "ʾ", MessageBox.INFORMATION); + return; + } + Map claMap = new HashMap(); + if (icos != null && icos.length > 0) { + + ICSProperty[] icss = icos[0].getICSProperties(true); + + for (ICSProperty ics : icss) { + for (ICSAdminClassAttribute icsa : icsAttrs) { + if (icsa.getAttributeId() == ics.getId()) { + System.out.print("icsa.getName():" + icsa.getName()); + claMap.put(icsa.getName(), ics.getValue()); + } + } + } + } + + // ѡеķ + className2 = selCodeBean.getClassID(); + if (attrMap.containsKey(className2)) { + List nameMarkList = attrMap.get(className2); + String attrNames = nameMarkList.get(0); + String marks = nameMarkList.get(1); + String defaultValues = nameMarkList.get(2); + String isN = nameMarkList.get(3); + if (attrNames.contains(";")) { + String[] attrs = attrNames.split(";"); + String[] markss = marks.split(";"); + String[] valuess = defaultValues.split(";"); + String[] isNs = isN.split(";"); + for (int i = 0; i < attrs.length; i++) { + System.out.println("attrs==============" + attrs[i]); + if (attrs[i].contains("+")) { + String[] attrss = attrs[i].split("\\+"); + attrList.add(attrss[0]); + esAttrList.add(attrss[1]); + markList.add(markss[i]); + defaultValueList.add(valuess[i]); + isNList.add(isNs[i]); + } + } + } + + List nameMarkList2 = attrMap2.get(className2); + String attrNames2 = nameMarkList2.get(0); + String marks2 = nameMarkList2.get(1); + String defaultValues2 = nameMarkList2.get(2); + String isNs2 = nameMarkList2.get(3); + System.out.println("attrNames2============" + attrNames2); + if (attrNames2.contains(";")) { + String[] attrs2 = attrNames2.split(";"); + String[] markss2 = marks2.split(";"); + String[] valuess = defaultValues2.split(";"); + String[] isNs2s = isNs2.split(";"); + for (int i = 0; i < attrs2.length; i++) { + if (attrs2[i].contains("+")) { + String[] attrss = attrs2[i].split("\\+"); + attrList2.add(attrss[0]); + esAttrList2.add(attrss[1]); + markList2.add(markss2[i]); + defaultValueList2.add(valuess[i]); + isNList2.add(isNs2s[i]); + } + } + } + } + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c2 = classificationService.newICSAdminClass(); + c2.load(className2); + String cName = c2.getName(); + ICSAdminClassAttribute[] icsAttrS2 = c2.getAttributes(); + if (PlmLocaleUtil.getString("BearingAccessories").equals(cName)) { + classFlag = false; + } else if (PlmLocaleUtil.getString("Cage").equals(cName)) { + classFlag2 = true; + } + System.out.println("cName===" + cName); + if (icsAttrS2 != null) { + for (ICSAdminClassAttribute attr : icsAttrS2) { + if (attr.isHidden()) { + continue; + } + ClassAttributeBean bean = new ClassAttributeBean(); + if (attr.isReferenceAttribute()) {// + continue; + } + if (attr.isReference()) { + continue; + } + int propID = attr.getAttributeId(); + bean.setId(propID); + String propDisName = attr.getName(); + System.out.print("propDisName:" + propDisName); + bean.setName(propDisName); + + int attrType = attr.getFormat1().getType(); + bean.setType(attrType); + // ÷ + if (claMap != null && claMap.containsKey(propDisName)) { + bean.setVal(claMap.get(propDisName)); + } else { + bean.setVal(""); + } + ICSKeyLov lov1 = attr.getFormat1().getKeyLov(); + lov1 = (lov1 == null ? attr.getFormat2().getKeyLov() : lov1); + if (lov1 != null) { + bean.setIslov(true); + String[] keys = lov1.getKeys(); + Map map1 = new HashMap(); + for (String key : keys) { + KeyLov lov_key = lov1.getKeyLovOfKey(key); + boolean deprecated = lov_key.isDeprecated(); + if (deprecated) { + if (key.equals(bean.getVal())) { + bean.setVal(""); + } + continue; + } + String value = lov1.getValueOfKey(key); + map1.put(value, key);// <ʾֵ,ʵֵ> + if (key.equals(bean.getVal()) && (!bean.getVal().equals(""))) { + bean.setVal(value); + } + } + bean.setLov(map1); + } else { + bean.setIslov(false); + } + + classList.add(bean); + + } + } + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + labels1 = new JLabel[classList.size()]; + // + for (int i = 0; i < classList.size(); i++) { + ClassAttributeBean bean = classList.get(i); + String attrName = bean.getName(); + labels1[i] = new JLabel(attrName); + jp2.add((i + 6) + ".1.center.top", labels1[i]); + labels1[i].setBounds(5, 5, 5, 5); + String value = bean.getVal(); + System.out.println("ĬֵΪ:" + value); + // жϷǷlov + if (bean.isIslov()) { + JComboBox comb = new JComboBox(); + comb.setEditable(false); + comb.setSize(new Dimension(60, 40)); + // -- + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + queryByButton(bu, jt, comb); + // --end + if (classFlag2) { + if ((PlmLocaleUtil.getString("heatTreatment")).equals(attrName)) { + comb.addItem(""); + HeatTreatment = value; + } else { + comb.addItem(value); + } + } else { + comb.addItem(value); + } + for (Entry entry : bean.getLov().entrySet()) { + // lovĵһֵɸѡ + if (i == 0) { + System.out.println("entry.getKey()====" + entry.getKey()); + } + if (!(value.equals(entry.getKey()))) { + comb.addItem(entry.getKey()); + } + } + map2 = new HashMap(); + map2.put("JComboBox", comb); + values.add(map2); + jp2.add((i + 6) + ".2.center.top", comb); + jp2.add((i + 6) + ".3.center.top", jt); + jp2.add((i + 6) + ".4.center.top", bu); + // --Ʒźͼƴӷʽݽƥ䣬ƥ䵽ӵmap + if (attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, comb); + lovMap.put(attrName, "yes"); + } + if (attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, comb); + lovMap2.put(attrName, "yes"); + } + // Ϊ⴦ + if ((PlmLocaleUtil.getString("Category")).equals(attrName)) { + typeList.add(comb); + } + // --end + } else { + JTextField field = new JTextField(18); + field.setText(value); + map2 = new HashMap(); + map2.put("JTextField", field); + values.add(map2); + jp2.add((i + 6) + ".2.center.top", field); + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName)) { + JComboBox box = new JComboBox(); + // -- + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + queryByButton(bu, jt, box); + // --end + box.addItem(" "); + String[] strs = new String[] { "C0", "C2", "C3", "C4", "C5" }; + for (int j = 0; j < strs.length; j++) { + box.addItem(strs[j]); + } + boxMap.put(attrName, box); + jp2.add((i + 6) + ".3.center.top", box); + jp2.add((i + 6) + ".4.center.top", jt); + jp2.add((i + 6) + ".5.center.top", bu); + } + + // --Ʒźͼƴӷʽݽƥ䣬ƥ䵽ӵmap + if (attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, field); + lovMap.put(attrName, "no"); + } + if (attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, field); + lovMap2.put(attrName, "no"); + } + // --end + + } + v = i + 7; + } + + // --ʼӶ + addObjectAttrs(v, attrs); + // --end + + jp2.setVisible(true); + jp2.validate(); + jp2.repaint(); + scr2.validate(); + } + } + + }); + + // 岼// + JScrollPane scrollPane = new JScrollPane(tree); + scrollPane.setPreferredSize(new Dimension(250, 250)); + // ӹ嵽// + jp1.add(scrollPane, BorderLayout.CENTER); + classJpanel.add(scr2); + JSplitPane splitPane = new JSplitPane(); + splitPane.setOneTouchExpandable(true);// ÷ָʾͷ + splitPane.setContinuousLayout(true);// ͷػͼ + splitPane.setLeftComponent(new JScrollPane(jp1)); + splitPane.setRightComponent(new JScrollPane(classJpanel)); + JPanel titlePanel = new JPanel(new FlowLayout());// Խ + + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(button2); + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(okBut); + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(celBut); + this.add(splitPane, BorderLayout.CENTER); + this.add(titlePanel, BorderLayout.SOUTH); + + button2.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("׼"); + G4MDialog classDialog = new G4MDialog("˱", null, revList, session); + new Thread(classDialog).start(); + } + }); + + okBut.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + createItem(); + // setVisible(false); + } + + }); + celBut.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("ȡ"); + setVisible(false); + } + }); + this.setVisible(true); + this.centerToScreen(); + } + + /** + * + */ + private void createItem() { + String jhID = ""; + try { + if (idList != null && idList.size() > 0) { + JTextField idField = (JTextField) idList.get(0); + JComboBox idbox = (JComboBox) idList.get(1); + String id = idField.getText(); + String boxID = (String) idbox.getSelectedItem(); + if ("".equals(id.trim())) { + id = boxID.trim(); + } + jhID = id; + } + + String typeID = ""; + if (typeList != null && typeList.size() > 0) { + JComboBox idComb = typeList.get(0); + typeID = (String) idComb.getSelectedItem(); + if (typeID.indexOf("Ʒ") >= 0 || typeID.indexOf("Finished product") >= 0) { + typeID = ""; + } else if (typeID.indexOf("") >= 0 || typeID.indexOf("Turning workpiece") >= 0) { + typeID = "C"; + } else if (typeID.indexOf("ȴ") >= 0 || typeID.indexOf("Heat treatment parts") >= 0) { + typeID = "R"; + } else if (typeID.indexOf("շ伷") >= 0 + || typeID.indexOf("Cold rolled parts or cold extrusion parts") >= 0) { + typeID = "D"; + } else if (typeID.indexOf("ͼ") >= 0 || typeID.indexOf("Forge piece") >= 0) { + typeID = "D"; + } + } + String item_type = ""; + if (selCodeBean != null) { + item_type = selCodeBean.getType(); + } + String targetId = idField1.getText(); + if ("".equals(targetId.trim())) { + MessageBox.post("дϱţ", "ʾ", MessageBox.INFORMATION); + return; + } + String newID = targetId + jhID + typeID; + String revID = (String) revBox.getSelectedItem(); + String itemName = (String) nameComb.getSelectedItem(); + + if (classFlag) { + // --ƴӹвƷźͼŵƴ + productNumber = splicValue(defaultValueList, attrList, esAttrList, objMap, markList, isNList, lovMap); + drawingNumber = splicValue(defaultValueList2, attrList2, esAttrList2, objMap2, markList2, isNList2, + lovMap2); + // --end + System.out.println("productNumber============" + productNumber); + System.out.println("drawingNumber============" + drawingNumber); + if (productNumber == null || drawingNumber == null) { + return; + } + } else { + productNumber = targetItem.getStringProperty("rb3_th") + jhID; + drawingNumber = targetItem.getStringProperty("rb3_th") + jhID; + System.out.println("productNumber============" + productNumber); + System.out.println("drawingNumber============" + drawingNumber); + } + try { + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(item_type); + TCComponentItem find = itemType.find(newID); + // --TCǷѾڸID + if (find != null) { + MessageBox.post(":" + newID + "Ѵ,޷!", "", MessageBox.ERROR); + return; + } + // --end + // --ݲƷŲѯǷڲɹͼ + List compList = queryObject(cph_query, new String[] { "Ʒ" }, + new String[] { productNumber }); + if (compList != null) { + if (compList.size() > 0) { + MessageBox.post("ϵͳѴڲƷΪ" + productNumber + "ϣ룡", "", MessageBox.INFORMATION); + return; + } + } + // --end + + // -- + // --ǰȻȡλ + + String dlVal = (String) dl.getSelectedItem(); + TCComponent uom = tagMap.get(dlVal); + if (uom == null) { + MessageBox.post("λѡ", "", MessageBox.INFORMATION); + return; + } + // --end + TCComponentItem itemComp = itemType.create(newID, revID, item_type, itemName, null, uom); + // --ȡѡеڵļλ + getFolder(); + folder.add("contents", itemComp); + folder.refresh(); + // --end + // --end + + // --ɵIJİ汾ֵʼ + TCComponentItemRevision itemRev = itemComp.getLatestItemRevision(); + // --:״̬ + String statu = ""; + if ("A1".equals(revID)) { + statu = ":Conceptual design"; + } else if ("B1".equals(revID)) { + statu = ":Product design"; + } else if ("R1".equals(revID)) { + statu = ":Process design/Sample delivery"; + } else if ("P1".equals(revID)) { + statu = "P:Pilot production/small batch"; + } else if ("M1".equals(revID)) { + statu = "M:Mass production"; + } + itemRev.setStringProperty("rb3_smzqzt", statu); + // --end + + // --:Ʒ + itemRev.setStringProperty("rb3_cph", productNumber); + // --end + + // --: + itemRev.setStringProperty("rb3_jh", jhID); + // --end + + // --:ͼ + itemRev.setStringProperty("rb3_th", drawingNumber); + // --end + // -- + setObjectValues(itemRev); + // --end + // --end + + // --ɹͼ + createCGT(itemRev); + // --end + + // ɵIJӵBOM + TCTypeService typeService = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) typeService.getTypeComponent("BOMWindow"); + // һµwindow + TCComponentBOMWindow view = winType.create(null); + view.lock(); + // öbomline + TCComponentBOMLine line = view.setWindowTopLine(targetItem.getItem(), targetItem, null, null); + // bomline + TCComponentBOMLine childBomline = line.add(itemComp, itemRev, null, false, ""); + // + view.save(); + // + view.unlock(); + // ر + view.close(); + + Fenlei fenlei = getFenLeiAttr(); + Integer[] classKeys = fenlei.getClassKeys(); + String[] classVals = fenlei.getClassVals(); + // +++ + new Thread() { + @Override + public void run() { + sendObjToClassficationByWebService(className2, itemRev, classKeys, classVals, url); + MessageBox.post("ϴɹ", "", MessageBox.INFORMATION); + } + }.start(); + // +++ + setVisible(false); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + MessageBox.post("ϴʧܣ", "", MessageBox.INFORMATION); + } + } + + /** + * ͷ + * + * @param class_id + * @param rev + * @param keys + * @param vals + * @param url + */ + public void sendObjToClassficationByWebService(String class_id, TCComponentItemRevision rev, Integer[] keys, + String[] vals, String url) { + + try { + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList(); + + for (int i = 0; i < keys.length; i++) { + if (keys[i] != null && vals[i] != null) { + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + System.out.println("rev's uid is:" + rev.getUid()); + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Ϣ + * + * @return + */ + private Fenlei getFenLeiAttr() { + List vals = new ArrayList(); + for (Map value : values) { + for (Map.Entry entry : value.entrySet()) { + String type = entry.getKey(); + if (type.equals("JComboBox")) { + JComboBox comb1 = (JComboBox) entry.getValue(); + String val = (String) comb1.getSelectedItem(); + vals.add(val); + } else { + JTextField field1 = (JTextField) entry.getValue(); + String val = field1.getText(); + vals.add(val); + } + } + } + Integer[] classKeys = new Integer[classList.size()]; + String[] classVals = new String[classList.size()]; + System.out.println("size============================" + classList.size()); + for (int i = 0; i < labels1.length; i++) { + String val = vals.get(i); + if (val == null || val.trim() == "") { + continue; + } + String val2 = ""; + if (classList.get(i).isIslov()) { + val2 = classList.get(i).getLov().get(val);// ʵֵ + System.out.println("val2================" + val2); + System.out.println("val================" + val); + } else { + val2 = val; + } + classKeys[i] = classList.get(i).getId(); + String attrName = classList.get(i).getName(); + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName) + || (PlmLocaleUtil.getString("PartNumber")).equals(attrName)) { + if ("".equals(val2.trim())) { + JComboBox box = boxMap.get(attrName); + val2 = (String) box.getSelectedItem(); + } + } + classVals[i] = val2; + } + Fenlei fenlei = new Fenlei(); + fenlei.setClassKeys(classKeys); + fenlei.setClassVals(classVals); + System.out.println(fenlei.toString()); + return fenlei; + } + + private JTree getTree(MenuBean menuBean1) { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(treenodename); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), rootNode); + } + } + JTree tree = new JTree(rootNode); + tree.setShowsRootHandles(true); + + return tree; + } + + /** + * ˵ṹ + * + * @param menuBean1 + * @param rootNode + */ + private void getRecursion(MenuBean menuBean1, DefaultMutableTreeNode rootNode) { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode node = new DefaultMutableTreeNode(treenodename); + rootNode.add(node); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), node); + } + } + } + + /** + * ˢе + */ + private void refreshMsg() { + classFlag = true; + classFlag2 = false; + objMap.clear(); + objMap2.clear(); + fieldList.clear(); + comboxList.clear(); + fieldmap.clear(); + comboxmap.clear(); + lovMap.clear(); + lovMap2.clear(); + attrList.clear(); + esAttrList.clear(); + attrList2.clear(); + esAttrList2.clear(); + classList.clear(); + markList.clear(); + markList2.clear(); + isNList.clear(); + isNList2.clear(); + defaultValueList.clear(); + defaultValueList2.clear(); + jp2.removeAll(); + idList.clear(); + lovAttrs.clear(); + } + + /** + * ͨݹĸӽڵ + * + * @param treeNode + * @param names + * @return + */ + private String getNode(TreeNode treeNode, String names) { + // TODO Auto-generated method stub + if (!names.equals("")) { + names = "&" + names; + } + names = treeNode.toString() + names; + + TreeNode parent = treeNode.getParent(); + if (parent != null) { + return getNode(parent, names); + } + + return names; + } + + /** + * Ʒźͼŵɷ + * + * @param defaultValueList + * @param attrList + * @param esAttrList + * @param map + * @param markList + * @param isNList + * @param lovMap + * @return + */ + public String splicValue(List defaultValueList, List attrList, List esAttrList, + Map map, List markList, List isNList, Map lovMap) { + + List objList = new ArrayList(); + List lovList = new ArrayList(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < attrList.size(); i++) { + String attr = attrList.get(i); + System.out.println("attr======112" + attr); + String esAttr = esAttrList.get(i); + if (classFlag2) { + if ((PlmLocaleUtil.getString("heatTreatment")).equals(attr) + || (PlmLocaleUtil.getString("heatTreatment")).equals(esAttr)) { + objList.add(HeatTreatment); + lovList.add("string"); + continue; + } + } + if (map.get(attr) == null && map.get(esAttr) == null) { + if ((PlmLocaleUtil.getString("PartNumber")).equals(attr) + || (PlmLocaleUtil.getString("PartNumber")).equals(esAttr)) { + JComboBox idbox = boxMap.get(PlmLocaleUtil.getString("PartNumber")); + JTextField idfield = (JTextField) idList.get(0); + String fieldText = idfield.getText(); + String boxText = (String) idbox.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(PlmLocaleUtil.getString("PartNumber") + "ͬʱдֵ", "ʾ", + MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(fieldText); + lovList.add("string"); + } else { + objList.add(boxText); + lovList.add("string"); + } + continue; + } + objList.add(defaultValueList.get(i)); + lovList.add("string"); + continue; + } + if (!("".equals(attr.trim()))) { + Object obj = map.get(attr); + JComboBox box = null; + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attr) + || (PlmLocaleUtil.getString("RadialInternalClearance")).equals(esAttr)) { + box = boxMap.get(PlmLocaleUtil.getString("RadialInternalClearance")); + } + if (obj == null) { + obj = map.get(esAttr); + if (box != null) { + JTextField field = (JTextField) obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(esAttr + "ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(esAttr + "дһֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + } else { + objList.add(box); + lovList.add("yes"); + } + } else { + objList.add(obj); + lovList.add(lovMap.get(esAttr)); + } + } else { + if (box != null) { + JTextField field = (JTextField) obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(attr + "ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(attr + "дһֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + } else { + objList.add(box); + lovList.add("yes"); + } + } else { + objList.add(obj); + lovList.add(lovMap.get(attr)); + } + } + } + } + for (int i = 0; i < objList.size(); i++) { + String attrValue = ""; + Object obj = objList.get(i); + if (obj != null) { + if ("yes".equals(lovList.get(i))) { + String value = (String) ((JComboBox) obj).getSelectedItem(); + System.out.println("ֵΪ:" + value); + if (asList.contains(value) || esList.contains(value)) { + if (isNList.get(i).trim().contains(value)) { + if (value.contains(":")) { + System.out.println("value============" + value); + String[] values = value.split(":"); + value = values[0]; + } else if (value.contains("")) { + System.out.println("value============" + value); + String[] values = value.split(""); + value = values[0]; + } + } else { + value = ""; + } + } else { + if (value.contains(":")) { + System.out.println("value============" + value); + String[] values = value.split(":"); + value = values[0]; + } else if (value.contains("")) { + System.out.println("value============" + value); + String[] values = value.split(""); + value = values[0]; + } + } + if ("Ʒ".equals(value) || "Finished product".equals(value)) { + value = ""; + } else if ("".equals(value) || "Turning workpiece".equals(value)) { + value = "C"; + } else if ("ȴ".equals(value) || "Heat treatment parts".equals(value)) { + value = "R"; + } else if ("շ伷".equals(value) || "Cold rolled parts or cold extrusion parts".equals(value)) { + value = "D"; + } else if ("ͼ".equals(value) || "Forge piece".equals(value)) { + value = "D"; + } + attrValue = value; + } else if ("no".equals(lovList.get(i))) { + attrValue = ((JTextField) obj).getText(); + } else { + attrValue = (String) obj; + } + if (asList.contains(attrValue) || esList.contains(attrValue)) { + attrValue = ""; + } else { + if (attrValue.contains(":")) { + System.out.println("attrValue============" + attrValue); + String[] values = attrValue.split(":"); + attrValue = values[0]; + } else if (attrValue.contains("")) { + System.out.println("attrValue============" + attrValue); + String[] values = attrValue.split(""); + attrValue = values[0]; + } + } + String mark = markList.get(i); + if (!("".equals(attrValue.trim()))) { + sb.append(mark.trim()); + sb.append(attrValue); + } + } + } + return sb.toString(); + } + + /** + * ȡ + * + * @param className + * @return + */ + private ICSAdminClassAttribute[] getClassAttrs(String className) { + try { + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(className); + ICSAdminClassAttribute[] icsAttrs = c.getAttributes(); + return icsAttrs; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * ͨѯѯ + * + * @param queryName + * @param keys + * @param values + * @return + */ + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + return null; + } + } + + /** + * ȡѡֵ + * + * @param preName + * @return + */ + private Map getPrefValues(String preName) { + Map map = new HashMap(); + String[] preVal = service.getStringValues(preName); + if (preVal != null) { + for (String val : preVal) { + String[] split = val.split("="); + map.put(split[0], split[1]); + } + System.out.println(preName + "ѡֵΪ:" + map); + return map; + } else { + MessageBox.post(preName + "ѡû!", "", MessageBox.ERROR); + return null; + } + } + + /** + * ȡѡϵĸļ + */ + public void getFolder() { + boolean b = false; + if (refs.length > 0) { + for (AIFComponentContext ref : refs) { + InterfaceAIFComponent component = ref.getComponent(); + if (component instanceof TCComponentFolder) { + folder = (TCComponentFolder) component; + b = true; + break; + } + } + } + if (!b) { + try { + folder = session.getUser().getHomeFolder(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * ƷͼĴ + * + * @param itemRev汾 + */ + private void createCGT(TCComponentItemRevision itemRev) { + try { + if (revList.size() > 0) { + TCComponentItemRevision picItem = revList.get(0); + TCComponent[] pics; + + pics = picItem.getReferenceListProperty("TC_Is_Represented_By"); + for (int i = 0; i < pics.length; i++) { + itemRev.add("TC_Is_Represented_By", pics[i]); + } + + } else { + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent("RB3_CGT"); + // String revID = typeComponent.getNewRev(null); + // String drawID = typeComponent.getNewID(); + String item_id = targetItem.getProperty("item_id"); + String id = dealItemId(item_id); + if (id != null) { + build.append(id); + build.append(drawingNumber); + } + String[] keys = new String[] { " ID" }; + String[] values = new String[] { build.toString() }; + List tzList = queryObject(" ID", keys, values); + TCComponentItemRevision CPTRev = null; + if (tzList != null) { + if (tzList.size() > 0) { + if (tzList.get(0) instanceof TCComponentItem) { + TCComponentItem tcItem = (TCComponentItem) tzList.get(0); + CPTRev = tcItem.getLatestItemRevision(); + } + } + } else { + if (id != null) { + TCComponentItem CPTItem = typeComponent.create(build.toString(), "V1", "RB3_CGT", "", "", null); + CPTRev = CPTItem.getLatestItemRevision(); + if (CPTItem != null) { + // session.getUser().getHomeFolder().add("contents", CPTItem); + // session.getUser().getHomeFolder().refresh(); + if (build.toString().length() > 0) { + CPTRev.setStringProperty("rb3_th", build.toString()); + } else { + CPTRev.setStringProperty("rb3_th", drawingNumber); + } + folder.add("contents", CPTItem); + folder.refresh(); + } + } else { + TCComponentItem CPTItem = typeComponent.create(drawingNumber, "V1", "RB3_CGT", "", "", null); + CPTRev = CPTItem.getLatestItemRevision(); + if (CPTItem != null) { + // session.getUser().getHomeFolder().add("contents", CPTItem); + // session.getUser().getHomeFolder().refresh(); + folder.add("contents", CPTItem); + folder.refresh(); + } + } + } + itemRev.add("TC_Is_Represented_By", CPTRev); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * itemIDĴ + */ + public String dealItemId(String id) { + String subs = id.substring(0, 2); + if (subs.equals("XX")) { + + String sub = id.substring(2, 4); + if (sub.equals("22")) { + System.out.println("idXX22ͷ!"); + return "XX-"; + } + } else if (subs.equals("22")) { + System.out.println("id22ͷ!"); + return "SF-"; + } + return null; + } + + /** + * ͨťѯеֵ + * + * @param bu Ҫ󶨼İť + * @param jt + * @param box + */ + public void queryByButton(JButton bu, JTextField jt, JComboBox box) { + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + System.out.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(box, tip); + } + } + + }); + } + + /** + * ҳӶ + * + * @param v + * @param prefName + */ + public void addObjectAttrs(int v, String prefName) { + jp2.add(v + ".1.center.top", new JLabel(" ")); + jp2.add(v + ".2.center.top", new JLabel("****************************")); + v += 1; + // λ + jp2.add(v + ".1.center.top", new JLabel("λ")); + try { + tagMap.clear(); + dl = new JComboBox(); + dl.setSize(new Dimension(60, 40)); + dl.setName("uom_tag"); + TCProperty zclov1; + TCComponentItem oldItem = targetItem.getItem(); + zclov1 = oldItem.getTCProperty("uom_tag"); + + TCComponentListOfValues zcprolov1 = zclov1.getLOV(); + String[] comboxitems1; + JTextField jt1 = new JTextField(9); + JButton bu1 = new JButton(""); + if (zcprolov1 != null) { + comboxitems1 = zcprolov1.getListOfValues().getLOVDisplayValues(); + TCComponent[] tags = zcprolov1.getListOfValues().getTagListOfValues(); + for (int flag = 0; flag < comboxitems1.length; flag++) { + tagMap.put(comboxitems1[flag], tags[flag]); + } + ComboBoxModel model1 = new DefaultComboBoxModel(comboxitems1); + dl.setModel(model1); + queryByButton(bu1, jt1, dl); + } + dl.setSelectedItem(oldItem.getProperty("uom_tag")); + // if(!(ZC_LBJ_list.LBJDisPros.get(i)).equals("ʱϱʶ")) { + dl.setSelectedIndex(-1); + jp2.add(v + ".2.center.top", dl); + jp2.add((v) + ".3.center.top", jt1); + jp2.add((v) + ".4.center.top", bu1); + v += 1; + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + // end + // Եļֵ(ʾֵ--ʵֵ) + Map attrsMap = getPrefValues(prefName); + Set> entrySet = attrsMap.entrySet(); + for (Entry entry : entrySet) { + String disName = entry.getKey(); + String realname = entry.getValue(); + jp2.add(v + ".1.center.top", new JLabel(disName)); + + try { + String val = targetItem.getProperty(realname); + TCProperty tcProperty = targetItem.getTCProperty(realname); + TCComponentListOfValues lov = tcProperty.getLOV(); + // --жǷǸlov + if (lov != null) { + // --Ƕֵԣ⴦ + JComboBox box; + if (realname.equals("rb3_scgc1")) { + String[] comboxitems = lov.getListOfValues().getLOVDisplayValues(); + box = new RwJComboBox(comboxitems); + box.setEditable(true); + realname.replace("1", ""); + String lovname = "rb3_scgc"; + box.setName(lovname); + box.setSize(new Dimension(60, 40)); + box.setSelectedItem(val); + String[] realitems = lov.getListOfValues().getStringListOfValues(); + dealLovValues(lovname, comboxitems, realitems); + jp2.add(v + ".2.center.top", box); + } else { + + box = new JComboBox(); + box.setSize(new Dimension(60, 40)); + box.setName(realname); + String[] comboxitems = lov.getListOfValues().getLOVDisplayValues(); + ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + box.setModel(model); + box.setSelectedItem(val); + String[] realitems = lov.getListOfValues().getStringListOfValues(); + dealLovValues(realname, comboxitems, realitems); + JTextField jt1 = new JTextField(9); + JButton bu1 = new JButton(""); + queryByButton(bu1, jt1, box); + jp2.add(v + ".2.center.top", box); + jp2.add(v + ".3.center.top", jt1); + jp2.add(v + ".4.center.top", bu1); + } + // --end + comboxList.add(box); + + } else { + JTextField field = new JTextField(18); + field.setName(realname); + field.setText(val); + jp2.add(v + ".2.center.top", field); + fieldList.add(field); + } + // --end + v += 1; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * 洢lovʵֵʾֵ + * + * @param lovName + * @param disNames ʾֵ + * @param realNames ʵֵ + */ + private void dealLovValues(String lovName, String[] disNames, String[] realNames) { + HashMap map = new HashMap(); + for (int i = 0; i < disNames.length; i++) { + map.put(disNames[i], realNames[i]); + } + lovAttrs.put(lovName, map); + System.out.println("lovAttrsֵΪ:" + lovAttrs); + } + + private void setObjectValues(TCComponentItemRevision itemRev) { + Map map = new HashMap(); + for (Object obj : fieldList) { + JTextField text = (JTextField) obj; + String attrName = text.getName(); + String attrValue = text.getText(); + map.put(attrName, attrValue); + } + for (Object obj : comboxList) { + JComboBox box = (JComboBox) obj; + String attrName = box.getName(); + HashMap lovmap = lovAttrs.get(attrName); + String attrValue = (String) box.getSelectedItem(); + + if (attrName.equals("rb3_scgc")) { + System.out.println("ֵΪ:" + attrValue); + String[] split = attrValue.split(","); + List list = new ArrayList(); + for (String key : split) { + String val = lovmap.get(key); + if (val != null) { + list.add(val); + } + + } + String[] ss = list.toArray(new String[list.size()]); + try { + itemRev.getTCProperty(attrName).setStringValueArray(ss); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } else { + System.out.println("attrNameֵΪ:" + attrName); + System.out.println("attrValueֵΪ:" + attrValue); + + String realVal = lovmap.get(attrValue); + System.out.println("lovԵʵֵΪ:" + realVal); + map.put(attrName, realVal); + } + } + try { + System.out.println("ԵļֵΪ:" + map); + itemRev.setProperties(map); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/rb/plm/biaozhunjian/GZLiShuHandler.java b/src/com/connor/rb/plm/biaozhunjian/GZLiShuHandler.java new file mode 100644 index 0000000..32edea7 --- /dev/null +++ b/src/com/connor/rb/plm/biaozhunjian/GZLiShuHandler.java @@ -0,0 +1,65 @@ +package com.connor.rb.plm.biaozhunjian; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.common.NotDefinedException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.util.MessageBox; + +public class GZLiShuHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + String name = ""; + try { + String name1 = arg0.getCommand().getName(); + String preName = ""; + String queryName = ""; + String attrs = ""; + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if (targetComponent instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) targetComponent; + String revType = rev.getType(); + if ("RB3_GZRevision".equals(revType) || "RB3_GZBJRevision".equals(revType)) { + preName = "RB3_GZ_names"; + queryName = "RBSearchGZCPH"; + name = ""; + attrs = "RB3_GZ_attrs"; + GZLiShuAction bzjAct = new GZLiShuAction(app, null, name, name1, queryName, preName, attrs); + new Thread(bzjAct).start(); + } else if ("RB3_GQRevision".equals(revType) || "RB3_GQBJRevision".equals(revType)) { + preName = "RB3_GQ_names"; + queryName = "RBSearchGQCPH"; + name = ""; + attrs = "RB3_GQ_attrs"; + GZLiShuAction bzjAct = new GZLiShuAction(app, null, name, name1, queryName, preName, attrs); + new Thread(bzjAct).start(); + } else if ("RB3_BZJRevision".equals(revType) || "RB3_BZJBJRevision".equals(revType)) { + preName = "RB3_BZJ_names"; + queryName = "RBSearchBZJCPH"; + name = "׼"; + attrs = "RB3_BZJ_attrs"; + GZLiShuAction bzjAct = new GZLiShuAction(app, null, name, name1, queryName, preName, attrs); + new Thread(bzjAct).start(); + } else { + MessageBox.post("ѡ׼汾д!!!", "ʾ", MessageBox.INFORMATION); + } + } else { + MessageBox.post("ѡ汾д!!!", "ʾ", MessageBox.INFORMATION); + } + } catch (NotDefinedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + +} diff --git a/src/com/connor/rb/plm/biaozhunjian/RwBasicComboPopup.java b/src/com/connor/rb/plm/biaozhunjian/RwBasicComboPopup.java new file mode 100644 index 0000000..5c70564 --- /dev/null +++ b/src/com/connor/rb/plm/biaozhunjian/RwBasicComboPopup.java @@ -0,0 +1,27 @@ +package com.connor.rb.plm.biaozhunjian; + +import java.awt.event.KeyListener; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; + +import javax.swing.JComboBox; +import javax.swing.JList; +import javax.swing.plaf.basic.BasicComboPopup; +import javax.swing.plaf.basic.ComboPopup; + +public class RwBasicComboPopup extends BasicComboPopup { + + public RwBasicComboPopup(JComboBox combo) { + // TODO Auto-generated constructor stub + super(combo); + } + + protected void configureList() { + super.configureList(); + list.setSelectionModel(new RwDefaultListSelectionModel(comboBox)); + } + + protected MouseListener createListMouseListener() { + return new RwMouseAdapter(list, comboBox); + } +} diff --git a/src/com/connor/rb/plm/biaozhunjian/RwDefaultComboBoxModel.java b/src/com/connor/rb/plm/biaozhunjian/RwDefaultComboBoxModel.java new file mode 100644 index 0000000..acb2333 --- /dev/null +++ b/src/com/connor/rb/plm/biaozhunjian/RwDefaultComboBoxModel.java @@ -0,0 +1,16 @@ +package com.connor.rb.plm.biaozhunjian; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.event.ListDataListener; + +public class RwDefaultComboBoxModel extends DefaultComboBoxModel { + + public RwDefaultComboBoxModel(String[] str) { + // TODO Auto-generated constructor stub + for (int i = 0; i < str.length; i++) { + addElement(str[i]); + } + } + +} diff --git a/src/com/connor/rb/plm/biaozhunjian/RwDefaultListSelectionModel.java b/src/com/connor/rb/plm/biaozhunjian/RwDefaultListSelectionModel.java new file mode 100644 index 0000000..ee3ffef --- /dev/null +++ b/src/com/connor/rb/plm/biaozhunjian/RwDefaultListSelectionModel.java @@ -0,0 +1,21 @@ +package com.connor.rb.plm.biaozhunjian; + +import javax.swing.DefaultListSelectionModel; +import javax.swing.JComboBox; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionListener; + +public class RwDefaultListSelectionModel extends DefaultListSelectionModel { + + protected RwJComboBox rwJComboBox; + + public RwDefaultListSelectionModel(JComboBox comboBox) { + // TODO Auto-generated constructor stub + this.rwJComboBox = (RwJComboBox) comboBox; + } + + public boolean isSelectedIndex(int index) { + return rwJComboBox.set.contains(index); + } + +} diff --git a/src/com/connor/rb/plm/biaozhunjian/RwJCheckBox.java b/src/com/connor/rb/plm/biaozhunjian/RwJCheckBox.java new file mode 100644 index 0000000..c717e1c --- /dev/null +++ b/src/com/connor/rb/plm/biaozhunjian/RwJCheckBox.java @@ -0,0 +1,30 @@ +package com.connor.rb.plm.biaozhunjian; + +import java.awt.Component; + +import javax.swing.JCheckBox; +import javax.swing.JList; +import javax.swing.ListCellRenderer; + +public class RwJCheckBox extends JCheckBox implements ListCellRenderer { + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, + boolean cellHasFocus) { + // TODO Auto-generated method stub + setComponentOrientation(list.getComponentOrientation()); +// if(isSelected) { +// setBackground(list.getSelectionBackground()); +// setBackground(list.getSelectionForeground()); +// }else { +// setBackground(list.getBackground()); +// setForeground(list.getForeground()); +// } + setEnabled(list.isEnabled()); + setSelected(isSelected); + setText(value == null ? "" : value.toString()); + setFont(list.getFont()); + return this; + } + +} diff --git a/src/com/connor/rb/plm/biaozhunjian/RwJComboBox.java b/src/com/connor/rb/plm/biaozhunjian/RwJComboBox.java new file mode 100644 index 0000000..7f4ae0f --- /dev/null +++ b/src/com/connor/rb/plm/biaozhunjian/RwJComboBox.java @@ -0,0 +1,42 @@ +package com.connor.rb.plm.biaozhunjian; + +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.util.HashSet; +import java.util.Set; + +import javax.swing.JComboBox; + +public class RwJComboBox extends JComboBox implements FocusListener { + + protected Set set = new HashSet(); + + public RwJComboBox(String str[]) { + setModel(new RwDefaultComboBoxModel(str)); + setUI(new RwMetalComboBoxUI(this)); + setRenderer(new RwJCheckBox()); + // setSelectedIndex(-1); + } + + public void setSet() { + this.set.clear(); + + } + + public Set getSet() { + return set; + } + + @Override + public void focusGained(FocusEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void focusLost(FocusEvent e) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/com/connor/rb/plm/biaozhunjian/RwMetalComboBoxUI.java b/src/com/connor/rb/plm/biaozhunjian/RwMetalComboBoxUI.java new file mode 100644 index 0000000..51f3edb --- /dev/null +++ b/src/com/connor/rb/plm/biaozhunjian/RwMetalComboBoxUI.java @@ -0,0 +1,37 @@ +package com.connor.rb.plm.biaozhunjian; + +import javax.swing.JComboBox; +import javax.swing.plaf.ComboBoxUI; +import javax.swing.plaf.basic.ComboPopup; +import javax.swing.plaf.metal.MetalComboBoxUI; + +public class RwMetalComboBoxUI extends MetalComboBoxUI { + + public RwMetalComboBoxUI(RwJComboBox rwJComboBox) { + // TODO Auto-generated constructor stub + this.comboBox = rwJComboBox; + } + + protected ComboPopup createPopup() { + return new RwBasicComboPopup(comboBox); + } + + @Override + public void setPopupVisible(JComboBox c, boolean v) { + // TODO Auto-generated method stub + + } + + @Override + public boolean isPopupVisible(JComboBox c) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isFocusTraversable(JComboBox c) { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/src/com/connor/rb/plm/biaozhunjian/RwMouseAdapter.java b/src/com/connor/rb/plm/biaozhunjian/RwMouseAdapter.java new file mode 100644 index 0000000..5b40f2b --- /dev/null +++ b/src/com/connor/rb/plm/biaozhunjian/RwMouseAdapter.java @@ -0,0 +1,105 @@ +package com.connor.rb.plm.biaozhunjian; + +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.swing.JComboBox; +import javax.swing.JList; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; + +public class RwMouseAdapter extends MouseAdapter { + + private JList list; + private RwJComboBox rwJComboBox; + + public RwMouseAdapter(JList list, JComboBox comboBox) { + // TODO Auto-generated constructor stub + this.list = list; + this.rwJComboBox = (RwJComboBox) comboBox; + } + + public void mousePressed(MouseEvent anEvent) { + StringBuilder sb, sb1, sb2, sb3; + int k, index; + index = list.getSelectedIndex(); + JTextField jTextField = (JTextField) rwJComboBox.getEditor().getEditorComponent(); + sb = new StringBuilder(jTextField.getText()); + if (sb.length() > 0 && ',' != sb.charAt(0)) { + sb.insert(0, ","); + } + if (sb.length() > 0 && ',' != sb.charAt(sb.length() - 1)) { + sb.append(","); + } + if (sb.length() > 0 && ",".equals(sb.toString())) { + sb = new StringBuilder(); + } + if (list.getSelectionMode() == ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { + if (rwJComboBox.set.contains(index)) { + rwJComboBox.set.remove(index); + sb1 = new StringBuilder(); + sb1.append(",").append(rwJComboBox.getModel().getElementAt(index)).append(","); + k = sb.indexOf(sb1.toString()); + while (k != -1) { + sb.replace(k, k + sb1.length(), ","); + k = sb.indexOf(sb1.toString()); + } + } else { + rwJComboBox.set.add(index); + if (sb.length() == 0) { + sb.append(",").append(rwJComboBox.getModel().getElementAt(index)).append(","); + + } else { + sb.append(rwJComboBox.getModel().getElementAt(index)).append(","); + } + } + } else { + if (!rwJComboBox.set.contains(index)) { + rwJComboBox.set.clear(); + rwJComboBox.set.add(index); + } + } + Object obj; + sb2 = new StringBuilder(sb); + // 滻Ŀѡֵ + for (int i = 0; i < list.getModel().getSize(); i++) { + obj = list.getModel().getElementAt(i); + sb1 = new StringBuilder(); + sb1.append(",").append(obj).append(","); + k = sb2.indexOf(sb1.toString()); + while (k != -1) { + sb2.replace(k, k + sb1.length(), ","); + k = sb2.indexOf(sb1.toString()); + } + } + List list1 = new ArrayList(rwJComboBox.set); + Collections.sort(list1); + for (int i = 0; i < list1.size(); i++) { + obj = rwJComboBox.getModel().getElementAt(Integer.parseInt(list1.get(i).toString())); + sb1 = new StringBuilder(); + sb1.append(",").append(obj).append(","); + k = sb.indexOf(sb1.toString()); + if (k != -1 && sb2.indexOf(sb1.toString()) == -1) { + sb2.append(obj).append(","); + } + } + sb = new StringBuilder(sb2); + if (sb.length() > 0 && ',' == sb.charAt(0)) { + sb.deleteCharAt(0); + } + if (sb.length() > 0 && ',' == sb.charAt(sb.length() - 1)) { + sb.deleteCharAt(sb.length() - 1); + } + if (sb.length() > 0 && ",".equals(sb.toString())) { + sb = new StringBuilder(); + } + jTextField.setText(sb.toString()); + rwJComboBox.repaint(); + list.repaint(); + } + +} diff --git a/src/com/connor/rb/plm/biaozhunjian/Test.java b/src/com/connor/rb/plm/biaozhunjian/Test.java new file mode 100644 index 0000000..3bff59c --- /dev/null +++ b/src/com/connor/rb/plm/biaozhunjian/Test.java @@ -0,0 +1,62 @@ +package com.connor.rb.plm.biaozhunjian; + +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTextField; + +public class Test { + static JFrame jf; + static JComboBox comb; + + public static void initView() { + jf = new JFrame(); + jf.setBounds(300, 100, 400, 300); + JPanel jp = new JPanel(new GridBagLayout()); + String[] comboxitems = { "a", "b", "c", "d", "c" }; + comb = new RwJComboBox(comboxitems); + comb.setSize(new Dimension(60, 40)); + comb.setEditable(true); + comb.setSelectedItem("a"); + comb.setSelectedItem("r,r"); + JTextField jt = new JTextField(6); + JButton bu = new JButton(""); + search(comb, bu); + jp.add(comb); + jp.add(jt); + jp.add(bu); + jf.add(jp); + + jf.setVisible(true); + } + + public static void main(String[] args) { + initView(); + } + + public static void search(JComboBox box, JButton bu) { + + bu.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub +// Object[] objs = box.getSelectedObjects(); +// for(Object obj:objs) { +// String b=(String)obj; +// System.out.println("ѡеΪ:"+b); +// } + String s = (String) box.getSelectedItem(); + System.out.println(s); + } + + }); + } +} diff --git a/src/com/connor/rb/plm/entity/ZC_LBJ_list.java b/src/com/connor/rb/plm/entity/ZC_LBJ_list.java new file mode 100644 index 0000000..e2c4fe7 --- /dev/null +++ b/src/com/connor/rb/plm/entity/ZC_LBJ_list.java @@ -0,0 +1,106 @@ +package com.connor.rb.plm.entity; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ZC_LBJ_list { + public static List ZCPros = new ArrayList<>(Arrays.asList("rb3_wxcc_nj", "rb3_wxcc_wj", "rb3_wxcc_kd", + "rb3_nqzxzpdj", "rb3_wqzxzpdj", "rb3_eddzh", "rb3_edjzh", "rb3_jxyx", "rb3_zxyx", "rb3_zzl", "rb3_ls", + "rb3_gdtdx", "rb3_mlgdtsl", "rb3_jyzj", "rb3_scgc", "rb3_cjyh", "rb3_sjr", "rb3_dztsyq", "rb3_jsyqbgqf", + "rb3_sybw", "rb3_ptkh", "rb3_ptcx", "rb3_yyly", "rb3_cph", "rb3_th", "rb3_bsh", "rb3_sm2", "rb3_ms", + "rb3_zclx", "rb3_smzqzt", "rb3_lswlbs", "rb3_yxq", "rb3_zl", "rb3_lth", "rb3_jwlh")); + public static List ZCDisPros = new ArrayList<>(Arrays.asList("γߴ_ھ(mm)", "γߴ_⾶(mm)", "γߴ_(mm)", + "ȦСװ䵹rmin", "ȦСװ䵹rmin", "غCr", "غCor", "϶(mm)", "϶(mm)", "ע֬(g)", "", "С(mm)", + "ÿй", "Բֱ(mm)", "", "û", "", "Ҫ", "Ҫ", "ʹòλ", "׿ͻ", "׳", "Ӧ", "Ʒ", + "ͼ", "ʶ", "˵", "", "ܳ", "״̬", "ʱϱʶ", "Ч", "(kg)", "ͼ/ͻͼ", "Ϻ")); +// public static List LBJPros = new ArrayList<>( +// Arrays.asList("rb3_cph", "rb3_th", "rb3_jwlh", "rb3_jh", "rb3_zl", "rb3_scgc", "rb3_dzzxj", "rb3_dztsyq", +// "rb3_ms", "rb3_jsyqbgqf", "rb3_cjyh", "rb3_smzqzt", "rb3_lswlbs", "rb3_yxq")); +// public static List LBJDisPros = new ArrayList<>(Arrays.asList("Ʒ", "ͼ", "Ϻ", "", "(kg)", "", +// "ľ", "Ҫ", "", "Ҫ", "û", "״̬", "ʱϱʶ", "Ч")); + // 20230927 е һ + // ޸++ +// public static List LBJPros = new ArrayList<>( +// Arrays.asList("rb3_cph", "rb3_jh","rb3_scgc","rb3_smzqtz")); +// +//public static List LBJDisPros = new ArrayList<>(Arrays.asList("Ʒ", "", "", "״̬")); + + public static List LBJPros = new ArrayList<>(Arrays.asList("rb3_cph", "rb3_jerpbm", "rb3_khth", "rb3_khxmh", + "rb3_glh", "rb3_jh", "rb3_scgc", "rb3_smzqzt")); + public static List LBJDisPros = new ArrayList<>( + Arrays.asList("Ʒ", "ERP", "ͻͼ", "ͻĿ", "", "", "", "״̬")); + +//ӳƷ + public static List XZCPPros = new ArrayList<>( + Arrays.asList("rb3_cph", "rb3_jerpbm", "rb3_khth", "rb3_scgc", "rb3_smzqzt")); /// ,"rb3_khxmh","rb3_glh","rb3_jh" + /// û + public static List XZCPDisPros = new ArrayList<>(Arrays.asList("Ʒ", "ERP", "ͻͼ", "", "״̬")); + + public static List GNZCPros = new ArrayList<>( + Arrays.asList("rb3_cph", "rb3_glh", "rb3_jerpbm", "rb3_khxmh", "rb3_khth", "rb3_smzqzt")); + public static List GNZCDisPros = new ArrayList<>( + Arrays.asList("Ʒ", "", "ERP", "ͻĿ", "ͻͼ", "״̬")); + + public static List ZC_LBJ_Lov = new ArrayList<>(Arrays.asList("rb3_ls", "rb3_scgc", "rb3_yyly", "rb3_zclx", + "rb3_smzqzt", "rb3_lswlbs", "rb3_scgc", "rb3_smzqzt", "rb3_lswlbs")); + public static Map map = new HashMap() { + /** + * + */ + private static final long serialVersionUID = 1L; + + { + put("rb3_ls", "RB3_LSLX"); + put("rb3_scgc", "rb3_scgc"); + put("rb3_yyly", "RB3_YYLY"); + put("rb3_zclx", "RB3_ZCLX"); + put("rb3_smzqzt", "RB3_SMZQZT"); + put("rb3_lswlbs", "RB3_LSWLBS"); + put("rb3_scgc", "rb3_scgc"); + put("rb3_smzqzt", "RB3_SMZQZT"); + put("rb3_lswlbs", "RB3_LSWLBS"); + } + }; + + public static Map xzmap = new HashMap() { + /** + * + */ + private static final long serialVersionUID = 1L; + + { + put("rb3_ls", "RB3_LSLX"); + put("rb3_xzscgc", "rb3_xzscgc"); + put("rb3_yyly", "RB3_YYLY"); + put("rb3_zclx", "RB3_ZCLX"); + put("rb3_smzqzt", "RB3_SMZQZT"); + put("rb3_lswlbs", "RB3_LSWLBS"); + put("rb3_scgc", "rb3_scgc"); + put("rb3_smzqzt", "RB3_SMZQZT"); + put("rb3_lswlbs", "RB3_LSWLBS"); + } + }; + public static Map LiShu_lov = new HashMap() { + /** + * + */ + private static final long serialVersionUID = 1L; + + { + put("rb3_scgc", ""); + } + }; + public static Map LiShu = new HashMap() { + /** + * + */ + private static final long serialVersionUID = 1L; + + { + put("rb3_cjyh", "û"); + } + }; +} diff --git a/src/com/connor/rb/plm/entity/ZC_LBJ_listLBJ.java b/src/com/connor/rb/plm/entity/ZC_LBJ_listLBJ.java new file mode 100644 index 0000000..ac7c158 --- /dev/null +++ b/src/com/connor/rb/plm/entity/ZC_LBJ_listLBJ.java @@ -0,0 +1,88 @@ +package com.connor.rb.plm.entity; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ZC_LBJ_listLBJ { + public static List ZCPros = new ArrayList<>(Arrays.asList("rb3_wxcc_nj", "rb3_wxcc_wj", "rb3_wxcc_kd", + "rb3_nqzxzpdj", "rb3_wqzxzpdj", "rb3_eddzh", "rb3_edjzh", "rb3_jxyx", "rb3_zxyx", "rb3_zzl", "rb3_ls", + "rb3_gdtdx", "rb3_mlgdtsl", "rb3_jyzj", "rb3_scgc1", "rb3_cjyh", "rb3_sjr", "rb3_dztsyq", "rb3_jsyqbgqf", + "rb3_sybw", "rb3_ptkh", "rb3_ptcx", "rb3_yyly", "rb3_cph", "rb3_th", "rb3_bsh", "rb3_sm2", "rb3_ms", + "rb3_zclx", "rb3_smzqzt", "rb3_lswlbs", "rb3_yxq", "rb3_zl", "rb3_lth", "rb3_jwlh")); + public static List ZCDisPros = new ArrayList<>(Arrays.asList("γߴ_ھ(mm)", "γߴ_⾶(mm)", "γߴ_(mm)", + "ȦСװ䵹rmin", "ȦСװ䵹rmin", "غCr", "غCor", "϶(mm)", "϶(mm)", "ע֬(g)", "", "С(mm)", + "ÿй", "Բֱ(mm)", "", "û", "", "Ҫ", "Ҫ", "ʹòλ", "׿ͻ", "׳", "Ӧ", "Ʒ", + "ͼ", "ʶ", "˵", "", "ܳ", "״̬", "ʱϱʶ", "Ч", "(kg)", "ͼ/ͻͼ", "Ϻ")); + public static List LBJPros = new ArrayList<>( + Arrays.asList("rb3_cph", "rb3_th", "rb3_jwlh", "rb3_jh", "rb3_zl", "rb3_scgc1", "rb3_dzzxj", "rb3_dztsyq", + "rb3_ms", "rb3_jsyqbgqf", "rb3_cjyh", "rb3_smzqzt", "rb3_lswlbs", "rb3_yxq")); + public static List LBJDisPros = new ArrayList<>(Arrays.asList("Ʒ", "ͼ", "Ϻ", "", "(kg)", "", + "ľ", "Ҫ", "", "Ҫ", "û", "״̬", "ʱϱʶ", "Ч")); + public static List YWLBJDisPros = new ArrayList<>(Arrays.asList( "Product Number", "Design Drawing Number", "Legacy Material Number", "Part Number", "Weight (kg)", "Manufacturing Plant", "Typing Center Diameter", "Typing Special Requirements", "Description", "Technical Specification Change Indicator", "Creating User", "Lifecycle Status", "Temporary Material Flag", "Expiration Date" )); + /** + * hcj Ҫ¶lbjݼ + */ + public static List XZLBJPros = new ArrayList<>(Arrays.asList("rb3_cph", "rb3_th", "rb3_kherpbm", + "rb3_khtzbb", "rb3_khbbrq", "rb3_khth", "rb3_kh", "rb3_xzscgc", "rb3_cplx2", "rb3_ycllx", "rb3_yclgg", + "rb3_yclcj", "rb3_cpzl", "rb3_xhzl", "rb3_cpjd", "rb3_smzqzt")); + public static List XZLBJDisPros = new ArrayList<>(Arrays.asList("Ʒ", "ͼ", "ͻERP", "ͻͼֽ汾", + "ͻ汾", "ͻͼ", "ͻ", "", "Ʒ", "ԭ", "ԭϹ", "ԭϳ", "Ʒ", "", "Ʒ׶", "״̬")); + + // ޸++ + public static List GNZCPros = new ArrayList<>( + Arrays.asList("rb3_cph", "rb3_glh", "rb3_jerpbm", "rb3_khxmh", "rb3_khth", "rb3_smzqzt")); + public static List GNZCDisPros = new ArrayList<>( + Arrays.asList("Ʒ", "", "ERP", "ͻĿ", "ͻͼ", "״̬")); + public static List YWGNZCDisPros = new ArrayList<>(Arrays.asList( "Product Number", "Management Number", "Old ERP Code", "Customer Project Number", "Customer Drawing Number", "Lifecycle Status" )); + + public static List ZC_LBJ_Lov = new ArrayList<>(Arrays.asList("rb3_ls", "rb3_scgc1", "rb3_yyly", "rb3_zclx", + "rb3_smzqzt", "rb3_lswlbs", "rb3_scgc1", "rb3_smzqzt", "rb3_lswlbs")); + + public static Map map = new HashMap() { + /** + * + */ + private static final long serialVersionUID = 1L; + + { + put("rb3_ls", "RB3_LSLX"); + put("rb3_scgc1", "RB3_SCGC1"); + put("rb3_yyly", "RB3_YYLY"); + put("rb3_zclx", "RB3_ZCLX"); + put("rb3_smzqzt", "RB3_SMZQZT"); + put("rb3_lswlbs", "RB3_LSWLBS"); + put("rb3_scgc1", "RB3_SCGC1"); + put("rb3_smzqzt", "RB3_SMZQZT"); + put("rb3_lswlbs", "RB3_LSWLBS"); + put("rb3_xzscgc", "RB3_XZSCGC_LOV"); + put("rb3_cplx2", "RB3_CPLX2"); + put("rb3_ycllx", "RB3_YCLLX"); + put("rb3_yclcj", "RB3_YCLCJ"); + put("rb3_cpjd", "RB3_CPJD"); + + } + }; + public static Map LiShu_lov = new HashMap() { + /** + * + */ + private static final long serialVersionUID = 1L; + + { + put("rb3_scgc1", ""); + } + }; + public static Map LiShu = new HashMap() { + /** + * + */ + private static final long serialVersionUID = 1L; + + { + put("rb3_cjyh", "û"); + } + }; +} diff --git a/src/com/connor/rb/plm/exportBOM/ExportBOMDialog.java b/src/com/connor/rb/plm/exportBOM/ExportBOMDialog.java new file mode 100644 index 0000000..fea7af2 --- /dev/null +++ b/src/com/connor/rb/plm/exportBOM/ExportBOMDialog.java @@ -0,0 +1,128 @@ +package com.connor.rb.plm.exportBOM; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import java.awt.Component; +import java.awt.Container; +import java.awt.LayoutManager; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.util.Objects; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; + +public class ExportBOMDialog extends AbstractAIFDialog { + private static final long serialVersionUID = -4196916619518806046L; + private AbstractAIFApplication app; + private TCSession session; + private JFileChooser fileChooser; + private JTextField fileName; + private JTextField filePath; + private File file; + private String directoryPath; + private String sxx; + + public ExportBOMDialog(AbstractAIFApplication app,String sxx) { + super(false); + this.app = app; + this.session = (TCSession)app.getSession(); + this.sxx = sxx; + } + + public void run() { + this.initialize(); + } + + private void initialize() { + this.setTitle("BOM"); + this.setLayout((LayoutManager)null); + this.setBounds(300, 300, 450, 200); + this.setDefaultCloseOperation(2); + Container container = this.getContentPane(); + JLabel label = new JLabel("ļ"); + label.setBounds(20, 10, 90, 25); + container.add(label); + this.fileName = new JTextField(); + this.fileName.setColumns(30); + this.fileName.setBounds(120, 10, 200, 25); + container.add(this.fileName); + JLabel label_2 = new JLabel("ļ·"); + label_2.setBounds(20, 50, 90, 25); + container.add(label_2); + this.filePath = new JTextField(); + this.filePath.setColumns(30); + this.filePath.setBounds(120, 50, 200, 25); + container.add(this.filePath); + this.fileChooser = new JFileChooser(FileSystemView.getFileSystemView().getHomeDirectory()); + this.fileChooser.setFileSelectionMode(1); + JButton selectBtn = new JButton("·ѡ"); + selectBtn.setBounds(330, 50, 100, 25); + selectBtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + int state = ExportBOMDialog.this.fileChooser.showOpenDialog((Component)null); + if (state != 1) { + ExportBOMDialog.this.file = ExportBOMDialog.this.fileChooser.getSelectedFile(); + if (ExportBOMDialog.this.file.isDirectory()) { + ExportBOMDialog.this.directoryPath = ExportBOMDialog.this.file.getAbsolutePath(); + ExportBOMDialog.this.filePath.setText(ExportBOMDialog.this.file.getAbsolutePath()); + } + } + + } + }); + container.add(selectBtn); + JButton sureBtn = new JButton("ȷ"); + sureBtn.setBounds(70, 100, 100, 25); + sureBtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + ExportBOMDialog.this.okEvent(e); + } + }); + container.add(sureBtn); + JButton closeBtn = new JButton("ȡ"); + closeBtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + ExportBOMDialog.this.celEvent(e); + } + }); + closeBtn.setBounds(180, 100, 100, 25); + container.add(closeBtn); + this.setVisible(true); + } + + public void okEvent(ActionEvent e) { + try { + if (Objects.equals("", this.fileName.getText())) { + MessageBox.post("дļ", "ʾ", 2); + return; + } + + if (Objects.equals("", this.filePath.getText())) { + MessageBox.post("ѡ񵼳·", "ʾ", 2); + return; + } + + this.dispose(); + this.directoryPath = this.directoryPath + "\\" + this.fileName.getText() + ".xlsx"; + System.out.println("directory = " + this.directoryPath); + ExportBOMOperation2 operation = new ExportBOMOperation2(this.app, this.session, this.directoryPath,this.sxx); + this.session.queueOperation(operation); + } catch (Exception var3) { + Exception e1 = var3; + e1.printStackTrace(); + } + + } + + public void celEvent(ActionEvent e) { + this.dispose(); + } +} diff --git a/src/com/connor/rb/plm/exportBOM/ExportBOMHandler.java b/src/com/connor/rb/plm/exportBOM/ExportBOMHandler.java new file mode 100644 index 0000000..d29dda1 --- /dev/null +++ b/src/com/connor/rb/plm/exportBOM/ExportBOMHandler.java @@ -0,0 +1,72 @@ +package com.connor.rb.plm.exportBOM; + +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.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.util.MessageBox; + +public class ExportBOMHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication application = AIFUtility.getCurrentApplication(); + String sxx = null; + try { + InterfaceAIFComponent[] targetComponents = application.getTargetComponents(); + int target_num = targetComponents.length; + if (target_num>0) { + String compareType = targetComponents[0].getType();//һѡжΪȽ + for (int i = 0; i < targetComponents.length; i++) { + String targetComponentType = targetComponents[i].getType(); + if (targetComponentType.equals(compareType)) { + continue; + }else { + MessageBox.post("ǰѡжͲͬ޷","ʾ",MessageBox.INFORMATION); + return null; + } + } + //ѡжƴѡ + System.out.println("ǰѡж=="+compareType); + TCComponentItemRevision itemRev = null;//ѡжİ汾 + TCComponentItem item = null; + if (targetComponents[0] instanceof TCComponentItemRevision) { + itemRev = (TCComponentItemRevision) targetComponents[0]; + item = itemRev.getItem(); + } else if (targetComponents[0] instanceof TCComponentItem) { + System.out.println("ǰѡжΪitemȡ°汾"); + item = (TCComponentItem) targetComponents[0]; + itemRev = item.getLatestItemRevision(); + } else { + System.out.println("ѡΪ=" + compareType + "Ҫ"); + } + if (item != null) { + String typeString = item.getStringProperty("object_type");//ȡʵֵ + sxx = typeString + "Bom_Export_Properties"; + System.out.println("ǰѡжΪ"+compareType+"ӦѡΪ"+sxx); + } + + }else { + MessageBox.post("δѡκζ","ʾ",MessageBox.INFORMATION); + return null; + } + + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(e.getMessage() , "쳣", MessageBox.ERROR); + } + + ExportBOMDialog exportBOMDialog = new ExportBOMDialog(application,sxx); + + new Thread(exportBOMDialog).start(); + + return null; + } + +} diff --git a/src/com/connor/rb/plm/exportBOM/ExportBOMOperation.java b/src/com/connor/rb/plm/exportBOM/ExportBOMOperation.java new file mode 100644 index 0000000..cf7e8bf --- /dev/null +++ b/src/com/connor/rb/plm/exportBOM/ExportBOMOperation.java @@ -0,0 +1,504 @@ +package com.connor.rb.plm.exportBOM; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMLineType; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.soa.client.model.PropertyDescription; + +/** + * ǰ᣺ѡõÿһַеıͷһ + * + * @author kuma + * + */ +public class ExportBOMOperation extends AbstractAIFOperation { + private TCSession session; + private String directoryPath;// xlsxļ + private WaitingDialog wait;// ص + private InterfaceAIFComponent[] targetComponents;// ѡж󼯺 + private TCComponentBOMWindowType windowType; + private List bomLines; + private int headNum = 0;// ͷУ + private List> tableList = new ArrayList>(); + List headPropertyList = new ArrayList();//ڴűͷеList + private String sxx; + private String[] afterValueString = new String[100];//ѡıͷIJ/ðźIJ + java.util.Hashtable propDescs; + String[] properties; + + public ExportBOMOperation(AbstractAIFApplication app, TCSession session, String directoryPath, String sxx) { + this.session = session; + this.directoryPath = directoryPath; + this.targetComponents = app.getTargetComponents(); + this.sxx = sxx;//ѡ + System.out.println("յõѡƣ"+sxx); + } + + public void executeOperation() throws Exception { + System.out.println("ExportBOMOperation is executing"); + this.excute(); + } + + private void excute() throws TCException { + TCComponentBOMLineType bomLineType = (TCComponentBOMLineType) session.getTypeComponent("BOMLine"); +// Hashtable iHashtable = bomLineType.getPropDescs(); + propDescs = bomLineType.getPropDescs(); + + //1.ȡѡе + properties = getSXX(sxx); + if (properties.length > 0) { + System.out.println("ʼȡͷϢ"); + this.headNum = properties.length; + for (int i = 0; i < properties.length; i++) { + String propertyTemp = properties[i];//лȡѡеϢ + System.out.println("propertyTemp="+propertyTemp); + String headString = propertyTemp.split(":")[0];//ȡеıͷ + System.out.println("headString="+headString); + afterValueString[i] = propertyTemp.split(":")[1];//ȡѡıͷ:IJ???? + System.out.println(":="+headString); + headPropertyList.add(headString); + } + tableList.add(headPropertyList);// ͷ + System.out.println("ȡѡ"+sxx+"ɹͷУ"); + for (int i = 0; i < headPropertyList.size(); i++) { + String string = headPropertyList.get(i); + System.out.println("|"+headPropertyList.get(i)); + } + } else { + System.out.println("δȡѡ"+ sxx +"ݣ\n"); + } + + //2.ѡж + int targetCompsNum = this.targetComponents.length; + System.out.println("ѡж"+targetCompsNum); + for (int i = 0; i < targetCompsNum; i++) { + System.out.println("ʼѡж󡤡"); + TCComponentItemRevision itemRev = null;//ѡжİ汾 + //ȡѡжitemͰ汾 + InterfaceAIFComponent targetComponent = targetComponents[i];//ѡж֮һ + String targetComponentType = targetComponent.getType(); + System.out.println("ǰѡж=="+targetComponentType); + if (targetComponent instanceof TCComponentItemRevision) { + itemRev = (TCComponentItemRevision) targetComponent; + } else if (targetComponent instanceof TCComponentItem) { + System.out.println("ǰѡжΪitemȡ°汾"); + TCComponentItem item = (TCComponentItem) targetComponent; + itemRev = item.getLatestItemRevision(); + } else { + System.out.println("ѡΪ=" + targetComponentType + "Ҫ"); + } + String targetName = itemRev.getProperty("object_name"); + // ȡѡжBOMṹ + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = winType.create(null); + TCComponentBOMLine bomLine = view.setWindowTopLine(itemRev.getItem(), itemRev, null, null); + TCComponentBOMLine parentLine = bomLine.getCachedParent(); + if (!bomLine.hasChildren()) {//ѡж󲻴ûBOMṹ򲻵ݡѭеһѡж + System.out.println("ǰѡж汾"+ targetName +"BOMṹ"); + continue; + } + // Դŵǰbomlineе + List propertyList = new ArrayList(); + String parentID = null; + if (parentLine != null) { + parentID = parentLine.getProperty("bl_item_item_id"); + } + String childlD = bomLine.getProperty("bl_item_item_id"); + //ѡϢȡֵ + for (int j = 0; j < properties.length; j++) {//бȡֵѡõһоһֵ + String[] Attributes = afterValueString[j].split(",");//afterValueStringðźIJ + //߼ͷΪͷ.ͷ:******ʱӦȡͷ +// 1.ȡǰϢӦıͷ + String headString = headPropertyList.get(j); + String[] headParts = headString.split("\\."); + if (headParts.length > 1 && headParts[0].equals("")){//Ըͷұͷִ.ָĶԪʱ + if (parentLine != null){ + String fjAttributeValue = null; + for (String Attribute : Attributes) {//AttributesϢÿԵ飬ÿԪAttribute=[bomline.bl_RB3_YZRevision_rb3_bjlx] + String fjsx = Attribute.split("\\.")[1];//bomline + fjAttributeValue = parentLine.getProperty(fjsx); + if (fjAttributeValue == null || fjAttributeValue.length() == 0) {//ȡõbomlineΪգȡһѡõbomlineԣֱȡֵΪֹȡֵѭ + System.out.println("õĸֶ="+fjsx+"δȡκֵͨͷһԻȡ"); + continue; + }else { + System.out.println("add="+fjAttributeValue); + break; + } + } + if(fjAttributeValue == null || fjAttributeValue.length() == 0) { + propertyList.add(""); + }else { + propertyList.add(fjAttributeValue); + } + }else { + propertyList.add(""); + } + + continue;//ԴɣһϢӰĴ߼ + } + + //ԭ߼ + String tag = Attributes[0].split("\\.")[0]; + if (!tag.equals("bomline")) {//bomline + if(afterValueString[j].equals("ParentID")) { + System.out.println("parentID = "+ parentID); + propertyList.add(parentID); + }else if (afterValueString[j].equals("ChildID")) { + System.out.println("childlD = "+ childlD); + propertyList.add(childlD); + } + + }else { + String attributeValue = null; + for (String Attribute : Attributes) { + String bjsx = Attribute.split("\\.")[1];//bomline + if (!propDescs.containsKey(bjsx)) { + System.out.println("ѡ"+sxx+"е"+bjsx+"ڣ"+"ͨͷһԻȡ"); + String tipString = "ѡ"+sxx+"е"+bjsx+"ڣ"; + MessageBox.post(tipString , "쳣", MessageBox.ERROR); + continue; + } else { + System.out.println("õֶ="+bjsx+"bomlineдڣ"); + attributeValue = bomLine.getProperty(bjsx); + } + + if (attributeValue == null || attributeValue.length() == 0) {//ȡõbomlineΪգȡһѡõbomlineԣֱȡֵΪֹȡֵѭ + System.out.println("õֶ="+bjsx+"δȡκֵͨͷһԻȡ"); + continue; + }else { + System.out.println("add="+attributeValue); + break; + } + } + if(attributeValue == null || attributeValue.length() == 0) { + propertyList.add(""); + }else { + propertyList.add(attributeValue); + } + } + } + + if (propertyList.size() == this.headNum) { + System.out.println("ѡϢȡԳɹдtableList success"); + tableList.add(propertyList); + }else { + System.out.println("ͷ"+this.headNum+",\n ǰѡȡ"+propertyList.size()); + } + + getBom(bomLine); + view.close(); + } + System.out.println("======дtableList.size == "+tableList.size()); + exportToFile(tableList, directoryPath); + + } + + /** + * ݹ + * @param bomLine + */ + private void getBom(TCComponentBOMLine parentBomLine) throws TCException { + if (parentBomLine.hasChildren()) { + //ȡID + String parentID = parentBomLine.getProperty("bl_item_item_id"); + AIFComponentContext[] childrens = parentBomLine.getChildren(); + System.out.println(parentID+"bom = "+childrens.length); + for (AIFComponentContext children : childrens) { + // Դŵǰbomlineе + List propertyList = new ArrayList(); + TCComponentBOMLine bomLine = (TCComponentBOMLine) children.getComponent();// ѡж + System.out.println("addID="+parentID); + //ID + String childlD = bomLine.getProperty("bl_item_item_id"); + System.out.println("addӼID="+childlD); + //ѡϢȡֵ + for (int j = 0; j < properties.length; j++) { + String[] Attributes = afterValueString[j].split(","); + //߼ͷΪͷ.ͷ:******ʱӦȡͷ +// 1.ȡǰϢӦıͷ + String headString = headPropertyList.get(j); + String[] headParts = headString.split("\\."); + if (headParts.length > 1 && headParts[0].equals("")){//Ըͷұͷִ.ָĶԪʱ + if (parentBomLine != null){ + String fjAttributeValue = null; + for (String Attribute : Attributes) {//AttributesϢÿԵ飬ÿԪAttribute=[bomline.bl_RB3_YZRevision_rb3_bjlx] + String fjsx = Attribute.split("\\.")[1];//bomline + fjAttributeValue = parentBomLine.getProperty(fjsx); + if (fjAttributeValue == null || fjAttributeValue.length() == 0) {//ȡõbomlineΪգȡһѡõbomlineԣֱȡֵΪֹȡֵѭ + System.out.println("õֶ="+fjsx+"δȡκֵͨͷһԻȡ"); + continue; + }else { + System.out.println("add="+fjAttributeValue); + break; + } + } + if(fjAttributeValue == null || fjAttributeValue.length() == 0) { + propertyList.add(""); + }else { + propertyList.add(fjAttributeValue); + } + }else { + propertyList.add(""); + } + continue;//ԴɣһϢӰĴ߼ + } + + //ԭ߼ + String tag = Attributes[0].split("\\.")[0]; + if (!tag.equals("bomline")) {//bomline + if(afterValueString[j].equals("ParentID")) { + System.out.println("parentID = "+ parentID); + propertyList.add(parentID); + }else if (afterValueString[j].equals("ChildID")) { + System.out.println("childlD = "+ childlD); + propertyList.add(childlD); + } + + }else { + String attributeValue = null; + for (String Attribute : Attributes) { + String bjsx = Attribute.split("\\.")[1];//bomline + if (!propDescs.containsKey(bjsx)) { + System.out.println("ѡXXеXXڣ"); + String tipString = "ѡ"+sxx+"е"+bjsx+"ڣ"; + MessageBox.post(tipString , "쳣", MessageBox.ERROR); + continue; + } else { + System.out.println("õֶ="+bjsx+"bomlineдڣ"); + attributeValue = bomLine.getProperty(bjsx); + } + + if (attributeValue == null || attributeValue.length() == 0 || attributeValue.length() == 0) {//ȡõbomlineΪգȡһѡõbomlineԣֱȡֵΪֹȡֵѭ + System.out.println("õֶ="+bjsx+"δȡκֵѯһֶΣ"); + continue; + }else { + System.out.println("add="+attributeValue); + break; + } + } + if(attributeValue == null || attributeValue.length() == 0 || attributeValue.length() == 0) { + propertyList.add(""); + }else { + propertyList.add(attributeValue); + } + } + + } + + if (propertyList.size() == this.headNum) { + System.out.println("ѡϢȡԳɹдtableList success"); + tableList.add(propertyList); + }else { + System.out.println("ͷ"+this.headNum+",\n ǰѡȡ"+propertyList.size()); + } + getBom(bomLine); + } + } + + + } + + /** + * ļ + * + * @param tableList2 ݣÿһList + * @param directoryPath2 ļ· + */ + private void exportToFile(List> tableList2, String directoryPath2) { + System.out.println("exportToFileʼִС"); + XSSFWorkbook workbook = null; + boolean isSuccess = false; + + try { + // һµĹ + workbook = new XSSFWorkbook(); + + // һ + Sheet sheet = workbook.createSheet("Sheet1"); + + // һԪʽڱͷ + CellStyle headerStyle = workbook.createCellStyle(); + Font headerFont = workbook.createFont(); + // ΪӴ + headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD); + headerStyle.setFont(headerFont); + + // + int rowNum = 0; + for (List row : tableList2) { + + System.out.println("ʼдһݵxlsxļĿ"+row.size()); + Row currentRow = sheet.createRow(rowNum++); + + int colNum = 0; + for (String cellValue : row) { + System.out.println("ʼд뵥ԪֵΪ"+cellValue); + Cell cell = currentRow.createCell(colNum++); + cell.setCellValue(cellValue); + + // ǵһУͷӦñͷʽ + if (rowNum == 1) { + System.out.println("ǰдΪͷñͷʽ"); + cell.setCellStyle(headerStyle); + } + } + } + + // Զп + for (int i = 0; i < tableList2.get(0).size(); i++) { + sheet.autoSizeColumn(i); + } + + // ʹ try-with-resources ȷļȷر + try (FileOutputStream fileOut = new FileOutputStream(directoryPath2)) { + // дļ + System.out.println("дļдļ·fileOut=="+directoryPath2); + workbook.write(fileOut); + isSuccess = true; // û׳쳣Ϊɹ + } catch (IOException e) { + e.printStackTrace(); + } + + } catch (Exception e) { + e.printStackTrace(); + } finally { + // Ȼ XSSFWorkbook ҪʽرգȻԽΪ null + if (workbook != null) { + workbook = null; + } + } + if (isSuccess) { + MessageBox.post("ɹ" , "", MessageBox.INFORMATION); + }else { + MessageBox.post("ʧܣ" , "", MessageBox.ERROR); + } + } + + /** + * ȡѡ + * + * @return + */ + private String[] getSXX(String sxx) { + // ȡѡеͶ + TCPreferenceService preferenceService = session.getPreferenceService(); + String[] properties = preferenceService.getStringValues(sxx); + if (properties.length > 0) { + System.out.println("ȡѡ"+sxx+"ɹ\n"); + //ӡȡѡ + int t = 0; + for (String p : properties) { + System.out.println("ѡ["+t+"] = "+p); + t++; + } + return properties; + } else { + System.out.println("δȡѡ"+sxx+"ݣ\n"); + return null; + } + } + + + /** + * + * @Title: getTCPropertyValue @Description: ȡԵʵֵ @param @param + * item @param @param propertyName @param @return @return Object @throws + */ + public static Object getTCPropertyValue(TCComponent item, String propertyName) { + Object result = ""; + + try { + TCProperty tcProperty = item.getTCProperty(propertyName); + if (tcProperty == null) { + System.out.println("δȡԣ" + propertyName); + return result; + } + switch (tcProperty.getPropertyType()) { + case TCProperty.PROP_double: + result = tcProperty.getDoubleValue(); + break; + case TCProperty.PROP_int: + result = tcProperty.getIntValue(); + break; + case TCProperty.PROP_string: + result = tcProperty.getStringValue(); + break; + case TCProperty.PROP_date: + result = tcProperty.getDateValue(); + break; + default: + break; + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return result; + } + + /** + * + * @param afterPartString = + * "ParentlD(),ChildlD(Ӽ),bomline.bl_RB3_ZCRevision_rb3_smzqzt(״̬)" + * @return ParentlD,ChildlD,bomline.bl_RB3_ZCRevision_rb3_smzqzt + */ + private List getAttributeList(String afterPartString) { + System.out.println("getAttributeListafterPartString=="+afterPartString); + List resultList = new ArrayList<>(); + String[] split0 = afterPartString.split(",");//st=ParentlD() + for (String st : split0) { + String[] split1 = st.split("\\(", 2);//split1=ParentlD,) + System.out.println("getAttributeListȡƥ䵽ѡеֶγԱ = "+split1[0]); + resultList.add(split1[0]); + } + System.out.println("ƥ䵽ѡϢлȡ"+resultList.size()+"Ŀ"); + return resultList; + } + + /** + * ȡеıͷ + * + * @param afterPartString = ParentlD(),ChildlD(Ӽ),bomline.bl_RB3_ZCRevision_rb3_smzqzt(״̬) + * @return + */ + private List getHead(String afterPartString) { + List resultList = new ArrayList<>(); + System.out.println("getHeadʼִСΣ"+afterPartString); + String[] split0 = afterPartString.split(",");//ParentlD()...... + for (String str0 : split0) {//str0 = ParentlD() + String stR = str0.split("\\(",2)[1];//stR = ) + System.out.println("ѡϢлȡıͷ = "+stR.split("\\)")[0]); + resultList.add(stR.split("\\)")[0]); + } + return resultList; + } + + +} diff --git a/src/com/connor/rb/plm/exportBOM/ExportBOMOperation2.java b/src/com/connor/rb/plm/exportBOM/ExportBOMOperation2.java new file mode 100644 index 0000000..090fdba --- /dev/null +++ b/src/com/connor/rb/plm/exportBOM/ExportBOMOperation2.java @@ -0,0 +1,278 @@ +package com.connor.rb.plm.exportBOM; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.*; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.soa.client.model.PropertyDescription; + +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; + +public class ExportBOMOperation2 extends AbstractAIFOperation { + private final TCSession session; + private final String directoryPath; + private final InterfaceAIFComponent[] targetComponents; + private final String sxx; + + private List> tableList = new ArrayList<>(); + private List headPropertyList = new ArrayList<>(); + private java.util.Hashtable propDescs; + private String[] properties; + private int headNum = 0; + + public ExportBOMOperation2(AbstractAIFApplication app, TCSession session, + String directoryPath, String sxx) { + this.session = session; + this.directoryPath = directoryPath; + this.targetComponents = app.getTargetComponents(); + this.sxx = sxx; + } + + @Override + public void executeOperation() throws Exception { + System.out.println("ExportBOMOperation executing..."); + this.excute(); + } + + private void excute() throws TCException { + // 1. ʼȡѡ + initializePreferences(); + + // 2. ÿѡеĶ + for (InterfaceAIFComponent targetComponent : targetComponents) { + TCComponentItemRevision itemRev = getItemRevision(targetComponent); + if (itemRev == null) continue; + + // 3. BOMڲȡBOMLine + TCComponentBOMWindow view = createBOMWindow(itemRev); + TCComponentBOMLine topLine = view.setWindowTopLine(itemRev.getItem(), itemRev, null, null); + + if (!topLine.hasChildren()) { + System.out.println("No BOM structure found for: " + itemRev.getProperty("object_name")); + view.close(); + continue; + } + + // 4. BOMṹ + processBOMStructure(topLine); + view.close(); + } + + // 5. ļ + exportToFile(tableList, directoryPath); + } + + private void initializePreferences() throws TCException { + TCComponentBOMLineType bomLineType = (TCComponentBOMLineType) session.getTypeComponent("BOMLine"); + propDescs = bomLineType.getPropDescs(); + + properties = getSXX(sxx); + if (properties == null || properties.length == 0) { + throw new TCException("No preferences found for: " + sxx); + } + + this.headNum = properties.length; + for (String propertyTemp : properties) { + String[] parts = propertyTemp.split(":", 2); + headPropertyList.add(parts[0]); + } + tableList.add(headPropertyList); + } + + private TCComponentItemRevision getItemRevision(InterfaceAIFComponent targetComponent) throws TCException { + if (targetComponent instanceof TCComponentItemRevision) { + return (TCComponentItemRevision) targetComponent; + } else if (targetComponent instanceof TCComponentItem) { + return ((TCComponentItem) targetComponent).getLatestItemRevision(); + } + System.out.println("Unsupported component type: " + targetComponent.getType()); + return null; + } + + private TCComponentBOMWindow createBOMWindow(TCComponentItemRevision itemRev) throws TCException { + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + return winType.create(null); + } + + private void processBOMStructure(TCComponentBOMLine bomLine) throws TCException { + // 1. ռҪȡ + Map> attributeMapping = parseAttributeMapping(); + + // 2. ǰBOMLine + processBOMLine(bomLine, attributeMapping); + + // 3. ݹ鴦 + if (bomLine.hasChildren()) { + for (AIFComponentContext childContext : bomLine.getChildren()) { + processBOMStructure((TCComponentBOMLine) childContext.getComponent()); + } + } + } + + private Map> parseAttributeMapping() { + Map> mapping = new HashMap<>(); + + for (int i = 0; i < properties.length; i++) { + String[] parts = properties[i].split(":", 2); + String head = parts[0]; + String[] attributes = parts[1].split(","); + + List propNames = new ArrayList<>(); + for (String attr : attributes) { + if (attr.startsWith("bomline.")) { + propNames.add(attr.split("\\.")[1]); + } else if (attr.startsWith("parent.")) { + propNames.add(attr.split("\\.")[1]); + } + } + + mapping.put(head, propNames); + } + + return mapping; + } + + private void processBOMLine(TCComponentBOMLine bomLine, Map> attributeMapping) + throws TCException { + TCComponentBOMLine parentLine = bomLine.getCachedParent(); + + // 1. ȡǰBOMLine͸BOMLine + Map bomLineProps = batchGetProperties(bomLine, + attributeMapping.values().stream() + .flatMap(List::stream) + .filter(prop -> propDescs.containsKey(prop)) + .collect(Collectors.toList())); + + Map parentProps = parentLine != null ? + batchGetProperties(parentLine, + attributeMapping.entrySet().stream() + .filter(e -> e.getKey().startsWith("")) + .flatMap(e -> e.getValue().stream()) + .collect(Collectors.toList())) + : new HashMap<>(); + + // 2. + List rowData = new ArrayList<>(); + for (String head : headPropertyList) { + String value = ""; + + if (head.startsWith("")) { + value = getFirstNonEmptyValue(parentProps, attributeMapping.get(head)); + } else { + value = getFirstNonEmptyValue(bomLineProps, attributeMapping.get(head)); + } + + rowData.add(value); + } + + // 3. ⴦IDֶ + if (headPropertyList.contains("ParentID")) { + int index = headPropertyList.indexOf("ParentID"); + rowData.set(index, parentLine != null ? parentLine.getProperty("bl_item_item_id") : ""); + } + + if (headPropertyList.contains("ChildID")) { + int index = headPropertyList.indexOf("ChildID"); + rowData.set(index, bomLine.getProperty("bl_item_item_id")); + } + + tableList.add(rowData); + } + + private Map batchGetProperties(TCComponentBOMLine bomLine, List propertyNames) + throws TCException { + Map result = new HashMap<>(); + + if (propertyNames.isEmpty()) { + return result; + } + + String[] props = propertyNames.toArray(new String[0]); + String[] values = bomLine.getProperties(props); + + for (int i = 0; i < props.length; i++) { + result.put(props[i], values[i] != null ? values[i] : ""); + } + + return result; + } + + private String getFirstNonEmptyValue(Map propMap, List propNames) { + if (propNames == null) return ""; + + for (String prop : propNames) { + String value = propMap.getOrDefault(prop, ""); + if (!value.isEmpty()) { + return value; + } + } + return ""; + } + + private void exportToFile(List> data, String filePath) { + XSSFWorkbook workbook = new XSSFWorkbook(); + + try { + FileOutputStream fos = new FileOutputStream(filePath); + Sheet sheet = workbook.createSheet("BOM Data"); + + // ͷʽ + CellStyle headerStyle = workbook.createCellStyle(); + Font headerFont = workbook.createFont(); + // ΪӴ + headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD); + headerStyle.setFont(headerFont); + + // д + for (int i = 0; i < data.size(); i++) { + Row row = sheet.createRow(i); + List rowData = data.get(i); + + for (int j = 0; j < rowData.size(); j++) { + Cell cell = row.createCell(j); + cell.setCellValue(rowData.get(j)); + + if (i == 0) { + cell.setCellStyle(headerStyle); + } + } + } + + // Զп + for (int i = 0; i < headPropertyList.size(); i++) { + sheet.autoSizeColumn(i); + } + + workbook.write(fos); + MessageBox.post("Export completed successfully!", "Info", MessageBox.INFORMATION); + } catch (IOException e) { + MessageBox.post("Export failed: " + e.getMessage(), "Error", MessageBox.ERROR); + e.printStackTrace(); + } + } + + private String[] getSXX(String prefName) throws TCException { + TCPreferenceService prefService = session.getPreferenceService(); + String[] values = prefService.getStringValues(prefName); + + if (values == null || values.length == 0) { + System.out.println("No values found for preference: " + prefName); + return new String[0]; + } + + System.out.println("Loaded preference values for " + prefName + ":"); + for (String val : values) { + System.out.println(val); + } + + return values; + } +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/exportBOM/WaitingDialog.java b/src/com/connor/rb/plm/exportBOM/WaitingDialog.java new file mode 100644 index 0000000..e5e9d12 --- /dev/null +++ b/src/com/connor/rb/plm/exportBOM/WaitingDialog.java @@ -0,0 +1,48 @@ +package com.connor.rb.plm.exportBOM; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Label; +import javax.swing.JPanel; +import javax.swing.JProgressBar; + +public class WaitingDialog extends AbstractAIFDialog { + public JPanel panel; + public JProgressBar progressBar = null; + + public WaitingDialog(Frame arg0, String title, String message) { + super(arg0, title); + this.setModal(false); + this.panel = new JPanel(new BorderLayout()); + this.progressBar = new JProgressBar(0); + this.progressBar.setVisible(true); + this.progressBar.setIndeterminate(true); + this.panel.add("Center", new Label(message)); + this.panel.add("South", this.progressBar); + this.panel.setPreferredSize(new Dimension(350, 60)); + this.getContentPane().add(this.panel); + this.centerToScreen(); + this.pack(); + } + + public void SetDialogMessage(String sMessage) { + try { + Component[] components = this.panel.getComponents(); + + for(int i = 0; i < components.length; ++i) { + if (components[i] instanceof Label) { + Label label = (Label)components[i]; + label.setText(sMessage); + break; + } + } + } catch (Exception var5) { + Exception e = var5; + e.printStackTrace(); + } + + } +} diff --git a/src/com/connor/rb/plm/handlers/SampleHandler.java b/src/com/connor/rb/plm/handlers/SampleHandler.java new file mode 100644 index 0000000..84450f5 --- /dev/null +++ b/src/com/connor/rb/plm/handlers/SampleHandler.java @@ -0,0 +1,18 @@ +package com.connor.rb.plm.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.handlers.HandlerUtil; +import org.eclipse.jface.dialogs.MessageDialog; + +public class SampleHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); + MessageDialog.openInformation(window.getShell(), "Plm", "Hello, Eclipse world"); + return null; + } +} diff --git a/src/com/connor/rb/plm/newcombox/RwBasicComboPopup.java b/src/com/connor/rb/plm/newcombox/RwBasicComboPopup.java new file mode 100644 index 0000000..e18391a --- /dev/null +++ b/src/com/connor/rb/plm/newcombox/RwBasicComboPopup.java @@ -0,0 +1,27 @@ +package com.connor.rb.plm.newcombox; + +import java.awt.event.KeyListener; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; + +import javax.swing.JComboBox; +import javax.swing.JList; +import javax.swing.plaf.basic.BasicComboPopup; +import javax.swing.plaf.basic.ComboPopup; + +public class RwBasicComboPopup extends BasicComboPopup { + + public RwBasicComboPopup(JComboBox combo) { + // TODO Auto-generated constructor stub + super(combo); + } + + protected void configureList() { + super.configureList(); + list.setSelectionModel(new RwDefaultListSelectionModel(comboBox)); + } + + protected MouseListener createListMouseListener() { + return new RwMouseAdapter(list, comboBox); + } +} diff --git a/src/com/connor/rb/plm/newcombox/RwDefaultComboBoxModel.java b/src/com/connor/rb/plm/newcombox/RwDefaultComboBoxModel.java new file mode 100644 index 0000000..354cc99 --- /dev/null +++ b/src/com/connor/rb/plm/newcombox/RwDefaultComboBoxModel.java @@ -0,0 +1,16 @@ +package com.connor.rb.plm.newcombox; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.event.ListDataListener; + +public class RwDefaultComboBoxModel extends DefaultComboBoxModel { + + public RwDefaultComboBoxModel(String[] str) { + // TODO Auto-generated constructor stub + for (int i = 0; i < str.length; i++) { + addElement(str[i]); + } + } + +} diff --git a/src/com/connor/rb/plm/newcombox/RwDefaultListSelectionModel.java b/src/com/connor/rb/plm/newcombox/RwDefaultListSelectionModel.java new file mode 100644 index 0000000..68daad0 --- /dev/null +++ b/src/com/connor/rb/plm/newcombox/RwDefaultListSelectionModel.java @@ -0,0 +1,21 @@ +package com.connor.rb.plm.newcombox; + +import javax.swing.DefaultListSelectionModel; +import javax.swing.JComboBox; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionListener; + +public class RwDefaultListSelectionModel extends DefaultListSelectionModel { + + protected RwJComboBox rwJComboBox; + + public RwDefaultListSelectionModel(JComboBox comboBox) { + // TODO Auto-generated constructor stub + this.rwJComboBox = (RwJComboBox) comboBox; + } + + public boolean isSelectedIndex(int index) { + return rwJComboBox.set.contains(index); + } + +} diff --git a/src/com/connor/rb/plm/newcombox/RwJCheckBox.java b/src/com/connor/rb/plm/newcombox/RwJCheckBox.java new file mode 100644 index 0000000..a0bd5da --- /dev/null +++ b/src/com/connor/rb/plm/newcombox/RwJCheckBox.java @@ -0,0 +1,30 @@ +package com.connor.rb.plm.newcombox; + +import java.awt.Component; + +import javax.swing.JCheckBox; +import javax.swing.JList; +import javax.swing.ListCellRenderer; + +public class RwJCheckBox extends JCheckBox implements ListCellRenderer { + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, + boolean cellHasFocus) { + // TODO Auto-generated method stub + setComponentOrientation(list.getComponentOrientation()); +// if(isSelected) { +// setBackground(list.getSelectionBackground()); +// setBackground(list.getSelectionForeground()); +// }else { +// setBackground(list.getBackground()); +// setForeground(list.getForeground()); +// } + setEnabled(list.isEnabled()); + setSelected(isSelected); + setText(value == null ? "" : value.toString()); + setFont(list.getFont()); + return this; + } + +} diff --git a/src/com/connor/rb/plm/newcombox/RwJComboBox.java b/src/com/connor/rb/plm/newcombox/RwJComboBox.java new file mode 100644 index 0000000..608ff81 --- /dev/null +++ b/src/com/connor/rb/plm/newcombox/RwJComboBox.java @@ -0,0 +1,42 @@ +package com.connor.rb.plm.newcombox; + +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.util.HashSet; +import java.util.Set; + +import javax.swing.JComboBox; + +public class RwJComboBox extends JComboBox implements FocusListener { + + protected Set set = new HashSet(); + + public RwJComboBox(String str[]) { + setModel(new RwDefaultComboBoxModel(str)); + setUI(new RwMetalComboBoxUI(this)); + setRenderer(new RwJCheckBox()); + // setSelectedIndex(-1); + } + + public void setSet() { + this.set.clear(); + + } + + public Set getSet() { + return set; + } + + @Override + public void focusGained(FocusEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void focusLost(FocusEvent e) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/com/connor/rb/plm/newcombox/RwMetalComboBoxUI.java b/src/com/connor/rb/plm/newcombox/RwMetalComboBoxUI.java new file mode 100644 index 0000000..2a74c95 --- /dev/null +++ b/src/com/connor/rb/plm/newcombox/RwMetalComboBoxUI.java @@ -0,0 +1,37 @@ +package com.connor.rb.plm.newcombox; + +import javax.swing.JComboBox; +import javax.swing.plaf.ComboBoxUI; +import javax.swing.plaf.basic.ComboPopup; +import javax.swing.plaf.metal.MetalComboBoxUI; + +public class RwMetalComboBoxUI extends MetalComboBoxUI { + + public RwMetalComboBoxUI(RwJComboBox rwJComboBox) { + // TODO Auto-generated constructor stub + this.comboBox = rwJComboBox; + } + + protected ComboPopup createPopup() { + return new RwBasicComboPopup(comboBox); + } + + @Override + public void setPopupVisible(JComboBox c, boolean v) { + // TODO Auto-generated method stub + + } + + @Override + public boolean isPopupVisible(JComboBox c) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isFocusTraversable(JComboBox c) { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/src/com/connor/rb/plm/newcombox/RwMouseAdapter.java b/src/com/connor/rb/plm/newcombox/RwMouseAdapter.java new file mode 100644 index 0000000..6850fe5 --- /dev/null +++ b/src/com/connor/rb/plm/newcombox/RwMouseAdapter.java @@ -0,0 +1,105 @@ +package com.connor.rb.plm.newcombox; + +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.swing.JComboBox; +import javax.swing.JList; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; + +public class RwMouseAdapter extends MouseAdapter { + + private JList list; + private RwJComboBox rwJComboBox; + + public RwMouseAdapter(JList list, JComboBox comboBox) { + // TODO Auto-generated constructor stub + this.list = list; + this.rwJComboBox = (RwJComboBox) comboBox; + } + + public void mousePressed(MouseEvent anEvent) { + StringBuilder sb, sb1, sb2, sb3; + int k, index; + index = list.getSelectedIndex(); + JTextField jTextField = (JTextField) rwJComboBox.getEditor().getEditorComponent(); + sb = new StringBuilder(jTextField.getText()); + if (sb.length() > 0 && ',' != sb.charAt(0)) { + sb.insert(0, ","); + } + if (sb.length() > 0 && ',' != sb.charAt(sb.length() - 1)) { + sb.append(","); + } + if (sb.length() > 0 && ",".equals(sb.toString())) { + sb = new StringBuilder(); + } + if (list.getSelectionMode() == ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { + if (rwJComboBox.set.contains(index)) { + rwJComboBox.set.remove(index); + sb1 = new StringBuilder(); + sb1.append(",").append(rwJComboBox.getModel().getElementAt(index)).append(","); + k = sb.indexOf(sb1.toString()); + while (k != -1) { + sb.replace(k, k + sb1.length(), ","); + k = sb.indexOf(sb1.toString()); + } + } else { + rwJComboBox.set.add(index); + if (sb.length() == 0) { + sb.append(",").append(rwJComboBox.getModel().getElementAt(index)).append(","); + + } else { + sb.append(rwJComboBox.getModel().getElementAt(index)).append(","); + } + } + } else { + if (!rwJComboBox.set.contains(index)) { + rwJComboBox.set.clear(); + rwJComboBox.set.add(index); + } + } + Object obj; + sb2 = new StringBuilder(sb); + // 滻Ŀѡֵ + for (int i = 0; i < list.getModel().getSize(); i++) { + obj = list.getModel().getElementAt(i); + sb1 = new StringBuilder(); + sb1.append(",").append(obj).append(","); + k = sb2.indexOf(sb1.toString()); + while (k != -1) { + sb2.replace(k, k + sb1.length(), ","); + k = sb2.indexOf(sb1.toString()); + } + } + List list1 = new ArrayList(rwJComboBox.set); + Collections.sort(list1); + for (int i = 0; i < list1.size(); i++) { + obj = rwJComboBox.getModel().getElementAt(Integer.parseInt(list1.get(i).toString())); + sb1 = new StringBuilder(); + sb1.append(",").append(obj).append(","); + k = sb.indexOf(sb1.toString()); + if (k != -1 && sb2.indexOf(sb1.toString()) == -1) { + sb2.append(obj).append(","); + } + } + sb = new StringBuilder(sb2); + if (sb.length() > 0 && ',' == sb.charAt(0)) { + sb.deleteCharAt(0); + } + if (sb.length() > 0 && ',' == sb.charAt(sb.length() - 1)) { + sb.deleteCharAt(sb.length() - 1); + } + if (sb.length() > 0 && ",".equals(sb.toString())) { + sb = new StringBuilder(); + } + jTextField.setText(sb.toString()); + rwJComboBox.repaint(); + list.repaint(); + } + +} diff --git a/src/com/connor/rb/plm/openFastWorkflowLists/CustTaskToPerformDto.java b/src/com/connor/rb/plm/openFastWorkflowLists/CustTaskToPerformDto.java new file mode 100644 index 0000000..6707d40 --- /dev/null +++ b/src/com/connor/rb/plm/openFastWorkflowLists/CustTaskToPerformDto.java @@ -0,0 +1,335 @@ +package com.connor.rb.plm.openFastWorkflowLists; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.io.Serializable; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.eclipse.swt.widgets.TableItem; + +import com.connor.rb.plm.openFastWorkflowLists.common.StringUtil; +import com.teamcenter.rac.kernel.TCComponent; + + +/** + * + * WorkFlowListһж + * + * @author Jreden + * + */ +public class CustTaskToPerformDto implements Serializable { + public TCComponent getEpmJobObj() { + return epmJobObj; + } + + public void setEpmJobObj(TCComponent epmJobObj) { + this.epmJobObj = epmJobObj; + } + + public TCComponent getEpmTaskObj() { + return epmTaskObj; + } + + public void setEpmTaskObj(TCComponent epmTaskObj) { + this.epmTaskObj = epmTaskObj; + } + + private static final long serialVersionUID = 1L; + /** + * SQLȡ + SELECT + J.WFTEMPLATE AS WFTEMPLATE_EN, + (select DISTINCT PVAL_0 from INFODBA.VL10N_TEMPLATE_NAME where puid = j.WFTemplateUid and locale = 'zh_CN') AS WFTEMPLATE_CN, + V.EPMTASK_PUID, + V.EPMTASK_TYPE, + V.EPMJOBNAME, + V.EPMTASK_NAME, + V.EPMTASK_NAME_CN, + V.PSTATE_VALUE, + V.PTASK_RESULT, + V.PUSER_ID, + V.EPMJOB_PUID, + V.RPARENT_PROCESSC, + V.RRESPONSIBLE_PARTYU, + V.RRESPONSIBLE_PARTYC, + V.PCREATION_DATE, + V.PLAST_MOD_DATE + FROM + INFODBA.V_CUST_TASKSTOPERFORM V , + INFODBA.V_CUST_WFJOBLIST J + WHERE + J.JOBUID = V.EPMJOB_PUID AND + upper(V.PUSER_ID) = 'PDT01' + **/ + + private TCComponent epmJobObj; // Job + private TCComponent epmTaskObj; // Task + + private String seq; // + + /** ģӢ */ + private String wfTemplateEn; + + /** ģƣVL10N_TEMPLATE_NAME Ӳѯ */ + private String wfTemplateCn; + + /* ====== VV_CUST_TASKSTOPERFORM ====== */ + /** EPM PUID */ + private String epmTaskPuid; + + /** */ + private String epmTaskType; + + /** EPM ҵ */ + private String epmJobName; + + /** Ӣ */ + private String epmTaskName; + + /** */ + private String epmTaskNameCn; + + /** ״ֵ̬ */ + private String pstateValue; + + /** */ + private String ptaskResult; + + /** û ID */ + private String puserId; + + /** EPM ҵ PUID */ + private String epmJobPuid; + + /** PUID */ + private String rparentProcessc; + + /** ηû PUID */ + private String rresponsiblePartyu; + + /** η˾ PUID */ + private String rresponsiblePartyc; + + /** ʱ */ + private Date pcreationDate; + + /** ޸ʱ */ + private Date plastModDate; + + /** ʱStr */ + private String creationDateStr; + + /** ޸ʱStr */ + private String lastModDateStr; + + /** + * @return the seq + */ + public String getSeq() { + return seq; + } + + /** + * @param seq the seq to set + */ + public void setSeq(String seq) { + this.seq = seq; + } + + /* ====== Getter / Setter ====== */ + public String getWfTemplateEn() { + return wfTemplateEn; + } + + public void setWfTemplateEn(String wfTemplateEn) { + this.wfTemplateEn = wfTemplateEn; + } + + public String getWfTemplateCn() { + return wfTemplateCn; + } + + public void setWfTemplateCn(String wfTemplateCn) { + this.wfTemplateCn = wfTemplateCn; + } + + public String getEpmTaskPuid() { + return epmTaskPuid; + } + + public void setEpmTaskPuid(String epmTaskPuid) { + this.epmTaskPuid = epmTaskPuid; + } + + public String getEpmTaskType() { + return epmTaskType; + } + + public void setEpmTaskType(String epmTaskType) { + this.epmTaskType = epmTaskType; + } + + public String getEpmJobName() { + return epmJobName; + } + + public void setEpmJobName(String epmJobName) { + this.epmJobName = epmJobName; + } + + public String getEpmTaskName() { + return epmTaskName; + } + + public void setEpmTaskName(String epmTaskName) { + this.epmTaskName = epmTaskName; + } + + public String getEpmTaskNameCn() { + return epmTaskNameCn; + } + + public void setEpmTaskNameCn(String epmTaskNameCn) { + this.epmTaskNameCn = epmTaskNameCn; + } + + public String getPstateValue() { + return pstateValue; + } + + public void setPstateValue(String pstateValue) { + this.pstateValue = pstateValue; + } + + public String getPtaskResult() { + return ptaskResult; + } + + public void setPtaskResult(String ptaskResult) { + this.ptaskResult = ptaskResult; + } + + public String getPuserId() { + return puserId; + } + + public void setPuserId(String puserId) { + this.puserId = puserId; + } + + public String getEpmJobPuid() { + return epmJobPuid; + } + + public void setEpmJobPuid(String epmJobPuid) { + this.epmJobPuid = epmJobPuid; + } + + public String getRparentProcessc() { + return rparentProcessc; + } + + public void setRparentProcessc(String rparentProcessc) { + this.rparentProcessc = rparentProcessc; + } + + public String getRresponsiblePartyu() { + return rresponsiblePartyu; + } + + public void setRresponsiblePartyu(String rresponsiblePartyu) { + this.rresponsiblePartyu = rresponsiblePartyu; + } + + public String getRresponsiblePartyc() { + return rresponsiblePartyc; + } + + public void setRresponsiblePartyc(String rresponsiblePartyc) { + this.rresponsiblePartyc = rresponsiblePartyc; + } + + public Date getPcreationDate() { + return pcreationDate; + } + + public void setPcreationDate(Date pcreationDate) { + this.pcreationDate = pcreationDate; + } + + public Date getPlastModDate() { + return plastModDate; + } + + public void setPlastModDate(Date plastModDate) { + this.plastModDate = plastModDate; + } + + + + /** + * @ "", "", "", "̷ʱ", "޸ʱ", "" + * @ˣJreden + * @ʱ䣺20201113 3:25:11 + * + @return ֵ + */ + public String[] toArray() { + String[] str = new String[] { + this.seq, + this.epmJobName, + this.epmTaskNameCn, + this.creationDateStr, + this.lastModDateStr, + this.puserId + }; + return str; + } + + /** + * @return + * @ ͷ + * @ˣJreden + */ + public String[] propNametoArray() { + String[] str = new String[] { "", "", "", "̷ʱ", "޸ʱ", ""}; + return str; + } + + + public CustTaskToPerformDto() { + + } + + public CustTaskToPerformDto(TableItem item) { + + //"", "", "", "̷ʱ", "޸ʱ", "" + // this.seq, this.familyGroupName, this.familyClassify, this.familyID, this.familyName, this.optionID, this.optionName, this.optionSeq + this.seq = item.getText(0); + this.epmJobName = item.getText(1); + this.epmTaskNameCn = item.getText(2); + } + + public String getCreationDateStr() { + return creationDateStr; + } + + public void setCreationDateStr(String creationDateStr) { + this.creationDateStr = creationDateStr; + } + + public String getLastModDateStr() { + return lastModDateStr; + } + + public void setLastModDateStr(String lastModDateStr) { + this.lastModDateStr = lastModDateStr; + } + + +} diff --git a/src/com/connor/rb/plm/openFastWorkflowLists/OpenFastWorkflowListsAction.java b/src/com/connor/rb/plm/openFastWorkflowLists/OpenFastWorkflowListsAction.java new file mode 100644 index 0000000..3f753ae --- /dev/null +++ b/src/com/connor/rb/plm/openFastWorkflowLists/OpenFastWorkflowListsAction.java @@ -0,0 +1,438 @@ +package com.connor.rb.plm.openFastWorkflowLists; + +import java.io.File; +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; + +import org.apache.commons.lang.StringUtils; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.TabItem; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; + + +import com.connor.rb.plm.openFastWorkflowLists.common.ExcelUtil; +import com.connor.rb.plm.openFastWorkflowLists.common.ProgressMonitorAction; +import com.connor.rb.plm.openFastWorkflowLists.common.StringUtil; +import com.connor.rb.plm.openFastWorkflowLists.common.TCMsgUtil; +import com.connor.rb.plm.openFastWorkflowLists.common.TableUtils; +import com.connor.rb.plm.openFastWorkflowLists.common.TimeConvertUtil; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentSavedVariantRule; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.services.loose.core.DataManagementService; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.ServiceData; + +public class OpenFastWorkflowListsAction extends ProgressMonitorAction { + + static TCSession session; + public static Connection dBConnection = null; + + private final static String ROW_INDEX = "rowIndex"; + + private final static String FLAG_DISPLAY = "-display"; + + private Shell shell; + + private static OpenFastWorkflowListsAction instance; + + /** tableϵڵʱȡӦtable **/ + private Map workflowTableMap = new HashMap(); + private List workflowTableList = new ArrayList
(); + + + /** tableͷ **/ + private List headColList; + + private TCComponent TcUserId; + private Table Table; + + private com.teamcenter.soa.client.Connection soaconn; + private DataManagementService dataManagement; + + private OpenFastWorkflowListsAction() { + } + + public static OpenFastWorkflowListsAction getInstance() { + if (instance == null) { + instance = new OpenFastWorkflowListsAction(); + } + return instance; + } + + //ڸʽ + private static final SimpleDateFormat CN_DataFMT = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + + + + /** + * Ⱦ桢 + * + * @param currentTcUser + * @param svr + * @throws TCException + */ + public void addTabComponent(final Table table, final TCComponentUser currentTcUser, final IProgressMonitor monitor) throws TCException { + // ռݣ˴ռȾֿ⿨ + final List strList = new ArrayList(); + final List dataList = new ArrayList<>(); + final String userId = currentTcUser.getUserId(); + + final String userDisplay = currentTcUser.toDisplayString(); + int num = 1; + int totalNum = 1; + + soaconn = RACUIUtil.getTCSession().getSoaConnection(); + dataManagement = DataManagementService.getService(soaconn); + + // + monitor.beginTask("ڼ:" + userDisplay + ", дϢ...",4); + try { + // ؼغʱ + long totalstart = System.currentTimeMillis(); + monitor.setTaskName("ڳʼݿ..."); + + /** + * û ID ѯִб + * + * @param conn ⲿݿӣ÷/رգ + * @param userId ᱻԶ upper() + * @return ѯбʱؿ List null + * @throws SQLException JDBC 쳣ʱԭ׳ϲ㴦 + */ + + String sql = + "SELECT " + + " J.WFTEMPLATE AS WFTEMPLATE_EN, " + + " (SELECT DISTINCT PVAL_0 " + + " FROM INFODBA.VL10N_TEMPLATE_NAME " + + " WHERE PUID = J.WFTEMPLATEUID " + + " AND LOCALE = 'zh_CN') AS WFTEMPLATE_CN, " + + " V.EPMTASK_PUID, " + + " V.EPMTASK_TYPE, " + + " V.EPMJOBNAME, " + + " V.EPMTASK_NAME, " + + " V.EPMTASK_NAME_CN, " + + " V.PSTATE_VALUE, " + + " V.PTASK_RESULT, " + + " V.PUSER_ID, " + + " V.EPMJOB_PUID, " + + " V.RRESPONSIBLE_PARTYU, " + + " V.RRESPONSIBLE_PARTYC, " + + " V.PCREATION_DATE, " + + " V.PLAST_MOD_DATE " + + " FROM INFODBA.V_CUST_TASKSTOPERFORM V " + + " JOIN INFODBA.V_CUST_WFJOBLIST J " + + " ON J.JOBUID = V.EPMJOB_PUID " + + " WHERE UPPER(V.PUSER_ID) = ?" + + "order by V.PLAST_MOD_DATE DESC"; + //userId.toUpperCase() + //SQLȡϢ,ݸtotalNum + + if (dBConnection == null) { + //ȡJDBC + getConnectionTC12(); + } + monitor.worked(1); + monitor.setTaskName("ִݿѯ..."); + // ִ SQL ѯ + PreparedStatement ps = dBConnection.prepareStatement(sql); + // ⲿ upper upper һη + ps.setString(1, userId.toUpperCase()); + //ps.setString(1,"PDT01"); + // չʾ + ResultSet rs = ps.executeQuery(); + int rowCount = 0; + monitor.worked(1); + monitor.beginTask("ʼݿ....", 500); + num = 0; + while (rs.next()) { + num++; + if (monitor.isCanceled()) return; + monitor.worked(1); + if(num%10==0)monitor.subTask("ڼص:" + num + "..."); + CustTaskToPerformDto dao = new CustTaskToPerformDto(); + dao.setSeq(Integer.toString(num)); + dao.setWfTemplateEn(rs.getString("WFTEMPLATE_EN")); + dao.setWfTemplateCn(rs.getString("WFTEMPLATE_CN")); + dao.setEpmTaskPuid(rs.getString("EPMTASK_PUID")); + dao.setEpmTaskType(rs.getString("EPMTASK_TYPE")); + dao.setEpmJobName(rs.getString("EPMJOBNAME")); + dao.setEpmTaskName(rs.getString("EPMTASK_NAME")); + dao.setEpmTaskNameCn(rs.getString("EPMTASK_NAME_CN")); + //dao.setPstateValue(rs.getString("PSTATE_VALUE")); + //dao.setPtaskResult(rs.getString("PTASK_RESULT")); + dao.setPuserId(rs.getString("PUSER_ID")); + dao.setEpmJobPuid(rs.getString("EPMJOB_PUID")); + //dao.setRparentProcessc(rs.getString("RPARENTPROCESSC")); + //dao.setRresponsiblePartyu(rs.getString("RRESPONSIBLE_PARTYU")); + //dao.setRresponsiblePartyc(rs.getString("RRESPONSIBLE_PARTYC")); + //dao.setPcreationDate(TimeConvertUtil.readUtcToCN(rs, "PCREATION_DATE")); + //dao.setPlastModDate(TimeConvertUtil.readUtcToCN(rs, "PLAST_MOD_DATE")); + dao.setPcreationDate(rs.getTimestamp("PCREATION_DATE")); + dao.setPlastModDate(rs.getTimestamp("PLAST_MOD_DATE")); + //dao.setCreationDateStr(CN_DataFMT.format(TimeConvertUtil.readUtcToCN(rs,"PCREATION_DATE"))); + //dao.setLastModDateStr(CN_DataFMT.format(TimeConvertUtil.readUtcToCN(rs,"PLAST_MOD_DATE"))); + dataList.add(dao); + } + + // رԴ + rs.close(); + ps.close(); + + long totalend = System.currentTimeMillis(); + System.out.println("ݿѯ̴񣬺ϼƵʱ䣺" + (totalend - totalstart) + "!"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + //رݿ + try { + dBConnection.close(); + dBConnection=null; + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if (monitor.isCanceled()) return; + //ʼ + monitor.beginTask("ʼתʾ....:" + (dataList.size()) + "...", dataList.size()); + num=0; + for (int i=0;i tableColumnList = new ArrayList(); + + //޸ظͷ + if(table.getColumnCount()==0) { + // ñͷ + for (String key : headColList) { + TableColumn tableColumn = new TableColumn(table, SWT.LEFT); + tableColumn.setText(key); + tableColumnList.add(tableColumn); + } + } + // + for (int i=0;i350) { + column.setWidth(350); + } + + } + workflowTableMap.put(currentTcUser, table); + workflowTableList.add(table); + TableUtils.addSorters(table); + TableUtils.addSorter(table, table.getColumn(0), null, StringUtil.sortByStr()); + //2020-11-24ѡ + table.setSortDirection(SWT.UP); + table.getColumn(0).notifyListeners(SWT.Selection, new Event()); + table.setRedraw(true); + } + }); + } + + /** + * ʼ + * @param svr2 + * + * @throws TCException + */ + public void init(TCComponent TcUser, Table table, Shell shell) { + this.TcUserId = TcUser; + this.Table = table; + this.shell = shell; + workflowTableList.clear(); + processMonitorRun(null); + + } + + @Override + public void pmExecute(IProgressMonitor monitor, Shell shell) { + monitor.beginTask("ݼУԺ󡣡", 5); + monitor.worked(1); + try { + addTabComponent(Table, (TCComponentUser) TcUserId, monitor); + } catch (Exception e) { + TCMsgUtil.errorMsgBox(shell, e.getMessage()); + } finally { + monitor.done(); + } + } + + /** + * excel + */ + public void exportExcel() { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); + String dateString = dateFormat.format(new Date()); + // ļ + FileDialog fileDlg = new FileDialog(AIFDesktop.getActiveDesktop().getShell(), SWT.SAVE); + fileDlg.setText("Ϣ"); + fileDlg.setFilterExtensions(new String[] { "*.xls" }); + String fileName = TcUserId.toDisplayString() + "嵥" + dateString + ".xls"; + fileDlg.setFileName(fileName); + String filePath = fileDlg.open(); + File file = new File(filePath); + try { + if (file.exists()) { + boolean b = MessageDialog.openConfirm(shell, "ʾ", "ļѾڣǷ񸲸ǣ"); + if (!b) { + return; + } + } + ExcelUtil.buildExcelLocally(file, this.Table); + boolean result = MessageDialog.openQuestion(null, "Ϣ", "ļɹ :" + filePath + "Ƿ򿪲鿴...?"); + if (result) { + Runtime.getRuntime().exec("cmd /c \"" + filePath + "\""); + } + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + + /* ߣnull -> "" */ + private static String strNotNullConv(String s) { + return s == null ? "" : s; + } + + /* ߣDate -> yyyy-MM-dd HH:mm:ss */ + private static String dateFmt(Date d) { + return d == null ? "" : CN_DataFMT.format(d); + } + + /** + * ݿ + */ + public static Connection getConnectionTC12() { +// connection = com.connor.rb.DBTest.GetConn.getConnAction(); + try { + TCPreferenceService service = session.getPreferenceService(); + String[] array = service.getStringArray(TCPreferenceService.TC_preference_site, "TC12_Oracle_MSG"); + String driver_temp = null; + String url = null; + String dbName = null; + String dbPassword = null; + if (array != null) + for (String str : array) { + System.out.println(" ORACLE = " + str); + if (str != null && str.startsWith("ORACEL_DRIVER=")) { + driver_temp = str.substring(str.indexOf("=") + 1, str.length()); + } else if (str != null && str.startsWith("ORACEL_URL=")) { + url = str.substring(str.indexOf("=") + 1, str.length()); + } else if (str != null && str.startsWith("ORACEL_NAME=")) { + dbName = str.substring(str.indexOf("=") + 1, str.length()); + } else if (str != null && str.startsWith("ORACEL_PASSWORD=")) { + dbPassword = str.substring(str.indexOf("=") + 1, str.length()); + } + } + + if (driver_temp == null || url == null || dbName == null || dbPassword == null) { + Locale defaultLocale = Locale.getDefault(); + MessageBox.post("ѡTC12_Oracle_MSG", "ʾ", MessageBox.ERROR); + } + + System.out.println(url + dbName + dbPassword); + dBConnection = DriverManager.getConnection(url, dbName, dbPassword); + dBConnection.setAutoCommit(false); + } catch (SQLException e) { + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + return null; + // MessageBox.post("ORACEL CONNECT EXCEPTION + // \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + } + return dBConnection; + } + +} diff --git a/src/com/connor/rb/plm/openFastWorkflowLists/OpenFastWorkflowListsDialog.java b/src/com/connor/rb/plm/openFastWorkflowLists/OpenFastWorkflowListsDialog.java new file mode 100644 index 0000000..3e503e4 --- /dev/null +++ b/src/com/connor/rb/plm/openFastWorkflowLists/OpenFastWorkflowListsDialog.java @@ -0,0 +1,395 @@ +package com.connor.rb.plm.openFastWorkflowLists; + + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Dialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.wb.swt.SWTResourceManager; + +import com.connor.rb.plm.openFastWorkflowLists.common.RacSoaUtils; +import com.connor.rb.plm.openFastWorkflowLists.common.StringUtil; +import com.connor.rb.plm.openFastWorkflowLists.common.StringUtils; +import com.connor.rb.plm.openFastWorkflowLists.common.TCMsgUtil; +import com.connor.rb.plm.util.TCUtils; +import com.teamcenter.rac.aif.kernel.AIFSession; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCComponentUserType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.common.RACUIUtil; + +import swing2swt.layout.BorderLayout; + + +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.custom.ScrolledComposite; +import org.eclipse.swt.widgets.Table; + +public class OpenFastWorkflowListsDialog extends Dialog { + + private TCSession session; + protected Object result; + protected Shell shlsox; + private OpenFastWorkflowListsAction action; + private Button btnLoadData; + private Text txtFind; + private Text txtUserID; + private ScrolledComposite tableComposite; + private Table table; + private String currentUserId =""; + private TCComponentUser currentUser; + + private static int statidnex = 0; + private Group groupView; + + /** + * Create the dialog. + * + * @param parent + * @param style + */ + public OpenFastWorkflowListsDialog(Shell parent, int style) { + super(parent, style); + setText("C&U Cust"); + } + + /** + * Open the dialog. + * + * @return the result + */ + public Object open() { + action = OpenFastWorkflowListsAction.getInstance(); + action.session = RACUIUtil.getTCSession(); + //ȡǰû + session = RACUIUtil.getTCSession(); + TCComponentUser TcUserComp = null; + try { + TcUserComp=session.getUser(); + if (TcUserComp!=null) { + setCurrentUser(TcUserComp); + setCurrentUserId(TcUserComp.getUserId().toUpperCase()); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + //Ի + createContents(); + init(); + shlsox.open(); + shlsox.layout(); + Display display = getParent().getDisplay(); + while (!shlsox.isDisposed()) { + if (!display.readAndDispatch()) { + display.sleep(); + } + } + return result; + } + + /** + * Create contents of the dialog. + */ + private void createContents() { + shlsox = new Shell(getParent(), SWT.SHELL_TRIM | SWT.BORDER); + shlsox.setImage(SWTResourceManager.getImage(OpenFastWorkflowListsDialog.class, "/com/connor/rb/plm/openFastWorkflowLists/common/TeamCenter.png")); + shlsox.setSize(800, 450); + shlsox.setText("\u5F85\u529E\u4EFB\u52A1\u6E05\u5355 Rev1.1 2025-12-23"); + shlsox.setLayout(new FillLayout(SWT.HORIZONTAL)); + + Composite composite = new Composite(shlsox, SWT.NONE); + composite.setLayout(new BorderLayout(0, 0)); + + Group groupAction = new Group(composite, SWT.NONE); + groupAction.setLayoutData(BorderLayout.NORTH); + groupAction.setText("\u64CD\u4F5C"); + GridLayout gl_groupAction = new GridLayout(6, false); + gl_groupAction.marginLeft = 10; + gl_groupAction.marginWidth = 0; + gl_groupAction.verticalSpacing = 0; + gl_groupAction.horizontalSpacing = 10; + groupAction.setLayout(gl_groupAction); + + //ûIDݹ + txtUserID = new Text(groupAction, SWT.BORDER); + GridData gd_txtUserID = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); + gd_txtUserID.minimumWidth = 50; + gd_txtUserID.widthHint = 60; + txtUserID.setLayoutData(gd_txtUserID); + txtUserID.setText(currentUserId.toUpperCase()); + + btnLoadData = new Button(groupAction, SWT.NONE); + btnLoadData.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if(StringUtils.isNotBlank(txtUserID.getText())) { + TCComponentUser user = RacSoaUtils.findUserByUserID(txtUserID.getText(), session); + if(user==null) { + TCMsgUtil.infoMsgBox("ûid"+txtUserID.getText()+"ڣټ..."); + return; + }else { + setCurrentUser(user); + groupView.setText(getCurrentUser().toDisplayString() + " Ĵ˫дǩ"); + } + } + table.setRedraw(false); + //ձ + table.clearAll(); + table.removeAll(); + action.init(currentUser, table, shlsox); + table.setRedraw(true); + } + }); + btnLoadData.setImage(SWTResourceManager.getImage(OpenFastWorkflowListsDialog.class, "/com/teamcenter/rac/util/images/expand_16.png")); + btnLoadData.setText("\u91CD\u65B0\u52A0\u8F7D"); + + Button btnExport = new Button(groupAction, SWT.NONE); + btnExport.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + action.exportExcel(); + } + }); + btnExport.setImage(SWTResourceManager.getImage(OpenFastWorkflowListsDialog.class, "/com/teamcenter/rac/util/images/excelfiletype_16.png")); + btnExport.setText("\u5BFC\u51FAExcel"); + new Label(groupAction, SWT.NONE); + + txtFind = new Text(groupAction, SWT.BORDER); + GridData gd_txtFind = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); + gd_txtFind.widthHint = 462; + txtFind.setLayoutData(gd_txtFind); + + + Button btnFind = new Button(groupAction, SWT.NONE); + btnFind.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + filterTable2(table, txtFind.getText()); + } + }); + + //ӻس + txtFind.addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + if (e.keyCode == 13 || e.keyCode ==16777296) { + Event event1 = new Event(); + event1.widget = btnFind; + // btnFind ѯ ¼ + btnFind.notifyListeners(SWT.Selection, event1); + } + } + }); + GridData gd_btnFind = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); + gd_btnFind.widthHint = 100; + gd_btnFind.minimumWidth = 100; + btnFind.setLayoutData(gd_btnFind); + btnFind.setImage(SWTResourceManager.getImage(OpenFastWorkflowListsDialog.class, "/com/teamcenter/rac/util/images/search_16.png")); + btnFind.setText("\u67E5\u627E"); + + Label lblNewLabel = new Label(groupAction, SWT.CENTER); + lblNewLabel.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1)); + lblNewLabel.setText(" "); + + groupView = new Group(composite, SWT.NONE); + groupView.setText("\u5F85\u529E\u4EFB\u52A1"); + groupView.setLayoutData(BorderLayout.CENTER); + groupView.setLayout(new FillLayout(SWT.HORIZONTAL)); + groupView.setText(getCurrentUser().toDisplayString() + " Ĵ˫дǩ"); + + tableComposite = new ScrolledComposite(groupView, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); + tableComposite.setExpandHorizontal(true); + tableComposite.setExpandVertical(true); + + table = new Table(tableComposite, SWT.BORDER | SWT.FULL_SELECTION); + table.setHeaderVisible(true); + table.setLinesVisible(true); + tableComposite.setContent(table); + tableComposite.setMinSize(table.computeSize(SWT.DEFAULT, SWT.DEFAULT)); + + //˫򿪶 + table.addMouseListener(new MouseAdapter() { + @Override + public void mouseDoubleClick(MouseEvent e) { + //ȡ˫Ϣ + if (table.getSelectionCount() != 0) { + final TableItem item = table.getItem(table.getSelectionIndex()); + String puidStr = (String) item.getData(); + TCComponent tccomp =null; + try { + tccomp = session.stringToComponent(puidStr); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + if(tccomp==null) { + TCMsgUtil.errorMsgBox("˫:"+item.getText(1)+" 쳣ϵԱ..."); + return; + } + TCComponent[] tcobj = new TCComponent[]{tccomp}; + openComp(tcobj); + } + } + }); + } + + /** + * ݳʼ + */ + protected void init() { + if(StringUtils.isNotBlank(txtUserID.getText())) { + + } + action.init(getCurrentUser(),table, shlsox); + // action.loadProductItemData(productItemList, tabFolder, shlsox); + } + + + /** ϴҵλãȫֱ */ + private int lastFoundIndex = -1; + + /** + * table filterTextִСд + * ҲlastFoundIndex Ϊ -1 ʾ + */ + private void filterTable2(Table table, String filterText) { + if (filterText == null || filterText.isEmpty()) { + clearAllHighlight(table); + lastFoundIndex = -1; + return; + } + + String key = filterText.toLowerCase(); + TableItem[] items = table.getItems(); + int rowCount = items.length; + int colCount = table.getColumnCount(); + + /* ӡһСʼѣԭ̤ */ + int start = (lastFoundIndex + 1) % rowCount; + boolean wrapped = false; // Ƿѻؾ 0 + + while (true) { + for (int col = 0; col < colCount; col++) { + String cell = items[start].getText(col).toLowerCase(); + if (cell.contains(key)) { + /* Уλ¼¼ */ + //clearAllHighlight(table); // ɵĸ + items[start].setBackground( + Display.getDefault().getSystemColor(SWT.COLOR_GREEN)); + table.select(start); + table.showSelection(); + Event evt = new Event(); + evt.widget = table; + table.notifyListeners(SWT.Selection, evt); + lastFoundIndex = start; + return; + } + } + + /* δУһ */ + start++; + if (start >= rowCount) { // ĩβؾ 0 + start = 0; + wrapped = true; + } + if (wrapped && start > lastFoundIndex) { + break; // ѾɨһȦûҵ + } + } + + /* ûҵ */ + clearAllHighlight(table); + lastFoundIndex = -1; + TCMsgUtil.infoMsgBox("δҵƥ"); + } + + /** еĸ */ + private void clearAllHighlight(Table table) { + for (TableItem item : table.getItems()) { + item.setBackground(null); // ָĬ + } + } + + /** + * ұе + * + * @param table + * @param filterText + */ + private void filterTable(Table table, String filterText) { + TableItem[] items = table.getItems(); + int cloumn = table.getColumnCount(); + for (int i = statidnex, l = items.length; i < l; i++) { + for (int j = 0; j < cloumn; j++) { + if (items[i].getText(j).indexOf(filterText) > -1) { + table.select(i); + table.showSelection(); + Event event1 = new Event(); + event1.widget = table; + table.notifyListeners(SWT.Selection, event1); + //items[i].setForeground(getParent().getShell().getDisplay().getSystemColor(SWT.COLOR_RED)); + items[i].setBackground(getParent().getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION)); + statidnex = i + 1; + return; + } else { + items[i].setForeground(getParent().getShell().getDisplay().getSystemColor(SWT.COLOR_BLACK)); + items[i].setBackground(getParent().getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE)); + } + if (i == items.length - 1) { + i = 0; + statidnex = 0; + } + } + } + statidnex = 0; + } + + public void openComp (TCComponent[] itemObj){ + //EPMJob + if(itemObj[0]!=null && + (itemObj[0] instanceof TCComponent || itemObj[0] instanceof TCComponentTask)){ + TCUtils.openComponent(itemObj[0]); + return; + } + + + } + + public String getCurrentUserId() { + return currentUserId; + } + + public void setCurrentUserId(String currentUserId) { + this.currentUserId = currentUserId; + } + + public TCComponentUser getCurrentUser() { + return currentUser; + } + + public void setCurrentUser(TCComponentUser currentUser) { + this.currentUser = currentUser; + } + + +} diff --git a/src/com/connor/rb/plm/openFastWorkflowLists/OpenFastWorkflowListsHandler.java b/src/com/connor/rb/plm/openFastWorkflowLists/OpenFastWorkflowListsHandler.java new file mode 100644 index 0000000..f0550b6 --- /dev/null +++ b/src/com/connor/rb/plm/openFastWorkflowLists/OpenFastWorkflowListsHandler.java @@ -0,0 +1,27 @@ +package com.connor.rb.plm.openFastWorkflowLists; + + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.swt.SWT; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.handlers.HandlerUtil; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; + +public class OpenFastWorkflowListsHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + AIFDesktop aifDesktop = AIFDesktop.getActiveDesktop(); + //AbstractAIFUIApplication app = aifDesktop.getCurrentApplication(); + //InterfaceAIFComponent target = app.getTargetComponent(); + IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); + OpenFastWorkflowListsDialog dialog = new OpenFastWorkflowListsDialog(window.getShell(), SWT.DIALOG_TRIM); + dialog.open(); + return null; + } +} diff --git a/src/com/connor/rb/plm/openFastWorkflowLists/common/BeanUtils.java b/src/com/connor/rb/plm/openFastWorkflowLists/common/BeanUtils.java new file mode 100644 index 0000000..b6abcee --- /dev/null +++ b/src/com/connor/rb/plm/openFastWorkflowLists/common/BeanUtils.java @@ -0,0 +1,81 @@ +package com.connor.rb.plm.openFastWorkflowLists.common; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +/** + * ȡListתΪJavaBean + * @author suny + * @date 2017-7-4 + *
+ *  desc:
+ * 
+ */ +public class BeanUtils { + + /** + * List>תΪJavaBean + * @param datas + * @param beanClass + * @return + * @throws CommonException + */ + public List ListMap2JavaBean(List> datas, Class beanClass) throws CommonException { + // ݼ + List list = null; + // ֶ + String fieldname = ""; + // 󷽷 + String methodname = ""; + // 󷽷Ҫֵ + Object methodsetvalue = ""; + try { + list = new ArrayList(); + // õֶ + Field fields[] = beanClass.getDeclaredFields(); + // + for (Map mapdata : datas) { + // һʵ + T t = beanClass.newInstance(); + // ֶΣӦúõֶβֵ + for (Field field : fields) { + if(null != field) { + // ȫתΪСд + String dbfieldname = field.getName().toLowerCase(); + // ȡֶ + fieldname = field.getName(); + // ƴset + + methodname = "set" + StringUtil.capitalize(fieldname); + // ȡdataĶӦֵ + methodsetvalue = mapdata.get(dbfieldname); + // ֵֶ + Method m = beanClass.getDeclaredMethod(methodname, field.getType()); + m.invoke(t, methodsetvalue); + } + } + // 뷵б + list.add(t); + } + } catch (InstantiationException e) { + throw new CommonException(e, "beanClassʵ쳣"); + } catch (IllegalAccessException e) { + throw new CommonException(e, "beanClassʵ쳣"); + } catch (SecurityException e) { + throw new CommonException(e, "ȡ[" + fieldname + "] getter setter 쳣"); + } catch (NoSuchMethodException e) { + throw new CommonException(e, "ȡ[" + fieldname + "] getter setter 쳣"); + } catch (IllegalArgumentException e) { + throw new CommonException(e, "[" + methodname + "] ֵ쳣"); + } catch (InvocationTargetException e) { + throw new CommonException(e, "[" + methodname + "] ֵ쳣"); + } + // + return list; + } + +} + diff --git a/src/com/connor/rb/plm/openFastWorkflowLists/common/CommonException.java b/src/com/connor/rb/plm/openFastWorkflowLists/common/CommonException.java new file mode 100644 index 0000000..4bee8f0 --- /dev/null +++ b/src/com/connor/rb/plm/openFastWorkflowLists/common/CommonException.java @@ -0,0 +1,48 @@ +package com.connor.rb.plm.openFastWorkflowLists.common; + +/** + * 쳣 + * עԭ쳣ûֻǶһerrormsgֶΣ濪Աṩ쳣ʾϢ + * @author suny + * @date 2017-7-4 + *
+ *  desc:
+ * 
+ */ +public class CommonException extends Exception { + + // ԭʼ쳣 + private Throwable target; + + // ṩ쳣ʾ + private String errormsg = ""; + + public Throwable getTargetException() { + return target; + } + + public Throwable getCause() { + return target; + } + + protected CommonException() { + super((Throwable) null); + } + + public CommonException(Throwable target, String s) { + super(s, null); + this.target = target; + this.errormsg = s; + } + + public CommonException(Throwable target) { + super((Throwable) null); + this.target = target; + } + + public String getErrormsg() { + return errormsg; + } + +} + diff --git a/src/com/connor/rb/plm/openFastWorkflowLists/common/ExcelUtil.java b/src/com/connor/rb/plm/openFastWorkflowLists/common/ExcelUtil.java new file mode 100644 index 0000000..780a292 --- /dev/null +++ b/src/com/connor/rb/plm/openFastWorkflowLists/common/ExcelUtil.java @@ -0,0 +1,448 @@ +package com.connor.rb.plm.openFastWorkflowLists.common; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import jxl.Workbook; +import jxl.format.Border; +import jxl.format.BorderLineStyle; +import jxl.format.Colour; +import jxl.format.UnderlineStyle; +import jxl.format.VerticalAlignment; +import jxl.write.Label; +import jxl.write.WritableCellFormat; +import jxl.write.WritableFont; +import jxl.write.WritableSheet; +import jxl.write.WritableWorkbook; +import jxl.write.WriteException; + +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.hssf.usermodel.HSSFPalette; +import org.apache.poi.hssf.usermodel.HSSFRichTextString; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.openxml4j.exceptions.InvalidFormatException; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.WorkbookFactory; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; + +import com.teamcenter.rac.aif.AIFDesktop; + + +/*** + * еĿؼ + * @author a4687 + * @time 2018-02-01 + */ +public class ExcelUtil { + + /** + * ڵSWTеTableؼ + * @throws WriteException + * @throws IOException + */ + public static void tableExport(Table[] tableArray, String savepath) throws Exception{ + if(tableArray == null || tableArray.length == 0){ + TCMsgUtil.warningMsgBox("ûݣ"); + } + + //һЩɫ + // ɫ + WritableFont varTitleWf = new WritableFont(WritableFont.ARIAL, 12, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.WHITE); + WritableCellFormat varTitleWcf = new WritableCellFormat(varTitleWf); // Ԫ + varTitleWcf.setAlignment(jxl.format.Alignment.CENTRE); // ö뷽ʽ + varTitleWcf.setBorder(Border.ALL, BorderLineStyle.THIN); + varTitleWcf.setBackground(Colour.ORANGE); + + // //ͷʽ2 + // WritableFont titleWf = new WritableFont(WritableFont.ARIAL, 12, + // WritableFont.BOLD, false); + // WritableCellFormat titleWcf = new WritableCellFormat(titleWf); // + // Ԫ + // titleWcf.setAlignment(jxl.format.Alignment.CENTRE); // ö뷽ʽ + // titleWcf.setBorder(Border.ALL, BorderLineStyle.THIN); + // titleWcf.setBackground(Colour.GRAY_25); + + // ɫ + WritableFont titleWf = new WritableFont(WritableFont.ARIAL, 12, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.WHITE); + WritableCellFormat titleWcf = new WritableCellFormat(titleWf); // Ԫ + titleWcf.setAlignment(jxl.format.Alignment.CENTRE); // ö뷽ʽ + titleWcf.setVerticalAlignment(VerticalAlignment.CENTRE); + titleWcf.setBorder(Border.ALL, BorderLineStyle.THIN); + titleWcf.setBackground(Colour.OCEAN_BLUE); + + // ɫ + WritableFont greenWf = new WritableFont(WritableFont.ARIAL, 12, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK); + WritableCellFormat greenWcf = new WritableCellFormat(greenWf); // Ԫ + greenWcf.setAlignment(jxl.format.Alignment.CENTRE); // ö뷽ʽ + greenWcf.setVerticalAlignment(VerticalAlignment.CENTRE); + greenWcf.setBorder(Border.ALL, BorderLineStyle.THIN); + greenWcf.setBackground(Colour.LIGHT_GREEN); + + // ɫ + WritableFont varInfoAWf = new WritableFont(WritableFont.ARIAL, 11, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK); + WritableCellFormat varInfoAWcf = new WritableCellFormat(varInfoAWf); // Ԫ + varInfoAWcf.setAlignment(jxl.format.Alignment.CENTRE); // ö뷽ʽ + varInfoAWcf.setBorder(Border.ALL, BorderLineStyle.THIN); + varInfoAWcf.setBackground(Colour.IVORY); + + // + WritableCellFormat varInfoBWcf = new WritableCellFormat(varInfoAWf); // Ԫ + varInfoBWcf.setAlignment(jxl.format.Alignment.CENTRE); // ö뷽ʽ + varInfoBWcf.setBorder(Border.ALL, BorderLineStyle.THIN); + varInfoBWcf.setBackground(Colour.VERY_LIGHT_YELLOW); + + jxl.write.WritableFont wfctrue = new jxl.write.WritableFont(WritableFont.ARIAL, 10, WritableFont.NO_BOLD, + false, jxl.format.UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK); + jxl.write.WritableFont wfcfalse = new jxl.write.WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD, + false, jxl.format.UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.RED); + WritableCellFormat dataWcftrue = new WritableCellFormat(wfctrue); + dataWcftrue.setAlignment(jxl.format.Alignment.CENTRE); + dataWcftrue.setBorder(Border.ALL, BorderLineStyle.THIN); + WritableCellFormat dataWcffalse = new WritableCellFormat(wfcfalse); + dataWcffalse.setAlignment(jxl.format.Alignment.CENTRE); + dataWcffalse.setBorder(Border.ALL, BorderLineStyle.THIN); + + // ɫ + WritableFont varInfoSWf = new WritableFont(WritableFont.ARIAL, 11, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.RED); + WritableCellFormat varInfoSWcf = new WritableCellFormat(varInfoSWf); // Ԫ + varInfoSWcf.setAlignment(jxl.format.Alignment.CENTRE); // ö뷽ʽ + varInfoSWcf.setBorder(Border.ALL, BorderLineStyle.THIN); + varInfoSWcf.setBackground(Colour.WHITE); + + int tableIndex = 0; + WritableWorkbook book = Workbook.createWorkbook(new File(savepath)); + try{ + for(Table table : tableArray){ + TableItem[] tableItems = table.getItems(); + TableColumn[] TableColumns = table.getColumns(); + if(TableColumns != null && TableColumns.length > 0){ + String[] tablehead = new String[TableColumns.length]; + for(int i = 0; i < TableColumns.length; i++){ + tablehead[i] = TableColumns[i].getText(); + } + WritableSheet sheet = book.createSheet("Sheet" + (tableIndex + 1), tableIndex); + + tableIndex++; + + //дͷ + for (int i = 0; i < tablehead.length; i++) { + sheet.setColumnView(i, 20); + sheet.addCell(new Label(i, 0, tablehead[i], titleWcf)); + } + + //д + jxl.format.CellFormat backGround = varTitleWcf; + for(int i = 0; i < tableItems.length; i++){ + if (i % 2 == 0) { + backGround = varInfoAWcf; + } else { + backGround = varInfoBWcf; + } + jxl.format.CellFormat tmpbackGround = backGround; + for(int j = 0; j < tablehead.length; j++){ + sheet.addCell(new Label(j, i + 1, tableItems[i].getText(j), backGround)); + } + } + } + } + book.write(); + }finally{ + book.close(); + } + } + /** + * ӱص,ʽĬϵһΪ⣬ӵڶпʼȡ + * @param combo + */ + public static List getExcelByLocal(){ + List dataList = new ArrayList(); + FileDialog dialog = new FileDialog(AIFDesktop.getActiveDesktop().getShell(), SWT.OPEN); + dialog.setFilterPath(""); + dialog.setText("ļѡ"); + dialog.setFileName(""); + dialog.setFilterExtensions(new String[] { "*.xlsx", "*.xls" }); + String filepath = dialog.open();// + if (filepath == null) { + return null; + } + dataList.clear(); + try { + File file = new File(filepath); + InputStream is = new FileInputStream(file); + org.apache.poi.ss.usermodel.Workbook workbook = WorkbookFactory.create(is); + Sheet sheet = workbook.getSheetAt(0); + int cells = sheet.getRow(0).getLastCellNum(); + for (int i = 1; i < sheet.getLastRowNum() + 1; i++) { + String[] rowData = new String[cells+1]; + rowData[0] = (i + 1) + ""; + for (int j = 0; j < cells; j++) { + Cell cell = sheet.getRow(i).getCell(j); + if(cell == null){ + rowData[j + 1] = ""; + continue; + } + if(cell.getCellType() == Cell.CELL_TYPE_NUMERIC){ + double cur=cell.getNumericCellValue(); + long longVal = Math.round(cur); + Object inputValue = null; + if(Double.parseDouble(longVal + ".0") == cur) { + inputValue = longVal; + } + else{ + inputValue = cur; + } + rowData[j + 1] = String.valueOf(inputValue); + }else{ + rowData[j + 1] = cell.toString(); + } + } + dataList.add(rowData); + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (InvalidFormatException e) { + e.printStackTrace(); + } + return dataList; + } + /** + * + * ȡExcel(ר) + * @param beginRowNum ӵڼпʼȡ + * @return + */ + + public static List getExcelByLocal(int beginRowNum){ + List dataList = new ArrayList(); + FileDialog dialog = new FileDialog(AIFDesktop.getActiveDesktop().getShell(), SWT.OPEN); + dialog.setFilterPath(""); + dialog.setText("ļѡ"); + dialog.setFileName(""); + dialog.setFilterExtensions(new String[] { "*.xlsx", "*.xls" }); + String filepath = dialog.open();// + if (filepath == null) { + return null; + } + dataList.clear(); + try { + File file = new File(filepath); + InputStream is = new FileInputStream(file); + org.apache.poi.ss.usermodel.Workbook workbook = WorkbookFactory.create(is); + Sheet sheet = workbook.getSheetAt(0); + + boolean flag = false; + for (int i = beginRowNum; i < sheet.getLastRowNum() + 1; i++) { + if(flag){ + break; + } + if(sheet.getRow(i) == null){ + flag = true; + break; + } + int cells = sheet.getRow(i).getLastCellNum(); + String[] rowData = new String[cells+1]; + rowData[0] = (i + 1) + ""; + for (int j = 0; j < cells; j++) { + if(sheet.getRow(i) == null){ + flag = true; + break; + } + Cell cell = sheet.getRow(i).getCell(j); + if(j == 0 &&(cell == null || StringUtils.isBlank(cell.toString()))){ + flag = true; + break; + } + if(cell == null){ + rowData[j + 1] = ""; + }else{ + if(cell.getCellType() == Cell.CELL_TYPE_NUMERIC){ + double cur=cell.getNumericCellValue(); + long longVal = Math.round(cur); + Object inputValue = null; + if(Double.parseDouble(longVal + ".0") == cur) { + inputValue = longVal; + } + else{ + inputValue = cur; + } + rowData[j + 1] = String.valueOf(inputValue); + }else{ + rowData[j + 1] = cell.toString(); + } + } + + } + if(!flag){ + dataList.add(rowData); + } + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (InvalidFormatException e) { + e.printStackTrace(); + } + return dataList; + } + + /** + * + * table + * @param file + * @param table + */ + public static void buildExcelLocally(File file, Table table) { + // µExcel + String[] headers = new String [table.getColumns().length]; + for (int i = 0; i < table.getColumns().length; i++) { + headers[i] = table.getColumns()[i].getText().trim(); + } + + HSSFWorkbook workbook = new HSSFWorkbook(); + // Excelнһ + HSSFSheet sheet = workbook.createSheet("sheet"); + sheet.setDefaultRowHeightInPoints(16); + sheet.setDefaultColumnWidth((short) 20); + // ====================Excel========================// + // ==ͷӴ + HSSFFont fontHead = workbook.createFont(); + fontHead.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); + fontHead.setFontHeightInPoints((short) 12); + fontHead.setColor(HSSFColor.GREY_80_PERCENT.index); + fontHead.setFontName("΢ź"); + + // ==ģ + HSSFFont font = workbook.createFont(); + font.setFontName("΢ź"); + font.setFontHeightInPoints((short) 11); + + // øʽ==ͷģ + HSSFCellStyle cellStyleHead = workbook.createCellStyle(); + cellStyleHead.setFont(fontHead); + cellStyleHead.setAlignment(HSSFCellStyle.ALIGN_CENTER); + cellStyleHead.setBorderLeft(HSSFCellStyle.BORDER_THIN); + cellStyleHead.setBorderBottom(HSSFCellStyle.BORDER_THIN); + cellStyleHead.setBorderRight(HSSFCellStyle.BORDER_THIN); + cellStyleHead.setBorderTop(HSSFCellStyle.BORDER_THIN); + HSSFPalette customPalette = workbook.getCustomPalette(); + customPalette.setColorAtIndex(HSSFColor.ORANGE.index, (byte) 153, (byte) 204, (byte) 0); + cellStyleHead.setFillForegroundColor(HSSFColor.ORANGE.index); + cellStyleHead.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); + + // øʽ==ģ + HSSFCellStyle cellStyle = workbook.createCellStyle(); + cellStyle.setFont(font); + cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); + cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); + cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); + cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); + cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); + customPalette.setColorAtIndex(HSSFColor.LIGHT_CORNFLOWER_BLUE.index, (byte) 221, (byte) 221, (byte) 221); + //cellStyle.setFillForegroundColor(HSSFColor.LIGHT_CORNFLOWER_BLUE.index); + //cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); + + // øʽ==ģ + HSSFCellStyle cellStyleRed = workbook.createCellStyle(); + cellStyleRed.setFont(font); + cellStyleRed.setAlignment(HSSFCellStyle.ALIGN_CENTER); + cellStyleRed.setBorderLeft(HSSFCellStyle.BORDER_THIN); + cellStyleRed.setBorderBottom(HSSFCellStyle.BORDER_THIN); + cellStyleRed.setBorderRight(HSSFCellStyle.BORDER_THIN); + cellStyleRed.setBorderTop(HSSFCellStyle.BORDER_THIN); + customPalette.setColorAtIndex(HSSFColor.WHITE.index, (byte) 238, (byte) 230, (byte) 133); + cellStyleRed.setFillForegroundColor(HSSFColor.WHITE.index); + cellStyleRed.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); + // =====================================================// + + int rowNum = 0;// б + int colNum = 0;// б + HSSFRow row = sheet.createRow(rowNum); + HSSFCell cell = null; + // 1 һУͷ + for (colNum = 0; colNum < headers.length; colNum++) { + cell = row.createCell((short) colNum); + cell.setCellType(HSSFCell.CELL_TYPE_STRING); + cell.setCellStyle(cellStyleHead); + cell.setCellValue(new HSSFRichTextString(headers[colNum])); + } + rowNum++; + for (; rowNum < table.getItems().length + 1; rowNum++) { + row = sheet.createRow(rowNum); + for (colNum = 0; colNum < table.getColumns().length; colNum++) { + cell = row.createCell((short) colNum); + cell.setCellStyle(cellStyle); + if (table.getItem(rowNum - 1).getText(colNum) == null || table.getItem(rowNum - 1).getText(colNum) == "") { + cell.setCellValue(new HSSFRichTextString("")); + } else { + cell.setCellValue(new HSSFRichTextString(table.getItem(rowNum - 1).getText(colNum).toString())); + } + } + } + + //ñӦ + ExcelUtil.setSizeColumn(sheet, headers.length); + + try { + FileOutputStream fOut = new FileOutputStream(file); + workbook.write(fOut); + fOut.flush(); + fOut.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * @Description:Ӧ(֧) + * @Author: + * @param sheet sheet + * @param columnLength + */ + public static void setSizeColumn(HSSFSheet sheet, int columnLength) { + for (int columnNum = 0; columnNum <= columnLength; columnNum++) { + int columnWidth = sheet.getColumnWidth(columnNum) / 256; + for (int rowNum = 0; rowNum < sheet.getLastRowNum(); rowNum++) { + HSSFRow currentRow; // ǰδʹù + if (sheet.getRow(rowNum) == null) { + currentRow = sheet.createRow(rowNum); + } else { + currentRow = sheet.getRow(rowNum); + } + if (currentRow.getCell(columnNum) != null) { + HSSFCell currentCell = currentRow.getCell(columnNum); + if (currentCell.getCellType() == HSSFCell.CELL_TYPE_STRING) { + int length = currentCell.getStringCellValue().getBytes().length; + if (columnWidth < length) { + columnWidth = length+5; + } + } + } + } + if((columnWidth * 256)>25500){ + sheet.setColumnWidth(columnNum, 25500); + }else{ + sheet.setColumnWidth(columnNum, columnWidth * 256); + } + + } + } +} diff --git a/src/com/connor/rb/plm/openFastWorkflowLists/common/MyMsg.java b/src/com/connor/rb/plm/openFastWorkflowLists/common/MyMsg.java new file mode 100644 index 0000000..8a0788e --- /dev/null +++ b/src/com/connor/rb/plm/openFastWorkflowLists/common/MyMsg.java @@ -0,0 +1,24 @@ +package com.connor.rb.plm.openFastWorkflowLists.common; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Shell; + +public class MyMsg { + + + public static void info(String msg){ +// MessageBox.post(msg,"ʾ",MessageBox.INFORMATION); + MessageDialog.openInformation(null, "ʾ", msg); + + } + public static void info(Shell shell ,String msg){ +// MessageBox.post(msg,"ʾ",MessageBox.INFORMATION); + MessageDialog.openInformation(shell, "ʾ", msg); + + } + + public static void error(String msg){ +// MessageBox.post(msg,"",MessageBox.ERROR); + MessageDialog.openError(null, "", msg); + } +} diff --git a/src/com/connor/rb/plm/openFastWorkflowLists/common/ProgressMonitorAction.java b/src/com/connor/rb/plm/openFastWorkflowLists/common/ProgressMonitorAction.java new file mode 100644 index 0000000..455d80d --- /dev/null +++ b/src/com/connor/rb/plm/openFastWorkflowLists/common/ProgressMonitorAction.java @@ -0,0 +1,33 @@ +package com.connor.rb.plm.openFastWorkflowLists.common; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.swt.widgets.Shell; + +import com.teamcenter.rac.aif.AIFDesktop; + + +public abstract class ProgressMonitorAction { + public void processMonitorRun(Shell shell){ + try{ + if(shell == null){ + shell = AIFDesktop.getActiveDesktop().getShell(); + } + final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell); + IRunnableWithProgress rwp = new IRunnableWithProgress() { + public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + pmExecute(monitor, pmd.getShell()); + } + }; + pmd.run(true, true, rwp);// Ƿˢҳ棬ȡťǷ + }catch(Exception e){ + e.printStackTrace(); + TCMsgUtil.errorMsgBox(e.getMessage()); + } + } + + public abstract void pmExecute(IProgressMonitor monitor, Shell shell); +} diff --git a/src/com/connor/rb/plm/openFastWorkflowLists/common/PropertiesUtil.java b/src/com/connor/rb/plm/openFastWorkflowLists/common/PropertiesUtil.java new file mode 100644 index 0000000..66b5ab8 --- /dev/null +++ b/src/com/connor/rb/plm/openFastWorkflowLists/common/PropertiesUtil.java @@ -0,0 +1,27 @@ +package com.connor.rb.plm.openFastWorkflowLists.common; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +public class PropertiesUtil +{ +/* public PropertiesUtil(String path){ + getProperties(path); + }*/ + public Properties getProperties(String path) + { + Properties prop = new Properties(); + InputStream in = super.getClass().getResourceAsStream(path); + try + { + prop.load(in); + in.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + return prop; + } +} diff --git a/src/com/connor/rb/plm/openFastWorkflowLists/common/RacSoaUtils.java b/src/com/connor/rb/plm/openFastWorkflowLists/common/RacSoaUtils.java new file mode 100644 index 0000000..69bcdde --- /dev/null +++ b/src/com/connor/rb/plm/openFastWorkflowLists/common/RacSoaUtils.java @@ -0,0 +1,24 @@ +package com.connor.rb.plm.openFastWorkflowLists.common; + +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCComponentUserType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class RacSoaUtils { + // UserIDѯû + public static TCComponentUser findUserByUserID(String userID, TCSession session) { + TCComponentUser myQueryedItem = null; + try { + TCComponentUserType itemType = (TCComponentUserType) session.getTypeComponent("User"); + myQueryedItem = itemType.find(userID); + if (myQueryedItem != null) + return myQueryedItem; + + } catch (TCException e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/com/connor/rb/plm/openFastWorkflowLists/common/ReadTxtFile.java b/src/com/connor/rb/plm/openFastWorkflowLists/common/ReadTxtFile.java new file mode 100644 index 0000000..10ecc90 --- /dev/null +++ b/src/com/connor/rb/plm/openFastWorkflowLists/common/ReadTxtFile.java @@ -0,0 +1,46 @@ +package com.connor.rb.plm.openFastWorkflowLists.common; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class ReadTxtFile { + public static List readText(File file) { + if (file == null) { + System.err.println("the file is null, skip read text content..."); + return Collections.emptyList(); + } + // System.out.println("txt:"+file.getAbsolutePath()); + ArrayList listData = new ArrayList(); + + try { + BufferedReader br = new BufferedReader(new FileReader(file));// 构??BufferedReader类来读取文件 + + // 读取数据 + String strLine; + while ((strLine = br.readLine()) != null) {// 使用readLine方法,一次读? + listData.add(strLine); + } + br.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return listData; + } + + public static String readAllContent(File file) { + List list = readText(file); + StringBuffer sb = new StringBuffer(); + for (String str : list) { + sb.append(str); + } + return sb.toString(); + } +} diff --git a/src/com/connor/rb/plm/openFastWorkflowLists/common/ScoreMessageDialog.java b/src/com/connor/rb/plm/openFastWorkflowLists/common/ScoreMessageDialog.java new file mode 100644 index 0000000..d0cf130 --- /dev/null +++ b/src/com/connor/rb/plm/openFastWorkflowLists/common/ScoreMessageDialog.java @@ -0,0 +1,76 @@ +package com.connor.rb.plm.openFastWorkflowLists.common; + + +import java.awt.Toolkit; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.layout.GridLayoutFactory; +import org.eclipse.jface.layout.LayoutConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +import com.teamcenter.rac.aif.AIFDesktop; + +public class ScoreMessageDialog extends MessageDialog { + + private StyledText text; + + public ScoreMessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage, int dialogImageType, String[] dialogButtonLabels, + int defaultIndex) { + super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex); + } + + @Override + protected Control createMessageArea(Composite composite) { + Image image = getImage(); + composite.getLayoutData(); + if (image != null) { + imageLabel = new Label(composite, 0); + image.setBackground(imageLabel.getBackground()); + imageLabel.setImage(image); + GridDataFactory.fillDefaults().align(16777216, 1).applyTo(imageLabel); + } + if (message != null) { + text = new StyledText(composite, SWT.READ_ONLY | SWT.V_SCROLL | SWT.MULTI | SWT.WRAP); + text.setBackground(composite.getBackground()); + text.setText(message); + // õĻĿȺ͸߶ + int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height; + int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width; + // õShellڵĿȺ͸߶ + int shellHeight = AIFDesktop.getActiveDesktop().getShell().getBounds().height; + int shellWidth = AIFDesktop.getActiveDesktop().getShell().getBounds().width; + // ڴСĻСôĻȴ + if (shellHeight > screenHeight) + shellHeight = screenHeight; + if (shellWidth > screenWidth) + shellWidth = screenWidth; + FontData[] fontdata = getShell().getFont().getFontData(); + GridDataFactory.fillDefaults().align(4, 1).grab(false, false).hint(-1, -1).applyTo(text); + if (Math.abs(text.getLineCount() * fontdata[0].data.lfHeight) + 95 >= shellHeight) { + GridDataFactory.fillDefaults().align(4, 1).grab(false, false).hint(-1, getShell().getBounds().height).applyTo(text); + } + } + return composite; + } + + @Override + protected Control createContents(Composite parent) { + initializeDialogUnits(parent); + Point defaultSpacing = LayoutConstants.getSpacing(); + GridLayoutFactory.fillDefaults().margins(LayoutConstants.getMargins()).spacing(defaultSpacing.x * 2, defaultSpacing.y).numColumns(2).applyTo(parent); + GridDataFactory.fillDefaults().grab(true, true).applyTo(parent); + createDialogAndButtonArea(parent); + return parent; + } +} diff --git a/src/com/connor/rb/plm/openFastWorkflowLists/common/StringUtil.java b/src/com/connor/rb/plm/openFastWorkflowLists/common/StringUtil.java new file mode 100644 index 0000000..66d471c --- /dev/null +++ b/src/com/connor/rb/plm/openFastWorkflowLists/common/StringUtil.java @@ -0,0 +1,373 @@ +package com.connor.rb.plm.openFastWorkflowLists.common; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.text.CollationKey; +import java.text.Collator; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.teamcenter.rac.aif.kernel.AbstractAIFSession; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.MessageBox; + +public class StringUtil { + + /** + * + * @ ַ滻Ϊº _ + * @param refId + * @return + * + * @ Jreden + * @ʱ 20201114 + */ + public static String transRefId(String refId) { + return refId.replaceAll("[/|\\|:|\\*|\\?|<|>|\\|\\\\|\"|\\|]", "_"); + } + + /** + * + * @ УַǷΪдĸֻ ̺ܼº - _ + * @param str + * @return + * + * @ Jreden + * @ʱ 2021114 + */ + public static boolean checkStrIsCapital(String str) { + boolean result = true; + String pattern = "^[A-Z0-9-_]+$"; + Pattern r = Pattern.compile(pattern); + Matcher m = r.matcher(str); + result = m.matches(); + return result; + } + + /** + * жڱʽ + * + * @param type + * @param itemId + * @return + */ + public static boolean getStrPattern(String pattern, String str) { + Pattern r = Pattern.compile(pattern); + Matcher m = r.matcher(str); + return m.matches(); + } + + /** + * ȡtxtı + * @param txtPath + * @return + */ + public static String readTxt(String txtPath){ + StringBuffer sb = new StringBuffer(); + try{ + BufferedReader in = new BufferedReader(new FileReader(txtPath)); + String line = null; + while((line = in.readLine()) != null){ + sb.append(line); + } + in.close(); + return sb.toString(); + }catch(Exception e){ + e.printStackTrace(); + return null; + } + } + + /** + * ַתַ,ӷΪ + * @param String[] source + * @return String + */ + public static String arrayToStr(String[] source){ + String arrayStr = ""; + for(int i = 0; i < source.length; i++){ + arrayStr += "'" + source[i] + "',"; + } + if(arrayStr.endsWith(",")){ + arrayStr = arrayStr.substring(0, arrayStr.length() - 1); + } + return arrayStr; + } + + /** + * + * @ Listַתַ + * @param list + * @return + * + * @ Jreden + * @ʱ 20201115 + */ + private String[] listToArray(List list) { + String[] array = new String[list.size()]; + for (int i = 0; i < list.size(); i++) { + array[i] = list.get(i); + } + return array; + } + + public static boolean isEmpty(String str){ + if(str==null){ + return true; + } + if(str.trim().equals("")){ + return true; + } + return false; + } + + /** + * + * @ ڱַתintԱ + * @return + * + * @ Jreden + * @ʱ 20201122 + */ + public static Collator sortByStrInt(){ + Collator myCollator = new Collator(){ + @Override + public int compare(String arg0, String arg1) { + return Integer.valueOf(arg0).compareTo(Integer.valueOf(arg1)); + } + + @Override + public CollationKey getCollationKey(String arg0) { + return null; + } + + @Override + public int hashCode() { + return 0; + } + }; + return myCollator; + } + + /** + * + * @ ڱַתfloatԱ + * @return + * + * @ Jreden + * @ʱ 20201122 + */ + public static Collator sortByStrfloat(){ + Collator myCollator = new Collator(){ + @Override + public int compare(String arg0, String arg1) { + return Float.valueOf(arg0).compareTo(Float.valueOf(arg1)); + } + + @Override + public CollationKey getCollationKey(String arg0) { + return null; + } + + @Override + public int hashCode() { + return 0; + } + }; + return myCollator; + } + + public static Collator sortByStr(){ + Collator myCollator = new Collator() { + + @Override + public int compare(String obj1, String obj2) { + Pattern p = Pattern.compile("[a-zA-z]"); + if (obj1 == null || obj2 == null) { + return -1; + } + if (p.matcher(obj1.toString()).find() || p.matcher(obj2.toString()).find()) { + return new String(obj1.toString()).compareTo(new String(obj2.toString())); + } else { + if (!p.matcher(obj1.toString()).find() && !p.matcher(obj2.toString()).find()) { + if (!obj1.toString().contains(".")) { + obj1 = obj1 + ".0"; + } + if (!obj2.toString().contains(".")) { + obj2 = obj2 + ".0"; + } + String[] temp1 = obj1.toString().split("\\."); + String[] temp2 = obj2.toString().split("\\."); + String[] str1; + String[] str2; + if (temp1.length > temp2.length) { + str2 = temp1; + str1 = temp2; + } else { + str1 = temp2; + str2 = temp1; + } + for (int i = 0; i < str2.length; i++) { + if (i <= (str1.length - 1)) { + if (Long.valueOf(str2[i]) > Long.valueOf(str1[i])) { + return 1; + } else if (Long.valueOf(str2[i]) < Long.valueOf(str1[i])) { + return -1; + } else { + continue; + } + } else { + return 1; + } + } + } + } + return 0; + } + + @Override + public CollationKey getCollationKey(String source) { + // TODO Auto-generated method stub + return null; + } + + @Override + public int hashCode() { + // TODO Auto-generated method stub + return 0; + } + }; + return myCollator; + } + + /** + * + * @ ַĩβ׷ + * @param arr + * @param str + * @return + * + * @ Jreden + * @ʱ 20201120 + */ + public static String[] insertStrArray(String[] arr, String... str) { + int size = arr.length; // ȡԭ鳤 + int newSize = size + str.length; // ԭ鳤ȼ׷ӵݵܳ + // ½ʱַ + String[] tmp = new String[newSize]; + // ȱԭַӵʱַ + for (int i = 0; i < size; i++) { + tmp[i] = arr[i]; + } + // ĩβҪ׷ӵ + for (int i = size; i < newSize; i++) { + tmp[i] = str[i - size]; + } + return tmp; // ƴɵַ + } + + + /* + * JavaǻUnicodeģˣһֵijΪ12 + * ʱҪֽڵλַijȡ磬123abcǡֽڳȼ10Unicode㳤8 + * Ϊ˻10ҪͷɨַAsciiþij + * DZ׼ַAsciiķΧ0255ǺֻȫַAscii255 + * ˣԱдµķֽΪλַȡ + */ + public static int getWordCount(String s) { + int length = 0; + for (int i = 0; i < s.length(); i++) { + int ascii = Character.codePointAt(s, i); + if (ascii >= 0 && ascii <= 255) length++; + else length += 2; + + } + return length; + + } + + /* + * ԭǽַеķDZ׼ַ˫ַֽ滻׼ַ**ҲԣͿֱlengthַֽڳ + */ + public static int getWordCountRegex(String s) { + + s = s.replaceAll("[^\\x00-\\xff]", "**"); + int length = s.length(); + return length; + } + + + + /** + * ַһĸд + * @param str + * @return + */ + public static String capitalize(String str) { + int strLen; + if (str == null || (strLen = str.length()) == 0) { + return str; + } + return new StringBuilder(strLen) + .append(Character.toTitleCase(str.charAt(0))) + .append(str.substring(1)) + .toString(); + } + + /** + * ʹStringBuilderƴַ + * @param objects + * @return + */ + public static String appendSbl(Object... objects) { + StringBuilder sbl = new StringBuilder(); + for (Object obj : objects) { + sbl.append(obj); + } + return sbl.toString(); + } + + /** + * ʹStringBufferƴַ + * @param objects + * @return + */ + public static String appendSbf(Object... objects) { + StringBuffer sbl = new StringBuffer(); + for (Object obj : objects) { + sbl.append(obj); + } + return sbl.toString(); + } + + /** + * ַȡ׺ + * @param str + * ȡ null + */ + public static String getSuffix(String str) { + if(null != str && str.lastIndexOf(".") > 0) { + str = str.substring(str.lastIndexOf("."), str.length()); + } else { + str = null; + } + return str; + } + + /** + * Ƿ + * @tags @return + * @exception + * @return boolean + */ + public static boolean isNumber(String str) { + float number = Float.valueOf(str); + return Math.ceil(number) == Math.floor(number); + } + +} diff --git a/src/com/connor/rb/plm/openFastWorkflowLists/common/StringUtils.java b/src/com/connor/rb/plm/openFastWorkflowLists/common/StringUtils.java new file mode 100644 index 0000000..188b57c --- /dev/null +++ b/src/com/connor/rb/plm/openFastWorkflowLists/common/StringUtils.java @@ -0,0 +1,100 @@ +package com.connor.rb.plm.openFastWorkflowLists.common; + + +import java.util.Collection; +import java.util.Iterator; + +public class StringUtils { + /** + * ַǷǺ + * + * @param a + * char + * @return boolean + */ + public static boolean isChinese(char a) { + int v = (int) a; + return (v >= 19968 && v <= 171941); + } + + public static boolean containsChinese(String s) { + if (null == s || "".equals(s.trim())) + return false; + for (int i = 0; i < s.length(); i++) { + if (isChinese(s.charAt(i))) + return true; + } + return false; + } + + public static boolean isEmpty(String str) { + return str == null || str.length() == 0; + } + + public static boolean isNotEmpty(String str) { + return !isEmpty(str); + } + + public static boolean isBlank(String str) { + int strLen; + if (str == null || (strLen = str.length()) == 0) + return true; + for (int i = 0; i < strLen; i++) + if (!Character.isWhitespace(str.charAt(i))) + return false; + + return true; + } + + public static boolean isNotBlank(String str) { + return !isBlank(str); + } + + public static String join(Iterator iterator, String separator) { + if (iterator == null) + return null; + if (!iterator.hasNext()) + return ""; + Object first = iterator.next(); + if (!iterator.hasNext()) + return first != null ? first.toString() : ""; + StringBuffer buf = new StringBuffer(256); + if (first != null) + buf.append(first); + do { + if (!iterator.hasNext()) + break; + if (separator != null) + buf.append(separator); + Object obj = iterator.next(); + if (obj != null) + buf.append(obj); + } while (true); + return buf.toString(); + } + + public static String join(Collection collection, String separator) { + if (collection == null) { + return null; + } else { + return join(collection.iterator(), separator); + } + } + + /** + * ȡַǰNλֽڣ֧Ľȡ + * @param index + * @return + */ + public static String subStringByte(String source, int index){ + String result = source; + if(result.getBytes().length > index){ + result = new String(result.getBytes(), 0, 32); + Character c = result.charAt(result.length() - 1); + if(c.hashCode() == 65533){ + result = new String(result.getBytes(), 0, 31); + } + } + return result; + } +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/openFastWorkflowLists/common/TCMsgUtil.java b/src/com/connor/rb/plm/openFastWorkflowLists/common/TCMsgUtil.java new file mode 100644 index 0000000..26f5dfa --- /dev/null +++ b/src/com/connor/rb/plm/openFastWorkflowLists/common/TCMsgUtil.java @@ -0,0 +1,85 @@ +package com.connor.rb.plm.openFastWorkflowLists.common; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Shell; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.util.MessageBox; + +public class TCMsgUtil { + + public static void infoMsgBox(String info){ + MessageBox.post(info, "ʾ", MessageBox.INFORMATION); + } + + public static void warningMsgBox(String info){ + MessageBox.post(info, "", MessageBox.WARNING); + } + + public static void errorMsgBox(String info){ + MessageBox.post(info, "", MessageBox.ERROR); + } + + public static boolean infoScoreMsgBox(String info, boolean isConfirm, String[] options){ + if(!isConfirm){ + options = new String[]{}; + } + ScoreMessageDialog msgdialog = new ScoreMessageDialog(AIFDesktop.getActiveDesktop().getShell(), "ʾ", null, info, MessageDialog.INFORMATION, options, 0); + return 0 == msgdialog.open() ? true : false; + } + + public static boolean warningScoreMsgBox(String info, boolean isConfirm, String[] options){ + if(!isConfirm){ + options = new String[]{}; + } + ScoreMessageDialog msgdialog = new ScoreMessageDialog(AIFDesktop.getActiveDesktop().getShell(), "", null, info, MessageDialog.WARNING, options, 0); + return 0 == msgdialog.open() ? true : false; + } + + public static boolean errorScoreMsgBox(String info, boolean isConfirm, String[] options){ + if(!isConfirm){ + options = new String[]{}; + } + ScoreMessageDialog msgdialog = new ScoreMessageDialog(AIFDesktop.getActiveDesktop().getShell(), "", null, info, MessageDialog.ERROR, options, 0); + return 0 == msgdialog.open() ? true : false; + } + + + + + public static void infoMsgBox(Shell shell, String info){ + MessageBox.post(shell, info, "ʾ", MessageBox.INFORMATION); + } + + public static void warningMsgBox(Shell shell, String info){ + MessageBox.post(shell, info, "", MessageBox.WARNING); + } + + public static void errorMsgBox(Shell shell, String info){ + MessageBox.post(shell, info, "", MessageBox.ERROR); + } + + public static boolean infoScoreMsgBox(Shell shell, String info, boolean isConfirm, String[] options){ + if(!isConfirm){ + options = new String[]{}; + } + ScoreMessageDialog msgdialog = new ScoreMessageDialog(shell, "ʾ", null, info, MessageDialog.INFORMATION, options, 0); + return 0 == msgdialog.open() ? true : false; + } + + public static boolean warningScoreMsgBox(Shell shell, String info, boolean isConfirm, String[] options){ + if(!isConfirm){ + options = new String[]{}; + } + ScoreMessageDialog msgdialog = new ScoreMessageDialog(shell, "", null, info, MessageDialog.WARNING, options, 0); + return 0 == msgdialog.open() ? true : false; + } + + public static boolean errorScoreMsgBox(Shell shell, String info, boolean isConfirm, String[] options){ + if(!isConfirm){ + options = new String[]{}; + } + ScoreMessageDialog msgdialog = new ScoreMessageDialog(shell, "", null, info, MessageDialog.ERROR, options, 0); + return 0 == msgdialog.open() ? true : false; + } +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/openFastWorkflowLists/common/TableUtils.java b/src/com/connor/rb/plm/openFastWorkflowLists/common/TableUtils.java new file mode 100644 index 0000000..65d3e30 --- /dev/null +++ b/src/com/connor/rb/plm/openFastWorkflowLists/common/TableUtils.java @@ -0,0 +1,600 @@ +package com.connor.rb.plm.openFastWorkflowLists.common; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.text.Collator; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CCombo; +import org.eclipse.swt.custom.TableEditor; +import org.eclipse.swt.events.FocusAdapter; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.TraverseEvent; +import org.eclipse.swt.events.TraverseListener; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.Text; + + +/** + * 񹤾 + * + * @author Jimmyliu + */ +public class TableUtils { + + /** + * Ϊм(SWT) + * + * @param table + * @param dataNames dataŵkey + */ + + public static String[] combItemsArray; + + public static void addSorters(Table table, String[] dataNames) { + TableColumn[] columns = table.getColumns(); + for (TableColumn column : columns) { + addSorter(table, column, dataNames); + } + } + + /** + * Ϊм(SWT) + * + * @param table + * @param dataNames dataŵkey + */ + public static void addSorters(Table table, String[] dataNames, Collator tmpComparator) { + TableColumn[] columns = table.getColumns(); + for (TableColumn column : columns) { + addSorter(table, column, dataNames, tmpComparator); + } + } + + /** + * Ϊм(SWT) + * + * @param table + * @deprecated + * @see #addSorters(Table, String[]) + */ + @Deprecated + public static void addSorters(Table table) { + TableColumn[] columns = table.getColumns(); + for (TableColumn column : columns) { + addSorter(table, column); + } + } + + /** + * Ϊijм(SWT) + * + * @param table + * @param column + */ + public static void addSorter(final Table table, final TableColumn column, final String[] dataNames) { + column.addListener(SWT.Selection, new Listener() { + boolean isAscend = true; + Collator comparator = Collator.getInstance(Locale.getDefault()); + + public void handleEvent(Event e) { + int columnIndex = getColumnIndex(table, column); + TableItem[] items = table.getItems(); + + for (int i = 1; i < items.length; i++) { + String value2 = items[i].getText(columnIndex); + for (int j = 0; j < i; j++) { + String value1 = items[j].getText(columnIndex); + boolean isLessThan = comparator.compare(value2, value1) < 0; + if ((isAscend && isLessThan) || (!isAscend && !isLessThan)) { + String[] values = getTableItemText(table, items[i]); + Object obj = items[i].getData(); + TableItem item = new TableItem(table, SWT.NONE, j); + item.setText(values); + item.setData(obj); + if (dataNames != null && dataNames.length > 0) { + for (String dataName : dataNames) { + item.setData(dataName, items[i].getData(dataName)); + } + } + item.setBackground(items[i].getBackground()); + item.setForeground(items[i].getForeground()); + items[i].dispose(); + items = table.getItems(); + break; + } + } + } + + table.setSortColumn(column); + table.setSortDirection((isAscend ? SWT.UP : SWT.DOWN)); + isAscend = !isAscend; + } + }); + } + + /** + * Ϊijм(SWT) + * + * @param table + * @param column + * @param comparator + */ + public static void addSorter(final Table table, final TableColumn column, + final String[] dataNames, Collator tmpComparator) { + if (tmpComparator == null) { + tmpComparator = Collator.getInstance(Locale.getDefault()); + } + final Collator comparator = tmpComparator; + column.addListener(SWT.Selection, new Listener() { + boolean isAscend = true; + + public void handleEvent(Event e) { + int columnIndex = getColumnIndex(table, column); + TableItem[] items = table.getItems(); + + for (int i = 1; i < items.length; i++) { + String value2 = items[i].getText(columnIndex); + for (int j = 0; j < i; j++) { + String value1 = items[j].getText(columnIndex); + boolean isLessThan = comparator.compare(value2, value1) < 0; + if ((isAscend && isLessThan) || (!isAscend && !isLessThan)) { + String[] values = getTableItemText(table, items[i]); + Object obj = items[i].getData(); + TableItem item = new TableItem(table, SWT.NONE, j); + item.setText(values); + item.setData(obj); + if (dataNames != null && dataNames.length > 0) { + for (String dataName : dataNames) { + item.setData(dataName, items[i].getData(dataName)); + } + } + item.setBackground(items[i].getBackground()); + item.setForeground(items[i].getForeground()); + items[i].dispose(); + items = table.getItems(); + break; + } + } + } + + table.setSortColumn(column); + table.setSortDirection((isAscend ? SWT.UP : SWT.DOWN)); + isAscend = !isAscend; + } + }); + } + + /** + * Ϊijм(SWT) + * + * @param table + * @param column + * @deprecated + * @see #addSorter(Table, TableColumn, String[]) + */ + @Deprecated + public static void addSorter(final Table table, final TableColumn column) { + column.addListener(SWT.Selection, new Listener() { + boolean isAscend = true; + Collator comparator = Collator.getInstance(Locale.getDefault()); + + public void handleEvent(Event e) { + int columnIndex = getColumnIndex(table, column); + TableItem[] items = table.getItems(); + + for (int i = 1; i < items.length; i++) { + String value2 = items[i].getText(columnIndex); + for (int j = 0; j < i; j++) { + String value1 = items[j].getText(columnIndex); + boolean isLessThan = comparator.compare(value2, value1) < 0; + if ((isAscend && isLessThan) || (!isAscend && !isLessThan)) { + String[] values = getTableItemText(table, items[i]); + Object obj = items[i].getData(); + TableItem item = new TableItem(table, SWT.NONE, j); + item.setText(values); + item.setData(obj); + item.setBackground(items[i].getBackground()); + item.setForeground(items[i].getForeground()); + items[i].dispose(); + items = table.getItems(); + break; + } + } + } + + table.setSortColumn(column); + table.setSortDirection((isAscend ? SWT.UP : SWT.DOWN)); + isAscend = !isAscend; + } + }); + } + + /** + * ȡijеIndex(SWT) + * + * @param table + * @param column + * @return + */ + public static int getColumnIndex(Table table, TableColumn column) { + TableColumn[] columns = table.getColumns(); + for (int i = 0; i < columns.length; i++) { + if (columns[i].equals(column)) + return i; + } + return -1; + } + + /** + * ȡijݵֵַ飩(SWT) + * + * @param table + * @param item + * @return + */ + public static String[] getTableItemText(Table table, TableItem item) { + int count = table.getColumnCount(); + String[] strs = new String[count]; + for (int i = 0; i < count; i++) { + strs[i] = item.getText(i); + } + return strs; + } + + /** + * ѱijб + * + * @param table + * @param combItems ѡ + * @param column ҪУ0ʼ + * @param isEdit Ƿɱ༭ + */ + public static CCombo changeTableToEditComb(Table table, String[] combItems, final int column, + boolean isEdit) { + if (table.getSelectionCount() == 0) { + return null; + } + final TableItem item = table.getItem(table.getSelectionIndex()); + if (item == null) { + return null; + } + + final TableEditor editor = new TableEditor(table); + Control oldEditor = editor.getEditor(); + if (oldEditor != null) { + oldEditor.dispose(); + } + + int type = SWT.NONE; + if (!isEdit) { + type = SWT.READ_ONLY; + } + final CCombo comOptionValue = new CCombo(table, type); + comOptionValue.computeSize(SWT.DEFAULT, table.getItemHeight()); + editor.grabHorizontal = true; + editor.minimumHeight = comOptionValue.getSize().y; + editor.minimumWidth = comOptionValue.getSize().x; + editor.setEditor(comOptionValue, item, column); + + if (combItems != null && combItems.length > 0) { + comOptionValue.setItems(combItems); + } + + comOptionValue.setText(item.getText(column)); + comOptionValue.forceFocus(); + + setFastSearch(comOptionValue); + + // ༭رʽ + comOptionValue.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent focusevent) { + Control defaultEditor = editor.getEditor(); + editor.setEditor(defaultEditor, item, 1); + item.setText(column, comOptionValue.getText()); + comOptionValue.dispose(); + } + }); + return comOptionValue; + } + + /** + * ѱijб + * + * @param table + * @param combItems ѡ + * @param column ҪУ0ʼ + * @param isEdit Ƿɱ༭ + */ + public static CCombo changeTableToEditComb(Table table, String[] combItems, final int column, + boolean isEdit, final LostFocusHandle handle) { + combItemsArray = combItems; + if (table.getSelectionCount() == 0) { + return null; + } + final TableItem item = table.getItem(table.getSelectionIndex()); + if (item == null) { + return null; + } + + final TableEditor editor = new TableEditor(table); + Control oldEditor = editor.getEditor(); + if (oldEditor != null) { + oldEditor.dispose(); + } + + int type = SWT.NONE; + if (!isEdit) { + type = SWT.READ_ONLY; + } + final CCombo comOptionValue = new CCombo(table, type); + comOptionValue.computeSize(SWT.DEFAULT, table.getItemHeight()); + editor.grabHorizontal = true; + editor.minimumHeight = comOptionValue.getSize().y; + editor.minimumWidth = comOptionValue.getSize().x; + editor.setEditor(comOptionValue, item, column); + + if (combItems != null && combItems.length > 0) { + comOptionValue.setItems(combItems); + } + + comOptionValue.setText(item.getText(column)); + comOptionValue.forceFocus(); + + setFastSearch(comOptionValue); + + // ༭رʽ + comOptionValue.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent focusevent) { + Control defaultEditor = editor.getEditor(); + editor.setEditor(defaultEditor, item, 1); + item.setText(column, comOptionValue.getText()); + handle.handle(item, comOptionValue); + comOptionValue.dispose(); + } + }); + comOptionValue.addListener(SWT.KeyUp, new Listener() { + @Override + public void handleEvent(Event event) { + // TODO Auto-generated method stub + if (event.keyCode == 13) { + String txt = comOptionValue.getText().trim(); + comOptionValue.removeAll(); + if (txt.trim().equals("")) { + comOptionValue.setListVisible(false); + return; + } + Map nameCode = new HashMap(); + for (String str : combItemsArray) { + if (str.contains(txt)) { + comOptionValue.add(str); + nameCode.put(str, str); + } + } + comOptionValue.setData(nameCode); + comOptionValue.setListVisible(true); + comOptionValue.setText(txt); + comOptionValue.setSelection(new Point(txt.length(), txt.length())); + } + } + }); + return comOptionValue; + } + + + + /** + * TABLE ˫ɱ༭ (SWT) + * + * @param table + * @param column Ҫɿɱ༭У0ʼ + */ + public static Text changeTableToEditText(Table table, final int column) { + if (table.getSelectionCount() == 0) { + return null; + } + final TableItem item = table.getItem(table.getSelectionIndex()); + if (item == null) { + return null; + } + + final TableEditor editor = new TableEditor(table); + Control oldEditor = editor.getEditor(); + if (oldEditor != null) { + oldEditor.dispose(); + } + + final Text changeItemText = new Text(table, SWT.NONE); + changeItemText.computeSize(SWT.DEFAULT, table.getItemHeight()); + editor.grabHorizontal = true; + editor.minimumHeight = changeItemText.getSize().y; + editor.minimumWidth = changeItemText.getSize().x; + editor.setEditor(changeItemText, item, column); + + changeItemText.setText(item.getText(column)); + changeItemText.forceFocus(); + // 궨λ + changeItemText.setSelection(999); + + // ༭رʽ + changeItemText.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent focusevent) { + Control defaultEditor = editor.getEditor(); + editor.setEditor(defaultEditor, item, 1); + item.setText(column, changeItemText.getText()); + changeItemText.dispose(); + } + }); + + // سָ + changeItemText.addTraverseListener(new TraverseListener() { + public void keyTraversed(TraverseEvent e) { + System.out.println(e.keyCode); + if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) { + e.detail = SWT.TRAVERSE_TAB_NEXT; + e.doit = true; + } + } + }); + return changeItemText; + } + + /** + * TABLE ˫ɱ༭ (SWT) + * + * @param table + * @param column Ҫɿɱ༭У0ʼ + */ + public static Text changeTableToEditText(Table table, final int column, + final LostFocusHandle handle) { + if (table.getSelectionCount() == 0) { + return null; + } + final TableItem item = table.getItem(table.getSelectionIndex()); + if (item == null) { + return null; + } + + final TableEditor editor = new TableEditor(table); + Control oldEditor = editor.getEditor(); + if (oldEditor != null) { + oldEditor.dispose(); + } + + final Text changeItemText = new Text(table, SWT.NONE); + changeItemText.computeSize(SWT.DEFAULT, table.getItemHeight()); + editor.grabHorizontal = true; + editor.minimumHeight = changeItemText.getSize().y; + editor.minimumWidth = changeItemText.getSize().x; + editor.setEditor(changeItemText, item, column); + + changeItemText.setText(item.getText(column)); + changeItemText.forceFocus(); + + // ༭رʽ + changeItemText.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent focusevent) { + Control defaultEditor = editor.getEditor(); + editor.setEditor(defaultEditor, item, 1); + item.setText(column, changeItemText.getText()); + handle.handle(item, changeItemText); + changeItemText.dispose(); + } + }); + + // سָ + changeItemText.addTraverseListener(new TraverseListener() { + public void keyTraversed(TraverseEvent e) { + if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) { + e.detail = SWT.TRAVERSE_TAB_NEXT; + e.doit = true; + } + } + }); + return changeItemText; + } + + /** + * ͨmouseeventötableÿִеĶ + * + * @param mouseevent ¼ + * @param table Ҫöı + * @param handleMap key:УŴ0ʼvalue:ӦҪִеĶColumnActionHandle + * + * ʹӣ final Map handleMap = new HashMap(); ColumnActionHandle handle = new ColumnActionHandle(){ + * @Override public void handle(Table table, TableItem item, int colIndex) { + * TableUtils.changeTableToEditText(table, colIndex); } }; handleMap.put(2, handle); + * + * table.addMouseListener(new MouseAdapter() { + * @Override public void mouseUp(MouseEvent e) { TableUtils.setTableColumnHandle(table, e, + * handleMap); } }); + */ + public static void setTableColumnHandle(Table table, MouseEvent mouseevent, + Map handleMap) { + int tmpCol = 0; + if (table.getSelectionCount() != 0) { + final TableItem item = table.getItem(table.getSelectionIndex()); + Point point = new Point(mouseevent.x, mouseevent.y); + for (int i = 0; i < table.getColumnCount(); i++) { + Rectangle rect = item.getBounds(i); + if (rect.contains(point)) { + tmpCol = i; + break; + } + } + if (handleMap == null) { + return; + } + if (handleMap.containsKey(tmpCol)) { + handleMap.get(tmpCol).handle(table, item, tmpCol); + } + } + } + + public static abstract class LostFocusHandle { + abstract public void handle(TableItem item, Control control); + } + + public static abstract class ColumnActionHandle { + abstract public void handle(Table table, TableItem item, int colIndex); + } + + /** + * ÿٲ + * + * @param combo + */ + private static void setFastSearch(final CCombo combo) { + combo.addMouseListener(new MouseAdapter() { + @Override + public void mouseUp(MouseEvent arg0) { + String txt = combo.getText(); + if (StringUtils.isNotBlank(txt)) { + // ȫƥ䣬Ĭϻȡȫƥ + for (String values : combo.getItems()) { + if (values.equalsIgnoreCase(txt)) { + int index = combo.indexOf(values); + combo.setText(combo.getItem(index)); + combo.select(index); + return; + } + } + + // ȫƥٻȡһƥ + for (String values : combo.getItems()) { + if (values.toUpperCase().startsWith(txt.toUpperCase())) { + int index = combo.indexOf(values); + combo.setText(combo.getItem(index)); + combo.select(index); + return; + } + } + } + } + }); + } + + public static void main(String[] args) { + System.out.println(System.getProperty("java.io.tmpdir")); + } + +} diff --git a/src/com/connor/rb/plm/openFastWorkflowLists/common/TeamCenter.png b/src/com/connor/rb/plm/openFastWorkflowLists/common/TeamCenter.png new file mode 100644 index 0000000..65bd911 Binary files /dev/null and b/src/com/connor/rb/plm/openFastWorkflowLists/common/TeamCenter.png differ diff --git a/src/com/connor/rb/plm/openFastWorkflowLists/common/TimeConvertUtil.java b/src/com/connor/rb/plm/openFastWorkflowLists/common/TimeConvertUtil.java new file mode 100644 index 0000000..33ff260 --- /dev/null +++ b/src/com/connor/rb/plm/openFastWorkflowLists/common/TimeConvertUtil.java @@ -0,0 +1,30 @@ +package com.connor.rb.plm.openFastWorkflowLists.common; + +import java.time.*; +import java.util.Date; + +public final class TimeConvertUtil { + private static final ZoneId ZONE_CN = ZoneId.of("Asia/Shanghai"); + + /** Date/Timestamp -> ʱ䣨java.util.Date */ + public static Date utcToCn(Date date) { + if (date == null) return null; + + Instant instant; + if (date instanceof java.sql.Timestamp) { + instant = ((java.sql.Timestamp) date).toInstant(); // Ƽ + } else if (date instanceof java.sql.Date) { + // java.sql.Date ֻ --գֱӲת Instant + instant = ((java.sql.Date) date).toLocalDate() + .atStartOfDay(ZONE_CN) + .toInstant(); + } else { + // ͨ java.util.Date + instant = date.toInstant(); + } + + // תʱ + ZonedDateTime cn = instant.atZone(ZONE_CN); + return Date.from(cn.toInstant()); + } +} diff --git a/src/com/connor/rb/plm/query/AssembleQueryBean.java b/src/com/connor/rb/plm/query/AssembleQueryBean.java new file mode 100644 index 0000000..a778fe9 --- /dev/null +++ b/src/com/connor/rb/plm/query/AssembleQueryBean.java @@ -0,0 +1,385 @@ +/** * @Title: ZCObject.java + * @Package com.connor.rb.plm.query + * @Description: TODO(һ仰ļʲô) + * @author admin * @date 2024914 + * @version V1.0 + */ +package com.connor.rb.plm.query; + +/** + * @ClassName: ZCObject + * @Description: TODO(һ仰) + * @author admin + * @date 2024914 + * + */ +public class AssembleQueryBean { + + + private String id; + private String productNumber; + private String designDrawingNumber; + private String identificationNumber; + private String description2; + private String oldDrawingCustomerDrawingNumber; + private String oldMaterialNumber; + private String commodityCode; + + private String assemblyType; + private String productionFactory; + + private String designer; + private String createdBy; + private String usedPart; + private String customerFor; + private String vehicleModel; + private String outerDiameterGte; + private String outerDiameterLte; + private String innerDiameterGte; + private String innerDiameterLte; + private String widthGte; + private String widthLte; + private String radialClearance; + private String axialClearance; + private String pitchCircleDiameterGte; + private String pitchCircleDiameterLte; + private String rollerSizeGte; + private String rollerSizeLte; + private String weightGte; + private String weightLte; + + private String creationTimeAfter; + private String creationTimeBefore; + + private String baseMaterialNumber; + + private String developmentKind; + private String lifeCycleStatus; + private String ownershipUser; + private String ownershipGroup; + private String releaseStatus; + + // Getter and Setter methods for all properties + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getProductNumber() { + return productNumber; + } + + public void setProductNumber(String productNumber) { + this.productNumber = productNumber; + } + + + public String getDesignDrawingNumber() { + return designDrawingNumber; + } + + public void setDesignDrawingNumber(String designDrawingNumber) { + this.designDrawingNumber = designDrawingNumber; + } + + public String getIdentificationNumber() { + return identificationNumber; + } + + public void setIdentificationNumber(String identificationNumber) { + this.identificationNumber = identificationNumber; + } + + public String getDescription2() { + return description2; + } + + public void setDescription2(String description2) { + this.description2 = description2; + } + + public String getOldDrawingCustomerDrawingNumber() { + return oldDrawingCustomerDrawingNumber; + } + + public void setOldDrawingCustomerDrawingNumber(String oldDrawingCustomerDrawingNumber) { + this.oldDrawingCustomerDrawingNumber = oldDrawingCustomerDrawingNumber; + } + + public String getOldMaterialNumber() { + return oldMaterialNumber; + } + + public void setOldMaterialNumber(String oldMaterialNumber) { + this.oldMaterialNumber = oldMaterialNumber; + } + + public String getCommodityCode() { + return commodityCode; + } + + public void setCommodityCode(String commodityCode) { + this.commodityCode = commodityCode; + } + + public String getAssemblyType() { + return assemblyType; + } + + public void setAssemblyType(String assemblyType) { + this.assemblyType = assemblyType; + } + + public String getProductionFactory() { + return productionFactory; + } + + public void setProductionFactory(String productionFactory) { + this.productionFactory = productionFactory; + } + + public String getDesigner() { + return designer; + } + + public void setDesigner(String designer) { + this.designer = designer; + } + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public String getUsedPart() { + return usedPart; + } + + public void setUsedPart(String usedPart) { + this.usedPart = usedPart; + } + + public String getCustomerFor() { + return customerFor; + } + + public void setCustomerFor(String customerFor) { + this.customerFor = customerFor; + } + + public String getVehicleModel() { + return vehicleModel; + } + + public void setVehicleModel(String vehicleModel) { + this.vehicleModel = vehicleModel; + } + + + + + + public String getRadialClearance() { + return radialClearance; + } + + public void setRadialClearance(String radialClearance) { + this.radialClearance = radialClearance; + } + + public String getAxialClearance() { + return axialClearance; + } + + public void setAxialClearance(String axialClearance) { + this.axialClearance = axialClearance; + } + + + + public String getOuterDiameterGte() { + return outerDiameterGte; + } + + public void setOuterDiameterGte(String outerDiameterGte) { + this.outerDiameterGte = outerDiameterGte; + } + + public String getOuterDiameterLte() { + return outerDiameterLte; + } + + public void setOuterDiameterLte(String outerDiameterLte) { + this.outerDiameterLte = outerDiameterLte; + } + + public String getInnerDiameterGte() { + return innerDiameterGte; + } + + public void setInnerDiameterGte(String innerDiameterGte) { + this.innerDiameterGte = innerDiameterGte; + } + + public String getInnerDiameterLte() { + return innerDiameterLte; + } + + public void setInnerDiameterLte(String innerDiameterLte) { + this.innerDiameterLte = innerDiameterLte; + } + + public String getWidthGte() { + return widthGte; + } + + public void setWidthGte(String widthGte) { + this.widthGte = widthGte; + } + + public String getWidthLte() { + return widthLte; + } + + public void setWidthLte(String widthLte) { + this.widthLte = widthLte; + } + + public String getPitchCircleDiameterGte() { + return pitchCircleDiameterGte; + } + + public void setPitchCircleDiameterGte(String pitchCircleDiameterGte) { + this.pitchCircleDiameterGte = pitchCircleDiameterGte; + } + + public String getPitchCircleDiameterLte() { + return pitchCircleDiameterLte; + } + + public void setPitchCircleDiameterLte(String pitchCircleDiameterLte) { + this.pitchCircleDiameterLte = pitchCircleDiameterLte; + } + + public String getRollerSizeGte() { + return rollerSizeGte; + } + + public void setRollerSizeGte(String rollerSizeGte) { + this.rollerSizeGte = rollerSizeGte; + } + + public String getRollerSizeLte() { + return rollerSizeLte; + } + + public void setRollerSizeLte(String rollerSizeLte) { + this.rollerSizeLte = rollerSizeLte; + } + + public String getWeightGte() { + return weightGte; + } + + public void setWeightGte(String weightGte) { + this.weightGte = weightGte; + } + + public String getWeightLte() { + return weightLte; + } + + public void setWeightLte(String weightLte) { + this.weightLte = weightLte; + } + + public String getCreationTimeAfter() { + return creationTimeAfter; + } + + public void setCreationTimeAfter(String creationTimeAfter) { + this.creationTimeAfter = creationTimeAfter; + } + + public String getCreationTimeBefore() { + return creationTimeBefore; + } + + public void setCreationTimeBefore(String creationTimeBefore) { + this.creationTimeBefore = creationTimeBefore; + } + + public String getBaseMaterialNumber() { + return baseMaterialNumber; + } + + public void setBaseMaterialNumber(String baseMaterialNumber) { + this.baseMaterialNumber = baseMaterialNumber; + } + + public String getDevelopmentKind() { + return developmentKind; + } + + public void setDevelopmentKind(String developmentKind) { + this.developmentKind = developmentKind; + } + + public String getLifeCycleStatus() { + return lifeCycleStatus; + } + + public void setLifeCycleStatus(String lifeCycleStatus) { + this.lifeCycleStatus = lifeCycleStatus; + } + + public String getOwnershipUser() { + return ownershipUser; + } + + public void setOwnershipUser(String ownershipUser) { + this.ownershipUser = ownershipUser; + } + + public String getOwnershipGroup() { + return ownershipGroup; + } + + public void setOwnershipGroup(String ownershipGroup) { + this.ownershipGroup = ownershipGroup; + } + + public String getReleaseStatus() { + return releaseStatus; + } + + public void setReleaseStatus(String releaseStatus) { + this.releaseStatus = releaseStatus; + } + + @Override + public String toString() { + return "AssembleQueryBean [id=" + id + ", productNumber=" + productNumber + ", designDrawingNumber=" + + designDrawingNumber + ", identificationNumber=" + identificationNumber + ", description2=" + + description2 + ", oldDrawingCustomerDrawingNumber=" + oldDrawingCustomerDrawingNumber + + ", oldMaterialNumber=" + oldMaterialNumber + ", commodityCode=" + commodityCode + ", assemblyType=" + + assemblyType + ", productionFactory=" + productionFactory + ", designer=" + designer + ", createdBy=" + + createdBy + ", usedPart=" + usedPart + ", customerFor=" + customerFor + ", vehicleModel=" + + vehicleModel + ", outerDiameterGte=" + outerDiameterGte + ", outerDiameterLte=" + outerDiameterLte + + ", innerDiameterGte=" + innerDiameterGte + ", innerDiameterLte=" + innerDiameterLte + ", widthGte=" + + widthGte + ", widthLte=" + widthLte + ", radialClearance=" + radialClearance + ", axialClearance=" + + axialClearance + ", pitchCircleDiameterGte=" + pitchCircleDiameterGte + ", pitchCircleDiameterLte=" + + pitchCircleDiameterLte + ", rollerSizeGte=" + rollerSizeGte + ", rollerSizeLte=" + rollerSizeLte + + ", weightGte=" + weightGte + ", weightLte=" + weightLte + ", creationTimeAfter=" + creationTimeAfter + + ", creationTimeBefore=" + creationTimeBefore + ", baseMaterialNumber=" + baseMaterialNumber + + ", developmentKind=" + developmentKind + ", lifeCycleStatus=" + lifeCycleStatus + ", ownershipUser=" + + ownershipUser + ", ownershipGroup=" + ownershipGroup + ", releaseStatus=" + releaseStatus + "]"; + } +} diff --git a/src/com/connor/rb/plm/query/Result.java b/src/com/connor/rb/plm/query/Result.java new file mode 100644 index 0000000..a85a662 --- /dev/null +++ b/src/com/connor/rb/plm/query/Result.java @@ -0,0 +1,48 @@ +/** * @Title: Result.java + * @Package com.connor.rb.plm.query + * @Description: TODO(һ仰ļʲô) + * @author admin * @date 2024918 + * @version V1.0 + */ +package com.connor.rb.plm.query; + +import org.omg.CORBA.PRIVATE_MEMBER; + +/** + * @ClassName: Result + * @Description: TODO(һ仰) + * @author admin + * @date 2024918 + * + */ +public class Result { + private String id; + private String name; + + + public Result() { + super(); + } + public Result(String id, String name) { + super(); + this.id = id; + this.name = name; + } + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + @Override + public String toString() { + return "Result [id=" + id + ", name=" + name + "]"; + } + +} diff --git a/src/com/connor/rb/plm/query/ScrollablePanelWindow.java b/src/com/connor/rb/plm/query/ScrollablePanelWindow.java new file mode 100644 index 0000000..0102161 --- /dev/null +++ b/src/com/connor/rb/plm/query/ScrollablePanelWindow.java @@ -0,0 +1,179 @@ +/** * @Title: test.java + * @Package com.connor.rb.plm.query + * @Description: TODO(һ仰ļʲô) + * @author admin * @date 2024914 + * @version V1.0 + */ +package com.connor.rb.plm.query; + +/** + * @ClassName: test + * @Description: TODO(һ仰) + * @author admin + * @date 2024914 + * + */ +import javax.swing.*; +import javax.swing.*; +import javax.swing.table.DefaultTableModel; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.table.DefaultTableModel; + +import com.aspose.cad.internal.aa.i; +import com.connor.rb.plm.rb012.DateChooser; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.Arrays; + +public class ScrollablePanelWindow { + public void showResults(List results) { + List ids = new ArrayList<>(); + List names = new ArrayList<>(); + for (int i = 0; i < results.size(); i++) { + ids.add(results.get(i).getId()); + names.add(results.get(i).getName()); + } + + JFrame newFrame = new JFrame("ѯ"); + newFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); + newFrame.setSize(300, 400); + + DefaultTableModel model = new DefaultTableModel(); + model.addColumn("ID"); + model.addColumn(""); + + // ʹ Set Ѿӹ + Set addedRows = new HashSet<>(); + + for (int i = 0; i < ids.size(); i++) { + String id = ids.get(i); + String name = names.get(i); + String rowKey = id + ":" + name; // һΨһļʶÿ + + if (!addedRows.contains(rowKey)) { + model.addRow(new Object[]{id, name}); + addedRows.add(rowKey); // еıʶӵ set + } + } + + JTable table = new JTable(model); + table.setDefaultEditor(Object.class, null); // ñ񲻿ɱ༭ + table.getColumnModel().getColumn(0).setPreferredWidth(100); // п + + // ˫ + table.addMouseListener(new MouseListener() { + @Override + public void mouseReleased(MouseEvent e) { + } + + @Override + public void mousePressed(MouseEvent e) { + } + + @Override + public void mouseExited(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + } + + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2) { // Ƿ˫ +// int selectedRow = table.getSelectedRow(); +// if (selectedRow >= 0) { +// String id = table.getValueAt(selectedRow, 0).toString(); +// if (!isEmpty(id)) { +// System.out.println("Double-clicked ID: " + table.getValueAt(selectedRow, 0)); +// com.teamcenter.rac.common.Activator.getDefault() +// .openPerspective("com.teamcenter.rac.ui.perspectives.navigatorPerspective"); +// com.teamcenter.rac.common.Activator.getDefault().openComponents( +// "com.teamcenter.rac.ui.perspectives.navigatorPerspective", +// new InterfaceAIFComponent[]{getItemById(id)}); +// } +// } + } + } + }); + + JScrollPane scrollPane = new JScrollPane(table); + + // Ӱť + JButton getSelectedIdsButton = new JButton("ȡѡID"); + getSelectedIdsButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int[] selectedRows = table.getSelectedRows(); + List selectedIds = new ArrayList<>(); + for (int row : selectedRows) { + String id = table.getValueAt(row, 0).toString(); + selectedIds.add(id); + } + System.out.println("ѡеID: " + selectedIds); + } + }); + + // ò + JPanel buttonPanel = new JPanel(); + buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); + buttonPanel.add(getSelectedIdsButton); + + newFrame.getContentPane().add(scrollPane, BorderLayout.CENTER); + newFrame.getContentPane().add(buttonPanel, BorderLayout.SOUTH); + + // ôھ + newFrame.setLocationRelativeTo(null); + newFrame.setAlwaysOnTop(true); + // ÿɼ + newFrame.setVisible(true); + } + + private boolean isEmpty(String str) { + return str == null || str.trim().isEmpty(); + } + + + // ʾ Result + public static class Result { + private String id; + private String name; + + public Result(String id, String name) { + this.id = id; + this.name = name; + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + } + + public static void main(String[] args) { + List results = new ArrayList<>(); + results.add(new Result("1", "Item 1")); + results.add(new Result("2", "Item 2")); + results.add(new Result("3", "Item 3")); + + ScrollablePanelWindow dialog = new ScrollablePanelWindow(); + dialog.showResults(results); + } +} diff --git a/src/com/connor/rb/plm/query/ZCQueryDialog.java b/src/com/connor/rb/plm/query/ZCQueryDialog.java new file mode 100644 index 0000000..dfb4fea --- /dev/null +++ b/src/com/connor/rb/plm/query/ZCQueryDialog.java @@ -0,0 +1,1347 @@ +/** * @Title: ZCQueryDialog.java + * @Package com.connor.rb.plm.query + * @Description: TODO(һ仰ļʲô) + * @author admin * @date 2024913 + * @version V1.0 + */ +package com.connor.rb.plm.query; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Frame; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.Label; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.WindowEvent; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.table.DefaultTableModel; + +import com.aspose.cad.internal.ay.iF; +import com.connor.rb.plm.rb012.DateChooser; +import com.connor.rb.plm.rb026.Rb026Dialog; +import com.itextpdf.text.pdf.PdfStructTreeController.returnType; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.soa.exceptions.NotLoadedException; +import com.teamcenter.soaictstubs.stringSeq_tHolder; + +/** + * @ClassName: ZCQueryDialog + * @Description: TODO(һ仰) + * @author hcj + * @date 2024913 + * + */ +public class ZCQueryDialog extends AbstractAIFOperation { + + private static TCSession session; + private static LinkedHashMap attrHashMap = new LinkedHashMap(); + public static Connection connection = null; + public static List lovDisPlayList1 = new ArrayList(); + public static List lovDisPlayList2 = new ArrayList(); + public static Map rB3_ZCLXMap; + public static Map RB3_SCGC1Map; + public static Map RB3_KFFL_LOVMap; + public static Map RB3_SMZQZTMap; + public static Map OwningUsernamesMap; + public static Map OwningGroupnamesMap; + public static Map releaseStatusMap = new HashMap(); + + /** + * һµʵ ZCQueryDialog + * + * @param session + */ + public ZCQueryDialog(TCSession session) { + // TODO Auto-generated constructor stub + this.session = session; + WaitingDialog dia = new WaitingDialog(AIFUtility.getCurrentApplication().getDesktop(), + "INFOMATION", "ʼ......"); + try { + dia.setVisible(true); + getLovMap(session); + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (NotLoadedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + dia.setVisible(false); + } + } + + /** + * @Title: getLovMap + * @Description: TODO(һ仰) + * @param @param session2 + * @return void + * @throws TCException + * @throws SQLException + * @throws NotLoadedException + * @throws + */ + private void getLovMap(TCSession session) throws TCException, SQLException, NotLoadedException { + // TODO Auto-generated method stub + // ȡlov + rB3_ZCLXMap = getUnitValue_display(session, "RB3_ZCLX"); + RB3_SCGC1Map = getUnitValue_display(session, "RB3_SCGC1"); + lovDisPlayList1.add(getKeys(rB3_ZCLXMap)); + lovDisPlayList1.add(getKeys(RB3_SCGC1Map)); + + RB3_KFFL_LOVMap = getUnitValue_display(session, "RB3_KFFL_LOV"); + RB3_SMZQZTMap = getUnitValue_display(session, "RB3_SMZQZT"); + OwningUsernamesMap = getUnitValue_display(session, "Owning User names"); + OwningGroupnamesMap = getUnitValue_display(session, "Owning Group names"); + lovDisPlayList2.add(getKeys(RB3_KFFL_LOVMap)); + lovDisPlayList2.add(getKeys(RB3_SMZQZTMap)); + lovDisPlayList2.add(getKeys(OwningUsernamesMap)); + lovDisPlayList2.add(getKeys(OwningGroupnamesMap)); + + System.out.println("rB3_ZCLXMap:" + rB3_ZCLXMap); + System.out.println("RB3_SCGC1Map:" + RB3_SCGC1Map); + + System.out.println("RB3_KFFL_LOVMap:" + RB3_KFFL_LOVMap); + System.out.println("RB3_SMZQZTMap:" + RB3_SMZQZTMap); + System.out.println("OwningUsernamesMap:" + OwningUsernamesMap); + System.out.println("OwningGroupnamesMap:" + OwningGroupnamesMap); + + // ͨݿȡ״̬ + if (connection == null) { + getConnectionTC12(); + } + // sql + String sql = "select PVAL_0 from PL10N_TASKTYPE_NAME where PVAL_0 like 'zh%'"; + // ִ SQL ѯ + PreparedStatement prepareStatement = connection.prepareStatement(sql); + // չʾ + java.sql.ResultSet executeQuery = prepareStatement.executeQuery(); + + + List results = new ArrayList<>(); + while (executeQuery.next()) { + String result = executeQuery.getString("PVAL_0"); + String[] split = result.split(":"); + results.add(split[split.length - 1]); + } + lovDisPlayList2.add(results.toArray(new String[0])); + + String sql2 = "select PVAL_0 from PL10N_TASKTYPE_NAME where PVAL_0 like 'en%'"; + PreparedStatement prepareStatement1 = connection.prepareStatement(sql); + // չʾ + java.sql.ResultSet executeQuery1 = prepareStatement1.executeQuery(); + + List results1 = new ArrayList<>(); + while (executeQuery1.next()) { + String result = executeQuery1.getString("PVAL_0"); + String[] split = result.split(":"); + results1.add(split[split.length - 1]); + } + for (int i = 0; i < results.size(); i++) { + releaseStatusMap.put(results.get(i), results1.get(i)); + } + } + + private String[] getKeys(Map map) { + // Map key 洢һ List + List keyList = new ArrayList<>(); + for (String key : map.keySet()) { + keyList.add(key); + } + + // List תΪ + String[] keyArray = keyList.toArray(new String[0]); + + // ӡ + for (String key : keyArray) { + System.out.println(key); + } + return keyArray; + } + + /* + * Title: executeOperation Description: + * + * @throws Exception + * + * @see com.teamcenter.rac.aif.AbstractAIFOperation#executeOperation() + */ + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + // ʼJFrame + JFrame frame = new JFrame("ܳɼ-11"); + + frame.setSize(420, 600); + + // ݵJFrame + JScrollPane centerPanel = createCenterPanel(); + JPanel bottomPanel = createBottomPanel(frame); + + frame.getContentPane().add(centerPanel, BorderLayout.CENTER); + frame.getContentPane().add(bottomPanel, BorderLayout.SOUTH); + // ôھ + frame.setLocationRelativeTo(null); + frame.setDefaultCloseOperation(2); + // ÿɼ + frame.setVisible(true); + } + + private static JScrollPane createCenterPanel() throws SQLException { + // йܵJPanel + JScrollPane scrollPane = null; + try { + scrollPane = new JScrollPane(createFormPanel()); + } catch (SQLException | TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return scrollPane; + } + + public static Map getUnitValue_display(TCSession seesion, String lovProp) throws TCException, NotLoadedException { + Map value_displays = new HashMap(); + TCComponentListOfValues unitLov = getLov(seesion, lovProp); + if (unitLov != null) { + ListOfValuesInfo listOfValues = unitLov.getListOfValues(); + if("Owning User names".equals(lovProp)) { + TCComponent[] tagListOfValues = listOfValues.getTagListOfValues(); + for(TCComponent component : tagListOfValues) { + String propertyDisplayableValue = component.getPropertyDisplayableValue("user_name"); + String stringProperty = component.getStringProperty("user_name"); + value_displays.put(stringProperty,propertyDisplayableValue); + } + }else if("Owning Group names".equals(lovProp)) { + TCComponent[] tagListOfValues = listOfValues.getTagListOfValues(); + for(TCComponent component : tagListOfValues) { + String propertyDisplayableValue = component.getPropertyDisplayableValue("name"); + String stringProperty = component.getStringProperty("name"); + value_displays.put(stringProperty,propertyDisplayableValue); + } + }else { + String[] realval = listOfValues.getStringListOfValues(); + String value = ""; + boolean flag = false; + for (int i = 0; i < realval.length; i++) { + String disval = listOfValues.getDisplayableValue(realval[i]); + value_displays.put(disval,realval[i]); + } + } + + + + + + } + return value_displays; + } + private static String[] prependEmptyString(String[] items) { + String[] newItems = new String[items.length + 1]; + newItems[0] = ""; // ĵһλӿַ + System.arraycopy(items, 0, newItems, 1, items.length); // ԭݵ + return newItems; + } + + public static TCComponentListOfValues getLov(TCSession session, String lovName) { + TCComponentListOfValuesType lovType; + try { + lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lov = lovType.find(lovName); + if (lov.length > 0) + return lov[0]; + } catch (TCException e) { + e.printStackTrace(); + } + return null; + } + + private static JPanel createFormPanel() throws SQLException, TCException { + if (attrHashMap.size() > 0) { + attrHashMap.clear(); + } + // һJPanelɱԪ + JPanel formPanel = new JPanel(new GridBagLayout()); + + GridBagConstraints c = new GridBagConstraints(); + c.insets = new Insets(5, 5, 5, 5); // ߾ + + // ֶμӦıǩ + JLabel[] labels = { new JLabel("ID:"), new JLabel("Ʒ:"), new JLabel("ͼ:"), new JLabel("ʶ:"), + new JLabel("˵2:"), new JLabel("ͼ/ͻͼ:"), new JLabel("Ϻ:"), new JLabel("Ʒ:") }; // ͼƬеֶӦJLabel + JTextField[] textFields = new JTextField[labels.length]; + + JLabel[] labels1 = { new JLabel("ܳ:"), new JLabel(":") }; // ͼƬеֶӦJLabel + JComboBox[] coxFields1 = new JComboBox[labels1.length]; + + JLabel[] labels2 = { new JLabel(":"), new JLabel("û:"), new JLabel("ʹòλ:"), new JLabel("׿ͻ:"), + new JLabel("׳:"), new JLabel("⾶(mm)>=:"), new JLabel("⾶(mm)<=:"), new JLabel("ھ(mm)>=:"), + new JLabel("ھ(mm)<=:"), new JLabel("(mm)>=:"), new JLabel("(mm)<=:"), new JLabel("϶:"), + new JLabel("϶:"), new JLabel("Բֱ(mm)>=:"), new JLabel("Բֱ(mm)<=:"), new JLabel("С(mm)>="), + new JLabel("С(mm)<="), new JLabel("(mm)>="), new JLabel("(mm)<=") }; // ͼƬеֶӦJLabel + JTextField[] textFields2 = new JTextField[labels2.length]; + + JLabel[] labels3 = { new JLabel("ʱ:"), new JLabel("ʱ:") }; // ͼƬеֶӦJLabel + JTextField[] dateFields1 = new JTextField[labels3.length]; + + JLabel[] labels4 = { new JLabel("ƷϺ:") }; // ͼƬеֶӦJLabel + JTextField[] textFields4 = new JTextField[labels4.length]; + + JLabel[] labels5 = { new JLabel(":"), new JLabel("״̬:"), new JLabel("Ȩû:"), new JLabel("Ȩ:"), + new JLabel("״̬:") }; // ͼƬеֶӦJLabel + JComboBox[] coxFields5 = new JComboBox[labels5.length]; + + // ÿJLabelJTextFieldӵformPanel + for (int i = 0; i < labels.length; i++) { + c.gridx = 0; + c.weightx = 0; + c.anchor = GridBagConstraints.LINE_START; + labels[i].setFont(new Font("΢ź", Font.BOLD, 15)); + formPanel.add(labels[i], c); + + c.gridx = 1; + c.weightx = 1; + c.fill = GridBagConstraints.HORIZONTAL; + JTextField jTextField = new JTextField(10); + jTextField.setFont(new Font("΢ź", Font.BOLD, 15)); + formPanel.add(textFields[i] = jTextField, c); + attrHashMap.put(labels[i].getText(), jTextField); + } + // ÿJLabelJTextFieldӵformPanel + for (int i = 0; i < labels1.length; i++) { + c.gridx = 0; + c.weightx = 0; + c.anchor = GridBagConstraints.LINE_START; + labels1[i].setFont(new Font("΢ź", Font.BOLD, 15)); + formPanel.add(labels1[i], c); + + c.gridx = 1; + c.weightx = 1; + c.fill = GridBagConstraints.HORIZONTAL; + + JComboBox jComboBox = new JComboBox(prependEmptyString(lovDisPlayList1.get(i))); + jComboBox.setFont(new Font("΢ź", Font.BOLD, 15)); + jComboBox.setSelectedIndex(-1); + formPanel.add(jComboBox = new JComboBox(), c); + attrHashMap.put(labels1[i].getText(), jComboBox); + } + // ÿJLabelJTextFieldӵformPanel + for (int i = 0; i < labels2.length; i++) { + c.gridx = 0; + c.weightx = 0; + c.anchor = GridBagConstraints.LINE_START; + labels2[i].setFont(new Font("΢ź", Font.BOLD, 15)); + formPanel.add(labels2[i], c); + + c.gridx = 1; + c.weightx = 1; + c.fill = GridBagConstraints.HORIZONTAL; + JTextField jTextField = new JTextField(10); + jTextField.setFont(new Font("΢ź", Font.BOLD, 15)); + formPanel.add(textFields2[i] = jTextField, c); + + attrHashMap.put(labels2[i].getText(), jTextField); + } + + // ÿJLabelJTextFieldӵformPanel + for (int i = 0; i < labels3.length; i++) { + c.gridx = 0; + c.weightx = 0; + c.anchor = GridBagConstraints.LINE_START; + labels3[i].setFont(new Font("΢ź", Font.BOLD, 15)); + formPanel.add(labels3[i], c); + + c.gridx = 1; + c.weightx = 1; + c.fill = GridBagConstraints.HORIZONTAL; + JTextField jTextField = new JTextField(); + jTextField.setFont(new Font("΢ź", Font.BOLD, 15)); + DateChooser dateChooser1 = DateChooser.getInstance("yyyy-MM-dd"); + dateChooser1.register(jTextField); + formPanel.add(dateFields1[i] = jTextField, c); + attrHashMap.put(labels3[i].getText(), jTextField); + + } + + // ÿJLabelJTextFieldӵformPanel + for (int i = 0; i < labels4.length; i++) { + c.gridx = 0; + c.weightx = 0; + c.anchor = GridBagConstraints.LINE_START; + labels4[i].setFont(new Font("΢ź", Font.BOLD, 15)); + formPanel.add(labels4[i], c); + + c.gridx = 1; + c.weightx = 1; + c.fill = GridBagConstraints.HORIZONTAL; + JTextField jTextField = new JTextField(10); + jTextField.setFont(new Font("΢ź", Font.BOLD, 15)); + formPanel.add(textFields4[i] = jTextField, c); + attrHashMap.put(labels4[i].getText(), jTextField); + } + + // ÿJLabelJTextFieldӵformPanel + for (int i = 0; i < labels5.length; i++) { + c.gridx = 0; + c.weightx = 0; + c.anchor = GridBagConstraints.LINE_START; + labels5[i].setFont(new Font("΢ź", Font.BOLD, 15)); + formPanel.add(labels5[i], c); + + c.gridx = 1; + c.weightx = 1; + c.fill = GridBagConstraints.HORIZONTAL; + JComboBox jComboBox = new JComboBox(prependEmptyString(lovDisPlayList2.get(i))); + jComboBox.setFont(new Font("΢ź", Font.BOLD, 15)); + jComboBox.setSelectedIndex(-1); + formPanel.add(coxFields5[i] = jComboBox, c); + attrHashMap.put(labels5[i].getText(), jComboBox); + } + + return formPanel; + } + + private static JPanel createBottomPanel(JFrame frame) { + // ťJPanel + JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER)); + JButton button1 = new JButton("ѯ"); + JButton button2 = new JButton("ȡ"); + // Ӱť + button1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + WaitingDialog dia = new WaitingDialog(AIFUtility.getCurrentApplication().getDesktop(), + "INFOMATION", "ѯУԺ......"); + try { + dia.setVisible(true); + List queryZCData = queryZCData(attrHashMap); + if(queryZCData == null || queryZCData.size() == 0) { + MessageBox.post("δѯ", "ʾ", MessageBox.INFORMATION); + return; + } + //رյǰ + frame.dispose(); + showNewWindow(queryZCData); + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + }finally { + dia.setVisible(false); + } + + } + }); + button2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + frame.dispose(); + + } + }); + panel.add(button1); + panel.add(button2); + return panel; + } + + public static String[] getLovByName(TCSession session, String lovName) { + try { + TCComponentListOfValues lov = TCComponentListOfValuesType.findLOVByName(session, lovName); + if (lov != null) { + ListOfValuesInfo lovInfo = lov.getListOfValues(); + String[] arr = lovInfo.getLOVDisplayValues(); + // lovInfo.getListOfFilters()[0].getChildren(); + return arr; + } + } catch (TCException e) { + e.printStackTrace(); + } + return null; + } + + /** + * @Title: queryZCData + * @Description: ѯ + * @param @param attrHashMap2 + * @return void + * @throws SQLException + * @throws + */ + protected static List queryZCData(LinkedHashMap attrHashMap2) throws SQLException { + AssembleQueryBean assembleQueryBean = new AssembleQueryBean(); + // ȡ + AssembleQueryBean getdata = getdata(attrHashMap2, assembleQueryBean); + System.out.println("getdata:" + getdata.toString()); + // ȡݿ + if (connection == null) { + getConnectionTC12(); + } + // sql +// String sql = "select * from (select p1.PUID,p1.PITEM_ID,p1.POBJECT_NAME,p1.PCREATION_DATE,p1.PNAME,\r\n" +// + "p1.PUSER_NAME,p1.RELEASRNAME,z.PRB3_CPH,z.PRB3_TH,z.PRB3_BSH,z.PRB3_SM2,z.PRB3_LTH,\r\n" +// + "z.PRB3_JWLH,z.PRB3_SPM,z.PRB3_ZCLX,z.PRB3_SCGC,z.PRB3_SJR,z.PRB3_CJYH,z.PRB3_SYBW,\r\n" +// + "z.PRB3_PTKH,z.PRB3_PTCX,z.PRB3_WXCC_WJ,z.PRB3_WXCC_NJ,z.PRB3_WXCC_KD,z.PRB3_JXYX,\r\n" +// + "z.PRB3_ZXYX,z.PRB3_JYZJ,z.PRB3_GDTDX,z.PRB3_ZL,z.PRB3_JPLH,z.PRB3_KFFL,z.PRB3_SMZQZT\r\n" +// + "from (select r.PUID,i.PITEM_ID,w.POBJECT_NAME,o.PCREATION_DATE,g.PNAME,u.PUSER_NAME,\r\n" +// + "o.PNAME as RELEASRNAME from PITEM i,PITEMREVISION r,PWORKSPACEOBJECT w,(select n.*,\r\n" +// + "z.PNAME from PPOM_APPLICATION_OBJECT n,PRELEASE_STATUS_LIST m,PRELEASESTATUS z \r\n" +// + "where n.PUID = m.PUID and z.PUID = m.PVALU_0)o,PPOM_GROUP g,PPOM_USER u where \r\n" +// + "i.PUID = r.RITEMS_TAGU and r.PUID = w.PUID and r.PUID = o.PUID and g.PUID = o.ROWNING_GROUPU\r\n" +// + "and u.PUID = o.ROWNING_USERU) p1 , PRB3_ZCREVISION z where p1.PUID = z.PUID)"; + // SQL ѯģ + String sql = "SELECT * FROM (\n" + + " SELECT p1.PUID, p1.PITEM_ID, p1.POBJECT_NAME, p1.PCREATION_DATE, p1.PNAME,\n" + + " p1.PUSER_NAME, p1.RELEASRNAME, z.PRB3_CPH, z.PRB3_TH, z.PRB3_BSH, z.PRB3_SM2, z.PRB3_LTH,\n" + + " z.PRB3_JWLH, z.PRB3_SPM, z.PRB3_ZCLX, z.PRB3_SCGC, z.PRB3_SJR, z.PRB3_CJYH, z.PRB3_SYBW,\n" + + " z.PRB3_PTKH, z.PRB3_PTCX, z.PRB3_WXCC_WJ, z.PRB3_WXCC_NJ, z.PRB3_WXCC_KD, z.PRB3_JXYX,\n" + + " z.PRB3_ZXYX, z.PRB3_JYZJ, z.PRB3_GDTDX, z.PRB3_ZL, z.PRB3_JPLH, z.PRB3_KFFL, z.PRB3_SMZQZT,\n" + + " CASE\n" + + " WHEN REGEXP_LIKE(PRB3_WXCC_WJ, '^[0-9]+(\\.[0-9]+)?$') THEN TO_NUMBER(PRB3_WXCC_WJ)\n" + + " ELSE NULL\n" + + " END AS PRB3_WXCC_WJ_NUM,\n" + + " CASE\n" + + " WHEN REGEXP_LIKE(PRB3_WXCC_NJ, '^[0-9]+(\\.[0-9]+)?$') THEN TO_NUMBER(PRB3_WXCC_NJ)\n" + + " ELSE NULL\n" + + " END AS PRB3_WXCC_NJ_NUM,\n" + + " CASE\n" + + " WHEN REGEXP_LIKE(PRB3_WXCC_KD, '^[0-9]+(\\.[0-9]+)?$') THEN TO_NUMBER(PRB3_WXCC_KD)\n" + + " ELSE NULL\n" + + " END AS PRB3_WXCC_KD_NUM,\n" + + " CASE\n" + + " WHEN REGEXP_LIKE(PRB3_JYZJ, '^[0-9]+(\\.[0-9]+)?$') THEN TO_NUMBER(PRB3_JYZJ)\n" + + " ELSE NULL\n" + + " END AS PRB3_JYZJ_NUM,\n" + + " CASE\n" + + " WHEN REGEXP_LIKE(PRB3_GDTDX, '^[0-9]+(\\.[0-9]+)?$') THEN TO_NUMBER(PRB3_GDTDX)\n" + + " ELSE NULL\n" + + " END AS PRB3_GDTDX_NUM,\n" + + " CASE\n" + + " WHEN REGEXP_LIKE(PRB3_ZL, '^[0-9]+(\\.[0-9]+)?$') THEN TO_NUMBER(PRB3_ZL)\n" + + " ELSE NULL\n" + + " END AS PRB3_ZL_NUM\n" + + " FROM (\n" + + " SELECT r.PUID, i.PITEM_ID, w.POBJECT_NAME, o.PCREATION_DATE, g.PNAME, u.PUSER_NAME,\n" + + " o.PNAME AS RELEASRNAME\n" + + " FROM PITEM i, PITEMREVISION r, PWORKSPACEOBJECT w, (\n" + + " SELECT n.*, z.PNAME\n" + + " FROM PPOM_APPLICATION_OBJECT n, PRELEASE_STATUS_LIST m, PRELEASESTATUS z\n" + + " WHERE n.PUID = m.PUID AND z.PUID = m.PVALU_0\n" + + " ) o, PPOM_GROUP g, PPOM_USER u\n" + + " WHERE i.PUID = r.RITEMS_TAGU AND r.PUID = w.PUID AND r.PUID = o.PUID AND g.PUID = o.ROWNING_GROUPU\n" + + " AND u.PUID = o.ROWNING_USERU\n" + + " ) p1, PRB3_ZCREVISION z\n" + + " WHERE p1.PUID = z.PUID\n" + + ") WHERE 1=1"; + // ƴsql + // ڶ̬ WHERE Ӿ + StringBuilder whereClause = new StringBuilder(""); + boolean firstCondition = true; + + // item_id + addCondition(whereClause, firstCondition, "PITEM_ID", assembleQueryBean.getId()); + + // Ʒ + addCondition(whereClause, firstCondition, "PRB3_CPH", assembleQueryBean.getProductNumber()); + + // ͼ + addCondition(whereClause, firstCondition, "PRB3_TH", assembleQueryBean.getDesignDrawingNumber()); + + // ʶ + addCondition(whereClause, firstCondition, "PRB3_BSH", assembleQueryBean.getIdentificationNumber()); + + // ˵2 + addCondition(whereClause, firstCondition, "PRB3_SM2", assembleQueryBean.getDescription2()); + + // ͼ/ͻͼ + addCondition(whereClause, firstCondition, "PRB3_LTH", assembleQueryBean.getOldDrawingCustomerDrawingNumber()); + + // Ϻ + addCondition(whereClause, firstCondition, "PRB3_JWLH", assembleQueryBean.getOldMaterialNumber()); + + // Ʒ + addCondition(whereClause, firstCondition, "PRB3_SPM", assembleQueryBean.getCommodityCode()); + + // ܳ + if(!isEmpty(assembleQueryBean.getAssemblyType())) { + addCondition(whereClause, firstCondition, "PRB3_ZCLX",rB3_ZCLXMap.get(assembleQueryBean.getAssemblyType())); + } + + + // ɹ + if(isEmpty(assembleQueryBean.getProductionFactory())) { + addCondition(whereClause, firstCondition, "PRB3_SCGC",RB3_SCGC1Map.get(assembleQueryBean.getProductionFactory())); + } + + // + addCondition(whereClause, firstCondition, "PRB3_SJR", assembleQueryBean.getDesigner()); + + // û + addCondition(whereClause, firstCondition, "PRB3_CJYH", assembleQueryBean.getCreatedBy()); + + // ʹòλ + addCondition(whereClause, firstCondition, "PRB3_SYBW", assembleQueryBean.getUsedPart()); + + // ׿ͻ + addCondition(whereClause, firstCondition, "PRB3_PTKH", assembleQueryBean.getCustomerFor()); + + // ׳ + addCondition(whereClause, firstCondition, "PRB3_PTCX", assembleQueryBean.getVehicleModel()); + + // ⾶ + addConditionGte(whereClause, firstCondition, "PRB3_WXCC_WJ", assembleQueryBean.getOuterDiameterGte()); + addConditionLte(whereClause, firstCondition, "PRB3_WXCC_WJ", assembleQueryBean.getOuterDiameterLte()); + + // ھ + addConditionGte(whereClause, firstCondition, "PRB3_WXCC_NJ", assembleQueryBean.getInnerDiameterGte()); + addConditionLte(whereClause, firstCondition, "PRB3_WXCC_NJ", assembleQueryBean.getInnerDiameterLte()); + + // + addConditionGte(whereClause, firstCondition, "PRB3_WXCC_KD", assembleQueryBean.getWidthGte()); + addConditionLte(whereClause, firstCondition, "PRB3_WXCC_KD", assembleQueryBean.getWidthLte()); + + // ϶ + addCondition(whereClause, firstCondition, "PRB3_JXYX", assembleQueryBean.getRadialClearance()); + + // ϶ + addCondition(whereClause, firstCondition, "PRB3_ZXYX", assembleQueryBean.getAxialClearance()); + + // Բֱ + addConditionGte(whereClause, firstCondition, "PRB3_JYZJ", assembleQueryBean.getPitchCircleDiameterGte()); + addConditionLte(whereClause, firstCondition, "PRB3_JYZJ", assembleQueryBean.getPitchCircleDiameterLte()); + + // С + addConditionGte(whereClause, firstCondition, "PRB3_GDTDX", assembleQueryBean.getRollerSizeGte()); + addConditionLte(whereClause, firstCondition, "PRB3_GDTDX", assembleQueryBean.getRollerSizeLte()); + + // + addConditionGte(whereClause, firstCondition, "PRB3_ZL", assembleQueryBean.getWeightGte()); + addConditionLte(whereClause, firstCondition, "PRB3_ZL", assembleQueryBean.getWeightLte()); + + // ʱ + addConditionDateGte(whereClause, firstCondition, "PCREATION_DATE", assembleQueryBean.getCreationTimeAfter()); + addConditionDateLte(whereClause, firstCondition, "PCREATION_DATE", assembleQueryBean.getCreationTimeBefore()); + + // ƷϺ + addCondition(whereClause, firstCondition, "PRB3_JPLH", assembleQueryBean.getBaseMaterialNumber()); + + // + if(!isEmpty(assembleQueryBean.getDevelopmentKind())) { + addCondition(whereClause, firstCondition, "PRB3_KFFL",RB3_KFFL_LOVMap.get(assembleQueryBean.getDevelopmentKind())); + } + + // ״̬ + if(!isEmpty(assembleQueryBean.getLifeCycleStatus())) { + addCondition(whereClause, firstCondition, "PRB3_SMZQZT",RB3_SMZQZTMap.get(assembleQueryBean.getLifeCycleStatus())); + + } + + // Ȩû + if(!isEmpty(assembleQueryBean.getOwnershipUser())) { + addCondition(whereClause, firstCondition, "PUSER_NAME",OwningUsernamesMap.get(assembleQueryBean.getOwnershipUser())); + } + + // Ȩ + if(!isEmpty(assembleQueryBean.getOwnershipGroup())) { + addCondition(whereClause, firstCondition, "PNAME",OwningGroupnamesMap.get(assembleQueryBean.getOwnershipGroup())); + } + + // ״̬ + if(!isEmpty(assembleQueryBean.getReleaseStatus())) { + addCondition(whereClause, firstCondition, "RELEASRNAME",releaseStatusMap.get(assembleQueryBean.getReleaseStatus())); + } + + // յ SQL ѯ + String finalSQL = sql + whereClause; + + System.out.println("finalSQL:" + finalSQL); + + // ִ SQL ѯ + + PreparedStatement prepareStatement = connection.prepareStatement(finalSQL); + // չʾ + java.sql.ResultSet executeQuery = prepareStatement.executeQuery(); + + List results = new ArrayList<>(); + while (executeQuery.next()) { + Result result = new Result(); + result.setId(executeQuery.getString("PITEM_ID")); + result.setName(executeQuery.getString("POBJECT_NAME")); + results.add(result); + } + + // رԴ + executeQuery.close(); + prepareStatement.close(); + return results; + + } + + // ֵ + private static void addCondition(StringBuilder whereClause, boolean firstCondition, String fieldName, + String fieldValue) { + if (!isEmpty(fieldValue)) { + whereClause.append(" AND "); + String searchValue = fieldValue.trim(); + if (searchValue.contains("*")) { + searchValue = searchValue.replace("*", "%"); + whereClause.append(fieldName).append(" LIKE ").append("'").append(searchValue).append("'"); + } else { + whereClause.append(fieldName).append(" = ").append("'").append(searchValue).append("'"); + } + } + } + private static boolean isNumeric(String str) { + return str.matches("^[0-9]+(\\.[0-9]+)?$"); + } + + // ҪַתΪֲдڵڱȽϵ + private static void addConditionGte(StringBuilder whereClause, boolean firstCondition, String fieldName, + String value) { +// if (minValue > 0.0) { // ûǷΪ +// whereClause.append(" AND "); +// // ֶַתΪֲдڵڱȽ +// whereClause.append("TO_NUMBER(").append(fieldName).append(") >= ").append(minValue); +// } + if (value != null && !value.isEmpty() && isNumeric(value)) { + whereClause.append(" AND "); + whereClause.append(fieldName).append("_NUM >= " + value); + } + } + + // ҪַתΪֲСڵڱȽϵ + private static void addConditionLte(StringBuilder whereClause, boolean firstCondition, String fieldName, + String value) { +// if (maxValue > 0.0) { // ûǷΪ +// +// whereClause.append(" AND "); +// // ֶַתΪֲСڵڱȽ +// whereClause.append("TO_NUMBER(").append(fieldName).append(") <= ").append(maxValue); +// } + if (value != null && !value.isEmpty() && isNumeric(value)) { + whereClause.append(" AND "); + whereClause.append(fieldName).append("_NUM <= " + value); + } + } + + // ҪַתΪڲдڵڱȽϵ + private static void addConditionDateGte(StringBuilder whereClause, boolean firstCondition, String fieldName, + String dateValue) { + if (!isEmpty(dateValue)) { + + whereClause.append(" AND "); + // ֶַתΪڲдڵڱȽ + whereClause.append(fieldName).append(" >= TO_DATE('") + .append(dateValue).append("', 'YYYY-MM-DD')"); + } + } + + // ҪַתΪڲСڵڱȽϵ + private static void addConditionDateLte(StringBuilder whereClause, boolean firstCondition, String fieldName, + String dateValue) { + if (!isEmpty(dateValue)) { + + whereClause.append(" AND "); + // ֶַתΪڲСڵڱȽ + whereClause.append(fieldName).append(" <= TO_DATE('") + .append(dateValue).append("', 'YYYY-MM-DD')"); + } + } + + /** + * ݿ + */ + public static Connection getConnectionTC12() { +// connection = com.connor.rb.DBTest.GetConn.getConnAction(); + try { + TCPreferenceService service = session.getPreferenceService(); + String[] array = service.getStringArray(TCPreferenceService.TC_preference_site, "TC12_Oracle_MSG"); + String driver_temp = null; + String url = null; + String dbName = null; + String dbPassword = null; + if (array != null) + for (String str : array) { + System.out.println(" ORACLE = " + str); + if (str != null && str.startsWith("ORACEL_DRIVER=")) { + driver_temp = str.substring(str.indexOf("=") + 1, str.length()); + } else if (str != null && str.startsWith("ORACEL_URL=")) { + url = str.substring(str.indexOf("=") + 1, str.length()); + } else if (str != null && str.startsWith("ORACEL_NAME=")) { + dbName = str.substring(str.indexOf("=") + 1, str.length()); + } else if (str != null && str.startsWith("ORACEL_PASSWORD=")) { + dbPassword = str.substring(str.indexOf("=") + 1, str.length()); + } + } + + if (driver_temp == null || url == null || dbName == null || dbPassword == null) { + Locale defaultLocale = Locale.getDefault(); + MessageBox.post("ѡTC12_Oracle_MSG", "ʾ", MessageBox.ERROR); + } + + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + return null; + // MessageBox.post("ORACEL CONNECT EXCEPTION + // \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + } + return connection; + } + + /** + * @Title: getdata + * @Description: TODO(һ仰) + * @param @param attrHashMap2 + * @param @param assembleQueryBean + * @return void + * @throws + */ + private static AssembleQueryBean getdata(LinkedHashMap attrHashMap2, + AssembleQueryBean assembleQueryBean) { + // TODO Auto-generated method stub + // Mapݸֵbean + for (Entry entry : attrHashMap2.entrySet()) { + String key = entry.getKey(); // keyӦJLabel.getName()Ľ + System.out.println("key:"+key); + Object value = entry.getValue(); + System.out.println("value:"+value); + + try { + // keybean + // labelbeanһ£ֱʹ÷ƽиֵ + switch (key) { + case "ID:": + assembleQueryBean.setId((String) getValue(value)); + break; + case "Ʒ:": + assembleQueryBean.setProductNumber((String) getValue(value)); + break; + case "ͼ:": + assembleQueryBean.setDesignDrawingNumber((String) getValue(value)); + break; + case "ʶ:": + assembleQueryBean.setIdentificationNumber((String) getValue(value)); + break; + case "˵2:": + assembleQueryBean.setDescription2((String) getValue(value)); + break; + case "ͼ/ͻͼ:": + assembleQueryBean.setOldDrawingCustomerDrawingNumber((String) getValue(value)); + break; + case "Ϻ:": + assembleQueryBean.setOldMaterialNumber((String) getValue(value)); + break; + case "Ʒ:": + assembleQueryBean.setCommodityCode((String) getValue(value)); + break; + case "ܳ:": + assembleQueryBean.setAssemblyType(getSelectedValue((JComboBox) value)); + break; + case ":": + assembleQueryBean.setProductionFactory(getSelectedValue((JComboBox) value)); + break; + case ":": + assembleQueryBean.setDesigner((String) getValue(value)); + break; + case "û:": + assembleQueryBean.setCreatedBy((String) getValue(value)); + break; + case "ʹòλ:": + assembleQueryBean.setUsedPart((String) getValue(value)); + break; + case "׿ͻ:": + assembleQueryBean.setCustomerFor((String) getValue(value)); + break; + case "׳:": + assembleQueryBean.setVehicleModel((String) getValue(value)); + break; + case "⾶(mm)>=:": + assembleQueryBean.setOuterDiameterGte((String) getValue(value)); + break; + case "⾶(mm)<=:": + assembleQueryBean.setOuterDiameterLte((String) getValue(value)); + break; + case "ھ(mm)>=:": + assembleQueryBean.setInnerDiameterGte((String) getValue(value)); + break; + case "ھ(mm)<=:": + assembleQueryBean.setInnerDiameterLte((String) getValue(value)); + break; + case "(mm)>=:": + assembleQueryBean.setWidthGte((String) getValue(value)); + break; + case "(mm)<=:": + assembleQueryBean.setWidthLte((String) getValue(value)); + break; + case "϶:": + assembleQueryBean.setRadialClearance((String) getValue(value)); + break; + case "϶:": + assembleQueryBean.setAxialClearance((String) getValue(value)); + break; + case "Բֱ(mm)>=:": + assembleQueryBean.setPitchCircleDiameterGte((String) getValue(value)); + break; + case "Բֱ(mm)<=:": + assembleQueryBean.setPitchCircleDiameterLte((String) getValue(value)); + break; + case "С(mm)>=:": + assembleQueryBean.setRollerSizeGte((String) getValue(value)); + break; + case "С(mm)<=": + assembleQueryBean.setRollerSizeLte((String) getValue(value)); + break; + case "(mm)>=:": + assembleQueryBean.setWeightGte((String) getValue(value)); + break; + case "(mm)<=": + assembleQueryBean.setWeightLte((String) getValue(value)); + break; + case "ʱ:": + assembleQueryBean.setCreationTimeAfter((String) getValue(value)); + break; + case "ʱ:": + assembleQueryBean.setCreationTimeBefore((String) getValue(value)); + break; + case "ƷϺ:": + assembleQueryBean.setBaseMaterialNumber((String) getValue(value)); + break; + case ":": + assembleQueryBean.setDevelopmentKind(getSelectedValue((JComboBox) value)); + break; + case "״̬:": + assembleQueryBean.setLifeCycleStatus(getSelectedValue((JComboBox) value)); + break; + case "Ȩû:": + assembleQueryBean.setOwnershipUser(getSelectedValue((JComboBox) value)); + break; + case "Ȩ:": + assembleQueryBean.setOwnershipGroup(getSelectedValue((JComboBox) value)); + break; + case "״̬:": + assembleQueryBean.setReleaseStatus(getSelectedValue((JComboBox) value)); + break; + default: + System.err.println("δ֪ԣ" + key); + } + } catch (NumberFormatException | NullPointerException e) { + System.err.println("ʱ" + key + ", Ϣ" + e.getMessage()); + } + } + return assembleQueryBean; + } + + /** + * ȡJTextFieldDateChooserֵ + * + * @param value + * @return ıֵ + */ + private static String getValue(Object value) { + if (value instanceof JTextField) { + return ((JTextField) value).getText(); + } else if (value instanceof JComboBox) { + return ((JComboBox) value).getSelectedItem().toString(); + } + return null; + } + + /** + * ȡJComboBoxѡֵ + * + * @param comboBox Ͽ + * @return ѡֵ + */ + private static String getSelectedValue(JComboBox comboBox) { + return comboBox.getSelectedItem() == null ? null : comboBox.getSelectedItem().toString(); + } + + /** + * + * @Title: getItemById + * @Description: idòѯض + * @param @param id + * @param @return + * @return TCComponent + * @throws + */ + public static TCComponent getItemById(String id) { + + try { + System.out.println("ûĿ" + getText(session, "ItemID")); + // òѯ + String[] keys = new String[] { getText(session, "ItemID") }; + // òѯidֵ + String[] values = new String[] { id }; + List comps = queryObject("...", keys, values); + if (comps != null || comps.size() > 0) { + return comps.get(0); + } else { + MessageBox.post("ѡûвѯ", "", MessageBox.ERROR); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + + /** + * + * @Title: queryObject + * @Description: òѯ + * @param @param queryName + * @param @param keys + * @param @param values + * @param @return + * @return List + * @throws + */ + public static List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + MessageBox.post("ûвѯ", "", MessageBox.ERROR); + return null; + } + } + + /** + * + * @Title: getText + * @Description: ȡûĿֵ + * @param @param session + * @param @param str + * @param @return + * @param @throws Exception + * @return String + * @throws + */ + 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; + } + } + + /** + * + * @Title: isEmpty + * @Description: жǷΪ + * @param @param str + * @param @return + * @return boolean + * @throws + */ + public static boolean isEmpty(String str) { + return str == null || "".equals(str.trim()); + } + + private static void showNewWindow(List results) { + List ids = new ArrayList<>(); + List names = new ArrayList<>(); + for (int i = 0; i < results.size(); i++) { + ids.add(results.get(i).getId()); + names.add(results.get(i).getName()); + } + + JFrame newFrame = new JFrame("ѯ"); + newFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); + newFrame.setSize(300, 400); + + DefaultTableModel model = new DefaultTableModel(); + model.addColumn("ID"); + model.addColumn(""); + + // ʹ Set Ѿӹ + Set addedRows = new HashSet<>(); + + for (int i = 0; i < ids.size(); i++) { + String id = ids.get(i); + String name = names.get(i); + String rowKey = id + ":" + name; // һΨһļʶÿ + + if (!addedRows.contains(rowKey)) { + model.addRow(new Object[]{id, name}); + addedRows.add(rowKey); // еıʶӵ set + } + } + + JTable table = new JTable(model); + table.setDefaultEditor(Object.class, null); // ñ񲻿ɱ༭ + table.getColumnModel().getColumn(0).setPreferredWidth(100); // п + + // ˫ + table.addMouseListener(new MouseListener() { + @Override + public void mouseReleased(MouseEvent e) { + } + + @Override + public void mousePressed(MouseEvent e) { + } + + @Override + public void mouseExited(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + } + + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2) { // Ƿ˫ + int selectedRow = table.getSelectedRow(); + if (selectedRow >= 0) { + String id = table.getValueAt(selectedRow, 0).toString(); + if (!isEmpty(id)) { + System.out.println("Double-clicked ID: " + table.getValueAt(selectedRow, 0)); + com.teamcenter.rac.common.Activator.getDefault() + .openPerspective("com.teamcenter.rac.ui.perspectives.navigatorPerspective"); + com.teamcenter.rac.common.Activator.getDefault().openComponents( + "com.teamcenter.rac.ui.perspectives.navigatorPerspective", + new InterfaceAIFComponent[]{getItemById(id)}); + } + } + } + } + }); + + JScrollPane scrollPane = new JScrollPane(table); + + // Ӱť + JButton getSelectedIdsButton = new JButton(""); + getSelectedIdsButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int[] selectedRows = table.getSelectedRows(); + ArrayList selectedIds = new ArrayList<>(); + for (int row : selectedRows) { + String id = table.getValueAt(row, 0).toString(); + selectedIds.add(id); + } + System.out.println("ѡеID: " + selectedIds); + if(selectedIds.size()>0) { + newFrame.dispose(); + session.queueOperation(new Rb026Dialog(session,selectedIds)); +// new Thread(new Rb026Dialog(session,selectedIds)).start(); + }else { + MessageBox.post("ѡ", "ʾ", MessageBox.INFORMATION); + return; + } + + } + }); + + // ò + JPanel buttonPanel = new JPanel(); + buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); + buttonPanel.add(getSelectedIdsButton); + + newFrame.getContentPane().add(scrollPane, BorderLayout.CENTER); + newFrame.getContentPane().add(buttonPanel, BorderLayout.SOUTH); + + // ôھ + newFrame.setLocationRelativeTo(null); + newFrame.setAlwaysOnTop(true); + // ÿɼ + newFrame.setVisible(true); +// List ids = new ArrayList(); +// List names = new ArrayList(); +// for (int i = 0; i < results.size(); i++) { +// ids.add(results.get(i).getId()); +// names.add(results.get(i).getName()); +// } +// +// JFrame newFrame = new JFrame("ѯ"); +// newFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); +// newFrame.setSize(300, 400); +// +// DefaultTableModel model = new DefaultTableModel(); +// model.addColumn("ID"); +// model.addColumn(""); +// +// // ʹ Set Ѿӹ +// Set addedRows = new HashSet<>(); +// +// for (int i = 0; i < ids.size(); i++) { +// String id = ids.get(i); +// String name = names.get(i); +// String rowKey = id + ":" + name; // һΨһļʶÿ +// +// if (!addedRows.contains(rowKey)) { +// model.addRow(new Object[]{id, name}); +// addedRows.add(rowKey); // еıʶӵ set +// } +// } +// +// JTable table = new JTable(model); +// table.setDefaultEditor(Object.class, null); // ñ񲻿ɱ༭ +// table.getColumnModel().getColumn(0).setPreferredWidth(100); // п +// +// +// +// +// // ˫ +// table.addMouseListener(new MouseListener() { +// +// @Override +// public void mouseReleased(MouseEvent e) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mousePressed(MouseEvent e) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseExited(MouseEvent e) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseEntered(MouseEvent e) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseClicked(MouseEvent e) { +// if (e.getClickCount() == 2) { // Ƿ˫ +// int selectedRow = table.getSelectedRow(); +// if (selectedRow >= 0) { +// String id = table.getValueAt(selectedRow, 0).toString(); +// if (!isEmpty(id)) { +// System.out.println("Double-clicked ID: " + table.getValueAt(selectedRow, 0)); +// com.teamcenter.rac.common.Activator.getDefault() +// .openPerspective("com.teamcenter.rac.ui.perspectives.navigatorPerspective"); +// com.teamcenter.rac.common.Activator.getDefault().openComponents( +// "com.teamcenter.rac.ui.perspectives.navigatorPerspective", +// new InterfaceAIFComponent[] { getItemById(id) }); +// } +// +// } +// } +// } +// }); +// +// JScrollPane scrollPane = new JScrollPane(table); +// newFrame.getContentPane().add(scrollPane, BorderLayout.CENTER); +// +// // ôھ +// newFrame.setLocationRelativeTo(null); +// newFrame.setAlwaysOnTop(true); +// // ÿɼ +// newFrame.setVisible(true); + } + public void report(ArrayList idList) { + session.queueOperation(new Rb026Dialog(session,idList)); + //new Thread(new Rb026Dialog(session,idList)).start(); + } + +} +class WaitingDialog extends com.teamcenter.rac.aif.AbstractAIFDialog { + private static final long serialVersionUID = 1L; + public JPanel panel; + JProgressBar progressBar = null; + + public WaitingDialog(Frame arg0, String title, String message) { + super(arg0, title); + this.setModal(false); + + panel = new JPanel(new BorderLayout()); + + /* + * JLabel label = new JLabel(message); System.out.println("message:"+message); + * System.out.println("label:"+label); panel.add(label); + */ + + progressBar = new JProgressBar(SwingConstants.HORIZONTAL); + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + + panel.add(BorderLayout.CENTER, new Label(message)); + panel.add(BorderLayout.SOUTH, progressBar); + + panel.setPreferredSize(new Dimension(350, 60)); + + this.getContentPane().add(panel); + + centerToScreen(); + + pack(); + + } +} diff --git a/src/com/connor/rb/plm/query/ZCQueryHandler.java b/src/com/connor/rb/plm/query/ZCQueryHandler.java new file mode 100644 index 0000000..7cff963 --- /dev/null +++ b/src/com/connor/rb/plm/query/ZCQueryHandler.java @@ -0,0 +1,53 @@ +/** * @Title: ZCQuery.java + * @Package com.connor.rb.plm.query + * @Description: TODO(һ仰ļʲô) + * @author admin * @date 2024913 + * @version V1.0 + */ +package com.connor.rb.plm.query; + +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +/** + * @ClassName: ZCQuery + * @Description: TODO(һ仰) + * @author admin + * @date 2024913 + * + */ +public class ZCQueryHandler extends AbstractHandler{ + + /* + * Title: execute + * Description: + * @param arg0 + * @return + * @throws ExecutionException + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + private static AbstractAIFApplication app; + private static TCSession session; + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); + + new Thread(){ + public void run() { + session.queueOperation(new ZCQueryDialog(session)); + }; + }.start(); + + + return null; + } + +} diff --git a/src/com/connor/rb/plm/query/test.java b/src/com/connor/rb/plm/query/test.java new file mode 100644 index 0000000..29f68a1 --- /dev/null +++ b/src/com/connor/rb/plm/query/test.java @@ -0,0 +1,223 @@ +/** * @Title: test.java + * @Package com.connor.rb.plm.query + * @Description: TODO(һ仰ļʲô) + * @author admin * @date 2024919 + * @version V1.0 + */ +package com.connor.rb.plm.query; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.sql.SQLException; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +import com.connor.rb.plm.rb012.DateChooser; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.MessageBox; + +/** + * @ClassName: test + * @Description: TODO(һ仰) + * @author admin + * @date 2024919 + * + */ +public class test { + public static void main(String[] args) throws SQLException { + JFrame frame = new JFrame("ܳɼ-11"); + + frame.setSize(420, 600); + + // ݵJFrame + JScrollPane centerPanel = createCenterPanel(); + JPanel bottomPanel = createBottomPanel(frame); + + frame.getContentPane().add(centerPanel, BorderLayout.CENTER); + frame.getContentPane().add(bottomPanel, BorderLayout.SOUTH); + // ôھ + frame.setLocationRelativeTo(null); + frame.setDefaultCloseOperation(2); + // ÿɼ + frame.setVisible(true); + } + + private static JScrollPane createCenterPanel() throws SQLException { + // йܵJPanel + JScrollPane scrollPane = null; + try { + scrollPane = new JScrollPane(createFormPanel()); + } catch (SQLException | TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return scrollPane; + } + + private static JPanel createBottomPanel(JFrame frame) { + // ťJPanel + JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER)); + JButton button1 = new JButton("ѯ"); + JButton button2 = new JButton("ȡ"); + + panel.add(button1); + panel.add(button2); + return panel; + } + private static JPanel createFormPanel() throws SQLException, TCException { + + // һJPanelɱԪ + JPanel formPanel = new JPanel(new GridBagLayout()); + + GridBagConstraints c = new GridBagConstraints(); + c.insets = new Insets(5, 5, 5, 5); // ߾ + + // ֶμӦıǩ + JLabel[] labels = { new JLabel("ID:"), new JLabel("Ʒ:"), new JLabel("ͼ:"), new JLabel("ʶ:"), + new JLabel("˵2:"), new JLabel("ͼ/ͻͼ:"), new JLabel("Ϻ:"), new JLabel("Ʒ:") }; // ͼƬеֶӦJLabel + JTextField[] textFields = new JTextField[labels.length]; + + JLabel[] labels1 = { new JLabel("ܳ:"), new JLabel(":") }; // ͼƬеֶӦJLabel + JComboBox[] coxFields1 = new JComboBox[labels1.length]; + + JLabel[] labels2 = { new JLabel(":"), new JLabel("û:"), new JLabel("ʹòλ:"), new JLabel("׿ͻ:"), + new JLabel("׳:"), new JLabel("⾶(mm)>=:"), new JLabel("⾶(mm)<=:"), new JLabel("ھ(mm)>=:"), + new JLabel("ھ(mm)<=:"), new JLabel("(mm)>=:"), new JLabel("(mm)<=:"), new JLabel("϶:"), + new JLabel("϶:"), new JLabel("Բֱ(mm)>=:"), new JLabel("Բֱ(mm)<=:"), new JLabel("С(mm)>="), + new JLabel("С(mm)<="), new JLabel("(mm)>="), new JLabel("(mm)<=") }; // ͼƬеֶӦJLabel + JTextField[] textFields2 = new JTextField[labels2.length]; + + JLabel[] labels3 = { new JLabel("ʱ:"), new JLabel("ʱ:") }; // ͼƬеֶӦJLabel + JTextField[] dateFields1 = new JTextField[labels3.length]; + + JLabel[] labels4 = { new JLabel("ƷϺ:") }; // ͼƬеֶӦJLabel + JTextField[] textFields4 = new JTextField[labels4.length]; + + JLabel[] labels5 = { new JLabel(":"), new JLabel("״̬:"), new JLabel("Ȩû:"), new JLabel("Ȩ:"), + new JLabel("״̬:") }; // ͼƬеֶӦJLabel + JComboBox[] coxFields5 = new JComboBox[labels5.length]; + + // ÿJLabelJTextFieldӵformPanel + for (int i = 0; i < labels.length; i++) { + c.gridx = 0; + c.weightx = 0; + c.anchor = GridBagConstraints.LINE_START; + labels[i].setFont(new Font("΢ź", Font.BOLD, 15)); + formPanel.add(labels[i], c); + + c.gridx = 1; + c.weightx = 1; + c.fill = GridBagConstraints.HORIZONTAL; + JTextField jTextField = new JTextField(10); + jTextField.setFont(new Font("΢ź", Font.BOLD, 15)); + formPanel.add(textFields[i] = jTextField, c); + + } + // ÿJLabelJTextFieldӵformPanel + for (int i = 0; i < labels1.length; i++) { + c.gridx = 0; + c.weightx = 0; + c.anchor = GridBagConstraints.LINE_START; + labels1[i].setFont(new Font("΢ź", Font.BOLD, 15)); + formPanel.add(labels1[i], c); + + c.gridx = 1; + c.weightx = 1; + c.fill = GridBagConstraints.HORIZONTAL; + + JComboBox jComboBox = new JComboBox(); + jComboBox.setFont(new Font("΢ź", Font.BOLD, 15)); + jComboBox.setSelectedIndex(-1); + formPanel.add(jComboBox = new JComboBox(), c); + + } + // ÿJLabelJTextFieldӵformPanel + for (int i = 0; i < labels2.length; i++) { + c.gridx = 0; + c.weightx = 0; + c.anchor = GridBagConstraints.LINE_START; + labels2[i].setFont(new Font("΢ź", Font.BOLD, 15)); + formPanel.add(labels2[i], c); + + c.gridx = 1; + c.weightx = 1; + c.fill = GridBagConstraints.HORIZONTAL; + JTextField jTextField = new JTextField(10); + jTextField.setFont(new Font("΢ź", Font.BOLD, 15)); + formPanel.add(textFields2[i] = jTextField, c); + + + } + + // ÿJLabelJTextFieldӵformPanel + for (int i = 0; i < labels3.length; i++) { + c.gridx = 0; + c.weightx = 0; + c.anchor = GridBagConstraints.LINE_START; + labels3[i].setFont(new Font("΢ź", Font.BOLD, 15)); + formPanel.add(labels3[i], c); + + c.gridx = 1; + c.weightx = 1; + c.fill = GridBagConstraints.HORIZONTAL; + JTextField jTextField = new JTextField(); + jTextField.setFont(new Font("΢ź", Font.BOLD, 15)); + DateChooser dateChooser1 = DateChooser.getInstance("yyyy-MM-dd"); + dateChooser1.register(jTextField); + formPanel.add(dateFields1[i] = jTextField, c); + + + } + + // ÿJLabelJTextFieldӵformPanel + for (int i = 0; i < labels4.length; i++) { + c.gridx = 0; + c.weightx = 0; + c.anchor = GridBagConstraints.LINE_START; + labels4[i].setFont(new Font("΢ź", Font.BOLD, 15)); + formPanel.add(labels4[i], c); + + c.gridx = 1; + c.weightx = 1; + c.fill = GridBagConstraints.HORIZONTAL; + JTextField jTextField = new JTextField(10); + jTextField.setFont(new Font("΢ź", Font.BOLD, 15)); + formPanel.add(textFields4[i] = jTextField, c); + + } + + // ÿJLabelJTextFieldӵformPanel + for (int i = 0; i < labels5.length; i++) { + c.gridx = 0; + c.weightx = 0; + c.anchor = GridBagConstraints.LINE_START; + labels5[i].setFont(new Font("΢ź", Font.BOLD, 15)); + formPanel.add(labels5[i], c); + + c.gridx = 1; + c.weightx = 1; + c.fill = GridBagConstraints.HORIZONTAL; + JComboBox jComboBox = new JComboBox(); + jComboBox.setFont(new Font("΢ź", Font.BOLD, 15)); + jComboBox.setSelectedIndex(-1); + formPanel.add(coxFields5[i] = jComboBox, c); + } + + return formPanel; + } + +} diff --git a/src/com/connor/rb/plm/rb001/PlclIDHandler.java b/src/com/connor/rb/plm/rb001/PlclIDHandler.java new file mode 100644 index 0000000..c1bd4c6 --- /dev/null +++ b/src/com/connor/rb/plm/rb001/PlclIDHandler.java @@ -0,0 +1,40 @@ +package com.connor.rb.plm.rb001; + +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class PlclIDHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + + new Thread() { + @Override + public void run() { + + try { + new PlclidDialog(app, session); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + }.start(); + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + return null; + } +} diff --git a/src/com/connor/rb/plm/rb001/PlclidDialog.java b/src/com/connor/rb/plm/rb001/PlclidDialog.java new file mode 100644 index 0000000..ca81908 --- /dev/null +++ b/src/com/connor/rb/plm/rb001/PlclidDialog.java @@ -0,0 +1,114 @@ +package com.connor.rb.plm.rb001; + +import java.io.File; +import java.io.FileInputStream; +import java.util.Locale; +import java.util.ResourceBundle; +import javax.swing.JFileChooser; +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.connor.rb.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +/** + * =============================================================================== + * Copyright (c) 2012-2024 CONNOR lijh. Unpublished - All Rights Reserved + * =============================================================================== + * File description: + * + * PlclidDialog.java ȡexcelݣ޸ϵͳID + * + * =============================================================================== + * DATE Name Description of Change + * + * + * =============================================================================== + */ + +public class PlclidDialog extends AbstractAIFDialog { + + private TCSession session; + private AbstractAIFApplication app; + + public PlclidDialog(AbstractAIFApplication app, TCSession session) throws Exception { + this.session = session; + this.app = app; + initUI(); + } + + public void initUI() throws Exception { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + + AbstractAIFUIApplication abstractAIFUIApplication = AIFUtility.getCurrentApplication(); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + int result = fileChooser.showOpenDialog(abstractAIFUIApplication.getApplicationPanel()); + if (result == JFileChooser.APPROVE_OPTION) { + File file = fileChooser.getSelectedFile(); + if (file.isFile() && file.getName().endsWith(".xlsx")) { + // ѡļ + System.out.println("ѡļǣ" + file.getAbsolutePath()); + // ȡEXCEL + FileInputStream fis = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(fis); + // ȡexcelĵ + // ҵһҳ + XSSFSheet sheet = wb.getSheetAt(0); + int rowIndex = 1;// ӵڶпʼ + SoaServerUtil.openByPass(session); + while (true) { + XSSFRow nextRow = sheet.getRow(rowIndex); + // ѭж + if (nextRow == null || nextRow.getCell(0) == null + || nextRow.getCell(0).getCellType() == XSSFCell.CELL_TYPE_BLANK + || nextRow.getCell(1) == null + || nextRow.getCell(1).getCellType() == XSSFCell.CELL_TYPE_BLANK) { + break; + } + + System.out.println(nextRow.getCell(0) + "->" + nextRow.getCell(1)); + // Ӧ޸ID + try { + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item"); + TCComponentItem item = itemType.find(nextRow.getCell(1).toString());// ͨidȡitem + item.setStringProperty("item_id", nextRow.getCell(0).toString()); + // ޸ıid + TCComponent itemForm = item.getRelatedComponent("IMAN_master_form"); + itemForm.setStringProperty("object_name", nextRow.getCell(0).toString()); + itemForm.save(); + // ȡ汾 + TCComponentItemRevision latestItemRevision = item.getLatestItemRevision(); + TCComponent revForm = latestItemRevision.getRelatedComponent("IMAN_master_form_rev"); + revForm.setStringProperty("object_name", nextRow.getCell(0).toString()); + revForm.save(); + } catch (Exception e) { + MessageBox.post("ID:" + nextRow.getCell(1).toString() + rb.getString("zxtzbcz.TITLE"), "ʾ", + MessageBox.INFORMATION); + SoaServerUtil.closeByPass(session); + return; + } + + rowIndex++; + } + SoaServerUtil.closeByPass(session); + MessageBox.post(rb.getString("idxgcg.TITLE"), "ʾ", MessageBox.INFORMATION); + } else { + MessageBox.post(rb.getString("qxzexcel.TITLE"), "ʾ", MessageBox.INFORMATION); + } + + } + } +} diff --git a/src/com/connor/rb/plm/rb001/Rb001Dialog.java b/src/com/connor/rb/plm/rb001/Rb001Dialog.java new file mode 100644 index 0000000..a86dc1e --- /dev/null +++ b/src/com/connor/rb/plm/rb001/Rb001Dialog.java @@ -0,0 +1,408 @@ +package com.connor.rb.plm.rb001; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.aspose.cad.internal.ay.iF; +import com.connor.rb.plm.util.SoaServerUtil; +import com.connor.rb.plm.util.TCUtils; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCPropertyService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +/** + * :Rb001Dialog : ͼֽ޶ :2020-12-28 Ա + * + * ޸ ޸ ޸ 2019-01-24 XXXX + */ +public class Rb001Dialog extends AbstractAIFDialog { + private AbstractAIFUIApplication app; + private TCComponentItemRevision rev; + private TCSession session; + + public Rb001Dialog(AbstractAIFUIApplication app, TCComponentItemRevision rev) { + this.app = app; + this.session = (TCSession) app.getSession(); + this.rev = rev; + } + + public void run() { + initUI(); + } + + public void initUI() { + this.setLayout(new PropertyLayout()); + this.setTitle("ͼֽ޶"); + this.setPreferredSize(new Dimension(200, 200)); + this.setResizable(false);// ɱ䶯ڴС + + final JPanel centerPanel = new JPanel(new PropertyLayout()); + centerPanel.setPreferredSize(new Dimension(200, 80)); + final JPanel abcPanel = new JPanel(new PropertyLayout()); + abcPanel.setPreferredSize(new Dimension(200, 40)); + JCheckBox xbb = new JCheckBox("С汾"); + JCheckBox dbb = new JCheckBox("汾"); + JCheckBox a = new JCheckBox("A"); + JCheckBox b = new JCheckBox("B"); + JCheckBox c = new JCheckBox("C"); + centerPanel.add("1.1.center.top", new JLabel(" ")); + centerPanel.add("2.1.center.top", new JLabel(" ")); + centerPanel.add("2.2.center.top", xbb); + centerPanel.add("3.1.center.top", new JLabel(" ")); + centerPanel.add("3.2.center.top", dbb); + abcPanel.add("1.1.center.top", new JLabel(" ")); + abcPanel.add("1.2.center.top", a); + abcPanel.add("1.3.center.top", new JLabel(" ")); + abcPanel.add("1.4.center.top", b); + abcPanel.add("1.5.center.top", new JLabel(" ")); + abcPanel.add("1.6.center.top", c); + + JPanel southPanel = new JPanel(new PropertyLayout()); + southPanel.setPreferredSize(new Dimension(200, 80)); + JButton okBtn = new JButton("ȷ"); + okBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + // · + Object[] obj = new Object[1]; + obj[0] = ""; + TCUserService userservice = session.getUserService(); + try { + try { + TCUtils.openLogByPass(session, "ͼֽ޶"); + userservice.call("Connor_set_bypass", obj); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + List list = new ArrayList(); + List abcList = new ArrayList(); + Component[] jcbs = centerPanel.getComponents();// ѡݴ + for (Component component : jcbs) { + if (component instanceof JCheckBox) { + JCheckBox jcb = (JCheckBox) component; + if (jcb.isSelected()) { + list.add(jcb.getText()); + } + } + } + Component[] abcs = abcPanel.getComponents();// ѡݴ + for (Component component : abcs) { + if (component instanceof JCheckBox) { + JCheckBox jcb = (JCheckBox) component; + if (jcb.isSelected()) { + abcList.add(jcb.getText()); + } + } + } + // if (list.size() != 1) { + // MessageBox.post("ȷѡʽ", "ʾ", MessageBox.INFORMATION); + // return; + // } else { + String revType = ""; + if (list.size() > 0) { + revType = list.get(0); + } + try { + // TCComponentItem item = rev.getItem(); + // TCComponentItemRevision lastRev = item.getLatestItemRevision(); + String revID = rev.getStringProperty("item_revision_id"); + String end = ""; + String oldID = ""; + String endWith = revID.substring(revID.length() - 1, revID.length()); + System.out.println("endWith=================" + endWith); + // if (abcList.size() > 1) { + // MessageBox.post("ѡһ汾棡", "ʾ", MessageBox.INFORMATION); + // return; + // } else + // if ("ABC".indexOf(endWith) > 0 && abcList.size() <= 0 && + // "С汾".equals(revType)) { + // MessageBox.post("ѡ汾" + endWith + "棡", "ʾ", MessageBox.INFORMATION); + // return; + // } else if ("ABC".indexOf(endWith) > 0 && "С汾".equals(revType)) { + // String str = abcList.get(0); + // if (!(endWith.equals(str))) { + // MessageBox.post("ѡȷİ汾,ǰȷ汾Ϊ" + endWith + "", "ʾ", + // MessageBox.INFORMATION); + // return; + // } + // } + try { + SoaServerUtil.openByPass(session); + if ("С汾".equals(revType)) { + if (revID.contains(".")) { + String[] revs = revID.split("\\."); + if (endWith.equals("A") || endWith.equals("B") || endWith.equals("C")) { + oldID = revs[1].substring(0, revs[1].length() - 1); + end = revs[1].substring(revs[1].length() - 1, revs[1].length()); + System.out.println("end===========" + end); + } else { + oldID = revs[1].substring(0, revs[1].length()); + } + + int newID = Integer.parseInt(oldID) + 1; + StringBuilder sb = new StringBuilder(revs[0]); + sb.append("."); + String idEnd = newID + ""; + System.out.println("idEnd====" + idEnd); + sb.append(idEnd); + oldID = sb.toString(); + System.out.println("oldID=============" + oldID); + if ("".equals(end.trim())) { + if (abcList.size() > 0) { + for (int i = 0; i < abcList.size(); i++) { + StringBuilder sb2 = new StringBuilder(oldID); + sb2.append(abcList.get(i)); + System.out.println("°汾Ϊ" + sb2.toString()); + rev.saveAs(sb2.toString()); + } + } else { + System.out.println("°汾Ϊ" + oldID); + rev.saveAs(oldID); + } + } else { + sb.append(end); + System.out.println("°汾Ϊ" + sb.toString()); + rev.saveAs(sb.toString()); + } + } else { + if (endWith.equals("A") || endWith.equals("B") || endWith.equals("C")) { + oldID = revID.substring(0, revID.length() - 1); + end = revID.substring(revID.length() - 1, revID.length()); + System.out.println("end===========" + end); + } else { + oldID = revID; + } + StringBuilder sb = new StringBuilder(oldID); + sb.append(".1"); + oldID = sb.toString(); + System.out.println("oldID=============" + oldID); + if ("".equals(end.trim())) { + if (abcList.size() > 0) { + for (int i = 0; i < abcList.size(); i++) { + StringBuilder sb2 = new StringBuilder(oldID); + sb2.append(abcList.get(i)); + System.out.println("°汾Ϊ" + sb2.toString()); + rev.saveAs(sb2.toString()); + } + } else { + System.out.println("°汾Ϊ" + oldID); +// //޶֮ ɾõĹϵ +// AIFComponentContext[] whereReferenced = rev.whereReferenced(); +// Boolean flagBoolean = false; +// TCComponent component = null; +// for(AIFComponentContext componentContext : whereReferenced) { +// component = (TCComponent)componentContext.getComponent(); +// TCComponent[] referenceListProperty = component.getReferenceListProperty("TC_Is_Represented_By"); +// if(referenceListProperty != null) { +// for(TCComponent component2 : referenceListProperty) { +// if(component2 == rev) { +// flagBoolean = true; +// System.out.println("ҵ˶"+component.getProperty("item_id")+"´޶󣬽ϵ..."); +// component.cutOperation("TC_Is_Represented_By", new TCComponent[] {component2}); +// break; +// } +// } +// break; +// } +//// +// } + + try { + SoaServerUtil.openByPass(session); + TCUtils.openLogByPass(session, "ͼֽ޶"); + rev.saveAs(oldID); + } catch (Exception e1) { + // TODO: handle exception + } finally { + + SoaServerUtil.closeByPass(session); + TCUtils.closeLogByPass(session, "ͼֽ޶"); + } + +// if(flagBoolean) { +// SoaServerUtil.openByPass(session); +// TCUtils.openLogByPass(session, "ͼֽ޶"); +// +// } + + } + } else { + sb.append(end); + System.out.println("°汾Ϊ" + sb.toString()); + rev.saveAs(sb.toString()); + } + + } + + } else if ("汾".equals(revType)) { + if (revID.contains(".")) { + String[] revs = revID.split("\\."); + oldID = revs[0].substring(1, revs[0].length()); + if (endWith.equals("A") || endWith.equals("B") || endWith.equals("C")) { + end = revs[1].substring(revs[1].length() - 1, revs[1].length()); + System.out.println("end===========" + end); + } + int newID = Integer.parseInt(oldID) + 1; + String v = revID.substring(0, 1); + StringBuilder sb = new StringBuilder(v); + sb.append(newID + ""); + oldID = sb.toString(); + System.out.println("oldID=============" + oldID); + if ("".equals(end.trim())) { + if (abcList.size() > 0) { + for (int i = 0; i < abcList.size(); i++) { + StringBuilder sb2 = new StringBuilder(oldID); + sb2.append(abcList.get(i)); + System.out.println("°汾Ϊ" + sb2.toString()); + rev.saveAs(sb2.toString()); + } + } else { + System.out.println("°汾Ϊ" + oldID); + rev.saveAs(oldID); + } + } else { + sb.append(end); + System.out.println("°汾Ϊ" + sb.toString()); + rev.saveAs(sb.toString()); + } + } else { + + if (endWith.equals("A") || endWith.equals("B") || endWith.equals("C")) { + end = revID.substring(revID.length() - 1, revID.length()); + oldID = revID.substring(1, revID.length() - 1); + System.out.println("end===========" + end); + } else { + oldID = revID.substring(1, revID.length()); + } + int newID = Integer.parseInt(oldID) + 1; + String v = revID.substring(0, 1); + StringBuilder sb = new StringBuilder(v); + sb.append(newID + ""); + oldID = sb.toString(); + System.out.println("oldID=============" + oldID); + if ("".equals(end.trim())) { + if (abcList.size() > 0) { + for (int i = 0; i < abcList.size(); i++) { + StringBuilder sb2 = new StringBuilder(oldID); + sb2.append(abcList.get(i)); + System.out.println("°汾Ϊ" + sb2.toString()); + rev.saveAs(sb2.toString()); + } + } else { + System.out.println("°汾Ϊ" + oldID); + rev.saveAs(oldID); + } + } else { + sb.append(end); + System.out.println("°汾Ϊ" + sb.toString()); + rev.saveAs(sb.toString()); + } + } + } else { + if (endWith.equals("A") || endWith.equals("B") || endWith.equals("C")) { + // ѡ񲻴ĸİ汾棡 + MessageBox.post(rb.getString("qxzbdzmdbbjxsj01_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + return; + } + if (abcList.size() > 0) { + for (int i = 0; i < abcList.size(); i++) { + StringBuilder sb2 = new StringBuilder(revID); + sb2.append(abcList.get(i)); + System.out.println("°汾Ϊ" + sb2.toString()); + rev.saveAs(sb2.toString()); + } + } else { + + // ѡһ汾棡 + MessageBox.post(rb.getString("qxzygbbjxsj01_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + SoaServerUtil.closeByPass(session); + return; + } + + } + } catch (Exception r) { + + } finally { + SoaServerUtil.closeByPass(session); + } + + // ޶ɣ + MessageBox.post(rb.getString("xdwc01_display.TITLE"), "", MessageBox.INFORMATION); + } catch (TCException e1) { + // TODO Auto-generated catch block + // ޶ʧܣ + MessageBox.post(rb.getString("xdsb01_display.TITLE"), "ʧ", MessageBox.INFORMATION); + e1.printStackTrace(); + } + // } + disposeDialog(); + } catch (Exception e2) { + // TODO: handle exception + } finally { + try { + TCUtils.closeLogByPass(session, "ͼֽ޶"); + userservice.call("Connor_close_bypass", obj); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + } + }); + JButton celBtn = new JButton("ȡ"); + celBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + southPanel.add("1.1.center.top", new JLabel(" ")); + southPanel.add("1.2.center.top", okBtn); + southPanel.add("1.3.center.top", new JLabel(" ")); + southPanel.add("1.4.center.top", celBtn); + this.add("1.1.center.center", centerPanel); + this.add("2.1.center.center", abcPanel); + this.add("3.1.center.center", southPanel); + this.centerToScreen(); + this.showDialog(); + } +} diff --git a/src/com/connor/rb/plm/rb001/Rb001Handler.java b/src/com/connor/rb/plm/rb001/Rb001Handler.java new file mode 100644 index 0000000..08e4ab2 --- /dev/null +++ b/src/com/connor/rb/plm/rb001/Rb001Handler.java @@ -0,0 +1,51 @@ +package com.connor.rb.plm.rb001; + +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.util.MessageBox; + +public class Rb001Handler extends AbstractHandler { + private AbstractAIFUIApplication app; + private String[] types = { "RB3_CPTRevision", "RB3_CGTRevision", "RB3_CGTARevision", "RB3_CGTBRevision", + "RB3_CGTCRevision", "RB3_QRTRevision", "RB3_3DMXTRevision", "RB3_GNCPTRevision", "RB3_GNLJTRevision", + "RB3_XZCPTRevision" }; + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if (targetComponent instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) targetComponent; + String targetType = rev.getType(); + List typesList = Arrays.asList(types); + if (typesList.contains(targetType)) { + Rb001Dialog dialog = new Rb001Dialog(app, rev); + new Thread(dialog).start(); + } else { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + // ѡͼֽ汾 + MessageBox.post(rb.getString("qxztzbbdxjxsbcz01_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return null; + } + } else { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("qxzbbdx01_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return null; + } + return null; + } +} diff --git a/src/com/connor/rb/plm/rb004/Rb004Action.java b/src/com/connor/rb/plm/rb004/Rb004Action.java new file mode 100644 index 0000000..fc0800e --- /dev/null +++ b/src/com/connor/rb/plm/rb004/Rb004Action.java @@ -0,0 +1,21 @@ +package com.connor.rb.plm.rb004; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +public class Rb004Action extends AbstractAIFAction { + + + public Rb004Action(AIFDesktop arg0, String arg1) { + super(arg0, arg1); + + } + + + + @Override + public void run() { + + } + +} diff --git a/src/com/connor/rb/plm/rb004/Rb004Handler.java b/src/com/connor/rb/plm/rb004/Rb004Handler.java new file mode 100644 index 0000000..91361c3 --- /dev/null +++ b/src/com/connor/rb/plm/rb004/Rb004Handler.java @@ -0,0 +1,87 @@ +package com.connor.rb.plm.rb004; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.ui.PlatformUI; + +import com.teamcenter.rac.aif.AIFDesktop; + +import cn.com.origin.autocode.newitem.generatcode.NewCodeItemDialog; + +public class Rb004Handler extends AbstractHandler { + public Object execute(ExecutionEvent arg0) throws ExecutionException { + System.out.println("ñ======================"); + + + NewCodeItemDialog createDialog = + new NewCodeItemDialog(AIFDesktop.getActiveDesktop().getShell()); + //progressStart(); + System.out.println("ñ=2"); + AIFDesktop.getActiveDesktop().getShell().getDisplay().asyncExec(new Runnable() { + public void run() { + try { + System.out.println("ñ=3"); + createDialog.open(); + System.out.println("ñ=4"); + } catch (Exception e2) { + e2.printStackTrace(); + } + } + }); + + return null; + } + +// private void progressStart() { +// System.out.println("==>>1"); +// IRunnableWithProgress runnable = new IRunnableWithProgress() { +// public void run(IProgressMonitor monitor) { +// monitor.beginTask("......", 10000); +// // ʱ +// try { +// int count = 0; +// while(true) { +// if(NewCodeItemDialog.flg) { +// System.out.println(""); +// break; +// } +// Thread.sleep(100); +// count ++; +// if(count > 100){ +// System.out.println("ȴʱ"); +// break; +// } +// if(count%10 == 0) { +// System.out.println("ʱ["+(count/10)+"]"); +// } +// monitor.worked(100); +// } +// } catch (InterruptedException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// monitor.done();// ǰ +// } +// }; +// // PlatformUI.getWorkbench().getDisplay().getActiveShell() +// System.out.println("==>>2"); +// PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { +// public void run() { +// try { +// // һԻ򣬲runnable +// // һƼΪtrueΪfalseUI߳潫һͣ͸С +// // ڶtrueԻġȡťЧ +// new ProgressMonitorDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell()) +// .run(true, false, runnable); +// } catch (Exception e2) { +// e2.printStackTrace(); +// } +// } +// }); +// System.out.println("==>>3"); +// } +} diff --git a/src/com/connor/rb/plm/rb007/CreateItem.java b/src/com/connor/rb/plm/rb007/CreateItem.java new file mode 100644 index 0000000..c1fd190 --- /dev/null +++ b/src/com/connor/rb/plm/rb007/CreateItem.java @@ -0,0 +1,230 @@ +package com.connor.rb.plm.rb007; + +import java.awt.Color; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JTextField; +import javax.swing.WindowConstants; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CreateItem extends AbstractAIFOperation { + private String itemId = null; + private TCSession session; + private TCComponentItem f; + + public CreateItem(TCSession session2, TCComponentItem f) { + // TODO Auto-generated constructor stub + this.session = session2; + this.f = f; + } + + @Override + public void executeOperation() throws Exception { + + JFrame jFrame = new JFrame(""); + jFrame.setSize(550, 610); + jFrame.setLayout(null); + + JLabel order = new JLabel("Ʒţ"); + order.setFont(new Font("", Font.PLAIN, 16)); + order.setBounds(20, 20, 200, 50); + jFrame.add(order); + JTextField orderText = new JTextField(20); + orderText.setFont(new Font("", Font.PLAIN, 16)); + orderText.setSelectedTextColor(new Color(0xFF0000)); + orderText.setBounds(120, 32, 280, 25); + jFrame.add(orderText); + + JLabel name = new JLabel("ţ"); + name.setFont(new Font("", Font.PLAIN, 16)); + name.setBounds(20, 67, 200, 50); + jFrame.add(name); + JTextField nameText = new JTextField(20); + nameText.setFont(new Font("", Font.PLAIN, 16)); + nameText.setSelectedTextColor(new Color(0xFF0000)); + nameText.setBounds(120, 79, 280, 25); + jFrame.add(nameText); + + JLabel orderType = new JLabel("ERP룺"); + orderType.setFont(new Font("", Font.PLAIN, 16)); + orderType.setBounds(20, 112, 200, 50); + jFrame.add(orderType); + JTextField orderTypeText = new JTextField(20); + orderTypeText.setFont(new Font("", Font.PLAIN, 16)); + orderTypeText.setSelectedTextColor(new Color(0xFF0000)); + orderTypeText.setBounds(120, 126, 280, 25); + jFrame.add(orderTypeText); + + JLabel ctrlJLabel = new JLabel("ͻĿţ"); + ctrlJLabel.setFont(new Font("", Font.PLAIN, 16)); + ctrlJLabel.setBounds(20, 160, 200, 50); + jFrame.add(ctrlJLabel); + JTextField ctrlJLabelText = new JTextField(20); + ctrlJLabelText.setFont(new Font("", Font.PLAIN, 16)); + ctrlJLabelText.setSelectedTextColor(new Color(0xFF0000)); + ctrlJLabelText.setBounds(120, 175, 280, 25); + jFrame.add(ctrlJLabelText); + + JLabel compCode = new JLabel("ͻͼţ"); + compCode.setFont(new Font("", Font.PLAIN, 16)); + compCode.setBounds(20, 206, 200, 50); + jFrame.add(compCode); + JTextField compCodeBox = new JTextField(20); + compCodeBox.setFont(new Font("", Font.PLAIN, 16)); + compCodeBox.setSelectedTextColor(new Color(0xFF0000)); + compCodeBox.setBounds(120, 222, 280, 25); + jFrame.add(compCodeBox); + + JLabel factory = new JLabel("߷Ӳϣ"); + factory.setFont(new Font("", Font.PLAIN, 16)); + factory.setBounds(20, 253, 200, 50); + jFrame.add(factory); + JTextField factoryBox = new JTextField(20); + factoryBox.setFont(new Font("", Font.PLAIN, 16)); + factoryBox.setSelectedTextColor(new Color(0xFF0000)); + factoryBox.setBounds(120, 267, 280, 25); + jFrame.add(factoryBox); + + JLabel useJLabel = new JLabel("Ӧ׼"); + useJLabel.setFont(new Font("", Font.PLAIN, 16)); + useJLabel.setBounds(20, 300, 200, 50); + jFrame.add(useJLabel); + JTextField useBox = new JTextField(20); + useBox.setFont(new Font("", Font.PLAIN, 16)); + useBox.setSelectedTextColor(new Color(0xFF0000)); + useBox.setBounds(120, 314, 280, 25); + jFrame.add(useBox); + + JLabel objJLabel = new JLabel("䷽룺"); + objJLabel.setFont(new Font("", Font.PLAIN, 16)); + objJLabel.setBounds(20, 345, 200, 50); + jFrame.add(objJLabel); + JTextField objBox = new JTextField(20); + objBox.setFont(new Font("", Font.PLAIN, 16)); + objBox.setSelectedTextColor(new Color(0xFF0000)); + objBox.setBounds(120, 361, 280, 25); + jFrame.add(objBox); + + JLabel profitCenter = new JLabel("״̬"); + profitCenter.setFont(new Font("", Font.PLAIN, 16)); + profitCenter.setBounds(20, 390, 200, 50); + jFrame.add(profitCenter); + // lovֵ + String[] profitLov = getRealLoveName("RB3_SMZQZT"); + JComboBox profitCenterBox = new JComboBox(profitLov); + profitCenterBox.setFont(new Font("", Font.PLAIN, 16)); + profitCenterBox.setBounds(120, 406, 280, 25); + profitCenterBox.setSelectedIndex(-1); + jFrame.add(profitCenterBox); + + // ȷť + JButton assButton = new JButton("ȷ"); + assButton.setFont(new Font("", Font.PLAIN, 13)); + assButton.setBounds(150, 505, 70, 30); + jFrame.add(assButton); + + // ȡť + JButton register = new JButton("ȡ"); + register.setFont(new Font("", Font.PLAIN, 13)); + register.setBounds(250, 505, 70, 30); + jFrame.add(register); + // ȷť + assButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + TCComponentItemType tccomponentitemtype = null; + // ȡ汾 + String itemRev = null; + // ItemidItemİ汾ţItemͣƣĵλ(Ϊnull) + TCComponentItem item = null; + try { + tccomponentitemtype = (TCComponentItemType) session.getTypeComponent("RB3_GNLBJ"); + itemRev = tccomponentitemtype.getNewRev(null); + + String ordertext = (String) orderTypeText.getText(); + + String name = (String) nameText.getText(); + + String orderText = (String) orderTypeText.getText(); + + String ctrltext = (String) ctrlJLabelText.getText(); + + String comptext = (String) compCodeBox.getText(); + + String factorytext = (String) factoryBox.getText(); + + String usetext = (String) useBox.getText(); + + String objtext = (String) objBox.getText(); + + String profitCentertext = (String) profitCenterBox.getSelectedItem(); + item = tccomponentitemtype.create(itemId, itemRev, "RB3_GNLBJ", "rev", "", null); + TCComponentItemRevision itemRevision = item.getLatestItemRevision(); + f.add("IMAN_reference", item); + itemRevision.setStringProperty("rb3_cph", ordertext); + itemRevision.setStringProperty("rb3_glh", name); + itemRevision.setStringProperty("rb3_jerpbm", orderText); + itemRevision.setStringProperty("rb3_khxmh", ctrltext); + itemRevision.setStringProperty("rb3_khth", comptext); + itemRevision.setStringProperty("rb3_gfzcl", factorytext); + itemRevision.setStringProperty("rb3_dybz", usetext); + itemRevision.setStringProperty("rb3_pfdm", objtext); + itemRevision.setStringProperty("rb3_smzqzt", profitCentertext); + MessageBox.post("ɹ!", "ʾ", MessageBox.INFORMATION); + jFrame.dispose(); + return; + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + MessageBox.post("ʧ!", "ʾ", MessageBox.INFORMATION); + + } + }); + + // رհť + register.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + jFrame.dispose(); + } + }); + // λãĻм + jFrame.setLocationRelativeTo(null); + // ȷʹôڹرհťܹ˳̣ + jFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);// رմڲ˳ + // ֹԴڴСŴ + jFrame.setResizable(false); + // ÿɼ + jFrame.setVisible(true); + } + + // ȡlovֵ + public String[] getRealLoveName(String lovName) throws TCException { + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues projectItemslov = TCComponentListOfValuesType.findLOVByName(lovName); + String[] projectItems = null; + if (projectItemslov != null) { + System.out.println(projectItemslov.toString()); + projectItems = projectItemslov.getListOfValues().getLOVDisplayValues(); + } + return projectItems; + } +} diff --git a/src/com/connor/rb/plm/rb007/ExitDialog.java b/src/com/connor/rb/plm/rb007/ExitDialog.java new file mode 100644 index 0000000..341a603 --- /dev/null +++ b/src/com/connor/rb/plm/rb007/ExitDialog.java @@ -0,0 +1,70 @@ +package com.connor.rb.plm.rb007; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.PropertyLayout; + +public class ExitDialog extends AbstractAIFDialog { + + private JPanel panel; + public Integer y = 0; + private Component com; + + public ExitDialog(Component com) { + this.com = com; + } + + public void run() { + init(); + } + + public void init() { + this.setTitle("˳˵"); + this.setLayout(new BorderLayout()); + this.setPreferredSize(new Dimension(200, 300)); + panel = new JPanel(new PropertyLayout()); + + panel.setPreferredSize(new Dimension(200, 300)); + JLabel label = new JLabel("ȷ˳?"); + + JButton b1 = new JButton("ȷ"); + JButton b2 = new JButton("ȡ"); + panel.add("1.1.center.center", label); + panel.add("2.1.center.center", b1); + panel.add("2.2.center.center", b2); + this.add(panel, BorderLayout.CENTER); + this.centerToScreen(); + this.setVisible(true); + b1.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + y = 1; + + } + + }); + b2.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + y = 0; + dispose(); + } + + }); + + } +} diff --git a/src/com/connor/rb/plm/rb007/G4MDialog.java b/src/com/connor/rb/plm/rb007/G4MDialog.java new file mode 100644 index 0000000..c5d72fe --- /dev/null +++ b/src/com/connor/rb/plm/rb007/G4MDialog.java @@ -0,0 +1,206 @@ +package com.connor.rb.plm.rb007; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import javax.swing.JButton; +import javax.swing.JPanel; + +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.classification.common.AbstractG4MApplication; +import com.teamcenter.rac.classification.common.G4MApplicationPanel; +import com.teamcenter.rac.classification.common.G4MUserAppContext; +import com.teamcenter.rac.classification.common.table.G4MTable; +import com.teamcenter.rac.classification.icm.ICMApplication; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +@SuppressWarnings("serial") +public class G4MDialog extends AbstractAIFDialog { + + private JButton b_ok; + private JButton b_cel; + private ICMApplication app; + private MyG4MContext m_context; + protected TCComponentICO ico; + private String expandClass; + private List revList; + InterfaceAIFComponent iaf; + TCComponentForm form; + TCSession session; + + // public G4MDialog(String expandClass, InterfaceAIFComponent iaf, QZjsbjdBean + // jsbjdBean, TCSession session, TCComponentForm form) { + // super(AIFDesktop.getActiveDesktop(), true); + // this.jsbjdBean=jsbjdBean; + // this.expandClass = expandClass; + // this.iaf = iaf; + // this.session=session; + // this.form=form; + // try { + // this.app = new ICMApplication(); + // this.m_context = new MyG4MContext(app, "k0"); + // } catch (Exception e) { + // e.printStackTrace(); + // } + // initUI(); + // } + public G4MDialog(String expandClass, InterfaceAIFComponent iaf, List revList, + TCSession session) { + super(AIFDesktop.getActiveDesktop(), true); + this.expandClass = expandClass; + this.iaf = iaf; + this.revList = revList; + this.session = session; + try { + this.app = new ICMApplication(); + this.m_context = new MyG4MContext(app, "k0"); + } catch (Exception e) { + e.printStackTrace(); + } + initUI(); + } + + @Override + public void run() { + showDialog(); + } + + private void initUI() { + this.setTitle("ѡȡ"); + this.setLayout(new BorderLayout()); + this.setPreferredSize(new Dimension(1000, 600)); + this.setMinimumSize(new Dimension(640, 480)); + MyG4MPanel panel = new MyG4MPanel(null); + try { + m_context.openComponent(iaf); + panel.initialize(m_context); + this.add(BorderLayout.CENTER, panel); + m_context.getTree().expandToClass(expandClass); + // new Thread(m_context.getClassificationDialog()).start(); + } catch (Exception e) { + e.printStackTrace(); + } + // panel.open(iaf); + this.add(BorderLayout.SOUTH, initBtnPanel()); + addListeners(); + } + + private void addListeners() { + b_ok.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + G4MTable table = m_context.getTablePane().getG4MTable(); + List list = null; + if (table != null) { + ISelection sel = table.getSelection(); + if (sel != null && sel instanceof StructuredSelection) { + list = ((StructuredSelection) sel).toList(); + + } + } + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + if (list == null || list.size() == 0) { + + // ѡҪʹõĶ + MessageBox.post(rb.getString("qxzysyddx07_display.TITLE"), "", MessageBox.INFORMATION); + // KUtil.info(G4MDialog.this, "ѡҪʹõĶ"); + return; + } + if (list.size() > 1) { + // ѡ + MessageBox.post(rb.getString("qxzdhsj07_display.TITLE"), "", MessageBox.INFORMATION); + // KUtil.info(G4MDialog.this, "ѡ"); + return; + } + Object target = list.get(0); + if (target != null && target instanceof TCComponentICO) { + ico = (TCComponentICO) target; + System.out.println(" ico.getClassId()=====" + ico.getClassId()); + + TCComponentItemRevision rev = (TCComponentItemRevision) ico.getClassifiedObject(); + revList.add(rev); + // ͼֽóɹ + MessageBox.post(rb.getString("tzyycg07_display.TITLE"), "ɹ", MessageBox.INFORMATION); + } else { + // ѡݲICO + MessageBox.post(rb.getString("xzdsj07_display.TITLE"), "", MessageBox.INFORMATION); + // KUtil.info(G4MDialog.this, "ѡݲICO"); + return; + } + } + }); + b_cel.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + } + + private JPanel initBtnPanel() { + JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 25, 5)); + this.b_ok = new JButton("ȷ"); + this.b_cel = new JButton("ȡ"); + panel.add(b_ok); + panel.add(b_cel); + return panel; + } + + public class MyG4MContext extends G4MUserAppContext { + + public MyG4MContext(AbstractAIFUIApplication paramAbstractAIFUIApplication, String paramString) + throws Exception { + super(paramAbstractAIFUIApplication, paramString); + } + + @Override + public void setBusy(String paramString) { + } + + @Override + public void setIdle(String paramString) { + } + + } + + public class MyG4MPanel extends G4MApplicationPanel { + + public MyG4MPanel(AbstractG4MApplication paramAbstractG4MApplication) { + super(paramAbstractG4MApplication); + } + + @Override + public void closeSignaled() { + try { + m_context.clear(); + } catch (Exception e) { + e.printStackTrace(); + } + // m_context.openComponent(iaf); + } + + } + +} diff --git a/src/com/connor/rb/plm/rb007/Rb007Action.java b/src/com/connor/rb/plm/rb007/Rb007Action.java new file mode 100644 index 0000000..8b3c16a --- /dev/null +++ b/src/com/connor/rb/plm/rb007/Rb007Action.java @@ -0,0 +1,65 @@ +package com.connor.rb.plm.rb007; + +import com.connor.rb.plm.query.ZCQueryDialog; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.aif.kernel.AbstractAIFSession; +import com.teamcenter.rac.kernel.TCSession; + +public class Rb007Action extends AbstractAIFAction { + private AbstractAIFApplication app; + private String name; + private String itemtype = ""; + + public Rb007Action(AbstractAIFApplication arg0, String arg1, String name) { + super(arg0, arg1); + // TODO Auto-generated constructor stub + this.app = arg0; + this.name = name; + } + + public Rb007Action(AbstractAIFApplication arg0, String arg1, String name, String itemtype) { + super(arg0, arg1); + // TODO Auto-generated constructor stub + this.app = arg0; + this.name = name; + this.itemtype = itemtype; + } + + public void run() { + // TODO Auto-generated method stub + TCSession session = (TCSession)app.getSession(); + Rb007Dialog dia = null; + Rb007DialogLBJ dia1 = null; + Rb007DialogXZCP dia2 = null; + Rb007DialogXZLS dia3 = null; + + if (name.equals("")) { + System.out.println("name1:" + name); + dia = new Rb007Dialog(app, name); + } else if (name.equals("ӳƷ")) { + System.out.println("name1:" + name); + dia2 = new Rb007DialogXZCP(app, name); + } else if (name.equals("")) { + System.out.println("name1:" + name); + dia3 = new Rb007DialogXZLS(app, name, itemtype); + } else { + System.out.println("name2:" + name); + dia1 = new Rb007DialogLBJ(app, name, itemtype); + } + + if (dia != null) { + new Thread(dia).start(); + } else if (dia1 != null) { + System.out.println("Ż Чʼ-----------------------------------"); + session.queueOperation(dia1); + //new Thread(dia1).start(); + } else if (dia2 != null) { + new Thread(dia2).start(); + } else if (dia3 != null) { + new Thread(dia3).start(); + } + + } + +} diff --git a/src/com/connor/rb/plm/rb007/Rb007Dialog.java b/src/com/connor/rb/plm/rb007/Rb007Dialog.java new file mode 100644 index 0000000..93f1bd6 --- /dev/null +++ b/src/com/connor/rb/plm/rb007/Rb007Dialog.java @@ -0,0 +1,2407 @@ +package com.connor.rb.plm.rb007; + +/** +*=============================================================================== +* Copyright (c) 2012-2023 CONNOR Ltd. +* Unpublished - All Rights Reserved +*=============================================================================== +*File description: +* +* CloneCpgyOperation.java +* +* +*=============================================================================== + DATE Name Description of Change + + 2024-01-02 lijh modify 棬ѡһֵW + +=============================================================================== +*/ + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.ResourceBundle; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; + +import com.aspose.cad.internal.ay.iF; +import com.connor.rb.plm.entity.ZC_LBJ_list; +import com.connor.rb.plm.newcombox.RwJComboBox; +import com.connor.rb.plm.rb012.SearchJComItem; +import com.connor.rb.plm.util.ClassAttributeBean; +import com.connor.rb.plm.util.ClassProperty; +import com.connor.rb.plm.util.CodeBean; +import com.connor.rb.plm.util.GetCodeBean; +import com.connor.rb.plm.util.GetNewCode; +import com.connor.rb.plm.util.MenuBean; +import com.connor.rb.plm.util.ParseXML; +import com.connor.rb.plm.util.PlmLocaleUtil; +import com.connor.rb.plm.util.SoaServerUtil; +import com.connor.rb.plm.util.TCUtils; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSKeyLov.KeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.services.loose.core._2011_06.DataManagement.SaveAsOut; + +public class Rb007Dialog extends AbstractAIFDialog { + private AbstractAIFApplication app; + private TCSession session; + private TCPreferenceService service; + private String name; + private MenuBean menuBean; + private JPanel jp1; + private JPanel jp2; + private JPanel classJpanel; + private StringBuilder build = new StringBuilder(); + private List> values; + private List classList = new ArrayList(); + private Map tagMap = new HashMap(); + // private List codeBeanList; + private CodeBean selCodeBean; + private JButton okBut = new JButton("ȷ"); + private JButton button2 = new JButton("ͼֽ"); + private JButton celBut = new JButton("ȡ"); + private GetCodeBean getcode; + private JLabel[] labels1 = null; + // private JComboBox comb = null; + private String url = ""; + private JScrollPane scr2; + private boolean classFlag = true; + private boolean classFlag2 = false; + private Map map2; + private Map> boxMap = new HashMap>(); + private List revList = new ArrayList(); + private List idList = new ArrayList(); + private List typeList = new ArrayList(); + private JLabel nameLabel; + private JComboBox nameComb; + private JComboBox dl; + private JLabel idLabel; + private JTextField idField1; + private JLabel revLabel; + private JComboBox revBox; + private String className2; + private TCComponentItemRevision targetItem; + private TCComponentItem taItem; + private String productNumber = ""; + private String drawingNumber = ""; + private String HeatTreatment = ""; + private Map> attrMap; + private Map> attrMap2; + private Map objMap = new HashMap(); + private Map objMap2 = new HashMap(); + private Map lovMap = new HashMap(); + private Map lovMap2 = new HashMap(); + private List attrList = new ArrayList(); + private List esAttrList = new ArrayList(); + // private List objList = new ArrayList(); + // private List lovList = new ArrayList(); + private List attrList2 = new ArrayList(); + private List esAttrList2 = new ArrayList(); + // private List objList2 = new ArrayList(); + // private List lovList2 = new ArrayList(); + private List markList = new ArrayList(); + private List markList2 = new ArrayList(); + private List isNList = new ArrayList(); + private List isNList2 = new ArrayList(); + private List defaultValueList = new ArrayList(); + private List defaultValueList2 = new ArrayList(); + private List asList = new ArrayList(); + private List esList = new ArrayList(); + // Ż + private AIFComponentContext[] refs; + private TCComponentFolder folder; + private TCComponentItem tccItem; + private String toitemtype; + private int v = 0; + private Map lishu_lov = ZC_LBJ_list.LiShu_lov; + private Map lishu = ZC_LBJ_list.LiShu; + private Map zc_pro_map = new HashMap();// ܳɵԼֵ + // TextField + private List fieldList = new ArrayList(); + // box + private List comboxList = new ArrayList(); + private Map fieldmap = new HashMap<>(); + private Map comboxmap = new HashMap<>(); + private Map jcompMap = new HashMap(); + + private Map MustMap = new HashMap();// +++ǩдӽжǷ + // endŻ + + // private String[] lovVal = new String[] { "ǰ", "׼", "޽Ӵ", "ʽ", + // "ͨ", "A:NBR", "0:", "", "", + // "SN:1805ػ", "ȴ", "", "S:(25% to 35%)", + // "C0","V0","Z0","׼","PC:ﵽC&UƷƾҪ" + // ,"P0:ﵽC&UƷƾҪ","ṹҪƹ","0:˫нǽӴ",":SECC൱",":벿Ŷȷ","BC:35"}; + // private String[] esLovVal = new String[] { "Non", "Standard ball", "Non", + // "Open", "Without vent hole", "A:NBR", + // "0:Black", "Non", "Ball", "SN:1805 temper","Conventional monolithic + // martensite quenching heat treatment", + // "Single", "S:(25% to 35%)", "C0","V0","Z0","Standard","PC:Meet the group C&U + // brand accuracy requirements" + // ,"P0:Meet the group C&U brand accuracy requirements","Other structures need + // to formulate rules","0:Double row angular contact ball bearing" + // ,"Not marked: SECC or equivalent","Other materials: confirm with department + // team for approval","BC:35"}; + + public Rb007Dialog(AbstractAIFApplication app, String name) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.name = name; + this.values = new ArrayList>(); + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + + } + + public Rb007Dialog(AbstractAIFApplication app, String name, String itemtype) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.name = name; + this.values = new ArrayList>(); + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + this.toitemtype = itemtype; + System.out.println("toitemtype-----" + toitemtype); + + } + + @Override + public void run() { + // TODO Auto-generated method stub + getcode = new GetCodeBean(session); + menuBean = getcode.getMenuBean(name); + // codeBeanList = bean.getCodeBeanList(); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HH-mm-ss-SSS"); + String dirsPath = "C:\\Session"; + + String filename = "lscj_display-"+ sdf.format(new Date()) +".txt"; + File login_file = new File(dirsPath,filename); + File path = new File(dirsPath); + if(!path.exists()) { + path.mkdirs(); + } + if(login_file.exists()) { + login_file.delete(); + } + + + + try { + login_file.createNewFile(); + FileWriter fileWriter = new FileWriter(login_file, true); + PrintWriter writer = new PrintWriter(fileWriter); + writer.println("ʼȡxmlʼ̣" + new Date()); + + String lovVal = service.getStringValue("RB3_lovVal_default"); + String esLovVal = service.getStringValue("RB3_esLovVal_default"); + if (lovVal.contains(";")) { + String[] vals = lovVal.split(";"); + String[] esVals = esLovVal.split(";"); + for (int i = 0; i < vals.length; i++) { + asList.add(vals[i]); + esList.add(esVals[i]); + } + } + + writer.println("XMLļ..."); + + ParseXML xml = new ParseXML(); + File file = xml.getSXX("RB3_CPHPJFS", session); + attrMap = xml.parseXMLAttr(file,writer); + writer.println("attrMap:"+attrMap); + if (attrMap == null || attrMap.size() <= 0) { + MessageBox.post("ѡRB3_CPHPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + + File file2 = xml.getSXX("RB3_THPJFS", session); // hEtFB3llJxBjoC + attrMap2 = xml.parseXMLAttr(file2,writer); + writer.println("attrMap2:"+attrMap2); + if (attrMap2 == null || attrMap2.size() <= 0) { + MessageBox.post("ѡRB3_THPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + + writer.println("ȡĿ..."); + + InterfaceAIFComponent targetComp = app.getTargetComponent(); + if (targetComp instanceof TCComponentItemRevision) { + targetItem = (TCComponentItemRevision) targetComp; + tccItem = targetItem.getItem(); + refs = tccItem.whereReferenced(); + // Ż + zc_pro_map = targetItem.getProperties(); + // end + } else if (targetComp instanceof TCComponentItem) { + taItem = (TCComponentItem) targetComp; + targetItem = taItem.getLatestItemRevision(); + tccItem = taItem; + refs = taItem.whereReferenced(); + // Ż + zc_pro_map = taItem.getProperties(); + } + + writer.println("ʼ..."+ new Date()); + init(writer,login_file); + writer.flush(); + writer.close(); + } catch (TCException e) { + MessageBox.post("init()쳣", "WARNING", MessageBox.WARNING); + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * ҳ + * + * @throws TCException + */ + private void init(PrintWriter writer,File login_file) throws TCException { + writer.println("ʼڣʼʼ..." + new Date()); + + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle + .getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + this.setTitle(name); + this.setPreferredSize(new Dimension(860, 900)); + this.setLayout(new BorderLayout()); + + classJpanel = new JPanel(new BorderLayout()); // Խ + jp1 = new JPanel(new BorderLayout()); + jp2 = new JPanel(new PropertyLayout()); + jp1.setPreferredSize(new Dimension(200, 820)); + scr2 = new JScrollPane(jp2); + scr2.setPreferredSize(new Dimension(640, 820)); + classJpanel.add(scr2); + + // ־ + writer.println("JTreeü..." + new Date()); + + JTree tree = getTree(menuBean); + + tree.addKeyListener(new KeyListener() { + + @Override + public void keyTyped(KeyEvent e) { + // κβ + } + + @Override + public void keyPressed(KeyEvent e) { + // κβ + } + + @Override + public void keyReleased(KeyEvent e) { + int keyCode = e.getKeyCode(); + + if (keyCode == 27) { + writer.println("⵽ESCͷ..." + new Date()); + int option = JOptionPane.showOptionDialog(null, "ȷ˳˵", "", 0, 1, null, null, + Integer.valueOf(0)); + if (option == 0) { + writer.println("ûѡ˳˵..." + new Date()); + writer.println("˳"); + dispose(); + } else { + writer.println("ûȡ˳˵..." + new Date()); + return; + } + } + } + }); + + // ־ + writer.println("ʼ..." + new Date()); + + tree.addTreeSelectionListener(new TreeSelectionListener() { + public void valueChanged(TreeSelectionEvent e) { + // objList.clear(); + // objList2.clear(); + // lovList.clear(); + // lovList2.clear(); + + classFlag = true; + classFlag2 = false; + objMap.clear(); + objMap2.clear(); + // zc_pro_map.clear(); + fieldList.clear(); + comboxList.clear(); + fieldmap.clear(); + comboxmap.clear(); + + lovMap.clear(); + lovMap2.clear(); + attrList.clear(); + esAttrList.clear(); + attrList2.clear(); + esAttrList2.clear(); + classList.clear(); + markList.clear(); + markList2.clear(); + isNList.clear(); + isNList2.clear(); + defaultValueList.clear(); + defaultValueList2.clear(); + jp2.removeAll(); + idList.clear(); + + DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) e.getPath().getLastPathComponent(); + int childCount = treeNode.getChildCount(); + writer.println("ǰѡеĽڵ: " + treeNode + " ӽڵ:" + childCount + " (" + new Date() + ")"); + + if (childCount > 0) { + jp2.setVisible(false); + } else { + String names = getNode(treeNode, ""); + selCodeBean = getcode.getCodebean(names); + if (selCodeBean == null) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + // ѡײڵ㣡 + MessageBox.post(rb.getString("qxzzdcjd07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + + writer.println("ʼԪ..." + new Date()); + + JTextField idfield = new JTextField(18); + idList.add(idfield); + JComboBox idbox = new JComboBox(); + idList.add(idbox); + idbox.addItem(" "); + + // 20240102 档ѡһֵW + String[] idstrs = new String[103]; + for (int j = 0; j < 103; j++) { + if (j < 10) { + idstrs[j] = "0" + j; + } else { + // L G + if (j == 100) { + idstrs[j] = "L"; + } else if (j == 101) { + idstrs[j] = "G"; + } else if (j == 102) { + idstrs[j] = "W"; + } else { + idstrs[j] = j + ""; + } + } + } + for (int j = 0; j < idstrs.length; j++) { + idbox.addItem(idstrs[j]); + } + boxMap.put(PlmLocaleUtil.getString("PartNumber"), idbox); + + revLabel = new JLabel(rb.getString("banben_display.TITLE")); + revBox = new JComboBox(); + revBox.setEditable(false); + revBox.addItem("B1"); + String[] revs = service.getStringValues("RB_Revision_id"); + if (revs == null || revs.length <= 0) { + MessageBox.post("ѡRB_Revision_idδ,ϵԱ!!", "", MessageBox.ERROR); + return; + } + for (int i = 0; i < revs.length; i++) { + revBox.addItem(revs[i]); + } + nameLabel = new JLabel(rb.getString("mingcheng_display.TITLE")); + nameComb = new JComboBox(); + nameComb.setEditable(false); + + nameComb.addItem(""); + String[] lbjNames = service.getStringValues("RB3_GNLBJ_names"); + if (lbjNames == null || lbjNames.length <= 0) { + MessageBox.post("ѡRB3_GNLBJ_namesδ,ϵԱ!!", "", MessageBox.ERROR); + return; + } + for (int i = 0; i < lbjNames.length; i++) { + nameComb.addItem(lbjNames[i]); + } + + // Ż + nameComb.setSelectedIndex(1); + // endŻ + + idLabel = new JLabel(rb.getString("zcwlbm_display.TITLE")); + idField1 = new JTextField(18); + + // Ż + try { + idField1.setText(targetItem.getProperty("item_id")); + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + // endŻ + + writer.println("ӽԪصJPanel..." + new Date()); + + jp2.add("1.1.center.center", new JLabel("")); + jp2.add("2.1.center.center", idLabel); + jp2.add("2.2.center.center", idField1); + jp2.add("3.1.center.center", nameLabel); + jp2.add("3.2.center.center", nameComb); + jp2.add("4.1.center.center", new JLabel(PlmLocaleUtil.getString("PartNumber"))); + jp2.add("4.2.center.center", idfield); + jp2.add("4.3.center.center", idbox); + jp2.add("5.1.center.center", revLabel); + jp2.add("5.2.center.center", revBox); + + writer.println("ɹԪ..." + new Date()); + try { + String className = targetItem.getClassificationClass(); + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + writer.println("className============" + className + " (" + new Date() + ")"); + c.load(className); + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + // ȡ + TCComponentICO[] icos = targetItem.getClassificationObjects(); + writer.print("icos:====" + icos + " (" + new Date() + ")"); + + if (icos == null || icos.length <= 0) { + // ѡеûз͵࣬뷢ͣ + MessageBox.post(rb.getString("xzdwlmyfsdfl07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + + Map claMap = new HashMap(); + if (icos != null && icos.length > 0) { + ICSProperty[] icss = icos[0].getICSProperties(true); + + for (ICSProperty ics : icss) { + for (ICSAdminClassAttribute icsa : icsAttrS) { + if (icsa.getAttributeId() == ics.getId()) { + writer.print("icsa.getName():" + icsa.getName() + " (" + new Date() + ")"); + claMap.put(icsa.getName(), ics.getValue()); + } + } + } + } + + ICSAdminClass c2 = classificationService.newICSAdminClass(); + className2 = selCodeBean.getClassID(); + // String xmlClassName = className2.substring(0, 6); + writer.println("className2===========" + className2 + " (" + new Date() + ")"); + // System.out.println("xmlClassName==========="+xmlClassName); + + if (attrMap.containsKey(className2)) { + List nameMarkList = attrMap.get(className2); + String attrNames = nameMarkList.get(0); + String marks = nameMarkList.get(1); + String defaultValues = nameMarkList.get(2); + String isN = nameMarkList.get(3); + if (attrNames.contains(";")) { + String[] attrs = attrNames.split(";"); + String[] markss = marks.split(";"); + String[] valuess = defaultValues.split(";"); + String[] isNs = isN.split(";"); + for (int i = 0; i < attrs.length; i++) { + writer.println("attrs==============" + attrs[i] + " (" + new Date() + ")"); + if (attrs[i].contains("+")) { + String[] attrss = attrs[i].split("\\+"); + attrList.add(attrss[0]); + esAttrList.add(attrss[1]); + markList.add(markss[i]); + defaultValueList.add(valuess[i]); + isNList.add(isNs[i]); + } + } + } + + if (attrMap2.containsKey(className2)) { + List nameMarkList2 = attrMap2.get(className2); + String attrNames2 = nameMarkList2.get(0); + String marks2 = nameMarkList2.get(1); + String defaultValues2 = nameMarkList2.get(2); + String isNs2 = nameMarkList2.get(3); + writer.println("attrNames2============" + attrNames2 + " (" + new Date() + ")"); + if (attrNames2.contains(";")) { + String[] attrs2 = attrNames2.split(";"); + String[] markss2 = marks2.split(";"); + String[] valuess = defaultValues2.split(";"); + String[] isNs2s = isNs2.split(";"); + for (int i = 0; i < attrs2.length; i++) { + if (attrs2[i].contains("+")) { + String[] attrss = attrs2[i].split("\\+"); + attrList2.add(attrss[0]); + esAttrList2.add(attrss[1]); + markList2.add(markss2[i]); + defaultValueList2.add(valuess[i]); + isNList2.add(isNs2s[i]); + } + } + } + } + } + + c2.load(className2); + String cName = c2.getName(); + if (PlmLocaleUtil.getString("BearingAccessories").equals(cName)) { + classFlag = false; + } else if (PlmLocaleUtil.getString("Cage").equals(cName)) { + classFlag2 = true; + } + writer.println("cName===" + cName + " (" + new Date() + ")"); + + ICSAdminClassAttribute[] icsAttrS2 = c2.getAttributes(); + if (icsAttrS2 != null) { + for (ICSAdminClassAttribute attr : icsAttrS2) { + if (attr.isHidden()) { + continue; + } + ClassAttributeBean bean = new ClassAttributeBean(); + if (attr.isReferenceAttribute()) { // + continue; + } + if (attr.isReference()) { + continue; + } + int propID = attr.getAttributeId(); + bean.setId(propID); + String propDisName = attr.getName(); + writer.print("propDisName:" + propDisName + " (" + new Date() + ")"); + bean.setName(propDisName); + + int attrType = attr.getFormat1().getType(); + bean.setType(attrType); + // ÷ + if (claMap != null && claMap.containsKey(propDisName)) { + bean.setVal(claMap.get(propDisName)); + } else { + bean.setVal(""); + } + ICSKeyLov lov1 = attr.getFormat1().getKeyLov(); + lov1 = (lov1 == null ? attr.getFormat2().getKeyLov() : lov1); + if (lov1 != null) { + bean.setIslov(true); + String[] keys = lov1.getKeys(); + Map map1 = new HashMap(); + for (String key : keys) { + KeyLov lov_key = lov1.getKeyLovOfKey(key); + boolean deprecated = lov_key.isDeprecated(); + if (deprecated) { + if (key.equals(bean.getVal())) { + bean.setVal(""); + } + continue; + } + String value = lov1.getValueOfKey(key); + map1.put(value, key); // <ʾֵ,ʵֵ> + if (key.equals(bean.getVal()) && (!bean.getVal().equals(""))) { + bean.setVal(value); + } + } + bean.setLov(map1); + } else { + bean.setIslov(false); + } + + classList.add(bean); + + } + } +// String className = targetItem.getClassificationClass(); +// TCClassificationService classificationService = session.getClassificationService(); +// ICSAdminClass c = classificationService.newICSAdminClass(); +// System.out.println("className============" + className); +// c.load(className); +// ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); +// // ȡ +// TCComponentICO[] icos = targetItem.getClassificationObjects(); +// System.out.print("icos:====" + icos); +// if (icos == null || icos.length <= 0) { +// // ѡеûз͵࣬뷢ͣ +// MessageBox.post(rb.getString("xzdwlmyfsdfl07_display.TITLE"), "ʾ", MessageBox.INFORMATION); +// return; +// } +// Map claMap = new HashMap(); +// if (icos != null && icos.length > 0) { +// +// ICSProperty[] icss = icos[0].getICSProperties(true); +// +// for (ICSProperty ics : icss) { +// for (ICSAdminClassAttribute icsa : icsAttrS) { +// if (icsa.getAttributeId() == ics.getId()) { +// System.out.print("icsa.getName():" + icsa.getName()); +// claMap.put(icsa.getName(), ics.getValue()); +// } +// } +// } +// } +// ICSAdminClass c2 = classificationService.newICSAdminClass(); +// className2 = selCodeBean.getClassID(); +// // String xmlClassName = className2.substring(0, 6); +// System.out.println("className2===========" + className2); +// // System.out.println("xmlClassName==========="+xmlClassName); +// if (attrMap.containsKey(className2)) { +// List nameMarkList = attrMap.get(className2); +// String attrNames = nameMarkList.get(0); +// String marks = nameMarkList.get(1); +// String defaultValues = nameMarkList.get(2); +// String isN = nameMarkList.get(3); +// if (attrNames.contains(";")) { +// String[] attrs = attrNames.split(";"); +// String[] markss = marks.split(";"); +// String[] valuess = defaultValues.split(";"); +// String[] isNs = isN.split(";"); +// for (int i = 0; i < attrs.length; i++) { +// System.out.println("attrs==============" + attrs[i]); +// if (attrs[i].contains("+")) { +// String[] attrss = attrs[i].split("\\+"); +// attrList.add(attrss[0]); +// esAttrList.add(attrss[1]); +// markList.add(markss[i]); +// defaultValueList.add(valuess[i]); +// isNList.add(isNs[i]); +// } +// } +// } +// +// if (attrMap2.containsKey(className2)) { +// List nameMarkList2 = attrMap2.get(className2); +// String attrNames2 = nameMarkList2.get(0); +// String marks2 = nameMarkList2.get(1); +// String defaultValues2 = nameMarkList2.get(2); +// String isNs2 = nameMarkList2.get(3); +// System.out.println("attrNames2============" + attrNames2); +// if (attrNames2.contains(";")) { +// String[] attrs2 = attrNames2.split(";"); +// String[] markss2 = marks2.split(";"); +// String[] valuess = defaultValues2.split(";"); +// String[] isNs2s = isNs2.split(";"); +// for (int i = 0; i < attrs2.length; i++) { +// if (attrs2[i].contains("+")) { +// String[] attrss = attrs2[i].split("\\+"); +// attrList2.add(attrss[0]); +// esAttrList2.add(attrss[1]); +// markList2.add(markss2[i]); +// defaultValueList2.add(valuess[i]); +// isNList2.add(isNs2s[i]); +// } +// } +// } +// } +// } +// c2.load(className2); +// String cName = c2.getName(); +// if (PlmLocaleUtil.getString("BearingAccessories").equals(cName)) { +// classFlag = false; +// } else if (PlmLocaleUtil.getString("Cage").equals(cName)) { +// classFlag2 = true; +// } +// System.out.println("cName===" + cName); +// ICSAdminClassAttribute[] icsAttrS2 = c2.getAttributes(); +// if (icsAttrS2 != null) { +// for (ICSAdminClassAttribute attr : icsAttrS2) { +// if (attr.isHidden()) { +// continue; +// } +// ClassAttributeBean bean = new ClassAttributeBean(); +// if (attr.isReferenceAttribute()) {// +// continue; +// } +// if (attr.isReference()) { +// continue; +// } +// int propID = attr.getAttributeId(); +// bean.setId(propID); +// String propDisName = attr.getName(); +// System.out.print("propDisName:" + propDisName); +// bean.setName(propDisName); +// +// int attrType = attr.getFormat1().getType(); +// bean.setType(attrType); +// // ÷ +// if (claMap != null && claMap.containsKey(propDisName)) { +// bean.setVal(claMap.get(propDisName)); +// } else { +// bean.setVal(""); +// } +// ICSKeyLov lov1 = attr.getFormat1().getKeyLov(); +// lov1 = (lov1 == null ? attr.getFormat2().getKeyLov() : lov1); +// if (lov1 != null) { +// bean.setIslov(true); +// String[] keys = lov1.getKeys(); +// Map map1 = new HashMap(); +// for (String key : keys) { +// KeyLov lov_key = lov1.getKeyLovOfKey(key); +// boolean deprecated = lov_key.isDeprecated(); +// if (deprecated) { +// if (key.equals(bean.getVal())) { +// bean.setVal(""); +// } +// continue; +// } +// String value = lov1.getValueOfKey(key); +// map1.put(value, key);// <ʾֵ,ʵֵ> +// if (key.equals(bean.getVal()) && (!bean.getVal().equals(""))) { +// bean.setVal(value); +// } +// } +// bean.setLov(map1); +// } else { +// bean.setIslov(false); +// } +// +// classList.add(bean); +// +// } +// } + } catch (TCException e1) { + e1.printStackTrace(); + } + + labels1 = new JLabel[classList.size()]; + writer.print("classList.size():" + classList.size()); + for (int i = 0; i < classList.size(); i++) { + JComponent jcomp = null; + ClassAttributeBean bean = classList.get(i); + String attrName = bean.getName(); + int propID = bean.getId(); + labels1[i] = new JLabel(attrName); + jp2.add((i + 6) + ".1.center.top", labels1[i]); + labels1[i].setBounds(5, 5, 5, 5); + String value = bean.getVal(); + writer.println("ĬֵΪ:" + value); + if (bean.isIslov()) { + JComboBox comb = new JComboBox(); + // Ż + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + // end + comb.setEditable(false); + comb.setSize(new Dimension(60, 40)); + if (classFlag2) { + if ((PlmLocaleUtil.getString("heatTreatment")).equals(attrName)) { + comb.addItem(""); + HeatTreatment = value; + } else { + comb.addItem(value); + } + } else { + comb.addItem(value); + } + for (Entry entry : bean.getLov().entrySet()) { + if (i == 0) { + writer.println("entry.getKey()====" + entry.getKey()); + } + if (!(value.equals(entry.getKey()))) { + comb.addItem(entry.getKey()); + } + } + // Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + writer.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(comb, tip); + } + } + + }); + // end + map2 = new HashMap(); + map2.put("JComboBox", comb); + values.add(map2); + jp2.add((i + 6) + ".2.center.top", comb); + jp2.add((i + 6) + ".3.center.top", jt); + jp2.add((i + 6) + ".4.center.top", bu); + if (attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, comb); + lovMap.put(attrName, "yes"); + } + if (attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, comb); + lovMap2.put(attrName, "yes"); + } + + if ((PlmLocaleUtil.getString("Category")).equals(attrName)) { + typeList.add(comb); + } + jcomp = comb; + } else { + JTextField field = new JTextField(18); + field.setText(value); + map2 = new HashMap(); + map2.put("JTextField", field); + values.add(map2); + jp2.add((i + 6) + ".2.center.top", field); + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName)) { + JComboBox box = new JComboBox(); + // Ż + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + // end + box.addItem(" "); + String[] strs = new String[] { "C0", "C2", "C3", "C4", "C5" }; + for (int j = 0; j < strs.length; j++) { + box.addItem(strs[j]); + } + // Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + writer.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(box, tip); + } + } + + }); + boxMap.put(attrName, box); + jp2.add((i + 6) + ".3.center.top", box); + jp2.add((i + 6) + ".4.center.top", jt); + jp2.add((i + 6) + ".5.center.top", bu); + } + if (attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, field); + lovMap.put(attrName, "no"); + } + if (attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, field); + lovMap2.put(attrName, "no"); + } + jcomp = field; + } + v = i + 7; + + if (propID == 660113 || propID == 660114 || propID == 660115) { + jcompMap.put(propID, jcomp); + } + } + + // Ż + jp2.add(v + ".1.center.top", new JLabel(" ")); + jp2.add(v + ".2.center.top", new JLabel("**********************")); + v += 1; + // λ + jp2.add(v + ".1.center.top", new JLabel("λ")); + try { + tagMap.clear(); + dl = new JComboBox(); + dl.setSize(new Dimension(60, 40)); + dl.setName("uom_tag"); + TCProperty zclov1; + TCComponentItem oldItem = targetItem.getItem(); + zclov1 = oldItem.getTCProperty("uom_tag"); + + TCComponentListOfValues zcprolov1 = zclov1.getLOV(); + String[] comboxitems1; + JTextField jt1 = new JTextField(9); + JButton bu1 = new JButton(""); + if (zcprolov1 != null) { + comboxitems1 = zcprolov1.getListOfValues().getLOVDisplayValues(); + TCComponent[] tags = zcprolov1.getListOfValues().getTagListOfValues(); + for (int flag = 0; flag < comboxitems1.length; flag++) { + tagMap.put(comboxitems1[flag], tags[flag]); + } + ComboBoxModel model1 = new DefaultComboBoxModel(comboxitems1); + dl.setModel(model1); + bu1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip1 = jt1.getText(); + writer.println("" + tip1); + if (tip1.length() > 0) { + SearchJComItem.changeBox(dl, tip1); + } + } + + }); + // comboxList.add(dl); + } + dl.setSelectedItem(oldItem.getProperty("uom_tag")); + // if(!(ZC_LBJ_list.LBJDisPros.get(i)).equals("ʱϱʶ")) { + dl.setSelectedIndex(-1); + jp2.add(v + ".2.center.top", dl); + jp2.add((v) + ".3.center.top", jt1); + jp2.add((v) + ".4.center.top", bu1); + v += 1; + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + // λ + MustMap.put("λ", dl); + +// for(String s:lishu_lov.keySet()) { +// String val = lishu_lov.get(s); +// jp2.add(v+".1.center.top",new JLabel(val)); +// JComboBox lishu_comb=new JComboBox(); +// lishu_comb.setEditable(false); +// lishu_comb.setSize(new Dimension(60,40)); +// try { +// TCProperty zcLov_val = targetItem.getTCProperty(s); +// TCComponentListOfValues lov_val = zcLov_val.getLOV(); +// if(lov_val!=null) { +// String[] comboxitems=lov_val.getListOfValues().getLOVDisplayValues(); +// ComboBoxModel model = new DefaultComboBoxModel(comboxitems); +// lishu_comb.setModel(model); +// comboxList.add(lishu_comb); +// } +// lishu_comb.setSelectedItem(zc_pro_map.get(s)); +// jp2.add(v+".2.center.top",lishu_comb); +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// lishu_comb.setName(s); +// v++; +// } +// for(String m:lishu.keySet()) { +// String val=lishu.get(m); +// jp2.add(v+".1.center.top",new JLabel(val)); +// JTextField jf=new JTextField(18); +// jf.setName(m); +// jf.setText(zc_pro_map.get(m)); +// fieldList.add(jf); +// jp2.add(v+".2.center.top",jf); +// v++; +// } + if ("RB3_GNZC".equals(toitemtype)) { + writer.println("3------------------------------------------------"); + for (int i = 0; i < ZC_LBJ_list.GNZCPros.size(); i++) { + ZC_LBJ_list.LBJPros.size(); + + writer.println("GNZCProsѭ" + i + ",ҪӵΪ" + ZC_LBJ_list.GNZCDisPros.get(i) + "(" + + ZC_LBJ_list.GNZCPros.get(i) + ")"); +// if ((ZC_LBJ_list.GNZCDisPros.get(i)).equals("Ʒ") +// || (ZC_LBJ_list.GNZCDisPros.get(i)).equals("ͼ")) { +// +// continue; +// } + jp2.add((v) + ".1.center.top", new JLabel(ZC_LBJ_list.GNZCDisPros.get(i))); + boolean b = ZC_LBJ_list.map.containsKey(ZC_LBJ_list.GNZCPros.get(i)); + try { + if (b) { + + writer.println("Lov"); + // lovֵ + String[] profitLov = getRealLoveName(ZC_LBJ_list.GNZCPros.get(i),writer); + JComboBox zcBox = new JComboBox(profitLov); + zcBox.setSize(new Dimension(60, 40)); + zcBox.setName(ZC_LBJ_list.GNZCDisPros.get(i)); +// TCProperty zclov = ((TCComponentItemRevision) targetItem) +// .getTCProperty(ZC_LBJ_list.GNZCDisPros.get(i)); +// TCComponentListOfValues zcprolov = zclov.getLOV(); +// String[] comboxitems; +// JTextField jt = new JTextField(9); +// //JButton bu = new JButton(""); +// if (zcprolov != null) { +// comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); +// ComboBoxModel model = new DefaultComboBoxModel(comboxitems); +// zcBox.setModel(model); +//// bu.addActionListener(new ActionListener() { +//// @Override +//// public void actionPerformed(ActionEvent e) { +//// // TODO Auto-generated method stub +//// String tip = jt.getText(); +//// writer.println("" + tip); +//// if (tip.length() > 0) { +//// SearchJComItem.changeBox(zcBox, tip); +//// } +//// } +//// +//// }); +// comboxList.add(zcBox); +// } +// +// zcBox.setSelectedItem(zc_pro_map.get(ZC_LBJ_list.GNZCDisPros.get(i))); +// // if(!(ZC_LBJ_list.LBJDisPros.get(i)).equals("ʱϱʶ")) { +// zcBox.setSelectedIndex(-1); +// // } + + jp2.add(v + ".2.center.top", zcBox); + // jp2.add((v) + ".3.center.top", jt); + // jp2.add((v) + ".4.center.top", bu); + // +++ + MustMap.put(ZC_LBJ_list.GNZCDisPros.get(i), zcBox); + // +++ + } else { + JTextField field = new JTextField(18); + field.setName(ZC_LBJ_list.GNZCPros.get(i)); + jp2.add(v + ".2.center.top", field); + fieldList.add(field); + // +++ + MustMap.put(ZC_LBJ_list.GNZCDisPros.get(i), field); + // +++ + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + v++; + + } + } else { + for (int i = 0; i < ZC_LBJ_list.LBJPros.size(); i++) { + + writer.println("LBJProsѭ" + i + ",ҪӵΪ" + ZC_LBJ_list.LBJDisPros.get(i) + "(" + + ZC_LBJ_list.LBJPros.get(i) + ")"); + if ((ZC_LBJ_list.LBJDisPros.get(i)).equals("Ʒ") + || (ZC_LBJ_list.LBJDisPros.get(i)).equals("ͼ")) { + + continue; + } + jp2.add((v) + ".1.center.top", new JLabel(ZC_LBJ_list.LBJDisPros.get(i))); + boolean b = ZC_LBJ_list.map.containsKey(ZC_LBJ_list.LBJPros.get(i)); + try { + if (b) { + + writer.println("Lov"); + if (ZC_LBJ_list.LBJPros.get(i).equals("rb3_scgc") + || ZC_LBJ_list.LBJPros.get(i).equals("rb3_yyly")) { + // writer.println("Ϊ"); + String na = ZC_LBJ_list.LBJPros.get(i); + String[] vals = ((TCComponentItemRevision) targetItem).getTCProperty(na) + .getStringValueArray(); + JComboBox nbox = new RwJComboBox(new String[] { "" }); + nbox.setEditable(true); + TCProperty zclov = ((TCComponentItemRevision) targetItem) + .getTCProperty(ZC_LBJ_list.LBJPros.get(i)); + TCComponentListOfValues zcprolov = zclov.getLOV(); + List disVal = new ArrayList(); + String[] comboxitems; + for (int a = 0; a < vals.length; a++) { + if (vals[a] != null && !vals[a].equals("")) { + String disname = zcprolov.getListOfValues() + .getDisplayableValue(vals[a]); + disVal.add(disname); + } + } + if (zcprolov != null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + // ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + + nbox = new RwJComboBox(comboxitems); + nbox.setEditable(true); + nbox.setName(na); + nbox.setSize(new Dimension(60, 40)); + if (disVal.size() > 0) { + StringBuilder sb = new StringBuilder(); + for (int t = 0; t < disVal.size(); t++) { + if (t != (vals.length - 1)) { + + sb.append(disVal.get(t)); + sb.append(","); + } else { + sb.append(disVal.get(t)); + } + } + JTextField ed = (JTextField) nbox.getEditor().getEditorComponent(); + ed.setText(sb.toString()); + } + comboxList.add(nbox); + } + + jp2.add(v + ".2.center.top", nbox); + + // +++ + MustMap.put(ZC_LBJ_list.LBJDisPros.get(i), nbox); + // +++ + } else { + JComboBox zcBox = new JComboBox(); + zcBox.setSize(new Dimension(60, 40)); + zcBox.setName(ZC_LBJ_list.LBJPros.get(i)); + TCProperty zclov = ((TCComponentItemRevision) targetItem) + .getTCProperty(ZC_LBJ_list.LBJPros.get(i)); + if (zclov == null) { + zclov = ((TCComponentItemRevision) targetItem).getTCProperty("rb3_smzqtz"); + } + TCComponentListOfValues zcprolov = zclov.getLOV(); + String[] comboxitems; + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + if (zcprolov != null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + comboxitems = prependEmptyString(comboxitems); + ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + zcBox.setModel(model); + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + writer.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(zcBox, tip); + } + } + + }); + comboxList.add(zcBox); + } + + zcBox.setSelectedItem(zc_pro_map.get(ZC_LBJ_list.LBJPros.get(i))); + // if(!(ZC_LBJ_list.LBJDisPros.get(i)).equals("ʱϱʶ")) { + zcBox.setSelectedIndex(-1); + // } + + jp2.add(v + ".2.center.top", zcBox); + jp2.add((v) + ".3.center.top", jt); + jp2.add((v) + ".4.center.top", bu); + // +++ + MustMap.put(ZC_LBJ_list.LBJDisPros.get(i), zcBox); + // +++ + } + } else { + JTextField field = new JTextField(18); + field.setName(ZC_LBJ_list.LBJPros.get(i)); + if ((ZC_LBJ_list.LBJDisPros.get(i)).equals("û")) { + field.setText(zc_pro_map.get(ZC_LBJ_list.LBJPros.get(i))); + } + if ((ZC_LBJ_list.LBJDisPros.get(i)).equals("")) { + continue; + } + jp2.add(v + ".2.center.top", field); + fieldList.add(field); + // +++ + MustMap.put(ZC_LBJ_list.LBJDisPros.get(i), field); + // +++ + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + v++; + } + } + + jp2.setVisible(true); + jp2.validate(); + jp2.repaint(); + scr2.validate(); + } + } + }); + JScrollPane scrollPane = new JScrollPane(tree); + scrollPane.setPreferredSize(new Dimension(250, 250)); + + // ӹ嵽 + jp1.add(scrollPane, BorderLayout.CENTER); + // jp2.setVisible(false); + classJpanel.add(scr2); + JSplitPane splitPane = new JSplitPane(); + splitPane.setOneTouchExpandable(true);// ÷ָʾͷ + splitPane.setContinuousLayout(true);// ͷػͼ + splitPane.setLeftComponent(new JScrollPane(jp1)); + splitPane.setRightComponent(new JScrollPane(classJpanel)); + JPanel titlePanel = new JPanel(new FlowLayout());// Խ + + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(button2); + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(okBut); + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(celBut); + + this.add(splitPane, BorderLayout.CENTER); + this.add(titlePanel, BorderLayout.SOUTH); + // add("1.1.center.center", splitPane); + // add("1.1.center.center", jp1); + // add("1.2.center.center", classJpanel); + // add("2.1.center.center", button2); + // add("2.2.center.center", okBut); + // add("2.3.center.center", celBut); + + button2.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + writer.println("׼"); + G4MDialog classDialog = new G4MDialog("˱", null, revList, session); + new Thread(classDialog).start(); + } + }); + + okBut.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + try { + createItem(login_file); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + // setVisible(false); + } + + }); + celBut.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + writer.println("ȡ"); + setVisible(false); + } + }); + this.setVisible(true); + this.centerToScreen(); + // this.pack(); + } + + /** + * ǰһַ + * @param items ԭʼ + * @return µ飬ַ + */ + private static String[] prependEmptyString(String[] items) { + String[] newItems = new String[items.length + 1]; + newItems[0] = ""; // ĵһλӿַ + System.arraycopy(items, 0, newItems, 1, items.length); // ԭݵ + return newItems; + } + /* + * ϴ + */ + public void createItem(File login_file) throws IOException { + // +++жϱ + FileWriter fileWriter = new FileWriter(login_file, true); + PrintWriter writer = new PrintWriter(fileWriter); + writer.println("=============" + new Date()); + String[] mustAttributes = service.getStringValues("RB_CreateRequiredAttribute_ls"); +// writer.println("=======>RB_CreateRequiredAttribute_lsѡֵ" + Arrays.toString(mustAttributes)); +// writer.println("=======>attrList"+attrList.toString()); +// writer.println("=======>esAttrList"+esAttrList.toString());MustMap +// writer.println("MustMap.size====>" + MustMap.size()); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (mustAttributes != null && mustAttributes.length > 0) { + for (int i = 0; i < mustAttributes.length; i++) { + writer.println("==>ԣ" + mustAttributes[i]); + if (MustMap.containsKey(mustAttributes[i])) { + + if (MustMap.get(mustAttributes[i]) instanceof JComboBox) { + JComboBox box = (JComboBox) MustMap.get(mustAttributes[i]); + if (box != null) { +// writer.println("boxݣ" + box.getSelectedItem()); + if (box.getSelectedItem() == null || ((String) box.getSelectedItem()).equals("")) { + // δд + MessageBox.post(mustAttributes[i] + "," + rb.getString("sxwtx07_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + return; + } + } + } else if (MustMap.get(mustAttributes[i]) instanceof JTextField) { + JTextField field = (JTextField) MustMap.get(mustAttributes[i]); + if (field != null) { +// writer.println("boxݣ" + field.getText()); + if (field.getText() == null || ((String) field.getText()).equals("")) { + // δд + MessageBox.post("" + mustAttributes[i] + "," + rb.getString("sxwtx07_display.TITLE"), + "ʾ", MessageBox.INFORMATION); + return; + } + } + } + } +// if(attrList.contains(mustAttributes[i])) { +// writer.println("attrList+"+mustAttributes[i]); +// JComboBox box=(JComboBox) objMap.get(mustAttributes[i]); +// if(box!=null) { +// writer.println("boxݣ"+box.getSelectedItem()); +// if(box.getSelectedItem()==null||((String)box.getSelectedItem()).equals("")) { +// MessageBox.post(""+mustAttributes[i]+"δд", "ʾ", MessageBox.INFORMATION); +// return; +// } +// } +// }else if(esAttrList.contains(mustAttributes[i])) { +// writer.println("esAttrList"+mustAttributes[i]); +// JComboBox box=(JComboBox) objMap.get(mustAttributes[i]); +// if(box!=null) { +// writer.println("boxݣ"+box.getSelectedItem()); +// if(box.getSelectedItem()==null||((String)box.getSelectedItem()).equals("")) { +// MessageBox.post(""+mustAttributes[i]+"δд", "ʾ", MessageBox.INFORMATION); +// return; +// } +// } +// } + } + } else { +// writer.println("RB_CreateRequiredAttributeѡδ"); + } + + writer.println("========Լ======="+ new Date()); + // +++ + + // TODO Auto-generated method stub + String jhID = ""; + try { + if (idList != null && idList.size() > 0) { + JTextField idField = (JTextField) idList.get(0); + JComboBox idbox = (JComboBox) idList.get(1); + String id = idField.getText(); + String boxID = (String) idbox.getSelectedItem(); + // if ("".equals(id.trim()) && "".equals(boxID.trim())) { + // MessageBox.post("δд", "ʾ", MessageBox.INFORMATION); + // return; + // } + if ("".equals(id.trim())) { + id = boxID.trim(); + } + jhID = id; + writer.println("jhIDΪ: " + jhID + " (" + new Date() + ")"); + } + + String typeID = ""; + if (typeList != null && typeList.size() > 0) { + JComboBox idComb = typeList.get(0); + typeID = (String) idComb.getSelectedItem(); + if (typeID.indexOf("Ʒ") >= 0 || typeID.indexOf("Finished product") >= 0) { + typeID = ""; + } else if (typeID.indexOf("") >= 0 || typeID.indexOf("Turning workpiece") >= 0) { + typeID = "C"; + } else if (typeID.indexOf("ȴ") >= 0 || typeID.indexOf("Heat treatment parts") >= 0) { + typeID = "R"; + } else if (typeID.indexOf("շ伷") >= 0 + || typeID.indexOf("Cold rolled parts or cold extrusion parts") >= 0) { + typeID = "D"; + } else if (typeID.indexOf("ͼ") >= 0 || typeID.indexOf("Forge piece") >= 0) { + typeID = "D"; + } + writer.println("typeIDΪ: " + typeID + " (" + new Date() + ")"); + } + + String item_type = ""; + if (selCodeBean != null) { + item_type = selCodeBean.getType(); + } else { + MessageBox.post(rb.getString("qxzzdcjd07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + writer.println("item_typeΪ: " + item_type + " (" + new Date() + ")"); + + String targetId = idField1.getText(); + if ("".equals(targetId.trim())) { + // дܳϱţ + MessageBox.post(rb.getString("qtxwlzcbh07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + writer.println("targetIdΪ: " + targetId + " (" + new Date() + ")"); + + // String newID = targetId + jhID + typeID; + String newID = targetId + jhID; + writer.println("newIDΪ: " + newID + " (" + new Date() + ")"); + + String revID = (String) revBox.getSelectedItem(); + String itemName = (String) nameComb.getSelectedItem(); + + if (classFlag) { + productNumber = splicValue(defaultValueList, attrList, esAttrList, objMap, markList, isNList, lovMap , writer); + drawingNumber = splicValue(defaultValueList2, attrList2, esAttrList2, objMap2, markList2, isNList2, + lovMap2, writer); + + writer.println("productNumberΪ: " + productNumber + " (" + new Date() + ")"); + writer.println("drawingNumberΪ: " + drawingNumber + " (" + new Date() + ")"); + if (productNumber == null || drawingNumber == null) { + writer.println("ƷŻͼֽΪգ (" + new Date() + ")"); + return; + } + } else { + + productNumber = targetItem.getStringProperty("rb3_th") + jhID; + writer.println("productNumberΪ: " + productNumber + " (" + new Date() + ")"); + drawingNumber = targetItem.getStringProperty("rb3_th") + jhID; + writer.println("drawingNumberΪ: " + drawingNumber + " (" + new Date() + ")"); + } + + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(item_type); + TCComponentItem find = itemType.find(newID); + if (find != null) { + writer.println(" " + newID + " Ѵ (" + new Date() + ")"); + MessageBox.post(":" + newID + "Ѵ,޷!", "", MessageBox.ERROR); + return; + } +// if (idList != null && idList.size() > 0) { +// JTextField idField = (JTextField) idList.get(0); +// JComboBox idbox = (JComboBox) idList.get(1); +// String id = idField.getText(); +// String boxID = (String) idbox.getSelectedItem(); +//// if ("".equals(id.trim()) && "".equals(boxID.trim())) { +//// MessageBox.post("δд", "ʾ", MessageBox.INFORMATION); +//// return; +//// } +// if ("".equals(id.trim())) { +// id = boxID.trim(); +// } +// jhID = id; +// } +// String typeID = ""; +// if (typeList != null && typeList.size() > 0) { +// JComboBox idComb = typeList.get(0); +// typeID = (String) idComb.getSelectedItem(); +// if (typeID.indexOf("Ʒ") >= 0 || typeID.indexOf("Finished product") >= 0) { +// typeID = ""; +// } else if (typeID.indexOf("") >= 0 || typeID.indexOf("Turning workpiece") >= 0) { +// typeID = "C"; +// } else if (typeID.indexOf("ȴ") >= 0 || typeID.indexOf("Heat treatment parts") >= 0) { +// typeID = "R"; +// } else if (typeID.indexOf("շ伷") >= 0 +// || typeID.indexOf("Cold rolled parts or cold extrusion parts") >= 0) { +// typeID = "D"; +// } else if (typeID.indexOf("ͼ") >= 0 || typeID.indexOf("Forge piece") >= 0) { +// typeID = "D"; +// } +// } +// String item_type = ""; +// if (selCodeBean != null) { +// item_type = selCodeBean.getType(); +// } else { +// MessageBox.post(rb.getString("qxzzdcjd07_display.TITLE"), "ʾ", MessageBox.INFORMATION); +// return; +// } +// String targetId = idField1.getText(); +// if ("".equals(targetId.trim())) { +// // дܳϱţ +// MessageBox.post(rb.getString("qtxwlzcbh07_display.TITLE"), "ʾ", MessageBox.INFORMATION); +// return; +// } +// // String newID = targetId + jhID + typeID; +// String newID = targetId + jhID; +// writer.println("targetId======" + targetId); +// writer.println("jhID======" + jhID); +// writer.println("typeID======" + typeID); +// String revID = (String) revBox.getSelectedItem(); +// String itemName = (String) nameComb.getSelectedItem(); +// if (classFlag) { +// productNumber = splicValue(defaultValueList, attrList, esAttrList, objMap, markList, isNList, lovMap); +// drawingNumber = splicValue(defaultValueList2, attrList2, esAttrList2, objMap2, markList2, isNList2, +// lovMap2); +// +// writer.println("productNumber============" + productNumber); +// writer.println("drawingNumber============" + drawingNumber); +// if (productNumber == null || drawingNumber == null) { +// return; +// } +// } else { +// productNumber = targetItem.getStringProperty("rb3_th") + jhID; +// drawingNumber = targetItem.getStringProperty("rb3_th") + jhID; +// writer.println("productNumber============" + productNumber); +// writer.println("drawingNumber============" + drawingNumber); +// } +// +// TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(item_type); +// TCComponentItem find = itemType.find(newID); +// if (find != null) { +// MessageBox.post(":" + newID + "Ѵ,޷!", "", MessageBox.ERROR); +// return; +// } + // Ż + writer.println("òѯRBSearchLBJCPHǷظ"+ new Date()); + List compList = queryObject("RBSearchLBJCPH", new String[] { "Ʒ" }, + new String[] { productNumber }); + if (compList != null) { + if (compList.size() > 0) { + String nID = newID.substring(0, 2); + + for (int j = 0; j < compList.size(); j++) { + writer.println("жitem_idǰλǷͬ"); + String compID = compList.get(j).getProperty("item_id"); + String cID = compID.substring(0, 2); + if (nID.equals(cID)) { + MessageBox.post("ϵͳѴڲƷΪ" + productNumber + "ϣ룡", "", + MessageBox.INFORMATION); + return; + } + } + } + } + writer.println(""+ new Date()); + // endŻ + TCComponent uom = null; + String dlval = (String) dl.getSelectedItem(); + if (dlval == null || dlval.equals("")) { + MessageBox.post("λѡ", "", MessageBox.INFORMATION); + return; + } else { + TCComponent tcComponent = tagMap.get(dlval); + uom = tcComponent; + } + + TCComponentItem itemComp = itemType.create(newID, revID, item_type, itemName, null, uom); + getFolder(); +// session.getUser().getHomeFolder().add("contents", itemComp); +// session.getUser().getHomeFolder().refresh(); + folder.add("contents", itemComp); + folder.refresh(); + TCComponentItemRevision itemRev = itemComp.getLatestItemRevision(); + + // Ż + for (int k = 0; k < fieldList.size(); k++) { + JTextField jt = (JTextField) fieldList.get(k); + String key = jt.getName(); + String val = jt.getText(); + fieldmap.put(key, val); + } + for (int m = 0; m < comboxList.size(); m++) { + JComboBox cbo = (JComboBox) comboxList.get(m); + cbo.setEditable(false); + String key = cbo.getName(); + writer.println("comboxNameΪ:" + key); + + if (key.equals("rb3_scgc") || key.equals("rb3_yyly")) { + JTextField ed = (JTextField) cbo.getEditor().getEditorComponent(); + String text = ed.getText(); + + if (!text.equals("") && text != null) { + List proList = new ArrayList<>(); + String[] split = text.split(","); + TCProperty tclov = ((TCComponentItemRevision) targetItem).getTCProperty(key); + TCComponentListOfValues lov = tclov.getLOV(); + for (int p = 0; p < split.length; p++) { + String realVal = (String) lov.getListOfValues().getRealValue(split[p]); + proList.add(realVal); + } + Object[] array = proList.toArray(); + String[] svals = new String[array.length]; + for (int s = 0; s < array.length; s++) { + svals[s] = (String) array[s]; + } + itemRev.getTCProperty(key).setStringValueArray(svals); + } + } else { + // ж ܳ 㲿 + + if (targetItem.getType().equals("RB3_GNLBJRevision")) { + String val = (String) cbo.getSelectedItem(); + TCProperty tclov = ((TCComponentItemRevision) targetItem).getTCProperty("rb3_smzqtz"); + TCComponentListOfValues lov = tclov.getLOV(); + String realVal = (String) lov.getListOfValues().getRealValue(val); + writer.println("ѡеֵΪ1:" + val); + comboxmap.put("rb3_smzqtz", realVal); + } else if (targetItem.getType().equals("RB3_GNZCRevision")) { + String val = (String) cbo.getSelectedItem(); + TCProperty tclov = ((TCComponentItemRevision) targetItem).getTCProperty("rb3_smzqzt"); + TCComponentListOfValues lov = tclov.getLOV(); + String realVal = (String) lov.getListOfValues().getRealValue(val); + writer.println("ѡеֵΪ2:" + val); + comboxmap.put("rb3_smzqtz", realVal); + } else { + String val = (String) cbo.getSelectedItem(); + TCProperty tclov = ((TCComponentItemRevision) targetItem).getTCProperty(key); + TCComponentListOfValues lov = tclov.getLOV(); + String realVal = (String) lov.getListOfValues().getRealValue(val); + writer.println("ѡеֵΪ3:" + val); + comboxmap.put(key, realVal); + } + } + + } + itemRev.setProperties(fieldmap); + itemRev.setProperties(comboxmap); + + // endŻ + + String statu = ""; + if ("A1".equals(revID)) { + statu = ":Conceptual design"; + } else if ("B1".equals(revID)) { + statu = ":Product design"; + } else if ("R1".equals(revID)) { + statu = ":Process design/Sample delivery"; + } else if ("P1".equals(revID)) { + statu = "P:Pilot production/small batch"; + } else if ("M1".equals(revID)) { + statu = "M:Mass production"; + } + + itemRev.setStringProperty("rb3_cph", productNumber); + itemRev.setStringProperty("rb3_smzqzt", statu); + itemRev.setStringProperty("rb3_jh", jhID); + + String item_id = targetItem.getProperty("item_id"); + String id = dealItemId(item_id,writer); + if (id != null) { + build.append(id); + build.append(drawingNumber); + } else { + build.append(drawingNumber); + } + boolean glhFlag = false; + if ("RB3_GNLBJ".equals(item_type) || "RB3_GNZC".equals(toitemtype)) { + writer.println("4------------------------------------------------"); +// itemRev.setStringProperty("rb3_glh", drawingNumber); + // itemRev.setStringProperty("rb3_glh", build.toString()); + String glh = fieldmap.get("rb3_glh"); + itemRev.setStringProperty("rb3_glh", glh); + if (revList.size() > 0) { + TCComponentItemRevision picItem = revList.get(0); + TCComponent[] pics = picItem.getReferenceListProperty("TC_Is_Represented_By"); + for (int i = 0; i < pics.length; i++) { + itemRev.add("TC_Is_Represented_By", pics[i]); + } + // picItem.add("RB3_GLWL", itemRev); + } else { + String[] keys = new String[] { " ID" }; + String[] values = new String[] { glh }; + List tzList = queryObject(" ID", keys, values); + if (tzList != null) { + try { + if (targetItem.getType().equals("RB3_GNLBJRevision")) { + for (int i = 0; i < tzList.size(); i++) { + if (tzList.get(i) instanceof TCComponentItem) { + TCComponentItem LJH = ((TCComponentItem) tzList.get(i)); + if (LJH.getType().equals("RB3_GNLJT")) { + TCComponentItemRevision LJTRev = LJH.getLatestItemRevision(); + // folder.add("contents", tzList.get(0)); + folder.refresh(); + itemRev.add("TC_Is_Represented_By", LJTRev); + glhFlag = true; + break; + } + + } + } + } else if (targetItem.getType().equals("RB3_GNZCRevision")) { + for (int i = 0; i < tzList.size(); i++) { + if (tzList.get(i) instanceof TCComponentItem) { + TCComponentItem CPT = ((TCComponentItem) tzList.get(i)); + if (CPT.getType().equals("RB3_GNCPT")) { + TCComponentItemRevision CPTRev = CPT.getLatestItemRevision(); + // folder.add("contents", tzList.get(0)); + folder.refresh(); + itemRev.add("TC_Is_Represented_By", CPTRev); + glhFlag = true; + break; + } + + } + } + } + + } catch (TCException e) { + // TODO: handle exception + e.printStackTrace(); + MessageBox.post("Ȩ޲㣬ͼֽ޷ʴʧܣ", "ʾ", 2); + return; + } + + } + // ŵͼֽδϵͳҵ ½ + if (!glhFlag) { + try { + TCComponentItemType typeComponent = (TCComponentItemType) session + .getTypeComponent("RB3_GNLJT"); + TCComponentItem LJTItem = typeComponent.create(glh, "V1", "RB3_GNLJT", "", "", null); + if (LJTItem != null) { + TCComponentItemRevision LJTRev = LJTItem.getLatestItemRevision(); + // folder.add("contents", LJTItem); + folder.refresh(); + itemRev.add("TC_Is_Represented_By", LJTRev); + } + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post("ͼֽIDϵͳжIDͬʧܣ", "ʾ", 2); + return; + } + + } + } + } else { + itemRev.setStringProperty("rb3_th", build.toString()); + if (revList.size() > 0) { + TCComponentItemRevision picItem = revList.get(0); + TCComponent[] pics = picItem.getReferenceListProperty("TC_Is_Represented_By"); + for (int i = 0; i < pics.length; i++) { + itemRev.add("TC_Is_Represented_By", pics[i]); + } + // picItem.add("RB3_GLWL", itemRev); + } else { + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent("RB3_CGT"); + // String revID = typeComponent.getNewRev(null); + // String drawID = typeComponent.getNewID(); + String[] keys = new String[] { " ID" }; +// String[] values = new String[] { drawingNumber }; + String[] values = new String[] { build.toString() }; + List tzList = queryObject(" ID", keys, values); + TCComponentItemRevision CPTRev = null; + if (tzList != null) { + if (tzList.size() > 0) { + if (tzList.get(0) instanceof TCComponentItem) { + TCComponentItem tcItem = (TCComponentItem) tzList.get(0); + CPTRev = tcItem.getLatestItemRevision(); + } + } + } else { + + TCComponentItem CPTItem = typeComponent.create(build.toString(), "V1", "RB3_CGT", "", "", null); + CPTRev = CPTItem.getLatestItemRevision(); + if (CPTItem != null) { +// session.getUser().getHomeFolder().add("contents", CPTItem); +// session.getUser().getHomeFolder().refresh(); + if (build.toString().length() > 0) { + CPTRev.setStringProperty("rb3_th", build.toString()); + } else { + CPTRev.setStringProperty("rb3_th", drawingNumber); + } + folder.add("contents", CPTItem); + folder.refresh(); + } + + } + itemRev.add("TC_Is_Represented_By", CPTRev); + // CPTRev.add("RB3_GLWL", itemRev); + } + } + + List vals = new ArrayList(); + for (Map value : values) { + for (Map.Entry entry : value.entrySet()) { + String type = entry.getKey(); + if (type.equals("JComboBox")) { + JComboBox comb1 = (JComboBox) entry.getValue(); + String val = (String) comb1.getSelectedItem(); + vals.add(val); + } else { + JTextField field1 = (JTextField) entry.getValue(); + String val = field1.getText(); + vals.add(val); + } + } + } + Integer[] classKeys = new Integer[classList.size()]; + String[] classVals = new String[classList.size()]; + writer.println("size============================" + classList.size()); + for (int i = 0; i < labels1.length; i++) { + String val = vals.get(i); + if (val == null || val.trim() == "") { + continue; + } + String val2 = ""; + if (classList.get(i).isIslov()) { + val2 = classList.get(i).getLov().get(val);// ʵֵ + writer.println("val2================" + val2); + writer.println("val================" + val); + } else { + val2 = val; + } + classKeys[i] = classList.get(i).getId(); + String attrName = classList.get(i).getName(); + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName) + || (PlmLocaleUtil.getString("PartNumber")).equals(attrName)) { + if ("".equals(val2.trim())) { + JComboBox box = boxMap.get(attrName); + val2 = (String) box.getSelectedItem(); + } + } + classVals[i] = val2; + } + TCTypeService typeService = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) typeService.getTypeComponent("BOMWindow"); + // һµwindow + TCComponentBOMWindow view = winType.create(null); + view.lock(); + // öbomline + TCComponentBOMLine line = view.setWindowTopLine(targetItem.getItem(), targetItem, null, null); + // bomline + TCComponentBOMLine childBomline = line.add(itemComp, itemRev, null, false, ""); + // + view.save(); + // + view.unlock(); + // ر + view.close(); + + // +++ + new Thread() { + @Override + public void run() { + sendObjToClassficationByWebService(className2, itemRev, classKeys, classVals, url,login_file);// ͷ + MessageBox.post(rb.getString("wlcjcg07_display.TITLE"), "", MessageBox.INFORMATION ); + } + }.start(); + + setVisible(false); + + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + MessageBox.post(rb.getString("wlcjsb07_display.TITLE"), "", MessageBox.INFORMATION); + } + + writer.flush(); + writer.close(); + + } + + /** + * õǰTreeNodeĸ-ƻ + * + * @param treeNode ڵ + * @param names ƻ + * @return + */ + private String getNode(TreeNode treeNode, String names) { + // TODO Auto-generated method stub + if (!names.equals("")) { + names = "&" + names; + } + names = treeNode.toString() + names; + + TreeNode parent = treeNode.getParent(); + if (parent != null) { + return getNode(parent, names); + } + + return names; + } + + /** + * + * + * @param menuBean1 + * @return + * @throws TCException + */ + private JTree getTree(MenuBean menuBean1) throws TCException { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(treenodename); + Boolean flag = true; + if (list != null && list.size() > 0) { +// for (int i = 0; i < list.size(); i++) { +// if("RB3_GNLBJRevision".equals(targetItem.getType())) { +// String name = tccItem.getStringProperty("object_name"); +// writer.println("name1"+name); +// writer.println("name2"+list.get(i).getName()); +// if(name.equals(list.get(i).getName())) { +// flag = false; +// getRecursion(list.get(i), rootNode); +// } +// }else if("RB3_GNZCRevision".equals(targetItem.getType())) { +// //ѡķIDɸѡҪѡĶ(δӢĻ) +// String id = targetItem.getProperty("item_id"); +// String classID = id.substring(0,4); +// System.out.println("classID"+classID); +// //ݷIDȡ +// TCClassificationService classificationService = session.getClassificationService(); +// ICSAdminClass adminClass = classificationService.newICSAdminClass(); +// adminClass.load(classID); +// String name = adminClass.getName() + "Ʒ"; +// System.out.println("name1"+name); +// System.out.println("name2"+list.get(i).getName()); +// if(name.equals(list.get(i).getName())) { +// flag = false; +// getRecursion(list.get(i), rootNode); +// } +// } +// } + if(flag) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), rootNode); + } + } + } + JTree tree = new JTree(rootNode); + tree.setShowsRootHandles(true); + // tree.setEditable(true); + + return tree; + } + + /** + * ݹ˵ṹ + * + * @param menuBean1 + * @param rootNode + */ + private void getRecursion(MenuBean menuBean1, DefaultMutableTreeNode rootNode) { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode node = new DefaultMutableTreeNode(treenodename); + rootNode.add(node); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), node); + } + } + } + + /** + * ͨѯѯĿ + * + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + return null; + } + } + + /** + * ͷ + */ + public void sendObjToClassficationByWebService(String class_id, TCComponentItemRevision rev, Integer[] keys, + String[] vals, String url,File login_file) { + + try { + FileWriter fileWriter = new FileWriter(login_file, true); + PrintWriter writer = new PrintWriter(fileWriter); + writer.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList(); + + for (int i = 0; i < keys.length; i++) { + if (keys[i] != null && vals[i] != null) { + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + writer.flush(); + writer.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public String splicValue(List defaultValueList, List attrList, List esAttrList, + Map map, List markList, List isNList, Map lovMap,PrintWriter writer ) { + List objList = new ArrayList(); + List lovList = new ArrayList(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < attrList.size(); i++) { + String attr = attrList.get(i); + writer.println("attr======112" + attr); + String esAttr = esAttrList.get(i); + if (classFlag2) { + if ((PlmLocaleUtil.getString("heatTreatment")).equals(attr) + || (PlmLocaleUtil.getString("heatTreatment")).equals(esAttr)) { + objList.add(HeatTreatment); + lovList.add("string"); + continue; + } + } + if (map.get(attr) == null && map.get(esAttr) == null) { + if ((PlmLocaleUtil.getString("PartNumber")).equals(attr) + || (PlmLocaleUtil.getString("PartNumber")).equals(esAttr)) { + JComboBox idbox = boxMap.get(PlmLocaleUtil.getString("PartNumber")); + JTextField idfield = (JTextField) idList.get(0); + String fieldText = idfield.getText(); + String boxText = (String) idbox.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(PlmLocaleUtil.getString("PartNumber") + "ͬʱдֵ", "ʾ", + MessageBox.INFORMATION); + return null; + } +// if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { +// MessageBox.post(PlmLocaleUtil.getString("PartNumber") + "дһֵ", "ʾ", +// MessageBox.INFORMATION); +// return null; +// } + if (!("".equals(fieldText.trim()))) { + objList.add(fieldText); + lovList.add("string"); + } else { + objList.add(boxText); + lovList.add("string"); + } + continue; + } + objList.add(defaultValueList.get(i)); + lovList.add("string"); + continue; + } + if (!("".equals(attr.trim()))) { + Object obj = map.get(attr); + JComboBox box = null; + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attr) + || (PlmLocaleUtil.getString("RadialInternalClearance")).equals(esAttr)) { + box = boxMap.get(PlmLocaleUtil.getString("RadialInternalClearance")); + } + if (obj == null) { + obj = map.get(esAttr); + if (box != null) { + JTextField field = (JTextField) obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(esAttr + "ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(esAttr + "дһֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + } else { + objList.add(box); + lovList.add("yes"); + } + } else { + objList.add(obj); + lovList.add(lovMap.get(esAttr)); + } + } else { + if (box != null) { + JTextField field = (JTextField) obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(attr + "ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(attr + "дһֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + } else { + objList.add(box); + lovList.add("yes"); + } + } else { + objList.add(obj); + lovList.add(lovMap.get(attr)); + } + } + } + } + for (int i = 0; i < objList.size(); i++) { + String attrValue = ""; + Object obj = objList.get(i); + if (obj != null) { + if ("yes".equals(lovList.get(i))) { + String value = (String) ((JComboBox) obj).getSelectedItem(); + writer.println("ֵΪ:" + value); + if (asList.contains(value) || esList.contains(value)) { + if (isNList.get(i).trim().contains(value)) { + if (value.contains(":")) { + writer.println("value============" + value); + String[] values = value.split(":"); + value = values[0]; + } else if (value.contains("")) { + writer.println("value============" + value); + String[] values = value.split(""); + value = values[0]; + } + } else { + value = ""; + } + } else { + if (value.contains(":")) { + writer.println("value============" + value); + String[] values = value.split(":"); + value = values[0]; + } else if (value.contains("")) { + writer.println("value============" + value); + String[] values = value.split(""); + value = values[0]; + } + } + if ("Ʒ".equals(value) || "Finished product".equals(value)) { + value = ""; + } else if ("".equals(value) || "Turning workpiece".equals(value)) { + value = "C"; + } else if ("ȴ".equals(value) || "Heat treatment parts".equals(value)) { + value = "R"; + } else if ("շ伷".equals(value) || "Cold rolled parts or cold extrusion parts".equals(value)) { + value = "D"; + } else if ("ͼ".equals(value) || "Forge piece".equals(value)) { + value = "D"; + } + attrValue = value; + } else if ("no".equals(lovList.get(i))) { + attrValue = ((JTextField) obj).getText(); + } else { + attrValue = (String) obj; + } + if (asList.contains(attrValue) || esList.contains(attrValue)) { + attrValue = ""; + } else { + if (attrValue.contains(":")) { + writer.println("attrValue============" + attrValue); + String[] values = attrValue.split(":"); + attrValue = values[0]; + } else if (attrValue.contains("")) { + writer.println("attrValue============" + attrValue); + String[] values = attrValue.split(""); + attrValue = values[0]; + } + } + String mark = markList.get(i); + if (!("".equals(attrValue.trim()))) { + sb.append(mark.trim()); + sb.append(attrValue); + } + } + } + return sb.toString(); + } + + // Ż:idΪ22XX22ͷ + public String dealItemId(String id,PrintWriter writer) { + String subs = id.substring(0, 2); + if (subs.equals("XX")) { + + String sub = id.substring(2, 4); + if (sub.equals("22")) { + writer.println("idXX22ͷ!"); + return "XX-"; + } + } else if (subs.equals("22")) { + writer.println("id22ͷ!"); + return "SF-"; + } + return null; + } + + // ҶӦĸļ + public void getFolder() { + boolean b = false; + if (refs.length > 0) { + for (AIFComponentContext ref : refs) { + InterfaceAIFComponent component = ref.getComponent(); + if (component instanceof TCComponentFolder) { + folder = (TCComponentFolder) component; + b = true; + break; + } + } + } + if (!b) { + try { + folder = session.getUser().getHomeFolder(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + public String getGLH(PrintWriter writer) { + String glh = null; + JComponent jcomp1 = jcompMap.get(660113); + JComponent jcomp2 = jcompMap.get(660114); + JComponent jcomp3 = jcompMap.get(660115); + if (jcomp1 != null && jcomp2 != null && jcomp3 != null) { + List jcomps = new ArrayList(); + jcomps.add(jcomp1); + jcomps.add(jcomp2); + jcomps.add(jcomp3); + StringBuilder build = new StringBuilder(); + for (int i = 0; i < jcomps.size(); i++) { + JComponent jcomp = jcomps.get(i); + if (jcomp instanceof JComboBox) { + JComboBox combo = (JComboBox) jcomp; + String comboStr = (String) combo.getSelectedItem(); + if (!(comboStr.trim().equals(""))) { + if (comboStr.contains(":")) { + comboStr = comboStr.split(":")[0]; + } + if (i == 2) { + build.append("-" + comboStr + "|"); + } else { + build.append(comboStr + "|"); + } + + } + } else if (jcomp instanceof JTextField) { + JTextField jtext = (JTextField) jcomp; + String textStr = jtext.getText(); + if (!(textStr.trim().equals(""))) { + if (textStr.contains(":")) { + textStr = textStr.split(":")[0]; + } + if (i == 2) { + build.append("-" + textStr + "|"); + } else { + build.append(textStr + "|"); + } + + } + } + } + Object[] params = new Object[] { build.toString(), 4, 1, 9999, 1, "" }; + Object[] obj = new Object[1]; + obj[0] = ""; + TCUserService userservice = this.session.getUserService(); + try { + TCUtils.openLogByPass(session, name); + userservice.call("Connor_set_bypass", obj); + glh = (String) userservice.call("queryPartNo", params); + writer.println("ɵĹΪ:" + glh); + String[] keys = new String[] { " ID" }; + glh = dealGLH(glh,writer); + + String[] values = new String[] { glh }; + List compList = queryObject(" ID", keys, values); +// while (compList != null && compList.size() > 0) { +// glh = (String) userservice.call("queryPartNo", params); +// glh = dealGLH(glh); +// writer.println("whileѭɵglhΪ:" + glh); +// String[] value = new String[] { glh }; +// compList = queryObject(" ID", keys, value); +// } + if (compList != null && compList.size() > 0) { + glh = new GetNewCode(params,glh).getCode(); + String[] value = new String[] { glh }; + List queryObject = queryObject(" ID", keys, value); + if(queryObject != null && queryObject.size() > 0){ + MessageBox.post("ȡظϵԱ", "", MessageBox.INFORMATION); + return null; + } +// glh = (String) userservice.call("queryPartNo", params); +// glh = dealGLH(glh); +// writer.println("whileѭɵglhΪ:" + glh); +// String[] value = new String[] { glh }; +// compList = queryObject(" ID", keys, value); + } + } catch (TCException e) { + // TODO Auto-generated catch block + + e.printStackTrace(); + }finally { + try { + TCUtils.closeLogByPass(session, name); + userservice.call("Connor_close_bypass", obj); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } else { + MessageBox.post("Կͻ롢Ż汾δд", "ʾ", MessageBox.INFORMATION); + } + return glh; + } + + public String dealGLH(String glh,PrintWriter writer) { + writer.println("dealGLH"); + String[] split = glh.split("\\|"); + StringBuilder build = new StringBuilder(); + if (split.length > 3) { + build.append(split[0]); + build.append(split[3]); + build.append(split[1]); + build.append(split[2]); + } else { + writer.println("glhƴ쳣!"); + } + writer.println("glhֵΪ:" + build.toString()); + return build.toString(); + } + + // ȡlovֵ + public String[] getRealLoveName(String lovName,PrintWriter writer) throws TCException { + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues projectItemslov = TCComponentListOfValuesType.findLOVByName(lovName); + String[] projectItems = null; + if (projectItemslov != null) { + writer.println(projectItemslov.toString()); + projectItems = projectItemslov.getListOfValues().getLOVDisplayValues(); + } + return projectItems; + } +} diff --git a/src/com/connor/rb/plm/rb007/Rb007DialogLBJ.java b/src/com/connor/rb/plm/rb007/Rb007DialogLBJ.java new file mode 100644 index 0000000..735ef8a --- /dev/null +++ b/src/com/connor/rb/plm/rb007/Rb007DialogLBJ.java @@ -0,0 +1,2184 @@ +package com.connor.rb.plm.rb007; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.ResourceBundle; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; + +import com.aspose.cad.internal.ay.iF; +import com.connor.rb.plm.entity.ZC_LBJ_listLBJ; +import com.connor.rb.plm.newcombox.RwJComboBox; +import com.connor.rb.plm.rb012.SearchJComItem; +import com.connor.rb.plm.util.ClassAttributeBean; +import com.connor.rb.plm.util.ClassProperty; +import com.connor.rb.plm.util.CodeBean; +import com.connor.rb.plm.util.GetCodeBean; +import com.connor.rb.plm.util.GetNewCode; +import com.connor.rb.plm.util.MenuBean; +import com.connor.rb.plm.util.ParseXML; +import com.connor.rb.plm.util.PlmLocaleUtil; +import com.connor.rb.plm.util.SoaServerUtil; +import com.connor.rb.plm.util.TCUtils; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +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.TCClass; +import com.teamcenter.rac.kernel.TCClassManager; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSKeyLov.KeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +import cn.com.origin.autocode.newitem.generatcode.Item; + +public class Rb007DialogLBJ extends AbstractAIFOperation { + private AbstractAIFApplication app; + private TCSession session; + private TCPreferenceService service; + private String name; + private MenuBean menuBean; + private JPanel jp1; + private JPanel jp2; + private JPanel classJpanel; + private StringBuilder build = new StringBuilder(); + private List> values; + private List classList = new ArrayList(); + private Map tagMap = new HashMap(); + private CodeBean selCodeBean; + private JButton okBut = new JButton("ȷ"); + private JButton button2 = new JButton("ͼֽ"); + private JButton celBut = new JButton("ȡ"); + private GetCodeBean getcode; + private JLabel[] labels1 = null; + private String url = ""; + private JScrollPane scr2; + private boolean classFlag = true; + private boolean classFlag2 = false; + private Map map2; + private Map> boxMap = new HashMap>(); + private List revList = new ArrayList(); + private List idList = new ArrayList(); + private List typeList = new ArrayList(); + private JLabel nameLabel; + private JComboBox nameComb; + private JComboBox dl; + private JLabel idLabel; + private JTextField idField1; + private JLabel revLabel; + private JComboBox revBox; + private String className2; + private TCComponentItemRevision targetItem; + private TCComponentItem taItem; + private String productNumber = ""; + private String drawingNumber = ""; + private String HeatTreatment = ""; + private Map> attrMap; + private Map> attrMap2; + private Map objMap = new HashMap(); + private Map objMap2 = new HashMap(); + private Map lovMap = new HashMap(); + private Map lovMap2 = new HashMap(); + private List attrList = new ArrayList(); + private List esAttrList = new ArrayList(); + private List attrList2 = new ArrayList(); + private List esAttrList2 = new ArrayList(); + private List markList = new ArrayList(); + private List markList2 = new ArrayList(); + private List isNList = new ArrayList(); + private List isNList2 = new ArrayList(); + private List defaultValueList = new ArrayList(); + private List defaultValueList2 = new ArrayList(); + private List asList = new ArrayList(); + private List esList = new ArrayList(); + // Ż + private AIFComponentContext[] refs; + private TCComponentFolder folder; + private TCComponentItem tccItem; + private String toitemtype; + private int v = 0; + private Map lishu_lov = ZC_LBJ_listLBJ.LiShu_lov; + private Map lishu = ZC_LBJ_listLBJ.LiShu; + private Map zc_pro_map = new HashMap();// ܳɵԼֵ + // TextField + private List fieldList = new ArrayList(); + // box + private List comboxList = new ArrayList(); + private Map fieldmap = new HashMap<>(); + private Map comboxmap = new HashMap<>(); + private Map jcompMap = new HashMap(); + private JFrame jFrame = null; + private Map MustMap = new HashMap();// +++ǩдӽжǷ + private ResourceBundle rb; + public Rb007DialogLBJ(AbstractAIFApplication app, String name) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.name = name; + this.values = new ArrayList>(); + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + + } + + public Rb007DialogLBJ(AbstractAIFApplication app, String name, String itemtype) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.name = name; + this.values = new ArrayList>(); + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + this.toitemtype = itemtype; + + } + /* + * Title: executeOperation + * Description: + * @throws Exception + * @see com.teamcenter.rac.aif.AbstractAIFOperation#executeOperation() + */ + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + Locale defaultLocale = Locale.getDefault(); + + rb = ResourceBundle + .getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + // TODO Auto-generated method stub + getcode = new GetCodeBean(session); + menuBean = getcode.getMenuBean(name); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HH-mm-ss-SSS"); + String dirsPath = "C:\\Session"; + + String filename = "lscj_display-"+ sdf.format(new Date()) +".txt"; + File login_file = new File(dirsPath,filename); + File path = new File(dirsPath); + if(!path.exists()) { + path.mkdirs(); + } + if(login_file.exists()) { + login_file.delete(); + } + try { + login_file.createNewFile(); + FileWriter fileWriter = new FileWriter(login_file, true); + PrintWriter writer = new PrintWriter(fileWriter); + writer.println("ʼʼȡѡ"+ new Date()); + String lovVal = service.getStringValue("RB3_lovVal_default"); + String esLovVal = service.getStringValue("RB3_esLovVal_default"); + if (lovVal.contains(";")) { + String[] vals = lovVal.split(";"); + String[] esVals = esLovVal.split(";"); + for (int i = 0; i < vals.length; i++) { + asList.add(vals[i]); + esList.add(esVals[i]); + } + } + ParseXML xml = new ParseXML(); + File file = xml.getSXX("RB3_CPHPJFS", session); + + attrMap = xml.parseXMLAttr(file); + if (attrMap == null || attrMap.size() <= 0) { + MessageBox.post("ѡRB3_CPHPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + File file2 = xml.getSXX("RB3_THPJFS", session);// hEtFB3llJxBjoC + attrMap2 = xml.parseXMLAttr(file2); + if (attrMap2 == null || attrMap2.size() <= 0) { + MessageBox.post("ѡRB3_THPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + InterfaceAIFComponent targetComp = app.getTargetComponent(); + if (targetComp instanceof TCComponentItemRevision) { + targetItem = (TCComponentItemRevision) targetComp; + tccItem = targetItem.getItem(); + refs = tccItem.whereReferenced(); + // Ż + zc_pro_map = targetItem.getProperties(); + // end + } else if (targetComp instanceof TCComponentItem) { + taItem = (TCComponentItem) targetComp; + targetItem = taItem.getLatestItemRevision(); + tccItem = taItem; + refs = taItem.whereReferenced(); + // Ż + zc_pro_map = taItem.getProperties(); + } + writer.println("ʼ"+ new Date()); + writer.println("ʼ"+ new Date()); + + jFrame = new JFrame(); + + // TODO Auto-generated method stub + jFrame.setTitle(name); + // this.setMinimumSize(new Dimension(860,900)); + jFrame.setSize(860, 900); + // this.setLayout(new PropertyLayout()); + jFrame.setLayout(new BorderLayout()); + classJpanel = new JPanel(new BorderLayout());// Խ + jp1 = new JPanel(new BorderLayout()); + jp2 = new JPanel(new PropertyLayout()); + jp1.setPreferredSize(new Dimension(200, 820)); + scr2 = new JScrollPane(jp2); + scr2.setPreferredSize(new Dimension(640, 820)); + classJpanel.add(scr2); + // jp2.setPreferredSize(new Dimension(350, 600)); + JTree tree = null; + try { + tree = getTree(menuBean, writer); + } catch (Exception e3) { + // TODO Auto-generated catch block + e3.printStackTrace(); + } + + tree.addKeyListener(new KeyListener() { + + @Override + public void keyTyped(KeyEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void keyPressed(KeyEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void keyReleased(KeyEvent e) { + // TODO Auto-generated method stub + int keyCode = e.getKeyCode(); + + // writer.println(""+keyCode+"!"); + + if (keyCode == 27) { + + int option = JOptionPane.showOptionDialog(null, "ȷ˳˵", "", 0, 1, null, null, + Integer.valueOf(0)); + if (option == 0) { + writer.println("˳"); + jFrame.dispose(); + } else { + return; + } + } + } + }); + + tree.addTreeSelectionListener(new TreeSelectionListener() { + public void valueChanged(TreeSelectionEvent e) { + classFlag = true; + classFlag2 = false; + objMap.clear(); + objMap2.clear(); + // zc_pro_map.clear(); + fieldList.clear(); + comboxList.clear(); + fieldmap.clear(); + comboxmap.clear(); + // + + lovMap.clear(); + lovMap2.clear(); + attrList.clear(); + esAttrList.clear(); + attrList2.clear(); + esAttrList2.clear(); + classList.clear(); + markList.clear(); + markList2.clear(); + isNList.clear(); + isNList2.clear(); + defaultValueList.clear(); + defaultValueList2.clear(); + jp2.removeAll(); + idList.clear(); + DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) e.getPath().getLastPathComponent(); + int childCount = treeNode.getChildCount(); + writer.println("ǰѡеĽڵ: " + treeNode + " ӽڵ:" + childCount); + if (childCount > 0) { + jp2.setVisible(false); + } else { + String names = getNode(treeNode, ""); + selCodeBean = getcode.getCodebean(names); + if (selCodeBean == null) { + // ѡײڵ㣡 + MessageBox.post(rb.getString("qxzzdcjd07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + JTextField idfield = new JTextField(18); + idList.add(idfield); + JComboBox idbox = new JComboBox(); + + idList.add(idbox); + idbox.addItem(" "); + String[] idstrs = new String[100]; + for (int j = 0; j < 100; j++) { + if (j < 10) { + idstrs[j] = "0" + j; + } else { + idstrs[j] = j + ""; + } + } + for (int j = 0; j < idstrs.length; j++) { + idbox.addItem(idstrs[j]); + } + boxMap.put(PlmLocaleUtil.getString("PartNumber"), idbox); + revLabel = new JLabel(rb.getString("banben_display.TITLE")); + revBox = new JComboBox(); + revBox.setEditable(false); + revBox.addItem("B1"); + String[] revs = service.getStringValues("RB_Revision_id"); + if (revs == null || revs.length <= 0) { + MessageBox.post("ѡRB_Revision_idδ,ϵԱ!!", "", MessageBox.ERROR); + return; + } + for (int i = 0; i < revs.length; i++) { + revBox.addItem(revs[i]); + } + nameLabel = new JLabel(rb.getString("mingcheng_display.TITLE")); + nameComb = new JComboBox(); + nameComb.setEditable(false); + + nameComb.addItem(""); + String[] lbjNames = service.getStringValues("RB3_LBJ_names"); + + if (lbjNames == null || lbjNames.length <= 0) { + MessageBox.post("ѡRB3_LBJ_namesδ,ϵԱ!!", "", MessageBox.ERROR); + return; + } + for (int i = 0; i < lbjNames.length; i++) { + nameComb.addItem(lbjNames[i]); + } + + // Ż + nameComb.setSelectedIndex(1); + // endŻ + + idLabel = new JLabel(rb.getString("zcwlbm_display.TITLE")); + idField1 = new JTextField(18); + + // Ż + try { + idField1.setText(targetItem.getProperty("item_id")); + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + // endŻ + + jp2.add("1.1.center.center", new JLabel("")); + jp2.add("2.1.center.center", idLabel); + jp2.add("2.2.center.center", idField1); + jp2.add("3.1.center.center", nameLabel); + jp2.add("3.2.center.center", nameComb); + jp2.add("4.1.center.center", new JLabel(PlmLocaleUtil.getString("PartNumber"))); + jp2.add("4.2.center.center", idfield); + jp2.add("4.3.center.center", idbox); + jp2.add("5.1.center.center", revLabel); + jp2.add("5.2.center.center", revBox); + try { + String className = targetItem.getClassificationClass(); + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + writer.println("className============" + className); + c.load(className); + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + // ȡ + TCComponentICO[] icos = targetItem.getClassificationObjects(); + writer.print("icos:====" + icos); + if (icos == null || icos.length <= 0) { + // ѡеûз͵࣬뷢ͣ + MessageBox.post(rb.getString("xzdwlmyfsdfl07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + Map claMap = new HashMap(); + if (icos != null && icos.length > 0) { + + ICSProperty[] icss = icos[0].getICSProperties(true); + + for (ICSProperty ics : icss) { + for (ICSAdminClassAttribute icsa : icsAttrS) { + if (icsa.getAttributeId() == ics.getId()) { + writer.print("icsa.getName():" + icsa.getName()); + claMap.put(icsa.getName(), ics.getValue()); + } + } + } + } + ICSAdminClass c2 = classificationService.newICSAdminClass(); + className2 = selCodeBean.getClassID(); + // String xmlClassName = className2.substring(0, 6); + writer.println("className2===========" + className2); + // writer.println("xmlClassName==========="+xmlClassName); + if (attrMap.containsKey(className2)) { + List nameMarkList = attrMap.get(className2); + String attrNames = nameMarkList.get(0); + String marks = nameMarkList.get(1); + String defaultValues = nameMarkList.get(2); + String isN = nameMarkList.get(3); + if (attrNames.contains(";")) { + String[] attrs = attrNames.split(";"); + String[] markss = marks.split(";"); + String[] valuess = defaultValues.split(";"); + String[] isNs = isN.split(";"); + for (int i = 0; i < attrs.length; i++) { + writer.println("attrs==============" + attrs[i]); + if (attrs[i].contains("+")) { + String[] attrss = attrs[i].split("\\+"); + attrList.add(attrss[0]); + esAttrList.add(attrss[1]); + markList.add(markss[i]); + defaultValueList.add(valuess[i]); + isNList.add(isNs[i]); + } + } + } + + List nameMarkList2 = attrMap2.get(className2); + String attrNames2 = nameMarkList2.get(0); + String marks2 = nameMarkList2.get(1); + String defaultValues2 = nameMarkList2.get(2); + String isNs2 = nameMarkList2.get(3); + writer.println("attrNames2============" + attrNames2); + if (attrNames2.contains(";")) { + String[] attrs2 = attrNames2.split(";"); + String[] markss2 = marks2.split(";"); + String[] valuess = defaultValues2.split(";"); + String[] isNs2s = isNs2.split(";"); + for (int i = 0; i < attrs2.length; i++) { + if (attrs2[i].contains("+")) { + String[] attrss = attrs2[i].split("\\+"); + attrList2.add(attrss[0]); + esAttrList2.add(attrss[1]); + markList2.add(markss2[i]); + defaultValueList2.add(valuess[i]); + isNList2.add(isNs2s[i]); + } + } + } + } + c2.load(className2); + String cName = c2.getName(); + if (PlmLocaleUtil.getString("BearingAccessories").equals(cName)) { + classFlag = false; + } else if (PlmLocaleUtil.getString("Cage").equals(cName)) { + classFlag2 = true; + } + writer.println("cName===" + cName); + ICSAdminClassAttribute[] icsAttrS2 = c2.getAttributes(); + if (icsAttrS2 != null) { + for (ICSAdminClassAttribute attr : icsAttrS2) { + if (attr.isHidden()) { + continue; + } + ClassAttributeBean bean = new ClassAttributeBean(); + if (attr.isReferenceAttribute()) {// + continue; + } + if (attr.isReference()) { + continue; + } + int propID = attr.getAttributeId(); + bean.setId(propID); + String propDisName = attr.getName(); + writer.print("propDisName:" + propDisName); + bean.setName(propDisName); + + int attrType = attr.getFormat1().getType(); + bean.setType(attrType); + // ÷ + if (claMap != null && claMap.containsKey(propDisName)) { + bean.setVal(claMap.get(propDisName)); + } else { + bean.setVal(""); + } + ICSKeyLov lov1 = attr.getFormat1().getKeyLov(); + lov1 = (lov1 == null ? attr.getFormat2().getKeyLov() : lov1); + if (lov1 != null) { + bean.setIslov(true); + String[] keys = lov1.getKeys(); + Map map1 = new HashMap(); + for (String key : keys) { + KeyLov lov_key = lov1.getKeyLovOfKey(key); + boolean deprecated = lov_key.isDeprecated(); + if (deprecated) { + if (key.equals(bean.getVal())) { + bean.setVal(""); + } + continue; + } + String value = lov1.getValueOfKey(key); + map1.put(value, key);// <ʾֵ,ʵֵ> + if (key.equals(bean.getVal()) && (!bean.getVal().equals(""))) { + bean.setVal(value); + } + } + bean.setLov(map1); + } else { + bean.setIslov(false); + } + + classList.add(bean); + + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + + labels1 = new JLabel[classList.size()]; + writer.print("classList.size():" + classList.size()); + for (int i = 0; i < classList.size(); i++) { + JComponent jcomp = null; + ClassAttributeBean bean = classList.get(i); + String attrName = bean.getName(); + int propID = bean.getId(); + labels1[i] = new JLabel(attrName); + jp2.add((i + 6) + ".1.center.top", labels1[i]); + labels1[i].setBounds(5, 5, 5, 5); + String value = bean.getVal(); + writer.println("ĬֵΪ:" + value); + if (bean.isIslov()) { + JComboBox comb = new JComboBox(); + // Ż + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + // end + comb.setEditable(false); + comb.setSize(new Dimension(60, 40)); + if (classFlag2) { + if ((PlmLocaleUtil.getString("heatTreatment")).equals(attrName)) { + comb.addItem(""); + HeatTreatment = value; + } else { + comb.addItem(value); + } + } else { + comb.addItem(value); + } + for (Entry entry : bean.getLov().entrySet()) { + if (i == 0) { + writer.println("entry.getKey()====" + entry.getKey()); + } + if (!(value.equals(entry.getKey()))) { + comb.addItem(entry.getKey()); + } + } + // Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + writer.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(comb, tip); + } + } + + }); + // end + map2 = new HashMap(); + map2.put("JComboBox", comb); + values.add(map2); + jp2.add((i + 6) + ".2.center.top", comb); + jp2.add((i + 6) + ".3.center.top", jt); + jp2.add((i + 6) + ".4.center.top", bu); + if (attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, comb); + lovMap.put(attrName, "yes"); + } + if (attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, comb); + lovMap2.put(attrName, "yes"); + } + + if ((PlmLocaleUtil.getString("Category")).equals(attrName)) { + typeList.add(comb); + } + jcomp = comb; + } else { + JTextField field = new JTextField(18); + field.setText(value); + map2 = new HashMap(); + map2.put("JTextField", field); + values.add(map2); + jp2.add((i + 6) + ".2.center.top", field); + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName)) { + JComboBox box = new JComboBox(); + // Ż + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + // end + box.addItem(" "); + String[] strs = new String[] { "C0", "C2", "C3", "C4", "C5" }; + for (int j = 0; j < strs.length; j++) { + box.addItem(strs[j]); + } + // Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + writer.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(box, tip); + } + } + + }); + boxMap.put(attrName, box); + jp2.add((i + 6) + ".3.center.top", box); + jp2.add((i + 6) + ".4.center.top", jt); + jp2.add((i + 6) + ".5.center.top", bu); + } + if (attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, field); + lovMap.put(attrName, "no"); + } + if (attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, field); + lovMap2.put(attrName, "no"); + } + jcomp = field; + } + v = i + 7; + + if (propID == 660113 || propID == 660114 || propID == 660115) { + jcompMap.put(propID, jcomp); + } + } + + // Ż + jp2.add(v + ".1.center.top", new JLabel(" ")); + jp2.add(v + ".2.center.top", new JLabel("**********************")); + v += 1; + // λ + if(Locale.getDefault().toString().equalsIgnoreCase("zh_CN")) { + jp2.add(v + ".1.center.top", new JLabel("λ")); + }else { + jp2.add(v + ".1.center.top", new JLabel("Unit of measurement")); + } + + try { + tagMap.clear(); + dl = new JComboBox(); + dl.setSize(new Dimension(60, 40)); + dl.setName("uom_tag"); + TCProperty zclov1; + TCComponentItem oldItem = targetItem.getItem(); + zclov1 = oldItem.getTCProperty("uom_tag"); + + TCComponentListOfValues zcprolov1 = zclov1.getLOV(); + String[] comboxitems1; + JTextField jt1 = new JTextField(9); + JButton bu1 = new JButton(""); + if (zcprolov1 != null) { + comboxitems1 = zcprolov1.getListOfValues().getLOVDisplayValues(); + TCComponent[] tags = zcprolov1.getListOfValues().getTagListOfValues(); + for (int flag = 0; flag < comboxitems1.length; flag++) { + tagMap.put(comboxitems1[flag], tags[flag]); + } + ComboBoxModel model1 = new DefaultComboBoxModel(comboxitems1); + dl.setModel(model1); + bu1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip1 = jt1.getText(); + writer.println("" + tip1); + if (tip1.length() > 0) { + SearchJComItem.changeBox(dl, tip1); + } + } + + }); + // comboxList.add(dl); + } + dl.setSelectedItem(oldItem.getProperty("uom_tag")); + // if(!(ZC_LBJ_listLBJ.LBJDisPros.get(i)).equals("ʱϱʶ")) { + dl.setSelectedIndex(-1); + jp2.add(v + ".2.center.top", dl); + jp2.add((v) + ".3.center.top", jt1); + jp2.add((v) + ".4.center.top", bu1); + v += 1; + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + // λ + MustMap.put("λ", dl); + + + if ("RB3_GNZC".equals(toitemtype)) { + for (int i = 0; i < ZC_LBJ_listLBJ.GNZCPros.size(); i++) { + ZC_LBJ_listLBJ.LBJPros.size(); + + writer.println("ѭ" + i + ",ҪӵΪ" + ZC_LBJ_listLBJ.GNZCDisPros.get(i) + "(" + + ZC_LBJ_listLBJ.GNZCPros.get(i) + ")"); + + if(Locale.getDefault().toString().equalsIgnoreCase("zh_CN")) { + jp2.add((v) + ".1.center.top", new JLabel(ZC_LBJ_listLBJ.GNZCDisPros.get(i))); + }else { + jp2.add((v) + ".1.center.top", new JLabel(ZC_LBJ_listLBJ.YWGNZCDisPros.get(i))); + } + + boolean b = ZC_LBJ_listLBJ.map.containsKey(ZC_LBJ_listLBJ.GNZCPros.get(i)); + try { + if (b) { + + writer.println("Lov"); + // lovֵ + String[] profitLov = getRealLoveName(ZC_LBJ_listLBJ.GNZCPros.get(i), writer); + JComboBox zcBox = new JComboBox(profitLov); + zcBox.setSize(new Dimension(60, 40)); + zcBox.setName(ZC_LBJ_listLBJ.GNZCDisPros.get(i)); + jp2.add(v + ".2.center.top", zcBox); + MustMap.put(ZC_LBJ_listLBJ.GNZCDisPros.get(i), zcBox); + // +++ + } else { + JTextField field = new JTextField(18); + field.setName(ZC_LBJ_listLBJ.GNZCPros.get(i)); + jp2.add(v + ".2.center.top", field); + fieldList.add(field); + // +++ + MustMap.put(ZC_LBJ_listLBJ.GNZCDisPros.get(i), field); + // +++ + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + v++; + + } + } else { + for (int i = 0; i < ZC_LBJ_listLBJ.LBJPros.size(); i++) { + + writer.println("ѭ" + i + ",ҪӵΪ" + ZC_LBJ_listLBJ.LBJDisPros.get(i) + "(" + + ZC_LBJ_listLBJ.LBJPros.get(i) + ")"); + if ((ZC_LBJ_listLBJ.LBJDisPros.get(i)).equals("Ʒ") + || (ZC_LBJ_listLBJ.LBJDisPros.get(i)).equals("ͼ")) { + + continue; + } + if(Locale.getDefault().toString().equalsIgnoreCase("zh_CN")) { + jp2.add((v) + ".1.center.top", new JLabel(ZC_LBJ_listLBJ.LBJDisPros.get(i))); + }else { + jp2.add((v) + ".1.center.top", new JLabel(ZC_LBJ_listLBJ.YWLBJDisPros.get(i))); + } + + boolean b = ZC_LBJ_listLBJ.map.containsKey(ZC_LBJ_listLBJ.LBJPros.get(i)); + try { + if (b) { + + writer.println("Lov"); + if (ZC_LBJ_listLBJ.LBJPros.get(i).equals("rb3_scgc1") + || ZC_LBJ_listLBJ.LBJPros.get(i).equals("rb3_yyly")) { + // writer.println("Ϊ"); + String na = ZC_LBJ_listLBJ.LBJPros.get(i); + String[] vals = ((TCComponentItemRevision) targetItem).getTCProperty(na) + .getStringValueArray(); + JComboBox nbox = new RwJComboBox(new String[] { "" }); + nbox.setEditable(true); + TCProperty zclov = ((TCComponentItemRevision) targetItem) + .getTCProperty(ZC_LBJ_listLBJ.LBJPros.get(i)); + TCComponentListOfValues zcprolov = zclov.getLOV(); + List disVal = new ArrayList(); + String[] comboxitems; + for (int a = 0; a < vals.length; a++) { + if (vals[a] != null && !vals[a].equals("")) { + String disname = zcprolov.getListOfValues() + .getDisplayableValue(vals[a]); + disVal.add(disname); + } + } + if (zcprolov != null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + // ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + + nbox = new RwJComboBox(comboxitems); + nbox.setEditable(true); + nbox.setName(na); + nbox.setSize(new Dimension(60, 40)); + if (disVal.size() > 0) { + StringBuilder sb = new StringBuilder(); + for (int t = 0; t < disVal.size(); t++) { + if (t != (vals.length - 1)) { + + sb.append(disVal.get(t)); + sb.append(","); + } else { + sb.append(disVal.get(t)); + } + } + JTextField ed = (JTextField) nbox.getEditor().getEditorComponent(); + ed.setText(sb.toString()); + } + comboxList.add(nbox); + } + + jp2.add(v + ".2.center.top", nbox); + + // +++ + MustMap.put(ZC_LBJ_listLBJ.LBJDisPros.get(i), nbox); + // +++ + } else { + JComboBox zcBox = new JComboBox(); + zcBox.setSize(new Dimension(60, 40)); + zcBox.setName(ZC_LBJ_listLBJ.LBJPros.get(i)); + TCProperty zclov = ((TCComponentItemRevision) targetItem) + .getTCProperty(ZC_LBJ_listLBJ.LBJPros.get(i)); + TCComponentListOfValues zcprolov = zclov.getLOV(); + String[] comboxitems; + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + if (zcprolov != null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + comboxitems = prependEmptyString(comboxitems); + ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + + zcBox.setModel(model); + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + writer.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(zcBox, tip); + } + } + + }); + comboxList.add(zcBox); + } + + zcBox.setSelectedItem(zc_pro_map.get(ZC_LBJ_listLBJ.LBJPros.get(i))); + writer.println("testName:"+ZC_LBJ_listLBJ.LBJDisPros.get(i)); + // if(!(ZC_LBJ_listLBJ.LBJDisPros.get(i)).equals("ʱϱʶ")) { + zcBox.setSelectedIndex(-1); + // } + + jp2.add(v + ".2.center.top", zcBox); + jp2.add((v) + ".3.center.top", jt); + jp2.add((v) + ".4.center.top", bu); + // +++ + MustMap.put(ZC_LBJ_listLBJ.LBJDisPros.get(i), zcBox); + // +++ + } + } else { + JTextField field = new JTextField(18); + field.setName(ZC_LBJ_listLBJ.LBJPros.get(i)); + if ((ZC_LBJ_listLBJ.LBJDisPros.get(i)).equals("û")) { + field.setText(zc_pro_map.get(ZC_LBJ_listLBJ.LBJPros.get(i))); + } + if ((ZC_LBJ_listLBJ.LBJDisPros.get(i)).equals("")) { + continue; + } + jp2.add(v + ".2.center.top", field); + fieldList.add(field); + // +++ + MustMap.put(ZC_LBJ_listLBJ.LBJDisPros.get(i), field); + // +++ + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + v++; + } + } + + jp2.setVisible(true); + jp2.validate(); + jp2.repaint(); + scr2.validate(); + } + } + }); + JScrollPane scrollPane = new JScrollPane(tree); + scrollPane.setPreferredSize(new Dimension(250, 250)); + + // ӹ嵽 + jp1.add(scrollPane, BorderLayout.CENTER); + // jp2.setVisible(false); + classJpanel.add(scr2); + JSplitPane splitPane = new JSplitPane(); + splitPane.setOneTouchExpandable(true);// ÷ָʾͷ + splitPane.setContinuousLayout(true);// ͷػͼ + splitPane.setLeftComponent(new JScrollPane(jp1)); + splitPane.setRightComponent(new JScrollPane(classJpanel)); + splitPane.setDividerLocation(0.3); // ÷ָߵλΪ50% + JPanel titlePanel = new JPanel(new FlowLayout());// Խ + + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(button2); + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(okBut); + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(celBut); + + jFrame.add(splitPane, BorderLayout.CENTER); + jFrame.add(titlePanel, BorderLayout.SOUTH); + + button2.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + writer.println("׼"); + G4MDialog classDialog = new G4MDialog("˱", null, revList, session); + new Thread(classDialog).start(); + } + }); + + okBut.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + try { + createItem(login_file); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + // setVisible(false); + } + + }); + celBut.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + writer.println("ȡ"); + jFrame.setVisible(false); + } + }); + jFrame.pack(); + jFrame.setVisible(true); + Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); + int x = (int) ((dimension.getWidth() - jFrame.getWidth()) / 2); + int y = (int) ((dimension.getHeight() - jFrame.getHeight()) / 2); + jFrame.setLocation(x, y); + // this.pack(); + + writer.println("ʼ"+ new Date()); + } catch (TCException e) { + // TODO Auto-generated catch block + + MessageBox.post("init()쳣", "WARNING", MessageBox.WARNING); + e.printStackTrace(); + } + } + + /** + * ǰһַ + * @param items ԭʼ + * @return µ飬ַ + */ + private static String[] prependEmptyString(String[] items) { + String[] newItems = new String[items.length + 1]; + newItems[0] = ""; // ĵһλӿַ + System.arraycopy(items, 0, newItems, 1, items.length); // ԭݵ + return newItems; + } + + /* + * ϴ + */ + public void createItem(File login_file) throws IOException { + // +++жϱ + FileWriter fileWriter = new FileWriter(login_file, true); + PrintWriter writer = new PrintWriter(fileWriter); + writer.println("============="+ new Date()); + String[] mustAttributes = service.getStringValues("RB_CreateRequiredAttribute_ls"); + writer.println(new Date()+"=======>RB_CreateRequiredAttribute_lsѡֵ" + Arrays.toString(mustAttributes)); +// writer.println("=======>attrList"+attrList.toString()); +// writer.println("=======>esAttrList"+esAttrList.toString());MustMap + writer.println(new Date()+"MustMap.size====>" + MustMap.size()); + if (mustAttributes != null && mustAttributes.length > 0) { + for (int i = 0; i < mustAttributes.length; i++) { + writer.println(new Date()+"==>ԣ" + mustAttributes[i]); + if (MustMap.containsKey(mustAttributes[i])) { + + if (MustMap.get(mustAttributes[i]) instanceof JComboBox) { + JComboBox box = (JComboBox) MustMap.get(mustAttributes[i]); + if (box != null) { + writer.println("boxݣ" + box.getSelectedItem()); + if (box.getSelectedItem() == null || ((String) box.getSelectedItem()).equals("")) { + // δд + MessageBox.post(mustAttributes[i] + "," + rb.getString("sxwtx07_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + return; + } + } + } else if (MustMap.get(mustAttributes[i]) instanceof JTextField) { + JTextField field = (JTextField) MustMap.get(mustAttributes[i]); + if (field != null) { + writer.println("boxݣ" + field.getText()); + if (field.getText() == null || ((String) field.getText()).equals("")) { + // δд + MessageBox.post("" + mustAttributes[i] + "," + rb.getString("sxwtx07_display.TITLE"), + "ʾ", MessageBox.INFORMATION); + return; + } + } + } + } + } + } else { + writer.println(new Date()+"RB_CreateRequiredAttributeѡδ"); + } + + writer.println(new Date()+"========Լ======="); + // +++ + + // TODO Auto-generated method stub + String jhID = ""; + try { + if (idList != null && idList.size() > 0) { + JTextField idField = (JTextField) idList.get(0); + JComboBox idbox = (JComboBox) idList.get(1); + String id = idField.getText(); + String boxID = (String) idbox.getSelectedItem(); +// if ("".equals(id.trim()) && "".equals(boxID.trim())) { +// MessageBox.post("δд", "ʾ", MessageBox.INFORMATION); +// return; +// } + if ("".equals(id.trim())) { + id = boxID.trim(); + } + jhID = id; + } + String typeID = ""; + if (typeList != null && typeList.size() > 0) { + JComboBox idComb = typeList.get(0); + typeID = (String) idComb.getSelectedItem(); + if (typeID.indexOf("Ʒ") >= 0 || typeID.indexOf("Finished product") >= 0) { + typeID = ""; + } else if (typeID.indexOf("") >= 0 || typeID.indexOf("Turning workpiece") >= 0) { + typeID = "C"; + } else if (typeID.indexOf("ȴ") >= 0 || typeID.indexOf("Heat treatment parts") >= 0) { + typeID = "R"; + } else if (typeID.indexOf("շ伷") >= 0 + || typeID.indexOf("Cold rolled parts or cold extrusion parts") >= 0) { + typeID = "D"; + } else if (typeID.indexOf("ͼ") >= 0 || typeID.indexOf("Forge piece") >= 0) { + typeID = "D"; + } + } + String item_type = ""; + if (selCodeBean != null) { + item_type = selCodeBean.getType(); + } else { + MessageBox.post(rb.getString("qxzzdcjd07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + String targetId = idField1.getText(); + if ("".equals(targetId.trim())) { + // дܳϱţ + MessageBox.post(rb.getString("qtxwlzcbh07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + String newID = targetId + jhID + typeID; + String revID = (String) revBox.getSelectedItem(); + String itemName = (String) nameComb.getSelectedItem(); + if (classFlag) { + productNumber = splicValue(defaultValueList, attrList, esAttrList, objMap, markList, isNList, lovMap , writer); + writer.println(new Date()+"productNumber============" + productNumber); + drawingNumber = splicValue(defaultValueList2, attrList2, esAttrList2, objMap2, markList2, isNList2, + lovMap2, writer); + + + writer.println(new Date()+"drawingNumber============" + drawingNumber); + if (productNumber == null || drawingNumber == null) { + return; + } + } else { + productNumber = targetItem.getStringProperty("rb3_th") + jhID; + writer.println(new Date()+"productNumber============" + productNumber); + drawingNumber = targetItem.getStringProperty("rb3_th") + jhID; + + writer.println(new Date()+"drawingNumber============" + drawingNumber); + } + + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(item_type); + TCComponentItem find = itemType.find(newID); + if (find != null) { + MessageBox.post(":" + newID + "Ѵ,޷!", "", MessageBox.ERROR); + return; + } + // Ż + List compList = queryObject("RBSearchLBJCPH", new String[] { "Ʒ" }, + new String[] { productNumber }); + if (compList != null) { + if (compList.size() > 0) { + String nID = newID.substring(0, 2); + + for (int j = 0; j < compList.size(); j++) { + writer.println(new Date()+"жitem_idǰλǷͬ"); + String compID = compList.get(j).getProperty("item_id"); + String cID = compID.substring(0, 2); + if (nID.equals(cID)) { + MessageBox.post("ϵͳѴڲƷΪ" + productNumber + "ϣ룡", "", + MessageBox.INFORMATION); + return; + } + } + } + } + // endŻ + TCComponent uom = null; + String dlval = (String) dl.getSelectedItem(); + if (dlval == null || dlval.equals("")) { + MessageBox.post("λѡ", "", MessageBox.INFORMATION); + return; + } else { + TCComponent tcComponent = tagMap.get(dlval); + uom = tcComponent; + } + + TCComponentItem itemComp = itemType.create(newID, revID, item_type, itemName, null, uom); + getFolder(); + folder.add("contents", itemComp); + folder.refresh(); + TCComponentItemRevision itemRev = itemComp.getLatestItemRevision(); + + // Ż + for (int k = 0; k < fieldList.size(); k++) { + JTextField jt = (JTextField) fieldList.get(k); + String key = jt.getName(); + String val = jt.getText(); + fieldmap.put(key, val); + } + for (int m = 0; m < comboxList.size(); m++) { + JComboBox cbo = (JComboBox) comboxList.get(m); + cbo.setEditable(false); + String key = cbo.getName(); + writer.println("comboxNameΪ:" + key); + + if (key.equals("rb3_scgc1") || key.equals("rb3_yyly")) { + JTextField ed = (JTextField) cbo.getEditor().getEditorComponent(); + String text = ed.getText(); + + if (!text.equals("") && text != null) { + List proList = new ArrayList<>(); + String[] split = text.split(","); + TCProperty tclov = ((TCComponentItemRevision) targetItem).getTCProperty(key); + TCComponentListOfValues lov = tclov.getLOV(); + for (int p = 0; p < split.length; p++) { + String realVal = (String) lov.getListOfValues().getRealValue(split[p]); + proList.add(realVal); + } + Object[] array = proList.toArray(); + String[] svals = new String[array.length]; + for (int s = 0; s < array.length; s++) { + svals[s] = (String) array[s]; + } + itemRev.getTCProperty(key).setStringValueArray(svals); + } + } else { + String val = (String) cbo.getSelectedItem(); + TCProperty tclov = ((TCComponentItemRevision) targetItem).getTCProperty(key); + TCComponentListOfValues lov = tclov.getLOV(); + String realVal = (String) lov.getListOfValues().getRealValue(val); + writer.println("ѡеֵΪ:" + val); + comboxmap.put(key, realVal); + } + + } + itemRev.setProperties(fieldmap); + itemRev.setProperties(comboxmap); + + // endŻ + + String statu = ""; + if ("A1".equals(revID)) { + statu = ":Conceptual design"; + } else if ("B1".equals(revID)) { + statu = ":Product design"; + } else if ("R1".equals(revID)) { + statu = ":Process design/Sample delivery"; + } else if ("P1".equals(revID)) { + statu = "P:Pilot production/small batch"; + } else if ("M1".equals(revID)) { + statu = "M:Mass production"; + } + + itemRev.setStringProperty("rb3_cph", productNumber); + itemRev.setStringProperty("rb3_smzqzt", statu); + itemRev.setStringProperty("rb3_jh", jhID); + + String item_id = targetItem.getProperty("item_id"); + String id = dealItemId(item_id,writer); + if (id != null) { + build.append(id); + build.append(drawingNumber); + } else { + build.append(drawingNumber); + } + if ("RB3_GNLBJ".equals(item_type) || "RB3_GNZC".equals(toitemtype)) { +// itemRev.setStringProperty("rb3_glh", drawingNumber); + // itemRev.setStringProperty("rb3_glh", build.toString()); + String glh = getGLH(writer); + itemRev.setStringProperty("rb3_glh", glh); + if (revList.size() > 0) { + TCComponentItemRevision picItem = revList.get(0); + TCComponent[] pics = picItem.getReferenceListProperty("TC_Is_Represented_By"); + for (int i = 0; i < pics.length; i++) { + itemRev.add("TC_Is_Represented_By", pics[i]); + } + // picItem.add("RB3_GLWL", itemRev); + } else { + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent("RB3_GNLJT"); + TCComponentItem LJTItem = typeComponent.create(glh, "V1", "RB3_GNLJT", "", "", null); + if (LJTItem != null) { + TCComponentItemRevision LJTRev = LJTItem.getLatestItemRevision(); + folder.add("contents", LJTItem); + folder.refresh(); + itemRev.add("TC_Is_Represented_By", LJTRev); + } + } + } else { + itemRev.setStringProperty("rb3_th", build.toString()); + if (revList.size() > 0) { + TCComponentItemRevision picItem = revList.get(0); + TCComponent[] pics = picItem.getReferenceListProperty("TC_Is_Represented_By"); + for (int i = 0; i < pics.length; i++) { + itemRev.add("TC_Is_Represented_By", pics[i]); + } + // picItem.add("RB3_GLWL", itemRev); + } else { + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent("RB3_CGT"); + // String revID = typeComponent.getNewRev(null); + // String drawID = typeComponent.getNewID(); + String[] keys = new String[] { " ID" }; +// String[] values = new String[] { drawingNumber }; + String[] values = new String[] { build.toString() }; + List tzList = queryObject(" ID", keys, values); + TCComponentItemRevision CPTRev = null; + if (tzList != null) { + if (tzList.size() > 0) { + if (tzList.get(0) instanceof TCComponentItem) { + TCComponentItem tcItem = (TCComponentItem) tzList.get(0); + CPTRev = tcItem.getLatestItemRevision(); + } + } + } else { + TCComponentItem CPTItem = typeComponent.create(build.toString(), "V1", "RB3_CGT", "", "", null); + CPTRev = CPTItem.getLatestItemRevision(); + if (CPTItem != null) { +// session.getUser().getHomeFolder().add("contents", CPTItem); +// session.getUser().getHomeFolder().refresh(); + if (build.toString().length() > 0) { + CPTRev.setStringProperty("rb3_th", build.toString()); + } else { + CPTRev.setStringProperty("rb3_th", drawingNumber); + } + folder.add("contents", CPTItem); + folder.refresh(); + } + + } + itemRev.add("TC_Is_Represented_By", CPTRev); + // CPTRev.add("RB3_GLWL", itemRev); + } + } + + List vals = new ArrayList(); + for (Map value : values) { + for (Map.Entry entry : value.entrySet()) { + String type = entry.getKey(); + if (type.equals("JComboBox")) { + JComboBox comb1 = (JComboBox) entry.getValue(); + String val = (String) comb1.getSelectedItem(); + vals.add(val); + } else { + JTextField field1 = (JTextField) entry.getValue(); + String val = field1.getText(); + vals.add(val); + } + } + } + Integer[] classKeys = new Integer[classList.size()]; + String[] classVals = new String[classList.size()]; +// writer.println("size============================" + classList.size()); + for (int i = 0; i < labels1.length; i++) { + String val = vals.get(i); + if (val == null || val.trim() == "") { + continue; + } + String val2 = ""; + if (classList.get(i).isIslov()) { + val2 = classList.get(i).getLov().get(val);// ʵֵ +// writer.println("val2================" + val2); +// writer.println("val================" + val); + } else { + val2 = val; + } + classKeys[i] = classList.get(i).getId(); + String attrName = classList.get(i).getName(); + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName) + || (PlmLocaleUtil.getString("PartNumber")).equals(attrName)) { + if ("".equals(val2.trim())) { + JComboBox box = boxMap.get(attrName); + val2 = (String) box.getSelectedItem(); + } + } + classVals[i] = val2; + } + new Thread() { + @Override + public void run() { + // + try { + TCTypeService typeService = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) typeService + .getTypeComponent("BOMWindow"); + // һµwindow + TCComponentBOMWindow view = winType.create(null); + view.lock(); + // öbomline + TCComponentBOMLine line = view.setWindowTopLine(targetItem.getItem(), targetItem, null, null); + // bomline + TCComponentBOMLine childBomline = line.add(itemComp, itemRev, null, false, ""); + view.save(); + // + view.unlock(); + // ر + view.close(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + }.start(); + + // +++ + new Thread() { + @Override + public void run() { + sendObjToClassficationByWebService(className2, itemRev, classKeys, classVals, url , login_file);// ͷ + MessageBox.post(rb.getString("wlcjcg07_display.TITLE"), "", MessageBox.INFORMATION); + } + }.start(); + // +++ +// sendObjToClassficationByWebService(className2, itemRev, classKeys, classVals, url);// ͷ +// MessageBox.post("ϴɹ", "", MessageBox.INFORMATION); + + jFrame.setVisible(false); + + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + MessageBox.post(rb.getString("wlcjsb07_display.TITLE"), "", MessageBox.INFORMATION); + } + writer.flush(); + writer.close(); + } + + /** + * õǰTreeNodeĸ-ƻ + * + * @param treeNode ڵ + * @param names ƻ + * @return + */ + private String getNode(TreeNode treeNode, String names) { + // TODO Auto-generated method stub + if (!names.equals("")) { + names = "&" + names; + } + names = treeNode.toString() + names; + + TreeNode parent = treeNode.getParent(); + if (parent != null) { + return getNode(parent, names); + } + + return names; + } + + /** + * + * + * @param menuBean1 + * @return + * @throws Exception + */ + private JTree getTree(MenuBean menuBean1,PrintWriter writer) throws Exception { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + writer.println("treenodename:"+treenodename); + List list = menuBean1.getList(); + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(treenodename); + if (list != null && list.size() > 0) { + //ѡķIDɸѡҪѡĶ(δӢĻ) + String id = targetItem.getProperty("item_id"); + writer.println("id:"+id); + writer.println(id.substring(0,6)); + String classID = ""; + String subs = id.substring(0, 2); + Boolean xlbFlag = false; + if (subs.equals("XX")) { + classID = id.substring(2, 6); + if ((classID.equals("1166") || classID.equals("2266")) && id.substring(6,8).equals("77")) { + classID+="77"; + } + }else { + + if("221611".equals(id.substring(0,6)) || "221612".equals(id.substring(0,6)) + || "221613".equals(id.substring(0,6)) || "221614".equals(id.substring(0,6)) + || "221615".equals(id.substring(0,6)) || "221616".equals(id.substring(0,6)) + || "221617".equals(id.substring(0,6))) { + //ɸѡṹ + xlbFlag = true; + classID = id.substring(0,6); + }else { + classID = id.substring(0,4); + if ((classID.equals("1166") || classID.equals("2266")) && id.substring(4,6).equals("77")) { + classID+="77"; + } + } + } + + writer.println("classID"+classID); + //ݷIDȡ + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass adminClass = classificationService.newICSAdminClass(); + adminClass.load(classID); + String name = adminClass.getName(); + Boolean flag = true; + for (int i = 0; i < list.size(); i++) { + if(name.contains("DZ")) { + if(list.get(i).getName().contains("DZ")) { + flag = false; + getRecursion(list.get(i), rootNode); + } + }else { + if(classID.startsWith("22")) { + if(xlbFlag) { + if(list.get(i).getName().startsWith("") && list.get(i).getName().contains("")) { + flag = false; + getRecursion(list.get(i), rootNode); + } + }else { + writer.println("name1"+name); + writer.println("name2"+list.get(i).getName()); + if(list.get(i).getName().startsWith("") && list.get(i).getName().endsWith(name)) { + flag = false; + getRecursion(list.get(i), rootNode); + } + } + + }else if(classID.startsWith("11")) { + writer.println("name1"+name); + writer.println("name2"+list.get(i).getName()); + if(list.get(i).getName().endsWith(name) && !list.get(i).getName().startsWith("")) { + flag = false; + getRecursion(list.get(i), rootNode); + } + } + } + } + if(flag) { + for (int i1 = 0; i1 < list.size(); i1++) { + getRecursion(list.get(i1), rootNode); + } + } + } + JTree tree = new JTree(rootNode); + tree.setShowsRootHandles(true); + // tree.setEditable(true); + + return tree; + } + + /** + * ݹ˵ṹ + * + * @param menuBean1 + * @param rootNode + */ + private void getRecursion(MenuBean menuBean1, DefaultMutableTreeNode rootNode) { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode node = new DefaultMutableTreeNode(treenodename); + rootNode.add(node); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), node); + } + } + } + + /** + * ͨѯѯĿ + * + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + return null; + } + } + + /** + * ͷ + */ + public void sendObjToClassficationByWebService(String class_id, TCComponentItemRevision rev, Integer[] keys, + String[] vals, String url,File login_file) { + try { + FileWriter fileWriter = new FileWriter(login_file, true); + PrintWriter writer = new PrintWriter(fileWriter); + writer.println(new Date()+"ͷ"); + writer.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList(); + + for (int i = 0; i < keys.length; i++) { + if (keys[i] != null && vals[i] != null) { + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + writer.println(new Date()+""); + writer.flush(); + writer.close(); + } catch (Exception e) { + e.printStackTrace(); + } + + } + +// public String splicValue(List defaultValueList, List attrList, List esAttrList, +// Map map, List markList, List isNList, Map lovMap) { +// List objList = new ArrayList<>(); +// List lovList = new ArrayList<>(); +// StringBuilder sb = new StringBuilder(); +// +// for (int i = 0; i < attrList.size(); i++) { +// handleAttribute(attrList.get(i), esAttrList.get(i), map, defaultValueList.get(i), lovMap, objList, lovList); +// } +// +// processObjects(objList, lovList, markList, isNList, sb); +// +// return sb.toString(); +// } +// +// private void handleAttribute(String attr, String esAttr, Map map, String defaultValue, +// Map lovMap, List objList, List lovList) { +// if (classFlag2 && isHeatTreatment(attr, esAttr)) { +// objList.add(HeatTreatment); +// lovList.add("string"); +// return; +// } +// +// Object value = getValue(map, attr, esAttr, defaultValue); +// if (value == null) { +// return; +// } +// +// if (isPartNumber(attr, esAttr)) { +// handlePartNumber(objList, lovList); +// return; +// } +// +// if (isRadialInternalClearance(attr, esAttr)) { +// handleRadialInternalClearance(value, objList, lovList); +// return; +// } +// +// objList.add(value); +// lovList.add(getLOVValue(attr, esAttr, lovMap)); +// } +// +// private boolean isHeatTreatment(String attr, String esAttr) { +// return PlmLocaleUtil.getString("heatTreatment").equals(attr) +// || PlmLocaleUtil.getString("heatTreatment").equals(esAttr); +// } +// +// private boolean isPartNumber(String attr, String esAttr) { +// return PlmLocaleUtil.getString("PartNumber").equals(attr) +// || PlmLocaleUtil.getString("PartNumber").equals(esAttr); +// } +// +// private boolean isRadialInternalClearance(String attr, String esAttr) { +// return PlmLocaleUtil.getString("RadialInternalClearance").equals(attr) +// || PlmLocaleUtil.getString("RadialInternalClearance").equals(esAttr); +// } +// +// private Object getValue(Map map, String attr, String esAttr, String defaultValue) { +// if (map.containsKey(attr)) { +// return map.get(attr); +// } else if (map.containsKey(esAttr)) { +// return map.get(esAttr); +// } +// return defaultValue; +// } +// +// private void handlePartNumber(List objList, List lovList) { +// JComboBox idbox = boxMap.get(PlmLocaleUtil.getString("PartNumber")); +// JTextField idfield = (JTextField) idList.get(0); +// String fieldText = idfield.getText().trim(); +// String boxText = ((String) idbox.getSelectedItem()).trim(); +// +// if (!fieldText.isEmpty() && !boxText.isEmpty()) { +// MessageBox.post(PlmLocaleUtil.getString("PartNumber") + "ͬʱдֵ", "ʾ", MessageBox.INFORMATION); +// throw new IllegalArgumentException("Both values cannot be filled at the same time."); +// } +// +// if (!fieldText.isEmpty()) { +// objList.add(fieldText); +// lovList.add("string"); +// } else if (!boxText.isEmpty()) { +// objList.add(boxText); +// lovList.add("string"); +// } +// } +// +// private void handleRadialInternalClearance(Object value, List objList, List lovList) { +// JComboBox box = boxMap.get(PlmLocaleUtil.getString("RadialInternalClearance")); +// if (value instanceof JTextField) { +// JTextField field = (JTextField) value; +// String fieldText = field.getText().trim(); +// String boxText = ((String) box.getSelectedItem()).trim(); +// processTextFieldAndBox(fieldText, boxText, objList, lovList); +// } else { +// objList.add(value); +// lovList.add(box != null ? "yes" : "no"); +// } +// } +// +// private void processTextFieldAndBox(String fieldText, String boxText, List objList, List lovList) { +// if (!fieldText.isEmpty() && !boxText.isEmpty()) { +// MessageBox.post("Բͬʱдֵ", "ʾ", MessageBox.INFORMATION); +// throw new IllegalArgumentException("Both values cannot be filled at the same time."); +// } +// if (!fieldText.isEmpty()) { +// objList.add(fieldText); +// lovList.add("no"); +// } else if (!boxText.isEmpty()) { +// objList.add(boxText); +// lovList.add("yes"); +// } +// } +// +// private String getLOVValue(String attr, String esAttr, Map lovMap) { +// return lovMap.getOrDefault(attr, lovMap.getOrDefault(esAttr, "string")); +// } +// +// private void processObjects(List objList, List lovList, List markList, List isNList, +// StringBuilder sb) { +// for (int i = 0; i < objList.size(); i++) { +// String attrValue = processAttributeValue(objList.get(i), lovList.get(i), isNList.get(i)); +// if (!attrValue.trim().isEmpty()) { +// sb.append(markList.get(i).trim()); +// sb.append(attrValue); +// } +// } +// } +// +// private String processAttributeValue(Object obj, String lov, String isN) { +// if ("yes".equals(lov)) { +// String value = ((JComboBox) obj).getSelectedItem().toString(); +// return processValue(value, isN); +// } else if ("no".equals(lov)) { +// return ((JTextField) obj).getText(); +// } else { +// return obj.toString(); +// } +// } +// +// private String processValue(String value, String isN) { +// if (asList.contains(value) || esList.contains(value)) { +// if (!isN.trim().contains(value)) { +// value = ""; +// } +// } +// value = removePrefix(value); +// value = translateValue(value); +// return asList.contains(value) || esList.contains(value) ? "" : value; +// } +// +// private String removePrefix(String value) { +// if (value.contains(":")) { +// return value.split(":")[0]; +// } else if (value.contains("")) { +// return value.split("")[0]; +// } +// return value; +// } +// +// private String translateValue(String value) { +// switch (value) { +// case "Ʒ": +// case "Finished product": +// return ""; +// case "": +// case "Turning workpiece": +// return "C"; +// case "ȴ": +// case "Heat treatment parts": +// return "R"; +// case "շ伷": +// case "Cold rolled parts or cold extrusion parts": +// return "D"; +// case "ͼ": +// case "Forge piece": +// return "D"; +// default: +// return value; +// } +// } + public String splicValue(List defaultValueList, List attrList, List esAttrList, + Map map, List markList, List isNList, Map lovMap,PrintWriter writer) { + List objList = new ArrayList(); + List lovList = new ArrayList(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < attrList.size(); i++) { + String attr = attrList.get(i); + writer.println("attr======112" + attr); + String esAttr = esAttrList.get(i); + if (classFlag2) { + if ((PlmLocaleUtil.getString("heatTreatment")).equals(attr) + || (PlmLocaleUtil.getString("heatTreatment")).equals(esAttr)) { + objList.add(HeatTreatment); + lovList.add("string"); + continue; + } + } + if (map.get(attr) == null && map.get(esAttr) == null) { + if ((PlmLocaleUtil.getString("PartNumber")).equals(attr) + || (PlmLocaleUtil.getString("PartNumber")).equals(esAttr)) { + JComboBox idbox = boxMap.get(PlmLocaleUtil.getString("PartNumber")); + JTextField idfield = (JTextField) idList.get(0); + String fieldText = idfield.getText(); + String boxText = (String) idbox.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(PlmLocaleUtil.getString("PartNumber") + "ͬʱдֵ", "ʾ", + MessageBox.INFORMATION); + return null; + } +// if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { +// MessageBox.post(PlmLocaleUtil.getString("PartNumber") + "дһֵ", "ʾ", +// MessageBox.INFORMATION); +// return null; +// } + if (!("".equals(fieldText.trim()))) { + objList.add(fieldText); + lovList.add("string"); + } else { + objList.add(boxText); + lovList.add("string"); + } + continue; + } + objList.add(defaultValueList.get(i)); + lovList.add("string"); + continue; + } + if (!("".equals(attr.trim()))) { + Object obj = map.get(attr); + JComboBox box = null; + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attr) + || (PlmLocaleUtil.getString("RadialInternalClearance")).equals(esAttr)) { + box = boxMap.get(PlmLocaleUtil.getString("RadialInternalClearance")); + } + if (obj == null) { + obj = map.get(esAttr); + if (box != null) { + JTextField field = (JTextField) obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(esAttr + "ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(esAttr + "дһֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + } else { + objList.add(box); + lovList.add("yes"); + } + } else { + objList.add(obj); + lovList.add(lovMap.get(esAttr)); + } + } else { + if (box != null) { + JTextField field = (JTextField) obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(attr + "ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(attr + "дһֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + } else { + objList.add(box); + lovList.add("yes"); + } + } else { + objList.add(obj); + lovList.add(lovMap.get(attr)); + } + } + } + } + for (int i = 0; i < objList.size(); i++) { + String attrValue = ""; + Object obj = objList.get(i); + if (obj != null) { + if ("yes".equals(lovList.get(i))) { + String value = (String) ((JComboBox) obj).getSelectedItem(); + writer.println("ֵΪ:" + value); + if (asList.contains(value) || esList.contains(value)) { + if (isNList.get(i).trim().contains(value)) { + if (value.contains(":")) { + writer.println("value============" + value); + String[] values = value.split(":"); + value = values[0]; + } else if (value.contains("")) { + writer.println("value============" + value); + String[] values = value.split(""); + value = values[0]; + } + } else { + value = ""; + } + } else { + if (value.contains(":")) { + writer.println("value============" + value); + String[] values = value.split(":"); + value = values[0]; + } else if (value.contains("")) { + writer.println("value============" + value); + String[] values = value.split(""); + value = values[0]; + } + } + if ("Ʒ".equals(value) || "Finished product".equals(value)) { + value = ""; + } else if ("".equals(value) || "Turning workpiece".equals(value)) { + value = "C"; + } else if ("ȴ".equals(value) || "Heat treatment parts".equals(value)) { + value = "R"; + } else if ("շ伷".equals(value) || "Cold rolled parts or cold extrusion parts".equals(value)) { + value = "D"; + } else if ("ͼ".equals(value) || "Forge piece".equals(value)) { + value = "D"; + } + attrValue = value; + + } else if ("no".equals(lovList.get(i))) { + attrValue = ((JTextField) obj).getText(); + } else { + attrValue = (String) obj; + } + if (asList.contains(attrValue) || esList.contains(attrValue)) { + attrValue = ""; + } else { + if (attrValue.contains(":")) { + writer.println("attrValue============" + attrValue); + String[] values = attrValue.split(":"); + attrValue = values[0]; + } else if (attrValue.contains("")) { + writer.println("attrValue============" + attrValue); + String[] values = attrValue.split(""); + attrValue = values[0]; + } + } + String mark = markList.get(i); + if (!("".equals(attrValue.trim()))) { + sb.append(mark.trim()); + sb.append(attrValue); + } + } + } + return sb.toString(); + } + + // Ż:idΪ22XX22ͷ + public String dealItemId(String id,PrintWriter writer) { + String subs = id.substring(0, 2); + if (subs.equals("XX")) { + + String sub = id.substring(2, 4); + if (sub.equals("22")) { + writer.println("idXX22ͷ!"); + return "XX-"; + } + } else if (subs.equals("22")) { + writer.println("id22ͷ!"); + return "SF-"; + } + return null; + } + + // ҶӦĸļ + public void getFolder() { + boolean b = false; + if (refs.length > 0) { + for (AIFComponentContext ref : refs) { + InterfaceAIFComponent component = ref.getComponent(); + if (component instanceof TCComponentFolder) { + folder = (TCComponentFolder) component; + b = true; + break; + } + } + } + if (!b) { + try { + folder = session.getUser().getHomeFolder(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + public String getGLH(PrintWriter writer) { + // ȡ + JComponent jcomp1 = jcompMap.get(660113); + JComponent jcomp2 = jcompMap.get(660114); + JComponent jcomp3 = jcompMap.get(660115); + + if (jcomp1 == null || jcomp2 == null || jcomp3 == null) { + MessageBox.post("Կͻ롢Ż汾δд", "ʾ", MessageBox.INFORMATION); + return null; + } + + StringBuilder build = new StringBuilder(); + processComponent(jcomp1, build, false); + processComponent(jcomp2, build, false); + processComponent(jcomp3, build, true); // һǰ"-" + + String paramStr = build.toString().trim(); + if (paramStr.isEmpty()) { + MessageBox.post("Կͻ롢Ż汾δд", "ʾ", MessageBox.INFORMATION); + return null; + } + + Object[] params = new Object[] { paramStr, 4, 1, 9999, 1, "" }; + Object[] obj = new Object[] { "" }; + TCUserService userservice = this.session.getUserService(); + + try { + TCUtils.openLogByPass(session, name); + userservice.call("Connor_set_bypass", obj); + + String glh = generateGLH(userservice, params, writer); + writer.println("ɵĹΪ:" + glh); + + return glh; + } catch (TCException e) { + e.printStackTrace(); + } finally { + try { + TCUtils.closeLogByPass(session, name); + userservice.call("Connor_close_bypass", obj); + } catch (TCException e) { + e.printStackTrace(); + } + } + + return null; + } + + private void processComponent(JComponent jcomp, StringBuilder build, boolean isLast) { + if (jcomp instanceof JComboBox) { + JComboBox combo = (JComboBox) jcomp; + String value = (String) combo.getSelectedItem(); + appendValue(build, value, isLast); + } else if (jcomp instanceof JTextField) { + JTextField text = (JTextField) jcomp; + String value = text.getText(); + appendValue(build, value, isLast); + } + } + + private void appendValue(StringBuilder build, String value, boolean isLast) { + if (value != null && !value.trim().isEmpty()) { + if (value.contains(":")) { + value = value.split(":")[0]; + } + build.append(isLast ? "-" : "").append(value).append("|"); + } + } + + private String generateGLH(TCUserService userservice, Object[] params,PrintWriter writer) throws TCException { + String glh; + List compList; + // ȡµĹ + glh = (String) userservice.call("queryPartNo", params); + glh = dealGLH(glh, writer); + writer.println("ɵĹΪ:" + glh); + + // ѯǷظĹ + String[] keys = new String[] { " ID" }; + String[] values = new String[] { glh }; + compList = queryObject(" ID", keys, values); + + if (compList != null && compList.size() > 0) { + glh = new GetNewCode(params,glh).getCode(); + String[] value = new String[] { glh }; + List queryObject = queryObject(" ID", keys, value); + if(queryObject != null && queryObject.size() > 0){ + MessageBox.post("ȡظϵԱ", "", MessageBox.INFORMATION); + return null; + } + } + +// do { +// // ȡµĹ +// glh = (String) userservice.call("queryPartNo", params); +// glh = dealGLH(glh); +// writer.println("ɵĹΪ:" + glh); +// +// // ѯǷظĹ +// String[] keys = new String[] { " ID" }; +// String[] values = new String[] { glh }; +// compList = queryObject(" ID", keys, values); +// } while (isDuplicate(compList)); // Ƿظ + + return glh; + } + + private boolean isDuplicate(List compList) { + // compList Ϊգʾظ + return compList != null && !compList.isEmpty(); + } + + public String dealGLH(String glh,PrintWriter writer) { + writer.println("dealGLH"); + String[] split = glh.split("\\|"); + StringBuilder build = new StringBuilder(); + if (split.length > 3) { + build.append(split[0]); + build.append(split[3]); + build.append(split[1]); + build.append(split[2]); + } else { + writer.println("glhƴ쳣!"); + } + writer.println("glhֵΪ:" + build.toString()); + return build.toString(); + } + + // ȡlovֵ + public String[] getRealLoveName(String lovName,PrintWriter writer) throws TCException { + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues projectItemslov = TCComponentListOfValuesType.findLOVByName(lovName); + String[] projectItems = null; + if (projectItemslov != null) { + writer.println(projectItemslov.toString()); + projectItems = projectItemslov.getListOfValues().getLOVDisplayValues(); + } + return projectItems; + } +} diff --git a/src/com/connor/rb/plm/rb007/Rb007DialogLBJ2.java b/src/com/connor/rb/plm/rb007/Rb007DialogLBJ2.java new file mode 100644 index 0000000..a89f400 --- /dev/null +++ b/src/com/connor/rb/plm/rb007/Rb007DialogLBJ2.java @@ -0,0 +1,1936 @@ +package com.connor.rb.plm.rb007; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.ResourceBundle; +import java.util.Set; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; +import com.connor.rb.plm.entity.ZC_LBJ_listLBJ; +import com.connor.rb.plm.newcombox.RwJComboBox; +import com.connor.rb.plm.rb012.SearchJComItem; +import com.connor.rb.plm.util.ClassAttributeBean; +import com.connor.rb.plm.util.ClassProperty; +import com.connor.rb.plm.util.CodeBean; +import com.connor.rb.plm.util.GetCodeBean; +import com.connor.rb.plm.util.GetNewCode; +import com.connor.rb.plm.util.MenuBean; +import com.connor.rb.plm.util.ParseXML; +import com.connor.rb.plm.util.PlmLocaleUtil; +import com.connor.rb.plm.util.SoaServerUtil; +import com.connor.rb.plm.util.TCUtils; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSKeyLov.KeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +import cn.com.origin.autocode.newitem.generatcode.Item; + +public class Rb007DialogLBJ2 extends AbstractAIFDialog { + private AbstractAIFApplication app; + private TCSession session; + private TCPreferenceService service; + private String name; + private MenuBean menuBean; + private JPanel jp1; + private JPanel jp2; + private JPanel classJpanel; + private StringBuilder build = new StringBuilder(); + private List> values; + private List classList = new ArrayList(); + private Map tagMap = new HashMap(); + // private List codeBeanList; + private CodeBean selCodeBean; + private JButton okBut = new JButton("ȷ"); + private JButton button2 = new JButton("ͼֽ"); + private JButton celBut = new JButton("ȡ"); + private GetCodeBean getcode; + private JLabel[] labels1 = null; + // private JComboBox comb = null; + private String url = ""; + private JScrollPane scr2; + private boolean classFlag = true; + private boolean classFlag2 = false; + private Map map2; + private Map> boxMap = new HashMap>(); + private List revList = new ArrayList(); + private List idList = new ArrayList(); + private List typeList = new ArrayList(); + private JLabel nameLabel; + private JComboBox nameComb; + private JComboBox dl; + private JLabel idLabel; + private JTextField idField1; + private JLabel revLabel; + private JComboBox revBox; + private String className2; + private TCComponentItemRevision targetItem; + private TCComponentItem taItem; + private String productNumber = ""; + private String drawingNumber = ""; + private String HeatTreatment = ""; + private Map> attrMap; + private Map> attrMap2; + private Map objMap = new HashMap(); + private Map objMap2 = new HashMap(); + private Map lovMap = new HashMap(); + private Map lovMap2 = new HashMap(); + private List attrList = new ArrayList(); + private List esAttrList = new ArrayList(); + // private List objList = new ArrayList(); + // private List lovList = new ArrayList(); + private List attrList2 = new ArrayList(); + private List esAttrList2 = new ArrayList(); + // private List objList2 = new ArrayList(); + // private List lovList2 = new ArrayList(); + private List markList = new ArrayList(); + private List markList2 = new ArrayList(); + private List isNList = new ArrayList(); + private List isNList2 = new ArrayList(); + private List defaultValueList = new ArrayList(); + private List defaultValueList2 = new ArrayList(); + private List asList = new ArrayList(); + private List esList = new ArrayList(); + // Ż + private AIFComponentContext[] refs; + private TCComponentFolder folder; + private TCComponentItem tccItem; + private String toitemtype; + private int v = 0; + private Map lishu_lov = ZC_LBJ_listLBJ.LiShu_lov; + private Map lishu = ZC_LBJ_listLBJ.LiShu; + private Map zc_pro_map = new HashMap();// ܳɵԼֵ + // TextField + private List fieldList = new ArrayList(); + // box + private List comboxList = new ArrayList(); + private Map fieldmap = new HashMap<>(); + private Map comboxmap = new HashMap<>(); + private Map jcompMap = new HashMap(); + + private Map MustMap = new HashMap();// +++ǩдӽжǷ + private ResourceBundle rb; + + public Rb007DialogLBJ2(AbstractAIFApplication app, String name) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.name = name; + this.values = new ArrayList>(); + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + Locale defaultLocale = Locale.getDefault(); + rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + } + + public Rb007DialogLBJ2(AbstractAIFApplication app, String name, String itemtype) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.name = name; + this.values = new ArrayList>(); + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + this.toitemtype = itemtype; + Locale defaultLocale = Locale.getDefault(); + rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + } + + @Override + public void run() { + System.out.println("ʼʼȡѡ: " + new Date()); + + try { + // ʼGetCodeBeanMenuBean + getcode = new GetCodeBean(session); + menuBean = getcode.getMenuBean(name); + + // ѡ + loadPreferences(); + + // XMLļ + ParseXML xml = new ParseXML(); + attrMap = loadAndValidateXML(xml, "RB3_CPHPJFS"); + attrMap2 = loadAndValidateXML(xml, "RB3_THPJFS"); + + // ʼĿ + initializeTargetComponent(app.getTargetComponent()); + + System.out.println("ʼ: " + new Date()); + System.out.println("ʼ: " + new Date()); + init(); + System.out.println("ʼ: " + new Date()); + } catch (TCException e) { + handleException("ʼʧ", e); + } + + } + + // + private void loadPreferences() throws TCException { + String lovVal = service.getStringValue("RB3_lovVal_default"); + String esLovVal = service.getStringValue("RB3_esLovVal_default"); + if (lovVal.contains(";")) { + String[] vals = lovVal.split(";"); + String[] esVals = esLovVal.split(";"); + for (int i = 0; i < vals.length; i++) { + asList.add(vals[i]); + esList.add(esVals[i]); + } + } + } + + private Map> loadAndValidateXML(ParseXML xml, String key) throws TCException { + File file = xml.getSXX(key, session); + Map> result = xml.parseXMLAttr(file); + if (result == null || result.isEmpty()) { + MessageBox.post("ѡ" + key + "δã飡", "WARNING", MessageBox.WARNING); + throw new TCException("ѡδ: " + key); + } + return result; + } + + private void initializeTargetComponent(InterfaceAIFComponent targetComp) throws TCException { + if (targetComp instanceof TCComponentItemRevision) { + targetItem = (TCComponentItemRevision) targetComp; + tccItem = targetItem.getItem(); + } else if (targetComp instanceof TCComponentItem) { + taItem = (TCComponentItem) targetComp; + targetItem = taItem.getLatestItemRevision(); + tccItem = taItem; + } + refs = tccItem.whereReferenced(); + zc_pro_map = tccItem.getProperties(); + } + + private void handleException(String message, Exception e) { + MessageBox.post(message, "WARNING", MessageBox.WARNING); + e.printStackTrace(); + } + + /** + * ҳ + * + * @throws TCException + */ + private void init() throws TCException { + // TODO Auto-generated method stub + this.setTitle(name); + this.setPreferredSize(new Dimension(860, 900)); + this.setLayout(new BorderLayout()); + classJpanel = new JPanel(new BorderLayout());// Խ + jp1 = new JPanel(new BorderLayout()); + jp2 = new JPanel(new PropertyLayout()); + jp1.setPreferredSize(new Dimension(200, 820)); + scr2 = new JScrollPane(jp2); + scr2.setPreferredSize(new Dimension(640, 820)); + classJpanel.add(scr2); + JTree tree = null; + try { + tree = getTree(menuBean); + } catch (Exception e3) { + // TODO Auto-generated catch block + e3.printStackTrace(); + } + + tree.addKeyListener(new KeyListener() { + + @Override + public void keyTyped(KeyEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void keyPressed(KeyEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void keyReleased(KeyEvent e) { + // TODO Auto-generated method stub + int keyCode = e.getKeyCode(); + + if (keyCode == 27) { + int option = JOptionPane.showOptionDialog(null, "ȷ˳˵", "", 0, 1, null, null, + Integer.valueOf(0)); + if (option == 0) { + System.out.println("˳"); + dispose(); + } else { + return; + } + } + } + }); + + tree.addTreeSelectionListener(new TreeSelectionListener() { + public void valueChanged(TreeSelectionEvent e) { + classFlag = true; + classFlag2 = false; + objMap.clear(); + objMap2.clear(); + fieldList.clear(); + comboxList.clear(); + fieldmap.clear(); + comboxmap.clear(); + lovMap.clear(); + lovMap2.clear(); + attrList.clear(); + esAttrList.clear(); + attrList2.clear(); + esAttrList2.clear(); + classList.clear(); + markList.clear(); + markList2.clear(); + isNList.clear(); + isNList2.clear(); + defaultValueList.clear(); + defaultValueList2.clear(); + jp2.removeAll(); + idList.clear(); + DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) e.getPath().getLastPathComponent(); + int childCount = treeNode.getChildCount(); + System.out.println("ǰѡеĽڵ: " + treeNode + " ӽڵ:" + childCount); + if (childCount > 0) { + jp2.setVisible(false); + } else { + String names = getNode(treeNode, ""); + selCodeBean = getcode.getCodebean(names); + if (selCodeBean == null) { + // ѡײڵ㣡 + MessageBox.post(rb.getString("qxzzdcjd07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + JTextField idfield = new JTextField(18); + idList.add(idfield); + JComboBox idbox = new JComboBox(); + + idList.add(idbox); + idbox.addItem(" "); + String[] idstrs = new String[100]; + for (int j = 0; j < 100; j++) { + if (j < 10) { + idstrs[j] = "0" + j; + } else { + idstrs[j] = j + ""; + } + } + for (int j = 0; j < idstrs.length; j++) { + idbox.addItem(idstrs[j]); + } + boxMap.put(PlmLocaleUtil.getString("PartNumber"), idbox); + revLabel = new JLabel(rb.getString("banben_display.TITLE")); + revBox = new JComboBox(); + revBox.setEditable(false); + revBox.addItem("B1"); + String[] revs = service.getStringValues("RB_Revision_id"); + if (revs == null || revs.length <= 0) { + MessageBox.post("ѡRB_Revision_idδ,ϵԱ!!", "", MessageBox.ERROR); + return; + } + for (int i = 0; i < revs.length; i++) { + revBox.addItem(revs[i]); + } + nameLabel = new JLabel(rb.getString("mingcheng_display.TITLE")); + nameComb = new JComboBox(); + nameComb.setEditable(false); + + nameComb.addItem(""); + String[] lbjNames = service.getStringValues("RB3_LBJ_names"); + + if (lbjNames == null || lbjNames.length <= 0) { + MessageBox.post("ѡRB3_LBJ_namesδ,ϵԱ!!", "", MessageBox.ERROR); + return; + } + for (int i = 0; i < lbjNames.length; i++) { + nameComb.addItem(lbjNames[i]); + } + + // Ż + nameComb.setSelectedIndex(1); + // endŻ + + idLabel = new JLabel(rb.getString("zcwlbm_display.TITLE")); + idField1 = new JTextField(18); + + // Ż + try { + idField1.setText(targetItem.getProperty("item_id")); + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + // endŻ + + jp2.add("1.1.center.center", new JLabel("")); + jp2.add("2.1.center.center", idLabel); + jp2.add("2.2.center.center", idField1); + jp2.add("3.1.center.center", nameLabel); + jp2.add("3.2.center.center", nameComb); + jp2.add("4.1.center.center", new JLabel(PlmLocaleUtil.getString("PartNumber"))); + jp2.add("4.2.center.center", idfield); + jp2.add("4.3.center.center", idbox); + jp2.add("5.1.center.center", revLabel); + jp2.add("5.2.center.center", revBox); + try { + String className = targetItem.getClassificationClass(); + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + System.out.println("className============" + className); + c.load(className); + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + // ȡ + TCComponentICO[] icos = targetItem.getClassificationObjects(); + System.out.print("icos:====" + icos); + if (icos == null || icos.length <= 0) { + // ѡеûз͵࣬뷢ͣ + MessageBox.post(rb.getString("xzdwlmyfsdfl07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + Map claMap = new HashMap(); + if (icos != null && icos.length > 0) { + + ICSProperty[] icss = icos[0].getICSProperties(true); + + for (ICSProperty ics : icss) { + for (ICSAdminClassAttribute icsa : icsAttrS) { + if (icsa.getAttributeId() == ics.getId()) { + System.out.print("icsa.getName():" + icsa.getName()); + claMap.put(icsa.getName(), ics.getValue()); + } + } + } + } + ICSAdminClass c2 = classificationService.newICSAdminClass(); + className2 = selCodeBean.getClassID(); + System.out.println("className2===========" + className2); + if (attrMap.containsKey(className2)) { + List nameMarkList = attrMap.get(className2); + String attrNames = nameMarkList.get(0); + String marks = nameMarkList.get(1); + String defaultValues = nameMarkList.get(2); + String isN = nameMarkList.get(3); + if (attrNames.contains(";")) { + String[] attrs = attrNames.split(";"); + String[] markss = marks.split(";"); + String[] valuess = defaultValues.split(";"); + String[] isNs = isN.split(";"); + for (int i = 0; i < attrs.length; i++) { + System.out.println("attrs==============" + attrs[i]); + if (attrs[i].contains("+")) { + String[] attrss = attrs[i].split("\\+"); + attrList.add(attrss[0]); + esAttrList.add(attrss[1]); + markList.add(markss[i]); + defaultValueList.add(valuess[i]); + isNList.add(isNs[i]); + } + } + } + + List nameMarkList2 = attrMap2.get(className2); + String attrNames2 = nameMarkList2.get(0); + String marks2 = nameMarkList2.get(1); + String defaultValues2 = nameMarkList2.get(2); + String isNs2 = nameMarkList2.get(3); + System.out.println("attrNames2============" + attrNames2); + if (attrNames2.contains(";")) { + String[] attrs2 = attrNames2.split(";"); + String[] markss2 = marks2.split(";"); + String[] valuess = defaultValues2.split(";"); + String[] isNs2s = isNs2.split(";"); + for (int i = 0; i < attrs2.length; i++) { + if (attrs2[i].contains("+")) { + String[] attrss = attrs2[i].split("\\+"); + attrList2.add(attrss[0]); + esAttrList2.add(attrss[1]); + markList2.add(markss2[i]); + defaultValueList2.add(valuess[i]); + isNList2.add(isNs2s[i]); + } + } + } + } + c2.load(className2); + String cName = c2.getName(); + if (PlmLocaleUtil.getString("BearingAccessories").equals(cName)) { + classFlag = false; + } else if (PlmLocaleUtil.getString("Cage").equals(cName)) { + classFlag2 = true; + } + System.out.println("cName===" + cName); + ICSAdminClassAttribute[] icsAttrS2 = c2.getAttributes(); + if (icsAttrS2 != null) { + for (ICSAdminClassAttribute attr : icsAttrS2) { + if (attr.isHidden()) { + continue; + } + ClassAttributeBean bean = new ClassAttributeBean(); + if (attr.isReferenceAttribute()) {// + continue; + } + if (attr.isReference()) { + continue; + } + int propID = attr.getAttributeId(); + bean.setId(propID); + String propDisName = attr.getName(); + System.out.print("propDisName:" + propDisName); + bean.setName(propDisName); + + int attrType = attr.getFormat1().getType(); + bean.setType(attrType); + // ÷ + if (claMap != null && claMap.containsKey(propDisName)) { + bean.setVal(claMap.get(propDisName)); + } else { + bean.setVal(""); + } + ICSKeyLov lov1 = attr.getFormat1().getKeyLov(); + lov1 = (lov1 == null ? attr.getFormat2().getKeyLov() : lov1); + if (lov1 != null) { + bean.setIslov(true); + String[] keys = lov1.getKeys(); + Map map1 = new HashMap(); + for (String key : keys) { + KeyLov lov_key = lov1.getKeyLovOfKey(key); + boolean deprecated = lov_key.isDeprecated(); + if (deprecated) { + if (key.equals(bean.getVal())) { + bean.setVal(""); + } + continue; + } + String value = lov1.getValueOfKey(key); + map1.put(value, key);// <ʾֵ,ʵֵ> + if (key.equals(bean.getVal()) && (!bean.getVal().equals(""))) { + bean.setVal(value); + } + } + bean.setLov(map1); + } else { + bean.setIslov(false); + } + + classList.add(bean); + + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + + labels1 = new JLabel[classList.size()]; + System.out.print("classList.size():" + classList.size()); + for (int i = 0; i < classList.size(); i++) { + JComponent jcomp = null; + ClassAttributeBean bean = classList.get(i); + String attrName = bean.getName(); + int propID = bean.getId(); + labels1[i] = new JLabel(attrName); + jp2.add((i + 6) + ".1.center.top", labels1[i]); + labels1[i].setBounds(5, 5, 5, 5); + String value = bean.getVal(); + System.out.println("ĬֵΪ:" + value); + if (bean.isIslov()) { + JComboBox comb = new JComboBox(); + // Ż + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + // end + comb.setEditable(false); + comb.setSize(new Dimension(60, 40)); + if (classFlag2) { + if ((PlmLocaleUtil.getString("heatTreatment")).equals(attrName)) { + comb.addItem(""); + HeatTreatment = value; + } else { + comb.addItem(value); + } + } else { + comb.addItem(value); + } + for (Entry entry : bean.getLov().entrySet()) { + if (i == 0) { + System.out.println("entry.getKey()====" + entry.getKey()); + } + if (!(value.equals(entry.getKey()))) { + comb.addItem(entry.getKey()); + } + } + // Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + System.out.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(comb, tip); + } + } + + }); + // end + map2 = new HashMap(); + map2.put("JComboBox", comb); + values.add(map2); + jp2.add((i + 6) + ".2.center.top", comb); + jp2.add((i + 6) + ".3.center.top", jt); + jp2.add((i + 6) + ".4.center.top", bu); + if (attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, comb); + lovMap.put(attrName, "yes"); + } + if (attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, comb); + lovMap2.put(attrName, "yes"); + } + + if ((PlmLocaleUtil.getString("Category")).equals(attrName)) { + typeList.add(comb); + } + jcomp = comb; + } else { + JTextField field = new JTextField(18); + field.setText(value); + map2 = new HashMap(); + map2.put("JTextField", field); + values.add(map2); + jp2.add((i + 6) + ".2.center.top", field); + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName)) { + JComboBox box = new JComboBox(); + // Ż + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + // end + box.addItem(" "); + String[] strs = new String[] { "C0", "C2", "C3", "C4", "C5" }; + for (int j = 0; j < strs.length; j++) { + box.addItem(strs[j]); + } + // Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + System.out.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(box, tip); + } + } + + }); + boxMap.put(attrName, box); + jp2.add((i + 6) + ".3.center.top", box); + jp2.add((i + 6) + ".4.center.top", jt); + jp2.add((i + 6) + ".5.center.top", bu); + } + if (attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, field); + lovMap.put(attrName, "no"); + } + if (attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, field); + lovMap2.put(attrName, "no"); + } + jcomp = field; + } + v = i + 7; + + if (propID == 660113 || propID == 660114 || propID == 660115) { + jcompMap.put(propID, jcomp); + } + } + + // Ż + jp2.add(v + ".1.center.top", new JLabel(" ")); + jp2.add(v + ".2.center.top", new JLabel("**********************")); + v += 1; + // λ + if (Locale.getDefault().toString().equalsIgnoreCase("zh_CN")) { + jp2.add(v + ".1.center.top", new JLabel("λ")); + } else { + jp2.add(v + ".1.center.top", new JLabel("Unit of measurement")); + } + + try { + tagMap.clear(); + dl = new JComboBox(); + dl.setSize(new Dimension(60, 40)); + dl.setName("uom_tag"); + TCProperty zclov1; + TCComponentItem oldItem = targetItem.getItem(); + zclov1 = oldItem.getTCProperty("uom_tag"); + + TCComponentListOfValues zcprolov1 = zclov1.getLOV(); + String[] comboxitems1; + JTextField jt1 = new JTextField(9); + JButton bu1 = new JButton(""); + if (zcprolov1 != null) { + comboxitems1 = zcprolov1.getListOfValues().getLOVDisplayValues(); + TCComponent[] tags = zcprolov1.getListOfValues().getTagListOfValues(); + for (int flag = 0; flag < comboxitems1.length; flag++) { + tagMap.put(comboxitems1[flag], tags[flag]); + } + ComboBoxModel model1 = new DefaultComboBoxModel(comboxitems1); + dl.setModel(model1); + bu1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip1 = jt1.getText(); + System.out.println("" + tip1); + if (tip1.length() > 0) { + SearchJComItem.changeBox(dl, tip1); + } + } + + }); + } + dl.setSelectedItem(oldItem.getProperty("uom_tag")); + // if(!(ZC_LBJ_listLBJ.LBJDisPros.get(i)).equals("ʱϱʶ")) { + dl.setSelectedIndex(-1); + jp2.add(v + ".2.center.top", dl); + jp2.add((v) + ".3.center.top", jt1); + jp2.add((v) + ".4.center.top", bu1); + v += 1; + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + // λ + MustMap.put("λ", dl); + + if ("RB3_GNZC".equals(toitemtype)) { + for (int i = 0; i < ZC_LBJ_listLBJ.GNZCPros.size(); i++) { + ZC_LBJ_listLBJ.LBJPros.size(); + + System.out.println("ѭ" + i + ",ҪӵΪ" + ZC_LBJ_listLBJ.GNZCDisPros.get(i) + "(" + + ZC_LBJ_listLBJ.GNZCPros.get(i) + ")"); + if (Locale.getDefault().toString().equalsIgnoreCase("zh_CN")) { + jp2.add((v) + ".1.center.top", new JLabel(ZC_LBJ_listLBJ.GNZCDisPros.get(i))); + } else { + jp2.add((v) + ".1.center.top", new JLabel(ZC_LBJ_listLBJ.YWGNZCDisPros.get(i))); + } + + boolean b = ZC_LBJ_listLBJ.map.containsKey(ZC_LBJ_listLBJ.GNZCPros.get(i)); + try { + if (b) { + + System.out.println("Lov"); + // lovֵ + String[] profitLov = getRealLoveName(ZC_LBJ_listLBJ.GNZCPros.get(i)); + JComboBox zcBox = new JComboBox(profitLov); + zcBox.setSize(new Dimension(60, 40)); + zcBox.setName(ZC_LBJ_listLBJ.GNZCDisPros.get(i)); + + jp2.add(v + ".2.center.top", zcBox); + MustMap.put(ZC_LBJ_listLBJ.GNZCDisPros.get(i), zcBox); + } else { + JTextField field = new JTextField(18); + field.setName(ZC_LBJ_listLBJ.GNZCPros.get(i)); + jp2.add(v + ".2.center.top", field); + fieldList.add(field); + // +++ + MustMap.put(ZC_LBJ_listLBJ.GNZCDisPros.get(i), field); + // +++ + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + v++; + + } + } else { + for (int i = 0; i < ZC_LBJ_listLBJ.LBJPros.size(); i++) { + + System.out.println("ѭ" + i + ",ҪӵΪ" + ZC_LBJ_listLBJ.LBJDisPros.get(i) + "(" + + ZC_LBJ_listLBJ.LBJPros.get(i) + ")"); + if ((ZC_LBJ_listLBJ.LBJDisPros.get(i)).equals("Ʒ") + || (ZC_LBJ_listLBJ.LBJDisPros.get(i)).equals("ͼ")) { + + continue; + } + if (Locale.getDefault().toString().equalsIgnoreCase("zh_CN")) { + jp2.add((v) + ".1.center.top", new JLabel(ZC_LBJ_listLBJ.LBJDisPros.get(i))); + } else { + jp2.add((v) + ".1.center.top", new JLabel(ZC_LBJ_listLBJ.YWLBJDisPros.get(i))); + } + + boolean b = ZC_LBJ_listLBJ.map.containsKey(ZC_LBJ_listLBJ.LBJPros.get(i)); + try { + if (b) { + + System.out.println("Lov"); + if (ZC_LBJ_listLBJ.LBJPros.get(i).equals("rb3_scgc1") + || ZC_LBJ_listLBJ.LBJPros.get(i).equals("rb3_yyly")) { + String na = ZC_LBJ_listLBJ.LBJPros.get(i); + String[] vals = ((TCComponentItemRevision) targetItem).getTCProperty(na) + .getStringValueArray(); + JComboBox nbox = new RwJComboBox(new String[] { "" }); + nbox.setEditable(true); + TCProperty zclov = ((TCComponentItemRevision) targetItem) + .getTCProperty(ZC_LBJ_listLBJ.LBJPros.get(i)); + TCComponentListOfValues zcprolov = zclov.getLOV(); + List disVal = new ArrayList(); + String[] comboxitems; + for (int a = 0; a < vals.length; a++) { + if (vals[a] != null && !vals[a].equals("")) { + String disname = zcprolov.getListOfValues() + .getDisplayableValue(vals[a]); + disVal.add(disname); + } + } + if (zcprolov != null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + // ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + + nbox = new RwJComboBox(comboxitems); + nbox.setEditable(true); + nbox.setName(na); + nbox.setSize(new Dimension(60, 40)); + if (disVal.size() > 0) { + StringBuilder sb = new StringBuilder(); + for (int t = 0; t < disVal.size(); t++) { + if (t != (vals.length - 1)) { + + sb.append(disVal.get(t)); + sb.append(","); + } else { + sb.append(disVal.get(t)); + } + } + JTextField ed = (JTextField) nbox.getEditor().getEditorComponent(); + ed.setText(sb.toString()); + } + comboxList.add(nbox); + } + + jp2.add(v + ".2.center.top", nbox); + + // +++ + MustMap.put(ZC_LBJ_listLBJ.LBJDisPros.get(i), nbox); + // +++ + } else { + JComboBox zcBox = new JComboBox(); + zcBox.setSize(new Dimension(60, 40)); + zcBox.setName(ZC_LBJ_listLBJ.LBJPros.get(i)); + TCProperty zclov = ((TCComponentItemRevision) targetItem) + .getTCProperty(ZC_LBJ_listLBJ.LBJPros.get(i)); + TCComponentListOfValues zcprolov = zclov.getLOV(); + String[] comboxitems; + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + if (zcprolov != null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + comboxitems = prependEmptyString(comboxitems); + ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + + zcBox.setModel(model); + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + System.out.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(zcBox, tip); + } + } + + }); + comboxList.add(zcBox); + } + + zcBox.setSelectedItem(zc_pro_map.get(ZC_LBJ_listLBJ.LBJPros.get(i))); + System.out.println("testName:" + ZC_LBJ_listLBJ.LBJDisPros.get(i)); + // if(!(ZC_LBJ_listLBJ.LBJDisPros.get(i)).equals("ʱϱʶ")) { + zcBox.setSelectedIndex(-1); + // } + + jp2.add(v + ".2.center.top", zcBox); + jp2.add((v) + ".3.center.top", jt); + jp2.add((v) + ".4.center.top", bu); + // +++ + MustMap.put(ZC_LBJ_listLBJ.LBJDisPros.get(i), zcBox); + // +++ + } + } else { + JTextField field = new JTextField(18); + field.setName(ZC_LBJ_listLBJ.LBJPros.get(i)); + if ((ZC_LBJ_listLBJ.LBJDisPros.get(i)).equals("û")) { + field.setText(zc_pro_map.get(ZC_LBJ_listLBJ.LBJPros.get(i))); + } + if ((ZC_LBJ_listLBJ.LBJDisPros.get(i)).equals("")) { + continue; + } + jp2.add(v + ".2.center.top", field); + fieldList.add(field); + // +++ + MustMap.put(ZC_LBJ_listLBJ.LBJDisPros.get(i), field); + // +++ + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + v++; + } + } + + jp2.setVisible(true); + jp2.validate(); + jp2.repaint(); + scr2.validate(); + } + } + }); + JScrollPane scrollPane = new JScrollPane(tree); + scrollPane.setPreferredSize(new Dimension(250, 250)); + + // ӹ嵽 + jp1.add(scrollPane, BorderLayout.CENTER); + // jp2.setVisible(false); + classJpanel.add(scr2); + JSplitPane splitPane = new JSplitPane(); + splitPane.setOneTouchExpandable(true);// ÷ָʾͷ + splitPane.setContinuousLayout(true);// ͷػͼ + splitPane.setLeftComponent(new JScrollPane(jp1)); + splitPane.setRightComponent(new JScrollPane(classJpanel)); + JPanel titlePanel = new JPanel(new FlowLayout());// Խ + + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(button2); + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(okBut); + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(celBut); + + this.add(splitPane, BorderLayout.CENTER); + this.add(titlePanel, BorderLayout.SOUTH); + + button2.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("׼"); + G4MDialog classDialog = new G4MDialog("˱", null, revList, session); + new Thread(classDialog).start(); + } + }); + + okBut.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + // У + verifyData(); + // + createItem(); + } + + }); + celBut.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("ȡ"); + setVisible(false); + } + }); + this.setVisible(true); + this.centerToScreen(); + } + + /** + * + * @Title: verifyData + * @Description: У + * @param + * @return void + * @throws + */ + private void verifyData() { + System.out.println("=============" + new Date()); + String[] mustAttributes = service.getStringValues("RB_CreateRequiredAttribute_ls"); + System.out.println(new Date() + "=======>RB_CreateRequiredAttribute_lsѡֵ" + Arrays.toString(mustAttributes)); + System.out.println(new Date() + "MustMap.size====>" + MustMap.size()); + + if (mustAttributes != null && mustAttributes.length > 0) { + for (int i = 0; i < mustAttributes.length; i++) { + System.out.println(new Date() + "==>ԣ" + mustAttributes[i]); + if (MustMap.containsKey(mustAttributes[i])) { + + if (MustMap.get(mustAttributes[i]) instanceof JComboBox) { + JComboBox box = (JComboBox) MustMap.get(mustAttributes[i]); + if (box != null) { + System.out.println("boxݣ" + box.getSelectedItem()); + if (box.getSelectedItem() == null || ((String) box.getSelectedItem()).equals("")) { + // δд + MessageBox.post(mustAttributes[i] + "," + rb.getString("sxwtx07_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + return; + } + } + } else if (MustMap.get(mustAttributes[i]) instanceof JTextField) { + JTextField field = (JTextField) MustMap.get(mustAttributes[i]); + if (field != null) { + System.out.println("boxݣ" + field.getText()); + if (field.getText() == null || ((String) field.getText()).equals("")) { + // δд + MessageBox.post("" + mustAttributes[i] + "," + rb.getString("sxwtx07_display.TITLE"), + "ʾ", MessageBox.INFORMATION); + return; + } + } + } + } + } + } else { + System.out.println(new Date() + "RB_CreateRequiredAttributeѡδ"); + } + if ("".equals(idField1.getText().trim())) { + // дܳϱţ + MessageBox.post(rb.getString("qtxwlzcbh07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + System.out.println(new Date() + "========Լ======="); + } + + /** + * ǰһַ + * + * @param items ԭʼ + * @return µ飬ַ + */ + private static String[] prependEmptyString(String[] items) { + String[] newItems = new String[items.length + 1]; + newItems[0] = ""; // ĵһλӿַ + System.arraycopy(items, 0, newItems, 1, items.length); // ԭݵ + return newItems; + } + + /* + * ϴ + */ + public void createItem() { + // TODO Auto-generated method stub + String jhID = ""; + try { + if (idList != null && idList.size() > 0) { + JTextField idField = (JTextField) idList.get(0); + JComboBox idbox = (JComboBox) idList.get(1); + String id = idField.getText().trim(); + String boxID = (String) idbox.getSelectedItem(); + jhID = id.isEmpty() ? boxID.trim() : id; + } + + String typeID = ""; + if (typeList != null && typeList.size() > 0) { + JComboBox idComb = typeList.get(0); + String selectedItem = (String) idComb.getSelectedItem(); + if (selectedItem.contains("Ʒ") || selectedItem.contains("Finished product")) { + typeID = ""; + } else if (selectedItem.contains("") || selectedItem.contains("Turning workpiece")) { + typeID = "C"; + } else if (selectedItem.contains("ȴ") || selectedItem.contains("Heat treatment parts")) { + typeID = "R"; + } else if (selectedItem.contains("շ伷") + || selectedItem.contains("Cold rolled parts or cold extrusion parts") + || selectedItem.contains("ͼ") || selectedItem.contains("Forge piece")) { + typeID = "D"; + } + } + + String item_type = selCodeBean != null ? selCodeBean.getType() : ""; + if (item_type.isEmpty()) { + MessageBox.post(rb.getString("qxzzdcjd07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + + String targetId = idField1.getText(); + String newID = targetId + jhID + typeID; + String revID = (String) revBox.getSelectedItem(); + String itemName = (String) nameComb.getSelectedItem(); + + String productNumber, drawingNumber; + if (classFlag) { + productNumber = splicValue(defaultValueList, attrList, esAttrList, objMap, markList, isNList, lovMap); + drawingNumber = splicValue(defaultValueList2, attrList2, esAttrList2, objMap2, markList2, isNList2, + lovMap2); + + if (productNumber == null || drawingNumber == null) { + return; + } + } else { + String baseStr = targetItem.getStringProperty("rb3_th") + jhID; + productNumber = baseStr; + drawingNumber = baseStr; + } + + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(item_type); + TCComponentItem find = itemType.find(newID); + if (find != null) { + MessageBox.post(":" + newID + "Ѵ,޷!", "", MessageBox.ERROR); + return; + } + + // Żѯ߼ + List compList = queryObject("RBSearchLBJCPH", new String[] { "Ʒ" }, + new String[] { productNumber }); + if (compList != null && !compList.isEmpty()) { + String nIDPrefix = newID.substring(0, 2); + Set cIDs = new HashSet<>(); + + for (TCComponent comp : compList) { + String compID = comp.getProperty("item_id"); + cIDs.add(compID.substring(0, 2)); + } + + // ʹHashSetĿٲ + if (cIDs.contains(nIDPrefix)) { + MessageBox.post("ϵͳѴڲƷΪ" + productNumber + "ϣ룡", "", MessageBox.INFORMATION); + return; + } + } + // endŻ + TCComponent uom = null; + String dlval = (String) dl.getSelectedItem(); + if (dlval == null || dlval.equals("")) { + MessageBox.post("λѡ", "", MessageBox.INFORMATION); + return; + } else { + TCComponent tcComponent = tagMap.get(dlval); + uom = tcComponent; + } + + TCComponentItem itemComp = itemType.create(newID, revID, item_type, itemName, null, uom); + getFolder(); + folder.add("contents", itemComp); + folder.refresh(); + TCComponentItemRevision itemRev = itemComp.getLatestItemRevision(); + + // Ż + for (int k = 0; k < fieldList.size(); k++) { + JTextField jt = (JTextField) fieldList.get(k); + String key = jt.getName(); + String val = jt.getText(); + fieldmap.put(key, val); + } + for (int m = 0; m < comboxList.size(); m++) { + JComboBox cbo = (JComboBox) comboxList.get(m); + cbo.setEditable(false); + String key = cbo.getName(); + System.out.println("comboxNameΪ:" + key); + + if (key.equals("rb3_scgc1") || key.equals("rb3_yyly")) { + JTextField ed = (JTextField) cbo.getEditor().getEditorComponent(); + String text = ed.getText(); + + if (!text.equals("") && text != null) { + List proList = new ArrayList<>(); + String[] split = text.split(","); + TCProperty tclov = ((TCComponentItemRevision) targetItem).getTCProperty(key); + TCComponentListOfValues lov = tclov.getLOV(); + for (int p = 0; p < split.length; p++) { + String realVal = (String) lov.getListOfValues().getRealValue(split[p]); + proList.add(realVal); + } + Object[] array = proList.toArray(); + String[] svals = new String[array.length]; + for (int s = 0; s < array.length; s++) { + svals[s] = (String) array[s]; + } + itemRev.getTCProperty(key).setStringValueArray(svals); + } + } else { + String val = (String) cbo.getSelectedItem(); + TCProperty tclov = ((TCComponentItemRevision) targetItem).getTCProperty(key); + TCComponentListOfValues lov = tclov.getLOV(); + String realVal = (String) lov.getListOfValues().getRealValue(val); + System.out.println("ѡеֵΪ:" + val); + comboxmap.put(key, realVal); + } + + } + itemRev.setProperties(fieldmap); + itemRev.setProperties(comboxmap); + + // endŻ + + String statu = ""; + if ("A1".equals(revID)) { + statu = ":Conceptual design"; + } else if ("B1".equals(revID)) { + statu = ":Product design"; + } else if ("R1".equals(revID)) { + statu = ":Process design/Sample delivery"; + } else if ("P1".equals(revID)) { + statu = "P:Pilot production/small batch"; + } else if ("M1".equals(revID)) { + statu = "M:Mass production"; + } + + itemRev.setStringProperty("rb3_cph", productNumber); + itemRev.setStringProperty("rb3_smzqzt", statu); + itemRev.setStringProperty("rb3_jh", jhID); + + String item_id = targetItem.getProperty("item_id"); + String id = dealItemId(item_id); + if (id != null) { + build.append(id); + build.append(drawingNumber); + } else { + build.append(drawingNumber); + } + if ("RB3_GNLBJ".equals(item_type) || "RB3_GNZC".equals(toitemtype)) { + String glh = getGLH(); + itemRev.setStringProperty("rb3_glh", glh); + if (revList.size() > 0) { + TCComponentItemRevision picItem = revList.get(0); + TCComponent[] pics = picItem.getReferenceListProperty("TC_Is_Represented_By"); + for (int i = 0; i < pics.length; i++) { + itemRev.add("TC_Is_Represented_By", pics[i]); + } + } else { + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent("RB3_GNLJT"); + TCComponentItem LJTItem = typeComponent.create(glh, "V1", "RB3_GNLJT", "", "", null); + if (LJTItem != null) { + TCComponentItemRevision LJTRev = LJTItem.getLatestItemRevision(); + folder.add("contents", LJTItem); + folder.refresh(); + itemRev.add("TC_Is_Represented_By", LJTRev); + } + } + } else { + itemRev.setStringProperty("rb3_th", build.toString()); + if (revList.size() > 0) { + TCComponentItemRevision picItem = revList.get(0); + TCComponent[] pics = picItem.getReferenceListProperty("TC_Is_Represented_By"); + for (int i = 0; i < pics.length; i++) { + itemRev.add("TC_Is_Represented_By", pics[i]); + } + } else { + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent("RB3_CGT"); + String[] keys = new String[] { " ID" }; + String[] values = new String[] { build.toString() }; + List tzList = queryObject(" ID", keys, values); + TCComponentItemRevision CPTRev = null; + if (tzList != null) { + if (tzList.size() > 0) { + if (tzList.get(0) instanceof TCComponentItem) { + TCComponentItem tcItem = (TCComponentItem) tzList.get(0); + CPTRev = tcItem.getLatestItemRevision(); + } + } + } else { + TCComponentItem CPTItem = typeComponent.create(build.toString(), "V1", "RB3_CGT", "", "", null); + CPTRev = CPTItem.getLatestItemRevision(); + if (CPTItem != null) { + if (build.toString().length() > 0) { + CPTRev.setStringProperty("rb3_th", build.toString()); + } else { + CPTRev.setStringProperty("rb3_th", drawingNumber); + } + folder.add("contents", CPTItem); + folder.refresh(); + } + + } + itemRev.add("TC_Is_Represented_By", CPTRev); + } + } + + List vals = new ArrayList(); + for (Map value : values) { + for (Map.Entry entry : value.entrySet()) { + String type = entry.getKey(); + if (type.equals("JComboBox")) { + JComboBox comb1 = (JComboBox) entry.getValue(); + String val = (String) comb1.getSelectedItem(); + vals.add(val); + } else { + JTextField field1 = (JTextField) entry.getValue(); + String val = field1.getText(); + vals.add(val); + } + } + } + Integer[] classKeys = new Integer[classList.size()]; + String[] classVals = new String[classList.size()]; + for (int i = 0; i < labels1.length; i++) { + String val = vals.get(i); + if (val == null || val.trim() == "") { + continue; + } + String val2 = ""; + if (classList.get(i).isIslov()) { + val2 = classList.get(i).getLov().get(val);// ʵֵ + } else { + val2 = val; + } + classKeys[i] = classList.get(i).getId(); + String attrName = classList.get(i).getName(); + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName) + || (PlmLocaleUtil.getString("PartNumber")).equals(attrName)) { + if ("".equals(val2.trim())) { + JComboBox box = boxMap.get(attrName); + val2 = (String) box.getSelectedItem(); + } + } + classVals[i] = val2; + } + new Thread() { + @Override + public void run() { + // + try { + TCTypeService typeService = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) typeService + .getTypeComponent("BOMWindow"); + // һµwindow + TCComponentBOMWindow view = winType.create(null); + view.lock(); + // öbomline + TCComponentBOMLine line = view.setWindowTopLine(targetItem.getItem(), targetItem, null, null); + // bomline + TCComponentBOMLine childBomline = line.add(itemComp, itemRev, null, false, ""); + view.save(); + // + view.unlock(); + // ر + view.close(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + }.start(); + + // +++ + new Thread() { + @Override + public void run() { + sendObjToClassficationByWebService(className2, itemRev, classKeys, classVals, url);// ͷ + MessageBox.post(rb.getString("wlcjcg07_display.TITLE"), "", MessageBox.INFORMATION); + } + }.start(); + + setVisible(false); + + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + MessageBox.post(rb.getString("wlcjsb07_display.TITLE"), "", MessageBox.INFORMATION); + } + + } + + /** + * õǰTreeNodeĸ-ƻ + * + * @param treeNode ڵ + * @param names ƻ + * @return + */ + private String getNode(TreeNode treeNode, String names) { + // TODO Auto-generated method stub + if (!names.equals("")) { + names = "&" + names; + } + names = treeNode.toString() + names; + + TreeNode parent = treeNode.getParent(); + if (parent != null) { + return getNode(parent, names); + } + + return names; + } + + /** + * + * + * @param menuBean1 + * @return + * @throws Exception + */ + private JTree getTree(MenuBean menuBean1) throws Exception { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + System.out.println("treenodename:" + treenodename); + List list = menuBean1.getList(); + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(treenodename); + if (list != null && list.size() > 0) { + // ѡķIDɸѡҪѡĶ(δӢĻ) + String id = targetItem.getProperty("item_id"); + System.out.println("id:" + id); + System.out.println(id.substring(0, 6)); + String classID = ""; + String subs = id.substring(0, 2); + if (subs.equals("XX")) { + classID = id.substring(2, 6); + if ((classID.equals("1166") || classID.equals("2266")) && id.substring(6, 8).equals("77")) { + classID += "77"; + } + } else { + + if ("221611".equals(id.substring(0, 6)) || "221612".equals(id.substring(0, 6)) + || "221613".equals(id.substring(0, 6)) || "221614".equals(id.substring(0, 6)) + || "221615".equals(id.substring(0, 6)) || "221616".equals(id.substring(0, 6)) + || "221617".equals(id.substring(0, 6))) { + classID = id.substring(0, 6); + } else { + classID = id.substring(0, 4); + if ((classID.equals("1166") || classID.equals("2266")) && id.substring(4, 6).equals("77")) { + classID += "77"; + } + } + } + + System.out.println("classID" + classID); + // ݷIDȡ + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass adminClass = classificationService.newICSAdminClass(); + adminClass.load(classID); + String name = adminClass.getName(); + Boolean flag = true; + for (int i = 0; i < list.size(); i++) { + if (name.contains("DZ")) { + if (list.get(i).getName().contains("DZ")) { + flag = false; + getRecursion(list.get(i), rootNode); + } + } else { + if (classID.startsWith("22")) { + System.out.println("name1" + name); + System.out.println("name2" + list.get(i).getName()); + if (list.get(i).getName().startsWith("") && list.get(i).getName().endsWith(name)) { + flag = false; + getRecursion(list.get(i), rootNode); + } + } else if (classID.startsWith("11")) { + System.out.println("name1" + name); + System.out.println("name2" + list.get(i).getName()); + if (list.get(i).getName().endsWith(name) && !list.get(i).getName().startsWith("")) { + flag = false; + getRecursion(list.get(i), rootNode); + } + } + } + } + if (flag) { + for (int i1 = 0; i1 < list.size(); i1++) { + getRecursion(list.get(i1), rootNode); + } + } + } + JTree tree = new JTree(rootNode); + tree.setShowsRootHandles(true); + // tree.setEditable(true); + + return tree; + } + + /** + * ݹ˵ṹ + * + * @param menuBean1 + * @param rootNode + */ + private void getRecursion(MenuBean menuBean1, DefaultMutableTreeNode rootNode) { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode node = new DefaultMutableTreeNode(treenodename); + rootNode.add(node); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), node); + } + } + } + + /** + * ͨѯѯĿ + * + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + return null; + } + } + + /** + * ͷ + */ + public void sendObjToClassficationByWebService(String class_id, TCComponentItemRevision rev, Integer[] keys, + String[] vals, String url) { + System.out.println(new Date() + "ͷ"); + try { + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList(); + + for (int i = 0; i < keys.length; i++) { + if (keys[i] != null && vals[i] != null) { + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println(new Date() + ""); + } + + public String splicValue(List defaultValueList, List attrList, List esAttrList, + Map map, List markList, List isNList, Map lovMap) { + List objList = new ArrayList<>(); + List lovList = new ArrayList<>(); + StringBuilder sb = new StringBuilder(); + + for (int i = 0; i < attrList.size(); i++) { + handleAttribute(attrList.get(i), esAttrList.get(i), map, defaultValueList.get(i), lovMap, objList, lovList); + } + + processObjects(objList, lovList, markList, isNList, sb); + + return sb.toString(); + } + + private void handleAttribute(String attr, String esAttr, Map map, String defaultValue, + Map lovMap, List objList, List lovList) { + if (classFlag2 && isHeatTreatment(attr, esAttr)) { + objList.add(HeatTreatment); + lovList.add("string"); + return; + } + + Object value = getValue(map, attr, esAttr, defaultValue); + if (value == null) { + return; + } + + if (isPartNumber(attr, esAttr)) { + handlePartNumber(objList, lovList); + return; + } + + if (isRadialInternalClearance(attr, esAttr)) { + handleRadialInternalClearance(value, objList, lovList); + return; + } + + objList.add(value); + lovList.add(getLOVValue(attr, esAttr, lovMap)); + } + + private boolean isHeatTreatment(String attr, String esAttr) { + return PlmLocaleUtil.getString("heatTreatment").equals(attr) + || PlmLocaleUtil.getString("heatTreatment").equals(esAttr); + } + + private boolean isPartNumber(String attr, String esAttr) { + return PlmLocaleUtil.getString("PartNumber").equals(attr) + || PlmLocaleUtil.getString("PartNumber").equals(esAttr); + } + + private boolean isRadialInternalClearance(String attr, String esAttr) { + return PlmLocaleUtil.getString("RadialInternalClearance").equals(attr) + || PlmLocaleUtil.getString("RadialInternalClearance").equals(esAttr); + } + + private Object getValue(Map map, String attr, String esAttr, String defaultValue) { + if (map.containsKey(attr)) { + return map.get(attr); + } else if (map.containsKey(esAttr)) { + return map.get(esAttr); + } + return defaultValue; + } + + private void handlePartNumber(List objList, List lovList) { + JComboBox idbox = boxMap.get(PlmLocaleUtil.getString("PartNumber")); + JTextField idfield = (JTextField) idList.get(0); + String fieldText = idfield.getText().trim(); + String boxText = ((String) idbox.getSelectedItem()).trim(); + + if (!fieldText.isEmpty() && !boxText.isEmpty()) { + MessageBox.post(PlmLocaleUtil.getString("PartNumber") + "ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + throw new IllegalArgumentException("Both values cannot be filled at the same time."); + } + + if (!fieldText.isEmpty()) { + objList.add(fieldText); + lovList.add("string"); + } else if (!boxText.isEmpty()) { + objList.add(boxText); + lovList.add("string"); + } + } + + private void handleRadialInternalClearance(Object value, List objList, List lovList) { + JComboBox box = boxMap.get(PlmLocaleUtil.getString("RadialInternalClearance")); + if (value instanceof JTextField) { + JTextField field = (JTextField) value; + String fieldText = field.getText().trim(); + String boxText = ((String) box.getSelectedItem()).trim(); + processTextFieldAndBox(fieldText, boxText, objList, lovList); + } else { + objList.add(value); + lovList.add(box != null ? "yes" : "no"); + } + } + + private void processTextFieldAndBox(String fieldText, String boxText, List objList, List lovList) { + if (!fieldText.isEmpty() && !boxText.isEmpty()) { + MessageBox.post("Բͬʱдֵ", "ʾ", MessageBox.INFORMATION); + throw new IllegalArgumentException("Both values cannot be filled at the same time."); + } + if (!fieldText.isEmpty()) { + objList.add(fieldText); + lovList.add("no"); + } else if (!boxText.isEmpty()) { + objList.add(boxText); + lovList.add("yes"); + } + } + + private String getLOVValue(String attr, String esAttr, Map lovMap) { + return lovMap.getOrDefault(attr, lovMap.getOrDefault(esAttr, "string")); + } + + private void processObjects(List objList, List lovList, List markList, List isNList, + StringBuilder sb) { + for (int i = 0; i < objList.size(); i++) { + String attrValue = processAttributeValue(objList.get(i), lovList.get(i), isNList.get(i)); + if (!attrValue.trim().isEmpty()) { + sb.append(markList.get(i).trim()); + sb.append(attrValue); + } + } + } + + private String processAttributeValue(Object obj, String lov, String isN) { + if ("yes".equals(lov)) { + String value = ((JComboBox) obj).getSelectedItem().toString(); + return processValue(value, isN); + } else if ("no".equals(lov)) { + return ((JTextField) obj).getText(); + } else { + return obj.toString(); + } + } + + private String processValue(String value, String isN) { + if (asList.contains(value) || esList.contains(value)) { + if (!isN.trim().contains(value)) { + value = ""; + } + } + value = removePrefix(value); + value = translateValue(value); + return asList.contains(value) || esList.contains(value) ? "" : value; + } + + private String removePrefix(String value) { + if (value.contains(":")) { + return value.split(":")[0]; + } else if (value.contains("")) { + return value.split("")[0]; + } + return value; + } + + private String translateValue(String value) { + switch (value) { + case "Ʒ": + case "Finished product": + return ""; + case "": + case "Turning workpiece": + return "C"; + case "ȴ": + case "Heat treatment parts": + return "R"; + case "շ伷": + case "Cold rolled parts or cold extrusion parts": + return "D"; + case "ͼ": + case "Forge piece": + return "D"; + default: + return value; + } + } + + // Ż:idΪ22XX22ͷ + public String dealItemId(String id) { + String subs = id.substring(0, 2); + if (subs.equals("XX")) { + + String sub = id.substring(2, 4); + if (sub.equals("22")) { + System.out.println("idXX22ͷ!"); + return "XX-"; + } + } else if (subs.equals("22")) { + System.out.println("id22ͷ!"); + return "SF-"; + } + return null; + } + + // ҶӦĸļ + public void getFolder() { + boolean b = false; + if (refs.length > 0) { + for (AIFComponentContext ref : refs) { + InterfaceAIFComponent component = ref.getComponent(); + if (component instanceof TCComponentFolder) { + folder = (TCComponentFolder) component; + b = true; + break; + } + } + } + if (!b) { + try { + folder = session.getUser().getHomeFolder(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + public String getGLH() { + // ȡ + JComponent jcomp1 = jcompMap.get(660113); + JComponent jcomp2 = jcompMap.get(660114); + JComponent jcomp3 = jcompMap.get(660115); + + if (jcomp1 == null || jcomp2 == null || jcomp3 == null) { + MessageBox.post("Կͻ롢Ż汾δд", "ʾ", MessageBox.INFORMATION); + return null; + } + + StringBuilder build = new StringBuilder(); + processComponent(jcomp1, build, false); + processComponent(jcomp2, build, false); + processComponent(jcomp3, build, true); // һǰ"-" + + String paramStr = build.toString().trim(); + if (paramStr.isEmpty()) { + MessageBox.post("Կͻ롢Ż汾δд", "ʾ", MessageBox.INFORMATION); + return null; + } + + Object[] params = new Object[] { paramStr, 4, 1, 9999, 1, "" }; + Object[] obj = new Object[] { "" }; + TCUserService userservice = this.session.getUserService(); + + try { + TCUtils.openLogByPass(session, name); + userservice.call("Connor_set_bypass", obj); + + String glh = generateGLH(userservice, params); + System.out.println("ɵĹΪ:" + glh); + + return glh; + } catch (TCException e) { + e.printStackTrace(); + } finally { + try { + TCUtils.closeLogByPass(session, name); + userservice.call("Connor_close_bypass", obj); + } catch (TCException e) { + e.printStackTrace(); + } + } + + return null; + } + + private void processComponent(JComponent jcomp, StringBuilder build, boolean isLast) { + if (jcomp instanceof JComboBox) { + JComboBox combo = (JComboBox) jcomp; + String value = (String) combo.getSelectedItem(); + appendValue(build, value, isLast); + } else if (jcomp instanceof JTextField) { + JTextField text = (JTextField) jcomp; + String value = text.getText(); + appendValue(build, value, isLast); + } + } + + private void appendValue(StringBuilder build, String value, boolean isLast) { + if (value != null && !value.trim().isEmpty()) { + if (value.contains(":")) { + value = value.split(":")[0]; + } + build.append(isLast ? "-" : "").append(value).append("|"); + } + } + + private String generateGLH(TCUserService userservice, Object[] params) throws TCException { + String glh; + List compList; + glh = (String) userservice.call("queryPartNo", params); + glh = dealGLH(glh); + System.out.println("ɵĹΪ:" + glh); + + // ѯǷظĹ + String[] keys = new String[] { " ID" }; + String[] values = new String[] { glh }; + compList = queryObject(" ID", keys, values); + + if (compList != null && compList.size() > 0) { + glh = new GetNewCode(params,glh).getCode(); + String[] value = new String[] { glh }; + List queryObject = queryObject(" ID", keys, value); + if(queryObject != null && queryObject.size() > 0){ + MessageBox.post("ȡظϵԱ", "", MessageBox.INFORMATION); + return null; + } + } +// do { +// // ȡµĹ +// glh = (String) userservice.call("queryPartNo", params); +// glh = dealGLH(glh); +// System.out.println("ɵĹΪ:" + glh); +// +// // ѯǷظĹ +// String[] keys = new String[] { " ID" }; +// String[] values = new String[] { glh }; +// compList = queryObject(" ID", keys, values); +// } while (isDuplicate(compList)); // Ƿظ + + return glh; + } + + private boolean isDuplicate(List compList) { + // compList Ϊգʾظ + return compList != null && !compList.isEmpty(); + } + + public String dealGLH(String glh) { + System.out.println("dealGLH"); + String[] split = glh.split("\\|"); + StringBuilder build = new StringBuilder(); + if (split.length > 3) { + build.append(split[0]); + build.append(split[3]); + build.append(split[1]); + build.append(split[2]); + } else { + System.out.println("glhƴ쳣!"); + } + System.out.println("glhֵΪ:" + build.toString()); + return build.toString(); + } + + // ȡlovֵ + public String[] getRealLoveName(String lovName) throws TCException { + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues projectItemslov = TCComponentListOfValuesType.findLOVByName(lovName); + String[] projectItems = null; + if (projectItemslov != null) { + System.out.println(projectItemslov.toString()); + projectItems = projectItemslov.getListOfValues().getLOVDisplayValues(); + } + return projectItems; + } +} diff --git a/src/com/connor/rb/plm/rb007/Rb007DialogXZCP.java b/src/com/connor/rb/plm/rb007/Rb007DialogXZCP.java new file mode 100644 index 0000000..76f1a57 --- /dev/null +++ b/src/com/connor/rb/plm/rb007/Rb007DialogXZCP.java @@ -0,0 +1,2285 @@ +package com.connor.rb.plm.rb007; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.ResourceBundle; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; + +import com.connor.rb.plm.entity.ZC_LBJ_list; +import com.connor.rb.plm.newcombox.RwJComboBox; +import com.connor.rb.plm.rb012.SearchJComItem; +import com.connor.rb.plm.util.ClassAttributeBean; +import com.connor.rb.plm.util.ClassProperty; +import com.connor.rb.plm.util.CodeBean; +import com.connor.rb.plm.util.GetCodeBean; +import com.connor.rb.plm.util.GetNewCode; +import com.connor.rb.plm.util.MenuBean; +import com.connor.rb.plm.util.ParseXML; +import com.connor.rb.plm.util.PlmLocaleUtil; +import com.connor.rb.plm.util.SoaServerUtil; +import com.connor.rb.plm.util.TCUtils; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSKeyLov.KeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.services.loose.core._2011_06.DataManagement.SaveAsOut; + +public class Rb007DialogXZCP extends AbstractAIFDialog { + private AbstractAIFApplication app; + private TCSession session; + private TCPreferenceService service; + private String name; + private MenuBean menuBean; + private JPanel jp1; + private JPanel jp2; + private JPanel classJpanel; + private StringBuilder build = new StringBuilder(); + private List> values; + private List classList = new ArrayList(); + private Map tagMap = new HashMap(); + // private List codeBeanList; + private CodeBean selCodeBean; + private JButton okBut = new JButton("ȷ"); + private JButton button2 = new JButton("ͼֽ"); + private JButton celBut = new JButton("ȡ"); + private GetCodeBean getcode; + private JLabel[] labels1 = null; + // private JComboBox comb = null; + private String url = ""; + private JScrollPane scr2; + private boolean classFlag = true; + private boolean classFlag2 = false; + private Map map2; + private Map> boxMap = new HashMap>(); + private List revList = new ArrayList(); + private List idList = new ArrayList(); + private List typeList = new ArrayList(); + private JLabel nameLabel; + private JComboBox nameComb; + private JComboBox dl; + private JLabel idLabel; + private JTextField idField1; + private JLabel revLabel; + private JComboBox revBox; + private String className2; + private TCComponentItemRevision targetItem; + private TCComponentItem taItem; + private String productNumber = ""; + private String drawingNumber = ""; + private String HeatTreatment = ""; + private Map> attrMap; + private Map> attrMap2; + private Map objMap = new HashMap(); + private Map objMap2 = new HashMap(); + private Map lovMap = new HashMap(); + private Map lovMap2 = new HashMap(); + private List attrList = new ArrayList(); + private List esAttrList = new ArrayList(); + // private List objList = new ArrayList(); + // private List lovList = new ArrayList(); + private List attrList2 = new ArrayList(); + private List esAttrList2 = new ArrayList(); + // private List objList2 = new ArrayList(); + // private List lovList2 = new ArrayList(); + private List markList = new ArrayList(); + private List markList2 = new ArrayList(); + private List isNList = new ArrayList(); + private List isNList2 = new ArrayList(); + private List defaultValueList = new ArrayList(); + private List defaultValueList2 = new ArrayList(); + private List asList = new ArrayList(); + private List esList = new ArrayList(); + // Ż + private AIFComponentContext[] refs; + private TCComponentFolder folder; + private TCComponentItem tccItem; + private String toitemtype; + private int v = 0; + private Map lishu_lov = ZC_LBJ_list.LiShu_lov; + private Map lishu = ZC_LBJ_list.LiShu; + private Map zc_pro_map = new HashMap();// ܳɵԼֵ + // TextField + private List fieldList = new ArrayList(); + // box + private List comboxList = new ArrayList(); + private Map fieldmap = new HashMap<>(); + private Map comboxmap = new HashMap<>(); + private Map jcompMap = new HashMap(); + + private Map MustMap = new HashMap();// +++ǩдӽжǷ + // endŻ + + // private String[] lovVal = new String[] { "ǰ", "׼", "޽Ӵ", "ʽ", + // "ͨ", "A:NBR", "0:", "", "", + // "SN:1805ػ", "ȴ", "", "S:(25% to 35%)", + // "C0","V0","Z0","׼","PC:ﵽC&UƷƾҪ" + // ,"P0:ﵽC&UƷƾҪ","ṹҪƹ","0:˫нǽӴ",":SECC൱",":벿Ŷȷ","BC:35"}; + // private String[] esLovVal = new String[] { "Non", "Standard ball", "Non", + // "Open", "Without vent hole", "A:NBR", + // "0:Black", "Non", "Ball", "SN:1805 temper","Conventional monolithic + // martensite quenching heat treatment", + // "Single", "S:(25% to 35%)", "C0","V0","Z0","Standard","PC:Meet the group C&U + // brand accuracy requirements" + // ,"P0:Meet the group C&U brand accuracy requirements","Other structures need + // to formulate rules","0:Double row angular contact ball bearing" + // ,"Not marked: SECC or equivalent","Other materials: confirm with department + // team for approval","BC:35"}; + + public Rb007DialogXZCP(AbstractAIFApplication app, String name) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.name = name; + this.values = new ArrayList>(); + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + + } + + public Rb007DialogXZCP(AbstractAIFApplication app, String name, String itemtype) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.name = name; + this.values = new ArrayList>(); + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + this.toitemtype = itemtype; + System.out.println("toitemtype-----" + toitemtype); + + } + + @Override + public void run() { + + // TODO Auto-generated method stub + + getcode = new GetCodeBean(session); + menuBean = getcode.getMenuBean(name); + // codeBeanList = bean.getCodeBeanList(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HH-mm-ss-SSS"); + String dirsPath = "C:\\Session"; + + String filename = "lscj_display-"+ sdf.format(new Date()) +".txt"; + File login_file = new File(dirsPath,filename); + File path = new File(dirsPath); + if(!path.exists()) { + path.mkdirs(); + } + if(login_file.exists()) { + login_file.delete(); + } + try { + login_file.createNewFile(); + FileWriter fileWriter = new FileWriter(login_file, true); + PrintWriter writer = new PrintWriter(fileWriter); + writer.println(new Date()+"ʼʼ"); + String lovVal = service.getStringValue("RB3_lovVal_default"); + String esLovVal = service.getStringValue("RB3_esLovVal_default"); + if (lovVal.contains(";")) { + String[] vals = lovVal.split(";"); + String[] esVals = esLovVal.split(";"); + for (int i = 0; i < vals.length; i++) { + asList.add(vals[i]); + esList.add(esVals[i]); + } + } + ParseXML xml = new ParseXML(); + File file = xml.getSXX("RB3_CPHPJFS", session); + + attrMap = xml.parseXMLAttr(file,writer); + if (attrMap == null || attrMap.size() <= 0) { + MessageBox.post("ѡRB3_CPHPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + File file2 = xml.getSXX("RB3_THPJFS", session);// hEtFB3llJxBjoC + attrMap2 = xml.parseXMLAttr(file2,writer); + if (attrMap2 == null || attrMap2.size() <= 0) { + MessageBox.post("ѡRB3_THPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + InterfaceAIFComponent targetComp = app.getTargetComponent(); + if (targetComp instanceof TCComponentItemRevision) { + targetItem = (TCComponentItemRevision) targetComp; + tccItem = targetItem.getItem(); + refs = tccItem.whereReferenced(); + // Ż + zc_pro_map = targetItem.getProperties(); + // end + } else if (targetComp instanceof TCComponentItem) { + taItem = (TCComponentItem) targetComp; + targetItem = taItem.getLatestItemRevision(); + tccItem = taItem; + refs = taItem.whereReferenced(); + // Ż + zc_pro_map = taItem.getProperties(); + } + writer.println(new Date()+"ʼ"); + writer.println(new Date()+"ʼ"); + init(writer,login_file); + writer.println(new Date()+"ʼ"); + writer.flush(); + writer.close(); + } catch (Exception e) { + // TODO Auto-generated catch block + + MessageBox.post("init()쳣", "WARNING", MessageBox.WARNING); + e.printStackTrace(); + } + + } + + /** + * ҳ + * + * @throws TCException + */ + private void init(PrintWriter writer,File login_file) throws TCException { + // TODO Auto-generated method stub + this.setTitle(name); + // this.setMinimumSize(new Dimension(860,900)); + this.setPreferredSize(new Dimension(860, 900)); + // this.setLayout(new PropertyLayout()); + this.setLayout(new BorderLayout()); + classJpanel = new JPanel(new BorderLayout());// Խ + jp1 = new JPanel(new BorderLayout()); + jp2 = new JPanel(new PropertyLayout()); + jp1.setPreferredSize(new Dimension(200, 820)); + scr2 = new JScrollPane(jp2); + scr2.setPreferredSize(new Dimension(640, 820)); + classJpanel.add(scr2); + // jp2.setPreferredSize(new Dimension(350, 600)); + JTree tree = getTree(menuBean); + + tree.addKeyListener(new KeyListener() { + + @Override + public void keyTyped(KeyEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void keyPressed(KeyEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void keyReleased(KeyEvent e) { + // TODO Auto-generated method stub + int keyCode = e.getKeyCode(); + + // writer.println(""+keyCode+"!"); + + if (keyCode == 27) { + // int showflag = + // JOptionPane.showConfirmDialog(null,"ȷ˳˵","˳",JOptionPane.YES_NO_OPTION); + int option = JOptionPane.showOptionDialog(null, "ȷ˳˵", "", 0, 1, null, null, + Integer.valueOf(0)); + if (option == 0) { + writer.println("˳"); + dispose(); + } else { + return; + } + } + } + }); + + tree.addTreeSelectionListener(new TreeSelectionListener() { + public void valueChanged(TreeSelectionEvent e) { + // objList.clear(); + // objList2.clear(); + // lovList.clear(); + // lovList2.clear(); + classFlag = true; + classFlag2 = false; + objMap.clear(); + objMap2.clear(); + // zc_pro_map.clear(); + fieldList.clear(); + comboxList.clear(); + fieldmap.clear(); + comboxmap.clear(); + // + + lovMap.clear(); + lovMap2.clear(); + attrList.clear(); + esAttrList.clear(); + attrList2.clear(); + esAttrList2.clear(); + classList.clear(); + markList.clear(); + markList2.clear(); + isNList.clear(); + isNList2.clear(); + defaultValueList.clear(); + defaultValueList2.clear(); + jp2.removeAll(); + idList.clear(); + DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) e.getPath().getLastPathComponent(); + int childCount = treeNode.getChildCount(); + writer.println("ǰѡеĽڵ: " + treeNode + " ӽڵ:" + childCount); + if (childCount > 0) { + jp2.setVisible(false); + } else { + String names = getNode(treeNode, ""); + selCodeBean = getcode.getCodebean(names); + if (selCodeBean == null) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + // ѡײڵ㣡 + MessageBox.post(rb.getString("qxzzdcjd07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + JTextField idfield = new JTextField(18); + idList.add(idfield); + JComboBox idbox = new JComboBox(); + + idList.add(idbox); + idbox.addItem(" "); + String[] idstrs = new String[102]; + for (int j = 0; j < 102; j++) { + if (j < 10) { + idstrs[j] = "0" + j; + } else { + // L G + if (j == 100) { + idstrs[j] = "L"; + } else if (j == 101) { + idstrs[j] = "G"; + } else { + idstrs[j] = j + ""; + } + + } + } + for (int j = 0; j < idstrs.length; j++) { + idbox.addItem(idstrs[j]); + } + boxMap.put(PlmLocaleUtil.getString("PartNumber"), idbox); + revLabel = new JLabel("汾"); + revBox = new JComboBox(); + revBox.setEditable(false); + revBox.addItem("B1"); + String[] revs = service.getStringValues("RB_Revision_id"); + if (revs == null || revs.length <= 0) { + MessageBox.post("ѡRB_Revision_idδ,ϵԱ!!", "", MessageBox.ERROR); + return; + } + for (int i = 0; i < revs.length; i++) { + revBox.addItem(revs[i]); + } + nameLabel = new JLabel("ƣ"); + nameComb = new JComboBox(); + nameComb.setEditable(false); + + nameComb.addItem(""); + String[] lbjNames = service.getStringValues("RB3_XZCP_names"); + if (lbjNames == null || lbjNames.length <= 0) { + MessageBox.post("ѡRB3_XZCP_namesδ,ϵԱ!!", "", MessageBox.ERROR); + return; + } + for (int i = 0; i < lbjNames.length; i++) { + nameComb.addItem(lbjNames[i]); + } + + // Ż + nameComb.setSelectedIndex(1); + // endŻ + + idLabel = new JLabel("ܳϱ룺"); + idField1 = new JTextField(18); + + // Ż + try { + idField1.setText(targetItem.getProperty("item_id")); + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + // endŻ + + jp2.add("1.1.center.center", new JLabel("")); + jp2.add("2.1.center.center", idLabel); + jp2.add("2.2.center.center", idField1); + jp2.add("3.1.center.center", nameLabel); + jp2.add("3.2.center.center", nameComb); + jp2.add("4.1.center.center", new JLabel(PlmLocaleUtil.getString("PartNumber"))); + jp2.add("4.2.center.center", idfield); + jp2.add("4.3.center.center", idbox); + jp2.add("5.1.center.center", revLabel); + jp2.add("5.2.center.center", revBox); + try { + String className = targetItem.getClassificationClass(); + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + writer.println("className============" + className); + c.load(className); + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + // ȡ + TCComponentICO[] icos = targetItem.getClassificationObjects(); + writer.print("icos:====" + icos); + if (icos == null || icos.length <= 0) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle + .getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + // ѡеûз͵࣬뷢ͣ + MessageBox.post(rb.getString("xzdwlmyfsdfl07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + Map claMap = new HashMap(); + if (icos != null && icos.length > 0) { + + ICSProperty[] icss = icos[0].getICSProperties(true); + + for (ICSProperty ics : icss) { + for (ICSAdminClassAttribute icsa : icsAttrS) { + if (icsa.getAttributeId() == ics.getId()) { + writer.print("icsa.getName():" + icsa.getName()); + claMap.put(icsa.getName(), ics.getValue()); + } + } + } + } + ICSAdminClass c2 = classificationService.newICSAdminClass(); + className2 = selCodeBean.getClassID(); + // String xmlClassName = className2.substring(0, 6); + writer.println("className2===========" + className2); + // writer.println("xmlClassName==========="+xmlClassName); + if (attrMap.containsKey(className2)) { + List nameMarkList = attrMap.get(className2); + String attrNames = nameMarkList.get(0); + String marks = nameMarkList.get(1); + String defaultValues = nameMarkList.get(2); + String isN = nameMarkList.get(3); + if (attrNames.contains(";")) { + String[] attrs = attrNames.split(";"); + String[] markss = marks.split(";"); + String[] valuess = defaultValues.split(";"); + String[] isNs = isN.split(";"); + for (int i = 0; i < attrs.length; i++) { + writer.println("attrs==============" + attrs[i]); + if (attrs[i].contains("+")) { + String[] attrss = attrs[i].split("\\+"); + attrList.add(attrss[0]); + esAttrList.add(attrss[1]); + markList.add(markss[i]); + defaultValueList.add(valuess[i]); + isNList.add(isNs[i]); + } + } + } + + if (attrMap2.containsKey(className2)) { + List nameMarkList2 = attrMap2.get(className2); + String attrNames2 = nameMarkList2.get(0); + String marks2 = nameMarkList2.get(1); + String defaultValues2 = nameMarkList2.get(2); + String isNs2 = nameMarkList2.get(3); + writer.println("attrNames2============" + attrNames2); + if (attrNames2.contains(";")) { + String[] attrs2 = attrNames2.split(";"); + String[] markss2 = marks2.split(";"); + String[] valuess = defaultValues2.split(";"); + String[] isNs2s = isNs2.split(";"); + for (int i = 0; i < attrs2.length; i++) { + if (attrs2[i].contains("+")) { + String[] attrss = attrs2[i].split("\\+"); + attrList2.add(attrss[0]); + esAttrList2.add(attrss[1]); + markList2.add(markss2[i]); + defaultValueList2.add(valuess[i]); + isNList2.add(isNs2s[i]); + } + } + } + } + } + c2.load(className2); + String cName = c2.getName(); + if (PlmLocaleUtil.getString("BearingAccessories").equals(cName)) { + classFlag = false; + } else if (PlmLocaleUtil.getString("Cage").equals(cName)) { + classFlag2 = true; + } + writer.println("cName===" + cName); + ICSAdminClassAttribute[] icsAttrS2 = c2.getAttributes(); + if (icsAttrS2 != null) { + for (ICSAdminClassAttribute attr : icsAttrS2) { + if (attr.isHidden()) { + continue; + } + ClassAttributeBean bean = new ClassAttributeBean(); + if (attr.isReferenceAttribute()) {// + continue; + } + if (attr.isReference()) { + continue; + } + int propID = attr.getAttributeId(); + bean.setId(propID); + String propDisName = attr.getName(); + writer.print("propDisName:" + propDisName); + bean.setName(propDisName); + + int attrType = attr.getFormat1().getType(); + bean.setType(attrType); + // ÷ + if (claMap != null && claMap.containsKey(propDisName)) { + bean.setVal(claMap.get(propDisName)); + } else { + bean.setVal(""); + } + ICSKeyLov lov1 = attr.getFormat1().getKeyLov(); + lov1 = (lov1 == null ? attr.getFormat2().getKeyLov() : lov1); + if (lov1 != null) { + bean.setIslov(true); + String[] keys = lov1.getKeys(); + Map map1 = new HashMap(); + for (String key : keys) { + KeyLov lov_key = lov1.getKeyLovOfKey(key); + boolean deprecated = lov_key.isDeprecated(); + if (deprecated) { + if (key.equals(bean.getVal())) { + bean.setVal(""); + } + continue; + } + String value = lov1.getValueOfKey(key); + map1.put(value, key);// <ʾֵ,ʵֵ> + if (key.equals(bean.getVal()) && (!bean.getVal().equals(""))) { + bean.setVal(value); + } + } + bean.setLov(map1); + } else { + bean.setIslov(false); + } + + classList.add(bean); + + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + + labels1 = new JLabel[classList.size()]; + writer.print("classList.size():" + classList.size()); + for (int i = 0; i < classList.size(); i++) { + JComponent jcomp = null; + ClassAttributeBean bean = classList.get(i); + String attrName = bean.getName(); + int propID = bean.getId(); + labels1[i] = new JLabel(attrName); + jp2.add((i + 6) + ".1.center.top", labels1[i]); + labels1[i].setBounds(5, 5, 5, 5); + String value = bean.getVal(); + writer.println("ĬֵΪ:" + value); + if (bean.isIslov()) { + JComboBox comb = new JComboBox(); + // Ż + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + // end + comb.setEditable(false); + comb.setSize(new Dimension(60, 40)); + if (classFlag2) { + if ((PlmLocaleUtil.getString("heatTreatment")).equals(attrName)) { + comb.addItem(""); + HeatTreatment = value; + } else { + comb.addItem(value); + } + } else { + comb.addItem(value); + } + for (Entry entry : bean.getLov().entrySet()) { + if (i == 0) { + writer.println("entry.getKey()====" + entry.getKey()); + } + if (!(value.equals(entry.getKey()))) { + comb.addItem(entry.getKey()); + } + } + // Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + writer.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(comb, tip); + } + } + + }); + // end + map2 = new HashMap(); + map2.put("JComboBox", comb); + values.add(map2); + jp2.add((i + 6) + ".2.center.top", comb); + jp2.add((i + 6) + ".3.center.top", jt); + jp2.add((i + 6) + ".4.center.top", bu); + if (attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, comb); + lovMap.put(attrName, "yes"); + } + if (attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, comb); + lovMap2.put(attrName, "yes"); + } + + if ((PlmLocaleUtil.getString("Category")).equals(attrName)) { + typeList.add(comb); + } + jcomp = comb; + } else { + JTextField field = new JTextField(18); + field.setText(value); + map2 = new HashMap(); + map2.put("JTextField", field); + values.add(map2); + jp2.add((i + 6) + ".2.center.top", field); + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName)) { + JComboBox box = new JComboBox(); + // Ż + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + // end + box.addItem(" "); + String[] strs = new String[] { "C0", "C2", "C3", "C4", "C5" }; + for (int j = 0; j < strs.length; j++) { + box.addItem(strs[j]); + } + // Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + writer.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(box, tip); + } + } + + }); + boxMap.put(attrName, box); + jp2.add((i + 6) + ".3.center.top", box); + jp2.add((i + 6) + ".4.center.top", jt); + jp2.add((i + 6) + ".5.center.top", bu); + } + if (attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, field); + lovMap.put(attrName, "no"); + } + if (attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, field); + lovMap2.put(attrName, "no"); + } + jcomp = field; + } + v = i + 7; + + if (propID == 660113 || propID == 660114 || propID == 660115) { + jcompMap.put(propID, jcomp); + } + } + + // Ż + jp2.add(v + ".1.center.top", new JLabel(" ")); + jp2.add(v + ".2.center.top", new JLabel("**********************")); + v += 1; + // λ + jp2.add(v + ".1.center.top", new JLabel("λ")); + try { + tagMap.clear(); + dl = new JComboBox(); + dl.setSize(new Dimension(60, 40)); + dl.setName("uom_tag"); + TCProperty zclov1; + TCComponentItem oldItem = targetItem.getItem(); + zclov1 = oldItem.getTCProperty("uom_tag"); + + TCComponentListOfValues zcprolov1 = zclov1.getLOV(); + String[] comboxitems1; + JTextField jt1 = new JTextField(9); + JButton bu1 = new JButton(""); + if (zcprolov1 != null) { + comboxitems1 = zcprolov1.getListOfValues().getLOVDisplayValues(); + TCComponent[] tags = zcprolov1.getListOfValues().getTagListOfValues(); + for (int flag = 0; flag < comboxitems1.length; flag++) { + tagMap.put(comboxitems1[flag], tags[flag]); + } + ComboBoxModel model1 = new DefaultComboBoxModel(comboxitems1); + dl.setModel(model1); + bu1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip1 = jt1.getText(); + writer.println("" + tip1); + if (tip1.length() > 0) { + SearchJComItem.changeBox(dl, tip1); + } + } + + }); + // comboxList.add(dl); + } + dl.setSelectedItem(oldItem.getProperty("uom_tag")); + // if(!(ZC_LBJ_list.XZCPDisPros.get(i)).equals("ʱϱʶ")) { + dl.setSelectedIndex(-1); + jp2.add(v + ".2.center.top", dl); + jp2.add((v) + ".3.center.top", jt1); + jp2.add((v) + ".4.center.top", bu1); + v += 1; + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + // λ + MustMap.put("λ", dl); + +// for(String s:lishu_lov.keySet()) { +// String val = lishu_lov.get(s); +// jp2.add(v+".1.center.top",new JLabel(val)); +// JComboBox lishu_comb=new JComboBox(); +// lishu_comb.setEditable(false); +// lishu_comb.setSize(new Dimension(60,40)); +// try { +// TCProperty zcLov_val = targetItem.getTCProperty(s); +// TCComponentListOfValues lov_val = zcLov_val.getLOV(); +// if(lov_val!=null) { +// String[] comboxitems=lov_val.getListOfValues().getLOVDisplayValues(); +// ComboBoxModel model = new DefaultComboBoxModel(comboxitems); +// lishu_comb.setModel(model); +// comboxList.add(lishu_comb); +// } +// lishu_comb.setSelectedItem(zc_pro_map.get(s)); +// jp2.add(v+".2.center.top",lishu_comb); +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// lishu_comb.setName(s); +// v++; +// } +// for(String m:lishu.keySet()) { +// String val=lishu.get(m); +// jp2.add(v+".1.center.top",new JLabel(val)); +// JTextField jf=new JTextField(18); +// jf.setName(m); +// jf.setText(zc_pro_map.get(m)); +// fieldList.add(jf); +// jp2.add(v+".2.center.top",jf); +// v++; +// } + if ("RB3_GNZC".equals(toitemtype)) { + writer.println("3------------------------------------------------"); + for (int i = 0; i < ZC_LBJ_list.GNZCPros.size(); i++) { + ZC_LBJ_list.XZCPPros.size(); + + writer.println("GNZCProsѭ" + i + ",ҪӵΪ" + ZC_LBJ_list.GNZCDisPros.get(i) + "(" + + ZC_LBJ_list.GNZCPros.get(i) + ")"); +// if ((ZC_LBJ_list.GNZCDisPros.get(i)).equals("Ʒ") +// || (ZC_LBJ_list.GNZCDisPros.get(i)).equals("ͼ")) { +// +// continue; +// } + jp2.add((v) + ".1.center.top", new JLabel(ZC_LBJ_list.GNZCDisPros.get(i))); + boolean b = ZC_LBJ_list.xzmap.containsKey(ZC_LBJ_list.GNZCPros.get(i)); + try { + if (b) { + + writer.println("Lov"); + // lovֵ + String[] profitLov = getRealLoveName(ZC_LBJ_list.GNZCPros.get(i),writer); + JComboBox zcBox = new JComboBox(profitLov); + zcBox.setSize(new Dimension(60, 40)); + zcBox.setName(ZC_LBJ_list.GNZCDisPros.get(i)); +// TCProperty zclov = ((TCComponentItemRevision) targetItem) +// .getTCProperty(ZC_LBJ_list.GNZCDisPros.get(i)); +// TCComponentListOfValues zcprolov = zclov.getLOV(); +// String[] comboxitems; +// JTextField jt = new JTextField(9); +// //JButton bu = new JButton(""); +// if (zcprolov != null) { +// comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); +// ComboBoxModel model = new DefaultComboBoxModel(comboxitems); +// zcBox.setModel(model); +//// bu.addActionListener(new ActionListener() { +//// @Override +//// public void actionPerformed(ActionEvent e) { +//// // TODO Auto-generated method stub +//// String tip = jt.getText(); +//// writer.println("" + tip); +//// if (tip.length() > 0) { +//// SearchJComItem.changeBox(zcBox, tip); +//// } +//// } +//// +//// }); +// comboxList.add(zcBox); +// } +// +// zcBox.setSelectedItem(zc_pro_map.get(ZC_LBJ_list.GNZCDisPros.get(i))); +// // if(!(ZC_LBJ_list.XZCPDisPros.get(i)).equals("ʱϱʶ")) { +// zcBox.setSelectedIndex(-1); +// // } + + jp2.add(v + ".2.center.top", zcBox); + // jp2.add((v) + ".3.center.top", jt); + // jp2.add((v) + ".4.center.top", bu); + // +++ + MustMap.put(ZC_LBJ_list.GNZCDisPros.get(i), zcBox); + // +++ + } else { + JTextField field = new JTextField(18); + field.setName(ZC_LBJ_list.GNZCPros.get(i)); + jp2.add(v + ".2.center.top", field); + fieldList.add(field); + // +++ + MustMap.put(ZC_LBJ_list.GNZCDisPros.get(i), field); + // +++ + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + v++; + + } + } else { + for (int i = 0; i < ZC_LBJ_list.XZCPPros.size(); i++) { + + writer.println("LBJProsѭ" + i + ",ҪӵΪ" + ZC_LBJ_list.XZCPDisPros.get(i) + "(" + + ZC_LBJ_list.XZCPPros.get(i) + ")"); + if ((ZC_LBJ_list.XZCPDisPros.get(i)).equals("Ʒ") + || (ZC_LBJ_list.XZCPDisPros.get(i)).equals("ͼ")) { + + continue; + } + jp2.add((v) + ".1.center.top", new JLabel(ZC_LBJ_list.XZCPDisPros.get(i))); + boolean b = ZC_LBJ_list.xzmap.containsKey(ZC_LBJ_list.XZCPPros.get(i)); + try { + if (b) { + + writer.println("Lov"); + if (ZC_LBJ_list.XZCPPros.get(i).equals("rb3_scgc") + || ZC_LBJ_list.XZCPPros.get(i).equals("rb3_yyly")) { + // writer.println("Ϊ"); + + String na = ZC_LBJ_list.XZCPPros.get(i); + writer.println("na======================" + na); + String[] vals = ((TCComponentItemRevision) targetItem).getTCProperty(na) + .getStringValueArray(); + JComboBox nbox = new RwJComboBox(new String[] { "" }); + nbox.setEditable(true); + TCProperty zclov = ((TCComponentItemRevision) targetItem) + .getTCProperty(ZC_LBJ_list.XZCPPros.get(i)); + TCComponentListOfValues zcprolov = zclov.getLOV(); + List disVal = new ArrayList(); + String[] comboxitems; + for (int a = 0; a < vals.length; a++) { + if (vals[a] != null && !vals[a].equals("")) { + String disname = zcprolov.getListOfValues() + .getDisplayableValue(vals[a]); + disVal.add(disname); + } + } + if (zcprolov != null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + // ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + + nbox = new RwJComboBox(comboxitems); + nbox.setEditable(true); + nbox.setName(na); + nbox.setSize(new Dimension(60, 40)); + if (disVal.size() > 0) { + StringBuilder sb = new StringBuilder(); + for (int t = 0; t < disVal.size(); t++) { + if (t != (vals.length - 1)) { + + sb.append(disVal.get(t)); + sb.append(","); + } else { + sb.append(disVal.get(t)); + } + } + JTextField ed = (JTextField) nbox.getEditor().getEditorComponent(); + ed.setText(sb.toString()); + } + comboxList.add(nbox); + } + + jp2.add(v + ".2.center.top", nbox); + + // +++ + MustMap.put(ZC_LBJ_list.XZCPDisPros.get(i), nbox); + // +++ + } else { + JComboBox zcBox = new JComboBox(); + zcBox.setSize(new Dimension(60, 40)); + zcBox.setName(ZC_LBJ_list.XZCPPros.get(i)); + TCProperty zclov = ((TCComponentItemRevision) targetItem) + .getTCProperty(ZC_LBJ_list.XZCPPros.get(i)); + if (zclov == null) { + zclov = ((TCComponentItemRevision) targetItem).getTCProperty("rb3_smzqtz"); + } + TCComponentListOfValues zcprolov = zclov.getLOV(); + String[] comboxitems; + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + if (zcprolov != null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + comboxitems = prependEmptyString(comboxitems); + ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + + zcBox.setModel(model); + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + writer.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(zcBox, tip); + } + } + + }); + comboxList.add(zcBox); + } + + zcBox.setSelectedItem(zc_pro_map.get(ZC_LBJ_list.XZCPPros.get(i))); + // if(!(ZC_LBJ_list.XZCPDisPros.get(i)).equals("ʱϱʶ")) { + zcBox.setSelectedIndex(-1); + // } + + jp2.add(v + ".2.center.top", zcBox); + jp2.add((v) + ".3.center.top", jt); + jp2.add((v) + ".4.center.top", bu); + // +++ + MustMap.put(ZC_LBJ_list.XZCPDisPros.get(i), zcBox); + // +++ + } + } else { + JTextField field = new JTextField(18); + field.setName(ZC_LBJ_list.XZCPPros.get(i)); + if ((ZC_LBJ_list.XZCPDisPros.get(i)).equals("û")) { + field.setText(zc_pro_map.get(ZC_LBJ_list.XZCPPros.get(i))); + } + if ((ZC_LBJ_list.XZCPDisPros.get(i)).equals("")) { + continue; + } + jp2.add(v + ".2.center.top", field); + fieldList.add(field); + // +++ + MustMap.put(ZC_LBJ_list.XZCPDisPros.get(i), field); + // +++ + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + v++; + } + } + + jp2.setVisible(true); + jp2.validate(); + jp2.repaint(); + scr2.validate(); + } + } + }); + JScrollPane scrollPane = new JScrollPane(tree); + scrollPane.setPreferredSize(new Dimension(250, 250)); + + // ӹ嵽 + jp1.add(scrollPane, BorderLayout.CENTER); + // jp2.setVisible(false); + classJpanel.add(scr2); + JSplitPane splitPane = new JSplitPane(); + splitPane.setOneTouchExpandable(true);// ÷ָʾͷ + splitPane.setContinuousLayout(true);// ͷػͼ + splitPane.setLeftComponent(new JScrollPane(jp1)); + splitPane.setRightComponent(new JScrollPane(classJpanel)); + JPanel titlePanel = new JPanel(new FlowLayout());// Խ + + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(button2); + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(okBut); + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(celBut); + + this.add(splitPane, BorderLayout.CENTER); + this.add(titlePanel, BorderLayout.SOUTH); + // add("1.1.center.center", splitPane); + // add("1.1.center.center", jp1); + // add("1.2.center.center", classJpanel); + // add("2.1.center.center", button2); + // add("2.2.center.center", okBut); + // add("2.3.center.center", celBut); + + button2.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + writer.println("׼"); + G4MDialog classDialog = new G4MDialog("˱", null, revList, session); + new Thread(classDialog).start(); + } + }); + + okBut.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + try { + createItem(login_file); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + // setVisible(false); + } + + }); + celBut.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + writer.println("ȡ"); + setVisible(false); + } + }); + this.setVisible(true); + this.centerToScreen(); + // this.pack(); + } + /** + * ǰһַ + * @param items ԭʼ + * @return µ飬ַ + */ + private static String[] prependEmptyString(String[] items) { + String[] newItems = new String[items.length + 1]; + newItems[0] = ""; // ĵһλӿַ + System.arraycopy(items, 0, newItems, 1, items.length); // ԭݵ + return newItems; + } + + /* + * ϴ + */ + public void createItem(File login_file) throws IOException { + // +++жϱ + FileWriter fileWriter = new FileWriter(login_file, true); + PrintWriter writer = new PrintWriter(fileWriter); + writer.println(new Date()+"ʼ"); + writer.println(new Date()+"============="); + String[] mustAttributes = service.getStringValues("RB_CreateRequiredAttribute_ls"); + writer.println(new Date()+"=======>RB_CreateRequiredAttribute_lsѡֵ" + Arrays.toString(mustAttributes)); +// writer.println("=======>attrList"+attrList.toString()); +// writer.println("=======>esAttrList"+esAttrList.toString());MustMap + writer.println(new Date()+"MustMap.size====>" + MustMap.size()); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (mustAttributes != null && mustAttributes.length > 0) { + for (int i = 0; i < mustAttributes.length; i++) { + writer.println("==>ԣ" + mustAttributes[i]); + if (MustMap.containsKey(mustAttributes[i])) { + + if (MustMap.get(mustAttributes[i]) instanceof JComboBox) { + JComboBox box = (JComboBox) MustMap.get(mustAttributes[i]); + if (box != null) { + writer.println("boxݣ" + box.getSelectedItem()); + if (box.getSelectedItem() == null || ((String) box.getSelectedItem()).equals("")) { + // δд + MessageBox.post(mustAttributes[i] + "," + rb.getString("sxwtx07_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + return; + } + } + } else if (MustMap.get(mustAttributes[i]) instanceof JTextField) { + JTextField field = (JTextField) MustMap.get(mustAttributes[i]); + if (field != null) { + writer.println("boxݣ" + field.getText()); + if (field.getText() == null || ((String) field.getText()).equals("")) { + // δд + MessageBox.post("" + mustAttributes[i] + "," + rb.getString("sxwtx07_display.TITLE"), + "ʾ", MessageBox.INFORMATION); + return; + } + } + } + } +// if(attrList.contains(mustAttributes[i])) { +// writer.println("attrList+"+mustAttributes[i]); +// JComboBox box=(JComboBox) objMap.get(mustAttributes[i]); +// if(box!=null) { +// writer.println("boxݣ"+box.getSelectedItem()); +// if(box.getSelectedItem()==null||((String)box.getSelectedItem()).equals("")) { +// MessageBox.post(""+mustAttributes[i]+"δд", "ʾ", MessageBox.INFORMATION); +// return; +// } +// } +// }else if(esAttrList.contains(mustAttributes[i])) { +// writer.println("esAttrList"+mustAttributes[i]); +// JComboBox box=(JComboBox) objMap.get(mustAttributes[i]); +// if(box!=null) { +// writer.println("boxݣ"+box.getSelectedItem()); +// if(box.getSelectedItem()==null||((String)box.getSelectedItem()).equals("")) { +// MessageBox.post(""+mustAttributes[i]+"δд", "ʾ", MessageBox.INFORMATION); +// return; +// } +// } +// } + } + } else { + writer.println(new Date()+"RB_CreateRequiredAttributeѡδ"); + } + + writer.println(new Date()+"========Լ======="); + // +++ + + // TODO Auto-generated method stub + String jhID = ""; + try { + if (idList != null && idList.size() > 0) { + JTextField idField = (JTextField) idList.get(0); + JComboBox idbox = (JComboBox) idList.get(1); + String id = idField.getText(); + String boxID = (String) idbox.getSelectedItem(); +// if ("".equals(id.trim()) && "".equals(boxID.trim())) { +// MessageBox.post("δд", "ʾ", MessageBox.INFORMATION); +// return; +// } + if ("".equals(id.trim())) { + id = boxID.trim(); + } + jhID = id; + } + String typeID = ""; + if (typeList != null && typeList.size() > 0) { + JComboBox idComb = typeList.get(0); + typeID = (String) idComb.getSelectedItem(); + if (typeID.indexOf("Ʒ") >= 0 || typeID.indexOf("Finished product") >= 0) { + typeID = ""; + } else if (typeID.indexOf("") >= 0 || typeID.indexOf("Turning workpiece") >= 0) { + typeID = "C"; + } else if (typeID.indexOf("ȴ") >= 0 || typeID.indexOf("Heat treatment parts") >= 0) { + typeID = "R"; + } else if (typeID.indexOf("շ伷") >= 0 + || typeID.indexOf("Cold rolled parts or cold extrusion parts") >= 0) { + typeID = "D"; + } else if (typeID.indexOf("ͼ") >= 0 || typeID.indexOf("Forge piece") >= 0) { + typeID = "D"; + } + } + String item_type = ""; + if (selCodeBean != null) { + item_type = selCodeBean.getType(); + } else { + MessageBox.post(rb.getString("qxzzdcjd07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + String targetId = idField1.getText(); + if ("".equals(targetId.trim())) { + // дܳϱţ + MessageBox.post(rb.getString("qtxwlzcbh07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + // String newID = targetId + jhID + typeID; + String newID = targetId + jhID; + writer.println("targetId======" + targetId); + writer.println("jhID======" + jhID); + writer.println("typeID======" + typeID); + String revID = (String) revBox.getSelectedItem(); + String itemName = (String) nameComb.getSelectedItem(); + + // List asList = Arrays.asList(lovVal); + // List esList = Arrays.asList(esLovVal); + // StringBuilder sb = new StringBuilder(); + // for (int i = 0; i < attrList.size(); i++) { + // String attr = attrList.get(i); + // String esAttr = esAttrList.get(i); + // if(!("".equals(attr.trim()))) { + // JComboBox box = null; + // if((PlmLocale.getString("RadialInternalClearance")).equals(attr) + // || (PlmLocale.getString("PartNumber")).equals(attr)) { + // box = boxMap.get(attr); + // } + // Object obj = objMap.get(attr); + // if(obj == null) { + // JTextField field = (JTextField)objMap.get(esAttr); + // if(box != null) { + // String fieldText = field.getText(); + // String boxText = (String) box.getSelectedItem(); + // if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + // MessageBox.post(esAttr+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + // MessageBox.post(esAttr+"дһֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if(!("".equals(fieldText.trim()))) { + // objList.add(field); + // lovList.add("no"); + // }else { + // objList.add(box); + // lovList.add("yes"); + // } + // }else { + // objList.add(field); + // lovList.add(lovMap.get(esAttr)); + // } + // }else { + // if(box != null) { + // JTextField field = (JTextField)obj; + // String fieldText = field.getText(); + // String boxText = (String) box.getSelectedItem(); + // if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + // MessageBox.post(attr+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + // MessageBox.post(attr+"дһֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if(!("".equals(fieldText.trim()))) { + // objList.add(field); + // lovList.add("no"); + // }else { + // objList.add(box); + // lovList.add("yes"); + // } + // }else { + // objList.add(obj); + // lovList.add(lovMap.get(attr)); + // } + // } + // } + // } + // for (int i = 0; i < attrList2.size(); i++) { + // String attr = attrList2.get(i); + // String esAttr = esAttrList2.get(i); + // if(!("".equals(attr.trim()))) { + // JComboBox box = null; + // if((PlmLocale.getString("RadialInternalClearance")).equals(attr) + // || (PlmLocale.getString("PartNumber")).equals(attr)) { + // box = boxMap.get(attr); + // } + // Object obj = objMap2.get(attr); + // if(obj == null) { + // JTextField field = (JTextField)objMap.get(esAttr); + // if(box != null) { + // String fieldText = field.getText(); + // String boxText = (String) box.getSelectedItem(); + // if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + // MessageBox.post(esAttr+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + // MessageBox.post(esAttr+"дһֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if(!("".equals(fieldText.trim()))) { + // objList2.add(field); + // lovList2.add("no"); + // }else { + // objList2.add(box); + // lovList2.add("yes"); + // } + // }else { + // objList2.add(field); + // lovList2.add(lovMap2.get(esAttr)); + // } + // }else { + // if(box != null) { + // JTextField field = (JTextField)obj; + // String fieldText = field.getText(); + // String boxText = (String) box.getSelectedItem(); + // if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + // MessageBox.post(attr+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + // MessageBox.post(attr+"дһֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if(!("".equals(fieldText.trim()))) { + // objList2.add(field); + // lovList2.add("no"); + // }else { + // objList2.add(box); + // lovList2.add("yes"); + // } + // }else { + // objList2.add(obj); + // lovList2.add(lovMap2.get(attr)); + // } + // } + // } + // } + // for (int i = 0; i < objList.size(); i++) { + // String attrValue = ""; + // if("yes".equals(lovList.get(i))) { + // String value = (String) ((JComboBox) + // objList.get(i)).getSelectedItem(); + // if(asList.contains(value) || esList.contains(value)) { + // value = ""; + // }else { + // if(value.contains(":")) { + // String[] values = value.split(":"); + // value = values[0]; + // }else if(value.contains("")) { + // String[] values = value.split(""); + // value = values[0]; + // } + // } + // if("Ʒ".equals(value)) { + // value = ""; + // }else if("".equals(value)) { + // value = "C"; + // }else if("ȴ".equals(value)) { + // value = "R"; + // }else if("".equals(value)) { + // value = "L"; + // }else if("ͼ".equals(value)) { + // value = "D"; + // } + // attrValue = value; + // }else { + // attrValue = ((JTextField) objList.get(i)).getText(); + // } + // String mark = markList.get(i); + // sb.append(mark.trim()); + // sb.append(attrValue); + // writer.println("attrValue=============="+attrValue); + // } + // productNumber = sb.toString(); + // writer.println("productNumber============"+productNumber); + // StringBuilder sb2 = new StringBuilder(); + // + // for (int i = 0; i < objList2.size(); i++) { + // String attrValue = ""; + // if("yes".equals(lovList2.get(i))) { + // String value = (String) ((JComboBox) + // objList2.get(i)).getSelectedItem(); + // if(asList.contains(value) || esList.contains(value)) { + // value = ""; + // }else { + // if(value.contains(":")) { + // String[] values = value.split(":"); + // value = values[0]; + // }else if(value.contains("")) { + // String[] values = value.split(""); + // value = values[0]; + // } + // } + // if("Ʒ".equals(value)) { + // value = ""; + // }else if("".equals(value)) { + // value = "C"; + // }else if("ȴ".equals(value)) { + // value = "R"; + // }else if("".equals(value)) { + // value = "L"; + // }else if("ͼ".equals(value)) { + // value = "D"; + // } + // attrValue = value; + // }else { + // attrValue = ((JTextField) objList2.get(i)).getText(); + // } + // writer.println("attrValue11111=============="+attrValue); + // String mark = markList2.get(i); + // sb2.append(mark.trim()); + // sb2.append(attrValue); + // } + // drawingNumber = sb2.toString(); + // writer.println("drawingNumber============"+drawingNumber); + if (classFlag) { + productNumber = splicValue(defaultValueList, attrList, esAttrList, objMap, markList, isNList, lovMap,writer); + writer.println(new Date()+"productNumber============" + productNumber); + drawingNumber = splicValue(defaultValueList2, attrList2, esAttrList2, objMap2, markList2, isNList2, + lovMap2,writer); + + + writer.println(new Date()+"drawingNumber============" + drawingNumber); + if (productNumber == null || drawingNumber == null) { + return; + } + } else { + productNumber = targetItem.getStringProperty("rb3_th") + jhID; + writer.println(new Date()+"productNumber============" + productNumber); + drawingNumber = targetItem.getStringProperty("rb3_th") + jhID; + + writer.println(new Date()+"drawingNumber============" + drawingNumber); + } + + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(item_type); + TCComponentItem find = itemType.find(newID); + if (find != null) { + MessageBox.post(":" + newID + "Ѵ,޷!", "", MessageBox.ERROR); + return; + } + // Ż + List compList = queryObject("RBSearchLBJCPH", new String[] { "Ʒ" }, + new String[] { productNumber }); + if (compList != null) { + if (compList.size() > 0) { + String nID = newID.substring(0, 2); + + for (int j = 0; j < compList.size(); j++) { + writer.println(new Date()+"жitem_idǰλǷͬ"); + String compID = compList.get(j).getProperty("item_id"); + String cID = compID.substring(0, 2); + if (nID.equals(cID)) { + MessageBox.post("ϵͳѴڲƷΪ" + productNumber + "ϣ룡", "", + MessageBox.INFORMATION); + return; + } + } + } + } + // endŻ + TCComponent uom = null; + String dlval = (String) dl.getSelectedItem(); + if (dlval == null || dlval.equals("")) { + MessageBox.post("λѡ", "", MessageBox.INFORMATION); + return; + } else { + TCComponent tcComponent = tagMap.get(dlval); + uom = tcComponent; + } + + TCComponentItem itemComp = itemType.create(newID, revID, "RB3_XZCP", itemName, null, uom); + getFolder(); +// session.getUser().getHomeFolder().add("contents", itemComp); +// session.getUser().getHomeFolder().refresh(); + folder.add("contents", itemComp); + folder.refresh(); + TCComponentItemRevision itemRev = itemComp.getLatestItemRevision(); + + // Ż + for (int k = 0; k < fieldList.size(); k++) { + JTextField jt = (JTextField) fieldList.get(k); + String key = jt.getName(); + String val = jt.getText(); + fieldmap.put(key, val); + } + for (int m = 0; m < comboxList.size(); m++) { + JComboBox cbo = (JComboBox) comboxList.get(m); + cbo.setEditable(false); + String key = cbo.getName(); + writer.println("comboxNameΪ:" + key); + + if (key.equals("rb3_scgc") || key.equals("rb3_yyly")) { + JTextField ed = (JTextField) cbo.getEditor().getEditorComponent(); + String text = ed.getText(); + + if (!text.equals("") && text != null) { + List proList = new ArrayList<>(); + String[] split = text.split(","); + TCProperty tclov = ((TCComponentItemRevision) targetItem).getTCProperty(key); + TCComponentListOfValues lov = tclov.getLOV(); + for (int p = 0; p < split.length; p++) { + String realVal = (String) lov.getListOfValues().getRealValue(split[p]); + proList.add(realVal); + } + Object[] array = proList.toArray(); + String[] svals = new String[array.length]; + for (int s = 0; s < array.length; s++) { + svals[s] = (String) array[s]; + } + itemRev.getTCProperty(key).setStringValueArray(svals); + } + } else { + // ж ܳ 㲿 + + if (targetItem.getType().equals("RB3_GNLBJRevision")) { + String val = (String) cbo.getSelectedItem(); + TCProperty tclov = ((TCComponentItemRevision) targetItem).getTCProperty("rb3_smzqtz"); + TCComponentListOfValues lov = tclov.getLOV(); + String realVal = (String) lov.getListOfValues().getRealValue(val); + writer.println("ѡеֵΪ1:" + val); + comboxmap.put("rb3_smzqtz", realVal); + } else if (targetItem.getType().equals("RB3_GNZCRevision")) { + String val = (String) cbo.getSelectedItem(); + TCProperty tclov = ((TCComponentItemRevision) targetItem).getTCProperty("rb3_smzqzt"); + TCComponentListOfValues lov = tclov.getLOV(); + String realVal = (String) lov.getListOfValues().getRealValue(val); + writer.println("ѡеֵΪ2:" + val); + comboxmap.put("rb3_smzqtz", realVal); + } else { + String val = (String) cbo.getSelectedItem(); + TCProperty tclov = ((TCComponentItemRevision) targetItem).getTCProperty(key); + TCComponentListOfValues lov = tclov.getLOV(); + String realVal = (String) lov.getListOfValues().getRealValue(val); + writer.println("ѡеֵΪ3:" + val); + comboxmap.put(key, realVal); + } + } + + } + itemRev.setProperties(fieldmap); + itemRev.setProperties(comboxmap); + + // endŻ + + String statu = ""; + if ("A1".equals(revID)) { + statu = ":Conceptual design"; + } else if ("B1".equals(revID)) { + statu = ":Product design"; + } else if ("R1".equals(revID)) { + statu = ":Process design/Sample delivery"; + } else if ("P1".equals(revID)) { + statu = "P:Pilot production/small batch"; + } else if ("M1".equals(revID)) { + statu = "M:Mass production"; + } + + itemRev.setStringProperty("rb3_cph", productNumber); + itemRev.setStringProperty("rb3_smzqzt", statu); + itemRev.setStringProperty("rb3_jh", jhID); + + String item_id = targetItem.getProperty("item_id"); + String id = dealItemId(item_id,writer); + if (id != null) { + build.append(id); + build.append(drawingNumber); + } else { + build.append(drawingNumber); + } + boolean glhFlag = false; + if ("RB3_XZCP".equals(item_type) || "RB3_XZCP".equals(toitemtype) || "RB3_XZCPRevision".equals(item_type) + || "RB3_XZCPRevision".equals(toitemtype)) { + writer.println("4------------------------------------------------"); +// itemRev.setStringProperty("rb3_glh", drawingNumber); + // itemRev.setStringProperty("rb3_glh", build.toString()); + String glh = fieldmap.get("rb3_glh"); + itemRev.setStringProperty("rb3_glh", glh); + if (revList.size() > 0) { + TCComponentItemRevision picItem = revList.get(0); + TCComponent[] pics = picItem.getReferenceListProperty("TC_Is_Represented_By"); + for (int i = 0; i < pics.length; i++) { + itemRev.add("TC_Is_Represented_By", pics[i]); + } + // picItem.add("RB3_GLWL", itemRev); + } else { + String[] keys = new String[] { " ID" }; + String[] values = new String[] { glh }; + List tzList = queryObject(" ID", keys, values); + if (tzList != null) { + try { + if (targetItem.getType().equals("RB3_XZCPRevision")) { + for (int i = 0; i < tzList.size(); i++) { + if (tzList.get(i) instanceof TCComponentItem) { + TCComponentItem LJH = ((TCComponentItem) tzList.get(i)); + if (LJH.getType().equals("RB3_XZCPT")) { + TCComponentItemRevision LJTRev = LJH.getLatestItemRevision(); + // folder.add("contents", tzList.get(0)); + folder.refresh(); + itemRev.add("TC_Is_Represented_By", LJTRev); + glhFlag = true; + break; + } + + } + } + } + } catch (TCException e) { + // TODO: handle exception + e.printStackTrace(); + MessageBox.post("Ȩ޲㣬ͼֽ޷ʴʧܣ", "ʾ", 2); + return; + } + + } + // ŵͼֽδϵͳҵ ½ + if (!glhFlag) { + + try { + TCComponentItemType typeComponent = (TCComponentItemType) session + .getTypeComponent("RB3_XZCPT"); + TCComponentItem LJTItem = typeComponent.create(glh, "V1", "RB3_XZCPT", "", "", null); + if (LJTItem != null) { + TCComponentItemRevision LJTRev = LJTItem.getLatestItemRevision(); + // folder.add("contents", LJTItem); + folder.refresh(); + itemRev.add("TC_Is_Represented_By", LJTRev); + } + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post("ͼֽIDϵͳжIDͬʧܣ", "ʾ", 2); + return; + } + + } + } + } else { + itemRev.setStringProperty("rb3_th", build.toString()); + if (revList.size() > 0) { + TCComponentItemRevision picItem = revList.get(0); + TCComponent[] pics = picItem.getReferenceListProperty("TC_Is_Represented_By"); + for (int i = 0; i < pics.length; i++) { + itemRev.add("TC_Is_Represented_By", pics[i]); + } + // picItem.add("RB3_GLWL", itemRev); + } else { + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent("RB3_XZCPT"); + // String revID = typeComponent.getNewRev(null); + // String drawID = typeComponent.getNewID(); + String[] keys = new String[] { " ID" }; +// String[] values = new String[] { drawingNumber }; + String[] values = new String[] { build.toString() }; + List tzList = queryObject(" ID", keys, values); + TCComponentItemRevision CPTRev = null; + if (tzList != null) { + if (tzList.size() > 0) { + if (tzList.get(0) instanceof TCComponentItem) { + TCComponentItem tcItem = (TCComponentItem) tzList.get(0); + CPTRev = tcItem.getLatestItemRevision(); + } + } + } else { + TCComponentItem CPTItem = typeComponent.create(build.toString(), "V1", "RB3_XZCPT", "", "", + null); + CPTRev = CPTItem.getLatestItemRevision(); + if (CPTItem != null) { +// session.getUser().getHomeFolder().add("contents", CPTItem); +// session.getUser().getHomeFolder().refresh(); + if (build.toString().length() > 0) { + CPTRev.setStringProperty("rb3_th", build.toString()); + } else { + CPTRev.setStringProperty("rb3_th", drawingNumber); + } + folder.add("contents", CPTItem); + folder.refresh(); + } + } + itemRev.add("TC_Is_Represented_By", CPTRev); + // CPTRev.add("RB3_GLWL", itemRev); + + } + } + + List vals = new ArrayList(); + for (Map value : values) { + for (Map.Entry entry : value.entrySet()) { + String type = entry.getKey(); + if (type.equals("JComboBox")) { + JComboBox comb1 = (JComboBox) entry.getValue(); + String val = (String) comb1.getSelectedItem(); + vals.add(val); + } else { + JTextField field1 = (JTextField) entry.getValue(); + String val = field1.getText(); + vals.add(val); + } + } + } + Integer[] classKeys = new Integer[classList.size()]; + String[] classVals = new String[classList.size()]; + writer.println("size============================" + classList.size()); + for (int i = 0; i < labels1.length; i++) { + String val = vals.get(i); + if (val == null || val.trim() == "") { + continue; + } + String val2 = ""; + if (classList.get(i).isIslov()) { + val2 = classList.get(i).getLov().get(val);// ʵֵ + writer.println("val2================" + val2); + writer.println("val================" + val); + } else { + val2 = val; + } + classKeys[i] = classList.get(i).getId(); + String attrName = classList.get(i).getName(); + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName) + || (PlmLocaleUtil.getString("PartNumber")).equals(attrName)) { + if ("".equals(val2.trim())) { + JComboBox box = boxMap.get(attrName); + val2 = (String) box.getSelectedItem(); + } + } + classVals[i] = val2; + } + TCTypeService typeService = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) typeService.getTypeComponent("BOMWindow"); + // һµwindow + TCComponentBOMWindow view = winType.create(null); + view.lock(); + // öbomline + TCComponentBOMLine line = view.setWindowTopLine(targetItem.getItem(), targetItem, null, null); + // bomline + TCComponentBOMLine childBomline = line.add(itemComp, itemRev, null, false, ""); + // + view.save(); + // + view.unlock(); + // ر + view.close(); + + // +++ + new Thread() { + @Override + public void run() { + sendObjToClassficationByWebService(className2, itemRev, classKeys, classVals, url,login_file);// ͷ + MessageBox.post(rb.getString("wlcjcg07_display.TITLE"), "", MessageBox.INFORMATION); + } + }.start(); + // +++ +// sendObjToClassficationByWebService(className2, itemRev, classKeys, classVals, url);// ͷ +// MessageBox.post("ϴɹ", "", MessageBox.INFORMATION); + + setVisible(false); + writer.println(new Date()+""); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + MessageBox.post(rb.getString("wlcjsb07_display.TITLE"), "", MessageBox.INFORMATION); + } + writer.flush(); + writer.close(); + } + + /** + * õǰTreeNodeĸ-ƻ + * + * @param treeNode ڵ + * @param names ƻ + * @return + */ + private String getNode(TreeNode treeNode, String names) { + // TODO Auto-generated method stub + if (!names.equals("")) { + names = "&" + names; + } + names = treeNode.toString() + names; + + TreeNode parent = treeNode.getParent(); + if (parent != null) { + return getNode(parent, names); + } + + return names; + } + + /** + * + * + * @param menuBean1 + * @return + */ + private JTree getTree(MenuBean menuBean1) { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(treenodename); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), rootNode); + } + } + JTree tree = new JTree(rootNode); + tree.setShowsRootHandles(true); + // tree.setEditable(true); + + return tree; + } + + /** + * ݹ˵ṹ + * + * @param menuBean1 + * @param rootNode + */ + private void getRecursion(MenuBean menuBean1, DefaultMutableTreeNode rootNode) { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode node = new DefaultMutableTreeNode(treenodename); + rootNode.add(node); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), node); + } + } + } + + /** + * ͨѯѯĿ + * + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + return null; + } + } + + /** + * ͷ + */ + public void sendObjToClassficationByWebService(String class_id, TCComponentItemRevision rev, Integer[] keys, + String[] vals, String url,File login_file) { + + try { + FileWriter fileWriter = new FileWriter(login_file, true); + PrintWriter writer = new PrintWriter(fileWriter); + writer.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList(); + + for (int i = 0; i < keys.length; i++) { + if (keys[i] != null && vals[i] != null) { + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + writer.flush(); + writer.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public String splicValue(List defaultValueList, List attrList, List esAttrList, + Map map, List markList, List isNList, Map lovMap,PrintWriter writer ) { + List objList = new ArrayList(); + List lovList = new ArrayList(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < attrList.size(); i++) { + String attr = attrList.get(i); + writer.println("attr======112" + attr); + String esAttr = esAttrList.get(i); + if (classFlag2) { + if ((PlmLocaleUtil.getString("heatTreatment")).equals(attr) + || (PlmLocaleUtil.getString("heatTreatment")).equals(esAttr)) { + objList.add(HeatTreatment); + lovList.add("string"); + continue; + } + } + if (map.get(attr) == null && map.get(esAttr) == null) { + if ((PlmLocaleUtil.getString("PartNumber")).equals(attr) + || (PlmLocaleUtil.getString("PartNumber")).equals(esAttr)) { + JComboBox idbox = boxMap.get(PlmLocaleUtil.getString("PartNumber")); + JTextField idfield = (JTextField) idList.get(0); + String fieldText = idfield.getText(); + String boxText = (String) idbox.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(PlmLocaleUtil.getString("PartNumber") + "ͬʱдֵ", "ʾ", + MessageBox.INFORMATION); + return null; + } +// if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { +// MessageBox.post(PlmLocaleUtil.getString("PartNumber") + "дһֵ", "ʾ", +// MessageBox.INFORMATION); +// return null; +// } + if (!("".equals(fieldText.trim()))) { + objList.add(fieldText); + lovList.add("string"); + } else { + objList.add(boxText); + lovList.add("string"); + } + continue; + } + objList.add(defaultValueList.get(i)); + lovList.add("string"); + continue; + } + if (!("".equals(attr.trim()))) { + Object obj = map.get(attr); + JComboBox box = null; + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attr) + || (PlmLocaleUtil.getString("RadialInternalClearance")).equals(esAttr)) { + box = boxMap.get(PlmLocaleUtil.getString("RadialInternalClearance")); + } + if (obj == null) { + obj = map.get(esAttr); + if (box != null) { + JTextField field = (JTextField) obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(esAttr + "ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(esAttr + "дһֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + } else { + objList.add(box); + lovList.add("yes"); + } + } else { + objList.add(obj); + lovList.add(lovMap.get(esAttr)); + } + } else { + if (box != null) { + JTextField field = (JTextField) obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(attr + "ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(attr + "дһֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + } else { + objList.add(box); + lovList.add("yes"); + } + } else { + objList.add(obj); + lovList.add(lovMap.get(attr)); + } + } + } + } + for (int i = 0; i < objList.size(); i++) { + String attrValue = ""; + Object obj = objList.get(i); + if (obj != null) { + if ("yes".equals(lovList.get(i))) { + String value = (String) ((JComboBox) obj).getSelectedItem(); + writer.println("ֵΪ:" + value); + if (asList.contains(value) || esList.contains(value)) { + if (isNList.get(i).trim().contains(value)) { + if (value.contains(":")) { + writer.println("value============" + value); + String[] values = value.split(":"); + value = values[0]; + } else if (value.contains("")) { + writer.println("value============" + value); + String[] values = value.split(""); + value = values[0]; + } + } else { + value = ""; + } + } else { + if (value.contains(":")) { + writer.println("value============" + value); + String[] values = value.split(":"); + value = values[0]; + } else if (value.contains("")) { + writer.println("value============" + value); + String[] values = value.split(""); + value = values[0]; + } + } + if ("Ʒ".equals(value) || "Finished product".equals(value)) { + value = ""; + } else if ("".equals(value) || "Turning workpiece".equals(value)) { + value = "C"; + } else if ("ȴ".equals(value) || "Heat treatment parts".equals(value)) { + value = "R"; + } else if ("շ伷".equals(value) || "Cold rolled parts or cold extrusion parts".equals(value)) { + value = "D"; + } else if ("ͼ".equals(value) || "Forge piece".equals(value)) { + value = "D"; + } + attrValue = value; + } else if ("no".equals(lovList.get(i))) { + attrValue = ((JTextField) obj).getText(); + } else { + attrValue = (String) obj; + } + if (asList.contains(attrValue) || esList.contains(attrValue)) { + attrValue = ""; + } else { + if (attrValue.contains(":")) { + writer.println("attrValue============" + attrValue); + String[] values = attrValue.split(":"); + attrValue = values[0]; + } else if (attrValue.contains("")) { + writer.println("attrValue============" + attrValue); + String[] values = attrValue.split(""); + attrValue = values[0]; + } + } + String mark = markList.get(i); + if (!("".equals(attrValue.trim()))) { + sb.append(mark.trim()); + sb.append(attrValue); + } + } + } + return sb.toString(); + } + + // Ż:idΪ22XX22ͷ + public String dealItemId(String id,PrintWriter writer ) { + String subs = id.substring(0, 2); + if (subs.equals("XX")) { + + String sub = id.substring(2, 4); + if (sub.equals("22")) { + writer.println("idXX22ͷ!"); + return "XX-"; + } + } else if (subs.equals("22")) { + writer.println("id22ͷ!"); + return "SF-"; + } + return null; + } + + // ҶӦĸļ + public void getFolder() { + boolean b = false; + if (refs.length > 0) { + for (AIFComponentContext ref : refs) { + InterfaceAIFComponent component = ref.getComponent(); + if (component instanceof TCComponentFolder) { + folder = (TCComponentFolder) component; + b = true; + break; + } + } + } + if (!b) { + try { + folder = session.getUser().getHomeFolder(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + public String getGLH(PrintWriter writer ) { + String glh = null; + JComponent jcomp1 = jcompMap.get(660113); + JComponent jcomp2 = jcompMap.get(660114); + JComponent jcomp3 = jcompMap.get(660115); + if (jcomp1 != null && jcomp2 != null && jcomp3 != null) { + List jcomps = new ArrayList(); + jcomps.add(jcomp1); + jcomps.add(jcomp2); + jcomps.add(jcomp3); + StringBuilder build = new StringBuilder(); + for (int i = 0; i < jcomps.size(); i++) { + JComponent jcomp = jcomps.get(i); + if (jcomp instanceof JComboBox) { + JComboBox combo = (JComboBox) jcomp; + String comboStr = (String) combo.getSelectedItem(); + if (!(comboStr.trim().equals(""))) { + if (comboStr.contains(":")) { + comboStr = comboStr.split(":")[0]; + } + if (i == 2) { + build.append("-" + comboStr + "|"); + } else { + build.append(comboStr + "|"); + } + + } + } else if (jcomp instanceof JTextField) { + JTextField jtext = (JTextField) jcomp; + String textStr = jtext.getText(); + if (!(textStr.trim().equals(""))) { + if (textStr.contains(":")) { + textStr = textStr.split(":")[0]; + } + if (i == 2) { + build.append("-" + textStr + "|"); + } else { + build.append(textStr + "|"); + } + + } + } + } + Object[] params = new Object[] { build.toString(), 4, 1, 9999, 1, "" }; + Object[] obj = new Object[1]; + obj[0] = ""; + TCUserService userservice = this.session.getUserService(); + try { + TCUtils.openLogByPass(session, name); + userservice.call("Connor_set_bypass", obj); + glh = (String) userservice.call("queryPartNo", params); + writer.println("ɵĹΪ:" + glh); + String[] keys = new String[] { " ID" }; + glh = dealGLH(glh,writer); + + String[] values = new String[] { glh }; + List compList = queryObject(" ID", keys, values); + if (compList != null && compList.size() > 0) { + glh = new GetNewCode(params,glh).getCode(); + String[] value = new String[] { glh }; + List queryObject = queryObject(" ID", keys, value); + if(queryObject != null && queryObject.size() > 0){ + MessageBox.post("ȡظϵԱ", "", MessageBox.INFORMATION); + return null; + } + } +// while (compList != null && compList.size() > 0) { +// glh = (String) userservice.call("queryPartNo", params); +// glh = dealGLH(glh); +// writer.println("whileѭɵglhΪ:" + glh); +// String[] value = new String[] { glh }; +// compList = queryObject(" ID", keys, value); +// } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + try { + TCUtils.closeLogByPass(session, name); + userservice.call("Connor_close_bypass", obj); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } else { + MessageBox.post("Կͻ롢Ż汾δд", "ʾ", MessageBox.INFORMATION); + } + return glh; + } + + public String dealGLH(String glh,PrintWriter writer ) { + writer.println("dealGLH"); + String[] split = glh.split("\\|"); + StringBuilder build = new StringBuilder(); + if (split.length > 3) { + build.append(split[0]); + build.append(split[3]); + build.append(split[1]); + build.append(split[2]); + } else { + writer.println("glhƴ쳣!"); + } + writer.println("glhֵΪ:" + build.toString()); + return build.toString(); + } + + // ȡlovֵ + public String[] getRealLoveName(String lovName,PrintWriter writer ) throws TCException { + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues projectItemslov = TCComponentListOfValuesType.findLOVByName(lovName); + String[] projectItems = null; + if (projectItemslov != null) { + writer.println(projectItemslov.toString()); + projectItems = projectItemslov.getListOfValues().getLOVDisplayValues(); + } + return projectItems; + } +} diff --git a/src/com/connor/rb/plm/rb007/Rb007DialogXZLS.java b/src/com/connor/rb/plm/rb007/Rb007DialogXZLS.java new file mode 100644 index 0000000..a3e60d7 --- /dev/null +++ b/src/com/connor/rb/plm/rb007/Rb007DialogXZLS.java @@ -0,0 +1,2232 @@ +package com.connor.rb.plm.rb007; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.ResourceBundle; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; + +import com.connor.rb.plm.entity.ZC_LBJ_listLBJ; +import com.connor.rb.plm.newcombox.RwJComboBox; +import com.connor.rb.plm.rb012.SearchJComItem; +import com.connor.rb.plm.util.ClassAttributeBean; +import com.connor.rb.plm.util.ClassProperty; +import com.connor.rb.plm.util.CodeBean; +import com.connor.rb.plm.util.GetCodeBean; +import com.connor.rb.plm.util.GetNewCode; +import com.connor.rb.plm.util.MenuBean; +import com.connor.rb.plm.util.ParseXML; +import com.connor.rb.plm.util.PlmLocaleUtil; +import com.connor.rb.plm.util.SoaServerUtil; +import com.connor.rb.plm.util.TCUtils; +import com.itextpdf.text.pdf.PdfStructTreeController.returnType; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSKeyLov.KeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class Rb007DialogXZLS extends AbstractAIFDialog { + private static final Object String = null; + private AbstractAIFApplication app; + private static TCSession session; + private TCPreferenceService service; + private String name; + private MenuBean menuBean; + private JPanel jp1; + private JPanel jp2; + private JPanel classJpanel; + private StringBuilder build = new StringBuilder(); + private List> values; + private List classList = new ArrayList(); + private Map tagMap = new HashMap(); + // private List codeBeanList; + private CodeBean selCodeBean; + private JButton okBut = new JButton("ȷ"); + private JButton button2 = new JButton("ͼֽ"); + private JButton celBut = new JButton("ȡ"); + private GetCodeBean getcode; + private JLabel[] labels1 = null; + // private JComboBox comb = null; + private String url = ""; + private JScrollPane scr2; + private boolean classFlag = true; + private boolean classFlag2 = false; + private Map map2; + private Map> boxMap = new HashMap>(); + private List revList = new ArrayList(); + private List idList = new ArrayList(); + private List typeList = new ArrayList(); + private JLabel nameLabel; + private JTextField nameComb; + private JComboBox dl; + private JLabel idLabel; + private JTextField idField1; + private JLabel revLabel; + private JComboBox revBox; + private String className2; + private TCComponentItemRevision targetItem; + private TCComponentItem taItem; + private String productNumber = ""; + private String drawingNumber = ""; + private String HeatTreatment = ""; + private Map> attrMap; + private Map> attrMap2; + private Map objMap = new HashMap(); + private Map objMap2 = new HashMap(); + private Map lovMap = new HashMap(); + private Map lovMap2 = new HashMap(); + private List attrList = new ArrayList(); + private List esAttrList = new ArrayList(); + // private List objList = new ArrayList(); + // private List lovList = new ArrayList(); + private List attrList2 = new ArrayList(); + private List esAttrList2 = new ArrayList(); + // private List objList2 = new ArrayList(); + // private List lovList2 = new ArrayList(); + private List markList = new ArrayList(); + private List markList2 = new ArrayList(); + private List isNList = new ArrayList(); + private List isNList2 = new ArrayList(); + private List defaultValueList = new ArrayList(); + private List defaultValueList2 = new ArrayList(); + private List asList = new ArrayList(); + private List esList = new ArrayList(); + // Ż + private AIFComponentContext[] refs; + private TCComponentFolder folder; + private TCComponentItem tccItem; + private String toitemtype; + private int v = 0; + private Map lishu_lov = ZC_LBJ_listLBJ.LiShu_lov; + private Map lishu = ZC_LBJ_listLBJ.LiShu; + private Map zc_pro_map = new HashMap();// ܳɵԼֵ + // TextField + private List fieldList = new ArrayList(); + // box + private List comboxList = new ArrayList(); + private Map fieldmap = new HashMap<>(); + private Map comboxmap = new HashMap<>(); + private Map jcompMap = new HashMap(); + + private Map MustMap = new HashMap();// +++ǩдӽжǷ + + // ƴԼ + Map attrsMap = new HashMap(); + + // endŻ + + // private String[] lovVal = new String[] { "ǰ", "׼", "޽Ӵ", "ʽ", + // "ͨ", "A:NBR", "0:", "", "", + // "SN:1805ػ", "ȴ", "", "S:(25% to 35%)", + // "C0","V0","Z0","׼","PC:ﵽC&UƷƾҪ" + // ,"P0:ﵽC&UƷƾҪ","ṹҪƹ","0:˫нǽӴ",":SECC൱",":벿Ŷȷ","BC:35"}; + // private String[] esLovVal = new String[] { "Non", "Standard ball", "Non", + // "Open", "Without vent hole", "A:NBR", + // "0:Black", "Non", "Ball", "SN:1805 temper","Conventional monolithic + // martensite quenching heat treatment", + // "Single", "S:(25% to 35%)", "C0","V0","Z0","Standard","PC:Meet the group C&U + // brand accuracy requirements" + // ,"P0:Meet the group C&U brand accuracy requirements","Other structures need + // to formulate rules","0:Double row angular contact ball bearing" + // ,"Not marked: SECC or equivalent","Other materials: confirm with department + // team for approval","BC:35"}; + + public Rb007DialogXZLS(AbstractAIFApplication app, String name) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.name = name; + this.values = new ArrayList>(); + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + + } + + public Rb007DialogXZLS(AbstractAIFApplication app, String name, String itemtype) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.name = name; + this.values = new ArrayList>(); + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + this.toitemtype = itemtype; + + } + + @Override + public void run() { + // TODO Auto-generated method stub + getcode = new GetCodeBean(session, "XZLS"); + menuBean = getcode.getMenuBean(name); + // codeBeanList = bean.getCodeBeanList(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HH-mm-ss-SSS"); + String dirsPath = "C:\\Session"; + + String filename = "lscj_display-"+ sdf.format(new Date()) +".txt"; + File login_file = new File(dirsPath,filename); + File path = new File(dirsPath); + if(!path.exists()) { + path.mkdirs(); + } + if(login_file.exists()) { + login_file.delete(); + } + try { + login_file.createNewFile(); + FileWriter fileWriter = new FileWriter(login_file, true); + PrintWriter writer = new PrintWriter(fileWriter); + writer.println(new Date()+"ʼʼ"); + String lovVal = service.getStringValue("RB3_lovVal_default"); + String esLovVal = service.getStringValue("RB3_esLovVal_default"); + if (lovVal.contains(";")) { + String[] vals = lovVal.split(";"); + String[] esVals = esLovVal.split(";"); + for (int i = 0; i < vals.length; i++) { + asList.add(vals[i]); + esList.add(esVals[i]); + } + } + ParseXML xml = new ParseXML(); + File file = xml.getSXX("RB3_CPHPJFS", session); + + attrMap = xml.parseXMLAttr(file,writer); + if (attrMap == null || attrMap.size() <= 0) { + MessageBox.post("ѡRB3_CPHPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + File file2 = xml.getSXX("RB3_THPJFS", session);// hEtFB3llJxBjoC + attrMap2 = xml.parseXMLAttr(file2,writer); + if (attrMap2 == null || attrMap2.size() <= 0) { + MessageBox.post("ѡRB3_THPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + InterfaceAIFComponent targetComp = app.getTargetComponent(); + if (targetComp instanceof TCComponentItemRevision) { + targetItem = (TCComponentItemRevision) targetComp; + tccItem = targetItem.getItem(); + refs = tccItem.whereReferenced(); + // Ż + zc_pro_map = targetItem.getProperties(); + // end + } else if (targetComp instanceof TCComponentItem) { + taItem = (TCComponentItem) targetComp; + targetItem = taItem.getLatestItemRevision(); + tccItem = taItem; + refs = taItem.whereReferenced(); + // Ż + zc_pro_map = taItem.getProperties(); + } + writer.println(new Date()+"ʼ"); + writer.println(new Date()+"ʼ"); + init(writer,login_file); + writer.println(new Date()+"ʼ"); + writer.flush(); + writer.close(); + } catch (Exception e) { + // TODO Auto-generated catch block + + MessageBox.post("init()쳣", "WARNING", MessageBox.WARNING); + e.printStackTrace(); + } + + } + + /** + * ҳ + * + * @throws TCException + */ + private void init(PrintWriter writer,File login_file) throws TCException { + // TODO Auto-generated method stub + this.setTitle(name); + // this.setMinimumSize(new Dimension(860,900)); + this.setPreferredSize(new Dimension(860, 900)); + // this.setLayout(new PropertyLayout()); + this.setLayout(new BorderLayout()); + classJpanel = new JPanel(new BorderLayout());// Խ + jp1 = new JPanel(new BorderLayout()); + jp2 = new JPanel(new PropertyLayout()); + jp1.setPreferredSize(new Dimension(200, 820)); + scr2 = new JScrollPane(jp2); + scr2.setPreferredSize(new Dimension(640, 820)); + classJpanel.add(scr2); + // jp2.setPreferredSize(new Dimension(350, 600)); + JTree tree = getTree(menuBean); + + tree.addKeyListener(new KeyListener() { + + @Override + public void keyTyped(KeyEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void keyPressed(KeyEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void keyReleased(KeyEvent e) { + // TODO Auto-generated method stub + int keyCode = e.getKeyCode(); + + // writer.println(""+keyCode+"!"); + + if (keyCode == 27) { + // int showflag = + // JOptionPane.showConfirmDialog(null,"ȷ˳˵","˳",JOptionPane.YES_NO_OPTION); + int option = JOptionPane.showOptionDialog(null, "ȷ˳˵", "", 0, 1, null, null, + Integer.valueOf(0)); + if (option == 0) { + writer.println("˳"); + dispose(); + } else { + return; + } + } + } + }); + + tree.addTreeSelectionListener(new TreeSelectionListener() { + public void valueChanged(TreeSelectionEvent e) { + // objList.clear(); + // objList2.clear(); + // lovList.clear(); + // lovList2.clear(); + classFlag = true; + classFlag2 = false; + objMap.clear(); + objMap2.clear(); + // zc_pro_map.clear(); + fieldList.clear(); + comboxList.clear(); + fieldmap.clear(); + comboxmap.clear(); + // + + lovMap.clear(); + lovMap2.clear(); + attrList.clear(); + esAttrList.clear(); + attrList2.clear(); + esAttrList2.clear(); + classList.clear(); + markList.clear(); + markList2.clear(); + isNList.clear(); + isNList2.clear(); + defaultValueList.clear(); + defaultValueList2.clear(); + jp2.removeAll(); + idList.clear(); + DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) e.getPath().getLastPathComponent(); + int childCount = treeNode.getChildCount(); + writer.println("ǰѡеĽڵ: " + treeNode + " ӽڵ:" + childCount); + if (childCount > 0) { + jp2.setVisible(false); + } else { + String names = getNode(treeNode, ""); + selCodeBean = getcode.getCodebean(names); + if (selCodeBean == null) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + // ѡײڵ㣡 + MessageBox.post(rb.getString("qxzzdcjd07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + // JTextField idfield = new JTextField(18); +// idList.add(idfield); +// //JComboBox idbox = new JComboBox(); +// +// idList.add(idbox); +// idbox.addItem(" "); +// String[] idstrs = new String[100]; +// for (int j = 0; j < 100; j++) { +// if (j < 10) { +// idstrs[j] = "0" + j; +// } else { +// idstrs[j] = j + ""; +// } +// } +// for (int j = 0; j < idstrs.length; j++) { +// idbox.addItem(idstrs[j]); +// } +// boxMap.put(PlmLocaleUtil.getString("PartNumber"), idbox); + revLabel = new JLabel("汾"); + revBox = new JComboBox(); + revBox.setEditable(false); + revBox.addItem("B1"); + String[] revs = service.getStringValues("RB_Revision_id"); + if (revs == null || revs.length <= 0) { + MessageBox.post("ѡRB_Revision_idδ,ϵԱ!!", "", MessageBox.ERROR); + return; + } + for (int i = 0; i < revs.length; i++) { + revBox.addItem(revs[i]); + } + nameLabel = new JLabel("ƣ"); + nameComb = new JTextField(); + + try { + nameComb.setText(targetItem.getStringProperty("object_name")); + } catch (TCException e3) { + // TODO Auto-generated catch block + e3.printStackTrace(); + } + String[] lbjNames = service.getStringValues("RB3_LBJ_names"); + +// if (lbjNames == null || lbjNames.length <= 0) { +// MessageBox.post("ѡRB3_LBJ_namesδ,ϵԱ!!", "", MessageBox.ERROR); +// return; +// } +// for (int i = 0; i < lbjNames.length; i++) { +// nameComb.addItem(lbjNames[i]); +// } +// +// // Ż +// nameComb.setSelectedIndex(1); + // endŻ + + idLabel = new JLabel("ܳϱ룺"); + idField1 = new JTextField(18); + + // Ż + try { + idField1.setText(targetItem.getProperty("item_id")); + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + // endŻ + + jp2.add("1.1.center.center", new JLabel("")); + jp2.add("2.1.center.center", idLabel); + jp2.add("2.2.center.center", idField1); + jp2.add("3.1.center.center", nameLabel); + jp2.add("3.2.center.center", nameComb); +// jp2.add("4.1.center.center", new JLabel(PlmLocaleUtil.getString("PartNumber"))); +// jp2.add("4.2.center.center", idfield); +// jp2.add("4.3.center.center", idbox); + jp2.add("4.1.center.center", revLabel); + jp2.add("4.2.center.center", revBox); + try { + String className = targetItem.getClassificationClass(); + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + writer.println("className============" + className); + c.load(className); + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + // ȡ + TCComponentICO[] icos = targetItem.getClassificationObjects(); + writer.print("icos:====" + icos); + if (icos == null || icos.length <= 0) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle + .getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + // ѡеûз͵࣬뷢ͣ + MessageBox.post(rb.getString("xzdwlmyfsdfl07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + writer.print("ʼȡ"); + Map claMap = new HashMap(); + if (icos != null && icos.length > 0) { + + ICSProperty[] icss = icos[0].getICSProperties(true); + + for (ICSProperty ics : icss) { + for (ICSAdminClassAttribute icsa : icsAttrS) { + if (icsa.getAttributeId() == ics.getId()) { + writer.print("icsa.getName():" + icsa.getName()); + writer.print("ics.getValue():" + ics.getValue()); + claMap.put(icsa.getName(), ics.getValue()); + } + } + } + } + ICSAdminClass c2 = classificationService.newICSAdminClass(); + className2 = selCodeBean.getClassID(); + // String xmlClassName = className2.substring(0, 6); + writer.println("className2===========" + className2); + // writer.println("xmlClassName==========="+xmlClassName); + if (attrMap.containsKey(className2)) { + List nameMarkList = attrMap.get(className2); + String attrNames = nameMarkList.get(0); + writer.println("attrNames:"+attrNames); + String marks = nameMarkList.get(1); + writer.println("marks:"+marks); + String defaultValues = nameMarkList.get(2); + writer.println("defaultValues:"+defaultValues); + String isN = nameMarkList.get(3); + writer.println("isN:"+isN); + if (attrNames.contains(";")) { + String[] attrs = attrNames.split(";"); + String[] markss = marks.split(";"); + String[] valuess = defaultValues.split(";"); + String[] isNs = isN.split(";"); + for (int i = 0; i < attrs.length; i++) { + writer.println("attrs==============" + attrs[i]); + if (attrs[i].contains("+")) { + String[] attrss = attrs[i].split("\\+"); + attrList.add(attrss[0]); + esAttrList.add(attrss[1]); + markList.add(markss[i]); + defaultValueList.add(valuess[i]); + isNList.add(isNs[i]); + } + } + } + + List nameMarkList2 = attrMap2.get(className2); + String attrNames2 = nameMarkList2.get(0); + String marks2 = nameMarkList2.get(1); + String defaultValues2 = nameMarkList2.get(2); + String isNs2 = nameMarkList2.get(3); + writer.println("attrNames2============" + attrNames2); + if (attrNames2.contains(";")) { + String[] attrs2 = attrNames2.split(";"); + String[] markss2 = marks2.split(";"); + String[] valuess = defaultValues2.split(";"); + String[] isNs2s = isNs2.split(";"); + for (int i = 0; i < attrs2.length; i++) { + if (attrs2[i].contains("+")) { + String[] attrss = attrs2[i].split("\\+"); + attrList2.add(attrss[0]); + esAttrList2.add(attrss[1]); + markList2.add(markss2[i]); + defaultValueList2.add(valuess[i]); + isNList2.add(isNs2s[i]); + } + } + } + } + c2.load(className2); + String cName = c2.getName(); + if (PlmLocaleUtil.getString("BearingAccessories").equals(cName)) { + classFlag = false; + } else if (PlmLocaleUtil.getString("Cage").equals(cName)) { + classFlag2 = true; + } + writer.println("cName===" + cName); + ICSAdminClassAttribute[] icsAttrS2 = c2.getAttributes(); + if (icsAttrS2 != null) { + for (ICSAdminClassAttribute attr : icsAttrS2) { + if (attr.isHidden()) { + continue; + } + ClassAttributeBean bean = new ClassAttributeBean(); + if (attr.isReferenceAttribute()) {// + continue; + } + if (attr.isReference()) { + continue; + } + int propID = attr.getAttributeId(); + bean.setId(propID); + String propDisName = attr.getName(); + writer.print("propDisName:" + propDisName); + bean.setName(propDisName); + + int attrType = attr.getFormat1().getType(); + bean.setType(attrType); + // ÷ + if (claMap != null && claMap.containsKey(propDisName)) { + bean.setVal(claMap.get(propDisName)); + writer.println("claMap.get(propDisName):"+claMap.get(propDisName)); + } else { + bean.setVal(""); + } + ICSKeyLov lov1 = attr.getFormat1().getKeyLov(); + lov1 = (lov1 == null ? attr.getFormat2().getKeyLov() : lov1); + if (lov1 != null) { + bean.setIslov(true); + String[] keys = lov1.getKeys(); + Map map1 = new HashMap(); + for (String key : keys) { + + KeyLov lov_key = lov1.getKeyLovOfKey(key); + boolean deprecated = lov_key.isDeprecated(); + if (deprecated) { + if (key.equals(bean.getVal())) { + bean.setVal(""); + } + continue; + } + String value = lov1.getValueOfKey(key); + if("B7".equals(key)) { + key = "7"; + } + writer.println("key:"+key); + writer.println("value"+value); + map1.put(value, key);// <ʾֵ,ʵֵ> + if (key.equals(bean.getVal()) && (!bean.getVal().equals(""))) { + bean.setVal(value); + } + } + bean.setLov(map1); + } else { + bean.setIslov(false); + } + + classList.add(bean); + + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + + labels1 = new JLabel[classList.size()]; + writer.print("classList.size():" + classList.size()); + for (int i = 0; i < classList.size(); i++) { + JComponent jcomp = null; + ClassAttributeBean bean = classList.get(i); + String attrName = bean.getName(); + int propID = bean.getId(); + labels1[i] = new JLabel(attrName); + jp2.add((i + 5) + ".1.center.top", labels1[i]); + labels1[i].setBounds(5, 5, 5, 5); + String value = bean.getVal(); + writer.println("ĬֵΪ:" + value); + if (bean.isIslov()) { + JComboBox comb = new JComboBox(); + // Ż + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + // end + comb.setEditable(false); + comb.setSize(new Dimension(60, 40)); + if (classFlag2) { + if ((PlmLocaleUtil.getString("heatTreatment")).equals(attrName)) { + comb.addItem(""); + HeatTreatment = value; + } else { + comb.addItem(value); + } + } else { + comb.addItem(value); + } + for (Entry entry : bean.getLov().entrySet()) { + if (i == 0) { + writer.println("entry.getKey()====" + entry.getKey()); + } + if (!(value.equals(entry.getKey()))) { + comb.addItem(entry.getKey()); + } + } + // Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + writer.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(comb, tip); + } + } + + }); + // end + map2 = new HashMap(); + map2.put("JComboBox", comb); + values.add(map2); + jp2.add((i + 5) + ".2.center.top", comb); + jp2.add((i + 5) + ".3.center.top", jt); + jp2.add((i + 5) + ".4.center.top", bu); + if (attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, comb); + lovMap.put(attrName, "yes"); + } + if (attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, comb); + lovMap2.put(attrName, "yes"); + } + + writer.println("" + PlmLocaleUtil.getString("PartCategory")); + writer.println("" + attrName); + if (("PartCategory").equals(attrName) || ("").equals(attrName)) { + typeList.add(comb); + attrsMap.put("", comb); + } + + if (("Factory code").equals(attrName) || ("").equals(attrName)) { + attrsMap.put("", comb); + } + if (("Production line code").equals(attrName) || ("ߴ").equals(attrName)) { + attrsMap.put("ߴ", comb); + } + + jcomp = comb; + } else { + JTextField field = new JTextField(18); + field.setText(value); + map2 = new HashMap(); + map2.put("JTextField", field); + values.add(map2); + jp2.add((i + 5) + ".2.center.top", field); + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName)) { + JComboBox box = new JComboBox(); + // Ż + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + // end + box.addItem(" "); + String[] strs = new String[] { "C0", "C2", "C3", "C4", "C5" }; + for (int j = 0; j < strs.length; j++) { + box.addItem(strs[j]); + } + // Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + writer.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(box, tip); + } + } + + }); + boxMap.put(attrName, box); + jp2.add((i + 5) + ".3.center.top", box); + jp2.add((i + 5) + ".4.center.top", jt); + jp2.add((i + 5) + ".5.center.top", bu); + } + if (attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, field); + lovMap.put(attrName, "no"); + } + if (attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, field); + lovMap2.put(attrName, "no"); + } + jcomp = field; + } + v = i + 6; + + if (propID == 660113 || propID == 660114 || propID == 660115) { + jcompMap.put(propID, jcomp); + } + } + + // Ż + jp2.add(v + ".1.center.top", new JLabel(" ")); + jp2.add(v + ".2.center.top", new JLabel("**********************")); + v += 1; + // λ + jp2.add(v + ".1.center.top", new JLabel("λ")); + try { + tagMap.clear(); + dl = new JComboBox(); + dl.setSize(new Dimension(60, 40)); + dl.setName("uom_tag"); + TCProperty zclov1; + TCComponentItem oldItem = targetItem.getItem(); + zclov1 = oldItem.getTCProperty("uom_tag"); + + TCComponentListOfValues zcprolov1 = zclov1.getLOV(); + String[] comboxitems1; + JTextField jt1 = new JTextField(9); + JButton bu1 = new JButton(""); + if (zcprolov1 != null) { + comboxitems1 = zcprolov1.getListOfValues().getLOVDisplayValues(); + TCComponent[] tags = zcprolov1.getListOfValues().getTagListOfValues(); + for (int flag = 0; flag < comboxitems1.length; flag++) { + tagMap.put(comboxitems1[flag], tags[flag]); + } + ComboBoxModel model1 = new DefaultComboBoxModel(comboxitems1); + dl.setModel(model1); + bu1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip1 = jt1.getText(); + writer.println("" + tip1); + if (tip1.length() > 0) { + SearchJComItem.changeBox(dl, tip1); + } + } + + }); + // comboxList.add(dl); + } + dl.setSelectedItem(oldItem.getProperty("uom_tag")); + // if(!(ZC_LBJ_listLBJ.XZLBJDisPros.get(i)).equals("ʱϱʶ")) { + dl.setSelectedIndex(-1); + jp2.add(v + ".2.center.top", dl); + jp2.add((v) + ".3.center.top", jt1); + jp2.add((v) + ".4.center.top", bu1); + v += 1; + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + // λ + MustMap.put("λ", dl); + +// for(String s:lishu_lov.keySet()) { +// String val = lishu_lov.get(s); +// jp2.add(v+".1.center.top",new JLabel(val)); +// JComboBox lishu_comb=new JComboBox(); +// lishu_comb.setEditable(false); +// lishu_comb.setSize(new Dimension(60,40)); +// try { +// TCProperty zcLov_val = targetItem.getTCProperty(s); +// TCComponentListOfValues lov_val = zcLov_val.getLOV(); +// if(lov_val!=null) { +// String[] comboxitems=lov_val.getListOfValues().getLOVDisplayValues(); +// ComboBoxModel model = new DefaultComboBoxModel(comboxitems); +// lishu_comb.setModel(model); +// comboxList.add(lishu_comb); +// } +// lishu_comb.setSelectedItem(zc_pro_map.get(s)); +// jp2.add(v+".2.center.top",lishu_comb); +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// lishu_comb.setName(s); +// v++; +// } +// for(String m:lishu.keySet()) { +// String val=lishu.get(m); +// jp2.add(v+".1.center.top",new JLabel(val)); +// JTextField jf=new JTextField(18); +// jf.setName(m); +// jf.setText(zc_pro_map.get(m)); +// fieldList.add(jf); +// jp2.add(v+".2.center.top",jf); +// v++; +// } + for (int i = 0; i < ZC_LBJ_listLBJ.XZLBJPros.size(); i++) { + + writer.println("ѭ" + i + ",ҪӵΪ" + ZC_LBJ_listLBJ.XZLBJDisPros.get(i) + "(" + + ZC_LBJ_listLBJ.XZLBJPros.get(i) + ")"); + if ((ZC_LBJ_listLBJ.XZLBJDisPros.get(i)).equals("Ʒ") + || (ZC_LBJ_listLBJ.XZLBJDisPros.get(i)).equals("ͼ")) { + + continue; + } + jp2.add((v) + ".1.center.top", new JLabel(ZC_LBJ_listLBJ.XZLBJDisPros.get(i))); + boolean b = ZC_LBJ_listLBJ.map.containsKey(ZC_LBJ_listLBJ.XZLBJPros.get(i)); + try { + if (b) { + + writer.println("Lov"); + JComboBox zcBox = new JComboBox(); + zcBox.setSize(new Dimension(60, 40)); + zcBox.setName(ZC_LBJ_listLBJ.XZLBJPros.get(i)); + TCProperty zclov = ((TCComponentItemRevision) targetItem) + .getTCProperty(ZC_LBJ_listLBJ.XZLBJPros.get(i)); + TCComponentListOfValues zcprolov = zclov.getLOV(); + String[] comboxitems; + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + if (zcprolov != null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + comboxitems = prependEmptyString(comboxitems); + ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + zcBox.setModel(model); + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + writer.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(zcBox, tip); + } + } + + }); + writer.println("ʼ" + zcBox.getName()); + comboxList.add(zcBox); + } + + // zcBox.setSelectedItem(zc_pro_map.get(ZC_LBJ_listLBJ.XZLBJPros.get(i))); + zcBox.setSelectedItem(targetItem.getProperty(ZC_LBJ_listLBJ.XZLBJPros.get(i))); + // if(!(ZC_LBJ_listLBJ.XZLBJDisPros.get(i)).equals("ʱϱʶ")) { +// zcBox.setSelectedIndex(-1); + // } + + jp2.add(v + ".2.center.top", zcBox); + jp2.add((v) + ".3.center.top", jt); + jp2.add((v) + ".4.center.top", bu); + // +++ + MustMap.put(ZC_LBJ_listLBJ.XZLBJDisPros.get(i), zcBox); + // +++ + } else { + JTextField field = new JTextField(18); + field.setName(ZC_LBJ_listLBJ.XZLBJPros.get(i)); + if ((ZC_LBJ_listLBJ.XZLBJDisPros.get(i)).equals("û")) { + field.setText(zc_pro_map.get(ZC_LBJ_listLBJ.XZLBJPros.get(i))); + } + if ((ZC_LBJ_listLBJ.XZLBJDisPros.get(i)).equals("")) { + continue; + } + field.setText(targetItem.getProperty(ZC_LBJ_listLBJ.XZLBJPros.get(i))); + jp2.add(v + ".2.center.top", field); + writer.println("ʼı" + field.getName()); + fieldList.add(field); + // +++ + MustMap.put(ZC_LBJ_listLBJ.XZLBJDisPros.get(i), field); + // +++ + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + v++; + } + + jp2.setVisible(true); + jp2.validate(); + jp2.repaint(); + scr2.validate(); + } + } + }); + JScrollPane scrollPane = new JScrollPane(tree); + scrollPane.setPreferredSize(new Dimension(250, 250)); + + // ӹ嵽 + jp1.add(scrollPane, BorderLayout.CENTER); + // jp2.setVisible(false); + classJpanel.add(scr2); + JSplitPane splitPane = new JSplitPane(); + splitPane.setOneTouchExpandable(true);// ÷ָʾͷ + splitPane.setContinuousLayout(true);// ͷػͼ + splitPane.setLeftComponent(new JScrollPane(jp1)); + splitPane.setRightComponent(new JScrollPane(classJpanel)); + JPanel titlePanel = new JPanel(new FlowLayout());// Խ + + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(button2); + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(okBut); + titlePanel.add(new JLabel(" ")); + titlePanel.add(new JLabel(" ")); + titlePanel.add(celBut); + + this.add(splitPane, BorderLayout.CENTER); + this.add(titlePanel, BorderLayout.SOUTH); + // add("1.1.center.center", splitPane); + // add("1.1.center.center", jp1); + // add("1.2.center.center", classJpanel); + // add("2.1.center.center", button2); + // add("2.2.center.center", okBut); + // add("2.3.center.center", celBut); + + button2.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + writer.println("׼"); + G4MDialog classDialog = new G4MDialog("˱", null, revList, session); + new Thread(classDialog).start(); + } + }); + + okBut.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + try { + createItem(login_file); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + // setVisible(false); + } + + }); + celBut.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + writer.println("ȡ"); + setVisible(false); + } + }); + this.setVisible(true); + this.centerToScreen(); + // this.pack(); + } + /** + * ǰһַ + * @param items ԭʼ + * @return µ飬ַ + */ + private static String[] prependEmptyString(String[] items) { + String[] newItems = new String[items.length + 1]; + newItems[0] = ""; // ĵһλӿַ + System.arraycopy(items, 0, newItems, 1, items.length); // ԭݵ + return newItems; + } + + /* + * ϴ + */ + public void createItem(File login_file) throws IOException { + FileWriter fileWriter = new FileWriter(login_file, true); + PrintWriter writer = new PrintWriter(fileWriter); + writer.println(new Date()+"ʼ"); + // +++жϱ + writer.println(new Date()+"============="); + String[] mustAttributes = service.getStringValues("RB_CreateRequiredAttribute_ls"); + writer.println("=======>RB_CreateRequiredAttribute_lsѡֵ" + Arrays.toString(mustAttributes)); +// writer.println("=======>attrList"+attrList.toString()); +// writer.println("=======>esAttrList"+esAttrList.toString());MustMap + writer.println(new Date()+"MustMap.size====>" + MustMap.size()); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (mustAttributes != null && mustAttributes.length > 0) { + for (int i = 0; i < mustAttributes.length; i++) { + writer.println(new Date()+"==>ԣ" + mustAttributes[i]); + if (MustMap.containsKey(mustAttributes[i])) { + + if (MustMap.get(mustAttributes[i]) instanceof JComboBox) { + JComboBox box = (JComboBox) MustMap.get(mustAttributes[i]); + if (box != null) { + writer.println("boxݣ" + box.getSelectedItem()); + if (box.getSelectedItem() == null || ((String) box.getSelectedItem()).equals("")) { + // δд + MessageBox.post(mustAttributes[i] + "," + rb.getString("sxwtx07_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + return; + } + } + } else if (MustMap.get(mustAttributes[i]) instanceof JTextField) { + JTextField field = (JTextField) MustMap.get(mustAttributes[i]); + if (field != null) { + writer.println("boxݣ" + field.getText()); + if (field.getText() == null || ((String) field.getText()).equals("")) { + // δд + MessageBox.post("" + mustAttributes[i] + "," + rb.getString("sxwtx07_display.TITLE"), + "ʾ", MessageBox.INFORMATION); + return; + } + } + } + } +// if(attrList.contains(mustAttributes[i])) { +// writer.println("attrList+"+mustAttributes[i]); +// JComboBox box=(JComboBox) objMap.get(mustAttributes[i]); +// if(box!=null) { +// writer.println("boxݣ"+box.getSelectedItem()); +// if(box.getSelectedItem()==null||((String)box.getSelectedItem()).equals("")) { +// MessageBox.post(""+mustAttributes[i]+"δд", "ʾ", MessageBox.INFORMATION); +// return; +// } +// } +// }else if(esAttrList.contains(mustAttributes[i])) { +// writer.println("esAttrList"+mustAttributes[i]); +// JComboBox box=(JComboBox) objMap.get(mustAttributes[i]); +// if(box!=null) { +// writer.println("boxݣ"+box.getSelectedItem()); +// if(box.getSelectedItem()==null||((String)box.getSelectedItem()).equals("")) { +// MessageBox.post(""+mustAttributes[i]+"δд", "ʾ", MessageBox.INFORMATION); +// return; +// } +// } +// } + } + } else { + writer.println("RB_CreateRequiredAttributeѡδ"); + } + + writer.println("========Լ======="); + // +++ + + // TODO Auto-generated method stub + String jhID = ""; + try { + if (idList != null && idList.size() > 0) { + JTextField idField = (JTextField) idList.get(0); + JComboBox idbox = (JComboBox) idList.get(1); + String id = idField.getText(); + String boxID = (String) idbox.getSelectedItem(); +// if ("".equals(id.trim()) && "".equals(boxID.trim())) { +// MessageBox.post("δд", "ʾ", MessageBox.INFORMATION); +// return; +// } + if ("".equals(id.trim())) { + id = boxID.trim(); + } + jhID = id; + } + String typeID = ""; + writer.println("ȣ" + typeList.size()); + if (typeList != null && typeList.size() > 0) { + JComboBox idComb = typeList.get(0); + writer.println(idComb.getSelectedItem().toString()); + typeID = (String) idComb.getSelectedItem(); + if (typeID.indexOf("") >= 0 || typeID.indexOf("Turning") >= 0) { + typeID = "C"; + } else if (typeID.indexOf("ȴ") >= 0 || typeID.indexOf("heat treatment piece") >= 0) { + typeID = "R"; + } else if (typeID.indexOf("") >= 0 || typeID.indexOf("Cold Pier pieces") >= 0) { + typeID = "D"; + } else if (typeID.indexOf("ͼ") >= 0 || typeID.indexOf("forging") >= 0) { + typeID = "D"; + } + } + String item_type = ""; + if (selCodeBean != null) { + item_type = selCodeBean.getType(); + } else { + MessageBox.post(rb.getString("qxzzdcjd07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + String targetId = idField1.getText(); + if ("".equals(targetId.trim())) { + // дܳϱţ + MessageBox.post(rb.getString("qtxwlzcbh07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + + String newID = targetId + jhID + typeID; + String revID = (String) revBox.getSelectedItem(); + String itemName = nameComb.getText(); + + // List asList = Arrays.asList(lovVal); + // List esList = Arrays.asList(esLovVal); + // StringBuilder sb = new StringBuilder(); + // for (int i = 0; i < attrList.size(); i++) { + // String attr = attrList.get(i); + // String esAttr = esAttrList.get(i); + // if(!("".equals(attr.trim()))) { + // JComboBox box = null; + // if((PlmLocale.getString("RadialInternalClearance")).equals(attr) + // || (PlmLocale.getString("PartNumber")).equals(attr)) { + // box = boxMap.get(attr); + // } + // Object obj = objMap.get(attr); + // if(obj == null) { + // JTextField field = (JTextField)objMap.get(esAttr); + // if(box != null) { + // String fieldText = field.getText(); + // String boxText = (String) box.getSelectedItem(); + // if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + // MessageBox.post(esAttr+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + // MessageBox.post(esAttr+"дһֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if(!("".equals(fieldText.trim()))) { + // objList.add(field); + // lovList.add("no"); + // }else { + // objList.add(box); + // lovList.add("yes"); + // } + // }else { + // objList.add(field); + // lovList.add(lovMap.get(esAttr)); + // } + // }else { + // if(box != null) { + // JTextField field = (JTextField)obj; + // String fieldText = field.getText(); + // String boxText = (String) box.getSelectedItem(); + // if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + // MessageBox.post(attr+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + // MessageBox.post(attr+"дһֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if(!("".equals(fieldText.trim()))) { + // objList.add(field); + // lovList.add("no"); + // }else { + // objList.add(box); + // lovList.add("yes"); + // } + // }else { + // objList.add(obj); + // lovList.add(lovMap.get(attr)); + // } + // } + // } + // } + // for (int i = 0; i < attrList2.size(); i++) { + // String attr = attrList2.get(i); + // String esAttr = esAttrList2.get(i); + // if(!("".equals(attr.trim()))) { + // JComboBox box = null; + // if((PlmLocale.getString("RadialInternalClearance")).equals(attr) + // || (PlmLocale.getString("PartNumber")).equals(attr)) { + // box = boxMap.get(attr); + // } + // Object obj = objMap2.get(attr); + // if(obj == null) { + // JTextField field = (JTextField)objMap.get(esAttr); + // if(box != null) { + // String fieldText = field.getText(); + // String boxText = (String) box.getSelectedItem(); + // if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + // MessageBox.post(esAttr+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + // MessageBox.post(esAttr+"дһֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if(!("".equals(fieldText.trim()))) { + // objList2.add(field); + // lovList2.add("no"); + // }else { + // objList2.add(box); + // lovList2.add("yes"); + // } + // }else { + // objList2.add(field); + // lovList2.add(lovMap2.get(esAttr)); + // } + // }else { + // if(box != null) { + // JTextField field = (JTextField)obj; + // String fieldText = field.getText(); + // String boxText = (String) box.getSelectedItem(); + // if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + // MessageBox.post(attr+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + // MessageBox.post(attr+"дһֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if(!("".equals(fieldText.trim()))) { + // objList2.add(field); + // lovList2.add("no"); + // }else { + // objList2.add(box); + // lovList2.add("yes"); + // } + // }else { + // objList2.add(obj); + // lovList2.add(lovMap2.get(attr)); + // } + // } + // } + // } + // for (int i = 0; i < objList.size(); i++) { + // String attrValue = ""; + // if("yes".equals(lovList.get(i))) { + // String value = (String) ((JComboBox) + // objList.get(i)).getSelectedItem(); + // if(asList.contains(value) || esList.contains(value)) { + // value = ""; + // }else { + // if(value.contains(":")) { + // String[] values = value.split(":"); + // value = values[0]; + // }else if(value.contains("")) { + // String[] values = value.split(""); + // value = values[0]; + // } + // } + // if("Ʒ".equals(value)) { + // value = ""; + // }else if("".equals(value)) { + // value = "C"; + // }else if("ȴ".equals(value)) { + // value = "R"; + // }else if("".equals(value)) { + // value = "L"; + // }else if("ͼ".equals(value)) { + // value = "D"; + // } + // attrValue = value; + // }else { + // attrValue = ((JTextField) objList.get(i)).getText(); + // } + // String mark = markList.get(i); + // sb.append(mark.trim()); + // sb.append(attrValue); + // writer.println("attrValue=============="+attrValue); + // } + // productNumber = sb.toString(); + // writer.println("productNumber============"+productNumber); + // StringBuilder sb2 = new StringBuilder(); + // + // for (int i = 0; i < objList2.size(); i++) { + // String attrValue = ""; + // if("yes".equals(lovList2.get(i))) { + // String value = (String) ((JComboBox) + // objList2.get(i)).getSelectedItem(); + // if(asList.contains(value) || esList.contains(value)) { + // value = ""; + // }else { + // if(value.contains(":")) { + // String[] values = value.split(":"); + // value = values[0]; + // }else if(value.contains("")) { + // String[] values = value.split(""); + // value = values[0]; + // } + // } + // if("Ʒ".equals(value)) { + // value = ""; + // }else if("".equals(value)) { + // value = "C"; + // }else if("ȴ".equals(value)) { + // value = "R"; + // }else if("".equals(value)) { + // value = "L"; + // }else if("ͼ".equals(value)) { + // value = "D"; + // } + // attrValue = value; + // }else { + // attrValue = ((JTextField) objList2.get(i)).getText(); + // } + // writer.println("attrValue11111=============="+attrValue); + // String mark = markList2.get(i); + // sb2.append(mark.trim()); + // sb2.append(attrValue); + // } + // drawingNumber = sb2.toString(); + // writer.println("drawingNumber============"+drawingNumber); + if (classFlag) { + productNumber = splicValue(defaultValueList, attrList, esAttrList, objMap, markList, isNList, lovMap, writer ); + productNumber += "-" + typeID; + writer.println(new Date()+"productNumber============" + productNumber); + drawingNumber = splicValue(defaultValueList2, attrList2, esAttrList2, objMap2, markList2, isNList2, + lovMap2, writer ); + + + writer.println(new Date()+"drawingNumber============" + drawingNumber); + if (productNumber == null || drawingNumber == null) { + return; + } + } else { + productNumber = targetItem.getStringProperty("rb3_th") + jhID; + writer.println(new Date()+"productNumber============" + productNumber); + drawingNumber = targetItem.getStringProperty("rb3_th") + jhID; + + writer.println(new Date()+"drawingNumber============" + drawingNumber); + } + + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(item_type); + TCComponentItem find = itemType.find(newID); + if (find != null) { + MessageBox.post(":" + newID + "Ѵ,޷!", "", MessageBox.ERROR); + return; + } + + // endŻ + TCComponent uom = null; + String dlval = (String) dl.getSelectedItem(); + if (dlval == null || dlval.equals("")) { + MessageBox.post("λѡ", "", MessageBox.INFORMATION); + return; + } else { + TCComponent tcComponent = tagMap.get(dlval); + uom = tcComponent; + } + + TCComponentItem itemComp = itemType.create(newID, revID, item_type, itemName, null, uom); + getFolder(); +// session.getUser().getHomeFolder().add("contents", itemComp); +// session.getUser().getHomeFolder().refresh(); + folder.add("contents", itemComp); + folder.refresh(); + TCComponentItemRevision itemRev = itemComp.getLatestItemRevision(); + + List vals = new ArrayList(); + for (Map value : values) { + for (Map.Entry entry : value.entrySet()) { + String type = entry.getKey(); + if (type.equals("JComboBox")) { + JComboBox comb1 = (JComboBox) entry.getValue(); + String val = (String) comb1.getSelectedItem(); + vals.add(val); + } else { + JTextField field1 = (JTextField) entry.getValue(); + String val = field1.getText(); + vals.add(val); + } + } + } + Integer[] classKeys = new Integer[classList.size()]; + String[] classVals = new String[classList.size()]; +// writer.println("size============================" + classList.size()); + for (int i = 0; i < labels1.length; i++) { + String val = vals.get(i); + if (val == null || val.trim() == "") { + continue; + } + String val2 = ""; + if (classList.get(i).isIslov()) { + val2 = classList.get(i).getLov().get(val);// ʵֵ +// writer.println("val2================" + val2); +// writer.println("val================" + val); + } else { + val2 = val; + } + classKeys[i] = classList.get(i).getId(); + String attrName = classList.get(i).getName(); + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName) + || (PlmLocaleUtil.getString("PartNumber")).equals(attrName)) { + if ("".equals(val2.trim())) { + JComboBox box = boxMap.get(attrName); + val2 = (String) box.getSelectedItem(); + } + } + classVals[i] = val2; + } + // ʼͷ + writer.println(new Date()+"ʼͷ==============" + className2); + writer.println(itemRev.getUid() + "============>" + itemRev.getStringProperty("object_string")); + sendObjToClassficationByWebService(className2, itemRev, classKeys, classVals, url,login_file);// ͷ + writer.println(new Date()+"෢"); + // Ż + for (int k = 0; k < fieldList.size(); k++) { + JTextField jt = (JTextField) fieldList.get(k); + String key = jt.getName(); + String val = jt.getText(); + writer.println("ı" + key + val); + fieldmap.put(key, val); + } + for (int m = 0; m < comboxList.size(); m++) { + JComboBox cbo = (JComboBox) comboxList.get(m); + cbo.setEditable(false); + String key = cbo.getName(); + writer.println("comboxNameΪ:" + key); + String val = (String) cbo.getSelectedItem(); + TCProperty tclov = ((TCComponentItemRevision) targetItem).getTCProperty(key); + TCComponentListOfValues lov = tclov.getLOV(); + String realVal = (String) lov.getListOfValues().getRealValue(val); + writer.println("ѡеֵΪ:" + val); + writer.println("Ӹѡ" + key + realVal); + comboxmap.put(key, realVal); + } + +// } + itemRev.setProperties(fieldmap); + itemRev.setProperties(comboxmap); + + // endŻ + + String statu = ""; + if ("A1".equals(revID)) { + statu = ":Conceptual design"; + } else if ("B1".equals(revID)) { + statu = ":Product design"; + } else if ("R1".equals(revID)) { + statu = ":Process design/Sample delivery"; + } else if ("P1".equals(revID)) { + statu = "P:Pilot production/small batch"; + } else if ("M1".equals(revID)) { + statu = "M:Mass production"; + } + + itemRev.setStringProperty("rb3_cph", productNumber); + itemRev.setStringProperty("rb3_smzqzt", statu); + // itemRev.setStringProperty("rb3_jh", jhID); + + String item_id = targetItem.getProperty("item_id"); + String id = dealItemId(item_id,writer); +// if (id != null) { +// build.append(id); +// build.append(drawingNumber); +// } else { +// build.append(drawingNumber); +// } + + // ʼƴͼű + if (attrsMap.size() > 0) { + build.append("P"); + String cpdh = (String) (attrsMap.get("").getSelectedItem()); + build.append(cpdh.split(":")[0]); + String cxdh = (String) (attrsMap.get("ߴ").getSelectedItem()); + build.append(cxdh.split(":")[0]); + writer.println("build:"+build.toString()); + + // ȡˮ + TCUserService userservice = this.session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = ""; + Object[] params = new Object[] { build.toString(), 4, 1, 9999, 1, "" }; + + try { + TCUtils.openLogByPass(session, name); + userservice.call("Connor_set_bypass", obj); + String str = "";// DM,8,400,99999999,1,"" + newID =(String) userservice.call("queryPartNo", params); + + + String newID_2 = ""; + String[] keys = new String[] { " ID" }; + newID_2 = newID + "-" + typeID; + writer.println("newID:"+newID_2); + + String[] values = new String[] { newID_2 }; + List compList = queryObject(" ID", keys, values); + +// if (compList != null && compList.size() > 0) { +// newID = new GetNewCode(params,newID).getCode(); +// newID_2 = newID + "-" + typeID; +// writer.println("newID2:"+newID_2); +// String[] value = new String[] { newID_2 }; +// List queryObject = queryObject(" ID", keys, value); +// if(queryObject != null && queryObject.size() > 0){ +// MessageBox.post("ȡظϵԱ", "", MessageBox.INFORMATION); +// return; +// } +//// newID = (String) userservice.call("queryPartNo", params); +//// newID = newID + "-" + typeID; +//// writer.println("whileѭɵglhΪ:" + newID); +//// String[] value = new String[] { newID }; +//// compList = queryObject(" ID", keys, value); +// } + + + while (compList != null && compList.size() > 0) { +// newID = (String) userservice.call("queryPartNo", params); + newID = new GetNewCode(params,newID).getCode(); + newID_2 = newID + "-" + typeID; + writer.println("whileѭɵglhΪ:" + newID_2); + String[] value = new String[] { newID_2 }; + compList = queryObject(" ID", keys, value); + } + + + + +// int index = newID.indexOf(build.toString()); +// if (index != -1) { +// // ע⣺indexOf()صַʼλãҪַij +// String remainingString = newID.substring(index + build.toString().length()); +// remainingString = remainingString.substring(1); +// newID = build.toString()+remainingString; +// } else { +// +// writer.println("not found in the given string."); +// return; +// } + writer.println(new Date()+"newID===============" + newID); + build = new StringBuilder(newID); + + } catch (Exception e) { + e.printStackTrace(); + }finally { + try { + TCUtils.closeLogByPass(session, name); + userservice.call("Connor_close_bypass", obj); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + } + + if ("RB3_XZLBJ".equals(item_type)) { + if (revList.size() > 0) { + TCComponentItemRevision picItem = revList.get(0); + TCComponent[] pics = picItem.getReferenceListProperty("TC_Is_Represented_By"); + for (int i = 0; i < pics.length; i++) { + itemRev.add("TC_Is_Represented_By", pics[i]); + } + // picItem.add("RB3_GLWL", itemRev); + } else { + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent("RB3_XZLJT"); + TCComponentItem LJTItem = typeComponent.create(build.toString(), "V1", "RB3_XZLJT", "", "", null); + if (LJTItem != null) { + TCComponentItemRevision LJTRev = LJTItem.getLatestItemRevision(); + folder.add("contents", LJTItem); + folder.refresh(); + itemRev.add("TC_Is_Represented_By", LJTRev); + } + } + } else { + itemRev.setStringProperty("rb3_th", build.toString()); + if (revList.size() > 0) { + TCComponentItemRevision picItem = revList.get(0); + TCComponent[] pics = picItem.getReferenceListProperty("TC_Is_Represented_By"); + for (int i = 0; i < pics.length; i++) { + itemRev.add("TC_Is_Represented_By", pics[i]); + } + // picItem.add("RB3_GLWL", itemRev); + } else { + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent("RB3_XZLJT"); + + String[] keys = new String[] { " ID" }; + + String[] values = new String[] { build.toString() }; + List tzList = queryObject(" ID", keys, values); + TCComponentItemRevision CPTRev = null; + if (tzList != null) { + if (tzList.size() > 0) { + if (tzList.get(0) instanceof TCComponentItem) { + TCComponentItem tcItem = (TCComponentItem) tzList.get(0); + CPTRev = tcItem.getLatestItemRevision(); + } + } + } else { + TCComponentItem CPTItem = typeComponent.create(build.toString(), "V1", "RB3_XZLJT", "", "", + null); + CPTRev = CPTItem.getLatestItemRevision(); + if (CPTItem != null) { + + if (build.toString().length() > 0) { + CPTRev.setStringProperty("rb3_th", build.toString()); + } else { + CPTRev.setStringProperty("rb3_th", drawingNumber); + } + folder.add("contents", CPTItem); + folder.refresh(); + } + + } + itemRev.add("TC_Is_Represented_By", CPTRev); + // CPTRev.add("RB3_GLWL", itemRev); + } + } + + TCTypeService typeService = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) typeService.getTypeComponent("BOMWindow"); + // һµwindow + TCComponentBOMWindow view = winType.create(null); + view.lock(); + // öbomline + TCComponentBOMLine line = view.setWindowTopLine(targetItem.getItem(), targetItem, null, null); + // bomline + TCComponentBOMLine childBomline = line.add(itemComp, itemRev, null, false, ""); + // + view.save(); + // + view.unlock(); + // ر + view.close(); + + MessageBox.post(rb.getString("wlcjcg07_display.TITLE"), "", MessageBox.INFORMATION); + + // +++ +// new Thread() { +// @Override +// public void run() { +// +// } +// }.start(); + // +++ +// sendObjToClassficationByWebService(className2, itemRev, classKeys, classVals, url);// ͷ +// MessageBox.post("ϴɹ", "", MessageBox.INFORMATION); + + setVisible(false); + writer.println(new Date()+""); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + MessageBox.post(rb.getString("wlcjsb07_display.TITLE"), "", MessageBox.INFORMATION); + } + writer.flush(); + writer.close(); + } + + /** + * õǰTreeNodeĸ-ƻ + * + * @param treeNode ڵ + * @param names ƻ + * @return + */ + private String getNode(TreeNode treeNode, String names) { + // TODO Auto-generated method stub + if (!names.equals("")) { + names = "&" + names; + } + names = treeNode.toString() + names; + + TreeNode parent = treeNode.getParent(); + if (parent != null) { + return getNode(parent, names); + } + + return names; + } + + /** + * + * + * @param menuBean1 + * @return + */ + private JTree getTree(MenuBean menuBean1) { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(treenodename); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), rootNode); + } + } + JTree tree = new JTree(rootNode); + tree.setShowsRootHandles(true); + // tree.setEditable(true); + + return tree; + } + + /** + * ݹ˵ṹ + * + * @param menuBean1 + * @param rootNode + */ + private void getRecursion(MenuBean menuBean1, DefaultMutableTreeNode rootNode) { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode node = new DefaultMutableTreeNode(treenodename); + rootNode.add(node); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), node); + } + } + } + + /** + * ͨѯѯĿ + * + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + return null; + } + } + + /** + * ͷ + */ + public void sendObjToClassficationByWebService(String class_id, TCComponentItemRevision rev, Integer[] keys, + String[] vals, String url,File login_file) { + + try { + FileWriter fileWriter = new FileWriter(login_file, true); + PrintWriter writer = new PrintWriter(fileWriter); + writer.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList(); + + for (int i = 0; i < keys.length; i++) { + if (keys[i] != null && vals[i] != null) { + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + writer.flush(); + writer.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public String splicValue(List defaultValueList, List attrList, List esAttrList, + Map map, List markList, List isNList, Map lovMap,PrintWriter writer ) { + List objList = new ArrayList(); + List lovList = new ArrayList(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < attrList.size(); i++) { + String attr = attrList.get(i); + writer.println("attr======112" + attr); + String esAttr = esAttrList.get(i); + if (classFlag2) { + if ((PlmLocaleUtil.getString("heatTreatment")).equals(attr) + || (PlmLocaleUtil.getString("heatTreatment")).equals(esAttr)) { + objList.add(HeatTreatment); + lovList.add("string"); + continue; + } + } + if (map.get(attr) == null && map.get(esAttr) == null) { + if ((PlmLocaleUtil.getString("PartNumber")).equals(attr) + || (PlmLocaleUtil.getString("PartNumber")).equals(esAttr)) { + JComboBox idbox = boxMap.get(PlmLocaleUtil.getString("PartNumber")); + JTextField idfield = (JTextField) idList.get(0); + String fieldText = idfield.getText(); + String boxText = (String) idbox.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(PlmLocaleUtil.getString("PartNumber") + "ͬʱдֵ", "ʾ", + MessageBox.INFORMATION); + return null; + } +// if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { +// MessageBox.post(PlmLocaleUtil.getString("PartNumber") + "дһֵ", "ʾ", +// MessageBox.INFORMATION); +// return null; +// } + if (!("".equals(fieldText.trim()))) { + objList.add(fieldText); + lovList.add("string"); + } else { + objList.add(boxText); + lovList.add("string"); + } + continue; + } + objList.add(defaultValueList.get(i)); + lovList.add("string"); + continue; + } + if (!("".equals(attr.trim()))) { + Object obj = map.get(attr); + JComboBox box = null; + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attr) + || (PlmLocaleUtil.getString("RadialInternalClearance")).equals(esAttr)) { + box = boxMap.get(PlmLocaleUtil.getString("RadialInternalClearance")); + } + if (obj == null) { + obj = map.get(esAttr); + if (box != null) { + JTextField field = (JTextField) obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(esAttr + "ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(esAttr + "дһֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + } else { + objList.add(box); + lovList.add("yes"); + } + } else { + objList.add(obj); + lovList.add(lovMap.get(esAttr)); + } + } else { + if (box != null) { + JTextField field = (JTextField) obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(attr + "ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(attr + "дһֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + } else { + objList.add(box); + lovList.add("yes"); + } + } else { + objList.add(obj); + lovList.add(lovMap.get(attr)); + } + } + } + } + for (int i = 0; i < objList.size(); i++) { + String attrValue = ""; + Object obj = objList.get(i); + if (obj != null) { + if ("yes".equals(lovList.get(i))) { + String value = (String) ((JComboBox) obj).getSelectedItem(); + writer.println("ֵΪ:" + value); + if (asList.contains(value) || esList.contains(value)) { + if (isNList.get(i).trim().contains(value)) { + if (value.contains(":")) { + writer.println("value============" + value); + String[] values = value.split(":"); + value = values[0]; + } else if (value.contains("")) { + writer.println("value============" + value); + String[] values = value.split(""); + value = values[0]; + } + } else { + value = ""; + } + } else { + if (value.contains(":")) { + writer.println("value============" + value); + String[] values = value.split(":"); + value = values[0]; + } else if (value.contains("")) { + writer.println("value============" + value); + String[] values = value.split(""); + value = values[0]; + } + } + + if ("".equals(value) || "Turning".equals(value)) { + value = "C"; + } else if ("ȴ".equals(value) || "heat treatment piece".equals(value)) { + value = "R"; + } else if ("".equals(value) || "Cold Pier pieces".equals(value)) { + value = "D"; + } else if ("ͼ".equals(value) || "forging".equals(value)) { + value = "D"; + } + attrValue = value; + } else if ("no".equals(lovList.get(i))) { + attrValue = ((JTextField) obj).getText(); + } else { + attrValue = (String) obj; + } + if (asList.contains(attrValue) || esList.contains(attrValue)) { + attrValue = ""; + } else { + if (attrValue.contains(":")) { + writer.println("attrValue============" + attrValue); + String[] values = attrValue.split(":"); + attrValue = values[0]; + } else if (attrValue.contains("")) { + writer.println("attrValue============" + attrValue); + String[] values = attrValue.split(""); + attrValue = values[0]; + } + } + String mark = markList.get(i); + if (!("".equals(attrValue.trim()))) { + sb.append(mark.trim()); + sb.append(attrValue); + } + } + } + return sb.toString(); + } + + // Ż:idΪ22XX22ͷ + public String dealItemId(String id,PrintWriter writer ) { + String subs = id.substring(0, 2); + if (subs.equals("XX")) { + + String sub = id.substring(2, 4); + if (sub.equals("22")) { + writer.println("idXX22ͷ!"); + return "XX-"; + } + } else if (subs.equals("22")) { + writer.println("id22ͷ!"); + return "SF-"; + } + return null; + } + + // ҶӦĸļ + public void getFolder() { + boolean b = false; + if (refs.length > 0) { + for (AIFComponentContext ref : refs) { + InterfaceAIFComponent component = ref.getComponent(); + if (component instanceof TCComponentFolder) { + folder = (TCComponentFolder) component; + b = true; + break; + } + } + } + if (!b) { + try { + folder = session.getUser().getHomeFolder(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + +// public String getGLH() { +// String glh = null; +// JComponent jcomp1 = jcompMap.get(660113); +// JComponent jcomp2 = jcompMap.get(660114); +// JComponent jcomp3 = jcompMap.get(660115); +// if (jcomp1 != null && jcomp2 != null && jcomp3 != null) { +// List jcomps = new ArrayList(); +// jcomps.add(jcomp1); +// jcomps.add(jcomp2); +// jcomps.add(jcomp3); +// StringBuilder build = new StringBuilder(); +// for (int i = 0; i < jcomps.size(); i++) { +// JComponent jcomp = jcomps.get(i); +// if (jcomp instanceof JComboBox) { +// JComboBox combo = (JComboBox) jcomp; +// String comboStr = (String) combo.getSelectedItem(); +// if (!(comboStr.trim().equals(""))) { +// if (comboStr.contains(":")) { +// comboStr = comboStr.split(":")[0]; +// } +// if (i == 2) { +// build.append("-" + comboStr + "|"); +// } else { +// build.append(comboStr + "|"); +// } +// +// } +// } else if (jcomp instanceof JTextField) { +// JTextField jtext = (JTextField) jcomp; +// String textStr = jtext.getText(); +// if (!(textStr.trim().equals(""))) { +// if (textStr.contains(":")) { +// textStr = textStr.split(":")[0]; +// } +// if (i == 2) { +// build.append("-" + textStr + "|"); +// } else { +// build.append(textStr + "|"); +// } +// +// } +// } +// } +// Object[] params = new Object[] { build.toString(), 4, 1, 9999, 1, "" }; +// Object[] obj = new Object[1]; +// obj[0] = ""; +// TCUserService userservice = this.session.getUserService(); +// try { +// userservice.call("Connor_set_bypass", obj); +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// +// try { +// glh = (String) userservice.call("queryPartNo", params); +// writer.println("ɵĹΪ:" + glh); +// String[] keys = new String[] { " ID" }; +// glh = dealGLH(glh); +// +// String[] values = new String[] { glh }; +// List compList = queryObject(" ID", keys, values); +// while (compList != null && compList.size() > 0) { +// glh = (String) userservice.call("queryPartNo", params); +// glh = dealGLH(glh); +// writer.println("whileѭɵglhΪ:" + glh); +// String[] value = new String[] { glh }; +// compList = queryObject(" ID", keys, value); +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } else { +// MessageBox.post("Կͻ롢Ż汾δд", "ʾ", MessageBox.INFORMATION); +// } +// return glh; +// } + +// public String dealGLH(String glh) { +// writer.println("dealGLH"); +// String[] split = glh.split("\\|"); +// StringBuilder build = new StringBuilder(); +// if (split.length > 3) { +// build.append(split[0]); +// build.append(split[3]); +// build.append(split[1]); +// build.append(split[2]); +// } else { +// writer.println("glhƴ쳣!"); +// } +// writer.println("glhֵΪ:" + build.toString()); +// return build.toString(); +// } + + // ȡlovֵ + public String[] getRealLoveName(String lovName,PrintWriter writer ) throws TCException { + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues projectItemslov = TCComponentListOfValuesType.findLOVByName(lovName); + String[] projectItems = null; + if (projectItemslov != null) { + writer.println(projectItemslov.toString()); + projectItems = projectItemslov.getListOfValues().getLOVDisplayValues(); + } + return projectItems; + } + + /** + * + * @Title: sendRevToClass + * @Description: ȡoriginRev෢͵copyRev + * @param @param originRev + * @param @param copyRev + * @param @throws TCException + * @return void + * @throws + */ + private static Integer[] keys; + private static String[] vals; + private static boolean isSucceed = true; + + public static void sendRevToClass(TCComponentItemRevision originRev, TCComponentItemRevision copyRev, + java.lang.String class_id) throws TCException { + TCComponentICO[] icoS = originRev.getClassificationObjects(); + + int count = 0; + int count1 = 0; + for (int i = 0; i < icoS.length; i++) { + ICSProperty[] cPropS = icoS[i].getICSProperties(true); + for (int j = 0; j < cPropS.length; j++) { + count++; + } + keys = new Integer[count]; + vals = new String[count]; + for (int j = 0; j < cPropS.length; j++) { + keys[count1] = cPropS[j].getId(); + vals[count1] = cPropS[j].getValue(); + count1++; + } + break; + } + + try { + sendObjToClassficationByWebService(copyRev, keys, vals, class_id); + } catch (Exception e) { + MessageBox.post("ʧ", "", MessageBox.ERROR); + e.printStackTrace(); + return; + } + if (isSucceed == false) { + MessageBox.post("ʧ", "", MessageBox.ERROR); + return; + } + + } + + /** + * + * @param class_id + * @Title: sendObjToClassficationByWebService + * @Description: ͷ + * @param @param rev + * @param @param keys + * @param @param vals + * @return void + * @throws + */ + public static void sendObjToClassficationByWebService(TCComponentItemRevision rev, Integer[] keys, String[] vals, + java.lang.String class_id) { + try { + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList<>(); + for (int i = 0; i < keys.length; i++) { + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + String url = session.getPreferenceService().getStringValue("Autocode_SendClassServer_URL"); + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + isSucceed = false; + e.printStackTrace(); + } + + } +} diff --git a/src/com/connor/rb/plm/rb007/Rb007Handler.java b/src/com/connor/rb/plm/rb007/Rb007Handler.java new file mode 100644 index 0000000..45fc6be --- /dev/null +++ b/src/com/connor/rb/plm/rb007/Rb007Handler.java @@ -0,0 +1,85 @@ +package com.connor.rb.plm.rb007; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.common.NotDefinedException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class Rb007Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + try { + String name = arg0.getCommand().getName(); + if (name.equals("Affiliate Creation")) { + name = ""; + } else if (name.equals("GNK Affiliate Creation")) { + name = ""; + } else if (name.equals("Xinzi finished product creation")) { + name = "ӳƷ"; + } else if (name.equals("Xinzi Affiliation Creation")) { + name = ""; + } + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + // TCSession session = (TCSession) app.getSession(); + // InterfaceAIFComponent com = app.getTargetComponent(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if (targetComponent instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) targetComponent; + System.out.println("rev.getType()=====" + rev.getType()); + if ("RB3_ZCRevision".equals(rev.getType()) || "RB3_LBJRevision".equals(rev.getType()) + || "RB3_GNZCRevision".equals(rev.getType()) || "RB3_GNLBJRevision".equals(rev.getType()) + || "RB3_XZCPRevision".equals(rev.getType()) || "RB3_XZZCRevision".equals(rev.getType())) { + Rb007Action dia = new Rb007Action(app, null, name); + System.out.println("1---"); + new Thread(dia).start(); + } else { + MessageBox.post(rb.getString("qxzzcbbhlbj07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return null; + } + } else if (targetComponent instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) targetComponent; + try { + String itemType = item.getStringProperty("object_type"); + if (itemType.equals("RB3_GNZC")) { + TCSession session2 = (TCSession) targetComponent.getSession(); + Rb007Action dia = new Rb007Action(app, null, name, itemType); + System.out.println("2---"); + new Thread(dia).start(); + } else { + MessageBox.post(rb.getString("gnzcdx_display.TITLE"), "ʾ", MessageBox.INFORMATION); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + MessageBox.post(rb.getString("qxzbbdx07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return null; + } + + } catch (NotDefinedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + +} diff --git a/src/com/connor/rb/plm/rb007/test.java b/src/com/connor/rb/plm/rb007/test.java new file mode 100644 index 0000000..f6afb3a --- /dev/null +++ b/src/com/connor/rb/plm/rb007/test.java @@ -0,0 +1,40 @@ +/** * @Title: test.java + * @Package com.connor.rb.plm.rb007 + * @Description: TODO(һ仰ļʲô) + * @author admin * @date 2024314 + * @version V1.0 + */ +package com.connor.rb.plm.rb007; + +import java.util.Locale; + +/** + * @ClassName: test + * @Description: TODO(һ仰) + * @author admin + * @date 2024314 + * + */ +public class test { +// public static void main(String[] args) { +// String newID = "TEST000001"; +// StringBuilder build = new StringBuilder("TEST"); +// int index = newID.indexOf(build.toString()); +// if (index != -1) { +// // ע⣺indexOf()صַʼλãҪַij +// String remainingString = newID.substring(index + build.toString().length()); +// remainingString = remainingString.substring(1); +// newID = build.toString()+remainingString; +// } else { +// +// System.out.println("not found in the given string."); +// return; +// } +// System.out.println(newID); +// } + public static void main(String[] args) { + String string = "LS-1412XKW33J2WXCAAQQQQQQQQQQQ"; + System.out.println(string.startsWith("LS-")); + } + +} diff --git a/src/com/connor/rb/plm/rb011/CreatDialog.java b/src/com/connor/rb/plm/rb011/CreatDialog.java new file mode 100644 index 0000000..661ed86 --- /dev/null +++ b/src/com/connor/rb/plm/rb011/CreatDialog.java @@ -0,0 +1,2242 @@ +package com.connor.rb.plm.rb011; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.ResourceBundle; +import java.util.Set; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.KeyStroke; + +import com.connor.rb.plm.newcombox.RwDefaultComboBoxModel; +import com.connor.rb.plm.newcombox.RwJComboBox; +import com.connor.rb.plm.rb012.SearchJComItem; +import com.connor.rb.plm.rb028.LovMsg; +import com.connor.rb.plm.rb028.LovUtils; +import com.connor.rb.plm.util.ClassAttributeBean; +import com.connor.rb.plm.util.ClassProperty; +import com.connor.rb.plm.util.GetNewCode; +import com.connor.rb.plm.util.ParseXML; +import com.connor.rb.plm.util.PlmLocaleUtil; +import com.connor.rb.plm.util.SoaServerUtil; +import com.connor.rb.plm.util.TCUtils; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +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.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSKeyLov.KeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class CreatDialog extends AbstractAIFOperation { + private AbstractAIFApplication app; + private TCSession session; + private TCPreferenceService service; + private List classList = new ArrayList(); + private JLabel[] labels1 = null; + private JComboBox comb = null; + private String className = ""; + private Map map2; + private List> values = new ArrayList>(); + private String type = ""; + private String targetType = ""; + private JScrollPane scr2; + private int flag = 0; + private String url = ""; + private TCComponentItemRevision targetRev = null; + private boolean classFlag = true; + private JTextField idField = null; + private JTextField nameField = null; + private JComboBox revComb = null; + private List idList = new ArrayList(); + private List typeList = new ArrayList(); + private String productNumber = ""; + private String drawingNumber = ""; + private Map> attrMap; + private Map> attrMap2; + private Map> attrMap3; + private Map> attrMap4; + private Map> boxMap = new HashMap>(); + private Map objMap = new HashMap(); + private Map objMap2 = new HashMap(); + private Map objMap3 = new HashMap(); + private Map objMap4 = new HashMap(); + private Map lovMap = new HashMap(); + private Map lovMap2 = new HashMap(); + private Map lovMap3 = new HashMap(); + private Map lovMap4 = new HashMap(); + private List defaultValueList = new ArrayList(); + private List isNList = new ArrayList(); + private List isNList2 = new ArrayList(); + private List isNList3 = new ArrayList(); + private List isNList4 = new ArrayList(); + private List markList = new ArrayList(); + private List markList2 = new ArrayList(); + private List markList3 = new ArrayList(); + private List markList4 = new ArrayList(); + private List attrList = new ArrayList(); + private List esAttrList = new ArrayList(); + // private List objList = new ArrayList(); + // private List lovList = new ArrayList(); + private List attrList2 = new ArrayList(); + private List attrList3 = new ArrayList(); + private List attrList4 = new ArrayList(); + private List esAttrList2 = new ArrayList(); + private List esAttrList3 = new ArrayList(); + private List esAttrList4 = new ArrayList(); + private String bsNumber = ""; + private String smNumber = ""; + private List asList = new ArrayList(); + private List esList = new ArrayList(); + private InterfaceAIFComponent targetComp; + // Ż + private AIFComponentContext[] refs; + private TCComponentFolder folder; + private TCComponentItem tccItem; + private Map zc_lbj_map = new HashMap<>(); + private List fieldList = new ArrayList<>(); + private List comboxList = new ArrayList(); + private List yylyList = new ArrayList(); + // private int h=4; + // private boolean boflag=false; + private Map fieldmap = new HashMap<>(); + private Map comboxmap = new HashMap<>(); + private String[] strss; + private JComboBox dl = null; + private String yyly_text = null; + private String yyly = "rb3_yyly"; + private String scgc = "rb3_scgc1"; + private LovMsg msg = new LovMsg(); + private Map tagMap = new HashMap(); + private Object[] params; + private TCUserService userservice; + private String[] remove = { "Ʒ", "ͼ", "ʶ", "˵" }; + + private List BZJPros = new ArrayList<>();// ׼ʵ + private List BZJDisPros = new ArrayList<>();// ׼ʾ + private Map khdmlbbbs = new HashMap();;// ͻ롢𡢰汾 + private Map gccxdhs = new HashMap();;// ͻ롢𡢰汾 + + private TCComponentItem item; + private int Count = 0; + + String comptype = ""; + List displayName = new ArrayList(); + List realName = new ArrayList(); + private JFrame jFrame; + + private Map MustMap = new HashMap();// +++ǩдӽжǷ + // endŻ + // private List objList2 = new ArrayList(); + // private List lovList2 = new ArrayList(); + // private String[] lovVal = new String[] { "ǰ", "׼", "޽Ӵ", "ʽ", + // "ͨ", "A:NBR", "0:", "", "", + // "SN:1805ػ", "ȴ", "", "S:(25% to 35%)", + // "C0","V0","Z0","׼","PC:ﵽC&UƷƾҪ" + // ,"P0:ﵽC&UƷƾҪ","ṹҪƹ","0:˫нǽӴ",":SECC൱",":벿Ŷȷ","BC:35"}; + // private String[] esLovVal = new String[] { "Non", "Standard ball", "Non", + // "Open", "Without vent hole", "A:NBR", + // "0:Black", "Non", "Ball", "SN:1805 temper","Conventional monolithic + // martensite quenching heat treatment", + // "Single", "S:(25% to 35%)", "C0","V0","Z0","Standard","PC:Meet the group C&U + // brand accuracy requirements" + // ,"P0:Meet the group C&U brand accuracy requirements","Other structures need + // to formulate rules","0:Double row angular contact ball bearing" + // ,"Not marked: SECC or equivalent","Other materials: confirm with department + // team for approval","BC:35"}; + + public CreatDialog(AbstractAIFApplication app, String comptype, List displayName, List realName) { + super(false); + this.app = app; + this.targetComp = app.getTargetComponent(); + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + this.comptype = comptype; + this.displayName = displayName; + this.realName = realName; + userservice = session.getUserService(); + } + + public CreatDialog(AbstractAIFApplication app, TCComponentItem item) { + super(false); + this.app = app; + this.item = item; + Count = 1; + + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + System.out.println(new Date() + "ʼȡѡ"); + String lovVal = service.getStringValue("RB3_lovVal_default"); + String esLovVal = service.getStringValue("RB3_esLovVal_default"); + if (lovVal.contains(";")) { + String[] vals = lovVal.split(";"); + String[] esVals = esLovVal.split(";"); + for (int i = 0; i < vals.length; i++) { + asList.add(vals[i]); + esList.add(esVals[i]); + } + } + ParseXML xml = new ParseXML(); + File file = xml.getSXX("RB3_CPHPJFS", session); + + attrMap = xml.parseXMLAttr(file); + if (attrMap == null || attrMap.size() <= 0) { + MessageBox.post("ѡRB3_CPHPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + File file2 = xml.getSXX("RB3_THPJFS", session); + attrMap2 = xml.parseXMLAttr(file2); + if (attrMap2 == null || attrMap2.size() <= 0) { + MessageBox.post("ѡRB3_THPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + System.out.println(new Date() + "ʼ"); + System.out.println(new Date() + "ʼʼ"); + + jFrame = new JFrame(); + jFrame.setTitle("Ϊ"); + int i = 1; + Dimension dimension = new Dimension(); + jFrame.setLayout(new PropertyLayout()); + dimension.setSize(670, 820); + jFrame.setMinimumSize(dimension); + jFrame.setPreferredSize(dimension); + JPanel parentPanel = new JPanel(new PropertyLayout()); + scr2 = new JScrollPane(parentPanel); + scr2.setPreferredSize(new Dimension(640, 690)); + JPanel classJpanel = new JPanel(new PropertyLayout());// Խ + classJpanel.add("1.1.center.top", scr2); + + KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); + jFrame.getRootPane().registerKeyboardAction(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int option = JOptionPane.showOptionDialog(null, "ȷ˳˵", "", 0, 1, null, null, Integer.valueOf(0)); + if (option == 0) { + System.out.println(new Date() + "˳"); + jFrame.dispose(); + } else { + return; + } + } + }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); + + // Żڼ + jFrame.addComponentListener(new ComponentListener() { + @Override + public void componentResized(ComponentEvent e) { + // TODO Auto-generated method stub + Component component2 = e.getComponent(); + int h = component2.getHeight(); + if (h > 800) { + scr2.setPreferredSize(new Dimension(component2.getWidth() - 20, h - 120)); + scr2.revalidate(); + scr2.repaint(); + classJpanel.setPreferredSize(new Dimension(component2.getWidth(), h - 110)); + classJpanel.revalidate(); + classJpanel.repaint(); + } + } + + @Override + public void componentMoved(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void componentShown(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void componentHidden(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + }); + + // endŻ + if (targetComp instanceof TCComponentItemRevision) { + targetRev = (TCComponentItemRevision) targetComp; + + String revType = targetRev.getType(); + try { + tccItem = targetRev.getItem(); + refs = tccItem.whereReferenced(); + getFolder(); + + targetType = targetRev.getItem().getType(); + System.out.println(new Date() + "revType============" + revType); + nameField = new JTextField(18); + parentPanel.add(i + ".1.center.top", new JLabel("")); + i += 1; + if ("RB3_ZCRevision".equals(revType)) { + type = targetRev.getStringProperty("rb3_zclx"); + flag = 1; + } else if ("RB3_LBJRevision".equals(revType)) { + idField = new JTextField(18); + flag = 2; + parentPanel.add(i + ".1.center.top", new JLabel("ܳϱ")); + parentPanel.add(i + ".2.center.top", idField); + i += 1; + type = targetRev.getStringProperty("rb3_lbjlx"); + } else {// ׼ + type = ""; + flag = 3; + } + parentPanel.add(i + ".1.center.top", new JLabel("")); + parentPanel.add(i + ".2.center.top", nameField); + i += 1; + String name = targetRev.getStringProperty("object_name"); + nameField.setText(name); + className = targetRev.getClassificationClass(); + String xmlClassName = ""; + if (flag == 2) {// 㲿 + xmlClassName = className; + JTextField idfield = new JTextField(18); + idList.add(idfield); + JComboBox idbox = new JComboBox(); + idList.add(idbox); + idbox.addItem(" "); + String[] idstrs = new String[99]; + for (int K = 0; K < 99; K++) { + if (K < 9) { + idstrs[K] = "0" + (K + 1); + } else { + idstrs[K] = (K + 1) + ""; + } + } + for (int K = 0; K < idstrs.length; K++) { + idbox.addItem(idstrs[K]); + } + boxMap.put(PlmLocaleUtil.getString("PartNumber"), idbox); + parentPanel.add((i) + ".1.center.top", new JLabel(PlmLocaleUtil.getString("PartNumber"))); + parentPanel.add((i) + ".2.center.top", idfield); + parentPanel.add((i) + ".3.center.top", idbox); + i += 1; + } else if (flag == 1) {// ܳ + xmlClassName = className.substring(0, 6); + ParseXML xml1 = new ParseXML(); + File file3 = xml1.getSXX("RB3_BSHPJFS", session); + attrMap3 = xml1.parseXMLAttr(file3); + if (attrMap3 == null || attrMap3.size() <= 0) { + MessageBox.post("ѡRB3_BSHPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + File file4 = xml1.getSXX("RB3_SMPJFS", session); + attrMap4 = xml1.parseXMLAttr(file4); + if (attrMap4 == null || attrMap4.size() <= 0) { + MessageBox.post("ѡRB3_SMPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + } else if (flag == 3) {// ׼ + xmlClassName = className; + JTextField idfield = new JTextField(18); + idList.add(idfield); + JComboBox idbox = new JComboBox(); + idList.add(idbox); + idbox.addItem(" "); + String[] idstrs = new String[99]; + for (int K = 0; K < 99; K++) { + if (K < 9) { + idstrs[K] = "0" + (K + 1); + } else { + idstrs[K] = (K + 1) + ""; + } + } + for (int K = 0; K < idstrs.length; K++) { + idbox.addItem(idstrs[K]); + } + boxMap.put(PlmLocaleUtil.getString("PartNumber"), idbox); + parentPanel.add((i) + ".1.center.top", new JLabel(PlmLocaleUtil.getString("PartNumber"))); + parentPanel.add((i) + ".2.center.top", idfield); + parentPanel.add((i) + ".3.center.top", idbox); + i += 1; + ParseXML xml1 = new ParseXML(); + File file3 = xml1.getSXX("RB3_BSHPJFS", session); + attrMap3 = xml1.parseXMLAttr(file3); + if (attrMap3 == null || attrMap3.size() <= 0) { + MessageBox.post("ѡRB3_BSHPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + } + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + System.out.println(new Date() + "className===========" + className); + System.out.println(new Date() + "xmlClassName===========" + xmlClassName); + saveCOM2(xmlClassName, attrMap, attrList, esAttrList, markList, defaultValueList, isNList); + saveCOM(xmlClassName, attrMap2, attrList2, esAttrList2, markList2, isNList2); + if (attrMap3 != null) { + saveCOM(xmlClassName, attrMap3, attrList3, esAttrList3, markList3, isNList3); + } + if (attrMap4 != null) { + saveCOM(xmlClassName, attrMap4, attrList4, esAttrList4, markList4, isNList4); + } + TCComponentICO[] icos = targetRev.getClassificationObjects(); + if (icos == null || icos.length <= 0) { + // + MessageBox.post(rb.getString("xzdwlmyfsdfl07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + Map claMap = new HashMap(); + if (icos != null && icos.length > 0) { + ICSProperty[] icss = icos[0].getICSProperties(true); + for (ICSProperty ics : icss) { + claMap.put(ics.getId(), ics.getValue()); + } + } + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(xmlClassName); + String cName = c.getName(); + System.out.println(new Date() + "cName===" + cName); + if (PlmLocaleUtil.getString("BearingAccessories").equals(cName)) { + classFlag = false; + } + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + if (icsAttrS != null) { + for (ICSAdminClassAttribute attr : icsAttrS) { + if (attr.isHidden()) { + continue; + } + ClassAttributeBean bean = new ClassAttributeBean(); + if (attr.isReferenceAttribute()) {// + continue; + } + if (attr.isReference()) { + continue; + } + int propID = attr.getAttributeId(); + bean.setId(propID); + String propDisName = attr.getName(); + bean.setName(propDisName); + System.out.print(new Date() + "propDisName:" + propDisName); + int attrType = attr.getFormat1().getType(); + bean.setType(attrType); + + if (claMap != null && claMap.containsKey(propID)) { + bean.setVal(claMap.get(propID)); + } else { + bean.setVal(""); + } + + ICSKeyLov lov1 = attr.getFormat1().getKeyLov(); + lov1 = (lov1 == null ? attr.getFormat2().getKeyLov() : lov1); + if (lov1 != null) { + bean.setIslov(true); + String[] keys = lov1.getKeys(); + Map map1 = new HashMap(); + for (String key : keys) { + KeyLov lov_key = lov1.getKeyLovOfKey(key); + boolean deprecated = lov_key.isDeprecated(); + if (deprecated) { + if (key.equals(bean.getVal())) { + bean.setVal(""); + } + continue; + } + String value = lov1.getValueOfKey(key); + map1.put(value, key);// <ʾֵ,ʵֵ> + if (key.equals(bean.getVal()) && (!bean.getVal().equals(""))) { + bean.setVal(value); + } + } + bean.setLov(map1); + } else { + bean.setIslov(false); + } + + classList.add(bean); + + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + + String[] revs = service.getStringValues("RB_Revision_id"); + if (revs == null || revs.length <= 0) { + MessageBox.post("ѡRB_Revision_idδ,ϵԱ!!", "", MessageBox.ERROR); + return; + } + + revComb = new JComboBox(); + revComb.addItem("B1"); + // Ż + revComb.setEditable(false); + // end + for (int j = 0; j < revs.length; j++) { + revComb.addItem(revs[j]); + } + + parentPanel.add(i + ".1.center.top", new JLabel("汾")); + parentPanel.add(i + ".2.center.top", revComb); + i += 1; + + labels1 = new JLabel[classList.size()]; + + for (int j = 0; j < classList.size(); j++, i++) { + ClassAttributeBean bean = classList.get(j); + labels1[j] = new JLabel(bean.getName()); + parentPanel.add(i + ".1.center.top", labels1[j]); + labels1[j].setBounds(5, 5, 5, 5); + String attrName = ""; + if ((bean.getName()).contains("\\")) { + attrName = (bean.getName()).split("\\\\")[0]; + System.out.println(new Date() + "attrName=============" + attrName); + } else { + attrName = bean.getName(); + } + if (bean.isIslov()) { + JComboBox comb = new JComboBox(); + // Ż + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + // end + comb.setEditable(false); + comb.setSize(new Dimension(60, 40)); + comb.addItem(bean.getVal()); + for (Entry entry : bean.getLov().entrySet()) { + if (!(bean.getVal().equals(entry.getKey()))) { + comb.addItem(entry.getKey()); + } + } + // Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + System.out.println(new Date() + "" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(comb, tip); + } + } + + }); + // end + map2 = new HashMap(); + map2.put("JComboBox", comb); + values.add(map2); + parentPanel.add(i + ".2.center.top", comb); + parentPanel.add(i + ".3.center.top", jt); + parentPanel.add(i + ".4.center.top", bu); + + if (attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, comb); + lovMap.put(attrName, "yes"); + } + if (attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, comb); + lovMap2.put(attrName, "yes"); + } + if (attrMap3 != null) { + if (attrList3.contains(attrName) || esAttrList3.contains(attrName)) { + objMap3.put(attrName, comb); + lovMap3.put(attrName, "yes"); + } + if (attrList4.contains(attrName) || esAttrList4.contains(attrName)) { + objMap4.put(attrName, comb); + lovMap4.put(attrName, "yes"); + } + } + if ((PlmLocaleUtil.getString("Category")).equals(attrName)) { + typeList.add(comb); + } + if (bean.getName().equals("ͻ") || bean.getName().equals("")) { + khdmlbbbs.put(bean.getName(), comb); + } + if (bean.getName().equals("") || bean.getName().equals("ߴ")) { + gccxdhs.put(bean.getName(), comb); + } + + } else { + JTextField field = new JTextField(18); + + map2 = new HashMap(); + map2.put("JTextField", field); + values.add(map2); + parentPanel.add(i + ".2.center.top", field); + if (bean.getVal() != null && bean.getVal() != "") { + field.setText(bean.getVal()); + } + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName)) { + JComboBox box = new JComboBox(); + // Ż + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + // end + box.addItem(" "); + String[] strs = new String[] { "C0", "C2", "C3", "C4", "C5" }; + for (int K = 0; K < strs.length; K++) { + box.addItem(strs[K]); + } + // Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + System.out.println(new Date() + "" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(comb, tip); + } + } + + }); + // end + boxMap.put(attrName, box); + parentPanel.add((i) + ".3.center.top", box); + parentPanel.add((i) + ".3.center.top", jt); + parentPanel.add((i) + ".3.center.top", bu); + } + if (attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, field); + lovMap.put(attrName, "no"); + } + if (attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, field); + lovMap2.put(attrName, "no"); + } + if (attrMap3 != null) { + if (attrList3.contains(attrName) || esAttrList3.contains(attrName)) { + objMap3.put(attrName, field); + lovMap3.put(attrName, "no"); + } + if (attrList4.contains(attrName) || esAttrList4.contains(attrName)) { + objMap4.put(attrName, field); + lovMap4.put(attrName, "no"); + } + } + if (bean.getName().equals("汾")) { + khdmlbbbs.put(bean.getName(), field); + } + } + + } + + // Ż + if (targetComp instanceof TCComponentItemRevision) { + targetRev = (TCComponentItemRevision) targetComp; + String revType = targetRev.getType(); + try { + zc_lbj_map = targetRev.getProperties(); + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + + System.out.println(new Date() + "汾:" + revType); +// if(revType.equals("RB3_ZCRevision")) { +// System.out.println(revType); +// boflag=true; +// +// }else { +// System.out.println(revType); +// +// } + parentPanel.add(i + ".1.center.top", new JLabel(" ")); + parentPanel.add(i + ".2.center.top", new JLabel("**********************")); + i += 1; + // λ + // λ + parentPanel.add(i + ".1.center.top", new JLabel("λ")); + try { + tagMap.clear(); + dl = new JComboBox(); + dl.setSize(new Dimension(60, 40)); + dl.setName("uom_tag"); + TCProperty zclov1; + TCComponentItem oldItem = targetRev.getItem(); + zclov1 = oldItem.getTCProperty("uom_tag"); + + TCComponentListOfValues zcprolov1 = zclov1.getLOV(); + String[] comboxitems1; + JTextField jt1 = new JTextField(9); + JButton bu1 = new JButton(""); + if (zcprolov1 != null) { + comboxitems1 = zcprolov1.getListOfValues().getLOVDisplayValues(); + TCComponent[] tags = zcprolov1.getListOfValues().getTagListOfValues(); + for (int fl = 0; fl < comboxitems1.length; fl++) { + tagMap.put(comboxitems1[fl], tags[fl]); + } + ComboBoxModel model1 = new DefaultComboBoxModel(comboxitems1); + dl.setModel(model1); + bu1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip1 = jt1.getText(); + System.out.println(new Date() + "" + tip1); + if (tip1.length() > 0) { + SearchJComItem.changeBox(dl, tip1); + } + } + + }); + // comboxList.add(dl); + } + dl.setSelectedItem(oldItem.getProperty("uom_tag")); + // if(!(ZC_LBJ_list.LBJDisPros.get(i)).equals("ʱϱʶ")) { + dl.setSelectedIndex(-1); + parentPanel.add(i + ".2.center.top", dl); + parentPanel.add((i) + ".3.center.top", jt1); + parentPanel.add((i) + ".4.center.top", bu1); + i += 1; + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + // λ + MustMap.put("λ", dl); + + int tt = 0; + System.out.println(new Date() + "ӵԸ:" + realName.size()); + for (int n = 0; n < realName.size(); n++) { + System.out.println( + new Date() + "ѭ" + n + ",ҪӵΪ" + displayName.get(n) + "(" + realName.get(n) + ")"); +// if((Arrays.asList(remove)).contains(ZC_LBJ_list.ZCDisPros.get(n))) { +// tt+=1; +// continue; +// } + if (displayName.get(n).contains("#")) { + parentPanel.add((i + n - tt) + ".1.center.top", + new JLabel(displayName.get(n).substring(0, displayName.get(n).length() - 1))); + } else { + parentPanel.add((i + n - tt) + ".1.center.top", new JLabel(displayName.get(n))); + } + + boolean b = displayName.get(n).contains("#"); + if (b) { + System.out.println(new Date() + "Lov"); + try { + if (realName.get(n).contains("rb3_scgc")) { + String na = realName.get(n); + // System.out.println("Ϊ"); + String[] vals = ((TCComponentItemRevision) targetComp).getTCProperty(na) + .getStringValueArray(); + JComboBox nbox = new RwJComboBox(new String[] { "" }); + nbox.setEditable(true); + TCProperty zclov = ((TCComponentItemRevision) targetComp).getTCProperty(realName.get(n)); + TCComponentListOfValues zcprolov = zclov.getLOV(); + String[] comboxitems; + List disVal = new ArrayList(); + for (int a = 0; a < vals.length; a++) { + if (vals[a] != null && !vals[a].equals("")) { + String disname = zcprolov.getListOfValues().getDisplayableValue(vals[a]); + disVal.add(disname); + } + } + if (zcprolov != null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + // ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + + nbox = new RwJComboBox(comboxitems); + nbox.setEditable(true); + nbox.setName(na); + nbox.setSize(new Dimension(60, 40)); + if (disVal.size() > 0) { + StringBuilder sb = new StringBuilder(); + for (int t = 0; t < disVal.size(); t++) { + if (t != (vals.length - 1)) { + + sb.append(disVal.get(t)); + sb.append(","); + } else { + sb.append(disVal.get(t)); + } + } + JTextField ed = (JTextField) nbox.getEditor().getEditorComponent(); + ed.setText(sb.toString()); + } + comboxList.add(nbox); + } + + parentPanel.add((n + i - tt) + ".2.center.top", nbox); + // +++ + if (displayName.get(n).contains("*")) { + MustMap.put(displayName.get(n).substring(0, displayName.get(n).length() - 1), nbox); + } + + // +++ + } else if (realName.get(n).equals("rb3_yyly")) { + + String realPro = realName.get(n); + + String[] vals_list = targetRev.getTCProperty(realPro).getStringArrayValue(); + ; + strss = vals_list; + JComboBox nbox = new RwJComboBox(new String[] { "" }); + nbox.setEditable(true); + TCProperty zclov = targetRev.getTCProperty(realPro); + TCComponentListOfValues lov = zclov.getLOV(); + String[] vals = new String[vals_list.length]; + for (int u = 0; u < vals_list.length; u++) { + vals[u] = lov.getListOfValues().getDisplayableValue(vals_list[u]); + } + String[] disvals = lov.getListOfValues().getLOVDisplayValues(); + Map dis_real = LovUtils.valOf_real_dis(disvals, lov); + nbox = new RwJComboBox(disvals); + nbox.setEditable(true); + nbox.setSelectedIndex(-1); + RwJComboBox nbox2 = new RwJComboBox(new String[] { "" }); + nbox2.setEditable(true); + + StringBuilder sb = new StringBuilder(); + + if (vals.length > 0) { + for (int a = 0; a < vals.length; a++) { + if (a != vals.length - 1) { + sb.append(vals[a]); + sb.append(","); + } else { + sb.append(vals[a]); + } + } + } + + nbox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + // TODO Auto-generated method stub + RwJComboBox box = (RwJComboBox) e.getSource(); + // Object[] objs = box.getSelectedObjects(); + + System.out.println(new Date() + "nboxitem¼!"); + Set set = box.getSet(); + + int size = set.size(); + // System.out.println("sizeijΪ:"+size); + if (size > 0) { + List lists = new ArrayList(set); + String[] strs = new String[size]; + for (int h = 0; h < lists.size(); h++) { + System.out.println(new Date() + "ѡеΪ:" + (Integer) lists.get(h)); + strs[h] = (String) box.getItemAt((Integer) lists.get(h)); + } +// for(int h=0;h ss = msg.getSs(); + String[] sss = ss.toArray(new String[ss.size()]); + nbox2.removeAllItems(); + // nbox2.getSelectedIndex(); + nbox2.setEditable(true); + nbox2.setModel(new RwDefaultComboBoxModel(sss)); + nbox2.setSet(); + + nbox2.setSelectedIndex(-1); + + } else { + nbox2.removeAllItems(); + nbox2.setEditable(true); + } + } + }); + RwJComboBox nbox3 = new RwJComboBox(new String[] { "" }); + nbox3.setEditable(true); + nbox3.setName(realPro); + JTextField jt = (JTextField) nbox3.getEditor().getEditorComponent(); + if (sb != null) { + yyly_text = sb.toString(); + jt.setText(sb.toString()); + } + nbox2.addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + // TODO Auto-generated method stub + System.out.println(new Date() + "nbox2item¼!"); + RwJComboBox box = (RwJComboBox) e.getSource(); + // Object[] objs = box.getSelectedObjects(); + Set set = box.getSet(); + int size = set.size(); + if (size > 0) { + List lists = new ArrayList(set); + String[] strs = new String[size]; + for (int h = 0; h < lists.size(); h++) { + System.out.println(new Date() + "ѡеΪ:" + (Integer) lists.get(h)); + strs[h] = (String) box.getItemAt((Integer) lists.get(h)); + } + LovUtils.getLovObj2(strs, msg); + System.out.println(new Date() + "ӡmsgϢ:" + msg.toString()); + List sss = msg.getSss(); + String[] vals_strs = sss.toArray(new String[sss.size()]); + nbox3.removeAllItems(); + // nbox2.getSelectedIndex(); + nbox3.setEditable(true); + nbox3.setModel(new RwDefaultComboBoxModel(vals_strs)); + nbox3.setSet(); + nbox3.setSelectedIndex(-1); + } else { + nbox3.removeAllItems(); + nbox3.setEditable(true); + } + } + + }); + + parentPanel.add(n + i - tt + ".2.center.top", nbox); + parentPanel.add(n + i - tt + ".3.center.top", nbox2); + parentPanel.add(n + i - tt + ".4.center.top", nbox3); + comboxList.add(nbox3); + + // +++ + if (displayName.get(n).contains("*")) { + MustMap.put(displayName.get(n).substring(0, displayName.get(n).length() - 1), nbox); + } + + // +++ + + } else { + JComboBox zcBox = new JComboBox(); + zcBox.setSize(new Dimension(60, 40)); + zcBox.setName(realName.get(n)); + TCProperty zclov = ((TCComponentItemRevision) targetComp).getTCProperty(realName.get(n)); + if (zclov == null) { + System.out.println( + new Date() + "ԣ" + displayName.get(n) + "=" + realName.get(n) + "޷lov"); + continue; + } + TCComponentListOfValues zcprolov = zclov.getLOV(); + String[] comboxitems; + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + if (zcprolov != null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + zcBox.setModel(model); + + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + System.out.println(new Date() + "" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(zcBox, tip); + } + } + + }); + + comboxList.add(zcBox); + // +++ + if (displayName.get(n).contains("*")) { + MustMap.put(displayName.get(n).substring(0, displayName.get(n).length() - 1), + zcBox); + } + // +++ + } + + zcBox.setSelectedItem(zc_lbj_map.get(realName.get(n))); + if ((displayName.get(n)).contains("ʱϱʶ")) { + zcBox.setSelectedIndex(-1); + } + parentPanel.add((n + i - tt) + ".2.center.top", zcBox); + parentPanel.add((n + i - tt) + ".3.center.top", jt); + parentPanel.add((n + i - tt) + ".4.center.top", bu); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } else { + JTextField field = new JTextField(18); + field.setName(realName.get(n)); + field.setText(zc_lbj_map.get(realName.get(n))); + parentPanel.add((n + i - tt) + ".2.center.top", field); + fieldList.add(field); + // +++ + if (displayName.get(n).contains("*")) { + MustMap.put(displayName.get(n), field); + } + + // +++ + } + } + + } + + JPanel southPanel = new JPanel(new FlowLayout()); + southPanel.setPreferredSize(new Dimension(250, 80)); + JButton button = new JButton(""); + JButton button1 = new JButton("ȡ"); + + button.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // objList.clear(); + // objList2.clear(); + // lovList.clear(); + // lovList2.clear(); + + // +++жϱ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + System.out.println(new Date() + "============="); + for (String name : MustMap.keySet()) { + System.out.println(new Date() + "ԣ" + name); + if (MustMap.get(name) instanceof JComboBox) { + JComboBox box = (JComboBox) MustMap.get(name); + if (box != null) { + System.out.println(new Date() + "boxݣ" + box.getSelectedItem()); + if (box.getSelectedItem() == null || ((String) box.getSelectedItem()).equals("")) { + // δд + MessageBox.post(name + "," + rb.getString("sxwtx07_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + return; + } + } + } else if (MustMap.get(name) instanceof JTextField) { + JTextField field = (JTextField) MustMap.get(name); + if (field != null) { + System.out.println(new Date() + "boxݣ" + field.getText()); + if (field.getText() == null || ((String) field.getText()).equals("")) { + // δд + MessageBox.post(name + "," + rb.getString("sxwtx07_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + return; + } + } + } + } + System.out.println(new Date() + "========Լ======="); + // +++ + + // TODO Auto-generated method stub + List zcList = null; + String jhID = ""; + + if (classFlag) { + productNumber = splicValue(attrList, esAttrList, objMap, markList, isNList, lovMap); + System.out.println(new Date() + "productNumber============" + productNumber); + drawingNumber = splicValue(attrList2, esAttrList2, objMap2, markList2, isNList2, lovMap2); + + System.out.println(new Date() + "drawingNumber============" + drawingNumber); + if (productNumber == null || drawingNumber == null) { + return; + } + } + TCComponentItemRevision newRev = null; + String newID = ""; + try { + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent(targetType); + if (flag == 2) { + StringBuilder idSb = null; + + idSb = new StringBuilder(idField.getText()); + + String id = ""; + if (idList != null && idList.size() > 0) { + JTextField idField = (JTextField) idList.get(0); + JComboBox idbox = (JComboBox) idList.get(1); + id = idField.getText(); + String boxID = (String) idbox.getSelectedItem(); +// if("".equals(id.trim()) && "".equals(boxID.trim())) { +// MessageBox.post("δд", "ʾ", MessageBox.INFORMATION); +// return; +// } + if ("".equals(id.trim())) { + if (boxID.equals(" ")) { + id = ""; + } else { + id = boxID; + } + + } + + jhID = id; + idSb.append(id); + + } + String typeID = ""; + if (typeList != null && typeList.size() > 0) { + JComboBox idComb = typeList.get(0); + typeID = (String) idComb.getSelectedItem(); + if (typeID.contains(":")) { + typeID = typeID.split(":")[1]; + } else if (typeID.contains("")) { + typeID = typeID.split("")[1]; + } + if ("Ʒ".equals(typeID) || "Finished product".equals(typeID)) { + typeID = ""; + } else if ("".equals(typeID) || "Turning workpiece".equals(typeID)) { + typeID = "C"; + } else if ("ȴ".equals(typeID) || "Heat treatment parts".equals(typeID)) { + typeID = "R"; + } else if ("շ伷".equals(typeID) + || "Cold rolled parts or cold extrusion parts".equals(typeID)) { + typeID = "D"; + } else if ("ͼ".equals(typeID) || "Forge piece".equals(typeID)) { + typeID = "D"; + } + idSb.append(typeID); + } + + newID = idSb.toString(); + String[] keys = new String[] { " ID" }; + String[] values = new String[] { idField.getText() }; + zcList = queryObject(" ID", keys, values); + if (zcList != null) { + if (zcList.size() > 0) { + if (zcList.get(0) instanceof TCComponentItem) { + TCComponentItem zcItem = (TCComponentItem) zcList.get(0); + TCComponentItemRevision zcRev = zcItem.getLatestItemRevision(); + TCProperty tcProperty = zcRev.getTCProperty("release_status_list"); + TCComponent[] targets = tcProperty.getReferenceValueArray(); + if (targets != null && targets.length > 0) { + MessageBox.post("ûйеܳɰ汾󴴽!!", "ʾ", MessageBox.WARNING); + return; + } + if (!classFlag) { + productNumber = zcRev.getStringProperty("rb3_th") + id; + drawingNumber = zcRev.getStringProperty("rb3_th") + id; + System.out.println("productNumber============" + productNumber); + System.out.println("drawingNumber============" + drawingNumber); + } + if ("RB3_ZC".equals(targetType)) { + List compList = queryObject("RBSearchZCCPH", + new String[] { "Ʒ" }, new String[] { productNumber }); + if (compList != null) { + if (compList.size() > 0) { + // Ż + String nID = newID.substring(0, 2); + for (int j = 0; j < compList.size(); j++) { + System.out.println(new Date() + "жitem_idǰλǷͬ"); + String compID = compList.get(j).getProperty("item_id"); + String cID = compID.substring(0, 2); + if (nID.equals(cID)) { + MessageBox.post("ϵͳѴڲƷΪ" + productNumber + "ϣ룡", + "", MessageBox.INFORMATION); + return; + } + } + // endŻ + } + + } + } else if ("RB3_LBJ".equals(targetType)) { + List compList = queryObject("RBSearchLBJCPH", + new String[] { "Ʒ" }, new String[] { productNumber }); + if (compList != null) { + if (compList.size() > 0) { + // Ż + String nID = newID.substring(0, 2); + for (int j = 0; j < compList.size(); j++) { + System.out.println(new Date() + "жitem_idǰλǷͬ"); + String compID = compList.get(j).getProperty("item_id"); + String cID = compID.substring(0, 2); + if (nID.equals(cID)) { + MessageBox.post( + "ϵͳѴڲƷΪ" + productNumber + "ϣ룡", "", + MessageBox.INFORMATION); + return; + } + } + // endŻ + } + } + } + } + } + } else { + MessageBox.post(rb.getString("nstwl11_display.TITLE"), "", MessageBox.INFORMATION); + return; + } + } else { + userservice = session.getUserService(); + // ȡitem_id-----------жidij(1122ͷitem_idijȶ10λXXͷitem_idλ) + String it_id = targetRev.getStringProperty("item_id"); + String flag1 = it_id.substring(0, 2); + + if (flag1.equals("XX")) { + params = new Object[] { targetRev.getStringProperty("item_id").substring(0, 8), 7, 1, 9999, + 1, "" }; + } else { + params = new Object[] { targetRev.getStringProperty("item_id").substring(0, 6), 7, 1, 9999, + 1, "" }; + } + try { + String str = "";// DM,8,400,99999999,1,"" + newID = (String) userservice.call("queryPartNo", params); + + userservice.call("delete_recycleID", new Object[] { newID }); + System.out.println("newID===============" + newID); + } catch (Exception e1) { + e1.printStackTrace(); + } + bsNumber = splicValue(attrList3, esAttrList3, objMap3, markList3, isNList3, lovMap3); + System.out.println(new Date() + "bsNumber============" + bsNumber); + smNumber = splicValue(attrList4, esAttrList4, objMap4, markList4, isNList4, lovMap4); + + System.out.println(new Date() + "smNumber============" + smNumber); + if (bsNumber == null || smNumber == null) { + return; + } + } + String[] keys = new String[] { " ID" }; + String[] values = new String[] { newID }; + List compList = queryObject(" ID", keys, values); +// int retryCount = 0; +// StringBuilder sbTemp = new StringBuilder(); +// for(Object objTemp : params) { +// sbTemp.append(""+objTemp).append("/"); +// +// } +// System.out.println("params="+sbTemp.toString()); +// while (compList != null && compList.size() > 0) { +//// if(retryCount == 10) { +//// MessageBox.post("ϵͳѾȡ10ѴidΪ" + newID + "ϣ룡", "", MessageBox.INFORMATION); +//// return; +//// } +// if (flag != 1) { +// MessageBox.post("ϵͳѴidΪ" + newID + "ϣ룡", "", MessageBox.INFORMATION); +// return; +// } else { +// String newCode = new GetNewCode(params,newID).getCode(); +// +// userservice = session.getUserService(); +// newID = (String) userservice.call("queryPartNo", params); +// userservice.call("delete_recycleID", new Object[] {newID}); +// System.out.println(new Date()+"whileѭɵnewIDΪ:" + newID); +// String[] value = new String[] { newID }; +// compList = queryObject(" ID", keys, value); +// } +//// retryCount ++; +// } + + if (compList != null && compList.size() > 0) { +// if(retryCount == 10) { +// MessageBox.post("ϵͳѾȡ10ѴidΪ" + newID + "ϣ룡", "", MessageBox.INFORMATION); +// return; +// } + if (flag != 1) { + MessageBox.post("ϵͳѴidΪ" + newID + "ϣ룡", "", MessageBox.INFORMATION); + return; + } else { + + newID = new GetNewCode(params, newID).getCode(); + String[] value = new String[] { newID }; + List queryObject = queryObject(" ID", keys, value); + if (queryObject != null && queryObject.size() > 0) { + MessageBox.post("ȡظϵԱ", "", MessageBox.INFORMATION); + return; + } +// userservice = session.getUserService(); +// newID = (String) userservice.call("queryPartNo", params); +// userservice.call("delete_recycleID", new Object[] {newID}); +// System.out.println(new Date()+"whileѭɵnewIDΪ:" + newID); +// String[] value = new String[] { newID }; +// compList = queryObject(" ID", keys, value); + } +// retryCount ++; + } +// if(compList != null) { +// if(compList.size() > 0) { +// +// MessageBox.post("ϵͳѴidΪ"+newID+"ϣ룡", +// "", MessageBox.INFORMATION); +// return; +// } +// //endŻ +// } + + String revID = (String) revComb.getSelectedItem(); + String name = nameField.getText(); + TCComponent uom = null; + String dlval = (String) dl.getSelectedItem(); + if (dlval == null || dlval.equals("")) { + MessageBox.post("λѡ", "", MessageBox.INFORMATION); + return; + } else { + TCComponent tcComponent = tagMap.get(dlval); + uom = tcComponent; + } + TCComponentItem newItem = typeComponent.create(newID, revID, targetType, name, "", uom); + if (newItem != null) { +// session.getUser().getHomeFolder() +// .add("contents", newItem); +// session.getUser().getHomeFolder().refresh(); + folder.add("contents", newItem); + folder.refresh(); + } + String statu = ""; + if ("A1".equals(revID)) { + statu = ":Conceptual design"; + } else if ("B1".equals(revID)) { + statu = ":Product design"; + } else if ("R1".equals(revID)) { + statu = ":Process design/Sample delivery"; + } else if ("P1".equals(revID)) { + statu = "P:Pilot production/small batch"; + } else if ("M1".equals(revID)) { + statu = "M:Mass production"; + } + newRev = newItem.getLatestItemRevision(); + newRev.setStringProperty("rb3_th", drawingNumber); + newRev.setStringProperty("rb3_cph", productNumber); + newRev.setStringProperty("rb3_smzqzt", statu); + if (!("".equals(jhID))) { + newRev.setStringProperty("rb3_jh", jhID); + } + if (!("".equals(bsNumber))) { + newRev.setStringProperty("rb3_bsh", bsNumber); + newRev.setStringProperty("rb3_sm2", smNumber); + } + + // Ż + for (int k = 0; k < fieldList.size(); k++) { + JTextField jt = (JTextField) fieldList.get(k); + String key = jt.getName(); + String val = jt.getText(); + fieldmap.put(key, val); + } + for (int m = 0; m < comboxList.size(); m++) { + JComboBox cbo = (JComboBox) comboxList.get(m); + String key = cbo.getName(); + System.out.println("comboxNameΪ:" + key); + if (key.contains("rb3_scgc")) { + JTextField ed = (JTextField) cbo.getEditor().getEditorComponent(); + String text = ed.getText(); + + if (!text.equals("") && text != null) { + List proList = new ArrayList<>(); + String[] split = text.split(","); + TCProperty tclov = ((TCComponentItemRevision) targetComp).getTCProperty(key); + TCComponentListOfValues lov = tclov.getLOV(); + for (int p = 0; p < split.length; p++) { + String realVal = (String) lov.getListOfValues().getRealValue(split[p]); + proList.add(realVal); + } + Object[] array = proList.toArray(); + String[] svals = new String[array.length]; + for (int s = 0; s < array.length; s++) { + svals[s] = (String) array[s]; + } + newRev.getTCProperty(key).setStringValueArray(svals); + } + } else if (key.equals(yyly)) { + RwJComboBox rjbox = (RwJComboBox) cbo; + Set set = rjbox.getSet(); + int size = set.size(); + if (size > 0) { + List lists = new ArrayList(set); + String[] strs = new String[size]; + Map valMap = msg.getValMap(); + if (valMap != null) { + for (int ob = 0; ob < lists.size(); ob++) { + String itemAt = (String) rjbox.getItemAt((Integer) lists.get(ob)); + String str = valMap.get(itemAt); + strs[ob] = str; + } + newRev.getTCProperty(key).setStringValueArray(strs); + } + + } else { + if (yyly_text != null) { + newRev.getTCProperty(key).setStringValueArray(strss); + } + } + } else { + + String val = (String) cbo.getSelectedItem(); + TCProperty tclov = ((TCComponentItemRevision) targetComp).getTCProperty(key); + TCComponentListOfValues lov = tclov.getLOV(); + String realVal = (String) lov.getListOfValues().getRealValue(val); + System.out.println(new Date() + "ѡеֵΪ:" + val); + comboxmap.put(key, realVal); + } + } + newRev.setProperties(fieldmap); + newRev.setProperties(comboxmap); + // endŻ + + // ͼ + if (newRev.getType().contains("RB3_XZCP")) { + String th = getXZCPTTH(); + System.out.println(new Date() + "RB3_XZCP͵ͼΪ" + th); + newRev.setStringProperty("rb3_th", th); + } else if (newRev.getType().contains("RB3_GNZC") || newRev.getType().contains("RB3_GNLBJ")) { + String glh = getGuNaiGLHao(); + System.out.println(new Date() + "RB3_GNZCRB3_GNLBJ͵ĹΪ" + glh); + newRev.setStringProperty("rb3_glh", getGuNaiGLHao()); + } + + TCTypeService typeService = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) typeService + .getTypeComponent("BOMWindow"); + // һµwindow + TCComponentBOMWindow view = winType.create(null); + if (flag != 1) { + newRev.setStringProperty("rb3_lbjlx", type); + if (zcList != null) { + if (zcList.get(0) instanceof TCComponentItem) { + TCComponentItem zcItem = (TCComponentItem) zcList.get(0); + TCComponentItemRevision zcRev = zcItem.getLatestItemRevision(); + // + view.lock(); + // öbomline + TCComponentBOMLine line = view.setWindowTopLine(zcItem, zcRev, null, null); + // bomline + TCComponentBOMLine childBomline = line.add(newRev.getItem(), newRev, null, false, ""); + // + view.save(); + // + view.unlock(); + // ر + view.close(); + } + } + } else { + List revList = new ArrayList(); + Map RevToQuantity = new HashMap();// +++bomжӦ + Map RevToUom = new HashMap();// +++bomжӦĵλ + // öbomline + TCComponentBOMLine line = view.setWindowTopLine(targetRev.getItem(), targetRev, null, null); + // BOMLINEµbomline + AIFComponentContext[] contexts = line.getChildren(); + for (AIFComponentContext context : contexts) { + InterfaceAIFComponent child = context.getComponent(); + if (child instanceof TCComponentBOMLine) { + TCComponentBOMLine childLine = (TCComponentBOMLine) child; + TCComponentItemRevision itemRevision = childLine.getItemRevision(); + revList.add(itemRevision); + // +++ + RevToQuantity.put(itemRevision, childLine.getStringProperty("bl_quantity")); + RevToUom.put(itemRevision, childLine.getProperty("bl_uom").toString()); + // +++ + } + } + // ر + view.close(); + view = winType.create(null); + // + view.lock(); + // öbomline + TCComponentBOMLine line1 = view.setWindowTopLine(newRev.getItem(), newRev, null, null); + for (TCComponentItemRevision revComp : revList) { + // bomline + TCComponentBOMLine childBomline = line1.add(revComp.getItem(), revComp, null, false, ""); + // +++ + childBomline.setProperty("bl_uom", RevToUom.get(revComp)); + childBomline.setStringProperty("bl_quantity", RevToQuantity.get(revComp)); + // +++ + } + + // + view.save(); + // + view.unlock(); + // ر + view.close(); + newRev.setStringProperty("rb3_zclx", type); + } + TCComponent[] references = targetRev.getReferenceListProperty("TC_Is_Represented_By"); + TCComponent[] referenceListProperty = targetRev.getReferenceListProperty("release_status_list"); + boolean isSaveAs = false; + if (referenceListProperty != null && referenceListProperty.length > 0) { + isSaveAs = true; + } + for (int i = 0; i < references.length; i++) { + if (references[i] instanceof TCComponentItemRevision) { + TCComponentItemRevision pic = (TCComponentItemRevision) references[i]; + TCComponent[] referenceListProperty1 = pic.getReferenceListProperty("release_status_list"); + if ((referenceListProperty1 == null || referenceListProperty1.length == 0) && isSaveAs) { + TCComponentItemRevision saveAs = pic.saveAs(null); + newRev.add("TC_Is_Represented_By", saveAs); + } else { + newRev.add("TC_Is_Represented_By", pic); + } + + } + } + TCComponent[] references3 = targetRev.getReferenceListProperty("TC_Is_Represented_By"); + Object[] obj = new Object[1]; + obj[0] = ""; + try { + TCUtils.openLogByPass(session, "Ϊ"); + userservice.call("Connor_set_bypass", obj); + targetRev.cutOperation("TC_Is_Represented_By", references3); + targetRev.add("TC_Is_Represented_By", references); + } catch (Exception e22) { + e22.printStackTrace(); + } finally { + TCUtils.closeLogByPass(session, "Ϊ"); + userservice.call("Connor_close_bypass", obj); + } + + } catch (Exception e1) { + // TODO Auto-generated catch block + MessageBox.post("ʧ!!!!", "ʾ", MessageBox.INFORMATION); + e1.printStackTrace(); + return; + } + List vals = new ArrayList(); + for (Map value : values) { + for (Map.Entry entry : value.entrySet()) { + String type = entry.getKey(); + if (type.equals("JComboBox")) { + JComboBox comb1 = (JComboBox) entry.getValue(); + String val = (String) comb1.getSelectedItem(); + vals.add(val); + } else { + JTextField field1 = (JTextField) entry.getValue(); + String val = field1.getText(); + vals.add(val); + } + } + } + Integer[] classKeys = new Integer[classList.size()]; + String[] classVals = new String[classList.size()]; + System.out.println(new Date() + "size============================" + classList.size()); + for (int i = 0; i < labels1.length; i++) { + String val = vals.get(i); + if (val == null || val.trim() == "") { + continue; + } + String val2 = ""; + if (classList.get(i).isIslov()) { + val2 = classList.get(i).getLov().get(val);// ʵֵ + System.out.println("val2================" + val2); + System.out.println("val================" + val); + } else { + val2 = val; + } + classKeys[i] = classList.get(i).getId(); + String attrName = classList.get(i).getName(); + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName) + || (PlmLocaleUtil.getString("PartNumber")).equals(attrName)) { + if ("".equals(val2.trim())) { + JComboBox box = boxMap.get(attrName); + val2 = (String) box.getSelectedItem(); + } + } + classVals[i] = val2; + } + + System.out.println(new Date() + ""); + jFrame.dispose(); + System.out.println(new Date() + "̨"); + sendObjToClassficationByWebService(className, newRev, classKeys, classVals);// ͷ + System.out.println(new Date() + "ͽ"); + MessageBox.post("ɹ!!!!", "", MessageBox.INFORMATION); + + // disposeDialog(); + } + + }); + button1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + jFrame.dispose(); + } + + }); + southPanel.add(button); + southPanel.add(button1); + jFrame.add("1.1.center.top", new JLabel(" ")); + jFrame.add("2.1.center.top", classJpanel); + jFrame.add("3.1.center.top", southPanel); + jFrame.pack(); + Dimension dimension1 = Toolkit.getDefaultToolkit().getScreenSize(); + int x = (int) ((dimension1.getWidth() - jFrame.getWidth()) / 2); + int y = (int) ((dimension1.getHeight() - jFrame.getHeight()) / 2); + jFrame.setLocation(x, y); + jFrame.setVisible(true); + + System.out.println(new Date() + "ʼ"); + + } + + private void saveCOM2(String xmlClassName, Map> attrMap, List attrList, + List esAttrList, List markList, List defaultValueList, List isNList) { + if (attrMap.containsKey(xmlClassName)) { + List nameMarkList = attrMap.get(xmlClassName); + String attrNames = nameMarkList.get(0); + String marks = nameMarkList.get(1); + String values = nameMarkList.get(2); + String isN = nameMarkList.get(3); + if (attrNames.contains(";")) { + String[] attrs = attrNames.split(";"); + String[] markss = marks.split(";"); + String[] valuess = values.split(";"); + String[] isNs = isN.split(";"); + for (int i = 0; i < attrs.length; i++) { + if (attrs[i].contains("+")) { + String[] attrss = attrs[i].split("\\+"); + attrList.add(attrss[0]); + esAttrList.add(attrss[1]); + markList.add(markss[i]); + defaultValueList.add(valuess[i]); + isNList.add(isNs[i]); + } + } + } + } + } + + private void saveCOM(String xmlClassName, Map> attrMap, List attrList, + List esAttrList, List markList, List isNList) { + if (attrMap.containsKey(xmlClassName)) { + List nameMarkList = attrMap.get(xmlClassName); + String attrNames = nameMarkList.get(0); + String marks = nameMarkList.get(1); + String isN = nameMarkList.get(3); + if (attrNames.contains(";")) { + String[] attrs = attrNames.split(";"); + String[] markss = marks.split(";"); + String[] isNs = isN.split(";"); + for (int i = 0; i < attrs.length; i++) { + if (attrs[i].contains("+")) { + String[] attrss = attrs[i].split("\\+"); + attrList.add(attrss[0]); + esAttrList.add(attrss[1]); + markList.add(markss[i]); + isNList.add(isNs[i]); + } + } + } + } + } + + /** + * ͷ + */ + public void sendObjToClassficationByWebService(String class_id, TCComponentItemRevision rev, Integer[] keys, + String[] vals) { + try { + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList(); + + for (int i = 0; i < keys.length; i++) { + + if (keys[i] != null && vals[i] != null) { + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + } + // +++9-28 + new Thread() { + @Override + public void run() { + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + }.start(); + // +++9-28 + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * ͨѯѯĿ + * + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + return null; + } + } + + public String splicValue(List attrList, List esAttrList, Map map, + List markList, List isNList, Map lovMap) { + // List asList = Arrays.asList(lovVal); + // List esList = Arrays.asList(esLovVal); + List objList = new ArrayList(); + List lovList = new ArrayList(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < attrList.size(); i++) { + String attr = attrList.get(i); + System.out.println("attr======112" + attr); + String esAttr = esAttrList.get(i); + if (map.get(attr) == null && map.get(esAttr) == null) { + if ((PlmLocaleUtil.getString("PartNumber")).equals(attr) + || (PlmLocaleUtil.getString("PartNumber")).equals(esAttr)) { + JComboBox idbox = boxMap.get(PlmLocaleUtil.getString("PartNumber")); + JTextField idfield = (JTextField) idList.get(0); + String fieldText = idfield.getText(); + String boxText = (String) idbox.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(PlmLocaleUtil.getString("PartNumber") + "ͬʱдֵ", "ʾ", + MessageBox.INFORMATION); + return null; + } +// if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { +// MessageBox.post(PlmLocaleUtil.getString("PartNumber")+"дһֵ", "ʾ", MessageBox.INFORMATION); +// return null; +// } + if (!("".equals(fieldText.trim()))) { + objList.add(idfield); + lovList.add("no"); + } else { + objList.add(idbox); + lovList.add("yes"); + } + continue; + } + objList.add(defaultValueList.get(i)); + lovList.add("string"); + continue; + } + if (!("".equals(attr.trim()))) { + Object obj = map.get(attr); + JComboBox box = null; + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attr)) { + box = boxMap.get(attr); + } + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(esAttr)) { + box = boxMap.get(esAttr); + } + if (obj == null) { + obj = map.get(esAttr); + if (box != null) { + JTextField field = (JTextField) obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(esAttr + "ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(esAttr + "дһֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + } else { + objList.add(box); + lovList.add("yes"); + } + } else { + objList.add(obj); + lovList.add(lovMap.get(esAttr)); + } + } else { + if (box != null) { + JTextField field = (JTextField) obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(attr + "ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(attr + "дһֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + } else { + objList.add(box); + lovList.add("yes"); + } + } else { + objList.add(obj); + lovList.add(lovMap.get(attr)); + } + } + } + } + for (int i = 0; i < objList.size(); i++) { + String attrValue = ""; + Object obj = objList.get(i); + if (obj != null) { + if ("yes".equals(lovList.get(i))) { + String value = (String) ((JComboBox) obj).getSelectedItem(); + if (asList.contains(value) || esList.contains(value)) { + if (isNList.get(i).trim().contains(value)) { + if (value.contains(":")) { + System.out.println("value============" + value); + String[] values = value.split(":"); + value = values[0]; + } else if (value.contains("")) { + System.out.println("value============" + value); + String[] values = value.split(""); + value = values[0]; + } + } else { + value = ""; + } + } else { + if (value.contains(":")) { + System.out.println("value============" + value); + String[] values = value.split(":"); + value = values[0]; + } else if (value.contains("")) { + System.out.println("value============" + value); + String[] values = value.split(""); + value = values[0]; + } + } + if ("Ʒ".equals(value) || "Finished product".equals(value)) { + value = ""; + } else if ("".equals(value) || "Turning workpiece".equals(value)) { + value = "C"; + } else if ("ȴ".equals(value) || "Heat treatment parts".equals(value)) { + value = "R"; + } else if ("շ伷".equals(value) || "Cold rolled parts or cold extrusion parts".equals(value)) { + value = "D"; + } else if ("ͼ".equals(value) || "Forge piece".equals(value)) { + value = "D"; + } + attrValue = value; + } else if ("no".equals(lovList.get(i))) { + attrValue = ((JTextField) obj).getText(); + + } else { + attrValue = (String) obj; + } + if (asList.contains(attrValue) || esList.contains(attrValue)) { + attrValue = ""; + } else { + if (attrValue.contains(":")) { + System.out.println("attrValue============" + attrValue); + String[] values = attrValue.split(":"); + attrValue = values[0]; + } else if (attrValue.contains("")) { + System.out.println("attrValue============" + attrValue); + String[] values = attrValue.split(""); + attrValue = values[0]; + } + } + + String mark = markList.get(i); + System.out.println("mark============" + mark); + if (!("".equals(attrValue.trim())) && mark != null) { + sb.append(mark.trim()); + sb.append(attrValue); + } + } + } + return sb.toString(); + } + + // 2022.3.9Ż:idΪ22XX22ͷ + public String dealItemId(String id) { + String subs = id.substring(0, 2); + if (subs.equals("XX")) { + + String sub = id.substring(2, 4); + if (sub.equals("22")) { + System.out.println("idXX22ͷ!"); + return "XX-"; + } + } else if (subs.equals("22")) { + System.out.println("id22ͷ!"); + return "SF-"; + } + return null; + } + + /** + * ƴӳƷͼͼ + * + * @return + */ + public String getXZCPTTH() { + Object[] obj = new Object[1]; + obj[0] = ""; + userservice = this.session.getUserService(); + String th = ""; + StringBuilder sb = new StringBuilder(); + String gcdhString = ""; + String cxdhString = ""; + try { + TCUtils.openLogByPass(session, "Ϊ"); + userservice.call("Connor_set_bypass", obj); + String ClassID = targetRev.getClassificationClass(); + TCComponentICO[] icos = targetRev.getClassificationObjects();// ȡ + ICSProperty[] icsValues = icos[0].getICSProperties(true);// ȡԵֵ + ICSPropertyDescription[] icsDNames = icos[0].getICSPropertyDescriptors();// ȡԵ + + int index = 0; + for (ICSPropertyDescription icsDName : icsDNames) { + System.out.println("====>ƣ" + icsDName.getName()); + if (icsDName.getName().equals("")) { + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId() == icsDName.getId()) { + gcdhString = getClassDisplayableValue(icsValue.getValue(), icsDName); + if (gcdhString.contains(":")) { + gcdhString = gcdhString.split(":")[0]; + } + if (gccxdhs.containsKey("")) { + if (!((String) ((JComboBox) gccxdhs.get("")).getSelectedItem()).equals("")) { + gcdhString = ((String) ((JComboBox) gccxdhs.get("")).getSelectedItem()) + .split(":")[0]; + } + } + index++; + } + } + } else if (icsDName.getName().equals("ߴ")) { + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId() == icsDName.getId()) { + cxdhString = getClassDisplayableValue(icsValue.getValue(), icsDName); + if (cxdhString.contains(":")) { + cxdhString = cxdhString.split(":")[0]; + } + if (gccxdhs.containsKey("ߴ")) { + if (!((String) ((JComboBox) gccxdhs.get("ߴ")).getSelectedItem()).equals("")) { + cxdhString = ((String) ((JComboBox) gccxdhs.get("ߴ")).getSelectedItem()) + .split(":")[0]; + } + } + index++; + } + } + } + if (index == 2) { + break; + } + } + // ID + if (!gcdhString.equals("")) { + sb.append(gcdhString); + } else { + System.out.println("=======>Żȡʧܣ"); + } + + if (!cxdhString.equals("")) { + sb.append(cxdhString); + } else { + System.out.println("=======>ߴŻȡʧܣ"); + } + System.out.println("ƴӵsb====>" + sb.toString()); + Object[] params = new Object[] { sb.toString(), 4, 1, 9999, 1, "" }; + th = (String) userservice.call("queryPartNo", params); + + userservice.call("delete_recycleID", new Object[] { th }); + + String[] keys = new String[] { " ID" }; + String[] values = new String[] { th }; + List compList = queryObject(" ID", keys, values); + System.out.println("ƴӵth====>" + th); + +// while (compList != null && compList.size() > 0) { +// th = (String) userservice.call("queryPartNo", params); +// userservice.call("delete_recycleID", new Object[] {th}); +// System.out.println("whileѭɵthΪ:" + th); +// String[] value = new String[] { th }; +// compList = queryObject(" ID", keys, value); +// } + if (compList != null && compList.size() > 0) { + th = new GetNewCode(params, th).getCode(); + String[] value = new String[] { th }; + List queryObject = queryObject(" ID", keys, value); + if (queryObject != null && queryObject.size() > 0) { + MessageBox.post("ȡظϵԱ", "", MessageBox.INFORMATION); + return null; + } +// th = (String) userservice.call("queryPartNo", params); +// userservice.call("delete_recycleID", new Object[] {th}); +// System.out.println("whileѭɵthΪ:" + th); +// String[] value = new String[] { th }; +// compList = queryObject(" ID", keys, value); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } finally { + try { + TCUtils.closeLogByPass(session, "Ϊ"); + userservice.call("Connor_close_bypass", obj); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + return th; + + } + + /** + * ɹܳɻ㲿Ĺ + * + * @return + */ + public String getGuNaiGLHao() { + Object[] obj = new Object[1]; + obj[0] = ""; + userservice = this.session.getUserService(); + String glh = "";// Xͻ||-汾| + StringBuilder sb = new StringBuilder(); + sb.append("X"); + String bbsString = ""; + String khdmsString = ""; + String lbString = ""; + try { + TCUtils.openLogByPass(session, "Ϊ"); + userservice.call("Connor_set_bypass", obj); + String ClassID = targetRev.getClassificationClass(); + TCComponentICO[] icos = targetRev.getClassificationObjects();// ȡ + ICSProperty[] icsValues = icos[0].getICSProperties(true);// ȡԵֵ + ICSPropertyDescription[] icsDNames = icos[0].getICSPropertyDescriptors();// ȡԵ + + int index = 0; + for (ICSPropertyDescription icsDName : icsDNames) { + System.out.println("====>ƣ" + icsDName.getName()); + if (icsDName.getName().equals("汾")) { + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId() == icsDName.getId()) { + bbsString = icsValue.getValue(); + if (bbsString.contains(":")) { + bbsString = bbsString.split(":")[0]; + } + if (khdmlbbbs.containsKey("汾")) { + if (!((JTextField) khdmlbbbs.get("汾")).getText().equals("")) { + bbsString = "-" + ((JTextField) khdmlbbbs.get("汾")).getText(); + } + } + index++; + } + } + } else if (icsDName.getName().equals("ͻ")) { + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId() == icsDName.getId()) { + khdmsString = getClassDisplayableValue(icsValue.getValue(), icsDName); + if (khdmsString.contains(":")) { + khdmsString = khdmsString.split(":")[0]; + } + if (khdmlbbbs.containsKey("ͻ")) { + if (!((String) ((JComboBox) khdmlbbbs.get("ͻ")).getSelectedItem()).equals("")) { + khdmsString = ((String) ((JComboBox) khdmlbbbs.get("ͻ")).getSelectedItem()) + .split(":")[0]; + } + } + index++; + } + } + } else if (icsDName.getName().equals("")) { + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId() == icsDName.getId()) { + lbString = getClassDisplayableValue(icsValue.getValue(), icsDName); + if (lbString.contains(":")) { + lbString = lbString.split(":")[0]; + } + if (khdmlbbbs.containsKey("")) { + if (!((String) ((JComboBox) khdmlbbbs.get("")).getSelectedItem()).equals("")) { + lbString = ((String) ((JComboBox) khdmlbbbs.get("")).getSelectedItem()) + .split(":")[0]; + } + } + index++; + } + } + } + if (index == 3) { + break; + } + } + // ID + if (!khdmsString.equals("")) { + sb.append(khdmsString + "|"); + } else { + System.out.println("=======>ͻȡʧܣ"); + } + + if (!lbString.equals("")) { + sb.append(lbString + "|"); + } else { + System.out.println("=======>ȡʧܣ"); + } + + if (!bbsString.equals("")) { + sb.append(bbsString + "|"); + } else { + System.out.println("=======>汾ȡʧܣ"); + } + + Object[] params = new Object[] { sb.toString(), 4, 1, 9999, 1, "" }; + glh = (String) userservice.call("queryPartNo", params); + userservice.call("delete_recycleID", new Object[] { glh }); + System.out.println("ɵglhֵΪ:" + glh); + String[] keys = new String[] { " ID" }; + glh = dealGLH(glh); + + String[] values = new String[] { glh }; + List compList = queryObject(" ID", keys, values); +// while (compList != null && compList.size() > 0) { +// glh = (String) userservice.call("queryPartNo", params); +// userservice.call("delete_recycleID", new Object[] {glh}); +// glh = dealGLH(glh); +// System.out.println("whileѭɵglhΪ:" + glh); +// String[] value = new String[] { glh }; +// compList = queryObject(" ID", keys, value); +// } + if (compList != null && compList.size() > 0) { + glh = new GetNewCode(params, glh).getCode(); + String[] value = new String[] { glh }; + List queryObject = queryObject(" ID", keys, value); + if (queryObject != null && queryObject.size() > 0) { + MessageBox.post("ȡظϵԱ", "", MessageBox.INFORMATION); + return null; + } +// glh = (String) userservice.call("queryPartNo", params); +// userservice.call("delete_recycleID", new Object[] {glh}); +// glh = dealGLH(glh); +// System.out.println("whileѭɵglhΪ:" + glh); +// String[] value = new String[] { glh }; +// compList = queryObject(" ID", keys, value); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } finally { + try { + TCUtils.closeLogByPass(session, "Ϊ"); + userservice.call("Connor_close_bypass", obj); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + return glh; + } + + public String getClassDisplayableValue(String value, ICSPropertyDescription icsD)// icsDƣvalueԵֵΪlovֵͨԾֱֵlovԾֵ + { + String result = ""; + ICSKeyLov lov1 = icsD.getFormat().getKeyLov();// ?ͨƻȡLOV + if (lov1 != null) { + String[] keys = lov1.getKeys();// ȡlovÿţ + for (String key : keys) { + if (value.equals(key))// ?źֵԶӦֱȡֵͿԻȡicsValues[j]ʾֵicsValues[j].getValue()ȡֵ + { + result = lov1.getValueOfKey(key); + return result; + } + } + } + return result; + } + + public String dealGLH(String glh) { + System.out.println("dealGLH"); + String[] split = glh.split("\\|"); + StringBuilder build = new StringBuilder(); + if (split.length > 3) { + build.append(split[0]); + build.append(split[3]); + build.append(split[1]); + build.append(split[2]); + } else { + System.out.println("glhƴ쳣!"); + } + System.out.println("glhֵΪ:" + build.toString()); + return build.toString(); + } + + // ҶӦĸļ + public void getFolder() { + try { + folder = session.getUser().getHomeFolder(); + } catch (TCException e) { + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/rb/plm/rb011/CreatDialog2.java b/src/com/connor/rb/plm/rb011/CreatDialog2.java new file mode 100644 index 0000000..906fbb2 --- /dev/null +++ b/src/com/connor/rb/plm/rb011/CreatDialog2.java @@ -0,0 +1,1169 @@ +package com.connor.rb.plm.rb011; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.ResourceBundle; +import java.util.Set; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.KeyStroke; + +import org.eclipse.swt.browser.WindowEvent; + +import com.connor.rb.plm.newcombox.RwDefaultComboBoxModel; +import com.connor.rb.plm.newcombox.RwJComboBox; +import com.connor.rb.plm.rb012.SearchJComItem; +import com.connor.rb.plm.rb028.LovMsg; +import com.connor.rb.plm.rb028.LovUtils; +import com.connor.rb.plm.util.ClassAttributeBean; +import com.connor.rb.plm.util.ClassProperty; +import com.connor.rb.plm.util.GetNewCode; +import com.connor.rb.plm.util.ParseXML; +import com.connor.rb.plm.util.PlmLocaleUtil; +import com.connor.rb.plm.util.SoaServerUtil; +import com.connor.rb.plm.util.TCUtils; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +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.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSKeyLov.KeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.AbstractDialog; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class CreatDialog2 extends AbstractDialog implements Runnable { + public AbstractAIFApplication app; + public TCSession session; + public TCPreferenceService service; + public List classList = new ArrayList(); + public JLabel[] labels1 = null; + public JComboBox comb = null; + public String className = ""; + public Map map2; + public List> values = new ArrayList>(); + public String type = ""; + public String targetType = ""; + public JScrollPane scr2; + public int flag = 0; + + public TCComponentItemRevision targetRev = null; + public boolean classFlag = true; + public JTextField idField = null; + public JTextField nameField = null; + public JComboBox revComb = null; + public List idList = new ArrayList(); + public List typeList = new ArrayList(); + public String productNumber = ""; + public String drawingNumber = ""; + public Map> attrMap; + public Map> attrMap2; + public Map> attrMap3; + public Map> attrMap4; + public Map> boxMap = new HashMap>(); + public Map objMap = new HashMap(); + public Map objMap2 = new HashMap(); + public Map objMap3 = new HashMap(); + public Map objMap4 = new HashMap(); + public Map lovMap = new HashMap(); + public Map lovMap2 = new HashMap(); + public Map lovMap3 = new HashMap(); + public Map lovMap4 = new HashMap(); + public List defaultValueList = new ArrayList(); + public List isNList = new ArrayList(); + public List isNList2 = new ArrayList(); + public List isNList3 = new ArrayList(); + public List isNList4 = new ArrayList(); + public List markList = new ArrayList(); + public List markList2 = new ArrayList(); + public List markList3 = new ArrayList(); + public List markList4 = new ArrayList(); + public List attrList = new ArrayList(); + public List esAttrList = new ArrayList(); + // private List objList = new ArrayList(); + // private List lovList = new ArrayList(); + public List attrList2 = new ArrayList(); + public List attrList3 = new ArrayList(); + public List attrList4 = new ArrayList(); + public List esAttrList2 = new ArrayList(); + public List esAttrList3 = new ArrayList(); + public List esAttrList4 = new ArrayList(); + + public List asList = new ArrayList(); + public List esList = new ArrayList(); + public InterfaceAIFComponent targetComp; + // Ż + public AIFComponentContext[] refs; + public TCComponentFolder folder; + public TCComponentItem tccItem; + public Map zc_lbj_map = new HashMap<>(); + public List fieldList = new ArrayList<>(); + public List comboxList = new ArrayList(); + public List yylyList = new ArrayList(); + // private int h=4; + // private boolean boflag=false; + public Map fieldmap = new HashMap<>(); + public Map comboxmap = new HashMap<>(); + public String[] strss; + public JComboBox dl = null; + public String yyly_text = null; + public String yyly = "rb3_yyly"; + public String scgc = "rb3_scgc1"; + public LovMsg msg = new LovMsg(); + public Map tagMap = new HashMap(); + public Object[] params; + public TCUserService userservice; + public String[] remove = { "Ʒ", "ͼ", "ʶ", "˵" }; + + public List BZJPros = new ArrayList<>();// ׼ʵ + public List BZJDisPros = new ArrayList<>();// ׼ʾ + public Map khdmlbbbs = new HashMap();;// ͻ롢𡢰汾 + public Map gccxdhs = new HashMap();;// ͻ롢𡢰汾 + + public TCComponentItem item; + public int Count = 0; + + public String comptype = ""; + public List displayName = new ArrayList(); + public List realName = new ArrayList(); +// private JFrame jFrame; + + public Map MustMap = new HashMap();// +++ǩдӽжǷ + // endŻ + // private List objList2 = new ArrayList(); + // private List lovList2 = new ArrayList(); + // private String[] lovVal = new String[] { "ǰ", "׼", "޽Ӵ", "ʽ", + // "ͨ", "A:NBR", "0:", "", "", + // "SN:1805ػ", "ȴ", "", "S:(25% to 35%)", + // "C0","V0","Z0","׼","PC:ﵽC&UƷƾҪ" + // ,"P0:ﵽC&UƷƾҪ","ṹҪƹ","0:˫нǽӴ",":SECC൱",":벿Ŷȷ","BC:35"}; + // private String[] esLovVal = new String[] { "Non", "Standard ball", "Non", + // "Open", "Without vent hole", "A:NBR", + // "0:Black", "Non", "Ball", "SN:1805 temper","Conventional monolithic + // martensite quenching heat treatment", + // "Single", "S:(25% to 35%)", "C0","V0","Z0","Standard","PC:Meet the group C&U + // brand accuracy requirements" + // ,"P0:Meet the group C&U brand accuracy requirements","Other structures need + // to formulate rules","0:Double row angular contact ball bearing" + // ,"Not marked: SECC or equivalent","Other materials: confirm with department + // team for approval","BC:35"}; + + public CreatDialog2(AbstractAIFApplication app, String comptype, List displayName, List realName) { + super(false); + this.app = app; + this.targetComp = app.getTargetComponent(); + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.comptype = comptype; + this.displayName = displayName; + this.realName = realName; + } + + public CreatDialog2(AbstractAIFApplication app, TCComponentItem item) { + super(false); + this.app = app; + this.item = item; + Count = 1; + + } + + @Override + public void run() { + + System.out.println(new Date()+"ʼȡѡ"); + String lovVal = service.getStringValue("RB3_lovVal_default"); + String esLovVal = service.getStringValue("RB3_esLovVal_default"); + if (lovVal.contains(";")) { + String[] vals = lovVal.split(";"); + String[] esVals = esLovVal.split(";"); + for (int i = 0; i < vals.length; i++) { + asList.add(vals[i]); + esList.add(esVals[i]); + } + } + ParseXML xml = new ParseXML(); + File file = xml.getSXX("RB3_CPHPJFS", session); + + attrMap = xml.parseXMLAttr(file); + if (attrMap == null || attrMap.size() <= 0) { + MessageBox.post("ѡRB3_CPHPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + File file2 = xml.getSXX("RB3_THPJFS", session); + attrMap2 = xml.parseXMLAttr(file2); + if (attrMap2 == null || attrMap2.size() <= 0) { + MessageBox.post("ѡRB3_THPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + System.out.println(new Date()+"ʼ"); + System.out.println(new Date()+"ʼʼ"); + +// jFrame = new JFrame(); + this.setTitle("Ϊ"); + int i = 1; + Dimension dimension = new Dimension(); + this.setLayout(new PropertyLayout()); + dimension.setSize(670, 720); + this.setMinimumSize(dimension); + this.setPreferredSize(dimension); + JPanel parentPanel = new JPanel(new PropertyLayout()); + scr2 = new JScrollPane(parentPanel); + scr2.setPreferredSize(new Dimension(640, 590)); + JPanel classJpanel = new JPanel(new PropertyLayout());// Խ + classJpanel.add("1.1.center.top", scr2); + + KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); + this.getRootPane().registerKeyboardAction(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int option = JOptionPane.showOptionDialog(null, "ȷ˳˵", "", 0, 1, null, null, Integer.valueOf(0)); + if (option == 0) { + System.out.println(new Date()+"˳"); + dispose(); + } else { + return; + } + } + }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); + + // Żڼ + this.addComponentListener(new ComponentListener() { + @Override + public void componentResized(ComponentEvent e) { + // TODO Auto-generated method stub + Component component2 = e.getComponent(); + int h = component2.getHeight(); + if (h > 800) { + scr2.setPreferredSize(new Dimension(component2.getWidth() - 20, h - 120)); + scr2.revalidate(); + scr2.repaint(); + classJpanel.setPreferredSize(new Dimension(component2.getWidth(), h - 110)); + classJpanel.revalidate(); + classJpanel.repaint(); + } + } + + @Override + public void componentMoved(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void componentShown(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void componentHidden(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + }); + + // endŻ + if (targetComp instanceof TCComponentItemRevision) { + targetRev = (TCComponentItemRevision) targetComp; + + String revType = targetRev.getType(); + try { + tccItem = targetRev.getItem(); + refs = tccItem.whereReferenced(); + getFolder(); + + targetType = targetRev.getItem().getType(); + System.out.println(new Date()+"revType============" + revType); + nameField = new JTextField(18); + parentPanel.add(i + ".1.center.top", new JLabel("")); + i += 1; + if ("RB3_ZCRevision".equals(revType)) { + type = targetRev.getStringProperty("rb3_zclx"); + flag = 1; + } else if ("RB3_LBJRevision".equals(revType)) { + idField = new JTextField(18); + flag = 2; + parentPanel.add(i + ".1.center.top", new JLabel("ܳϱ")); + parentPanel.add(i + ".2.center.top", idField); + i += 1; + type = targetRev.getStringProperty("rb3_lbjlx"); + } else {// ׼ + type = ""; + flag = 3; + } + parentPanel.add(i + ".1.center.top", new JLabel("")); + parentPanel.add(i + ".2.center.top", nameField); + i += 1; + String name = targetRev.getStringProperty("object_name"); + nameField.setText(name); + className = targetRev.getClassificationClass(); + String xmlClassName = ""; + if (flag == 2) {// 㲿 + xmlClassName = className; + JTextField idfield = new JTextField(18); + idList.add(idfield); + JComboBox idbox = new JComboBox(); + idList.add(idbox); + idbox.addItem(" "); + String[] idstrs = new String[99]; + for (int K = 0; K < 99; K++) { + if (K < 9) { + idstrs[K] = "0" + (K + 1); + } else { + idstrs[K] = (K + 1) + ""; + } + } + for (int K = 0; K < idstrs.length; K++) { + idbox.addItem(idstrs[K]); + } + boxMap.put(PlmLocaleUtil.getString("PartNumber"), idbox); + parentPanel.add((i) + ".1.center.top", new JLabel(PlmLocaleUtil.getString("PartNumber"))); + parentPanel.add((i) + ".2.center.top", idfield); + parentPanel.add((i) + ".3.center.top", idbox); + i += 1; + } else if (flag == 1) {// ܳ + xmlClassName = className.substring(0, 6); + ParseXML xml1 = new ParseXML(); + File file3 = xml1.getSXX("RB3_BSHPJFS", session); + attrMap3 = xml1.parseXMLAttr(file3); + if (attrMap3 == null || attrMap3.size() <= 0) { + MessageBox.post("ѡRB3_BSHPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + File file4 = xml1.getSXX("RB3_SMPJFS", session); + attrMap4 = xml1.parseXMLAttr(file4); + if (attrMap4 == null || attrMap4.size() <= 0) { + MessageBox.post("ѡRB3_SMPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + } else if (flag == 3) {// ׼ + xmlClassName = className; + JTextField idfield = new JTextField(18); + idList.add(idfield); + JComboBox idbox = new JComboBox(); + idList.add(idbox); + idbox.addItem(" "); + String[] idstrs = new String[99]; + for (int K = 0; K < 99; K++) { + if (K < 9) { + idstrs[K] = "0" + (K + 1); + } else { + idstrs[K] = (K + 1) + ""; + } + } + for (int K = 0; K < idstrs.length; K++) { + idbox.addItem(idstrs[K]); + } + boxMap.put(PlmLocaleUtil.getString("PartNumber"), idbox); + parentPanel.add((i) + ".1.center.top", new JLabel(PlmLocaleUtil.getString("PartNumber"))); + parentPanel.add((i) + ".2.center.top", idfield); + parentPanel.add((i) + ".3.center.top", idbox); + i += 1; + ParseXML xml1 = new ParseXML(); + File file3 = xml1.getSXX("RB3_BSHPJFS", session); + attrMap3 = xml1.parseXMLAttr(file3); + if (attrMap3 == null || attrMap3.size() <= 0) { + MessageBox.post("ѡRB3_BSHPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + } + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + System.out.println(new Date()+"className===========" + className); + System.out.println(new Date()+"xmlClassName===========" + xmlClassName); + saveCOM2(xmlClassName, attrMap, attrList, esAttrList, markList, defaultValueList, isNList); + saveCOM(xmlClassName, attrMap2, attrList2, esAttrList2, markList2, isNList2); + if (attrMap3 != null) { + saveCOM(xmlClassName, attrMap3, attrList3, esAttrList3, markList3, isNList3); + } + if (attrMap4 != null) { + saveCOM(xmlClassName, attrMap4, attrList4, esAttrList4, markList4, isNList4); + } + TCComponentICO[] icos = targetRev.getClassificationObjects(); + if (icos == null || icos.length <= 0) { + // + MessageBox.post(rb.getString("xzdwlmyfsdfl07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + Map claMap = new HashMap(); + if (icos != null && icos.length > 0) { + ICSProperty[] icss = icos[0].getICSProperties(true); + for (ICSProperty ics : icss) { + claMap.put(ics.getId(), ics.getValue()); + } + } + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(xmlClassName); + String cName = c.getName(); + System.out.println(new Date()+"cName===" + cName); + if (PlmLocaleUtil.getString("BearingAccessories").equals(cName)) { + classFlag = false; + } + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + if (icsAttrS != null) { + for (ICSAdminClassAttribute attr : icsAttrS) { + if (attr.isHidden()) { + continue; + } + ClassAttributeBean bean = new ClassAttributeBean(); + if (attr.isReferenceAttribute()) {// + continue; + } + if (attr.isReference()) { + continue; + } + int propID = attr.getAttributeId(); + bean.setId(propID); + String propDisName = attr.getName(); + bean.setName(propDisName); + System.out.print(new Date()+"propDisName:" + propDisName); + int attrType = attr.getFormat1().getType(); + bean.setType(attrType); + + if (claMap != null && claMap.containsKey(propID)) { + bean.setVal(claMap.get(propID)); + } else { + bean.setVal(""); + } + + ICSKeyLov lov1 = attr.getFormat1().getKeyLov(); + lov1 = (lov1 == null ? attr.getFormat2().getKeyLov() : lov1); + if (lov1 != null) { + bean.setIslov(true); + String[] keys = lov1.getKeys(); + Map map1 = new HashMap(); + for (String key : keys) { + KeyLov lov_key = lov1.getKeyLovOfKey(key); + boolean deprecated = lov_key.isDeprecated(); + if (deprecated) { + if (key.equals(bean.getVal())) { + bean.setVal(""); + } + continue; + } + String value = lov1.getValueOfKey(key); + map1.put(value, key);// <ʾֵ,ʵֵ> + if (key.equals(bean.getVal()) && (!bean.getVal().equals(""))) { + bean.setVal(value); + } + } + bean.setLov(map1); + } else { + bean.setIslov(false); + } + + classList.add(bean); + + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + + String[] revs = service.getStringValues("RB_Revision_id"); + if (revs == null || revs.length <= 0) { + MessageBox.post("ѡRB_Revision_idδ,ϵԱ!!", "", MessageBox.ERROR); + return; + } + + revComb = new JComboBox(); + revComb.addItem("B1"); + // Ż + revComb.setEditable(false); + // end + for (int j = 0; j < revs.length; j++) { + revComb.addItem(revs[j]); + } + + parentPanel.add(i + ".1.center.top", new JLabel("汾")); + parentPanel.add(i + ".2.center.top", revComb); + i += 1; + + labels1 = new JLabel[classList.size()]; + + for (int j = 0; j < classList.size(); j++, i++) { + ClassAttributeBean bean = classList.get(j); + labels1[j] = new JLabel(bean.getName()); + parentPanel.add(i + ".1.center.top", labels1[j]); + labels1[j].setBounds(5, 5, 5, 5); + String attrName = ""; + if ((bean.getName()).contains("\\")) { + attrName = (bean.getName()).split("\\\\")[0]; + System.out.println(new Date()+"attrName=============" + attrName); + } else { + attrName = bean.getName(); + } + if (bean.isIslov()) { + JComboBox comb = new JComboBox(); + // Ż + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + // end + comb.setEditable(false); + comb.setSize(new Dimension(60, 40)); + comb.addItem(bean.getVal()); + for (Entry entry : bean.getLov().entrySet()) { + if (!(bean.getVal().equals(entry.getKey()))) { + comb.addItem(entry.getKey()); + } + } + // Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + System.out.println(new Date()+"" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(comb, tip); + } + } + + }); + // end + map2 = new HashMap(); + map2.put("JComboBox", comb); + values.add(map2); + parentPanel.add(i + ".2.center.top", comb); + parentPanel.add(i + ".3.center.top", jt); + parentPanel.add(i + ".4.center.top", bu); + + if (attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, comb); + lovMap.put(attrName, "yes"); + } + if (attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, comb); + lovMap2.put(attrName, "yes"); + } + if (attrMap3 != null) { + if (attrList3.contains(attrName) || esAttrList3.contains(attrName)) { + objMap3.put(attrName, comb); + lovMap3.put(attrName, "yes"); + } + if (attrList4.contains(attrName) || esAttrList4.contains(attrName)) { + objMap4.put(attrName, comb); + lovMap4.put(attrName, "yes"); + } + } + if ((PlmLocaleUtil.getString("Category")).equals(attrName)) { + typeList.add(comb); + } + if (bean.getName().equals("ͻ") || bean.getName().equals("")) { + khdmlbbbs.put(bean.getName(), comb); + } + if (bean.getName().equals("") || bean.getName().equals("ߴ")) { + gccxdhs.put(bean.getName(), comb); + } + + } else { + JTextField field = new JTextField(18); + + map2 = new HashMap(); + map2.put("JTextField", field); + values.add(map2); + parentPanel.add(i + ".2.center.top", field); + if (bean.getVal() != null && bean.getVal() != "") { + field.setText(bean.getVal()); + } + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName)) { + JComboBox box = new JComboBox(); + // Ż + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + // end + box.addItem(" "); + String[] strs = new String[] { "C0", "C2", "C3", "C4", "C5" }; + for (int K = 0; K < strs.length; K++) { + box.addItem(strs[K]); + } + // Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + System.out.println(new Date()+"" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(comb, tip); + } + } + + }); + // end + boxMap.put(attrName, box); + parentPanel.add((i) + ".3.center.top", box); + parentPanel.add((i) + ".3.center.top", jt); + parentPanel.add((i) + ".3.center.top", bu); + } + if (attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, field); + lovMap.put(attrName, "no"); + } + if (attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, field); + lovMap2.put(attrName, "no"); + } + if (attrMap3 != null) { + if (attrList3.contains(attrName) || esAttrList3.contains(attrName)) { + objMap3.put(attrName, field); + lovMap3.put(attrName, "no"); + } + if (attrList4.contains(attrName) || esAttrList4.contains(attrName)) { + objMap4.put(attrName, field); + lovMap4.put(attrName, "no"); + } + } + if (bean.getName().equals("汾")) { + khdmlbbbs.put(bean.getName(), field); + } + } + + } + + // Ż + if (targetComp instanceof TCComponentItemRevision) { + targetRev = (TCComponentItemRevision) targetComp; + String revType = targetRev.getType(); + try { + zc_lbj_map = targetRev.getProperties(); + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + + System.out.println(new Date()+"汾:" + revType); +// if(revType.equals("RB3_ZCRevision")) { +// System.out.println(revType); +// boflag=true; +// +// }else { +// System.out.println(revType); +// +// } + parentPanel.add(i + ".1.center.top", new JLabel(" ")); + parentPanel.add(i + ".2.center.top", new JLabel("**********************")); + i += 1; + // λ + // λ + parentPanel.add(i + ".1.center.top", new JLabel("λ")); + try { + tagMap.clear(); + dl = new JComboBox(); + dl.setSize(new Dimension(60, 40)); + dl.setName("uom_tag"); + TCProperty zclov1; + TCComponentItem oldItem = targetRev.getItem(); + zclov1 = oldItem.getTCProperty("uom_tag"); + + TCComponentListOfValues zcprolov1 = zclov1.getLOV(); + String[] comboxitems1; + JTextField jt1 = new JTextField(9); + JButton bu1 = new JButton(""); + if (zcprolov1 != null) { + comboxitems1 = zcprolov1.getListOfValues().getLOVDisplayValues(); + TCComponent[] tags = zcprolov1.getListOfValues().getTagListOfValues(); + for (int fl = 0; fl < comboxitems1.length; fl++) { + tagMap.put(comboxitems1[fl], tags[fl]); + } + ComboBoxModel model1 = new DefaultComboBoxModel(comboxitems1); + dl.setModel(model1); + bu1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip1 = jt1.getText(); + System.out.println(new Date()+"" + tip1); + if (tip1.length() > 0) { + SearchJComItem.changeBox(dl, tip1); + } + } + + }); + // comboxList.add(dl); + } + dl.setSelectedItem(oldItem.getProperty("uom_tag")); + // if(!(ZC_LBJ_list.LBJDisPros.get(i)).equals("ʱϱʶ")) { + dl.setSelectedIndex(-1); + parentPanel.add(i + ".2.center.top", dl); + parentPanel.add((i) + ".3.center.top", jt1); + parentPanel.add((i) + ".4.center.top", bu1); + i += 1; + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + // λ + MustMap.put("λ", dl); + + int tt = 0; + System.out.println(new Date()+"ӵԸ:" + realName.size()); + for (int n = 0; n < realName.size(); n++) { + System.out.println(new Date()+"ѭ" + n + ",ҪӵΪ" + displayName.get(n) + "(" + realName.get(n) + ")"); +// if((Arrays.asList(remove)).contains(ZC_LBJ_list.ZCDisPros.get(n))) { +// tt+=1; +// continue; +// } + if (displayName.get(n).contains("#")) { + parentPanel.add((i + n - tt) + ".1.center.top", + new JLabel(displayName.get(n).substring(0, displayName.get(n).length() - 1))); + } else { + parentPanel.add((i + n - tt) + ".1.center.top", new JLabel(displayName.get(n))); + } + + boolean b = displayName.get(n).contains("#"); + if (b) { + System.out.println(new Date()+"Lov"); + try { + if (realName.get(n).contains("rb3_scgc")) { + String na = realName.get(n); + // System.out.println("Ϊ"); + String[] vals = ((TCComponentItemRevision) targetComp).getTCProperty(na) + .getStringValueArray(); + JComboBox nbox = new RwJComboBox(new String[] { "" }); + nbox.setEditable(true); + TCProperty zclov = ((TCComponentItemRevision) targetComp).getTCProperty(realName.get(n)); + TCComponentListOfValues zcprolov = zclov.getLOV(); + String[] comboxitems; + List disVal = new ArrayList(); + for (int a = 0; a < vals.length; a++) { + if (vals[a] != null && !vals[a].equals("")) { + String disname = zcprolov.getListOfValues().getDisplayableValue(vals[a]); + disVal.add(disname); + } + } + if (zcprolov != null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + // ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + + nbox = new RwJComboBox(comboxitems); + nbox.setEditable(true); + nbox.setName(na); + nbox.setSize(new Dimension(60, 40)); + if (disVal.size() > 0) { + StringBuilder sb = new StringBuilder(); + for (int t = 0; t < disVal.size(); t++) { + if (t != (vals.length - 1)) { + + sb.append(disVal.get(t)); + sb.append(","); + } else { + sb.append(disVal.get(t)); + } + } + JTextField ed = (JTextField) nbox.getEditor().getEditorComponent(); + ed.setText(sb.toString()); + } + comboxList.add(nbox); + } + + parentPanel.add((n + i - tt) + ".2.center.top", nbox); + // +++ + if (displayName.get(n).contains("*")) { + MustMap.put(displayName.get(n).substring(0, displayName.get(n).length() - 1), nbox); + } + + // +++ + } else if (realName.get(n).equals("rb3_yyly")) { + + String realPro = realName.get(n); + + String[] vals_list = targetRev.getTCProperty(realPro).getStringArrayValue(); + ; + strss = vals_list; + JComboBox nbox = new RwJComboBox(new String[] { "" }); + nbox.setEditable(true); + TCProperty zclov = targetRev.getTCProperty(realPro); + TCComponentListOfValues lov = zclov.getLOV(); + String[] vals = new String[vals_list.length]; + for (int u = 0; u < vals_list.length; u++) { + vals[u] = lov.getListOfValues().getDisplayableValue(vals_list[u]); + } + String[] disvals = lov.getListOfValues().getLOVDisplayValues(); + Map dis_real = LovUtils.valOf_real_dis(disvals, lov); + nbox = new RwJComboBox(disvals); + nbox.setEditable(true); + nbox.setSelectedIndex(-1); + RwJComboBox nbox2 = new RwJComboBox(new String[] { "" }); + nbox2.setEditable(true); + + StringBuilder sb = new StringBuilder(); + + if (vals.length > 0) { + for (int a = 0; a < vals.length; a++) { + if (a != vals.length - 1) { + sb.append(vals[a]); + sb.append(","); + } else { + sb.append(vals[a]); + } + } + } + + nbox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + // TODO Auto-generated method stub + RwJComboBox box = (RwJComboBox) e.getSource(); + // Object[] objs = box.getSelectedObjects(); + + System.out.println(new Date()+"nboxitem¼!"); + Set set = box.getSet(); + + int size = set.size(); + // System.out.println("sizeijΪ:"+size); + if (size > 0) { + List lists = new ArrayList(set); + String[] strs = new String[size]; + for (int h = 0; h < lists.size(); h++) { + System.out.println(new Date()+"ѡеΪ:" + (Integer) lists.get(h)); + strs[h] = (String) box.getItemAt((Integer) lists.get(h)); + } +// for(int h=0;h ss = msg.getSs(); + String[] sss = ss.toArray(new String[ss.size()]); + nbox2.removeAllItems(); + // nbox2.getSelectedIndex(); + nbox2.setEditable(true); + nbox2.setModel(new RwDefaultComboBoxModel(sss)); + nbox2.setSet(); + + nbox2.setSelectedIndex(-1); + + } else { + nbox2.removeAllItems(); + nbox2.setEditable(true); + } + } + }); + RwJComboBox nbox3 = new RwJComboBox(new String[] { "" }); + nbox3.setEditable(true); + nbox3.setName(realPro); + JTextField jt = (JTextField) nbox3.getEditor().getEditorComponent(); + if (sb != null) { + yyly_text = sb.toString(); + jt.setText(sb.toString()); + } + nbox2.addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + // TODO Auto-generated method stub + System.out.println(new Date()+"nbox2item¼!"); + RwJComboBox box = (RwJComboBox) e.getSource(); + // Object[] objs = box.getSelectedObjects(); + Set set = box.getSet(); + int size = set.size(); + if (size > 0) { + List lists = new ArrayList(set); + String[] strs = new String[size]; + for (int h = 0; h < lists.size(); h++) { + System.out.println(new Date()+"ѡеΪ:" + (Integer) lists.get(h)); + strs[h] = (String) box.getItemAt((Integer) lists.get(h)); + } + LovUtils.getLovObj2(strs, msg); + System.out.println(new Date()+"ӡmsgϢ:" + msg.toString()); + List sss = msg.getSss(); + String[] vals_strs = sss.toArray(new String[sss.size()]); + nbox3.removeAllItems(); + // nbox2.getSelectedIndex(); + nbox3.setEditable(true); + nbox3.setModel(new RwDefaultComboBoxModel(vals_strs)); + nbox3.setSet(); + nbox3.setSelectedIndex(-1); + } else { + nbox3.removeAllItems(); + nbox3.setEditable(true); + } + } + + }); + + parentPanel.add(n + i - tt + ".2.center.top", nbox); + parentPanel.add(n + i - tt + ".3.center.top", nbox2); + parentPanel.add(n + i - tt + ".4.center.top", nbox3); + comboxList.add(nbox3); + + // +++ + if (displayName.get(n).contains("*")) { + MustMap.put(displayName.get(n).substring(0, displayName.get(n).length() - 1), nbox); + } + + // +++ + + } else { + JComboBox zcBox = new JComboBox(); + zcBox.setSize(new Dimension(60, 40)); + zcBox.setName(realName.get(n)); + TCProperty zclov = ((TCComponentItemRevision) targetComp).getTCProperty(realName.get(n)); + if (zclov == null) { + System.out.println(new Date()+"ԣ" + displayName.get(n) + "=" + realName.get(n) + "޷lov"); + continue; + } + TCComponentListOfValues zcprolov = zclov.getLOV(); + String[] comboxitems; + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + if (zcprolov != null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + zcBox.setModel(model); + + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + System.out.println(new Date()+"" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(zcBox, tip); + } + } + + }); + + comboxList.add(zcBox); + // +++ + if (displayName.get(n).contains("*")) { + MustMap.put(displayName.get(n).substring(0, displayName.get(n).length() - 1), + zcBox); + } + // +++ + } + + zcBox.setSelectedItem(zc_lbj_map.get(realName.get(n))); + if ((displayName.get(n)).contains("ʱϱʶ")) { + zcBox.setSelectedIndex(-1); + } + parentPanel.add((n + i - tt) + ".2.center.top", zcBox); + parentPanel.add((n + i - tt) + ".3.center.top", jt); + parentPanel.add((n + i - tt) + ".4.center.top", bu); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } else { + JTextField field = new JTextField(18); + field.setName(realName.get(n)); + field.setText(zc_lbj_map.get(realName.get(n))); + parentPanel.add((n + i - tt) + ".2.center.top", field); + fieldList.add(field); + // +++ + if (displayName.get(n).contains("*")) { + MustMap.put(displayName.get(n), field); + } + + // +++ + } + } + + } + + JPanel southPanel = new JPanel(new FlowLayout()); + southPanel.setPreferredSize(new Dimension(250, 80)); + JButton button = new JButton(""); + JButton button1 = new JButton("ȡ"); + + button.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // + // +++жϱ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + System.out.println(new Date()+"============="); + for (String name : MustMap.keySet()) { + System.out.println(new Date()+"ԣ" + name); + if (MustMap.get(name) instanceof JComboBox) { + JComboBox box = (JComboBox) MustMap.get(name); + if (box != null) { + System.out.println(new Date()+"boxݣ" + box.getSelectedItem()); + if (box.getSelectedItem() == null || ((String) box.getSelectedItem()).equals("")) { + // δд + MessageBox.post(name + "," + rb.getString("sxwtx07_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + return; + } + } + } else if (MustMap.get(name) instanceof JTextField) { + JTextField field = (JTextField) MustMap.get(name); + if (field != null) { + System.out.println(new Date()+"boxݣ" + field.getText()); + if (field.getText() == null || ((String) field.getText()).equals("")) { + // δд + MessageBox.post(name + "," + rb.getString("sxwtx07_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + return; + } + } + } + } + String dlval = (String) dl.getSelectedItem(); + if (dlval == null || dlval.equals("")) { + MessageBox.post("λѡ", "", MessageBox.INFORMATION); + return; + } + System.out.println(new Date()+"========Լ======="); + dispose(); + session.queueOperation(new Createoperation(session,targetRev,khdmlbbbs,gccxdhs,boxMap, + idList,defaultValueList,asList,esList,classFlag,attrList,esAttrList,objMap,markList, + isNList,lovMap,attrList2,esAttrList2,objMap2,markList2,isNList2,lovMap2,targetType,flag, + idField,typeList,params,attrList3,esAttrList3,objMap3,markList3,isNList3,lovMap3,attrList4, + esAttrList4,objMap4,markList4,isNList4,lovMap4,revComb,nameField,dl,tagMap,folder,fieldList, + fieldmap,comboxList,targetComp,yyly,msg,yyly_text,strss,comboxmap,type,values,classList, + labels1,className)); + + } + + }); + button1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dispose(); + } + + }); + southPanel.add(button); + southPanel.add(button1); + this.add("1.1.center.top", new JLabel(" ")); + this.add("2.1.center.top", classJpanel); + this.add("3.1.center.top", southPanel); + this.pack(); + Dimension dimension1 = Toolkit.getDefaultToolkit().getScreenSize(); + int x = (int) ((dimension1.getWidth() - this.getWidth()) / 2); + int y = (int) ((dimension1.getHeight() - this.getHeight()) / 2); + this.setLocation(x, y); + this.setVisible(true); + this.setDefaultCloseOperation(2); + System.out.println(new Date()+"ʼ"); + + } + private void saveCOM2(String xmlClassName, Map> attrMap, List attrList, + List esAttrList, List markList, List defaultValueList, List isNList) { + if (attrMap.containsKey(xmlClassName)) { + List nameMarkList = attrMap.get(xmlClassName); + String attrNames = nameMarkList.get(0); + String marks = nameMarkList.get(1); + String values = nameMarkList.get(2); + String isN = nameMarkList.get(3); + if (attrNames.contains(";")) { + String[] attrs = attrNames.split(";"); + String[] markss = marks.split(";"); + String[] valuess = values.split(";"); + String[] isNs = isN.split(";"); + for (int i = 0; i < attrs.length; i++) { + if (attrs[i].contains("+")) { + String[] attrss = attrs[i].split("\\+"); + attrList.add(attrss[0]); + esAttrList.add(attrss[1]); + markList.add(markss[i]); + defaultValueList.add(valuess[i]); + isNList.add(isNs[i]); + } + } + } + } + } + + private void saveCOM(String xmlClassName, Map> attrMap, List attrList, + List esAttrList, List markList, List isNList) { + if (attrMap.containsKey(xmlClassName)) { + List nameMarkList = attrMap.get(xmlClassName); + String attrNames = nameMarkList.get(0); + String marks = nameMarkList.get(1); + String isN = nameMarkList.get(3); + if (attrNames.contains(";")) { + String[] attrs = attrNames.split(";"); + String[] markss = marks.split(";"); + String[] isNs = isN.split(";"); + for (int i = 0; i < attrs.length; i++) { + if (attrs[i].contains("+")) { + String[] attrss = attrs[i].split("\\+"); + attrList.add(attrss[0]); + esAttrList.add(attrss[1]); + markList.add(markss[i]); + isNList.add(isNs[i]); + } + } + } + } + } + + + // ҶӦĸļ + public void getFolder() { + try { + folder = session.getUser().getHomeFolder(); + } catch (TCException e) { + e.printStackTrace(); + } + } +} diff --git a/src/com/connor/rb/plm/rb011/CreateHandler.java b/src/com/connor/rb/plm/rb011/CreateHandler.java new file mode 100644 index 0000000..d056ed5 --- /dev/null +++ b/src/com/connor/rb/plm/rb011/CreateHandler.java @@ -0,0 +1,70 @@ +package com.connor.rb.plm.rb011; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +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.AbstractAIFSession; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CreateHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + TCSession session = (TCSession)app.getSession(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (targetComponent instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) targetComponent; + System.out.println("rev.getType()=====" + rev.getType()); + TCPreferenceService service = ((TCSession) app.getSession()).getPreferenceService(); + String[] strs = service.getStringValues("RB3_SaveMaterials_type"); + + String type = ""; + List displayName = new ArrayList(); + List realName = new ArrayList(); + for (String str : strs) { + if (str.contains(rev.getType()) && str.contains(":")) { + type = str.split(":")[0]; + for (String value : str.split(":")[1].split(";")) { + displayName.add(value.split("=")[0]); + realName.add(value.split("=")[1]); + } + break; + } + } + if (!type.equals("")) { + System.out.println("type===>" + type); + System.out.println("displayName===>" + displayName); + System.out.println("realName===>" + realName); +// CreatDialog dialog = new CreatDialog(app, type, displayName, realName); +// session.queueOperation(dialog); + CreatDialog2 dialog = new CreatDialog2(app, type, displayName, realName); + + new Thread(dialog).start(); + } else { + MessageBox.post(rb.getString("qxzypzddxcj11_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return null; + } + } else { + MessageBox.post(rb.getString("qxzbbdx07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return null; + } + + return null; + } + +} diff --git a/src/com/connor/rb/plm/rb011/Createoperation.java b/src/com/connor/rb/plm/rb011/Createoperation.java new file mode 100644 index 0000000..7d7a3c6 --- /dev/null +++ b/src/com/connor/rb/plm/rb011/Createoperation.java @@ -0,0 +1,1258 @@ +package com.connor.rb.plm.rb011; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.Set; + +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JProgressBar; +import javax.swing.JTextField; +import javax.swing.plaf.metal.MetalProgressBarUI; + +import com.connor.rb.plm.newcombox.RwJComboBox; +import com.connor.rb.plm.rb028.LovMsg; +import com.connor.rb.plm.util.ClassAttributeBean; +import com.connor.rb.plm.util.ClassProperty; +import com.connor.rb.plm.util.GetNewCode; +import com.connor.rb.plm.util.PlmLocaleUtil; +import com.connor.rb.plm.util.SoaServerUtil; +import com.connor.rb.plm.util.TCUtils; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.services.loose.core.DataManagementService; +import com.teamcenter.services.loose.core._2006_03.DataManagement; + +public class Createoperation extends AbstractAIFOperation { + public TCSession session; + public TCComponentItemRevision targetRev; + public Map khdmlbbbs; + public TCUserService userservice; + public Map gccxdhs; + public Map> boxMap; + public List idList; + public List defaultValueList; + public List asList; + public List esList; + public String url = ""; + public boolean classFlag; + public String productNumber = ""; + public String drawingNumber = ""; + public static String bsNumber = ""; + public static String smNumber = ""; + public List attrList; + public List esAttrList; + public Map objMap; + public List markList; + public List isNList; + Map lovMap; + public List attrList2; + public List esAttrList2; + public Map objMap2; + public List markList2; + public List isNList2; + public Map lovMap2; + public String targetType; + public int flag; + public JTextField idField; + public List typeList; + public Object[] params; + public List attrList3; + public List esAttrList3; + public Map objMap3; + public List markList3; + public List isNList3; + Map lovMap3; + public List attrList4; + public List esAttrList4; + public Map objMap4; + public List markList4; + public List isNList4; + public Map lovMap4; + public JComboBox revComb; + public JTextField nameField; + public JComboBox dl; + public Map tagMap; + public TCComponentFolder folder; + public List fieldList; + public Map fieldmap; + public List comboxList; + public InterfaceAIFComponent targetComp; + public String yyly; + public LovMsg msg; + public String yyly_text; + public String[] strss; + public Map comboxmap; + public String type; + public List> values; + public List classList; + public JLabel[] labels1; + public String className; + private JFrame frame = new JFrame("...");// + private JProgressBar progressBar = new JProgressBar() { + public void setValue(int n) { + super.setValue(n); + System.out.println("ǰȣ" + n); + }; + };// + + public Createoperation(TCSession session, TCComponentItemRevision targetRev, Map khdmlbbbs, + Map gccxdhs, Map> boxMap, List idList, + List defaultValueList, List asList, List esList, boolean classFlag, + List attrList, List esAttrList, Map objMap, List markList, + List isNList, Map lovMap, List attrList2, List esAttrList2, + Map objMap2, List markList2, List isNList2, Map lovMap2, + String targetType, int flag, JTextField idField, List typeList, Object[] params, + List attrList3, List esAttrList3, Map objMap3, List markList3, + List isNList3, Map lovMap3, List attrList4, List esAttrList4, + Map objMap4, List markList4, List isNList4, Map lovMap4, + JComboBox revComb, JTextField nameField, JComboBox dl, Map tagMap, + TCComponentFolder folder, List fieldList, Map fieldmap, List comboxList, + InterfaceAIFComponent targetComp, String yyly, LovMsg msg, String yyly_text, String[] strss, + Map comboxmap, String type, List> values, + List classList, JLabel[] labels1, String className) { + // TODO Auto-generated constructor stub + this.session = session; + this.targetRev = targetRev; + this.khdmlbbbs = khdmlbbbs; + this.userservice = session.getUserService(); + this.gccxdhs = gccxdhs; + this.boxMap = boxMap; + this.idList = idList; + this.defaultValueList = defaultValueList; + this.asList = asList; + this.esList = esList; + this.classFlag = classFlag; + this.url = session.getPreferenceService().getStringValue("Autocode_SendClassServer_URL"); + this.attrList = attrList; + this.esAttrList = esAttrList; + this.objMap = objMap; + this.markList = markList; + this.isNList = isNList; + this.lovMap = lovMap; + this.attrList2 = attrList2; + this.esAttrList2 = esAttrList2; + this.objMap2 = objMap2; + this.markList2 = markList2; + this.isNList2 = isNList2; + this.lovMap2 = lovMap2; + this.targetType = targetType; + this.flag = flag; + this.idField = idField; + this.typeList = typeList; + this.params = params; + this.attrList3 = attrList3; + this.esAttrList3 = esAttrList3; + this.objMap3 = objMap3; + this.markList3 = markList3; + this.isNList3 = isNList3; + this.lovMap3 = lovMap3; + this.attrList4 = attrList4; + this.esAttrList4 = esAttrList4; + this.objMap4 = objMap4; + this.markList4 = markList4; + this.isNList4 = isNList4; + this.lovMap4 = lovMap4; + this.revComb = revComb; + this.nameField = nameField; + this.dl = dl; + this.tagMap = tagMap; + this.folder = folder; + this.fieldList = fieldList; + this.fieldmap = fieldmap; + this.comboxList = comboxList; + this.targetComp = targetComp; + this.yyly = yyly; + this.msg = msg; + this.yyly_text = yyly_text; + this.strss = strss; + this.comboxmap = comboxmap; + this.type = type; + this.values = values; + this.classList = classList; + this.labels1 = labels1; + this.className = className; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + // +++ӽ + frame.setSize(300, 70); + frame.setLocationRelativeTo(null); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.setLayout(new BorderLayout()); + progressBar.setOrientation(JProgressBar.HORIZONTAL); + progressBar.setSize(300, 50); + progressBar.setMinimum(0); + progressBar.setMaximum(100); + progressBar.setBorderPainted(true); + progressBar.setUI(new MetalProgressBarUI()); + progressBar.setBackground(Color.white); + progressBar.setForeground(Color.green); + progressBar.setStringPainted(true); + frame.setAlwaysOnTop(true); + frame.add(progressBar); + frame.setVisible(true); + progressBar.setValue(1);// ؽ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + + List zcList = null; + String jhID = ""; + + if (classFlag) { + productNumber = splicValue(attrList, esAttrList, objMap, markList, isNList, lovMap); + System.out.println(new Date() + "productNumber============" + productNumber); + drawingNumber = splicValue(attrList2, esAttrList2, objMap2, markList2, isNList2, lovMap2); + + System.out.println(new Date() + "drawingNumber============" + drawingNumber); + if (productNumber == null || drawingNumber == null) { + return; + } + } + progressBar.setValue(10); + TCComponentItemRevision newRev = null; + String newID = ""; + try { + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent(targetType); + if (flag == 2) { + StringBuilder idSb = null; + + idSb = new StringBuilder(idField.getText()); + + String id = ""; + if (idList != null && idList.size() > 0) { + JTextField idField = (JTextField) idList.get(0); + JComboBox idbox = (JComboBox) idList.get(1); + id = idField.getText(); + String boxID = (String) idbox.getSelectedItem(); + if ("".equals(id.trim())) { + if (boxID.equals(" ")) { + id = ""; + } else { + id = boxID; + } + + } + + jhID = id; + idSb.append(id); + + } + String typeID = ""; + if (typeList != null && typeList.size() > 0) { + JComboBox idComb = typeList.get(0); + typeID = (String) idComb.getSelectedItem(); + if (typeID.contains(":")) { + typeID = typeID.split(":")[1]; + } else if (typeID.contains("")) { + typeID = typeID.split("")[1]; + } + if ("Ʒ".equals(typeID) || "Finished product".equals(typeID)) { + typeID = ""; + } else if ("".equals(typeID) || "Turning workpiece".equals(typeID)) { + typeID = "C"; + } else if ("ȴ".equals(typeID) || "Heat treatment parts".equals(typeID)) { + typeID = "R"; + } else if ("շ伷".equals(typeID) || "Cold rolled parts or cold extrusion parts".equals(typeID)) { + typeID = "D"; + } else if ("ͼ".equals(typeID) || "Forge piece".equals(typeID)) { + typeID = "D"; + } + idSb.append(typeID); + } + + newID = idSb.toString(); + String[] keys = new String[] { " ID" }; + System.out.println(idField.getText()); + String[] values = new String[] { idField.getText() }; + zcList = queryObject(" ID", keys, values); + if (zcList != null) { + if (zcList.size() > 0) { + if (zcList.get(0) instanceof TCComponentItem) { + TCComponentItem zcItem = (TCComponentItem) zcList.get(0); + TCComponentItemRevision zcRev = zcItem.getLatestItemRevision(); + TCProperty tcProperty = zcRev.getTCProperty("release_status_list"); + TCComponent[] targets = tcProperty.getReferenceValueArray(); + if (targets != null && targets.length > 0) { + MessageBox.post("ûйеܳɰ汾󴴽!!", "ʾ", MessageBox.WARNING); + return; + } + if (!classFlag) { + productNumber = zcRev.getStringProperty("rb3_th") + id; + drawingNumber = zcRev.getStringProperty("rb3_th") + id; + System.out.println("productNumber============" + productNumber); + System.out.println("drawingNumber============" + drawingNumber); + } + if ("RB3_ZC".equals(targetType)) { + List compList = queryObject("RBSearchZCCPH", new String[] { "Ʒ" }, + new String[] { productNumber }); + if (compList != null) { + if (compList.size() > 0) { + // Ż + String nID = newID.substring(0, 2); + for (int j = 0; j < compList.size(); j++) { + System.out.println(new Date() + "жitem_idǰλǷͬ"); + String compID = compList.get(j).getProperty("item_id"); + String cID = compID.substring(0, 2); + if (nID.equals(cID)) { + MessageBox.post("ϵͳѴڲƷΪ" + productNumber + "ϣ룡", "", + MessageBox.INFORMATION); + return; + } + } + // endŻ + } + + } + } else if ("RB3_LBJ".equals(targetType)) { + List compList = queryObject("RBSearchLBJCPH", new String[] { "Ʒ" }, + new String[] { productNumber }); + if (compList != null) { + if (compList.size() > 0) { + // Ż + String nID = newID.substring(0, 2); + for (int j = 0; j < compList.size(); j++) { + System.out.println(new Date() + "жitem_idǰλǷͬ"); + String compID = compList.get(j).getProperty("item_id"); + String cID = compID.substring(0, 2); + if (nID.equals(cID)) { + MessageBox.post("ϵͳѴڲƷΪ" + productNumber + "ϣ룡", "", + MessageBox.INFORMATION); + return; + } + } + // endŻ + } + } + } + } + } + } else { + MessageBox.post(rb.getString("nstwl11_display.TITLE"), "", MessageBox.INFORMATION); + return; + } + } else { + // ȡitem_id-----------жidij(1122ͷitem_idijȶ10λXXͷitem_idλ) + String it_id = targetRev.getStringProperty("item_id"); + String flag1 = it_id.substring(0, 2); + + if (flag1.equals("XX")) { + params = new Object[] { targetRev.getStringProperty("item_id").substring(0, 8), 7, 1, 9999999, 1, "" }; + } else { + params = new Object[] { targetRev.getStringProperty("item_id").substring(0, 6), 7, 1, 9999999, 1, "" }; + } + System.out.println(params); + try { + String str = "";// DM,8,400,99999999,1,"" + newID = (String) userservice.call("queryPartNo", params); + + userservice.call("delete_recycleID", new Object[] { newID }); + System.out.println("newID===============" + newID); + } catch (Exception e1) { + e1.printStackTrace(); + } + bsNumber = splicValue(attrList3, esAttrList3, objMap3, markList3, isNList3, lovMap3); + System.out.println(new Date() + "bsNumber============" + bsNumber); + smNumber = splicValue(attrList4, esAttrList4, objMap4, markList4, isNList4, lovMap4); + + System.out.println(new Date() + "smNumber============" + smNumber); + if (bsNumber == null || smNumber == null) { + return; + } + } + progressBar.setValue(30); + String[] keys = new String[] { " ID" }; + String[] values = new String[] { newID }; + List compList = queryObject(" ID", keys, values); + if (compList != null && compList.size() > 0) { + if (flag != 1) { + MessageBox.post("ϵͳѴidΪ" + newID + "ϣ룡", "", MessageBox.INFORMATION); + return; + } else { + newID = new GetNewCode(params, newID).getCode(); + String[] value = new String[] { newID }; + List queryObject = queryObject(" ID", keys, value); + if (queryObject != null && queryObject.size() > 0) { + MessageBox.post("ȡظϵԱ", "", MessageBox.INFORMATION); + return; + } + } + } + progressBar.setValue(40); + String revID = (String) revComb.getSelectedItem(); + String name = nameField.getText(); + TCComponent uom = null; + String dlval = (String) dl.getSelectedItem(); + TCComponent tcComponent = tagMap.get(dlval); + uom = tcComponent; + TCComponentItem newItem = typeComponent.create(newID, revID, targetType, name, "", uom); + if (newItem != null) { +// session.getUser().getHomeFolder() +// .add("contents", newItem); +// session.getUser().getHomeFolder().refresh(); + folder.add("contents", newItem); + folder.refresh(); + } + String statu = ""; + if ("A1".equals(revID)) { + statu = ":Conceptual design"; + } else if ("B1".equals(revID)) { + statu = ":Product design"; + } else if ("R1".equals(revID)) { + statu = ":Process design/Sample delivery"; + } else if ("P1".equals(revID)) { + statu = "P:Pilot production/small batch"; + } else if ("M1".equals(revID)) { + statu = "M:Mass production"; + } + newRev = newItem.getLatestItemRevision(); + newRev.setStringProperty("rb3_th", drawingNumber); + newRev.setStringProperty("rb3_cph", productNumber); + newRev.setStringProperty("rb3_smzqzt", statu); + if (!("".equals(jhID))) { + newRev.setStringProperty("rb3_jh", jhID); + } + if (!("".equals(bsNumber))) { + newRev.setStringProperty("rb3_bsh", bsNumber); + newRev.setStringProperty("rb3_sm2", smNumber); + } + progressBar.setValue(50); + // Ż + for (int k = 0; k < fieldList.size(); k++) { + JTextField jt = (JTextField) fieldList.get(k); + String key = jt.getName(); + String val = jt.getText(); + fieldmap.put(key, val); + } + for (int m = 0; m < comboxList.size(); m++) { + JComboBox cbo = (JComboBox) comboxList.get(m); + String key = cbo.getName(); + System.out.println("comboxNameΪ:" + key); + if (key.contains("rb3_scgc")) { + JTextField ed = (JTextField) cbo.getEditor().getEditorComponent(); + String text = ed.getText(); + + if (!text.equals("") && text != null) { + List proList = new ArrayList<>(); + String[] split = text.split(","); + TCProperty tclov = ((TCComponentItemRevision) targetComp).getTCProperty(key); + TCComponentListOfValues lov = tclov.getLOV(); + for (int p = 0; p < split.length; p++) { + String realVal = (String) lov.getListOfValues().getRealValue(split[p]); + proList.add(realVal); + } + Object[] array = proList.toArray(); + String[] svals = new String[array.length]; + for (int s = 0; s < array.length; s++) { + svals[s] = (String) array[s]; + } + newRev.getTCProperty(key).setStringValueArray(svals); + } + } else if (key.equals(yyly)) { + RwJComboBox rjbox = (RwJComboBox) cbo; + Set set = rjbox.getSet(); + int size = set.size(); + if (size > 0) { + List lists = new ArrayList(set); + String[] strs = new String[size]; + Map valMap = msg.getValMap(); + if (valMap != null) { + for (int ob = 0; ob < lists.size(); ob++) { + String itemAt = (String) rjbox.getItemAt((Integer) lists.get(ob)); + String str = valMap.get(itemAt); + strs[ob] = str; + } + newRev.getTCProperty(key).setStringValueArray(strs); + } + + } else { + if (yyly_text != null) { + newRev.getTCProperty(key).setStringValueArray(strss); + } + } + } else { + + String val = (String) cbo.getSelectedItem(); + TCProperty tclov = ((TCComponentItemRevision) targetComp).getTCProperty(key); + TCComponentListOfValues lov = tclov.getLOV(); + String realVal = (String) lov.getListOfValues().getRealValue(val); + System.out.println(new Date() + "ѡеֵΪ:" + val); + comboxmap.put(key, realVal); + } + } + progressBar.setValue(60); + newRev.setProperties(fieldmap); + newRev.setProperties(comboxmap); + // endŻ + + // ͼ + if (newRev.getType().contains("RB3_XZCP")) { + String th = getXZCPTTH(); + System.out.println(new Date() + "RB3_XZCP͵ͼΪ" + th); + newRev.setStringProperty("rb3_th", th); + } else if (newRev.getType().contains("RB3_GNZC") || newRev.getType().contains("RB3_GNLBJ")) { + String glh = getGuNaiGLHao(); + System.out.println(new Date() + "RB3_GNZCRB3_GNLBJ͵ĹΪ" + glh); + newRev.setStringProperty("rb3_glh", getGuNaiGLHao()); + } + progressBar.setValue(70); + TCTypeService typeService = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) typeService.getTypeComponent("BOMWindow"); + // һµwindow + TCComponentBOMWindow view = winType.create(null); + if (flag != 1) { + newRev.setStringProperty("rb3_lbjlx", type); + if (zcList != null) { + if (zcList.get(0) instanceof TCComponentItem) { + TCComponentItem zcItem = (TCComponentItem) zcList.get(0); + TCComponentItemRevision zcRev = zcItem.getLatestItemRevision(); + // + view.lock(); + // öbomline + TCComponentBOMLine line = view.setWindowTopLine(zcItem, zcRev, null, null); + // bomline + TCComponentBOMLine childBomline = line.add(newRev.getItem(), newRev, null, false, ""); + // + view.save(); + // + view.unlock(); + // ر + view.close(); + } + } + } else { + List revList = new ArrayList(); + Map RevToQuantity = new HashMap();// +++bomжӦ + Map RevToUom = new HashMap();// +++bomжӦĵλ + // öbomline + TCComponentBOMLine line = view.setWindowTopLine(targetRev.getItem(), targetRev, null, null); + // BOMLINEµbomline + AIFComponentContext[] contexts = line.getChildren(); + for (AIFComponentContext context : contexts) { + InterfaceAIFComponent child = context.getComponent(); + if (child instanceof TCComponentBOMLine) { + TCComponentBOMLine childLine = (TCComponentBOMLine) child; + TCComponentItemRevision itemRevision = childLine.getItemRevision(); + revList.add(itemRevision); + // +++ + RevToQuantity.put(itemRevision, childLine.getStringProperty("bl_quantity")); + RevToUom.put(itemRevision, childLine.getProperty("bl_uom").toString()); + // +++ + } + } + // ر + view.close(); + view = winType.create(null); + // + view.lock(); + + // öbomline + TCComponentBOMLine line1 = view.setWindowTopLine(newRev.getItem(), newRev, null, null); + for (TCComponentItemRevision revComp : revList) { + // bomline + TCComponentBOMLine childBomline = line1.add(revComp.getItem(), revComp, null, false, ""); + // +++ + childBomline.setProperty("bl_uom", RevToUom.get(revComp)); + childBomline.setStringProperty("bl_quantity", RevToQuantity.get(revComp)); + // +++ + } + + // + view.save(); + // + view.unlock(); + // ر + view.close(); + newRev.setStringProperty("rb3_zclx", type); + } + progressBar.setValue(80); + // · + Object[] obj = new Object[1]; + obj[0] = ""; + + try { + TCUtils.openLogByPass(session, "Ϊ"); + userservice.call("Connor_set_bypass", obj); + TCComponent[] references = targetRev.getReferenceListProperty("TC_Is_Represented_By"); +// TCComponent[] referenceListProperty = targetRev.getReferenceListProperty("release_status_list"); +// boolean isSaveAs = false; +// if (referenceListProperty != null && referenceListProperty.length > 0) { +// isSaveAs = true; +// } + for (int i = 0; i < references.length; i++) { + if (references[i] instanceof TCComponentItemRevision) { + TCComponentItemRevision pic = (TCComponentItemRevision) references[i]; +// TCComponent[] referenceListProperty1 = pic.getReferenceListProperty("release_status_list"); +// if ((referenceListProperty1 == null || referenceListProperty1.length == 0) && isSaveAs) { +// TCComponentItemRevision saveAs = pic.saveAs(null); +// newRev.add("TC_Is_Represented_By", saveAs); +// } else { +// newRev.add("TC_Is_Represented_By", pic); +// } + newRev.add("TC_Is_Represented_By", pic); + } + } + TCComponent[] references3 = targetRev.getReferenceListProperty("TC_Is_Represented_By"); +// targetRev.cutOperation("TC_Is_Represented_By", references3); +// targetRev.add("TC_Is_Represented_By", references); + + if (references3 != null && references3.length > 0) { +// targetRev.cutOperation("TC_Is_Represented_By", references3); + targetRev.remove("TC_Is_Represented_By", references3); + } + targetRev.refresh(); + if (references != null && references.length > 0) { + List asList2 = Arrays.asList(references); + System.out.println("Ӷ" + asList2 + "" + targetRev + "TC_Is_Represented_Byϵ"); + // ʹSOAķʽض RCPTC + DataManagement.Relationship[] rela_vec = new DataManagement.Relationship[asList2.size()]; + for (int a = 0; a < asList2.size(); a++) { + TCComponent comp = asList2.get(a); + DataManagement.Relationship one_rela = new DataManagement.Relationship(); + one_rela.clientId = ""; + one_rela.primaryObject = targetRev; + one_rela.secondaryObject = comp; + one_rela.relationType = "TC_Is_Represented_By"; + one_rela.userData = null; + rela_vec[a] = one_rela; + } + + // ϵ + DataManagementService service = DataManagementService.getService(session.getSoaConnection()); + DataManagement.CreateRelationsResponse reResp = null; + int breakTime = 0; + boolean createSuccess = false; + while (!createSuccess) { + try { + reResp = service.createRelations(rela_vec); + createSuccess = true; + break; + } catch (Exception e) { + e.printStackTrace(); + if(reResp != null && reResp.serviceData.sizeOfPartialErrors() > 0) { + System.out.println("create item failed"); + for (int i = 0; i < reResp.serviceData.sizeOfPartialErrors(); i++) { + String[] messages = reResp.serviceData.getPartialError(i).getMessages(); + for(int j=0;j 15) { + System.out.println("ѭ15δϵʧܣٴϵ"); + break; + } + } + // targetRev.add("TC_Is_Represented_By", references); + } + } catch (Exception e) { + + } finally { + TCUtils.closeLogByPass(session, "Ϊ"); + userservice.call("Connor_close_bypass", obj); + } + + progressBar.setValue(90); + } catch (Exception e1) { + // TODO Auto-generated catch block + MessageBox.post("ʧ!!!!", "ʾ", MessageBox.INFORMATION); + e1.printStackTrace(); + return; + } + List vals = new ArrayList(); + for (Map value : values) { + for (Map.Entry entry : value.entrySet()) { + String type = entry.getKey(); + if (type.equals("JComboBox")) { + JComboBox comb1 = (JComboBox) entry.getValue(); + String val = (String) comb1.getSelectedItem(); + vals.add(val); + } else { + JTextField field1 = (JTextField) entry.getValue(); + String val = field1.getText(); + vals.add(val); + } + } + } + Integer[] classKeys = new Integer[classList.size()]; + String[] classVals = new String[classList.size()]; + System.out.println(new Date() + "size============================" + classList.size()); + for (int i = 0; i < labels1.length; i++) { + String val = vals.get(i); + if (val == null || val.trim() == "") { + continue; + } + String val2 = ""; + if (classList.get(i).isIslov()) { + val2 = classList.get(i).getLov().get(val);// ʵֵ + System.out.println("val2================" + val2); + System.out.println("val================" + val); + } else { + val2 = val; + } + classKeys[i] = classList.get(i).getId(); + String attrName = classList.get(i).getName(); + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName) + || (PlmLocaleUtil.getString("PartNumber")).equals(attrName)) { + if ("".equals(val2.trim())) { + JComboBox box = boxMap.get(attrName); + val2 = (String) box.getSelectedItem(); + } + } + classVals[i] = val2; + } + progressBar.setValue(100); + frame.dispose(); + System.out.println(new Date() + ""); + System.out.println(new Date() + "̨"); + sendObjToClassficationByWebService(className, newRev, classKeys, classVals);// ͷ + System.out.println(new Date() + "ͽ"); + MessageBox.post("ɹ!!!!", "", MessageBox.INFORMATION); + + } + + /** + * ɹܳɻ㲿Ĺ + * + * @return + */ + public String getGuNaiGLHao() { + Object[] obj = new Object[1]; + obj[0] = ""; + + String glh = "";// Xͻ||-汾| + StringBuilder sb = new StringBuilder(); + sb.append("X"); + String bbsString = ""; + String khdmsString = ""; + String lbString = ""; + try { + TCUtils.openLogByPass(session, "Ϊ"); + userservice.call("Connor_set_bypass", obj); + String ClassID = targetRev.getClassificationClass(); + TCComponentICO[] icos = targetRev.getClassificationObjects();// ȡ + ICSProperty[] icsValues = icos[0].getICSProperties(true);// ȡԵֵ + ICSPropertyDescription[] icsDNames = icos[0].getICSPropertyDescriptors();// ȡԵ + + int index = 0; + for (ICSPropertyDescription icsDName : icsDNames) { + System.out.println("====>ƣ" + icsDName.getName()); + if (icsDName.getName().equals("汾")) { + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId() == icsDName.getId()) { + bbsString = icsValue.getValue(); + if (bbsString.contains(":")) { + bbsString = bbsString.split(":")[0]; + } + if (khdmlbbbs.containsKey("汾")) { + if (!((JTextField) khdmlbbbs.get("汾")).getText().equals("")) { + bbsString = "-" + ((JTextField) khdmlbbbs.get("汾")).getText(); + } + } + index++; + } + } + } else if (icsDName.getName().equals("ͻ")) { + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId() == icsDName.getId()) { + khdmsString = getClassDisplayableValue(icsValue.getValue(), icsDName); + if (khdmsString.contains(":")) { + khdmsString = khdmsString.split(":")[0]; + } + if (khdmlbbbs.containsKey("ͻ")) { + if (!((String) ((JComboBox) khdmlbbbs.get("ͻ")).getSelectedItem()).equals("")) { + khdmsString = ((String) ((JComboBox) khdmlbbbs.get("ͻ")).getSelectedItem()) + .split(":")[0]; + } + } + index++; + } + } + } else if (icsDName.getName().equals("")) { + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId() == icsDName.getId()) { + lbString = getClassDisplayableValue(icsValue.getValue(), icsDName); + if (lbString.contains(":")) { + lbString = lbString.split(":")[0]; + } + if (khdmlbbbs.containsKey("")) { + if (!((String) ((JComboBox) khdmlbbbs.get("")).getSelectedItem()).equals("")) { + lbString = ((String) ((JComboBox) khdmlbbbs.get("")).getSelectedItem()) + .split(":")[0]; + } + } + index++; + } + } + } + if (index == 3) { + break; + } + } + // ID + if (!khdmsString.equals("")) { + sb.append(khdmsString + "|"); + } else { + System.out.println("=======>ͻȡʧܣ"); + } + + if (!lbString.equals("")) { + sb.append(lbString + "|"); + } else { + System.out.println("=======>ȡʧܣ"); + } + + if (!bbsString.equals("")) { + sb.append(bbsString + "|"); + } else { + System.out.println("=======>汾ȡʧܣ"); + } + + Object[] params = new Object[] { sb.toString(), 4, 1, 9999, 1, "" }; + glh = (String) userservice.call("queryPartNo", params); + userservice.call("delete_recycleID", new Object[] { glh }); + System.out.println("ɵglhֵΪ:" + glh); + String[] keys = new String[] { " ID" }; + glh = dealGLH(glh); + + String[] values = new String[] { glh }; + List compList = queryObject(" ID", keys, values); + if (compList != null && compList.size() > 0) { + glh = new GetNewCode(params, glh).getCode(); + String[] value = new String[] { glh }; + List queryObject = queryObject(" ID", keys, value); + if (queryObject != null && queryObject.size() > 0) { + MessageBox.post("ȡظϵԱ", "", MessageBox.INFORMATION); + return null; + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } finally { + try { + TCUtils.closeLogByPass(session, "Ϊ"); + userservice.call("Connor_close_bypass", obj); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + return glh; + } + + /** + * ͨѯѯĿ + * + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + return null; + } + } + + public String getClassDisplayableValue(String value, ICSPropertyDescription icsD)// icsDƣvalueԵֵΪlovֵͨԾֱֵlovԾֵ + { + String result = ""; + ICSKeyLov lov1 = icsD.getFormat().getKeyLov();// ?ͨƻȡLOV + if (lov1 != null) { + String[] keys = lov1.getKeys();// ȡlovÿţ + for (String key : keys) { + if (value.equals(key))// ?źֵԶӦֱȡֵͿԻȡicsValues[j]ʾֵicsValues[j].getValue()ȡֵ + { + result = lov1.getValueOfKey(key); + return result; + } + } + } + return result; + } + + public String dealGLH(String glh) { + System.out.println("dealGLH"); + String[] split = glh.split("\\|"); + StringBuilder build = new StringBuilder(); + if (split.length > 3) { + build.append(split[0]); + build.append(split[3]); + build.append(split[1]); + build.append(split[2]); + } else { + System.out.println("glhƴ쳣!"); + } + System.out.println("glhֵΪ:" + build.toString()); + return build.toString(); + } + + /** + * ƴӳƷͼͼ + * + * @return + */ + public String getXZCPTTH() { + Object[] obj = new Object[1]; + obj[0] = ""; + String th = ""; + StringBuilder sb = new StringBuilder(); + String gcdhString = ""; + String cxdhString = ""; + try { + TCUtils.openLogByPass(session, "Ϊ"); + userservice.call("Connor_set_bypass", obj); + String ClassID = targetRev.getClassificationClass(); + TCComponentICO[] icos = targetRev.getClassificationObjects();// ȡ + ICSProperty[] icsValues = icos[0].getICSProperties(true);// ȡԵֵ + ICSPropertyDescription[] icsDNames = icos[0].getICSPropertyDescriptors();// ȡԵ + + int index = 0; + for (ICSPropertyDescription icsDName : icsDNames) { + System.out.println("====>ƣ" + icsDName.getName()); + if (icsDName.getName().equals("")) { + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId() == icsDName.getId()) { + gcdhString = getClassDisplayableValue(icsValue.getValue(), icsDName); + if (gcdhString.contains(":")) { + gcdhString = gcdhString.split(":")[0]; + } + if (gccxdhs.containsKey("")) { + if (!((String) ((JComboBox) gccxdhs.get("")).getSelectedItem()).equals("")) { + gcdhString = ((String) ((JComboBox) gccxdhs.get("")).getSelectedItem()) + .split(":")[0]; + } + } + index++; + } + } + } else if (icsDName.getName().equals("ߴ")) { + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId() == icsDName.getId()) { + cxdhString = getClassDisplayableValue(icsValue.getValue(), icsDName); + if (cxdhString.contains(":")) { + cxdhString = cxdhString.split(":")[0]; + } + if (gccxdhs.containsKey("ߴ")) { + if (!((String) ((JComboBox) gccxdhs.get("ߴ")).getSelectedItem()).equals("")) { + cxdhString = ((String) ((JComboBox) gccxdhs.get("ߴ")).getSelectedItem()) + .split(":")[0]; + } + } + index++; + } + } + } + if (index == 2) { + break; + } + } + // ID + if (!gcdhString.equals("")) { + sb.append(gcdhString); + } else { + System.out.println("=======>Żȡʧܣ"); + } + + if (!cxdhString.equals("")) { + sb.append(cxdhString); + } else { + System.out.println("=======>ߴŻȡʧܣ"); + } + System.out.println("ƴӵsb====>" + sb.toString()); + Object[] params = new Object[] { sb.toString(), 4, 1, 9999, 1, "" }; + th = (String) userservice.call("queryPartNo", params); + + userservice.call("delete_recycleID", new Object[] { th }); + + String[] keys = new String[] { " ID" }; + String[] values = new String[] { th }; + List compList = queryObject(" ID", keys, values); + System.out.println("ƴӵth====>" + th); + + if (compList != null && compList.size() > 0) { + th = new GetNewCode(params, th).getCode(); + String[] value = new String[] { th }; + List queryObject = queryObject(" ID", keys, value); + if (queryObject != null && queryObject.size() > 0) { + MessageBox.post("ȡظϵԱ", "", MessageBox.INFORMATION); + return null; + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } finally { + try { + TCUtils.closeLogByPass(session, "Ϊ"); + userservice.call("Connor_close_bypass", obj); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + return th; + + } + + public String splicValue(List attrList, List esAttrList, Map map, + List markList, List isNList, Map lovMap) { + List objList = new ArrayList(); + List lovList = new ArrayList(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < attrList.size(); i++) { + String attr = attrList.get(i); + System.out.println("attr======112" + attr); + String esAttr = esAttrList.get(i); + if (map.get(attr) == null && map.get(esAttr) == null) { + if ((PlmLocaleUtil.getString("PartNumber")).equals(attr) + || (PlmLocaleUtil.getString("PartNumber")).equals(esAttr)) { + JComboBox idbox = boxMap.get(PlmLocaleUtil.getString("PartNumber")); + JTextField idfield = (JTextField) idList.get(0); + String fieldText = idfield.getText(); + String boxText = (String) idbox.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(PlmLocaleUtil.getString("PartNumber") + "ͬʱдֵ", "ʾ", + MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(idfield); + lovList.add("no"); + } else { + objList.add(idbox); + lovList.add("yes"); + } + continue; + } + objList.add(defaultValueList.get(i)); + lovList.add("string"); + continue; + } + if (!("".equals(attr.trim()))) { + Object obj = map.get(attr); + JComboBox box = null; + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attr)) { + box = boxMap.get(attr); + } + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(esAttr)) { + box = boxMap.get(esAttr); + } + if (obj == null) { + obj = map.get(esAttr); + if (box != null) { + JTextField field = (JTextField) obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(esAttr + "ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(esAttr + "дһֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + } else { + objList.add(box); + lovList.add("yes"); + } + } else { + objList.add(obj); + lovList.add(lovMap.get(esAttr)); + } + } else { + if (box != null) { + JTextField field = (JTextField) obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(attr + "ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(attr + "дһֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + } else { + objList.add(box); + lovList.add("yes"); + } + } else { + objList.add(obj); + lovList.add(lovMap.get(attr)); + } + } + } + } + for (int i = 0; i < objList.size(); i++) { + String attrValue = ""; + Object obj = objList.get(i); + if (obj != null) { + if ("yes".equals(lovList.get(i))) { + String value = (String) ((JComboBox) obj).getSelectedItem(); + if (asList.contains(value) || esList.contains(value)) { + if (isNList.get(i).trim().contains(value)) { + if (value.contains(":")) { + System.out.println("value============" + value); + String[] values = value.split(":"); + value = values[0]; + } else if (value.contains("")) { + System.out.println("value============" + value); + String[] values = value.split(""); + value = values[0]; + } + } else { + value = ""; + } + } else { + if (value.contains(":")) { + System.out.println("value============" + value); + String[] values = value.split(":"); + value = values[0]; + } else if (value.contains("")) { + System.out.println("value============" + value); + String[] values = value.split(""); + value = values[0]; + } + } + if ("Ʒ".equals(value) || "Finished product".equals(value)) { + value = ""; + } else if ("".equals(value) || "Turning workpiece".equals(value)) { + value = "C"; + } else if ("ȴ".equals(value) || "Heat treatment parts".equals(value)) { + value = "R"; + } else if ("շ伷".equals(value) || "Cold rolled parts or cold extrusion parts".equals(value)) { + value = "D"; + } else if ("ͼ".equals(value) || "Forge piece".equals(value)) { + value = "D"; + } + attrValue = value; + } else if ("no".equals(lovList.get(i))) { + attrValue = ((JTextField) obj).getText(); + + } else { + attrValue = (String) obj; + } + if (asList.contains(attrValue) || esList.contains(attrValue)) { + attrValue = ""; + } else { + if (attrValue.contains(":")) { + System.out.println("attrValue============" + attrValue); + String[] values = attrValue.split(":"); + attrValue = values[0]; + } else if (attrValue.contains("")) { + System.out.println("attrValue============" + attrValue); + String[] values = attrValue.split(""); + attrValue = values[0]; + } + } + + String mark = markList.get(i); + System.out.println("mark============" + mark); + if (!("".equals(attrValue.trim())) && mark != null) { + sb.append(mark.trim()); + sb.append(attrValue); + } + } + } + return sb.toString(); + } + + /** + * ͷ + */ + public void sendObjToClassficationByWebService(String class_id, TCComponentItemRevision rev, Integer[] keys, + String[] vals) { + try { + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList(); + + for (int i = 0; i < keys.length; i++) { + + if (keys[i] != null && vals[i] != null) { + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + } + // +++9-28 + new Thread() { + @Override + public void run() { + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + }.start(); + // +++9-28 + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/rb/plm/rb011/LovMsg.java b/src/com/connor/rb/plm/rb011/LovMsg.java new file mode 100644 index 0000000..74e086f --- /dev/null +++ b/src/com/connor/rb/plm/rb011/LovMsg.java @@ -0,0 +1,71 @@ +package com.connor.rb.plm.rb011; + +import java.util.List; +import java.util.Map; + +import com.teamcenter.rac.kernel.TCComponentListOfValues; + +public class LovMsg { + private List ss; + private Map lovMap = null; + private List sss; + private Map valMap = null; + private Map lov4Map = null; + + public List getSss() { + return sss; + } + + public void setSss(List sss) { + this.sss = sss; + } + + public Map getValMap() { + return valMap; + } + + public void setValMap(Map valMap) { + this.valMap = valMap; + } + + private List lovs; + + public Map getLov4Map() { + return lov4Map; + } + + public void setLov4Map(Map lov4Map) { + this.lov4Map = lov4Map; + } + + public List getLovs() { + return lovs; + } + + public void setLovs(List lovs) { + this.lovs = lovs; + } + + public List getSs() { + return ss; + } + + public void setSs(List ss) { + this.ss = ss; + } + + public Map getLovMap() { + return lovMap; + } + + public void setLovMap(Map lovMap) { + this.lovMap = lovMap; + } + + @Override + public String toString() { + return "LovMsg [ss=" + ss + ", lovMap=" + lovMap + ", sss=" + sss + ", valMap=" + valMap + ", lov4Map=" + + lov4Map + ", lovs=" + lovs + "]"; + } + +} diff --git a/src/com/connor/rb/plm/rb012/CreatDialog.java b/src/com/connor/rb/plm/rb012/CreatDialog.java new file mode 100644 index 0000000..618532c --- /dev/null +++ b/src/com/connor/rb/plm/rb012/CreatDialog.java @@ -0,0 +1,1085 @@ +package com.connor.rb.plm.rb012; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.Map.Entry; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSeparator; +import javax.swing.JTextField; +import javax.swing.SwingConstants; + +import com.connor.rb.plm.entity.ZC_LBJ_list; +import com.connor.rb.plm.newcombox.RwJComboBox; +import com.connor.rb.plm.util.ClassAttributeBean; +import com.connor.rb.plm.util.ClassProperty; +import com.connor.rb.plm.util.PlmLocaleUtil; +import com.connor.rb.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.classification.common.G4MUnitSystemOptionButton; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSKeyLov.KeyLov; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class CreatDialog extends AbstractAIFDialog { + private AbstractAIFApplication app; + private TCSession session; + private TCPreferenceService service; + private List classList = new ArrayList(); + private JLabel[] labels1 = null; + // private JComboBox comb = null; + private String className = ""; + private Map map2; + private List idList = new ArrayList(); + // Ż:TextField + private List fieldList = new ArrayList(); + // box + private List comboxList = new ArrayList(); + private Map fieldmap = new HashMap<>(); + private Map comboxmap = new HashMap<>(); + private List yylyList = new ArrayList(); + // end + private List clearanceList = new ArrayList(); + private Map> boxMap = new HashMap>(); + private List> values = new ArrayList>(); + private String cph = ""; + private String th = ""; + private String revId = ""; + private String newID = ""; + private String type = ""; + private String targetType = ""; + private boolean flag = true; + private String url = ""; + private JTextField showDate1; + private JScrollPane scr2; + private SimpleDateFormat df = new SimpleDateFormat("yyyy-M-d HH:mm"); + private JTextField nameField = null; + private TCComponentItemRevision targetRev = null; + private Map zc_lbj_map;// ܳɻ㲿Լֵ + private int f = 0; + private int h = 4; + private int v = 4; + private boolean boflag = false; + private InterfaceAIFComponent targetComp; + + public CreatDialog(AbstractAIFApplication app) { + super(false); + this.app = app; + this.targetComp = app.getTargetComponent(); + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + } + + @Override + public void run() { + this.initUI(); + + } + + public void initUI() { + setTitle("ʱϴ"); + this.setLayout(new PropertyLayout()); + Dimension dimension = new Dimension(); + dimension.setSize(750, 630); + Dimension mindis = new Dimension(); + Dimension maxdis = new Dimension(); + mindis.setSize(750, 640); + maxdis.setSize(760, 1200); + this.setMaximumSize(maxdis); + this.setMinimumSize(mindis); + this.setPreferredSize(dimension); +// this.setLayout(new BorderLayout()); +// Dimension dimension = new Dimension(); +// dimension.setSize(450,630); +// this.setPreferredSize(dimension); + JPanel parentPanel = new JPanel(new PropertyLayout()); + scr2 = new JScrollPane(parentPanel); + scr2.setPreferredSize(new Dimension(720, 530)); + JPanel classJpanel = new JPanel(new PropertyLayout());// Խ + classJpanel.add("1.1.center.top", scr2); + // "1.1.center.top", + // ʱϴӴڸĶ + this.addComponentListener(new ComponentListener() { + + @Override + public void componentResized(ComponentEvent e) { + // TODO Auto-generated method stub + Component component2 = e.getComponent(); + int h = component2.getHeight(); + if (h > 630) { + scr2.setPreferredSize(new Dimension(component2.getWidth() - 30, h - 110)); + scr2.revalidate(); + scr2.repaint(); + classJpanel.setPreferredSize(new Dimension(component2.getWidth(), h - 110)); + classJpanel.revalidate(); + classJpanel.repaint(); + } + } + + @Override + public void componentMoved(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void componentShown(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void componentHidden(ComponentEvent e) { + // TODO Auto-generated method stub + + } + }); + + // Ż +// try { +// zc_lbj_map = targetComp.getProperties(); +// } catch (Exception e2) { +// // TODO Auto-generated catch block +// e2.printStackTrace(); +// } +// String objtype = targetComp.getType(); +// System.out.println("汾:"+objtype); +// if(objtype.equals("RB3_ZCRevision")) { +// System.out.println(objtype); +// boflag=true; +// +// }else { +// System.out.println(objtype); +// +// } + // endŻ + + if (targetComp instanceof TCComponentItemRevision) { + targetRev = (TCComponentItemRevision) targetComp; + try { + targetType = targetRev.getItem().getType(); + if ("RB3_ZC".equals(targetType)) { + type = targetRev.getStringProperty("rb3_zclx"); + flag = false; + } else if ("RB3_LBJ".equals(targetType)) { + type = targetRev.getStringProperty("rb3_lbjlx"); + } + String name = targetRev.getStringProperty("object_name"); + nameField = new JTextField(18); + nameField.setText(name); + DateChooser dateChooser1 = DateChooser.getInstance("yyyy-M-d HH:mm"); + Date date = new Date(); + Date newDate = stepMonth(date, +3); + System.out.println("ǰʱ3µڣ" + df.format(newDate)); + String time = df.format(newDate); + showDate1 = new JTextField(time); + dateChooser1.register(showDate1); + + parentPanel.add("1.1.center.top", new JLabel("")); + parentPanel.add("2.1.center.top", new JLabel("")); + parentPanel.add("2.2.center.top", nameField); + parentPanel.add("3.1.center.top", new JLabel("Ч")); + parentPanel.add("3.2.center.top", showDate1); + + cph = targetRev.getStringProperty("rb3_cph"); + th = targetRev.getStringProperty("rb3_th"); + String id = targetRev.getStringProperty("item_id"); + revId = targetRev.getStringProperty("item_revision_id"); + + StringBuilder sb = new StringBuilder("LS-"); + sb.append(id); + newID = sb.toString(); + className = targetRev.getClassificationClass(); + TCComponentICO[] icos = targetRev.getClassificationObjects(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + if (icos == null || icos.length <= 0) { + // ѡеûз͵࣬뷢ͣ + MessageBox.post(rb.getString("xzdwlmyfsdfl07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + Map claMap = new HashMap(); + if (icos != null && icos.length > 0) { + ICSProperty[] icss = icos[0].getICSProperties(true); + for (ICSProperty ics : icss) { + claMap.put(ics.getId(), ics.getValue()); + } + } + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(className); + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + if (icsAttrS != null) { + for (ICSAdminClassAttribute attr : icsAttrS) { + if (attr.isHidden()) { + continue; + } + ClassAttributeBean bean = new ClassAttributeBean(); + if (attr.isReferenceAttribute()) {// + continue; + } + if (attr.isReference()) { + continue; + } + int propID = attr.getAttributeId(); + bean.setId(propID); + String propDisName = attr.getName(); + bean.setName(propDisName); + + int attrType = attr.getFormat1().getType(); + bean.setType(attrType); + + if (claMap != null && claMap.containsKey(propID)) { + bean.setVal(claMap.get(propID)); + } else { + bean.setVal(""); + } + + ICSKeyLov lov1 = attr.getFormat1().getKeyLov(); + lov1 = (lov1 == null ? attr.getFormat2().getKeyLov() : lov1); + if (lov1 != null) { + bean.setIslov(true); + String[] keys = lov1.getKeys(); + Map map1 = new HashMap(); + for (String key : keys) { + KeyLov lov_key = lov1.getKeyLovOfKey(key); + boolean deprecated = lov_key.isDeprecated(); + if (deprecated) { + if (key.equals(bean.getVal())) { + bean.setVal(""); + } + continue; + } + String value = lov1.getValueOfKey(key); + map1.put(value, key);// <ʾֵ,ʵֵ> + if (key.equals(bean.getVal()) && (!bean.getVal().equals(""))) { + bean.setVal(value); + } + } + bean.setLov(map1); + } else { + bean.setIslov(false); + } + classList.add(bean); + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + labels1 = new JLabel[classList.size()]; + + for (int i = 0; i < classList.size(); i++) { + ClassAttributeBean bean = classList.get(i); + String attrName = bean.getName(); + labels1[i] = new JLabel(bean.getName()); + parentPanel.add((h + i) + ".1.center.top", labels1[i]); + labels1[i].setBounds(5, 5, 5, 5); + if (bean.isIslov()) { + JComboBox comb = new JComboBox(); + + // Ż + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + // end + + comb.setEditable(false); + comb.setSize(new Dimension(60, 40)); + comb.addItem(bean.getVal()); + for (Entry entry : bean.getLov().entrySet()) { + if (!(bean.getVal().equals(entry.getKey()))) { + comb.addItem(entry.getKey()); + } + } + // Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + System.out.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(comb, tip); + } + } + + }); + // end + map2 = new HashMap(); + map2.put("JComboBox", comb); + values.add(map2); + parentPanel.add((h + i) + ".2.center.top", comb); + parentPanel.add((h + i) + ".3.center.top", jt); + parentPanel.add((h + i) + ".4.center.top", bu); + + } else { + JTextField field = new JTextField(18); + map2 = new HashMap(); + map2.put("JTextField", field); + values.add(map2); + parentPanel.add((h + i) + ".2.center.top", field); + field.setText(bean.getVal()); + System.out.println("attrName================" + attrName); + System.out.println( + "PlmLocale.getString(\"PartNumber\")================" + PlmLocaleUtil.getString("PartNumber")); + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName)) { + clearanceList.add(field); + JComboBox box = new JComboBox(); + // Ż + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + // end + box.addItem(" "); + clearanceList.add(box); + String[] strs = new String[] { "C0", "C2", "C3", "C4", "C5" }; + for (int K = 0; K < strs.length; K++) { + box.addItem(strs[K]); + } + // Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + System.out.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(box, tip); + } + } + + }); + // end + boxMap.put(attrName, box); + parentPanel.add((h + i) + ".3.center.top", box); + // Ż + parentPanel.add((h + i) + ".4.center.top", jt); + parentPanel.add((h + i) + ".5.center.top", bu); + // end + v += h + i + 1; + } else if ((PlmLocaleUtil.getString("PartNumber")).equals(attrName)) { + + idList.add(field); + JComboBox box = new JComboBox(); + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + idList.add(box); + box.addItem(" "); + String[] strs = new String[99]; + for (int K = 0; K < 99; K++) { + if (K < 9) { + strs[K] = "0" + (K + 1); + } else { + strs[K] = (K + 1) + ""; + } + } + for (int K = 0; K < strs.length; K++) { + box.addItem(strs[K]); + } + // Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + System.out.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(box, tip); + } + } + + }); + // end + + boxMap.put(attrName, box); + parentPanel.add((h + i) + ".3.center.top", box); + parentPanel.add((h + i) + ".4.center.top", jt); + parentPanel.add((h + i) + ".5.center.top", bu); + } + } + v = h + i + 1; + } + + // Ż +// parentPanel.add(v+".1.center.top",new JLabel(" ")); +// parentPanel.add(v+".2.center.top",new JLabel("**********************")); +// v+=1; +// if(boflag) { +// //System.out.println("ӵԸ:"+h); +// for(int i=0;i disVal=new ArrayList(); +// for(int a=0;a0) { +// StringBuilder sb=new StringBuilder(); +// for(int t=0;t disVal=new ArrayList(); +// if(vals.length>0) { +// for(int e=0;e0) { +// comboxitems=new String[yylyList.size()]; +// for(int g=0;g0) { +// StringBuilder sb=new StringBuilder(); +// for(int t=0;t(); +// zcBox.setSize(new Dimension(60,40)); +// zcBox.setName(ZC_LBJ_list.ZCPros.get(i)); +// TCProperty zclov = ((TCComponentItemRevision) targetComp).getTCProperty(ZC_LBJ_list.ZCPros.get(i)); +// TCComponentListOfValues zcprolov = zclov.getLOV(); +// String[] comboxitems; +// +// JTextField jt=new JTextField(9); +// JButton bu=new JButton(""); +// if(zcprolov!=null) { +// comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); +// ComboBoxModel model = new DefaultComboBoxModel(comboxitems); +// zcBox.setModel(model); +// +// +// bu.addActionListener(new ActionListener() { +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// String tip=jt.getText(); +// System.out.println(""+tip); +// if(tip.length()>0) { +// SearchJComItem.changeBox(zcBox, tip); +// } +// } +// +// }); +// +// comboxList.add(zcBox); +// } +// +// zcBox.setSelectedItem(zc_lbj_map.get(ZC_LBJ_list.ZCPros.get(i))); +// if((ZC_LBJ_list.ZCDisPros.get(i)).equals("ʱϱʶ")) { +// zcBox.setSelectedIndex(-1); +// } +// parentPanel.add((v+i)+".2.center.top",zcBox); +// parentPanel.add((v+i)+".3.center.top",jt); +// parentPanel.add((v+i)+".4.center.top",bu); +// } +// +// +// }else { +// JTextField field=new JTextField(18); +// field.setName(ZC_LBJ_list.ZCPros.get(i)); +// field.setText(zc_lbj_map.get(ZC_LBJ_list.ZCPros.get(i))); +// parentPanel.add((v+i)+".2.center.top",field); +// fieldList.add(field); +// } +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// } +// }else { +// for(int i=0;i disVal=new ArrayList(); +// for(int a=0;a0) { +// StringBuilder sb=new StringBuilder(); +// for(int t=0;t(); +// zcBox.setSize(new Dimension(60,40)); +// zcBox.setName(ZC_LBJ_list.LBJPros.get(i)); +// TCProperty zclov = ((TCComponentItemRevision) targetComp).getTCProperty(ZC_LBJ_list.LBJPros.get(i)); +// TCComponentListOfValues zcprolov = zclov.getLOV(); +// String[] comboxitems; +// +// +// JTextField jt=new JTextField(9); +// JButton bu=new JButton(""); +// if(zcprolov!=null) { +// comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); +// ComboBoxModel model = new DefaultComboBoxModel(comboxitems); +// zcBox.setModel(model); +// +// +// bu.addActionListener(new ActionListener() { +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// String tip=jt.getText(); +// System.out.println(""+tip); +// if(tip.length()>0) { +// SearchJComItem.changeBox(zcBox, tip); +// } +// } +// +// }); +// +// comboxList.add(zcBox); +// } +// zcBox.setSelectedItem(zc_lbj_map.get(ZC_LBJ_list.LBJPros.get(i))); +// if((ZC_LBJ_list.LBJDisPros.get(i)).equals("ʱϱʶ")) { +// zcBox.setSelectedIndex(-1); +// } +// parentPanel.add((v+i)+".2.center.top",zcBox); +// parentPanel.add((v+i)+".3.center.top",jt); +// parentPanel.add((v+i)+".4.center.top",bu); +// } +// }else { +// JTextField field=new JTextField(18); +// field.setName(ZC_LBJ_list.LBJPros.get(i)); +// field.setText(zc_lbj_map.get(ZC_LBJ_list.LBJPros.get(i))); +// parentPanel.add((v+i)+".2.center.top",field); +// fieldList.add(field); +// } +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// } +// } + +// for(Map.Entry e:zc_lbj_map.entrySet()) { +// System.out.println(e.getKey()+"==="+e.getValue()); +// parentPanel.add(h+".1.center.top",new JLabel(e.getKey())); +// JTextField field=new JTextField(18); +// field.setName(e.getKey()); +// field.setText(e.getValue()); +// parentPanel.add(h+".2.center.top",field); +// h++; +// } + + // endŻ + + JPanel southPanel = new JPanel(new FlowLayout()); + southPanel.setPreferredSize(new Dimension(250, 50)); + JButton button = new JButton("½"); + JButton button1 = new JButton("ȡ"); + button.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + createItem(); + + } + + }); + button1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + + }); + southPanel.add(button); + southPanel.add(button1); + this.add("1.1.center.top", new JLabel(" ")); + // this.add(new JLabel(" "),BorderLayout.NORTH); + // this.add(classJpanel,BorderLayout.CENTER); + this.add("2.1.center.top", classJpanel); + + // this.add(southPanel,BorderLayout.SOUTH); + this.add("3.1.center.top", southPanel); + + pack(); + centerToScreen(1.0D, 0.75D); + this.showDialog(); + } + + protected void createItem() { + // TODO Auto-generated method stub + if (idList.size() > 0) { + JTextField idField = (JTextField) idList.get(0); + JComboBox idBox = (JComboBox) idList.get(1); + String idFieldText = idField.getText(); + String idBoxText = (String) idBox.getSelectedItem(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + if (!("".equals(idFieldText.trim())) && !("".equals(idBoxText.trim()))) { + // Ųͬʱдֵ + MessageBox.post(rb.getString("jhbntstxlgz12_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } +// if("".equals(idFieldText.trim()) && "".equals(idBoxText.trim())) { +// MessageBox.post("űдһֵ", "ʾ", MessageBox.INFORMATION); +// return; +// } + } + if (clearanceList.size() > 0) { + JTextField clearanceField = (JTextField) clearanceList.get(0); + JComboBox clearanceBox = (JComboBox) clearanceList.get(1); + String clearanceFieldText = clearanceField.getText(); + String clearanceBoxText = (String) clearanceBox.getSelectedItem(); + if (!("".equals(clearanceFieldText.trim())) && !("".equals(clearanceBoxText.trim()))) { + MessageBox.post("ڲ϶ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return; + } + if ("".equals(clearanceFieldText.trim()) && "".equals(clearanceBoxText.trim())) { + MessageBox.post("ڲ϶дһֵ", "ʾ", MessageBox.INFORMATION); + return; + } + } + + String[] keys1 = new String[] { " ID" }; + String[] values1 = new String[] { newID }; + List compList = queryObject(" ID", keys1, values1); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (compList != null && compList.size() > 0) { + // ϵͳѾڸIDŵ,󴴽! + MessageBox.post(rb.getString("xtzycz12_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + TCComponentItemRevision newRev = null; + try { + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent(targetType); + + TCComponentItem newItem = typeComponent.create(newID, revId, targetType, nameField.getText(), "", null); + if (newItem != null) { + session.getUser().getHomeFolder().add("contents", newItem); + session.getUser().getHomeFolder().refresh(); + } + newRev = newItem.getLatestItemRevision(); + + // Ż +// for(int k=0;k proList=new ArrayList<>(); +// String[] split = text.split(","); +// TCProperty tclov = ((TCComponentItemRevision) targetComp).getTCProperty(key); +// TCComponentListOfValues lov = tclov.getLOV(); +// for(int p=0;p pics = new ArrayList(); + List picID = new ArrayList(); + for (int i = 0; i < references.length; i++) { + if (references[i] instanceof TCComponentItemRevision) { + TCComponentItemRevision pic = (TCComponentItemRevision) references[i]; + String pic_type = pic.getItem().getType(); + String rev_id = pic.getStringProperty("item_revision_id"); + String id = pic.getStringProperty("item_id"); + String pic_name = pic.getStringProperty("object_name"); + StringBuilder sb = new StringBuilder("LS-"); + sb.append(id); + String picNewID = sb.toString(); + String[] keys2 = new String[] { " ID" }; + String[] values2 = new String[] { picNewID }; + List picList = queryObject(" ID", keys2, values2); + if (picList != null) { + if (picList.size() > 0) { + TCComponent tcComponent = picList.get(0); + if (tcComponent instanceof TCComponentItem) { + TCComponentItemRevision rev = ((TCComponentItem) tcComponent).getLatestItemRevision(); + if (!(picID.contains(picNewID))) { + picID.add(picNewID); + pics.add(rev); + } + } + } + } else { + TCComponentItemType picType = (TCComponentItemType) session.getTypeComponent(pic_type); + TCComponentItem picItem = picType.create(picNewID, rev_id, pic_type, pic_name, "", null); + TCComponentItemRevision picRev = picItem.getLatestItemRevision(); + newRev.add("TC_Is_Represented_By", picRev); + picID.add(picNewID); + } + + } + } + if (pics.size() > 0) { + for (int i = 0; i < pics.size(); i++) { + TCComponentItemRevision rev = pics.get(i); + newRev.add("TC_Is_Represented_By", rev); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + // ʱϴʧ! + MessageBox.post(rb.getString("lswlcjsb12_display.TITLE"), "", MessageBox.INFORMATION); + e.printStackTrace(); + return; + } + List vals = new ArrayList(); + for (Map value : values) { + for (Map.Entry entry : value.entrySet()) { + String type = entry.getKey(); + if (type.equals("JComboBox")) { + JComboBox comb1 = (JComboBox) entry.getValue(); + String val = (String) comb1.getSelectedItem(); + vals.add(val); + } else { + JTextField field1 = (JTextField) entry.getValue(); + String val = field1.getText(); + vals.add(val); + } + } + } + Integer[] classKeys = new Integer[classList.size()]; + String[] classVals = new String[classList.size()]; + System.out.println("size============================" + classList.size()); + for (int i = 0; i < labels1.length; i++) { + String val = vals.get(i); + if (val == null || val.trim() == "") { + continue; + } + String val2 = ""; + if (classList.get(i).isIslov()) { + val2 = classList.get(i).getLov().get(val);// ʵֵ + System.out.println("val2================" + val2); + System.out.println("val================" + val); + } else { + val2 = val; + } + classKeys[i] = classList.get(i).getId(); + String attrName = classList.get(i).getName(); + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName) + || (PlmLocaleUtil.getString("PartNumber")).equals(attrName)) { + if ("".equals(val2.trim())) { + JComboBox box = boxMap.get(attrName); + val2 = (String) box.getSelectedItem(); + } + } + classVals[i] = val2; + } + + disposeDialog(); + sendObjToClassficationByWebService(className, newRev, classKeys, classVals);// ͷ + MessageBox.post(rb.getString("lswlcjwc12_display.TITLE"), "", MessageBox.INFORMATION); + + } + + /** + * ͷ + */ + public void sendObjToClassficationByWebService(String class_id, TCComponentItemRevision rev, Integer[] keys, + String[] vals) { + try { + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList(); + + for (int i = 0; i < keys.length; i++) { + if (keys[i] != null && vals[i] != null) { + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + } + // +++9-28 + new Thread() { + @Override + public void run() { + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + }.start(); + // +++ + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static Date stepMonth(Date sourceDate, int month) { + Calendar c = Calendar.getInstance(); + c.setTime(sourceDate); + c.add(Calendar.MONTH, month); + + return c.getTime(); + } + + /** + * ͨѯѯĿ + * + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + return null; + } + } + +} diff --git a/src/com/connor/rb/plm/rb012/CreateHandler.java b/src/com/connor/rb/plm/rb012/CreateHandler.java new file mode 100644 index 0000000..b709f46 --- /dev/null +++ b/src/com/connor/rb/plm/rb012/CreateHandler.java @@ -0,0 +1,43 @@ +package com.connor.rb.plm.rb012; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.rb.plm.rb012.CreatDialog; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.util.MessageBox; + +public class CreateHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + // ȡʻ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (targetComponent instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) targetComponent; + System.out.println("rev.getType()=====" + rev.getType()); + if ("RB3_ZCRevision".equals(rev.getType()) || "RB3_LBJRevision".equals(rev.getType())) { + CreatDialog dialog = new CreatDialog(app); + new Thread(dialog).start(); + } else { + MessageBox.post(rb.getString("qxzzcbbhlbj07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return null; + } + } else { + MessageBox.post(rb.getString("qxzbbdx07_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return null; + } + return null; + } + +} diff --git a/src/com/connor/rb/plm/rb012/DateChooser.java b/src/com/connor/rb/plm/rb012/DateChooser.java new file mode 100644 index 0000000..d5c6913 --- /dev/null +++ b/src/com/connor/rb/plm/rb012/DateChooser.java @@ -0,0 +1,1198 @@ +package com.connor.rb.plm.rb012; + +import java.awt.BasicStroke; + +import java.awt.BorderLayout; + +import java.awt.Color; + +import java.awt.Component; + +import java.awt.Cursor; + +import java.awt.Dimension; + +import java.awt.Font; + +import java.awt.Graphics; + +import java.awt.Graphics2D; + +import java.awt.GridLayout; + +import java.awt.Point; + +import java.awt.Polygon; + +import java.awt.Stroke; + +import java.awt.Toolkit; + +import java.awt.event.FocusEvent; + +import java.awt.event.FocusListener; + +import java.awt.event.MouseAdapter; + +import java.awt.event.MouseEvent; + +import java.awt.event.MouseListener; + +import java.awt.event.MouseMotionListener; + +import java.text.SimpleDateFormat; + +import java.util.ArrayList; + +import java.util.Calendar; + +import java.util.Comparator; + +import java.util.Date; + +import java.util.List; + +import javax.swing.BorderFactory; + +import javax.swing.JComponent; + +import javax.swing.JFrame; + +import javax.swing.JLabel; + +import javax.swing.JPanel; + +import javax.swing.JTextField; + +import javax.swing.Popup; + +import javax.swing.PopupFactory; + +import javax.swing.SwingUtilities; + +import javax.swing.event.AncestorEvent; + +import javax.swing.event.AncestorListener; + +/** + * + * ѡָڵʾʽ + * + */ + +public class DateChooser extends JPanel { + + private static final long serialVersionUID = 4529266044762990227L; + + private Date initDate; + + private Calendar now = Calendar.getInstance(); + + private Calendar select; + + private JPanel monthPanel;// + + private JP1 jp1;// Ŀ, + + private JP2 jp2; + + private JP3 jp3; + + private JP4 jp4; + + private Font font = new Font("", Font.PLAIN, 12); + + private final LabelManager lm = new LabelManager(); + + private SimpleDateFormat sdf; + + private boolean isShow = false; + + private Popup pop; + + private JComponent showDate; + + public static DateChooser getInstance() { + + return new DateChooser(); + + } + + public static DateChooser getInstance(Date date) { + + return new DateChooser(date); + + } + + public static DateChooser getInstance(String format) { + + return new DateChooser(format); + + } + + public static DateChooser getInstance(Date date, String format) { + + return new DateChooser(date, format); + + } + + /** + * + * Creates a new instance of DateChooser + * + */ + + private DateChooser() { + + this(new Date()); + + } + + private DateChooser(Date date) { + + this(date, "yyyyMMdd"); + + } + + private DateChooser(String format) { + + this(new Date(), format); + + } + + private DateChooser(Date date, String format) { + + initDate = date; + + sdf = new SimpleDateFormat(format); + + select = Calendar.getInstance(); + + select.setTime(initDate); + + initPanel(); + + } + + /** + * + * Ƿûѡ + * + */ + + public void setEnabled(boolean b) { + + super.setEnabled(b); + + showDate.setEnabled(b); + + } + + /** + * + * õǰѡ + * + */ + + public Date getDate() { + + return select.getTime(); + + } + + public String getStrDate() { + + return sdf.format(select.getTime()); + + } + + public String getStrDate(String format) { + + sdf = new SimpleDateFormat(format); + + return sdf.format(select.getTime()); + + } + + // ݳʼ,ʼ + + private void initPanel() { + + monthPanel = new JPanel(new BorderLayout()); + + monthPanel.setBorder(BorderFactory.createLineBorder(Color.BLUE)); + + JPanel up = new JPanel(new BorderLayout()); + + up.add(jp1 = new JP1(), BorderLayout.NORTH); + + up.add(jp2 = new JP2(), BorderLayout.CENTER); + + monthPanel.add(jp3 = new JP3(), BorderLayout.CENTER); + + monthPanel.add(up, BorderLayout.NORTH); + + monthPanel.add(jp4 = new JP4(), BorderLayout.SOUTH); + + this.addAncestorListener(new AncestorListener() { + + public void ancestorAdded(AncestorEvent event) { + + } + + public void ancestorRemoved(AncestorEvent event) { + + } + + // ֻҪһƶ,Ͼpopupʧ + + public void ancestorMoved(AncestorEvent event) { + + hidePanel(); + + } + + }); + + } + + public void register(final JComponent showDate) { + + this.showDate = showDate; + + showDate.setRequestFocusEnabled(true); + + showDate.addMouseListener(new MouseAdapter() { + + public void mousePressed(MouseEvent me) { + + showDate.requestFocusInWindow(); + + } + + }); + + this.setBackground(Color.WHITE); + + this.add(showDate, BorderLayout.CENTER); + + this.setPreferredSize(new Dimension(90, 25)); + + this.setBorder(BorderFactory.createLineBorder(Color.GRAY)); + + showDate.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + if (showDate.isEnabled()) { + + showDate.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + showDate.setForeground(Color.RED); + + } + + } + + public void mouseExited(MouseEvent me) { + + if (showDate.isEnabled()) { + + showDate.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + showDate.setForeground(Color.BLACK); + + } + + } + + public void mousePressed(MouseEvent me) { + + if (showDate.isEnabled()) { + + showDate.setForeground(Color.CYAN); + + if (isShow) { + + hidePanel(); + + } else { + + showPanel(showDate); + + } + + } + + } + + public void mouseReleased(MouseEvent me) { + + if (showDate.isEnabled()) { + + showDate.setForeground(Color.BLACK); + + } + + } + + }); + + showDate.addFocusListener(new FocusListener() { + + public void focusLost(FocusEvent e) { + + hidePanel(); + + } + + public void focusGained(FocusEvent e) { + + } + + }); + + } + + // µˢ + + private void refresh() { + + jp1.updateDate(); + + jp2.updateDate(); + + jp3.updateDate(); + + jp4.updateDate(); + + SwingUtilities.updateComponentTreeUI(this); + + } + + // ύ + + private void commit() { + + // TODO add other components here + + if (showDate instanceof JTextField) { + + ((JTextField) showDate).setText(sdf.format(select.getTime())); + + } else if (showDate instanceof JLabel) { + + ((JLabel) showDate).setText(sdf.format(select.getTime())); + + } + + hidePanel(); + + } + + // ѡ + + private void hidePanel() { + + if (pop != null) { + + isShow = false; + + pop.hide(); + + pop = null; + + } + + } + + // ʾѡ + + private void showPanel(Component owner) { + + if (pop != null) { + + pop.hide(); + + } + + Point show = new Point(0, showDate.getHeight()); + + SwingUtilities.convertPointToScreen(show, showDate); + + Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); + + int x = show.x; + + int y = show.y; + + if (x < 0) { + + x = 0; + + } + + if (x > size.width - 295) { + + x = size.width - 295; + + } + + if (y < size.height - 170) { + + } else { + + y -= 188; + + } + + pop = PopupFactory.getSharedInstance().getPopup(owner, monthPanel, x, y); + + pop.show(); + + isShow = true; + + } + + /** + * + * ʾ·ݵ + * + */ + + private class JP1 extends JPanel { + + private static final long serialVersionUID = -5638853772805561174L; + + JLabel yearleft, yearright, monthleft, monthright, center, centercontainer; + + public JP1() { + + super(new BorderLayout()); + + this.setBackground(new Color(160, 185, 215)); + + initJP1(); + + } + + private void initJP1() { + + yearleft = new JLabel(" <<", JLabel.CENTER); + + yearleft.setToolTipText("һ"); + + yearright = new JLabel(">> ", JLabel.CENTER); + + yearright.setToolTipText("һ"); + + yearleft.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); + + yearright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); + + monthleft = new JLabel(" <", JLabel.RIGHT); + + monthleft.setToolTipText("һ"); + + monthright = new JLabel("> ", JLabel.LEFT); + + monthright.setToolTipText("һ"); + + monthleft.setBorder(BorderFactory.createEmptyBorder(2, 30, 0, 0)); + + monthright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 30)); + + centercontainer = new JLabel("", JLabel.CENTER); + + centercontainer.setLayout(new BorderLayout()); + + center = new JLabel("", JLabel.CENTER); + + centercontainer.add(monthleft, BorderLayout.WEST); + + centercontainer.add(center, BorderLayout.CENTER); + + centercontainer.add(monthright, BorderLayout.EAST); + + this.add(yearleft, BorderLayout.WEST); + + this.add(centercontainer, BorderLayout.CENTER); + + this.add(yearright, BorderLayout.EAST); + + this.setPreferredSize(new Dimension(295, 25)); + + updateDate(); + + yearleft.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + yearleft.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + yearleft.setForeground(Color.RED); + + } + + public void mouseExited(MouseEvent me) { + + yearleft.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + yearleft.setForeground(Color.BLACK); + + } + + public void mousePressed(MouseEvent me) { + + select.add(Calendar.YEAR, -1); + + yearleft.setForeground(Color.WHITE); + + refresh(); + + } + + public void mouseReleased(MouseEvent me) { + + yearleft.setForeground(Color.BLACK); + + } + + }); + + yearright.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + yearright.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + yearright.setForeground(Color.RED); + + } + + public void mouseExited(MouseEvent me) { + + yearright.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + yearright.setForeground(Color.BLACK); + + } + + public void mousePressed(MouseEvent me) { + + select.add(Calendar.YEAR, 1); + + yearright.setForeground(Color.WHITE); + + refresh(); + + } + + public void mouseReleased(MouseEvent me) { + + yearright.setForeground(Color.BLACK); + + } + + }); + + monthleft.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + monthleft.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + monthleft.setForeground(Color.RED); + + } + + public void mouseExited(MouseEvent me) { + + monthleft.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + monthleft.setForeground(Color.BLACK); + + } + + public void mousePressed(MouseEvent me) { + + select.add(Calendar.MONTH, -1); + + monthleft.setForeground(Color.WHITE); + + refresh(); + + } + + public void mouseReleased(MouseEvent me) { + + monthleft.setForeground(Color.BLACK); + + } + + }); + + monthright.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + monthright.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + monthright.setForeground(Color.RED); + + } + + public void mouseExited(MouseEvent me) { + + monthright.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + monthright.setForeground(Color.BLACK); + + } + + public void mousePressed(MouseEvent me) { + + select.add(Calendar.MONTH, 1); + + monthright.setForeground(Color.WHITE); + + refresh(); + + } + + public void mouseReleased(MouseEvent me) { + + monthright.setForeground(Color.BLACK); + + } + + }); + + } + + private void updateDate() { + + center.setText(select.get(Calendar.YEAR) + "" + (select.get(Calendar.MONTH) + 1) + ""); + + } + + } + + private class JP2 extends JPanel { + + private static final long serialVersionUID = -8176264838786175724L; + + public JP2() { + + this.setPreferredSize(new Dimension(295, 20)); + + } + + protected void paintComponent(Graphics g) { + + g.setFont(font); + + g.drawString(" һ ڶ ", 5, 10); + + g.drawLine(0, 15, getWidth(), 15); + + } + + private void updateDate() { + + } + + } + + private class JP3 extends JPanel { + + private static final long serialVersionUID = 43157272447522985L; + + public JP3() { + + super(new GridLayout(6, 7)); + + this.setPreferredSize(new Dimension(295, 100)); + + initJP3(); + + } + + private void initJP3() { + + updateDate(); + + } + + public void updateDate() { + + this.removeAll(); + + lm.clear(); + + Date temp = select.getTime(); + + Calendar select = Calendar.getInstance(); + + select.setTime(temp); + + select.set(Calendar.DAY_OF_MONTH, 1); + + int index = select.get(Calendar.DAY_OF_WEEK); + + int sum = (index == 1 ? 8 : index); + + select.add(Calendar.DAY_OF_MONTH, 0 - sum); + + for (int i = 0; i < 42; i++) { + + select.add(Calendar.DAY_OF_MONTH, 1); + + lm.addLabel(new MyLabel(select.get(Calendar.YEAR), select.get(Calendar.MONTH), + select.get(Calendar.DAY_OF_MONTH))); + + } + + for (MyLabel my : lm.getLabels()) { + + this.add(my); + + } + + select.setTime(temp); + + } + + } + + private class MyLabel extends JLabel implements Comparator, MouseListener, MouseMotionListener { + + private static final long serialVersionUID = 3668734399227577214L; + + private int year, month, day; + + private boolean isSelected; + + public MyLabel(int year, int month, int day) { + + super("" + day, JLabel.CENTER); + + this.year = year; + + this.day = day; + + this.month = month; + + this.addMouseListener(this); + + this.addMouseMotionListener(this); + + this.setFont(font); + + if (month == select.get(Calendar.MONTH)) { + + this.setForeground(Color.BLACK); + + } else { + + this.setForeground(Color.LIGHT_GRAY); + + } + + if (day == select.get(Calendar.DAY_OF_MONTH)) { + + this.setBackground(new Color(160, 185, 215)); + + } else { + + this.setBackground(Color.WHITE); + + } + + } + + public boolean getIsSelected() { + + return isSelected; + + } + + public void setSelected(boolean b, boolean isDrag) { + + isSelected = b; + + if (b && !isDrag) { + + int temp = select.get(Calendar.MONTH); + + select.set(year, month, day); + + if (temp == month) { + + SwingUtilities.updateComponentTreeUI(jp3); + + } else { + + refresh(); + + } + + } + + this.repaint(); + + } + + protected void paintComponent(Graphics g) { + + if (day == select.get(Calendar.DAY_OF_MONTH) && month == select.get(Calendar.MONTH)) { + + // ǰѡ,ʾ + + g.setColor(new Color(160, 185, 215)); + + g.fillRect(0, 0, getWidth(), getHeight()); + + } + + if (year == now.get(Calendar.YEAR) && month == now.get(Calendar.MONTH) + && day == now.get(Calendar.DAY_OF_MONTH)) { + + // ں͵ǰһ,ú + + Graphics2D gd = (Graphics2D) g; + + gd.setColor(Color.RED); + + Polygon p = new Polygon(); + + p.addPoint(0, 0); + + p.addPoint(getWidth() - 1, 0); + + p.addPoint(getWidth() - 1, getHeight() - 1); + + p.addPoint(0, getHeight() - 1); + + gd.drawPolygon(p); + + } + + if (isSelected) {// ѡ˾ͻһ߿ + + Stroke s = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL, 1.0f, + new float[] { 2.0f, 2.0f }, 1.0f); + + Graphics2D gd = (Graphics2D) g; + + gd.setStroke(s); + + gd.setColor(Color.BLACK); + + Polygon p = new Polygon(); + + p.addPoint(0, 0); + + p.addPoint(getWidth() - 1, 0); + + p.addPoint(getWidth() - 1, getHeight() - 1); + + p.addPoint(0, getHeight() - 1); + + gd.drawPolygon(p); + + } + + super.paintComponent(g); + + } + + public boolean contains(Point p) { + + return this.getBounds().contains(p); + + } + + private void update() { + + repaint(); + + } + + public void mouseClicked(MouseEvent e) { + + } + + public void mousePressed(MouseEvent e) { + + isSelected = true; + + update(); + + } + + public void mouseReleased(MouseEvent e) { + + Point p = SwingUtilities.convertPoint(this, e.getPoint(), jp3); + + lm.setSelect(p, false); + + commit(); + + } + + public void mouseEntered(MouseEvent e) { + + } + + public void mouseExited(MouseEvent e) { + + } + + public void mouseDragged(MouseEvent e) { + + Point p = SwingUtilities.convertPoint(this, e.getPoint(), jp3); + + lm.setSelect(p, true); + + } + + public void mouseMoved(MouseEvent e) { + + } + + public int compare(MyLabel o1, MyLabel o2) { + + Calendar c1 = Calendar.getInstance(); + + c1.set(o1.year, o2.month, o1.day); + + Calendar c2 = Calendar.getInstance(); + + c2.set(o2.year, o2.month, o2.day); + + return c1.compareTo(c2); + + } + + } + + private class LabelManager { + + private List list; + + public LabelManager() { + + list = new ArrayList(); + + } + + public List getLabels() { + + return list; + + } + + public void addLabel(MyLabel my) { + + list.add(my); + + } + + public void clear() { + + list.clear(); + + } + + @SuppressWarnings("unused") + + public void setSelect(MyLabel my, boolean b) { + + for (MyLabel m : list) { + + if (m.equals(my)) { + + m.setSelected(true, b); + + } else { + + m.setSelected(false, b); + + } + + } + + } + + public void setSelect(Point p, boolean b) { + + // ϶,ҪŻһ,Ч + + if (b) { + + // ʾǷܷ,ñȽеıǩ,ܷصı־ǰһǩ + + // Ҫʾıǩҵ˾Ϳ + + boolean findPrevious = false, findNext = false; + + for (MyLabel m : list) { + + if (m.contains(p)) { + + findNext = true; + + if (m.getIsSelected()) { + + findPrevious = true; + + } else { + + m.setSelected(true, b); + + } + + } else if (m.getIsSelected()) { + + findPrevious = true; + + m.setSelected(false, b); + + } + + if (findPrevious && findNext) { + + return; + + } + + } + + } else { + + MyLabel temp = null; + + for (MyLabel m : list) { + + if (m.contains(p)) { + + temp = m; + + } else if (m.getIsSelected()) { + + m.setSelected(false, b); + + } + + } + + if (temp != null) { + + temp.setSelected(true, b); + + } + + } + + } + + } + + private class JP4 extends JPanel { + + private static final long serialVersionUID = -6391305687575714469L; + + public JP4() { + + super(new BorderLayout()); + + this.setPreferredSize(new Dimension(295, 20)); + + this.setBackground(new Color(160, 185, 215)); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); + + final JLabel jl = new JLabel(": " + sdf.format(new Date())); + + jl.setToolTipText("ѡ"); + + this.add(jl, BorderLayout.CENTER); + + jl.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + jl.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + jl.setForeground(Color.RED); + + } + + public void mouseExited(MouseEvent me) { + + jl.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + jl.setForeground(Color.BLACK); + + } + + public void mousePressed(MouseEvent me) { + + jl.setForeground(Color.WHITE); + + select.setTime(new Date()); + + refresh(); + + commit(); + + } + + public void mouseReleased(MouseEvent me) { + + jl.setForeground(Color.BLACK); + + } + + }); + + } + + private void updateDate() { + + } + + } + + public static void main(String[] args) { + + DateChooser dateChooser1 = DateChooser.getInstance("yyyy-MM-dd"); + + DateChooser dateChooser2 = DateChooser.getInstance("yyyy-MM-dd"); + + JTextField showDate1 = new JTextField("ѡ"); + + JLabel showDate2 = new JLabel("ѡ"); + + dateChooser1.register(showDate1); + + dateChooser2.register(showDate2); + + JFrame jf = new JFrame("ѡ"); + + jf.add(showDate1, BorderLayout.NORTH); + + jf.add(showDate2, BorderLayout.SOUTH); + + jf.pack(); + + jf.setLocationRelativeTo(null); + + jf.setVisible(true); + + jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + } + +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/rb012/SearchJComItem.java b/src/com/connor/rb/plm/rb012/SearchJComItem.java new file mode 100644 index 0000000..c6f9b56 --- /dev/null +++ b/src/com/connor/rb/plm/rb012/SearchJComItem.java @@ -0,0 +1,45 @@ +package com.connor.rb.plm.rb012; + +import java.util.List; +import java.util.Vector; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; + +public class SearchJComItem { + public static Object[] getNewmodel(String str, ComboBoxModel model) { + List v = new Vector(); + List v1 = new Vector(); + for (int k = 0; k < model.getSize(); k++) { + Object obj = model.getElementAt(k); + System.out.println("еitemֵΪ:" + obj.toString()); + if (obj != null) { + String item = obj.toString().toLowerCase(); + if (item.contains(str.toLowerCase())) { + v.add(model.getElementAt(k)); + } else { + v1.add(model.getElementAt(k)); + } + } else { + v1.add(model.getElementAt(k)); + } + } + for (int i = 0; i < v1.size(); i++) { + v.add(v1.get(i)); + } + if (v.isEmpty()) { + return v1.toArray(); + } + return v.toArray(); + } + + public static void changeBox(JComboBox comb, String str) { + ComboBoxModel model = comb.getModel(); + + Object[] newmodel = getNewmodel(str, model); + ComboBoxModel mod = new DefaultComboBoxModel(newmodel); + comb.setModel(mod); + } + +} diff --git a/src/com/connor/rb/plm/rb013one/Rb013Dialog.java b/src/com/connor/rb/plm/rb013one/Rb013Dialog.java new file mode 100644 index 0000000..74780a8 --- /dev/null +++ b/src/com/connor/rb/plm/rb013one/Rb013Dialog.java @@ -0,0 +1,74 @@ +package com.connor.rb.plm.rb013one; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.PropertyLayout; + +public class Rb013Dialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFApplication app; + private JButton okBtn; + private JButton celBtn; + private JLabel label; + + public Rb013Dialog(AbstractAIFApplication app) { + super(false); + this.app = app; + + } + + private void initUI() { + this.setTitle(""); + this.setSize(new Dimension(500, 500)); + this.okBtn = new JButton("ȷ"); + this.celBtn = new JButton("ȡ"); + this.setLayout(new BorderLayout()); + this.label = new JLabel("ǷҪ"); + label.setFont(new Font("Dialog", 0, 16)); + JPanel centerJPanel = new JPanel(new FlowLayout()); + centerJPanel.add(label); + JPanel southJPanel = new JPanel(new FlowLayout()); + southJPanel.add(okBtn); + southJPanel.add(celBtn); + okBtn.addActionListener(this); + celBtn.addActionListener(this); + this.add(centerJPanel, BorderLayout.NORTH); + this.add(southJPanel, BorderLayout.SOUTH); + this.centerToScreen(); + this.showDialog(); + + } + + @Override + public void run() { + this.initUI(); + } + + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource().equals(this.okBtn)) { + + Rb013Operation operation = new Rb013Operation(this.app); + TCSession session = RACUIUtil.getTCSession(); + session.queueOperation(operation); + this.disposeDialog(); + } else { + this.disposeDialog(); + } + + } + +} diff --git a/src/com/connor/rb/plm/rb013one/Rb013Handler.java b/src/com/connor/rb/plm/rb013one/Rb013Handler.java new file mode 100644 index 0000000..d9d9660 --- /dev/null +++ b/src/com/connor/rb/plm/rb013one/Rb013Handler.java @@ -0,0 +1,48 @@ +package com.connor.rb.plm.rb013one; + +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.rb.plm.rb013one.Rb013Dialog; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.util.MessageBox; + +public class Rb013Handler extends AbstractHandler { + private String[] types = { "RB3_BZJRevision", "RB3_GQRevision", "RB3_GZRevision", "RB3_YZRevision", + "RB3_GNZCRevision", "RB3_GNLBJRevision", "RB3_XZCPRevision", "RB3_LBJRevision", "RB3_ZCRevision", + "RB3_YCLRevision", "RB3_GZBJRevision", "RB3_GQBJRevision", "RB3_BZJBJRevision" + ,"RB3_ZYGYKRevision","RB3_HZZZGYKRevision","RB3_ZPGYKRevision","RB3_PFMEARevision","RB3_SSCKZJHRevision","MEOPRevision","MEProcessRevision","RB3_ZYJZSRevision" }; + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent comp = app.getTargetComponent(); + if (comp instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) comp; + String type = rev.getType(); + System.out.println("type==================" + type); + List typesList = Arrays.asList(types); + if (typesList.contains(type)) { + Rb013Dialog dialog = new Rb013Dialog(app); + new Thread(dialog).start(); + } else { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("qxzzchlbj013_display.TITLE"), "", MessageBox.ERROR); + return null; + } + } + return null; + } + +} diff --git a/src/com/connor/rb/plm/rb013one/Rb013Operation.java b/src/com/connor/rb/plm/rb013one/Rb013Operation.java new file mode 100644 index 0000000..cf84f3a --- /dev/null +++ b/src/com/connor/rb/plm/rb013one/Rb013Operation.java @@ -0,0 +1,190 @@ +package com.connor.rb.plm.rb013one; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.Locale; +import java.util.ResourceBundle; + +import com.alibaba.fastjson2.JSONObject; +import com.connor.rb.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.MessageBox; + +public class Rb013Operation extends AbstractAIFOperation { + + private AbstractAIFApplication app; + private TCSession session = RACUIUtil.getTCSession(); + + public Rb013Operation(String[] dataserURL, String[] fileNames) { + + } + + public Rb013Operation(AbstractAIFApplication app) { + this.app = app; + } + + @Override + public void executeOperation() throws Exception { + + InterfaceAIFComponent targetComp = app.getTargetComponent(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + + if (targetComp instanceof TCComponentItemRevision) { + try { + SoaServerUtil.openByPass(session); + TCComponentItemRevision rev = (TCComponentItemRevision) targetComp; + TCComponentItem item = rev.getItem(); + TCComponentItemRevision itemRev = item.getLatestItemRevision(); + String revId = itemRev.getProperty("item_revision_id"); + char letter = revId.charAt(0); + String stage = getStage(letter); + // int num = Integer.parseInt(String.valueOf(revId.charAt(1))); + int num = Integer.parseInt(String.valueOf(revId.substring(1, revId.length()))); + StringBuffer newRevId = new StringBuffer(); + newRevId.append(letter); + newRevId.append(++num); + + String name = itemRev.getStringProperty("object_name"); + + // ȡǰû + String userUID = session.getUser().getUid(); + // ȡǰ¼ + String groupUID = session.getGroup().getUid(); + + JSONObject json = new JSONObject(); + + json.put("targetRevUID", rev.getUid()); + json.put("userUID", userUID); + json.put("groupUID", groupUID); + json.put("name", name); + json.put("revId", newRevId.toString()); + + System.out.println("json" + json); + + // ȡѡ + String[] prefValues = session.getPreferenceService().getStringValues("RB3_ProcessOPReviseAddress"); + + if (prefValues != null && prefValues.length > 0) { + // ȡurl + String url = prefValues[0]; + + System.out.println("url" + url); + + String newRevUID = newRevUID(url, json); + + if (!"".equals(newRevUID)) { + // ȡ + TCComponent newRev = session.stringToComponent(newRevUID); + +// TCComponentItemRevision newRev = rev.saveAs(newRevId.toString()); + newRev.lock(); + newRev.setStringProperty("rb3_smzqzt", stage); + newRev.save(); + newRev.unlock(); + newRev.refresh(); + ((TCComponentItemRevision)newRev).getItem().refresh(); + MessageBox.post(rb.getString("sbcg13_display.TITLE"), "ɹ", MessageBox.INFORMATION); + } else { + MessageBox.post(rb.getString("xdsb01_display.TITLE"), "ʾ", MessageBox.INFORMATION); + } + } else { + MessageBox.post(rb.getString("xdsb01111_display.TITLE"), "ʾ", MessageBox.INFORMATION); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + SoaServerUtil.closeByPass(session); + } + + } else { + MessageBox.post(rb.getString("qxz13_display.TITLE"), "ʾ", MessageBox.INFORMATION); + } + + } + + // ȡ״̬ + public static String getStage(char letter) { + String stage = ""; + switch (letter) { + case 'A': + stage = ":Conceptual design"; + break; + case 'B': + stage = ":Product design"; + break; + case 'R': + stage = ":Process design/Sample delivery"; + break; + case 'P': + stage = "P:Pilot production/small batch"; + break; + case 'M': + stage = "M:Mass production"; + break; + case 'T': + stage = "T:Scrap"; + break; + } + return stage; + } + + /** + * ýӿ + * + * @param url_ip + * @param json + * @return + */ + public static String newRevUID(String url_ip, JSONObject json) { + try { + // ַ + URL url = new URL(url_ip); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("POST"); + conn.setRequestProperty("Content-Type", "application/json; utf-8"); + conn.setRequestProperty("Accept", "application/json"); + conn.setDoOutput(true); + + System.out.println("" + json); + // + try (OutputStream os = conn.getOutputStream()) { + byte[] input = json.toString().getBytes("utf-8"); + os.write(input, 0, input.length); + } + + // ȡӦ + int responseCode = conn.getResponseCode(); + System.out.println("Response Code: " + responseCode); + + // ȡӦ + BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8")); + String inputLine; + StringBuilder response = new StringBuilder(); + + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + + System.out.println(response.toString()); + + return response.toString(); + + } catch (Exception e) { + e.printStackTrace(); + return "Error: " + e.getMessage(); + } + } + +} diff --git a/src/com/connor/rb/plm/rb013one/test.java b/src/com/connor/rb/plm/rb013one/test.java new file mode 100644 index 0000000..0038147 --- /dev/null +++ b/src/com/connor/rb/plm/rb013one/test.java @@ -0,0 +1,23 @@ +/** + * + */ +package com.connor.rb.plm.rb013one; + +/** + * @author luuu + * @date 2021112 + */ +public class test { + public static void main(String[] args) { + char c1 = 'a'; + char c2 = 'v'; + int num = 2; + StringBuffer s = new StringBuffer(); + s.append(c1); + s.append(c2); + s.append(num++); + System.out.println(num); + System.out.println(s); + System.out.println(s.length()); + } +} diff --git a/src/com/connor/rb/plm/rb013two/Rb013Dialog.java b/src/com/connor/rb/plm/rb013two/Rb013Dialog.java new file mode 100644 index 0000000..60fa3ed --- /dev/null +++ b/src/com/connor/rb/plm/rb013two/Rb013Dialog.java @@ -0,0 +1,116 @@ +package com.connor.rb.plm.rb013two; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Locale; +import java.util.ResourceBundle; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class Rb013Dialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFApplication app; + private JButton okBtn; + private JButton celBtn; + private JLabel label; + private JComboBox cmb; + + public Rb013Dialog(AbstractAIFApplication app) { + super(false); + this.app = app; + + } + + private void initUI() { + + this.setTitle("汾"); + this.setSize(new Dimension(500, 500)); + this.okBtn = new JButton("ȷ"); + this.celBtn = new JButton("ȡ"); + this.setLayout(new BorderLayout()); + this.label = new JLabel("ѡ汾"); + label.setFont(new Font("Dialog", 0, 16)); + this.cmb = new JComboBox(); + cmb.addItem("A1"); + cmb.addItem("B1"); + cmb.addItem("R1"); + cmb.addItem("P1"); + cmb.addItem("M1"); + cmb.addItem("T1"); + JPanel centerJPanel = new JPanel(new PropertyLayout()); + centerJPanel.add("1.1.left.top", label); + centerJPanel.add("1.2.left.top", cmb); + JPanel southJPanel = new JPanel(new FlowLayout()); + southJPanel.add(okBtn); + southJPanel.add(celBtn); + okBtn.addActionListener(this); + celBtn.addActionListener(this); + this.add(centerJPanel, BorderLayout.NORTH); + this.add(southJPanel, BorderLayout.SOUTH); + this.centerToScreen(); + this.showDialog(); + + } + + // ȡ°汾id + public static String getRevId(AbstractAIFApplication app) { + String revId = ""; + InterfaceAIFComponent targetComp = app.getTargetComponent(); + if (targetComp instanceof TCComponentItem) { + try { + TCComponentItem item = (TCComponentItem) targetComp; + revId = item.getLatestItemRevision().getProperty("item_revision_id"); + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return revId; + + } else { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("qxzz13_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return null; + } + } + + @Override + public void run() { + this.initUI(); + + } + + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource().equals(this.okBtn)) { + String revId = (String) cmb.getSelectedItem(); + Rb013Operation operation = new Rb013Operation(this.app, revId); + TCSession session = RACUIUtil.getTCSession(); + session.queueOperation(operation); + this.disposeDialog(); + } else { + this.disposeDialog(); + } + + } + +} diff --git a/src/com/connor/rb/plm/rb013two/Rb013Handler.java b/src/com/connor/rb/plm/rb013two/Rb013Handler.java new file mode 100644 index 0000000..04ad3fc --- /dev/null +++ b/src/com/connor/rb/plm/rb013two/Rb013Handler.java @@ -0,0 +1,43 @@ +package com.connor.rb.plm.rb013two; + +import java.util.Locale; +import java.util.ResourceBundle; + +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.TCComponentItemRevision; +import com.teamcenter.rac.util.MessageBox; + +public class Rb013Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent comp = app.getTargetComponent(); + if (comp instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) comp; + String type = rev.getType(); + System.out.println("type==================" + type); + if ("RB3_LBJRevision".equals(type) || "RB3_ZCRevision".equals(type) || "RB3_YCLRevision".equals(type) + || "RB3_BZJRevision".equals(type) || "RB3_GZRevision".equals(type) || "RB3_GQRevision".equals(type) + || "RB3_GNZCRevision".equals(type) || "RB3_GNLBJRevision".equals(type) || "RB3_GYZYRevision".equals(type)) { + Rb013Dialog dialog = new Rb013Dialog(app); + new Thread(dialog).start(); + } else { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("gbcz13_display.TITLE"), "", MessageBox.ERROR); + return null; + } + } + + return null; + } + +} diff --git a/src/com/connor/rb/plm/rb013two/Rb013Operation.java b/src/com/connor/rb/plm/rb013two/Rb013Operation.java new file mode 100644 index 0000000..a03ad72 --- /dev/null +++ b/src/com/connor/rb/plm/rb013two/Rb013Operation.java @@ -0,0 +1,86 @@ +package com.connor.rb.plm.rb013two; + +import java.util.Locale; +import java.util.ResourceBundle; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.util.MessageBox; + +public class Rb013Operation extends AbstractAIFOperation { + + private AbstractAIFApplication app; + private String revId; + + public Rb013Operation(AbstractAIFApplication app, String revId) { + this.app = app; + this.revId = revId; + } + + public Rb013Operation(AbstractAIFApplication app) { + this.app = app; + } + + @Override + public void executeOperation() throws Exception { + InterfaceAIFComponent targetComp = app.getTargetComponent(); + // ȡʻ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (targetComp instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) targetComp; + TCComponentItem item = rev.getItem(); + TCComponentItemRevision itemRev = item.getLatestItemRevision(); + System.out.println(revId); +// if("T1".equals(revId)) { +// TCComponent[] reference = rev.getReferenceListProperty("structure_revisions"); +// if(reference != null && reference.length > 0) { +// MessageBox.post("ѡеİ汾´BOMͼΪT1汾", +// "ʾ",MessageBox.INFORMATION); +// return; +// } +// } + TCComponentItemRevision newRev = rev.saveAs(revId); + String stage = getStage(revId); + System.out.println("״̬Ϊ" + stage); + newRev.lock(); + newRev.setStringProperty("rb3_smzqzt", stage); + newRev.save(); + newRev.unlock(); + MessageBox.post(rb.getString("bbghcg13_display.TITLE"), "ɹ", MessageBox.INFORMATION); + + } else { + MessageBox.post(rb.getString("qxz13_display.TITLE"), "ʾ", MessageBox.INFORMATION); + } + } + + public static String getStage(String revId) { + String stage = ""; + switch (revId) { + case "A1": + stage = ":Conceptual design"; + break; + case "B1": + stage = ":Product design"; + break; + case "R1": + stage = ":Process design/Sample delivery"; + break; + case "P1": + stage = "P:Pilot production/small batch"; + break; + case "M1": + stage = "M:Mass production"; + break; + case "T1": + stage = "T:Scrap"; + break; + } + return stage; + } + +} diff --git a/src/com/connor/rb/plm/rb015/Rb015Handler.java b/src/com/connor/rb/plm/rb015/Rb015Handler.java new file mode 100644 index 0000000..d82ba68 --- /dev/null +++ b/src/com/connor/rb/plm/rb015/Rb015Handler.java @@ -0,0 +1,363 @@ +package com.connor.rb.plm.rb015; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.concurrent.TimeUnit; +import java.util.ArrayList; +import java.util.Arrays; + +import com.teamcenter.services.loose.core._2010_09.DataManagement.NameValueStruct1; +import com.teamcenter.services.loose.core._2010_09.DataManagement.PropInfo; +import com.teamcenter.services.loose.core._2010_09.DataManagement.SetPropertyResponse; +import com.teamcenter.services.loose.workflow.WorkflowService; +import com.teamcenter.services.loose.workflow._2014_06.Workflow; +import com.teamcenter.services.loose.workflow._2014_06.Workflow.ApplySignatureInput; +import com.teamcenter.services.loose.workflow._2014_06.Workflow.PerformActionInputInfo; + +import org.apache.axis2.jaxws.handler.HandlerChainProcessor; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; + +import com.connor.rb.plm.rb022.Rb022Dialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.ServiceData; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.workflow.processdesigner.WorkflowDesignerService; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.exceptions.NotLoadedException; +import com.teamcenter.soaictstubs.stringSeq_tHolder; + +public class Rb015Handler extends AbstractHandler { + private Map> privilegedItemToTypes = new HashMap(); + private List privilegedUsers = new ArrayList(); + private boolean Auto = false; + private boolean Auto2 = false; + + @Override + public Object execute(ExecutionEvent arg0) { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + TCSession session = (TCSession) app.getSession(); + TCPreferenceService service = session.getPreferenceService(); + TCComponentGroup group = session.getCurrentGroup(); + + System.out.println("ѡеΪ" + targetComponent.getType()); + // System.out.println("====>"+String.valueOf(new + // SimpleDateFormat("yyyyMMddHHmmssSSS") .format(new Date() ))); + + // ȡʻ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); +// String[] strs = service.getStringValues("RB3_group_permission"); +// List groupList = Arrays.asList(strs); +// try { +//// String groupName = group.getGroupName(); +// String groupName = group.getTCProperty("name").getStringValue(); +// System.out.println("groupName============"+groupName); +// if(!(groupList.contains(groupName))) { +// MessageBox.post("ûдӡȨ,ϵԱ","ʾ",MessageBox.INFORMATION); +// return null; +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + if (targetComponent instanceof TCComponentDataset) { + + TCComponentDataset dataset = (TCComponentDataset) targetComponent; + + // ȡӡڵͣʱ䣬Զͨ + HandlerProcess(session, dataset.getUid()); + + if (service.getStringValues("RB_Allow_Print_User") != null) { + privilegedUsers = Arrays.asList(service.getStringValues("RB_Allow_Print_User"));// Ȩû + } else { + System.out.println("ȨûѡRB_Allow_Print_Userδ"); + } + if (service.getStringValues("RB_Limit_Print_ItemToType") != null) {// ƶµݼ + String[] values = service.getStringValues("RB_Limit_Print_ItemToType"); + for (String value : values) { + if (value.contains(":")) { + List val = new ArrayList(); + String val1 = value.split(":")[0]; + String val2 = value.split(":")[1]; + if (val2.contains("*")) { + val.add("*"); + } else if (val2.contains(";")) { + for (String v : val2.split(";")) { + val.add(v); + } + } else if (val2 != null) { + val.add(val2); + } + privilegedItemToTypes.put(val1, val); + } + } + } else { + System.out.println("ƶѡRB_Limit_Print_ItemToTypeδ"); + } + + try { + System.out.println("----жȨû---"); + boolean isPrivilege = false; + if (privilegedUsers.size() > 0 && privilegedUsers.contains(session.getUser().getUserId())) { + isPrivilege = true;// Ȩû + } else if (!getItemPrivilege(session, dataset)) { + isPrivilege = true;// Ȩݼ + } else if (getFlowPrivilege(session, dataset)) { + isPrivilege = true;// ̽ڵ㣬ͨ׼ + } +// else if(group.toDisplayString().equals("dbas")) { +// isPrivilege=true;//dba +// } +// if(privilegedUsers!=null&&privilegedUsers.size()>0) { +// +// privilegedUsers.clear(); +// } +// if(privilegedItemToTypes!=null&&privilegedItemToTypes.size()>0) { +// privilegedItemToTypes.clear(); +// } +// System.out.println("ݣ"); + if (isPrivilege) { + String userName = session.getUser().getUserId().toUpperCase(); + System.out.println("----شӡ----"); + Rb015Operation opeartion = new Rb015Operation(dataset, userName); + session.queueOperation(opeartion); + + } else { + if (Auto) { + MessageBox.post(rb.getString("lcygq15_display.TITLE"), "ʾ", MessageBox.INFORMATION); + } else if (Auto2) { + MessageBox.post(rb.getString("lcz15_display.TITLE"), "ʾ", MessageBox.INFORMATION); + } else { + MessageBox.post(rb.getString("xddxxdsjj15_display.TITLE"), "ʾ", MessageBox.INFORMATION); + } + + return null; + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + + MessageBox.post(rb.getString("qxzsjjdxjxcz15_display.TITLE"), "ʾ", MessageBox.INFORMATION); + + return null; + } + return null; + } + + /** + * ÿδ򿪶ж̽ڵǷ񳬹 + * + * @param session + * @param uid + */ + private void HandlerProcess(TCSession session, String uid) { + + try { + TCComponentDataset comp = (TCComponentDataset) session.stringToComponent(uid); + if (comp != null) { + TCComponent[] items = comp.getRelatedComponents("process_stage_list"); + for (int i = 0; i < items.length; i++) { + if (items[i].getPropertyDisplayableValue("object_name").indexOf("A19_ݼӡ") >= 0) { + TCComponent tar = items[i].getRelatedComponent("fnd0ActuatedInteractiveTsks");// ȡ̵Ľڵ + if ("ӡڵ".equals(tar.getPropertyDisplayableValue("object_name"))) { + Date reworkDate = items[i].getDateProperty("last_mod_date"); + System.out.println("Date===>" + reworkDate); + + Date endTime = new Date(System.currentTimeMillis()); // ȡǰʱ + long s = endTime.getTime() - reworkDate.getTime(); // endeTimestartTimeҪʱ + TimeUnit time = TimeUnit.DAYS; + long days = time.convert(s, TimeUnit.MILLISECONDS); // days + System.out.println("days===>" + days); + if (days > 3) { + System.out.println("----Զ------"); + AutoSignServer(tar.getUid(), session); + Auto = true; + } + } + + } + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + } + + /** + * ȡ̽ڵȨ + * + * @param session + * @param dataset + * @return + * @throws TCException + */ + public boolean getFlowPrivilege(TCSession session, TCComponentDataset dataset) throws TCException { + boolean isPrivilege = false; + try { + isPrivilege = isTargetTask(session, dataset.getUid()); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return isPrivilege; + } + + /** + * ȡöȨ + * + * @param session + * @param dataset + * @return + * @throws TCException + */ + public boolean getItemPrivilege(TCSession session, TCComponentDataset dataset) throws TCException { + boolean isPrivilege = false; + + if (privilegedItemToTypes == null || privilegedItemToTypes.size() <= 0) { + System.out.println("ƶµȨݼδ"); + } + // ȡݼĶ + AIFComponentContext[] contexts = dataset.whereReferenced(); + for (AIFComponentContext context : contexts) { + String itemType = context.getComponent().getType(); + if (privilegedItemToTypes.containsKey(itemType)) { + if (privilegedItemToTypes.get(itemType).contains(dataset.getType()) + || privilegedItemToTypes.get(itemType).contains(dataset.getDisplayType()) + || privilegedItemToTypes.get(itemType).contains("*")) { + isPrivilege = true; + break; + } + } + } + + return isPrivilege; + } + + // ǷǴӡڵ + public boolean isTargetTask(TCSession session, String uid) { + try { + TCComponentDataset comp = (TCComponentDataset) session.stringToComponent(uid); + if (comp != null) { +// ModelObject[] items = comp +// .getRelatedComponents("process_stage_list"); + TCComponent[] items = comp.getRelatedComponents("process_stage_list"); + for (int i = 0; i < items.length; i++) { + System.out.println("===>" + items[i].getPropertyDisplayableValue("object_name")); + if (items[i].getPropertyDisplayableValue("object_name").indexOf("A19_ݼӡ") >= 0) { + System.out.println("====>" + items[i].getStringProperty("task_type")); + TCComponent tar = items[i].getRelatedComponent("fnd0ActuatedInteractiveTsks");// ȡ̵Ľڵ + System.out.println("ڵ====>" + tar.getPropertyDisplayableValue("object_name")); + if ("ӡڵ".equals(tar.getPropertyDisplayableValue("object_name"))) { + // жͣڵ + return true; + } else { + Auto2 = true; + } + + } + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return false; + } + + /** + * Զ̽ڵ㣬 + * + * @param uid̽ڵuid + * @param session + * @throws TCException + */ + public void AutoSignServer(String uid, TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[2]; + obj[0] = session.getUser().getUid(); + obj[1] = uid; + // Object comp = obj[1] = + userservice.call("RB_AutoSignServer", obj); + System.out.println("=========uid" + obj[0] + "=======" + obj[1]); + } + +// /** +// * Do +// * +// * @param doTask +// * @throws ServiceException +// */ +// public static void completedDoTask(TCComponent doTask,TCSession session) throws ServiceException { +//// // Set Completed +//// com.teamcenter.services.loose.core.DataManagementService dmService = com.teamcenter.services.loose.core.DataManagementService +//// .getService(session.getSoaConnection()); +//// PropInfo[] info = new PropInfo[1]; +//// info[0] = new PropInfo(); +//// info[0].timestamp = Calendar.getInstance(); +//// info[0].object = doTask; +//// info[0].vecNameVal = new NameValueStruct1[1]; +//// info[0].vecNameVal[0] = new NameValueStruct1(); +//// info[0].vecNameVal[0].name = "task_result"; +//// info[0].vecNameVal[0].values = new String[] { "Completed" }; +//// +//// String[] options = new String[1]; +//// options[0] = "ENABLE_PSE_BULLETIN_BOARD"; +//// +//// SetPropertyResponse response = dmService.setProperties(info, options); +//// TCServiceExceptionUtils.validateServiceException(response.data); +////// +//// // Apply +//// WorkflowService wfService = WorkflowService.getService(session.getSoaConnection()); +//// ApplySignatureInput[] signatures = new ApplySignatureInput[1]; +//// signatures[0] = new ApplySignatureInput(); +//// ServiceData serviceData = (ServiceData) wfService.performActionWithSignature(doTask, "SOA_EPM_complete_action", "", null, +//// "SOA_EPM_completed", null, signatures); +//// TCServiceExceptionUtils.validateServiceException(serviceData); +// +// WorkflowService.getService(session.getSoaConnection()).performAction((TCComponentTask) doTask, "SOA_EPM_complete_action", +// "SOA complete.", null, "SOA_EPM_completed", null); +// +//// PerformActionInputInfo[] infos = new Workflow.PerformActionInputInfo[1]; +//// PerformActionInputInfo info = new Workflow.PerformActionInputInfo(); +//// info.clientId = "AppX_Perform"; +//// info.action = "SOA_EPM_approve_action"; +//// info.supportingValue = "SOA_EPM_approve"; +//// info.actionableObject = doTask; +//// info.supportingObject = ;// +////// Map propertyNameValues = new HashMap(); +////// propertyNameValues.put("comments",new String[]{taskRemark}); +////// info.propertyNameValues = propertyNameValues; +//// (ModelObject) (infos[0] = info); +//// ServiceData sData1 = wfService.performAction3(infos); +// } + +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/rb015/Rb015Operation.java b/src/com/connor/rb/plm/rb015/Rb015Operation.java new file mode 100644 index 0000000..e10f4db --- /dev/null +++ b/src/com/connor/rb/plm/rb015/Rb015Operation.java @@ -0,0 +1,562 @@ +package com.connor.rb.plm.rb015; + +import java.awt.AlphaComposite; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; +import java.awt.print.PageFormat; +import java.awt.print.Paper; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; +import java.util.ResourceBundle; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; + +import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException; +import org.apache.pdfbox.printing.PDFPrintable; + +import com.lowagie.text.Element; +import com.lowagie.text.pdf.BaseFont; +import com.lowagie.text.pdf.PdfContentByte; +import com.lowagie.text.pdf.PdfGState; +import com.lowagie.text.pdf.PdfReader; +import com.lowagie.text.pdf.PdfStamper; +import com.spire.doc.Document; +import com.spire.doc.FileFormat; +import com.spire.doc.TextWatermark; +import com.spire.doc.documents.WatermarkLayout; +import com.spire.xls.ViewMode; +import com.spire.xls.Workbook; +import com.spire.xls.Worksheet; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class Rb015Operation extends AbstractAIFOperation { + + private TCComponentDataset dataset; + private int statu = 0; + private String username = ""; + private String waterPath = "";// ˮӡPDF· + // private PdfTrueTypeFont font1 = new PdfTrueTypeFont(new Font ("Microsoft + // YaHei", Font.PLAIN, 45), true); + + public Rb015Operation(TCComponentDataset dataset, String username) { + this.dataset = dataset; + this.username = username; + + } + + @Override + public void executeOperation() throws Exception { + // ȡʻ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + try { + final File[] files = dataset.getFiles(""); + String type = dataset.getType(); + System.out.println("type=============" + type); + // printFileAction(files[0]); + if ("MSWordX".equals(type) || "MSWord".equals(type)) { + // printFileAction();(files[0]); + printWORD(files[0].getAbsolutePath()); + files[0].delete(); + } else if ("PDF".equals(type)) { + // statu = printPDF(files[0]); + new Runnable() { + public void run() { + statu = printPDF2(files[0].getAbsolutePath()); + } + }.run(); + + // files[0].delete(); + + } else if ("MSExcelX".equals(type) || "MSExcel".equals(type)) { + statu = printExcel(files[0]); + files[0].delete(); + } + + if (statu != 0) { + if (statu == -1) { + new saveFile(waterPath, dataset.getStringProperty("object_name")); + + } else { + if (new File(waterPath).exists()) { + new File(waterPath).delete(); + } + MessageBox.post(rb.getString("dycg15_display.TITLE"), "ʾ", MessageBox.INFORMATION); + } + + } + + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(rb.getString("dysb15_display.TITLE"), "ʾ", MessageBox.INFORMATION); + } + } + + // ӡword + public int printWORD(String path) { +// //ˮӡ +// WORDaddWatermark(path,this.username); + // ĵ + Document doc = new Document(); + doc.loadFromFile(path); + int statu = 0; + PrinterJob loPrinterJob = PrinterJob.getPrinterJob(); + PageFormat loPageFormat = loPrinterJob.defaultPage(); + // ôӡֽŴС + Paper loPaper = loPageFormat.getPaper(); +// loPaper.setSize(600, 500); +// loPageFormat.setPaper(loPaper); + // ɾĬҳ߾ + loPaper.setImageableArea(0, 0, loPageFormat.getWidth(), loPageFormat.getHeight()); +// //ôӡ +// loPrinterJob.setCopies(1); +// loPrinterJob.setPrintable((Printable) doc, loPageFormat); + // ôӡԻ + if (loPrinterJob.printDialog()) { + // ִдӡ + try { + loPrinterJob.print(); + statu = 1; + + } catch (PrinterException e) { + e.printStackTrace(); + } + } + return statu; + } + + // ӡPDF + public int printPDF2(String path) { + System.out.println("path================" + path); + + // ȡݼö,жǷȷͼеĻͲˮӡ + boolean isQRT = false; + try { + AIFComponentContext[] contexts = dataset.whereReferenced(); + for (AIFComponentContext context : contexts) { + if (context.getComponent().getType().contains("RB3_QRT")) { + isQRT = true; + break; + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + if (!isQRT) {// ȷͼˮӡ + // ++++Ŀˮӡ + try { + String systitem = new SimpleDateFormat("yyyyMMdd-HHmmss").format(new Date()); + waterPath = System.getProperty("java.io.tmpdir") + "\\" + systitem + ".pdf"; + addWaterMark(path, waterPath, this.username, 2); + if (new File(path).exists()) { + new File(path).delete(); + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + waterPath = path; + } +// + + // ++++ + File file = new File(waterPath); + int statu = 0; + try { + System.out.println("=====ִдӡ======="); + PDDocument document = PDDocument.load(file); + // سɴӡļ + PDFPrintable printable = new PDFPrintable(document); + PrinterJob job = PrinterJob.getPrinterJob(); + job.setPrintable(printable); + if (job.printDialog()) { + System.out.println("ӡ===>" + job.getJobName()); + job.print(); + statu = 1; + document.close(); + // new saveFile(path,"name"); + // file.deleteOnExit(); + // file.delete(); + } else { + // new saveFile(path,"name"); + document.close(); + statu = -1; + // file.deleteOnExit(); + // file.delete(); + } + } catch (InvalidPasswordException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (PrinterException e) { + e.printStackTrace(); + } finally { +// if(file.exists()) { +// file.delete(); +// } +// + } + System.out.println("=======ӡ======="); + + return statu; + } +// private int printPDF(File file) { +// int statu = 0; +// PdfDocument document = new PdfDocument(); +// document.loadFromFile(file.getAbsolutePath()); +// // PrinterJob +// PrinterJob printerJob = PrinterJob.getPrinterJob(); +// +// //ָӡҳΪĬϴСͷ +// PageFormat pageFormat = printerJob.defaultPage(); +// +// //شӡѡ +// Paper paper = pageFormat.getPaper(); +// paper.setImageableArea(0, 0, pageFormat.getWidth(), pageFormat.getHeight()); +// pageFormat.setPaper(paper); +// printerJob.setCopies(1); +// printerJob.setPrintable(document, pageFormat); +// if(printerJob.printDialog()) +// { +// +// //ִдӡ +// try { +// printerJob.print(); +// statu = 1; +// } catch (PrinterException e) { +// e.printStackTrace(); +// } +// } +// return statu; +// } + + private int printExcel(File file) { + // EXCELˮӡ + EXCELaddWatermark(file.getAbsolutePath(), this.username); + // ӡExcelļ + int statu = 0; + Workbook workbook = new Workbook(); + workbook.loadFromFile(file.getAbsolutePath()); + + // PrinterJob + PrinterJob printerJob = PrinterJob.getPrinterJob(); + + // ָӡҳΪĬϴСͷ + PageFormat pageFormat = printerJob.defaultPage(); + + // شӡѡ + Paper paper = pageFormat.getPaper(); + paper.setImageableArea(0, 0, pageFormat.getWidth(), pageFormat.getHeight()); + pageFormat.setPaper(paper); + printerJob.setCopies(1); + printerJob.setPrintable(workbook, pageFormat); + if (printerJob.printDialog()) { + // ִдӡ + try { + printerJob.print(); + statu = 1; + } catch (PrinterException e) { + e.printStackTrace(); + } + } + return statu; + } + + // WORDˮӡ + private void WORDaddWatermark(String path, String waterMark) { + Document document = new Document(); + document.loadFromFile(path); + TextWatermark txtWatermark = new TextWatermark(); + txtWatermark.setText(waterMark); + txtWatermark.setFontSize(40); + txtWatermark.setColor(Color.gray); + txtWatermark.setLayout(WatermarkLayout.Diagonal); + document.getSections().get(0).getDocument().setWatermark(txtWatermark); + document.saveToFile(path, FileFormat.Docx); + } + + // EXCELˮӡ + private void EXCELaddWatermark(String path, String waterMark) { + // Excelĵ + Workbook wb = new Workbook(); + wb.loadFromFile(path); + // ıС + Font font = new Font("", Font.PLAIN, 55); + System.out.println("====>" + wb.getWorksheets().getCount()); + for (int i = 0; i < wb.getWorksheets().getCount(); i++) { + Worksheet sheet = wb.getWorksheets().get(i); + // DrawText() ͼƬ + BufferedImage imgWtrmrk = EXCELinsertWatermark(waterMark, font, Color.black, Color.white, + sheet.getPageSetup().getPageHeight(), sheet.getPageSetup().getPageWidth()); + + // ͼƬΪҳü + sheet.getPageSetup().setCenterHeaderImage(imgWtrmrk); + sheet.getPageSetup().setCenterHeader("&G"); + + // ʾģʽΪLayout + sheet.setViewMode(ViewMode.Layout); + } + // ĵ + wb.saveToFile(path); + // wb.saveToFile(path); + Worksheet sheetRemove = wb.getWorksheets().get(wb.getActiveSheetIndex());// ɾˮӡһҳ + sheetRemove.remove(); + wb.saveToFile(path); + } + + // EXCELˮӡ + private BufferedImage EXCELinsertWatermark(String text, Font font, Color textColor, Color backColor, double height, + double width) { + // ͼƬȺ͸߶ + BufferedImage img = new BufferedImage((int) width, (int) height, 2); + + Graphics2D loGraphic = img.createGraphics(); + // ȡısize + FontMetrics loFontMetrics = loGraphic.getFontMetrics(font); + int liStrWidth = loFontMetrics.stringWidth(text); + int liStrHeight = loFontMetrics.getHeight(); + + // ıʾʽλ + loGraphic.setColor(backColor); + loGraphic.fillRect(0, 0, (int) width, (int) height); + loGraphic.translate(((int) width - liStrWidth) / 2, ((int) height - liStrHeight) / 2); + // loGraphic.rotate(Math.toRadians(-45)); + loGraphic.translate(-((int) width - liStrWidth) / 2, -((int) height - liStrHeight) / 2); + loGraphic.setFont(font); + loGraphic.setColor(textColor); + loGraphic.shear(0.1, -0.3);// б + loGraphic.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.3f));// 1.0fΪ͸ ֵ0-1.0αò͸ + loGraphic.drawString(text, ((int) width - liStrWidth) / 25, ((int) height - liStrHeight) / 2); + loGraphic.drawString(text, (((int) width - liStrWidth) / 25) * 15, ((int) height - liStrHeight) / 2); + loGraphic.drawString(text, ((int) width - liStrWidth) / 25, (((int) height - liStrHeight) / 2) * 2); + loGraphic.drawString(text, (((int) width - liStrWidth) / 25) * 15, (((int) height - liStrHeight) / 2) * 2); +// loGraphic.drawString(text, ((int) width - liStrWidth) /20 , ((int) height - liStrHeight) /2); +// loGraphic.drawString(text, (((int) width - liStrWidth) /20)*11 , ((int) height - liStrHeight) /2); +// loGraphic.drawString(text, ((int) width - liStrWidth) /20 , (((int) height - liStrHeight) /6)*5); +// loGraphic.drawString(text, (((int) width - liStrWidth) /20)*11 , (((int) height - liStrHeight) /6)*5); + + loGraphic.dispose(); + return img; + } + + public void addWaterMark(String srcPdfPath, String tarPdfPath, String WaterMarkContent, int numberOfPage) + throws Exception { + PdfReader reader = new PdfReader(srcPdfPath); + PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(tarPdfPath)); + PdfGState gs = new PdfGState(); + + // + // BaseFont font = BaseFont.createFont("STSong-Light","UniGB-UCS2-H", + // BaseFont.NOT_EMBEDDED); +// BaseFont base = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.EMBEDDED); + BaseFont base = BaseFont.createFont("C:\\Windows\\Fonts\\SIMHEI.TTF", BaseFont.IDENTITY_H, + BaseFont.NOT_EMBEDDED); + // ͸ + gs.setFillOpacity(0.4f); + + int total = reader.getNumberOfPages() + 1; + PdfContentByte content; + for (int i = 1; i < total; i++) { + content = stamper.getOverContent(i); + content.beginText(); + content.setGState(gs); + // ˮӡɫ + content.setColorFill(Color.GRAY); + // ˮӡʽʹС + content.setFontAndSize(base, 50);// С + // ˮӡ ѭÿҳ + for (int j = 0; j < numberOfPage; j++) { + content.showTextAligned(Element.ALIGN_CENTER, WaterMarkContent, 200, 300 * (j + 1), 25);// IJб + content.showTextAligned(Element.ALIGN_CENTER, WaterMarkContent, 450, 300 * (j + 1), 25); + } + content.endText(); + } + reader.close();// ر + stamper.close(); + + System.out.println("PDFˮӡɣ"); + } + +} + +// +class saveFile extends JFrame { + // ؼ + private JPanel mainPanel; + private JFileChooser jfc; + private JButton okButton; + private JButton celButton; + private JButton pictureButton; + private JButton fileButton; + private JTextField pathText; + private JTextField fleName; + private String path; + private String datasetName; + + public saveFile(String path, String datasetName) { + this.path = path; + this.datasetName = datasetName; + init(); + } + + private void init() { + this.setAlwaysOnTop(true); + System.out.println("copyPath:" + path); + this.setTitle("ѡ񱣴ַ"); + this.setPreferredSize(new Dimension(480, 230)); + Toolkit toolkit = Toolkit.getDefaultToolkit(); + int x = (int) (toolkit.getScreenSize().getWidth() - this.getWidth()) / 3; + + int y = (int) (toolkit.getScreenSize().getHeight() - this.getHeight()) / 3; + + this.setLocation(x, y); + this.okButton = new JButton(""); + this.okButton.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + + @Override + public void actionPerformed(ActionEvent e) { + copy(new File(path), new File(pathText.getText() + "\\" + fleName.getText())); + new File(path).delete(); + // ȡʻ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + + MessageBox.post(rb.getString("lccg15_display.TITLE"), "ʾ", MessageBox.INFORMATION); + dispose(); + } + }); + this.celButton = new JButton("ȡ"); + this.celButton.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + + @Override + public void actionPerformed(ActionEvent e) { + new File(path).delete(); + dispose(); + } + }); + FileSystemView fsv = FileSystemView.getFileSystemView(); + File com = fsv.getHomeDirectory(); + this.fileButton = new JButton("..."); + this.fileButton.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + jfc = new JFileChooser(); + jfc.setCurrentDirectory(new File(com.getPath()));// ļѡijʼĿ¼Ϊd + jfc.setFileSelectionMode(1);// 趨ֻѡļ + int state = jfc.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jfc.getSelectedFile();// fΪѡ񵽵Ŀ¼ + pathText.setText(f.toString()); + } + } + }); + this.pathText = new JTextField(); + pathText.setText(com.getPath()); + this.pathText.setPreferredSize(new Dimension(300, 30)); + fleName = new JTextField(); + fleName.setText(datasetName); + this.fleName.setPreferredSize(new Dimension(300, 30)); + JLabel label = new JLabel("ļ"); + label.setPreferredSize(new Dimension(100, 30)); + JLabel label2 = new JLabel("ѡļ"); + label2.setPreferredSize(new Dimension(100, 30)); + JPanel panel1 = new JPanel(new FlowLayout()); + panel1.add(label); + panel1.add(fleName); + JPanel panel2 = new JPanel(new FlowLayout()); + panel2.add(label2); + panel2.add(pathText); + panel2.add(fileButton); + this.mainPanel = new JPanel(new PropertyLayout()); + + this.mainPanel.add("1.1.left.top", panel1); + this.mainPanel.add("2.1.left.top", panel2); + + JPanel rootPanel = new JPanel(new FlowLayout()); + rootPanel.add(new JLabel(" ")); + rootPanel.add(this.okButton); + rootPanel.add(new JLabel(" ")); + rootPanel.add(this.celButton); + + this.setLayout(new BorderLayout()); + this.add(mainPanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + testTimer01(this); + } + + public void testTimer01(saveFile d) { + Timer timer = new Timer(); + TimerTask timerTask = new TimerTask() { + @Override + public void run() { + d.setAlwaysOnTop(false); + System.out.println("ȡö"); + } + }; + timer.schedule(timerTask, 500); + }// 5000Ϊ5 + + public void copy(File oldFile, File newFile) { + + try (InputStream in = new FileInputStream(oldFile); OutputStream out = new FileOutputStream(newFile)) { + + byte[] arr = new byte[1024]; + int len; + while ((len = in.read(arr)) != -1) { + out.write(arr, 0, len); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/com/connor/rb/plm/rb015/TCServiceExceptionUtils.java b/src/com/connor/rb/plm/rb015/TCServiceExceptionUtils.java new file mode 100644 index 0000000..c295e99 --- /dev/null +++ b/src/com/connor/rb/plm/rb015/TCServiceExceptionUtils.java @@ -0,0 +1,36 @@ +package com.connor.rb.plm.rb015; + +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; +import com.teamcenter.soa.client.model.ErrorStack; +import com.teamcenter.soa.client.model.ErrorValue; +import com.teamcenter.soa.client.model.ServiceData; + +public final class TCServiceExceptionUtils { + + private TCServiceExceptionUtils() { + } + + public static void validateServiceException(ServiceData serviceData) throws ServiceException { + if (serviceData.sizeOfPartialErrors() > 0) { + + StringBuffer buffer = new StringBuffer(); + int size = serviceData.sizeOfPartialErrors(); + + for (int i = 0; i < size; ++i) { + ErrorStack stack = serviceData.getPartialError(i); + ErrorValue[] errorValues = stack.getErrorValues(); + if (errorValues != null) { + for (ErrorValue errorValue : errorValues) { + String code = errorValue.getCode() + ""; + String level = errorValue.getLevel() + ""; + String msg = errorValue.getMessage(); + buffer.append("code:" + code + ", level:" + level + ", msg:" + msg + "\r\n"); + } + } + + } + + throw new ServiceException("returned a partial error.\n" + buffer.toString()); + } + } +} diff --git a/src/com/connor/rb/plm/rb016/BomCheckSaveCommand.java b/src/com/connor/rb/plm/rb016/BomCheckSaveCommand.java new file mode 100644 index 0000000..28f346f --- /dev/null +++ b/src/com/connor/rb/plm/rb016/BomCheckSaveCommand.java @@ -0,0 +1,206 @@ +package com.connor.rb.plm.rb016; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import org.apache.commons.lang.ObjectUtils.Null; +import org.apache.commons.lang.StringUtils; + +import com.aspose.cad.internal.ay.iF; +import com.itextpdf.text.pdf.PdfStructTreeController.returnType; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.pse.common.InterfaceBOMEditingApplication; +import com.teamcenter.rac.pse.operations.SaveBOMOperation; +import com.teamcenter.rac.util.MessageBox; + +public class BomCheckSaveCommand extends AbstractAIFCommand { + // private HashMap> propConifg; + private HashMap> forbidConifg; + // private HashMap> exclusiveConifg; + // private HashMap> exclOtherConifg;// + // private final String OPTION_NAME = "LP_bomSaveConfiger"; + private final String FORBID_NAME = "LP_bomSaveForbidConfiger"; + // private final String EXCLUSIVE_NAME = "LP_bomSaveExclusiveConfiger"; + private final String TYPE_NAME = "LP_bomSaveREVTypeConfiger"; + private String id = ""; + + public BomCheckSaveCommand(InterfaceBOMEditingApplication interfacebomeditingapplication) { + try { + // ޷BOM + System.out.println("=========BomCheckSaveCommand========="); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + TCComponentBOMLine topBomLine = interfacebomeditingapplication.getTopBOMLine(); + System.out.println("id:"+topBomLine.getItem().getStringProperty("item_id")); + //߼ bomжǷ"LS-"Ͽͷ + if(checkBOMIsStartLS(topBomLine,"LS-")) { + MessageBox.post(id + rb.getString("bomwfbclswl_display.TITLE"), "", MessageBox.ERROR); + return; + } + System.out.println("УǷLS-"+checkBOMIsStartLS(topBomLine,"LS-")); + TCComponentItemRevision itemRev = topBomLine.getItemRevision(); + + // topBomLineж + String smzq = itemRev.getStringProperty("rb3_smzqzt"); + String lswl = itemRev.getStringProperty("rb3_lswlbs"); + if(smzq!=null && lswl!=null){ + if (smzq.trim().equals("Scrap") || lswl.trim().equals("Temporary")) { + MessageBox.post(AIFUtility.getActiveDesktop(),rb.getString("bomzczbf16_display.TITLE"), "", MessageBox.ERROR); + return; + } + + // ж + if (!rule(topBomLine)) { + return; + } + } + + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + SaveBOMOperation savebomoperation = new SaveBOMOperation(interfacebomeditingapplication); + interfacebomeditingapplication.getSession().queueOperation(savebomoperation); + } + + /** + * @Title: checkBOMIsStartLS + * @Description: TODO(һ仰) + * @param @param topBomLine + * @param @param string + * @param @return + * @return boolean + * @throws TCException + * @throws + */ + private boolean checkBOMIsStartLS(TCComponentBOMLine topBomLine, String string) throws TCException { + // TODO Auto-generated method stub + String stringProperty = topBomLine.getItem().getStringProperty("item_id"); + System.out.print("ʼȽ"+stringProperty+"Ƿ"+string+"ͷ"); + if(stringProperty != null && stringProperty.startsWith(string)){ + System.out.println("У鲻ͨ"); + id = stringProperty; + return true; + } + if(topBomLine.hasChildren()) { + for(AIFComponentContext bomLine : topBomLine.getChildren()) { + TCComponentBOMLine component = (TCComponentBOMLine)bomLine.getComponent(); + if(checkBOMIsStartLS(component, string)) { // ݹõķֵ + return true; // һƥ䣬 + } + } + } + return false; + } + + // ݹж + public boolean rule(TCComponentBOMLine topBomLine) { + boolean res = true; + + try { + AIFComponentContext[] lines = topBomLine.getChildren(); + if (lines != null && lines.length != 0) { + for (AIFComponentContext aif : lines) { + if (!res) { + return res; + } + TCComponentBOMLine line = (TCComponentBOMLine) aif.getComponent(); + TCComponentItemRevision itemRev = line.getItemRevision(); + String smzq = itemRev.getStringProperty("rb3_smzqzt"); + String lswl = itemRev.getStringProperty("rb3_lswlbs"); + if (smzq != null && lswl != null) { + if (smzq.trim().equals("Scrap") || lswl.trim().equals("Temporary")) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle + .getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("bomzczbf16_display.TITLE"), "", MessageBox.ERROR); + res = false; + return res; + } + } + res = rule(line); + } + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return res; + } + + public void getForbidConfig(TCPreferenceService service) { + forbidConifg = new HashMap<>(); + // ֹ + String[] values = service.getStringValues(this.FORBID_NAME); + if (values == null || values.length < 1) { + System.out.println("ûҵѡ" + this.FORBID_NAME); + forbidConifg = null; + } else { + for (String value : values) { + String[] typeAndProp = value.split(":"); + if (typeAndProp.length != 2) { + System.out.println( + "ûҵѡ" + this.FORBID_NAME + "ʽȷ[REV:prop=AAA&prop=BBB][LINE:prop=AAA&prop=BBB]"); + forbidConifg = null;// ֵͬIJͨ + continue; + } + if ("".equals(typeAndProp[1].replace(" ", ""))) { + System.out.println( + "ûҵѡ" + this.FORBID_NAME + "ʽȷ[REV:prop=AAA&prop=BBB][LINE:prop=AAA&prop=BBB]"); + forbidConifg = null; + continue; + } + List propList = new ArrayList<>(); + String[] props = typeAndProp[1].split("\\&"); + for (String prop : props) { + String[] pd = prop.split("="); + if (pd.length != 2) { + continue; + } + CheckBean bean = new CheckBean(); + bean.setDefaultValue(pd[1]); + bean.setPropName(pd[0]); + propList.add(bean); + + } + forbidConifg.put(typeAndProp[0], propList); + } + } + } + + /** + * ȡӦ + * + * @param service + * @return + */ + public Map getTypeMap(TCPreferenceService service) { + String[] values = service.getStringValues(this.TYPE_NAME); + Map map = new HashMap<>(); + if (values != null && values.length >= 1) { + for (int i = 0; i < values.length; i++) { + map.put(values[i], values[i]); + } + } + return map; + } +} diff --git a/src/com/connor/rb/plm/rb016/BorderLayout.java b/src/com/connor/rb/plm/rb016/BorderLayout.java new file mode 100644 index 0000000..07c29e3 --- /dev/null +++ b/src/com/connor/rb/plm/rb016/BorderLayout.java @@ -0,0 +1,101 @@ +package com.connor.rb.plm.rb016; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Layout; + +public class BorderLayout extends Layout { + public static final int NORTH = 0; + public static final int SOUTH = 1; + public static final int CENTER = 2; + public static final int EAST = 3; + public static final int WEST = 4; + + public static class BorderData { + + public int region = CENTER; + + public BorderData() { + } + + public BorderData(int region) { + this.region = region; + } + } + + public Control[] controls = new Control[5]; + Point[] sizes; + int width; + int height; + + protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { + + if (sizes == null || flushCache == true) + refreshSizes(composite.getChildren()); + int w = wHint; + int h = hHint; + if (w == SWT.DEFAULT) + w = width; + if (h == SWT.DEFAULT) + h = height; + return new Point(w, h); + } + + protected void layout(Composite composite, boolean flushCache) { + if (flushCache || sizes == null) + refreshSizes(composite.getChildren()); + Rectangle clientArea = composite.getClientArea(); + if (controls[NORTH] != null) { + controls[NORTH].setBounds(clientArea.x, clientArea.y, clientArea.width, sizes[NORTH].y); + } + if (controls[SOUTH] != null) { + controls[SOUTH].setBounds(clientArea.x, clientArea.y + clientArea.height - sizes[SOUTH].y, clientArea.width, + sizes[SOUTH].y); + } + if (controls[WEST] != null) { + controls[WEST].setBounds(clientArea.x, clientArea.y + sizes[NORTH].y, sizes[WEST].x, + clientArea.height - sizes[NORTH].y - sizes[SOUTH].y); + } + if (controls[EAST] != null) { + controls[EAST].setBounds(clientArea.x + clientArea.width - sizes[EAST].x, clientArea.y + sizes[NORTH].y, + sizes[EAST].x, clientArea.height - sizes[NORTH].y - sizes[SOUTH].y); + } + if (controls[CENTER] != null) { + controls[CENTER].setBounds(clientArea.x + sizes[WEST].x, clientArea.y + sizes[NORTH].y, + clientArea.width - sizes[WEST].x - sizes[EAST].x, + clientArea.height - sizes[NORTH].y - sizes[SOUTH].y); + } + } + + private void refreshSizes(Control[] children) { + + for (int i = 0; i < children.length; i++) { + Object layoutData = children[i].getLayoutData(); + if (layoutData == null || (!(layoutData instanceof BorderData))) + continue; + BorderData borderData = (BorderData) layoutData; + if (borderData.region < 0 || borderData.region > 4) // Invalid. + continue; + controls[borderData.region] = children[i]; + } + width = 0; + height = 0; + if (sizes == null) + sizes = new Point[5]; + for (int i = 0; i < controls.length; i++) { + Control control = controls[i]; + if (control == null) { + sizes[i] = new Point(0, 0); + } else { + sizes[i] = control.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); + } + } + width = Math.max(width, sizes[NORTH].x); + width = Math.max(width, sizes[WEST].x + sizes[CENTER].x + sizes[EAST].x); + width = Math.max(width, sizes[SOUTH].x); + height = Math.max(Math.max(sizes[WEST].y, sizes[EAST].y), sizes[CENTER].y) + sizes[NORTH].y + sizes[SOUTH].y; + } +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/rb016/CheckBean.java b/src/com/connor/rb/plm/rb016/CheckBean.java new file mode 100644 index 0000000..a0e4952 --- /dev/null +++ b/src/com/connor/rb/plm/rb016/CheckBean.java @@ -0,0 +1,28 @@ +package com.connor.rb.plm.rb016; + +public class CheckBean { + private String defaultValue; + private String propName; + + public String getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + public String getPropName() { + return propName; + } + + public void setPropName(String propName) { + this.propName = propName; + } + + @Override + public String toString() { + return "[" + propName + "]"; + } + +} diff --git a/src/com/connor/rb/plm/rb016/MyMessageBox.java b/src/com/connor/rb/plm/rb016/MyMessageBox.java new file mode 100644 index 0000000..8a85066 --- /dev/null +++ b/src/com/connor/rb/plm/rb016/MyMessageBox.java @@ -0,0 +1,172 @@ +package com.connor.rb.plm.rb016; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.ShellAdapter; +import org.eclipse.swt.events.ShellEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Dialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.List; +import org.eclipse.swt.widgets.Shell; + +/** + * @copyRight 㽭տƼ޹˾ + * @author E-mail:hub@connor.net.cn + * @date ʱ䣺2017-8-16 11:14:39 + * @version v1.0 + * @parameter + * @since + * @return + */ + +public class MyMessageBox extends Dialog { + + public static final int OK = SWT.YES; + public static final int CEL = SWT.NO; + private int result = 1; + private Shell shell; + // private Tree lovTree; + // private List messageList; + private String[] msgList; + private String title; + + /** + * Create the dialog. + * + * @param parent + * @param style + */ + public MyMessageBox(Shell parent, int style, String title, String[] msgList) { + // super(parent); + super(parent, style); + this.title = title; + this.msgList = msgList; + + } + + /** + * Open the dialog. + * + * @return the result + */ + public int open() { + createContents(); + shell.open(); + shell.layout(); + Display display = getParent().getDisplay(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) { + display.sleep(); + } + } + return result; + } + + // private void initLovTree(TreeItem treeItem, TCComponentListOfValues lov) + // { + + // } + + /** + * Create contents of the dialog. + */ + private void createContents() { + shell = new Shell(getParent(), getStyle()); + // shell = new Shell(getParent()); + shell.setSize(610, 215); + + shell.setLayout(new BorderLayout()); + + // shell.setBounds(p.x, p.y, 330, 270); + // OS.SetWindowPos(shell.handle, OS.HWND_TOPMOST, p.x, p.y, 330, 270, + // SWT.NULL); + toCenter(shell); + shell.setText(title); + Label label1 = new Label(shell, SWT.PUSH); + label1.setText("¶ͬķ,Ƿ?"); + label1.setLayoutData(new BorderLayout.BorderData(BorderLayout.NORTH)); + + List messageList = new List(shell, SWT.BORDER | SWT.V_SCROLL); + // messageList.setBounds(10, 30, 585, 90); + messageList.setItems(msgList); + messageList.setLayoutData(new BorderLayout.BorderData(BorderLayout.CENTER)); + // initTree();s + // initLovTree(lovTree, this.lov); + + Composite southComposite = new Composite(shell, SWT.NO); + southComposite.setLayoutData(new BorderLayout.BorderData(BorderLayout.SOUTH)); + southComposite.setLayout(new GridLayout()); + + Composite composite = new Composite(southComposite, SWT.BORDER); + composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + // gridlayoutnumΪ2 + composite.setLayout(new GridLayout(2, false)); + + Button btnNewButton = new Button(composite, SWT.NONE); + btnNewButton.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, false)); + btnNewButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + + result = MyMessageBox.OK; + shell.dispose(); + } + }); + // Label label2 = new Label(shell, SWT.NONE); + // label2.setText("Ƿ?"); + // label2.setBounds(10, 125, 585, 20); + btnNewButton.setSize(80, 27); + btnNewButton.setText(" "); + + Button btnNewButton_1 = new Button(composite, SWT.NONE); + btnNewButton_1.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, false)); + btnNewButton_1.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + result = MyMessageBox.CEL; + shell.dispose(); + } + }); + btnNewButton_1.setSize(80, 27); + btnNewButton_1.setText(" "); + + shell.addShellListener(new ShellAdapter() { + public void shellClosed(final ShellEvent e) { + boolean b = MessageDialog.openConfirm(shell, "رʾ", "Ƿ"); + if (b == true) { + + e.doit = true; + result = MyMessageBox.OK; + + } else { + e.doit = true; + result = MyMessageBox.CEL; + } + } + }); + + } + + public void toCenter(Shell shell) { + + int width = shell.getMonitor().getClientArea().width; + int height = shell.getMonitor().getClientArea().height; + int x = shell.getSize().x; + int y = shell.getSize().y; + if (x > width) { + shell.getSize().x = width; + } + if (y > height) { + shell.getSize().y = height; + } + shell.setLocation((width - x) / 2, (height - y) / 2); + } + +} diff --git a/src/com/connor/rb/plm/rb016/test.java b/src/com/connor/rb/plm/rb016/test.java new file mode 100644 index 0000000..7c37c78 --- /dev/null +++ b/src/com/connor/rb/plm/rb016/test.java @@ -0,0 +1,12 @@ +package com.connor.rb.plm.rb016; + +public class test { + + public static void main(String[] args) { + String str = "REV:prop=AAA!prop=AAA&prop=BBB"; + + System.out.println(str.split(":")[1].split("!")[1].split("\\&")[0].split("=")[0]); + + } + +} diff --git a/src/com/connor/rb/plm/rb018one/CheckBoxTableHeaderRenderer.java b/src/com/connor/rb/plm/rb018one/CheckBoxTableHeaderRenderer.java new file mode 100644 index 0000000..55099f3 --- /dev/null +++ b/src/com/connor/rb/plm/rb018one/CheckBoxTableHeaderRenderer.java @@ -0,0 +1,75 @@ +package com.connor.rb.plm.rb018one; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.BorderFactory; +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; + +public class CheckBoxTableHeaderRenderer implements TableCellRenderer { + + private JTableHeader tableHeader; + private JCheckBox selectBox; + private int IND_BOOLEAN; + private static final Color BG = new Color(10, 192, 254); + + public CheckBoxTableHeaderRenderer(final JTable table, int IND_BOOLEAN1, boolean selected) { + this.tableHeader = table.getTableHeader(); + this.IND_BOOLEAN = IND_BOOLEAN1; + selectBox = new JCheckBox(""); + selectBox.setSelected(selected); + tableHeader.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() > 0) { + // ѡ + int selectColumn = tableHeader.columnAtPoint(e.getPoint()); + if (selectColumn == IND_BOOLEAN) { + boolean value = !selectBox.isSelected(); + selectBox.setSelected(value); + for (int index = 0; index < table.getRowCount(); index++) { + // System.out.println("index:"+index+";Ƿɱ༭:"+table.isCellEditable(index, + // IND_BOOLEAN)); + if (table.isCellEditable(index, IND_BOOLEAN)) { + table.setValueAt(value, index, IND_BOOLEAN); + } + } + tableHeader.repaint(); + } + } + } + }); + } + + public void setSelected(boolean b) { + selectBox.setSelected(b); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, + int row, int column) { + String valueStr = (String) value; + JLabel label = new JLabel(valueStr); + label.setHorizontalAlignment(SwingConstants.CENTER); // ͷǩ + selectBox.setHorizontalAlignment(SwingConstants.CENTER);// ͷǩ + selectBox.setBorderPainted(true); + JComponent component = (column == IND_BOOLEAN) ? selectBox : label; + component.setOpaque(true); + component.setForeground(Color.black);// tableHeader.getForeground()); + component.setBackground(BG);// (tableHeader.getBackground()); + component.setFont(tableHeader.getFont()); + component.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, Color.black)); + component.setPreferredSize(new Dimension(component.getPreferredSize().width, 25)); + return component; + } + +} diff --git a/src/com/connor/rb/plm/rb018one/FileBean.java b/src/com/connor/rb/plm/rb018one/FileBean.java new file mode 100644 index 0000000..c873306 --- /dev/null +++ b/src/com/connor/rb/plm/rb018one/FileBean.java @@ -0,0 +1,50 @@ +/** + * + */ +package com.connor.rb.plm.rb018one; + +import com.teamcenter.rac.kernel.TCComponentItemRevision; + +/** + * @author ½ + * @date 2021115 + */ +public class FileBean { + + private int index; + private TCComponentItemRevision itemRev; + + public Object[] getRowData() throws Exception { + // TODO Auto-generated method stub + return new Object[] { false, this, this.itemRev.getStringProperty("object_string") }; + } + + public TCComponentItemRevision getItemRev() { + return itemRev; + } + + public void setItemRev(TCComponentItemRevision itemRev) { + this.itemRev = itemRev; + } + + public int getIndex() { + return index; + } + + public void setIndex(int index) { + this.index = index; + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return this.index + ""; + } + + public FileBean(int index, TCComponentItemRevision itemRev) { + super(); + this.index = index; + this.itemRev = itemRev; + } + +} diff --git a/src/com/connor/rb/plm/rb018one/Rb018Dialog.java b/src/com/connor/rb/plm/rb018one/Rb018Dialog.java new file mode 100644 index 0000000..8e24d43 --- /dev/null +++ b/src/com/connor/rb/plm/rb018one/Rb018Dialog.java @@ -0,0 +1,269 @@ +package com.connor.rb.plm.rb018one; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumnModel; + +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.MessageBox; + +public class Rb018Dialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFApplication app; + private TCComponentItemRevision rootRev; + + private JComboBox jcomb; // · + private JButton btn_list; // ť + private JButton btn_upload; // ϴ + + private JPanel centerJPanel = new JPanel(); + + private JTable t_part; + private DefaultTableModel tm_part; + private CheckBoxTableHeaderRenderer tableHeaderRenderer; + + private final static String[] HEADER = { "", "", "ļ", "" }; + private final static int[] HEADERWIDTH = new int[] { 50, 50, 150, 150 }; + + public Rb018Dialog(AbstractAIFApplication app) { + super(false); + this.app = app; + } + + private void initUI() { + + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if (targetComponent instanceof TCComponentItemRevision) { + rootRev = (TCComponentItemRevision) targetComponent; + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + try { + if (!rootRev.getStringProperty("object_type").equals("RB3_zcRevision")) { + MessageBox.post(rb.getString("qxzggtzbb18_display.TITLE"), "ʧ", MessageBox.ERROR); + return; + } + } catch (Exception e) { + // TODO: handle exception + } + // + this.setTitle("޶"); + this.setPreferredSize(new Dimension(500, 400)); + this.setMinimumSize(new Dimension(400, 380)); + this.setLayout(new BorderLayout()); + this.add(BorderLayout.NORTH, getSelectPanel()); + this.add(BorderLayout.CENTER, centerJPanel); + this.add(BorderLayout.SOUTH, getImportPanel()); + this.btn_list.addActionListener(this); + this.btn_upload.addActionListener(this); + this.showDialog(); + + } else { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("qxzggtzbb18_display.TITLE"), "ʧ", MessageBox.ERROR); + } + } + + @Override + public void run() { + this.initUI(); + } + + // ť + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource().equals(this.btn_upload)) { + // ֹͣ༭ + stopTableEditing(t_part); + try { + Map map = getSelects(); + Rb018Operation operation = new Rb018Operation(this.app, map, rootRev); + TCSession session = RACUIUtil.getTCSession(); + session.queueOperation(operation); + this.disposeDialog(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else if (e.getSource().equals(this.btn_list)) { + + try { + // /ˢ± + this.remove(centerJPanel); + centerJPanel = getTablePanel(); + this.add(BorderLayout.CENTER, centerJPanel); + this.pack(); + readReference(rootRev, jcomb.getSelectedItem().toString()); + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + + // ȡѡ + public Map getSelects() { + Map map = new HashMap(); + int cout = t_part.getRowCount(); + List listBeans = new ArrayList<>(); + List listString = new ArrayList(); + FileBean bean; + for (int i = 0; i < cout; i++) { + if ("true".equals(t_part.getValueAt(i, 0).toString())) { + listBeans.add((FileBean) t_part.getValueAt(i, 1)); + listString.add((String) t_part.getValueAt(i, 3)); + } + } + map.put("beans", listBeans); + map.put("strings", listString); + + return map; + } + + // ȡ汾б + public void readReference(TCComponentItemRevision rootRev, String revType) throws Exception { + tm_part.setRowCount(0); + TCComponent[] comps = rootRev.getReferenceListProperty("EC_problem_item_rel");// ϵļʵ + List tuzhiList = new ArrayList(); + List wuliaoList = new ArrayList(); + + String tuzhiString = "RB3_CPTRevision" + "RB3_CGTRevision" + "RB3_CGTARevision" + "RB3_CGTBRevision" + + "RB3_CGTCRevision" + "RB3_QRTRevision" + "RB3_3DMXTRevision"; + String wuliaoString = "RB3_ZCRevision" + "RB3_LBJRevision"; + + for (TCComponent comp : comps) { + TCComponentItemRevision itemRev = (TCComponentItemRevision) comp; + String type = itemRev.getStringProperty("object_type"); + if (wuliaoString.indexOf(type) != -1) { + wuliaoList.add(itemRev); + } else if (tuzhiString.indexOf(type) != -1) { + tuzhiList.add(itemRev); + } + } + + FileBean bean; + int index = 1; + + if (revType.equals("ͼֽ")) { + for (int i = 0; i < tuzhiList.size(); i++) { + TCComponentItemRevision itemRev = tuzhiList.get(i); + bean = new FileBean(index++, itemRev); + tm_part.addRow(bean.getRowData()); + } + } else if (revType.equals("")) { + for (int i = 0; i < wuliaoList.size(); i++) { + TCComponentItemRevision itemRev = wuliaoList.get(i); + bean = new FileBean(index++, itemRev); + tm_part.addRow(bean.getRowData()); + } + } + } + + // ʹֹͣ༭ + public static void stopTableEditing(JTable t_proc) { + if (t_proc.isEditing()) { + int row = t_proc.getEditingRow(); + int col = t_proc.getEditingColumn(); + t_proc.getCellEditor(row, col).stopCellEditing(); + } + } + + // Ϸ|ѡذ汾 + private JPanel getSelectPanel() { + JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 5)); + panel.add(new JLabel("ѡͣ")); + jcomb = new JComboBox(); + Dimension preferredSize = new Dimension(100, 30); + jcomb.setPreferredSize(preferredSize); + jcomb.addItem("ͼֽ"); + jcomb.addItem(""); + btn_list = new JButton(" ȡ"); + btn_list.setPreferredSize(new Dimension(80, 30)); + panel.add(jcomb); + panel.add(btn_list); + return panel; + } + + // ·|水ť + private JPanel getImportPanel() { + JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 20, 20)); + btn_upload = new JButton(" "); + panel.add(btn_upload); + btn_upload.setPreferredSize(new Dimension(80, 30)); + return panel; + + } + + // м仭| + private JPanel getTablePanel() { + JPanel panel = new JPanel(new BorderLayout()); + tm_part = new DefaultTableModel(); + + t_part = new JTable(tm_part) { + @Override + public boolean isCellEditable(int row, int column) { + if (column == 0 || column == 3) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int column) { // ѡУУ + if (column == 0) { + return Boolean.class; + } + return super.getColumnClass(column); + } + }; + + tm_part.setDataVector(null, HEADER); + t_part.getTableHeader().setReorderingAllowed(false); // вƶᷢת󣨵У + this.t_part.setRowHeight(23); + TableColumnModel colModel = this.t_part.getColumnModel(); + int colCnt = HEADERWIDTH.length; + for (int i = 0; i < colCnt; i++) { + colModel.getColumn(i).setPreferredWidth(HEADERWIDTH[i]); + } + this.t_part.getTableHeader() + .setDefaultRenderer(this.tableHeaderRenderer = new CheckBoxTableHeaderRenderer(t_part, 0, false)); + this.t_part.getTableHeader().setBackground(Color.WHITE); + if (jcomb.getSelectedItem().equals("")) { + this.t_part.getColumnModel().getColumn(3).setCellEditor(new UploadCellEditor()); + } else if (jcomb.getSelectedItem().equals("ͼֽ")) { + this.t_part.getColumnModel().getColumn(3).setCellEditor(new UploadCellEditorDrawing()); + } + + JScrollPane scroll = new JScrollPane(t_part); + panel.add(BorderLayout.CENTER, scroll); + return panel; + } + +} diff --git a/src/com/connor/rb/plm/rb018one/Rb018Handler.java b/src/com/connor/rb/plm/rb018one/Rb018Handler.java new file mode 100644 index 0000000..d584623 --- /dev/null +++ b/src/com/connor/rb/plm/rb018one/Rb018Handler.java @@ -0,0 +1,20 @@ +package com.connor.rb.plm.rb018one; + +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.aifrcp.AIFUtility; + +public class Rb018Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + Rb018Dialog dialog = new Rb018Dialog(app); + new Thread(dialog).start(); + return null; + } + +} diff --git a/src/com/connor/rb/plm/rb018one/Rb018Operation.java b/src/com/connor/rb/plm/rb018one/Rb018Operation.java new file mode 100644 index 0000000..7e022ea --- /dev/null +++ b/src/com/connor/rb/plm/rb018one/Rb018Operation.java @@ -0,0 +1,111 @@ +package com.connor.rb.plm.rb018one; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.MessageBox; + +public class Rb018Operation extends AbstractAIFOperation { + private TCSession session = RACUIUtil.getTCSession(); + private AbstractAIFApplication app; + private Map map; + TCComponentItemRevision rootRev; + + public Rb018Operation(AbstractAIFApplication app, Map map, TCComponentItemRevision rootRev) { + this.app = app; + this.map = map; + this.rootRev = rootRev; + } + + public Rb018Operation(AbstractAIFApplication app) { + this.app = app; + } + + @Override + public void executeOperation() throws Exception { + List beans = (List) map.get("beans"); + List strings = (List) map.get("strings"); + TCComponentItemRevision itemRev; + String revId; + for (int i = 0; i < beans.size(); i++) { + itemRev = beans.get(i).getItemRev(); + revId = strings.get(i); + + if (revId.equals("")) { + TCComponentItemRevision newRev = itemRev.saveAs(null); + String newId = newRev.getStringProperty("item_revision_id"); + String stage = getStage(newId.charAt(0)); + newRev.setStringProperty("rb3_smzqjd", stage); + rootRev.add("EC_solution_item_rel", newRev); + } else if (revId.equals("С汾")) { + rootRev.add("EC_solution_item_rel", itemRev.saveAs(null)); + } else if (revId.equals("汾")) { + revId = getRevId(itemRev); + int id = Integer.parseInt(String.valueOf(revId.charAt(1))); + revId = "V" + String.valueOf(++id) + ".1"; + rootRev.add("EC_solution_item_rel", itemRev.saveAs(revId)); + } else { + char letter = revId.charAt(0); + String stage = getStage(letter); + TCComponentItemRevision newRev = itemRev.saveAs(revId); + newRev.setStringProperty("rb3_smzqjd", stage); + rootRev.add("EC_solution_item_rel", newRev); + + } + } + } + + // ȡ汾id + public static String getRevId(TCComponentItemRevision itemRev) { + String revId = ""; + try { + revId = itemRev.getStringProperty("item_revision_id"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return revId; + + } + + // ȡ״̬ + public static String getStage(char letter) { + String stage = ""; + switch (letter) { + case 'A': + stage = "ƣ"; + break; + case 'B': + stage = "Ʒƣ£"; + break; + case 'R': + stage = "/ã"; + break; + case 'P': + stage = "/СP"; + break; + case 'M': + stage = "M"; + break; + case 'T': + stage = "T"; + break; + } + return stage; + } + +} diff --git a/src/com/connor/rb/plm/rb018one/UploadCellEditor.java b/src/com/connor/rb/plm/rb018one/UploadCellEditor.java new file mode 100644 index 0000000..69457ae --- /dev/null +++ b/src/com/connor/rb/plm/rb018one/UploadCellEditor.java @@ -0,0 +1,51 @@ +package com.connor.rb.plm.rb018one; + +import java.awt.Component; + +import javax.swing.AbstractCellEditor; +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.table.TableCellEditor; +import javax.swing.text.JTextComponent; + +public class UploadCellEditor extends AbstractCellEditor implements TableCellEditor { + + private Component comp; + + @Override + public Object getCellEditorValue() { + + if (comp instanceof JTextComponent) { + return ((JTextComponent) comp).getText(); + } else if (comp instanceof JComboBox) { + return ((JComboBox) comp).getSelectedItem(); + } + return null; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (column == 3) { + comp = new JComboBox(); + JComboBox jcom = (JComboBox) comp; + jcom.addItem(""); + jcom.addItem("A1"); + jcom.addItem("B1"); + jcom.addItem("R1"); + jcom.addItem("P1"); + jcom.addItem("M1"); + // + if (value != null) { + String text = String.valueOf(value); + jcom.setSelectedItem(value); + } + + } else { + comp = new JTextField(); + + } + return comp; + } + +} diff --git a/src/com/connor/rb/plm/rb018one/UploadCellEditorDrawing.java b/src/com/connor/rb/plm/rb018one/UploadCellEditorDrawing.java new file mode 100644 index 0000000..d15c633 --- /dev/null +++ b/src/com/connor/rb/plm/rb018one/UploadCellEditorDrawing.java @@ -0,0 +1,48 @@ +package com.connor.rb.plm.rb018one; + +import java.awt.Component; + +import javax.swing.AbstractCellEditor; +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.table.TableCellEditor; +import javax.swing.text.JTextComponent; + +public class UploadCellEditorDrawing extends AbstractCellEditor implements TableCellEditor { + + private Component comp; + + @Override + public Object getCellEditorValue() { + + if (comp instanceof JTextComponent) { + return ((JTextComponent) comp).getText(); + } else if (comp instanceof JComboBox) { + return ((JComboBox) comp).getSelectedItem(); + } + return null; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (column == 3) { + comp = new JComboBox(); + JComboBox jcom = (JComboBox) comp; + jcom.addItem("С汾"); + jcom.addItem("汾"); + + // + if (value != null) { + String text = String.valueOf(value); + jcom.setSelectedItem(value); + } + + } else { + comp = new JTextField(); + + } + return comp; + } + +} diff --git a/src/com/connor/rb/plm/rb018two/CheckBoxTableHeaderRenderer.java b/src/com/connor/rb/plm/rb018two/CheckBoxTableHeaderRenderer.java new file mode 100644 index 0000000..2b8d2a4 --- /dev/null +++ b/src/com/connor/rb/plm/rb018two/CheckBoxTableHeaderRenderer.java @@ -0,0 +1,75 @@ +package com.connor.rb.plm.rb018two; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.BorderFactory; +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; + +public class CheckBoxTableHeaderRenderer implements TableCellRenderer { + + private JTableHeader tableHeader; + private JCheckBox selectBox; + private int IND_BOOLEAN; + private static final Color BG = new Color(10, 192, 254); + + public CheckBoxTableHeaderRenderer(final JTable table, int IND_BOOLEAN1, boolean selected) { + this.tableHeader = table.getTableHeader(); + this.IND_BOOLEAN = IND_BOOLEAN1; + selectBox = new JCheckBox(""); + selectBox.setSelected(selected); + tableHeader.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() > 0) { + // ѡ + int selectColumn = tableHeader.columnAtPoint(e.getPoint()); + if (selectColumn == IND_BOOLEAN) { + boolean value = !selectBox.isSelected(); + selectBox.setSelected(value); + for (int index = 0; index < table.getRowCount(); index++) { + // System.out.println("index:"+index+";Ƿɱ༭:"+table.isCellEditable(index, + // IND_BOOLEAN)); + if (table.isCellEditable(index, IND_BOOLEAN)) { + table.setValueAt(value, index, IND_BOOLEAN); + } + } + tableHeader.repaint(); + } + } + } + }); + } + + public void setSelected(boolean b) { + selectBox.setSelected(b); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, + int row, int column) { + String valueStr = (String) value; + JLabel label = new JLabel(valueStr); + label.setHorizontalAlignment(SwingConstants.CENTER); // ͷǩ + selectBox.setHorizontalAlignment(SwingConstants.CENTER);// ͷǩ + selectBox.setBorderPainted(true); + JComponent component = (column == IND_BOOLEAN) ? selectBox : label; + component.setOpaque(true); + component.setForeground(Color.black);// tableHeader.getForeground()); + component.setBackground(BG);// (tableHeader.getBackground()); + component.setFont(tableHeader.getFont()); + component.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, Color.black)); + component.setPreferredSize(new Dimension(component.getPreferredSize().width, 25)); + return component; + } + +} diff --git a/src/com/connor/rb/plm/rb018two/FileBean.java b/src/com/connor/rb/plm/rb018two/FileBean.java new file mode 100644 index 0000000..c25f4a1 --- /dev/null +++ b/src/com/connor/rb/plm/rb018two/FileBean.java @@ -0,0 +1,50 @@ +/** + * + */ +package com.connor.rb.plm.rb018two; + +import com.teamcenter.rac.kernel.TCComponentItemRevision; + +/** + * @author ½ + * @date 2021115 + */ +public class FileBean { + + private int index; + private TCComponentItemRevision itemRev; + + public Object[] getRowData() throws Exception { + // TODO Auto-generated method stub + return new Object[] { false, this, this.itemRev.getStringProperty("object_string") }; + } + + public TCComponentItemRevision getItemRev() { + return itemRev; + } + + public void setItemRev(TCComponentItemRevision itemRev) { + this.itemRev = itemRev; + } + + public int getIndex() { + return index; + } + + public void setIndex(int index) { + this.index = index; + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return this.index + ""; + } + + public FileBean(int index, TCComponentItemRevision itemRev) { + super(); + this.index = index; + this.itemRev = itemRev; + } + +} diff --git a/src/com/connor/rb/plm/rb018two/Rb018Dialog.java b/src/com/connor/rb/plm/rb018two/Rb018Dialog.java new file mode 100644 index 0000000..f77058e --- /dev/null +++ b/src/com/connor/rb/plm/rb018two/Rb018Dialog.java @@ -0,0 +1,269 @@ +package com.connor.rb.plm.rb018two; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumnModel; + +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.MessageBox; + +public class Rb018Dialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFApplication app; + private TCComponentItemRevision rootRev; + + private JComboBox jcomb; // · + private JButton btn_list; // ť + private JButton btn_upload; // ϴ + + private JPanel centerJPanel = new JPanel(); + + private JTable t_part; + private DefaultTableModel tm_part; + private CheckBoxTableHeaderRenderer tableHeaderRenderer; + + private final static String[] HEADER = { "", "", "ļ", "" }; + private final static int[] HEADERWIDTH = new int[] { 50, 50, 150, 150 }; + + public Rb018Dialog(AbstractAIFApplication app) { + super(false); + this.app = app; + } + + private void initUI() { + + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if (targetComponent instanceof TCComponentItemRevision) { + rootRev = (TCComponentItemRevision) targetComponent; + try { + if (!rootRev.getStringProperty("object_type").equals("RB3_zcRevision")) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("qxzggtzbb18_display.TITLE"), "ʧ", MessageBox.ERROR); + return; + } + } catch (Exception e) { + // TODO: handle exception + } + // + this.setTitle("޶Ӱ"); + this.setPreferredSize(new Dimension(500, 400)); + this.setMinimumSize(new Dimension(400, 380)); + this.setLayout(new BorderLayout()); + this.add(BorderLayout.NORTH, getSelectPanel()); + this.add(BorderLayout.CENTER, centerJPanel); + this.add(BorderLayout.SOUTH, getImportPanel()); + this.btn_list.addActionListener(this); + this.btn_upload.addActionListener(this); + this.showDialog(); + + } else { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("qxzggtzbb18_display.TITLE"), "ʧ", MessageBox.ERROR); + } + } + + @Override + public void run() { + this.initUI(); + } + + // ť + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource().equals(this.btn_upload)) { + // ֹͣ༭ + stopTableEditing(t_part); + try { + Map map = getSelects(); + Rb018Operation operation = new Rb018Operation(this.app, map, rootRev); + TCSession session = RACUIUtil.getTCSession(); + session.queueOperation(operation); + this.disposeDialog(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else if (e.getSource().equals(this.btn_list)) { + + try { + // /ˢ± + this.remove(centerJPanel); + centerJPanel = getTablePanel(); + this.add(BorderLayout.CENTER, centerJPanel); + this.pack(); + readReference(rootRev, jcomb.getSelectedItem().toString()); + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + + // ȡѡ + public Map getSelects() { + Map map = new HashMap(); + int cout = t_part.getRowCount(); + List listBeans = new ArrayList<>(); + List listString = new ArrayList(); + FileBean bean; + for (int i = 0; i < cout; i++) { + if ("true".equals(t_part.getValueAt(i, 0).toString())) { + listBeans.add((FileBean) t_part.getValueAt(i, 1)); + listString.add((String) t_part.getValueAt(i, 3)); + } + } + map.put("beans", listBeans); + map.put("strings", listString); + + return map; + } + + // ȡ汾б + public void readReference(TCComponentItemRevision rootRev, String revType) throws Exception { + tm_part.setRowCount(0); + TCComponent[] comps = rootRev.getReferenceListProperty("EC_affected_item_rel");// ϵļʵ + List tuzhiList = new ArrayList(); + List wuliaoList = new ArrayList(); + + String tuzhiString = "RB3_CPTRevision" + "RB3_CGTRevision" + "RB3_CGTARevision" + "RB3_CGTBRevision" + + "RB3_CGTCRevision" + "RB3_QRTRevision" + "RB3_3DMXTRevision"; + String wuliaoString = "RB3_ZCRevision" + "RB3_LBJRevision"; + + for (TCComponent comp : comps) { + TCComponentItemRevision itemRev = (TCComponentItemRevision) comp; + String type = itemRev.getStringProperty("object_type"); + if (wuliaoString.indexOf(type) != -1) { + wuliaoList.add(itemRev); + } else if (tuzhiString.indexOf(type) != -1) { + tuzhiList.add(itemRev); + } + } + + FileBean bean; + int index = 1; + + if (revType.equals("ͼֽ")) { + for (int i = 0; i < tuzhiList.size(); i++) { + TCComponentItemRevision itemRev = tuzhiList.get(i); + bean = new FileBean(index++, itemRev); + tm_part.addRow(bean.getRowData()); + } + } else if (revType.equals("")) { + for (int i = 0; i < wuliaoList.size(); i++) { + TCComponentItemRevision itemRev = wuliaoList.get(i); + bean = new FileBean(index++, itemRev); + tm_part.addRow(bean.getRowData()); + } + } + } + + // ʹֹͣ༭ + public static void stopTableEditing(JTable t_proc) { + if (t_proc.isEditing()) { + int row = t_proc.getEditingRow(); + int col = t_proc.getEditingColumn(); + t_proc.getCellEditor(row, col).stopCellEditing(); + } + } + + // Ϸ|ѡذ汾 + private JPanel getSelectPanel() { + JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 5)); + panel.add(new JLabel("ѡͣ")); + jcomb = new JComboBox(); + Dimension preferredSize = new Dimension(100, 30); + jcomb.setPreferredSize(preferredSize); + jcomb.addItem("ͼֽ"); + jcomb.addItem(""); + btn_list = new JButton(" ȡ"); + btn_list.setPreferredSize(new Dimension(80, 30)); + panel.add(jcomb); + panel.add(btn_list); + return panel; + } + + // ·|水ť + private JPanel getImportPanel() { + JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 20, 20)); + btn_upload = new JButton(" "); + panel.add(btn_upload); + btn_upload.setPreferredSize(new Dimension(80, 30)); + return panel; + + } + + // м仭| + private JPanel getTablePanel() { + JPanel panel = new JPanel(new BorderLayout()); + tm_part = new DefaultTableModel(); + + t_part = new JTable(tm_part) { + @Override + public boolean isCellEditable(int row, int column) { + if (column == 0 || column == 3) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int column) { // ѡУУ + if (column == 0) { + return Boolean.class; + } + return super.getColumnClass(column); + } + }; + + tm_part.setDataVector(null, HEADER); + t_part.getTableHeader().setReorderingAllowed(false); // вƶᷢת󣨵У + this.t_part.setRowHeight(23); + TableColumnModel colModel = this.t_part.getColumnModel(); + int colCnt = HEADERWIDTH.length; + for (int i = 0; i < colCnt; i++) { + colModel.getColumn(i).setPreferredWidth(HEADERWIDTH[i]); + } + this.t_part.getTableHeader() + .setDefaultRenderer(this.tableHeaderRenderer = new CheckBoxTableHeaderRenderer(t_part, 0, false)); + this.t_part.getTableHeader().setBackground(Color.WHITE); + if (jcomb.getSelectedItem().equals("")) { + this.t_part.getColumnModel().getColumn(3).setCellEditor(new UploadCellEditor()); + } else if (jcomb.getSelectedItem().equals("ͼֽ")) { + this.t_part.getColumnModel().getColumn(3).setCellEditor(new UploadCellEditorDrawing()); + } + + JScrollPane scroll = new JScrollPane(t_part); + panel.add(BorderLayout.CENTER, scroll); + return panel; + } + +} diff --git a/src/com/connor/rb/plm/rb018two/Rb018Handler.java b/src/com/connor/rb/plm/rb018two/Rb018Handler.java new file mode 100644 index 0000000..9e33d7b --- /dev/null +++ b/src/com/connor/rb/plm/rb018two/Rb018Handler.java @@ -0,0 +1,20 @@ +package com.connor.rb.plm.rb018two; + +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.aifrcp.AIFUtility; + +public class Rb018Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + Rb018Dialog dialog = new Rb018Dialog(app); + new Thread(dialog).start(); + return null; + } + +} diff --git a/src/com/connor/rb/plm/rb018two/Rb018Operation.java b/src/com/connor/rb/plm/rb018two/Rb018Operation.java new file mode 100644 index 0000000..f1bd37c --- /dev/null +++ b/src/com/connor/rb/plm/rb018two/Rb018Operation.java @@ -0,0 +1,109 @@ +package com.connor.rb.plm.rb018two; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.MessageBox; + +public class Rb018Operation extends AbstractAIFOperation { + private TCSession session = RACUIUtil.getTCSession(); + private AbstractAIFApplication app; + private Map map; + TCComponentItemRevision rootRev; + + public Rb018Operation(AbstractAIFApplication app, Map map, TCComponentItemRevision rootRev) { + this.app = app; + this.map = map; + this.rootRev = rootRev; + } + + public Rb018Operation(AbstractAIFApplication app) { + this.app = app; + } + + @Override + public void executeOperation() throws Exception { + + List beans = (List) map.get("beans"); + List strings = (List) map.get("strings"); + TCComponentItemRevision itemRev; + String revId; + for (int i = 0; i < beans.size(); i++) { + itemRev = beans.get(i).getItemRev(); + revId = strings.get(i); + + if (revId.equals("")) { + TCComponentItemRevision newRev = itemRev.saveAs(null); + String newId = newRev.getStringProperty("item_revision_id"); + String stage = getStage(newId.charAt(0)); + newRev.setStringProperty("rb3_smzqjd", stage); + rootRev.add("EC_solution_item_rel", newRev); + } else if (revId.equals("С汾")) { + rootRev.add("EC_solution_item_rel", itemRev.saveAs(null)); + } else if (revId.equals("汾")) { + revId = getRevId(itemRev); + int id = Integer.parseInt(String.valueOf(revId.charAt(1))); + revId = "V" + String.valueOf(++id) + ".1"; + rootRev.add("EC_solution_item_rel", itemRev.saveAs(revId)); + } else { + char letter = revId.charAt(0); + String stage = getStage(letter); + TCComponentItemRevision newRev = itemRev.saveAs(revId); + newRev.setStringProperty("rb3_smzqjd", stage); + rootRev.add("EC_solution_item_rel", newRev); + } + } + } + + // ȡ汾id + public static String getRevId(TCComponentItemRevision itemRev) { + String revId = ""; + try { + revId = itemRev.getStringProperty("item_revision_id"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return revId; + } + + // ȡ״̬ + public static String getStage(char letter) { + String stage = ""; + switch (letter) { + case 'A': + stage = "ƣ"; + break; + case 'B': + stage = "Ʒƣ£"; + break; + case 'R': + stage = "/ã"; + break; + case 'P': + stage = "/СP"; + break; + case 'M': + stage = "M"; + break; + case 'T': + stage = "T"; + break; + } + return stage; + } +} diff --git a/src/com/connor/rb/plm/rb018two/UploadCellEditor.java b/src/com/connor/rb/plm/rb018two/UploadCellEditor.java new file mode 100644 index 0000000..941f859 --- /dev/null +++ b/src/com/connor/rb/plm/rb018two/UploadCellEditor.java @@ -0,0 +1,51 @@ +package com.connor.rb.plm.rb018two; + +import java.awt.Component; + +import javax.swing.AbstractCellEditor; +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.table.TableCellEditor; +import javax.swing.text.JTextComponent; + +public class UploadCellEditor extends AbstractCellEditor implements TableCellEditor { + + private Component comp; + + @Override + public Object getCellEditorValue() { + + if (comp instanceof JTextComponent) { + return ((JTextComponent) comp).getText(); + } else if (comp instanceof JComboBox) { + return ((JComboBox) comp).getSelectedItem(); + } + return null; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (column == 3) { + comp = new JComboBox(); + JComboBox jcom = (JComboBox) comp; + jcom.addItem(""); + jcom.addItem("A1"); + jcom.addItem("B1"); + jcom.addItem("R1"); + jcom.addItem("P1"); + jcom.addItem("M1"); + // + if (value != null) { + String text = String.valueOf(value); + jcom.setSelectedItem(value); + } + + } else { + comp = new JTextField(); + + } + return comp; + } + +} diff --git a/src/com/connor/rb/plm/rb018two/UploadCellEditorDrawing.java b/src/com/connor/rb/plm/rb018two/UploadCellEditorDrawing.java new file mode 100644 index 0000000..b028213 --- /dev/null +++ b/src/com/connor/rb/plm/rb018two/UploadCellEditorDrawing.java @@ -0,0 +1,48 @@ +package com.connor.rb.plm.rb018two; + +import java.awt.Component; + +import javax.swing.AbstractCellEditor; +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.table.TableCellEditor; +import javax.swing.text.JTextComponent; + +public class UploadCellEditorDrawing extends AbstractCellEditor implements TableCellEditor { + + private Component comp; + + @Override + public Object getCellEditorValue() { + + if (comp instanceof JTextComponent) { + return ((JTextComponent) comp).getText(); + } else if (comp instanceof JComboBox) { + return ((JComboBox) comp).getSelectedItem(); + } + return null; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (column == 3) { + comp = new JComboBox(); + JComboBox jcom = (JComboBox) comp; + jcom.addItem("С汾"); + jcom.addItem("汾"); + + // + if (value != null) { + String text = String.valueOf(value); + jcom.setSelectedItem(value); + } + + } else { + comp = new JTextField(); + + } + return comp; + } + +} diff --git a/src/com/connor/rb/plm/rb019/ChangeOwnerbean.java b/src/com/connor/rb/plm/rb019/ChangeOwnerbean.java new file mode 100644 index 0000000..acd6288 --- /dev/null +++ b/src/com/connor/rb/plm/rb019/ChangeOwnerbean.java @@ -0,0 +1,72 @@ +package com.connor.rb.plm.rb019; + +public class ChangeOwnerbean { + + private String id; + private String rev; + private String name; + private String cph; + private String owner; + + public ChangeOwnerbean() { + super(); + } + + public ChangeOwnerbean(String id, String rev, String name, String cph, String owner) { + super(); + this.id = id; + this.rev = rev; + this.name = name; + this.cph = cph; + this.owner = owner; + } + + public ChangeOwnerbean(String id, String rev, String name, String owner) { + super(); + this.id = id; + this.rev = rev; + this.name = name; + this.owner = owner; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getRev() { + return rev; + } + + public void setRev(String rev) { + this.rev = rev; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCph() { + return cph; + } + + public void setCph(String cph) { + this.cph = cph; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + +} diff --git a/src/com/connor/rb/plm/rb019/SelectOwnerAction.java b/src/com/connor/rb/plm/rb019/SelectOwnerAction.java new file mode 100644 index 0000000..04c2565 --- /dev/null +++ b/src/com/connor/rb/plm/rb019/SelectOwnerAction.java @@ -0,0 +1,24 @@ +package com.connor.rb.plm.rb019; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +public class SelectOwnerAction extends AbstractAIFAction { + + private AbstractAIFUIApplication app; + + public SelectOwnerAction(AbstractAIFUIApplication app, String string) { + super(app, string); + this.app = app; + } + + @Override + public void run() { + try { + new SelectOwnerCommand(app).executeModal(); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/rb/plm/rb019/SelectOwnerCommand.java b/src/com/connor/rb/plm/rb019/SelectOwnerCommand.java new file mode 100644 index 0000000..82b5195 --- /dev/null +++ b/src/com/connor/rb/plm/rb019/SelectOwnerCommand.java @@ -0,0 +1,20 @@ +package com.connor.rb.plm.rb019; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCSession; + +public class SelectOwnerCommand extends AbstractAIFCommand { + + private AbstractAIFUIApplication app; + + public SelectOwnerCommand(AbstractAIFUIApplication app) { + this.app = app; + } + + @Override + public void executeModal() throws Exception { + new Thread(new SelectOwnerDialog(app)).start(); + } + +} diff --git a/src/com/connor/rb/plm/rb019/SelectOwnerDialog.java b/src/com/connor/rb/plm/rb019/SelectOwnerDialog.java new file mode 100644 index 0000000..6a9b499 --- /dev/null +++ b/src/com/connor/rb/plm/rb019/SelectOwnerDialog.java @@ -0,0 +1,875 @@ +package com.connor.rb.plm.rb019; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.OutputStreamWriter; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableRowSorter; + +import org.apache.commons.io.FileUtils; + +import com.connor.rb.plm.util.ClassPropBean; +import com.connor.rb.plm.util.ParseXMLUtil; +import com.connor.rb.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; + +public class SelectOwnerDialog extends AbstractAIFDialog implements ActionListener { + + private static final long serialVersionUID = 6130114042631785757L; + private static final int width = 700; + DefaultTableModel model; + private AbstractAIFUIApplication app; + private TCSession session; + private TCComponentDataset dataset; + private TCComponentItemRevision targetRev; + private TCComponentItemRevision itemTargetRev; + private JButton okBtn = new JButton("ȷ"); + private JButton okBtn2 = new JButton("ȷ"); + private JButton celBtn = new JButton("ȡ"); + private String[] columnNames = { "ID", "汾", "", "Ʒ", "" }; + private String[] columnNames2 = { "ID", "汾", "", "" }; + private JTable qryTable; + private Object[][] beans; + + public SelectOwnerDialog(AbstractAIFUIApplication app) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + } + + /** + * ˢtableʾÿ + */ + private void refreshTable() { + qryTable.removeAll(); + model.setDataVector(beans, columnNames); + // qryTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); + qryTable.getColumnModel().getColumn(0).setPreferredWidth(110); + qryTable.getColumnModel().getColumn(1).setPreferredWidth(50); + qryTable.getColumnModel().getColumn(2).setPreferredWidth(80); + qryTable.getColumnModel().getColumn(3).setPreferredWidth(50); + qryTable.getColumnModel().getColumn(4).setPreferredWidth(110); + + } + + @Override + public void run() { + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (targetComponent instanceof TCComponentDataset) { + dataset = (TCComponentDataset) targetComponent; + String type = dataset.getType(); + if ("RB3_GCAD".equals(type)) { + try { + AIFComponentContext[] referenceds = dataset.whereReferenced(); + for (int i = 0; i < referenceds.length; i++) { + InterfaceAIFComponent comp = referenceds[i].getComponent(); + if (comp instanceof TCComponentItemRevision) { + targetRev = (TCComponentItemRevision) comp; + String name = targetRev.getStringProperty("object_name"); + String revID = targetRev.getStringProperty("item_revision_id"); + // 2022.3.8 + String dataName1 = name + "/" + revID; + String dataName; + String datasetName = dataset.getStringProperty("object_name"); + System.out.println("dataName============" + dataName1); + if (!(dataName1.equals(datasetName))) { + if (dataName1.startsWith("SF-") || dataName1.startsWith("XX-")) { + dataName = dataName1.substring(3); + } else { + dataName = dataName1; + } + try { + SoaServerUtil.openByPass(session); + // dataset.setStringProperty("object_name", dataName); + dataset.save(); + System.out.println("datasetName111====" + dataset.getStringProperty("object_name")); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + SoaServerUtil.closeByPass(session); + } + } + break; + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // ʾ + initUI(); + } else { + MessageBox.post(rb.getString("qxzcadtzjxcz19_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + } else if (targetComponent instanceof TCComponentItemRevision) { + itemTargetRev = (TCComponentItemRevision) targetComponent; + String type = itemTargetRev.getType(); + if ("RB3_ZCRevision".equals(type) || "RB3_LBJRevision".equals(type)) { + initUI2(); + } else { + MessageBox.post(rb.getString("qxzwlbb19_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + } else { + MessageBox.post(rb.getString("qxzsjjdx19_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + } + + @SuppressWarnings("serial") + private void initUI2() { + this.setTitle("ͼֽб"); + this.setLayout(new FlowLayout(FlowLayout.CENTER, 2, 3)); + this.setPreferredSize(new Dimension(width, 455)); + this.setLocation(2, 5); + Object[][] cellData = getRecords2(); + model = new DefaultTableModel() { + private static final long serialVersionUID = 6905817304437097181L; + + public boolean isCellEditable(int row, int column) { + return false; + } + }; + + qryTable = new JTable(model) { + public String getToolTipText(MouseEvent e) { + int row = qryTable.rowAtPoint(e.getPoint()); + int col = qryTable.columnAtPoint(e.getPoint()); + String tiptextString = null; + if (row > -1 && col > -1) { + Object value = qryTable.getValueAt(row, col); + if (null != value && !"".equals(value)) + tiptextString = value.toString();// ʾԪ + } + return tiptextString; + } + }; + TableRowSorter sorter = new TableRowSorter(model); + qryTable.setRowSorter(sorter); // ΪJTable + model.setDataVector(cellData, columnNames2); + qryTable.setDefaultRenderer(Object.class, new TableCellTextAreaRenderer()); + JScrollPane scrollPane = new JScrollPane(qryTable); + scrollPane.setPreferredSize(new Dimension(width - 5, 392)); + // JPanel qryPanel=new JPanel(new PropertyLayout(5,5,5,0,5,5)); + JPanel rootPanel = new JPanel(new ButtonLayout()); + rootPanel.add(okBtn2); + rootPanel.add(celBtn); + addListeners(); + this.add(scrollPane); + this.add(rootPanel); + this.setResizable(false); + this.showDialog(); + } + + @SuppressWarnings("serial") + private void initUI() { + this.setTitle("öб"); + this.setLayout(new FlowLayout(FlowLayout.CENTER, 2, 3)); + this.setPreferredSize(new Dimension(width, 455)); + this.setLocation(2, 5); + Object[][] cellData = getRecords(); + model = new DefaultTableModel() { + private static final long serialVersionUID = 6905817304437097181L; + + public boolean isCellEditable(int row, int column) { + return false; + } + }; + + qryTable = new JTable(model) { + public String getToolTipText(MouseEvent e) { + int row = qryTable.rowAtPoint(e.getPoint()); + int col = qryTable.columnAtPoint(e.getPoint()); + String tiptextString = null; + if (row > -1 && col > -1) { + Object value = qryTable.getValueAt(row, col); + if (null != value && !"".equals(value)) + tiptextString = value.toString();// ʾԪ + } + return tiptextString; + } + }; + TableRowSorter sorter = new TableRowSorter(model); + qryTable.setRowSorter(sorter); // ΪJTable + model.setDataVector(cellData, columnNames); + qryTable.setDefaultRenderer(Object.class, new TableCellTextAreaRenderer()); + JScrollPane scrollPane = new JScrollPane(qryTable); + scrollPane.setPreferredSize(new Dimension(width - 5, 392)); + // JPanel qryPanel=new JPanel(new PropertyLayout(5,5,5,0,5,5)); + JPanel rootPanel = new JPanel(new ButtonLayout()); + rootPanel.add(okBtn); + rootPanel.add(celBtn); + addListeners(); + this.add(scrollPane); + this.add(rootPanel); + this.setResizable(false); + this.showDialog(); + } + + private void addListeners() { + this.okBtn2.addActionListener(this); + this.okBtn.addActionListener(this); + this.celBtn.addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent event) { + Object obj = event.getSource(); + if (obj.equals(this.okBtn)) { // ȷ + TCPreferenceService tcp = dataset.getSession().getPreferenceService(); + String[] prefs = tcp.getStringArray(TCPreferenceService.TC_preference_site, "Connor_Open_CadFile"); + Map config = new HashMap(); + for (int i = 0; i < prefs.length; i++) { + String pref = prefs[i]; + int ind = pref.lastIndexOf('='); + if (ind > 0) { + String cadTitle = pref.substring(0, ind); + String tcProp = pref.substring(ind + 1); + config.put(cadTitle, tcProp); + } + } + try { + TCComponentItemRevision itemRev = getTargetItemRev(); + TCComponentItemRevision tzRev = targetRev; + createTempFile(config, itemRev, tzRev); + File[] files = dataset.getFiles(""); + String uid = dataset.getUid(); + String datasetName = dataset.getStringProperty("object_name"); + String tempPath = System.getProperty("java.io.tmpdir"); + String systitem = new SimpleDateFormat("yyyyMMdd-HHmmss").format(new Date()); + if (datasetName.indexOf(".dwg") >= 0) { + datasetName = datasetName.replace(".dwg", ""); + } + System.out.println("UID=====>" + uid); + + File file = files[0]; + String d = file.getParent(); + System.out.println("ͼֽϲĿ¼" + d); +// for (File file : files) { + if ((file != null) && (file.exists())) { + // File dest = new File(tempPath+"\\"+datasetName+".dwg");file.getAbsolutePath() + // File f= new File(tempPath+"\\"+datasetName+".txt"); + File f = new File(file.getAbsolutePath().replace(".dwg", ".txt")); + System.out.println("uid洢·Ϊ" + file.getAbsolutePath().replace(".dwg", ".txt")); + if (f.exists()) { + f.delete(); + f.createNewFile(); + FileWriter fw = new FileWriter(f.getAbsoluteFile()); + BufferedWriter bw = new BufferedWriter(fw); + bw.write(uid); + bw.close(); + } else { + f.createNewFile(); + FileWriter fw = new FileWriter(f.getAbsoluteFile()); + BufferedWriter bw = new BufferedWriter(fw); + bw.write(uid); + bw.close(); + } + + // FileUtils.copyFile(file,dest); + // file.delete(); + // System.out.println( file.delete()); + // dest.delete(); + System.out.println("tempPath=============" + file.getAbsolutePath()); + Runtime.getRuntime().exec("cmd /c start /b call \"" + file.getAbsolutePath() + "\""); +// if(f.exists()) { +// f.delete(); +// } +// if(file.exists()) { +// file.delete(); +// } + } +// break; +// } + } catch (Exception e) { + e.printStackTrace(); + com.teamcenter.rac.util.MessageBox.post(e); + } + // InterfaceAIFComponent[] contexts = new InterfaceAIFComponent[] {dataset}; + // AbstractAIFCommand abstractaifcommand = new + // OpenCommand(AIFUtility.getActiveDesktop(), contexts); + // try { + // abstractaifcommand.executeModal(); + // } catch (Exception e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } + this.disposeDialog(); + } + if (obj.equals(this.okBtn2)) { // ȷ + TCComponentItemRevision itemRev = itemTargetRev; + TCComponentItemRevision tzRev = getTargetItemRev(); + try { + TCComponent[] datasets = tzRev.getReferenceListProperty("IMAN_specification"); + for (int i = 0; i < datasets.length; i++) { + if (datasets[i] instanceof TCComponentDataset) { + TCComponentDataset tzData = (TCComponentDataset) datasets[i]; + String type = tzData.getType(); + if ("RB3_GCAD".equals(type)) { + String name = tzRev.getStringProperty("object_name"); + String revID = tzRev.getStringProperty("item_revision_id"); + // 2022.3.8 + String dataName1 = name + "/" + revID; + String dataName; + String datasetName = tzData.getStringProperty("object_name"); + System.out.println("dataName============" + dataName1); + System.out.println("datasetName============" + datasetName); + if (!(dataName1.equals(datasetName))) { + if (dataName1.startsWith("SF-") || dataName1.startsWith("XX-")) { + dataName = dataName1.substring(3); + } else { + dataName = dataName1; + } + try { + SoaServerUtil.openByPass(session); + datasets[i].setStringProperty("object_name", dataName); + datasets[i].save(); + System.out.println("datasetName111====" + tzData.getStringProperty("object_name")); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + SoaServerUtil.closeByPass(session); + } + } + TCPreferenceService tcp = tzData.getSession().getPreferenceService(); + String[] prefs = tcp.getStringArray(TCPreferenceService.TC_preference_site, + "Connor_Open_CadFile"); + Map config = new HashMap(); + for (int j = 0; j < prefs.length; j++) { + String pref = prefs[j]; + int ind = pref.lastIndexOf('='); + if (ind > 0) { + String cadTitle = pref.substring(0, ind); + String tcProp = pref.substring(ind + 1); + config.put(cadTitle, tcProp); + } + } + + createTempFile(config, itemRev, tzRev); + File[] files = tzData.getFiles(""); + String uid = dataset.getUid(); + String datasetName2 = dataset.getStringProperty("object_name"); + if (datasetName.indexOf(".dwg") >= 0) { + datasetName = datasetName.replace(".dwg", ""); + } + String tempPath = System.getProperty("java.io.tmpdir"); + String systitem = new SimpleDateFormat("yyyyMMdd-HHmmss").format(new Date()); + System.out.println("UID======>" + uid); + File file = files[0]; +// for (File file : files) { + if ((file != null) && (file.exists())) { + File dest = new File(tempPath + "\\" + datasetName2 + systitem + "&" + uid + ".dwg"); + + FileUtils.copyFile(file, dest); + System.out.println("tempPath=============" + dest.getAbsolutePath()); + Runtime.getRuntime().exec("cmd /c start /b call \"" + dest.getAbsolutePath() + "\""); + } +// } + + } + } + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + // InterfaceAIFComponent[] contexts = new InterfaceAIFComponent[] {dataset}; + // AbstractAIFCommand abstractaifcommand = new + // OpenCommand(AIFUtility.getActiveDesktop(), contexts); + // try { + // abstractaifcommand.executeModal(); + // } catch (Exception e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } + this.disposeDialog(); + } + if (obj.equals(this.celBtn)) { // ȡ + this.disposeDialog(); + } + } + + private void createTempFile(Map config, TCComponentItemRevision itemRev, + TCComponentItemRevision tzRev) throws Exception { + if ((tzRev == null) || (config.size() == 0)) { + return; + } + tzRev.refresh(); + TCComponentItem item = tzRev.getItem(); + item.refresh(); + TCComponent itemmaster = item.getRelatedComponent("IMAN_master_form"); + itemmaster.refresh(); + TCComponent revmaster = tzRev.getRelatedComponent("IMAN_master_form_rev"); + revmaster.refresh(); + System.out.println("Load TC Data..."); + StringBuilder content = new StringBuilder(); + // boolean b=false; + for (String key : config.keySet()) { + String propName = (String) config.get(key); +// if(propName.equals("rb3_smzqzt")) { +// b=true; +// } + String propLoc = ""; + int ind = propName.indexOf('.'); + if (ind > 0) { + propLoc = propName.substring(0, ind).toUpperCase(); + propName = propName.substring(ind + 1); + } + String propVal = ""; + switch (propLoc) { + case "ITEM": + propVal = item.getProperty(propName); + break; + case "REV": + propVal = tzRev.getProperty(propName); + if (propVal.startsWith("SF-") || propVal.startsWith("XX-")) { + propVal = propVal.substring(3); + } +// else if(b) { +// if(propVal.contains(":")) { +// propVal=propVal.split(":")[0]; +// } +// } + + break; + case "REVMASTER": + propVal = revmaster.getProperty(propName); + break; + case "ITEMMASTER": + propVal = itemmaster.getProperty(propName); + break; + default: + break; + } + if (key.equals("ͼ")) { + if (propVal.length() > 21) { + String item_id1 = propVal.substring(0, 21); + String item_id2 = propVal.substring(21); + content.append("ͼ1" + "=" + item_id1 + "|"); + content.append("ͼ2" + "=" + item_id2 + "|"); + } else { + content.append("ͼ1" + "=" + propVal + "|"); + content.append("ͼ2" + "=" + "" + "|"); + } + } else { + content.append(key + "=" + propVal + "|"); + } + + } + String status = ""; + AIFComponentContext[] refes = tzRev.whereReferenced(); + for (AIFComponentContext ref : refes) { + InterfaceAIFComponent comp = ref.getComponent(); + if (comp instanceof TCComponentItemRevision) { + status = comp.getProperty("item_revision_id"); + } + } + + content.append("ϰ汾" + "=" + status + "|"); + // String revID = targetRev.getStringProperty("item_revision_id"); + // String userName = session.getUserName(); + // System.out.println("userName=========="+userName); + // SimpleDateFormat df = new SimpleDateFormat(); + // String date = df.format(new Date()); + // content.append("ӡ"); + // content.append("="); + // content.append(userName); + // content.append("|"); + // content.append("ӡʱ"); + // content.append("="); + // content.append(date); + // content.append("|"); + // content.append("汾"); + // content.append("="); + // content.append(revID); + // content.append("|"); + + if (itemRev != null) { + ParseXMLUtil xml = new ParseXMLUtil(); + File file = xml.getSXX("RB3_CLASS_Xml", session); + List> attrList = xml.parseXMLCAD(file); + if (attrList == null || attrList.size() <= 0) { + MessageBox.post("ѡRB3_CLASS_Xmlδã飡", "WARNING", MessageBox.WARNING); + return; + } + String classValue = getClassValue(itemRev, attrList); + System.out.println("classValue===============" + classValue); + + // ȷ content StringBuilder StringBuffer + content.append(classValue); + + // ־Ը content ı仯 + System.out.println("Before trimming: " + content); + + // ֻе content һַ "|" ʱŽнض + if (content.length() > 0 && content.charAt(content.length() - 1) == '|') { + content.setLength(content.length() - 1); + System.out.println("After trimming: " + content); + } else { + System.out.println("No trimming needed."); + } + } + + System.out.println("TC Data: " + content); + String filePath = System.getenv("TEMP") + "\\" + "signoff.txt"; + FileOutputStream fos = new FileOutputStream(filePath); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos)); + bw.write(content.toString()); + bw.close(); + fos.close(); + System.out.println("Load TC Data Complete"); + } + + private TCComponentItemRevision getTargetItemRev() { + // TODO Auto-generated method stub + TCComponentItemRevision rev = null; + int tableRow = qryTable.getSelectedRow(); + qryTable.setRowSelectionInterval(tableRow, tableRow); + int indexRow = qryTable.convertRowIndexToModel(tableRow); + // 2022.3.8 + String selectedID1 = (String) qryTable.getModel().getValueAt(indexRow, 0); + String selectedID; + if (selectedID1.startsWith("SF-") || selectedID1.startsWith("XX-")) { + selectedID = selectedID1.substring(3); + } else { + selectedID = selectedID1; + } + if (indexRow >= 0) { + if (!("ͼֽ".equals(selectedID))) { + String selectedRev = (String) qryTable.getModel().getValueAt(indexRow, 1); + StringBuilder sb = new StringBuilder(selectedID); + sb.append(";"); + sb.append(selectedRev); + String str = sb.toString(); + System.out.println("selectedID===================" + selectedID); + System.out.println("selectedRev===================" + selectedRev); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + List compList = queryObject(rb.getString("item_revquery.TITLE"), + new String[] { rb.getString("item_idquery.TITLE"), rb.getString("revquery.TITLE") }, + new String[] { selectedID, selectedRev }); + if (compList != null) { + if (compList.size() > 0) { + rev = (TCComponentItemRevision) compList.get(0); + } + } + } + } + return rev; + } + + /** + * ͨѯѯĿ + * + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("myzdcx19_display.TITLE") + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + return null; + } + } + + /* + * ȡӳķ + */ + public String getClassValue(TCComponent comp, List> allList) { + // TODO Auto-generated method stub + List attrList = allList.get(0); + List revList = allList.get(1); + + List vals = new ArrayList(); + StringBuilder revSb = new StringBuilder(); + StringBuilder classSb = new StringBuilder(); + List classPropList = new ArrayList(); + try { + String className = comp.getClassificationClass(); + if ("".equals(className.trim())) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(comp.getStringProperty("item_id") + rb.getString("gwlmyfszfl19_display.TITLE"), "ʾ", + MessageBox.WARNING); + return null; + } + TCComponentICO[] icos = comp.getClassificationObjects(); + TCClassificationService classificationService = comp.getSession().getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(className); + // String icoPUID = icos[0].getUid(); + Map claMap = new HashMap(); + if (icos != null && icos.length > 0) { + ICSProperty[] icss = icos[0].getICSProperties(true); + for (ICSProperty ics : icss) { + claMap.put(ics.getId(), ics.getValue()); + } + } + for (Map.Entry entry : claMap.entrySet()) { + System.out.println("key = " + entry.getKey() + ", value = " + entry.getValue()); + } + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + + if (icsAttrS != null) { + for (ICSAdminClassAttribute attr : icsAttrS) { + if (attr.isReferenceAttribute()) { + continue; + } + if (attr.isReference()) { + continue; + } + ClassPropBean bean = new ClassPropBean(attr); + classPropList.add(bean); + } + } + for (int j = 0; j < attrList.size(); j++) { + String classValue = attrList.get(j); + String revValue = revList.get(j); + if (classValue.contains(";") && revValue.contains(";")) { + String[] classValues = classValue.split(";"); + String[] revValues = revValue.split(";"); + if (className.equals(classValues[0])) { + for (int k = 1; k < classValues.length; k++) { + String attrName = classValues[k]; + System.out.println("attrName=====" + attrName); + if (attrName.contains("+")) { + String[] attrs = attrName.split("\\+"); + for (int i = 0; i < classPropList.size(); i++) { + ClassPropBean bean = classPropList.get(i); + // ޸ + + if (attrs[1].equals(bean.propDisName)) { + String value = claMap.get(bean.propID); + if (bean.isLov) { + String lovValue = bean.lovMapping.get(value); + classSb.append(attrs[0]); + classSb.append("="); + if (lovValue != null) { + classSb.append(lovValue); + } else { + classSb.append(""); + } + + if (k < classValues.length - 1) { + classSb.append("|"); + } + } else { + classSb.append(attrs[0]); + classSb.append("="); + if (value != null) { + + classSb.append(value); + + } else { + classSb.append(""); + } + + if (k < classValues.length - 1) { + classSb.append("|"); + } + } + break; + } + } + } + + } + for (int k = 1; k < revValues.length; k++) { + String attrName = revValues[k]; + if (attrName.contains("+")) { + String[] attrs = attrName.split("\\+"); + revSb.append(attrs[0]); + revSb.append("="); + revSb.append(comp.getProperty(attrs[1])); + revSb.append("|"); + } + } + break; + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + revSb.append(classSb.toString()); + String spec = revSb.toString(); + return spec; + } + + /** + * ѯϢȡ¼ + * + * @return tabledataVector + */ + private Object[][] getRecords() { + List list = new ArrayList<>(); + ChangeOwnerbean tzBean = new ChangeOwnerbean("ͼֽ", "ͼֽ", "ͼֽ", "ͼֽ", "ͼֽ"); + list.add(tzBean); + try { + if (targetRev != null) { + TCComponent[] targets = targetRev.getReferenceListProperty("representation_for"); + for (int i = 0; i < targets.length; i++) { + String id = targets[i].getStringProperty("item_id"); + String revID = targets[i].getStringProperty("item_revision_id"); + String name = targets[i].getStringProperty("object_name"); + String cph = targets[i].getStringProperty("rb3_cph"); + TCComponent user = targets[i].getRelatedComponent("owning_user"); + String owner = user.getStringProperty("user_name"); + ChangeOwnerbean bean = new ChangeOwnerbean(id, revID, name, cph, owner); + list.add(bean); + } + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // װ + Object res[][] = new Object[list.size()][this.columnNames.length]; + int i = 0; + for (ChangeOwnerbean record : list) { + res[i++] = new Object[] { record.getId(), record.getRev(), record.getName(), record.getCph(), + record.getOwner() }; + } + return res; + } + + /** + * ѯͼֽϢȡ¼ + * + * @return tabledataVector + */ + private Object[][] getRecords2() { + List list = new ArrayList<>(); + try { + if (itemTargetRev != null) { + TCComponent[] targets = itemTargetRev.getReferenceListProperty("TC_Is_Represented_By"); + for (int i = 0; i < targets.length; i++) { + String id = targets[i].getStringProperty("item_id"); + String revID = targets[i].getStringProperty("item_revision_id"); + String name = targets[i].getStringProperty("object_name"); + TCComponent user = targets[i].getRelatedComponent("owning_user"); + String owner = user.getStringProperty("user_name"); + ChangeOwnerbean bean = new ChangeOwnerbean(id, revID, name, owner); + list.add(bean); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // װ + Object res[][] = new Object[list.size()][this.columnNames2.length]; + int i = 0; + for (ChangeOwnerbean record : list) { + res[i++] = new Object[] { record.getId(), record.getRev(), record.getName(), record.getOwner() }; + } + return res; + } + + private class TableCellTextAreaRenderer extends JTextArea implements TableCellRenderer { + private static final long serialVersionUID = -7149062901533662226L; + + public TableCellTextAreaRenderer() { + // setLineWrap(true); //Զ + // setWrapStyleWord(true); + } + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, + int row, int column) { + if (isSelected) { + // ñѡеһеɫ + setBackground(new Color(51, 153, 255)); + setForeground(new Color(255, 255, 255)); + } else { + setBackground(table.getBackground()); + setForeground(table.getForeground()); + } + + // 㵱еѸ߶ + int maxPreferredHeight = 0; + for (int i = 0; i < table.getColumnCount(); i++) { + setText("" + table.getValueAt(row, i)); + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); + } + + if (table.getRowHeight(row) != maxPreferredHeight) + table.setRowHeight(row, maxPreferredHeight); + setText(value == null ? "" : value.toString()); + return this; + } + } +} diff --git a/src/com/connor/rb/plm/rb019/SelectOwnerHandler.java b/src/com/connor/rb/plm/rb019/SelectOwnerHandler.java new file mode 100644 index 0000000..250f447 --- /dev/null +++ b/src/com/connor/rb/plm/rb019/SelectOwnerHandler.java @@ -0,0 +1,19 @@ +package com.connor.rb.plm.rb019; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class SelectOwnerHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + new Thread(new SelectOwnerAction(app, "")).start(); + return null; + } + +} diff --git a/src/com/connor/rb/plm/rb020/Rb020Handler.java b/src/com/connor/rb/plm/rb020/Rb020Handler.java new file mode 100644 index 0000000..15c958c --- /dev/null +++ b/src/com/connor/rb/plm/rb020/Rb020Handler.java @@ -0,0 +1,23 @@ +package com.connor.rb.plm.rb020; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.rb.plm.rb013one.Rb013Dialog; +import com.connor.rb.plm.rb019.SelectOwnerAction; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AbstractAIFSession; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class Rb020Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + new Thread(new RelatePasteAction(app, "")).start(); + return null; + } + +} diff --git a/src/com/connor/rb/plm/rb020/RelatePasteAction.java b/src/com/connor/rb/plm/rb020/RelatePasteAction.java new file mode 100644 index 0000000..5ccb3a1 --- /dev/null +++ b/src/com/connor/rb/plm/rb020/RelatePasteAction.java @@ -0,0 +1,195 @@ +package com.connor.rb.plm.rb020; + +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import org.eclipse.core.commands.ExecutionEvent; + +import java.awt.datatransfer.Clipboard; +import com.teamcenter.rac.aif.AIFClipboard; +import com.teamcenter.rac.aif.AIFPortal; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentPseudoFolder; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.log.Debug; + +/** + * Company: www.connor.com + * + * @author E-mail: duanyf@connor.net.cn + * @date 2020630 + * @version 1.0 + */ +public class RelatePasteAction extends AbstractAIFAction { + private AbstractAIFApplication app; + TCPreferenceService preService; + // ճϵİ汾ͺ͹ϵĿİ汾ͺ͹ϵ + Map map1 = new HashMap(); + + // private ExecutionEvent arg0; + public RelatePasteAction(AbstractAIFApplication app, String arg1) { + super(app, arg1); + this.app = app; + } + + @Override + public void run() { + + TCSession session = (TCSession) app.getSession(); + preService = session.getPreferenceService(); + String[] preValues = preService.getStringValues("RB3_RevisionRelation"); + if (preValues == null || preValues.length == 0) { + return; + } else { + System.out.println("ѡ:" + preValues); + for (String s : preValues) { + String[] split = s.split("="); + String[] s1 = split[0].split("\\+"); + String[] s2 = split[1].split("\\+"); + String key1 = s1[0] + "&" + s2[0]; + String[] s3 = { s1[1], s2[1] }; + String key2 = s2[0] + "&" + s1[0]; + String[] s4 = { s2[1], s1[1] }; + map1.put(key1, s3); + map1.put(key2, s4); + } + } + AIFClipboard var4 = AIFPortal.getClipboard(); + Transferable copytar = var4.getContents(var4); + Object var7 = new ArrayList(); + if (var7 == null || ((List) var7).size() == 0) { + if (Debug.isOn("action,copy,cut,paste")) { + Debug.println("Get pasting objs from aif clipboard."); + } + + if (copytar != null) { + try { + var7 = (List) copytar.getTransferData(new DataFlavor(Vector.class, "AIF Vector")); + } catch (Exception var13) { + var7 = null; + } + } + } + if (var7 == null) { + return; + } + Object var6 = var7; + int var8 = ((List) var7).size(); + ArrayList var9 = new ArrayList(); + + for (int var10 = 0; var10 < var8; ++var10) { + InterfaceAIFComponent var11 = (InterfaceAIFComponent) ((List) var6).get(var10); + if (var11 instanceof TCComponentPseudoFolder + && !(((TCComponentPseudoFolder) var11).getOwningComponent() instanceof TCComponentTask)) { + return; + } + + var9.add((TCComponent) var11); + } + if (var9.isEmpty()) { + return; + } + + TCComponent[] var15 = (TCComponent[]) var9.toArray(new TCComponent[var9.size()]); + + for (int i = 0; i < var15.length; i++) { + System.out.println("var15" + i + "====>" + var15[i]);// var15ѡиƵĶ + } + + TCComponent target = (TCComponent) app.getTargetComponent(); + + // 鸴ƶ + String copytype = null; + copytype = var15[0].getType(); + +// if(copytype == null || (!"RB3_ZCRevision".equals(copytype)&&!"RB3_LBJRevision".equals(copytype))) { +// if((!"RB3_CPTRevision".equals(copytype)&&!"RB3_CGTRevision".equals(copytype) +// &&!"RB3_GGQQRevision".equals(copytype))) { +// return; +// } +// } + // õαļĶ汾ԼΪļеnameøαļӦĶ汾µĹϵ +// String objectName = target.toString(); + String objectName = ""; + try { + objectName = target.getDefaultPasteRelation(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + System.out.println("objectName===>" + objectName); + TCComponent owningObj = null; + String owningObjType = null; + String flag = null; + try { + owningObj = target.getRelatedComponent("owning_object"); + owningObjType = owningObj.getStringProperty("object_type"); + System.out.println("owningObjTypeΪ:" + owningObjType); + flag = owningObjType + "&" + copytype; + + } catch (TCException e) { + e.printStackTrace(); + return; + } + String[] ss = map1.get(flag); + if (null == ss) { + System.out.println("ճʧܣ"); + return; + } + try { + var15[0].setRelated(ss[1], new TCComponent[] { owningObj }); + owningObj.setRelated(ss[0], var15); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // ļеĶ԰汾ΪջͲ +// if(owningObj==null || (!"RB3_ZCRevision".equals(owningObj.getType())&&!"RB3_LBJRevision".equals(owningObj.getType()) )) { +// if((!"RB3_CPTRevision".equals(owningObj.getType())&&!"RB3_CGTRevision".equals(owningObj.getType()) +// &&!"RB3_GGQQRevision".equals(owningObj.getType()))) { +// return; +// } +// } +// // +// if(objectName!=null) { +// if("".equals(objectName)) { +// //Ϊ̱汾ıԴ +// try { +// //TCComponent[] copyObjs = new TCComponent[1]; +// //var15.setRelated("XJA2_ChangeFrom",); +// var15[0].setRelated("EC_affected_item_rel", new TCComponent[] {owningObj}); +// owningObj.setRelated("RB3_BGSQ",var15); +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// }else if("Ӱ".equals(objectName)) { +// try { +// var15[0].setRelated("RB3_BGSQ", new TCComponent[] {owningObj}); +// owningObj.setRelated("EC_affected_item_rel",var15); +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// +// } + + // + + System.out.println("ճ"); + + } + +} diff --git a/src/com/connor/rb/plm/rb021/Rb021Handler.java b/src/com/connor/rb/plm/rb021/Rb021Handler.java new file mode 100644 index 0000000..7c805b8 --- /dev/null +++ b/src/com/connor/rb/plm/rb021/Rb021Handler.java @@ -0,0 +1,60 @@ +package com.connor.rb.plm.rb021; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.common.NotDefinedException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; + +public class Rb021Handler extends AbstractHandler { + + private AbstractAIFUIApplication app; + private TCSession session; + private TCComponent target; + + @Override + public Object execute(ExecutionEvent arg0) { + app = AIFUtility.getCurrentApplication(); + target = (TCComponent) app.getTargetComponent(); + session = (TCSession) app.getSession(); + System.out.println(target.getType()); + + try { + if (target != null && target.getType().equals("EPMPerformSignoffTask")) { + String name = arg0.getCommand().getName(); + System.out.println(name); + String annotation = session.getPreferenceService().getStringValue("renben021"); + + TCUserService userService = session.getUserService(); + if (name.equals("׼")) { + Object[] arg1 = { target, 1, annotation }; + userService.call("approve_review_task", arg1); + } + if (name.equals("ܾ")) { + Object[] arg1 = { target, 0, annotation }; + userService.call("approve_review_task", arg1); + } + + } else { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("qxzshrw19_display.TITLE"), "", MessageBox.ERROR); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return null; + } + +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/rb022/ChangeOwnerbean.java b/src/com/connor/rb/plm/rb022/ChangeOwnerbean.java new file mode 100644 index 0000000..2ff04a4 --- /dev/null +++ b/src/com/connor/rb/plm/rb022/ChangeOwnerbean.java @@ -0,0 +1,64 @@ +package com.connor.rb.plm.rb022; + +public class ChangeOwnerbean { + + private String id; + private String rev; + private String name; + private String cph; + private String owner; + + public ChangeOwnerbean() { + super(); + } + + public ChangeOwnerbean(String id, String rev, String name, String cph, String owner) { + super(); + this.id = id; + this.rev = rev; + this.name = name; + this.cph = cph; + this.owner = owner; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getRev() { + return rev; + } + + public void setRev(String rev) { + this.rev = rev; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCph() { + return cph; + } + + public void setCph(String cph) { + this.cph = cph; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + +} diff --git a/src/com/connor/rb/plm/rb022/ConfirmDialog.java b/src/com/connor/rb/plm/rb022/ConfirmDialog.java new file mode 100644 index 0000000..85c081b --- /dev/null +++ b/src/com/connor/rb/plm/rb022/ConfirmDialog.java @@ -0,0 +1,76 @@ +package com.connor.rb.plm.rb022; + +import javax.swing.*; + +import com.itextpdf.text.pdf.PdfStructTreeController.returnType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.util.MessageBox; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; + +public class ConfirmDialog extends JDialog { + private JList list; + private JButton confirmButton; + private JButton cancelButton; + private List objects; + private TCComponentItemRevision selectedObjects; + + public ConfirmDialog(JFrame parent, List objects) { + super(parent, "ȷϴ", true); + this.objects = objects; + initUI(); + initListeners(); + setSize(300, 300); + setLocationRelativeTo(null); + setResizable(false); + setVisible(true); + } + + private void initUI() { + JPanel mainPanel = new JPanel(new BorderLayout()); + // һ壬JListӵ + JScrollPane scrollPane = new JScrollPane(); + list = new JList<>(objects.toArray()); + scrollPane.setViewportView(list); + mainPanel.add(scrollPane, BorderLayout.CENTER); + // һť壬ȷϰťȡťӵ + JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + confirmButton = new JButton("ȷ"); + cancelButton = new JButton("ȡ"); + buttonPanel.add(confirmButton); + buttonPanel.add(cancelButton); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + // ӵ + setContentPane(mainPanel); + } + + private void initListeners() { + confirmButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try { + selectedObjects = (TCComponentItemRevision) list.getSelectedValue(); + } catch (Exception e1) { + MessageBox.post("ѡ", "ʾ", MessageBox.INFORMATION); + // TODO Auto-generated catch block + e1.printStackTrace(); + } + dispose(); + } + }); + cancelButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + return; + } + }); + } + + public TCComponentItemRevision getSelectedObjects() { + return selectedObjects; + } +} diff --git a/src/com/connor/rb/plm/rb022/Rb022Dialog.java b/src/com/connor/rb/plm/rb022/Rb022Dialog.java new file mode 100644 index 0000000..ff4291c --- /dev/null +++ b/src/com/connor/rb/plm/rb022/Rb022Dialog.java @@ -0,0 +1,1384 @@ +package com.connor.rb.plm.rb022; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.print.PageFormat; +import java.awt.print.Paper; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.atomic.AtomicInteger; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableRowSorter; + +import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException; +import org.apache.pdfbox.printing.PDFPrintable; + +import com.connor.rb.plm.rb019.ChangeOwnerbean; +import com.connor.rb.plm.util.ClassPropBean; +import com.connor.rb.plm.util.ParseXMLUtil; +import com.connor.rb.plm.util.SoaServerUtil; +import com.spire.pdf.PdfDocument; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentManager; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +import de.hunsicker.util.concurrent.TimeoutException; + +public class Rb022Dialog extends AbstractAIFDialog implements ActionListener { + + private static final long serialVersionUID = 6130114042631785757L; + private static final int width = 700; + private TCPreferenceService service; + DefaultTableModel model; + private AbstractAIFUIApplication app; + private TCSession session; + private TCComponentDataset dataset; + private TCComponentItemRevision targetRev; + private JButton okBtn = new JButton("ȷ"); + private JButton celBtn = new JButton("ȡ"); + private String[] columnNames = { "ID", "汾", "", "Ʒ", "" }; + private JTable qryTable; + private Object[][] beans; + private String txtValue = ""; + private Map userMap = new HashMap(); + private String setName = ""; + private String itemRevId = ""; + private String itemRevId1 = ""; + private boolean isRelease = false; + + public Rb022Dialog(AbstractAIFUIApplication app) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + String[] users = service.getStringValues("RB3_user_uid"); + if (users == null || users.length <= 0) { + MessageBox.post("ѡRB3_user_uidδã飡", "WARNING", MessageBox.WARNING); + return; + } + for (int i = 0; i < users.length; i++) { + if (users[i].contains("=")) { + String[] us = users[i].split("="); + userMap.put(us[0], us[1]); + } + } + } + + /** + * ˢtableʾÿ + */ + private void refreshTable() { + qryTable.removeAll(); + model.setDataVector(beans, columnNames); + // qryTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); + qryTable.getColumnModel().getColumn(0).setPreferredWidth(110); + qryTable.getColumnModel().getColumn(1).setPreferredWidth(50); + qryTable.getColumnModel().getColumn(2).setPreferredWidth(80); + qryTable.getColumnModel().getColumn(3).setPreferredWidth(50); + qryTable.getColumnModel().getColumn(4).setPreferredWidth(110); + + } + + @Override + public void run() { + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date = new Date(); + String formattedDate = formatter.format(date); + System.out.println("ʼʱ䣨ˮӡ" + formattedDate); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if (targetComponent instanceof TCComponentDataset) { + dataset = (TCComponentDataset) targetComponent; + String type = dataset.getType(); + try { + setName = dataset.getProperty("object_name"); + System.out.println("setName is ==========>" + setName); + if (setName.contains(".")) { + setName = setName.substring(0, setName.lastIndexOf(".")); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + if ("RB3_GCAD".equals(type)) { + try { + AIFComponentContext[] referenceds = dataset.whereReferenced(); +// //ݼõı +// if(referenceds.length<=0) { +// MessageBox.post("ݼö󣡣","ʾ",MessageBox.INFORMATION); +// return; +// } + String release = dataset.getProperty("release_status_list"); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + if (release.contains(rb.getString("fabu_TITLE"))) {// TCM Released + isRelease = true; + } + List objects = new ArrayList(); + for (int i = 0; i < referenceds.length; i++) { + InterfaceAIFComponent comp = referenceds[i].getComponent(); + if (comp instanceof TCComponentItemRevision) { + targetRev = (TCComponentItemRevision) comp; + try { + System.out.println("targetRev:" + comp.getProperty("object_string")); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + // Object[] objs = new Object[2]; + // objs[1] = ""; + // objs[0] = targetRev; + // SoaServerUtil.dwgToPDF(session,objs); + + objects.add(targetRev); + } + + } + ConfirmDialog dialog = new ConfirmDialog(null, objects); + TCComponentItemRevision selectedObjects = dialog.getSelectedObjects(); + if (selectedObjects != null) { + System.out.println("ѡ¶"); + System.out.println(selectedObjects.toString()); + targetRev = selectedObjects; + String name = targetRev.getStringProperty("object_name"); + String revID = targetRev.getStringProperty("item_revision_id"); + itemRevId1 = revID; + // 2022.3.8 + String dataName1 = name + "/" + revID; + String dataName = ""; + String datasetName = dataset.getStringProperty("object_name"); + System.out.println("dataName============" + dataName1); + System.out.println("datasetName============" + datasetName); + if (!(dataName1.equals(datasetName))) { + if (dataName1.startsWith("SF-") || dataName1.startsWith("XX-")) { + dataName = dataName1.substring(3); + } else { + dataName = dataName1; + } +// SoaServerUtil.openByPass(session); +// // dataset.setStringProperty("object_name", dataName); +// dataset.save(); +// System.out.println("datasetName111====" + dataset.getStringProperty("object_name")); +// SoaServerUtil.closeByPass(session); + } + } else { + System.out.println("ûȡ˲"); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("qxzcadtzjxcz19_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + } else { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("qxzsjjdxjxcz22_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + + // ʾ + initUI(); + + } + + @SuppressWarnings("serial") + private void initUI() { + this.setTitle("öб"); + this.setLayout(new FlowLayout(FlowLayout.CENTER, 2, 3)); + this.setPreferredSize(new Dimension(width, 455)); + this.setLocation(2, 5); + Object[][] cellData = getRecords(); + model = new DefaultTableModel() { + private static final long serialVersionUID = 6905817304437097181L; + + public boolean isCellEditable(int row, int column) { + return false; + } + }; + + qryTable = new JTable(model) { + public String getToolTipText(MouseEvent e) { + int row = qryTable.rowAtPoint(e.getPoint()); + int col = qryTable.columnAtPoint(e.getPoint()); + String tiptextString = null; + if (row > -1 && col > -1) { + Object value = qryTable.getValueAt(row, col); + if (null != value && !"".equals(value)) + tiptextString = value.toString();// ʾԪ + } + return tiptextString; + } + }; + TableRowSorter sorter = new TableRowSorter(model); + qryTable.setRowSorter(sorter); // ΪJTable + model.setDataVector(cellData, columnNames); + qryTable.setDefaultRenderer(Object.class, new TableCellTextAreaRenderer()); + JScrollPane scrollPane = new JScrollPane(qryTable); + scrollPane.setPreferredSize(new Dimension(width - 5, 392)); + // JPanel qryPanel=new JPanel(new PropertyLayout(5,5,5,0,5,5)); + JPanel rootPanel = new JPanel(new ButtonLayout()); + rootPanel.add(okBtn); + rootPanel.add(celBtn); + addListeners(); + this.add(scrollPane); + this.add(rootPanel); + this.setResizable(false); + this.showDialog(); + } + + private void addListeners() { + this.okBtn.addActionListener(this); + this.celBtn.addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent event) { + Object obj = event.getSource(); + if (obj.equals(this.okBtn)) { // ȷ + + try { + + String signoff = ""; + if (dataset.getType().equals("RB3_QRT")) { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + String date = df.format(new Date()); + signoff = "ӡ=" + session.getUser().getStringProperty("user_id") + "|ӡʱ=" + date; + } else { + signoff = createTempFile(); + } + + if (signoff == null) { + this.disposeDialog(); + return; + } + Object[] objs = new Object[2]; + objs[1] = signoff; + objs[0] = targetRev; + if (session == null) { + session = (TCSession) app.getSession(); + } + TCComponent[] datasets = targetRev.getReferenceListProperty("IMAN_specification"); + List removeDatasets = new ArrayList<>(); + // + TCComponentItemType itemtype = (TCComponentItemType) session.getTypeComponent("RB3_CPT"); + TCComponentItem copyItem = itemtype.create( + "Ʒͼ" + String.valueOf(new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())), "A", "", + "", "", null); + TCComponentItemRevision copytargetRev = copyItem.getLatestItemRevision(); + boolean flag = false; + +// //ѡеcad½תpdfȡtarget + if (datasets.length > 1) { + for (TCComponent dat : datasets) { + if (dat instanceof TCComponentDataset) { + if (dat.getUid().equals(dataset.getUid())) { + try { + SoaServerUtil.openByPass(session); + copytargetRev.add("IMAN_specification", dat); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + SoaServerUtil.closeByPass(session); + } + objs[0] = copytargetRev; + + flag = true; + break; + } + } + } + } + // תcadʱɾ + try { + SoaServerUtil.dwgToPDF(session, objs); + } catch (Exception e) { + System.out.println("===>SoaServerUtil.dwgToPDF(session,objs)ʧܣ"); + copyItem.delete(); + e.printStackTrace(); + } + +// System.out.println("====ɾݼ====="); +// for(TCComponent dat:removeDatasets) { +// targetRev.add("IMAN_specification", dat); +// } + if (flag) { + datasets = copytargetRev.getReferenceListProperty("IMAN_specification"); + for (TCComponent dat : datasets) { + if (dat instanceof TCComponentDataset) { + if (((TCComponentDataset) dat).getType().equals("PDF")) { + try { + SoaServerUtil.openByPass(session); + targetRev.add("IMAN_specification", dat); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + SoaServerUtil.closeByPass(session); + } + break; + } + } + } + } + copyItem.delete(); + + this.disposeDialog(); + datasets = targetRev.getReferenceListProperty("IMAN_specification"); + + try { + SoaServerUtil.openByPass(session); + for (int i = 0; i < datasets.length; i++) { + if (datasets[i] instanceof TCComponentDataset) { + // System.out.println("ѡеݼӡ====>"+dataset.getStringProperty("item_id")+"-"+dataset.getStringProperty("object_name")); + TCComponentDataset data = (TCComponentDataset) datasets[i]; + + String type = data.getType(); + + System.out.println("type:" + type); + if ("PDF".equals(type)) { + String proName = data.getProperty("object_name"); + // ݼʱ + TCProperty tcp = data.getTCProperty("creation_date"); + Date date1 = tcp.getDateValue(); + Date date = new Date(); + long time1 = date1.getTime(); + long time = date.getTime(); + // PDFݼʱڵʱʱ + long interval_time = time1 - time; + if (proName.contains(".")) { + proName = proName.substring(0, proName.lastIndexOf(".")); + } + if (proName.equals(setName)) {// pdfݼͼֽͬӡ + // statu = printPDF(files[0]); + + File[] files = data.getFiles(""); + String datasetName = data.getStringProperty("object_name"); + targetRev.remove("IMAN_specification", new TCComponent[] { data }); + + data.delete(); + String path = files[0].getAbsolutePath(); + + // ȡݼö,жǷȷͼеĻͲˮӡ + AIFComponentContext[] contexts = dataset.whereReferenced(); + boolean isQRT = false; + int numWatch = 0; + for (AIFComponentContext context : contexts) { + if (context.getComponent().getType().contains("RB3_QRT")) { + isQRT = true; + break; + } else if (context.getComponent().getType().contains("RB3_XZCPTRevision")) { + System.out.println("ûȷͼΪxzcp"); + numWatch = 1; + } + + } + + if (!isQRT) { + String userID = session.getUser().getUserId().toUpperCase(); + System.out.println("ûIDΪ:" + userID); + System.out.println("txtValueֵΪ:" + txtValue); + System.out.println("pathֵΪ:" + path); + ProcessBuilder process = null; + if (numWatch == 0) { + process = new ProcessBuilder("java", "-jar", + "C:\\Siemens\\Teamcenter12\\bin\\SetUser.jar", txtValue, path, + userID); + } else { + System.out.println("׼setsuer"); + process = new ProcessBuilder("java", "-jar", + "C:\\Siemens\\Teamcenter12\\bin\\SetUser.jar", txtValue, path, + userID + "%"); + } + + Process pro; +// String[] cmd = new String[] { +// "cmd.exe","/C","java -jar C:\\Siemens\\Teamcenter12\\bin\\SetUser.jar " + txtValue + " "+ path+" "+userID}; + try { + System.out.println("ʼSetUser.jar"); + pro = process.start(); + pro.waitFor(); + BufferedReader br = new BufferedReader( + new InputStreamReader(pro.getInputStream())); + String readLine = br.readLine(); + if (readLine == null) { + String getenv = System.getenv("FMS_HOME"); + String replace = getenv.replace("tccs", "portal\\plugins");// ȡִjar· + ProcessBuilder process1 = null; + if (numWatch == 0) { + process1 = new ProcessBuilder("java", "-jar", + replace + "\\SetUser.jar", txtValue, path, userID); + } else { + System.out.println("׼setsuer"); + process1 = new ProcessBuilder("java", "-jar", + replace + "\\SetUser.jar", txtValue, path, userID + "%"); + } + Process pro1; + pro1 = process1.start(); + pro1.waitFor(); + } + +// Runtime.getRuntime().exec(cmd); + } catch (Exception e) { + System.out.println("SetUserܳ쳣!"); + e.printStackTrace(); + } + } + + // int statu = printPDF3(path, datasetName); + AtomicInteger result = new AtomicInteger(0); + result.set(printPDF3(path, datasetName)); + +// Thread pdfThread = new Thread(() -> { +// +// }); +// +// pdfThread.start(); +// +// try { +// pdfThread.join(300000); // ȴ5 +// if (pdfThread.isAlive()) { +// pdfThread.interrupt(); // ߳Уж߳ +// MessageBox.post("PDFӡʱ", "ʾ", MessageBox.INFORMATION); +// throw new TimeoutException(interval_time, "PDF print time out"); +// } +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } + + // ʹget()ȡ'statu'ֵ + int statu = result.get(); +// int statu = printPDF(files[0]); +// System.out.println("·===>"+path); +// if(new File(path).exists()) { +// System.out.println("ɾ===>"+path); +// new File(path).delete(); +// } +// files[0].delete(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle + .getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (statu != 0) { + MessageBox.post(rb.getString("dycg15_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + } else { + MessageBox.post(rb.getString("dysb15_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + } + + } else if (interval_time < 300000) {// pdfʱС5ӣɾݼ + targetRev.remove("IMAN_specification", new TCComponent[] { data }); + data.delete(); + } + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date11 = new Date(); + String formattedDate = formatter.format(date11); + System.out.println("ʱ䣨ˮӡ" + formattedDate); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + SoaServerUtil.closeByPass(session); + } + + // TCComponent[] refes = + // targetRev.getReferenceListProperty("IMAN_specification"); + // for (int j = 0; j < refes.length; j++) { + // TCComponent data = refes[j]; + // if("PDF".equals(data.getType())) { + // TCComponentDataset pdfData = (TCComponentDataset) data; + // File[] files = pdfData.getFiles(""); + // String path = files[0].getAbsolutePath(); + // System.out.println("path================"+path); + // print(path); + //// InterfaceAIFComponent[] contexts = new InterfaceAIFComponent[] {pdfData}; + //// AbstractAIFCommand abstractaifcommand = new + // OpenCommand(AIFUtility.getActiveDesktop(), contexts); + //// try { + //// abstractaifcommand.executeModal(); + //// } catch (Exception e) { + //// // TODO Auto-generated catch block + //// e.printStackTrace(); + //// } + // + // } + // } + + } catch (Exception e) { + e.printStackTrace(); + com.teamcenter.rac.util.MessageBox.post(e); + } + // InterfaceAIFComponent[] contexts = new InterfaceAIFComponent[] {dataset}; + // AbstractAIFCommand abstractaifcommand = new + // OpenCommand(AIFUtility.getActiveDesktop(), contexts); + // try { + // abstractaifcommand.executeModal(); + // } catch (Exception e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } + } + if (obj.equals(this.celBtn)) { // ȡ + this.disposeDialog(); + } + } + + private String createTempFile() { + StringBuilder content = new StringBuilder(); + StringBuilder txtSB = new StringBuilder(); + TCComponentItemRevision itemRev = getTargetItemRev(); + try { + if (isRelease) { + TCComponent revmaster = targetRev.getRelatedComponent("IMAN_master_form_rev"); + String[] strs = service.getStringValues("RB3_process_sign"); + if (strs == null || strs.length <= 0) { + MessageBox.post("ѡRB3_process_signδã飡", "WARNING", MessageBox.WARNING); + return ""; + } + for (int i = 0; i < strs.length; i++) { + System.out.println(":" + strs[i]); + String[] str = strs[i].split("="); + content.append(str[0]); + content.append("="); + String value = revmaster.getStringProperty(str[1]); + System.out.println("汾ϵֵΪ:" + value); + if (value == null) { + value = ""; + } else { + + // uidתcomponent + String uid = userMap.get(value); + if (uid != null) { + System.out.println("ǩͼƬuidΪ:" + uid); + txtSB.append(str[0]); + txtSB.append("="); + TCComponent data = session.stringToComponent(uid); + TCComponentDataset dataset = (TCComponentDataset) data; + File[] files = dataset.getFiles(""); + String path = files[0].getAbsolutePath(); + System.out.println("ǩͼƬ·:" + path); + txtSB.append(path); + txtSB.append("|"); + } + + } + content.append(value); + content.append("|"); + + } + txtValue = txtSB.toString(); + if (txtValue.equals("")) { + txtValue = "null"; + } + String revID = targetRev.getStringProperty("item_revision_id"); + String temp_item_id = targetRev.getStringProperty("item_id"); + String item_id1 = null; + String item_id = null; + if (temp_item_id.startsWith("XX-") || temp_item_id.startsWith("SF-")) { + temp_item_id = temp_item_id.substring(3); + } + if (temp_item_id.length() > 21) { + item_id = temp_item_id.substring(0, 21); + item_id1 = temp_item_id.substring(21); + } else { + item_id = temp_item_id; + } + AIFComponentContext[] refes = targetRev.whereReferenced(); + // String itemRevId1=null; + // if(refes!=null) { + // for(AIFComponentContext aifComp:refes) { + // InterfaceAIFComponent component = aifComp.getComponent(); + // if(component instanceof TCComponentItemRevision) { + // try { + // itemRevId1=component.getProperty("item_revision_id"); + // break; + // } catch (Exception e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } + // } + // } + // }else { + // itemRevId1=targetRev.getProperty("item_revision_id"); + // } + // String status=targetRev.getProperty("rb3_smzqzt"); + + // String userName = session.getUserName(); + String userID = session.getUser().getStringProperty("user_id"); + + System.out.println("userName==========" + userID); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + String date = df.format(new Date()); + content.append("ӡ"); + content.append("="); + content.append(userID); + content.append("|"); + content.append("ӡʱ"); + content.append("="); + content.append(date); + content.append("|"); + content.append("汾"); + content.append("="); + content.append(itemRevId1); + content.append("|"); + content.append("ϰ汾"); + content.append("="); + content.append(itemRevId); + content.append("|"); + content.append("ͼ1"); + content.append("="); + content.append(item_id); + if (item_id1 != null) { + content.append("|"); + content.append("ͼ2"); + content.append("="); + content.append(item_id1); + } + content.append("|"); + if (itemRev != null) { + ParseXMLUtil xml = new ParseXMLUtil(); + File file = xml.getSXX("RB3_CLASS_Xml", session); + List> attrList = xml.parseXMLCAD(file); + if (attrList == null || attrList.size() <= 0) { + MessageBox.post("ѡRB3_CLASS_Xmlδã飡", "WARNING", MessageBox.WARNING); + return ""; + } + String classValue = getClassValue(itemRev, attrList); + if (classValue == null) { + return null; + } + System.out.println("classValue===============" + classValue); + content.append(classValue); + // content.setLength(content.length() - 1); + } + } else { + txtValue = "null"; + String temp_item_id = targetRev.getStringProperty("item_id"); + String item_id1 = null; + String item_id = null; + if (temp_item_id.startsWith("XX-") || temp_item_id.startsWith("SF-")) { + temp_item_id = temp_item_id.substring(3); + } + if (temp_item_id.length() > 21) { + item_id = temp_item_id.substring(0, 21); + item_id1 = temp_item_id.substring(21); + } else { + item_id = temp_item_id; + } + content.append("ͼ1"); + content.append("="); + content.append(item_id); + if (item_id1 != null) { + content.append("|"); + content.append("ͼ2"); + content.append("="); + content.append(item_id1); + } + content.append("|"); + if (itemRev != null) { + ParseXMLUtil xml = new ParseXMLUtil(); + File file = xml.getSXX("RB3_CLASS_Xml", session); + List> attrList = xml.parseXMLCAD(file); + if (attrList == null || attrList.size() <= 0) { + MessageBox.post("ѡRB3_CLASS_Xmlδã飡", "WARNING", MessageBox.WARNING); + return ""; + } + String classValue = getClassValue(itemRev, attrList); + if (classValue == null) { + return null; + } + System.out.println("classValue(δ)===============" + classValue); + content.append(classValue); + // content.setLength(content.length() - 1); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + System.out.println("TC Data: " + content); + return content.toString(); + + } + + private TCComponentItemRevision getTargetItemRev() { + // TODO Auto-generated method stub + TCComponentItemRevision rev = null; + int tableRow = qryTable.getSelectedRow(); + qryTable.setRowSelectionInterval(tableRow, tableRow); + int indexRow = qryTable.convertRowIndexToModel(tableRow); + if (indexRow > 0) { + // 2022.3.8 + String selectedID1 = (String) qryTable.getModel().getValueAt(indexRow, 0); + itemRevId = (String) qryTable.getModel().getValueAt(indexRow, 1); + String selectedID; + if (selectedID1.startsWith("SF-") || selectedID1.startsWith("XX-")) { + selectedID = selectedID1.substring(3); + } else { + selectedID = selectedID1; + } + if (!("ͼֽ".equals(selectedID))) { + String selectedRev = (String) qryTable.getModel().getValueAt(indexRow, 1); + StringBuilder sb = new StringBuilder(selectedID); + sb.append(";"); + sb.append(selectedRev); + String str = sb.toString(); + System.out.println("selectedID===================" + selectedID); + System.out.println("selectedRev===================" + selectedRev); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + List compList = queryObject(rb.getString("item_revquery.TITLE"), + new String[] { rb.getString("item_idquery.TITLE"), rb.getString("revquery.TITLE") }, + new String[] { selectedID, selectedRev }); + if (compList != null) { + if (compList.size() > 0) { + rev = (TCComponentItemRevision) compList.get(0); + } + } + } + } + return rev; + } + + /** + * ͨѯѯĿ + * + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("myzdcx19_display.TITLE") + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + return null; + } + } + + /* + * ȡӳķ + */ + public String getClassValue(TCComponent comp, List> allList) { + // TODO Auto-generated method stub + List attrList = allList.get(0); + List revList = allList.get(1); + + List vals = new ArrayList(); + StringBuilder revSb = new StringBuilder(); + StringBuilder classSb = new StringBuilder(); + List classPropList = new ArrayList(); + try { + String className = comp.getClassificationClass(); + if ("".equals(className.trim())) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(comp.getStringProperty("item_id") + rb.getString("gwlmyfszfl19_display.TITLE"), "ʾ", + MessageBox.WARNING); + return null; + } + TCComponentICO[] icos = comp.getClassificationObjects(); + TCClassificationService classificationService = comp.getSession().getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(className); + // String icoPUID = icos[0].getUid(); + Map claMap = new HashMap(); + if (icos != null && icos.length > 0) { + ICSProperty[] icss = icos[0].getICSProperties(true); + for (ICSProperty ics : icss) { + claMap.put(ics.getId(), ics.getValue()); + } + } + for (Map.Entry entry : claMap.entrySet()) { + System.out.println("key = " + entry.getKey() + ", value = " + entry.getValue()); + } + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + + if (icsAttrS != null) { + for (ICSAdminClassAttribute attr : icsAttrS) { + if (attr.isReferenceAttribute()) { + continue; + } + if (attr.isReference()) { + continue; + } + ClassPropBean bean = new ClassPropBean(attr); + classPropList.add(bean); + } + } + for (int j = 0; j < attrList.size(); j++) { + String classValue = attrList.get(j); + String revValue = revList.get(j); + if (classValue.contains(";") && revValue.contains(";")) { + String[] classValues = classValue.split(";"); + String[] revValues = revValue.split(";"); + if (className.equals(classValues[0])) { + for (int k = 1; k < classValues.length; k++) { + String attrName = classValues[k]; + if (attrName.contains("+")) { + String[] attrs = attrName.split("\\+"); + for (int i = 0; i < classPropList.size(); i++) { + ClassPropBean bean = classPropList.get(i); + // ޸ + + if (attrs[1].equals(bean.propDisName)) { + String value = claMap.get(bean.propID); + if (bean.isLov) { + String lovValue = bean.lovMapping.get(value); + // classSb.append(attrs[0]); + if (attrs[0].contains("(")) { + String[] split = attrs[0].split("\\("); + classSb.append(split[0]); + } else { + classSb.append(attrs[0]); + } + classSb.append("="); + if (lovValue != null) { + + classSb.append(lovValue); + + } else { + classSb.append(""); + } + + if (k < classValues.length - 1) { + classSb.append("|"); + } + } else { + // classSb.append(attrs[0]); + if (attrs[0].contains("(")) { + String[] split = attrs[0].split("\\("); + classSb.append(split[0]); + } else { + classSb.append(attrs[0]); + } + classSb.append("="); + if (value != null) { + + classSb.append(value); + + } else { + classSb.append(""); + } + + if (k < classValues.length - 1) { + classSb.append("|"); + } + } + break; + } + } + } + + } + for (int k = 1; k < revValues.length; k++) { + String attrName = revValues[k]; + if (attrName.contains("+")) { + String[] attrs = attrName.split("\\+"); + + if (attrs[0].contains("(")) { + String[] split = attrs[0].split("\\("); + revSb.append(split[0]); + } else { + revSb.append(attrs[0]); + } + revSb.append("="); + String value = comp.getProperty(attrs[1]); + if (value != null) { + + revSb.append(value); + + } else { + revSb.append(""); + } + + revSb.append("|"); + } + } + break; + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + revSb.append(classSb.toString()); + String spec = revSb.toString(); + return spec; + } + + /** + * ѯĿϢȡ¼ + * + * @return tabledataVector + */ + private Object[][] getRecords() { + List list = new ArrayList<>(); + ChangeOwnerbean tzBean = new ChangeOwnerbean("ͼֽ", "ͼֽ", "ͼֽ", "ͼֽ", "ͼֽ"); + list.add(tzBean); + try { + if (targetRev != null) { + TCComponent[] targets = targetRev.getReferenceListProperty("representation_for"); + for (int i = 0; i < targets.length; i++) { + String id = targets[i].getStringProperty("item_id"); + String revID = targets[i].getStringProperty("item_revision_id"); + String name = targets[i].getStringProperty("object_name"); + if (name.startsWith("SF-") || name.startsWith("XX-")) { + name = name.substring(3); + } + String cph = targets[i].getStringProperty("rb3_cph"); + TCComponent user = targets[i].getRelatedComponent("owning_user"); + String owner = user.getStringProperty("user_name"); + ChangeOwnerbean bean = new ChangeOwnerbean(id, revID, name, cph, owner); + list.add(bean);// ͼֽ + } + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // װ + Object res[][] = new Object[list.size()][this.columnNames.length]; + int i = 0; + for (ChangeOwnerbean record : list) { + res[i++] = new Object[] { record.getId(), record.getRev(), record.getName(), record.getCph(), + record.getOwner() }; + } + return res; + } + + private class TableCellTextAreaRenderer extends JTextArea implements TableCellRenderer { + private static final long serialVersionUID = -7149062901533662226L; + + public TableCellTextAreaRenderer() { + // setLineWrap(true); //Զ + // setWrapStyleWord(true); + } + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, + int row, int column) { + if (isSelected) { + // ñѡеһеɫ + setBackground(new Color(51, 153, 255)); + setForeground(new Color(255, 255, 255)); + } else { + setBackground(table.getBackground()); + setForeground(table.getForeground()); + } + + // 㵱еѸ߶ + int maxPreferredHeight = 0; + for (int i = 0; i < table.getColumnCount(); i++) { + setText("" + table.getValueAt(row, i)); + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); + } + + if (table.getRowHeight(row) != maxPreferredHeight) + table.setRowHeight(row, maxPreferredHeight); + setText(value == null ? "" : value.toString()); + return this; + } + } + + public int printPDF3(String path, String datasetName) { + System.out.println("path================" + path); +// String newPath=path.split(".pdf")[0]+"CASH.pdf"; +// copy(new File(path), +// new File(newPath));//ȻһݳӡĬϽԭɾ +// System.out.println("===>"+newPath); + // ++++ + File file = new File(path); + int statu = 0; + try { + PDDocument document = PDDocument.load(file); + // سɴӡļ + PDFPrintable printable = new PDFPrintable(document); + PrinterJob job = PrinterJob.getPrinterJob(); + job.setPrintable(printable);// ӡĬϵѡ񵼳 + if (job.printDialog()) { + job.print(); + // ļ + // new saveFile(newPath,datasetName); + statu = 1; + document.close(); + file.delete(); + // file.deleteOnExit(); + // file.delete(); + } else { + document.close(); + new saveFile(path, datasetName); + // file.deleteOnExit(); + // file.delete(); + } + job.cancel(); + } catch (InvalidPasswordException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (PrinterException e) { + e.printStackTrace(); + } finally { + // file.delete(); + } + + return statu; + } +// public int printPDF3(String path,String datasetName) { +// System.out.println("path================"+path); +// String newPath=path.split(".pdf")[0]+"CASH.pdf"; +// copy(new File(path), +// new File(newPath));//ȻһݳӡĬϽԭɾ +// File file = new File(path); +// +// int statu = 0; +// try { +// PDDocument document = PDDocument.load(file); +// // سɴӡļ +// PDFPrintable printable = new PDFPrintable(document); +// PrinterJob job = PrinterJob.getPrinterJob(); +// //job.setPrintable(printable);//Ƿʾѡ񵼳ʾ +// if(job.printDialog()) +// { +// try { +// job.print(); +// } catch (PrinterException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// //ļ +// new saveFile(newPath,datasetName); +// +// statu = 1; +// document.close(); +// +// //file.deleteOnExit(); +// file.delete(); +// }else { +// document.close(); +// //file.deleteOnExit(); +// file.delete(); +// } +// } catch (InvalidPasswordException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +//// catch (PrinterException e) { +//// e.printStackTrace(); +//// } +// +// +// return statu; +// } + +// public int printPDF2(String path) { +// System.out.println("path================"+path); +// File file = new File(path); +// int statu = 0; +// try { +// PDDocument document = PDDocument.load(file); +// // سɴӡļ +// PDFPrintable printable = new PDFPrintable(document); +// PrinterJob job = PrinterJob.getPrinterJob(); +// job.setPrintable(printable); +// if(job.printDialog()) +// { +// job.print(); +// statu = 1; +// document.close(); +// //file.deleteOnExit(); +// file.delete(); +// }else { +// document.close(); +// //file.deleteOnExit(); +// file.delete(); +// } +// } catch (InvalidPasswordException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); +// } catch (PrinterException e) { +// e.printStackTrace(); +// } +// +// +// return statu; +// } + + public void copy(File oldFile, File newFile) { + + try (InputStream in = new FileInputStream(oldFile); OutputStream out = new FileOutputStream(newFile)) { + + byte[] arr = new byte[1024]; + int len; + while ((len = in.read(arr)) != -1) { + out.write(arr, 0, len); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + + private int printPDF(File file) { + int statu = 0; + PdfDocument document = new PdfDocument(); + document.loadFromFile(file.getAbsolutePath()); + // PrinterJob + PrinterJob printerJob = PrinterJob.getPrinterJob(); + + // ָӡҳΪĬϴСͷ + PageFormat pageFormat = printerJob.defaultPage(); + + // شӡѡ + Paper paper = pageFormat.getPaper(); + paper.setImageableArea(0, 0, pageFormat.getWidth(), pageFormat.getHeight()); + pageFormat.setPaper(paper); + printerJob.setCopies(1); + printerJob.setPrintable(document, pageFormat); + if (printerJob.printDialog()) { + + // ִдӡ + try { + printerJob.print(); + statu = 1; + file.delete(); + } catch (PrinterException e) { + e.printStackTrace(); + } + } + return statu; + } +} + +class saveFile extends JFrame { + // ؼ + private JPanel mainPanel; + private JFileChooser jfc; + private JButton okButton; + private JButton celButton; + private JButton pictureButton; + private JButton fileButton; + private JTextField pathText; + private JTextField fleName; + private String path; + private String datasetName; + + public saveFile(String path, String datasetName) { + this.path = path; + this.datasetName = datasetName; + init(); + } + + private void init() { + this.setAlwaysOnTop(true); + System.out.println("copyPath:" + path); + this.setTitle("ѡ񱣴ַ"); + this.setPreferredSize(new Dimension(480, 230)); + Toolkit toolkit = Toolkit.getDefaultToolkit(); + int x = (int) (toolkit.getScreenSize().getWidth() - this.getWidth()) / 3; + + int y = (int) (toolkit.getScreenSize().getHeight() - this.getHeight()) / 3; + + this.setLocation(x, y); + this.okButton = new JButton(""); + this.okButton.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + + @Override + public void actionPerformed(ActionEvent e) { + copy(new File(path), new File(pathText.getText() + "\\" + fleName.getText() + ".pdf")); + new File(path).delete(); + + dispose(); + } + }); + this.celButton = new JButton("ȡ"); + this.celButton.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + + @Override + public void actionPerformed(ActionEvent e) { + new File(path).delete(); + dispose(); + } + }); + FileSystemView fsv = FileSystemView.getFileSystemView(); + File com = fsv.getHomeDirectory(); + this.fileButton = new JButton("..."); + this.fileButton.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + jfc = new JFileChooser(); + jfc.setCurrentDirectory(new File(com.getPath()));// ļѡijʼĿ¼Ϊd + jfc.setFileSelectionMode(1);// 趨ֻѡļ + int state = jfc.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jfc.getSelectedFile();// fΪѡ񵽵Ŀ¼ + pathText.setText(f.toString()); + } + } + }); + this.pathText = new JTextField(); + pathText.setText(com.getPath()); + this.pathText.setPreferredSize(new Dimension(300, 30)); + fleName = new JTextField(); + fleName.setText(datasetName); + this.fleName.setPreferredSize(new Dimension(300, 30)); + JLabel label = new JLabel("ļ"); + label.setPreferredSize(new Dimension(100, 30)); + JLabel label2 = new JLabel("ѡļ"); + label2.setPreferredSize(new Dimension(100, 30)); + JPanel panel1 = new JPanel(new FlowLayout()); + panel1.add(label); + panel1.add(fleName); + JPanel panel2 = new JPanel(new FlowLayout()); + panel2.add(label2); + panel2.add(pathText); + panel2.add(fileButton); + this.mainPanel = new JPanel(new PropertyLayout()); + + this.mainPanel.add("1.1.left.top", panel1); + this.mainPanel.add("2.1.left.top", panel2); + + JPanel rootPanel = new JPanel(new FlowLayout()); + rootPanel.add(new JLabel(" ")); + rootPanel.add(this.okButton); + rootPanel.add(new JLabel(" ")); + rootPanel.add(this.celButton); + + this.setLayout(new BorderLayout()); + this.add(mainPanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + testTimer01(this); + } + + public void testTimer01(saveFile d) { + Timer timer = new Timer(); + TimerTask timerTask = new TimerTask() { + @Override + public void run() { + d.setAlwaysOnTop(false); + System.out.println("ȡö"); + } + }; + timer.schedule(timerTask, 500); + }// 5000Ϊ5 + + public void copy(File oldFile, File newFile) { + + try (InputStream in = new FileInputStream(oldFile); OutputStream out = new FileOutputStream(newFile)) { + + byte[] arr = new byte[1024]; + int len; + while ((len = in.read(arr)) != -1) { + out.write(arr, 0, len); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/com/connor/rb/plm/rb022/Rb022Handler.java b/src/com/connor/rb/plm/rb022/Rb022Handler.java new file mode 100644 index 0000000..667de7e --- /dev/null +++ b/src/com/connor/rb/plm/rb022/Rb022Handler.java @@ -0,0 +1,72 @@ +package com.connor.rb.plm.rb022; + +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class Rb022Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCPreferenceService service = session.getPreferenceService(); + TCComponentGroup group = session.getCurrentGroup(); +// InterfaceAIFComponent targetComponent = app.getTargetComponent(); +// TCComponentItemRevision componentItemRevision=(TCComponentItemRevision)targetComponent; +// try { +// TCProperty d=componentItemRevision.getTCProperty("rb3_th "); +// System.out.println("====>"+d.getStringValue()); +// d.setStringValue("1222"); +// System.out.println("====>"+d.getStringValue()); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + + String[] strs = service.getStringValues("RB3_group_permission"); + List groupList = Arrays.asList(strs); + boolean b = true; + try { +// String groupName = group.getGroupName(); + String groupName = group.getTCProperty("name").getStringValue(); + String dis_name = group.getTCProperty("full_name").getStringValue(); + String[] split = dis_name.split("\\."); + List asList = Arrays.asList(split); + System.out.println(":" + asList); + for (String name : split) { + if (groupList.contains(name)) { + System.out.println("groupName============" + name); + new Thread(new Rb022Dialog(app)).start(); + return null; + } + } + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("nmydyqx19_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return null; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/rb022/Rb022Handlernosy.java b/src/com/connor/rb/plm/rb022/Rb022Handlernosy.java new file mode 100644 index 0000000..9faa9da --- /dev/null +++ b/src/com/connor/rb/plm/rb022/Rb022Handlernosy.java @@ -0,0 +1,67 @@ +package com.connor.rb.plm.rb022; + +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class Rb022Handlernosy extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCPreferenceService service = session.getPreferenceService(); + TCComponentGroup group = session.getCurrentGroup(); +// InterfaceAIFComponent targetComponent = app.getTargetComponent(); +// TCComponentItemRevision componentItemRevision=(TCComponentItemRevision)targetComponent; +// try { +// TCProperty d=componentItemRevision.getTCProperty("rb3_th "); +// System.out.println("====>"+d.getStringValue()); +// d.setStringValue("1222"); +// System.out.println("====>"+d.getStringValue()); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + + String[] strs = service.getStringValues("RB3_group_permission"); + List groupList = Arrays.asList(strs); + boolean b = true; + try { +// String groupName = group.getGroupName(); + String groupName = group.getTCProperty("name").getStringValue(); + String dis_name = group.getTCProperty("full_name").getStringValue(); + String[] split = dis_name.split("\\."); + List asList = Arrays.asList(split); + System.out.println(":" + asList); + for (String name : split) { + if (groupList.contains(name)) { + System.out.println("groupName============" + name); + new Thread(new Rb022nosyDialog(app)).start(); + return null; + } + } + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("nmydyqx19_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return null; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/rb022/Rb022nosyDialog.java b/src/com/connor/rb/plm/rb022/Rb022nosyDialog.java new file mode 100644 index 0000000..e9f9d4b --- /dev/null +++ b/src/com/connor/rb/plm/rb022/Rb022nosyDialog.java @@ -0,0 +1,1379 @@ +package com.connor.rb.plm.rb022; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.print.PageFormat; +import java.awt.print.Paper; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.atomic.AtomicInteger; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableRowSorter; +import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException; +import org.apache.pdfbox.printing.PDFPrintable; +import com.connor.rb.plm.rb019.ChangeOwnerbean; +import com.connor.rb.plm.util.ClassPropBean; +import com.connor.rb.plm.util.ParseXMLUtil; +import com.connor.rb.plm.util.SoaServerUtil; +import com.spire.pdf.PdfDocument; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class Rb022nosyDialog extends AbstractAIFDialog implements ActionListener { + + private static final long serialVersionUID = 6130114042631785757L; + private static final int width = 700; + private TCPreferenceService service; + DefaultTableModel model; + private AbstractAIFUIApplication app; + private TCSession session; + private TCComponentDataset dataset; + private TCComponentItemRevision targetRev; + private JButton okBtn = new JButton("ȷ"); + private JButton celBtn = new JButton("ȡ"); + private String[] columnNames = { "ID", "汾", "", "Ʒ", "" }; + private JTable qryTable; + private Object[][] beans; + private String txtValue = ""; + private Map userMap = new HashMap(); + private String setName = ""; + private String itemRevId = ""; + private String itemRevId1 = ""; + private boolean isRelease = false; + + public Rb022nosyDialog(AbstractAIFUIApplication app) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + String[] users = service.getStringValues("RB3_user_uid"); + if (users == null || users.length <= 0) { + MessageBox.post("ѡRB3_user_uidδã飡", "WARNING", MessageBox.WARNING); + return; + } + for (int i = 0; i < users.length; i++) { + if (users[i].contains("=")) { + String[] us = users[i].split("="); + userMap.put(us[0], us[1]); + } + } + } + + /** + * ˢtableʾÿ + */ + private void refreshTable() { + qryTable.removeAll(); + model.setDataVector(beans, columnNames); + // qryTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); + qryTable.getColumnModel().getColumn(0).setPreferredWidth(110); + qryTable.getColumnModel().getColumn(1).setPreferredWidth(50); + qryTable.getColumnModel().getColumn(2).setPreferredWidth(80); + qryTable.getColumnModel().getColumn(3).setPreferredWidth(50); + qryTable.getColumnModel().getColumn(4).setPreferredWidth(110); + + } + + @Override + public void run() { + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date = new Date(); + String formattedDate = formatter.format(date); + System.out.println("ʼʱ䣨ûˮӡ" + formattedDate); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if (targetComponent instanceof TCComponentDataset) { + dataset = (TCComponentDataset) targetComponent; + String type = dataset.getType(); + try { + setName = dataset.getProperty("object_name"); + System.out.println("setName is ==========>" + setName); + if (setName.contains(".")) { + setName = setName.substring(0, setName.lastIndexOf(".")); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + if ("RB3_GCAD".equals(type)) { + try { + AIFComponentContext[] referenceds = dataset.whereReferenced(); +// //ݼõı +// if(referenceds.length<=0) { +// MessageBox.post("ݼö󣡣","ʾ",MessageBox.INFORMATION); +// return; +// } + String release = dataset.getProperty("release_status_list"); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + if (release.contains(rb.getString("fabu_TITLE"))) {// TCM Released + isRelease = true; + } + List objects = new ArrayList(); + for (int i = 0; i < referenceds.length; i++) { + InterfaceAIFComponent comp = referenceds[i].getComponent(); + if (comp instanceof TCComponentItemRevision) { + targetRev = (TCComponentItemRevision) comp; + try { + System.out.println("targetRev:" + comp.getProperty("object_string")); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + // Object[] objs = new Object[2]; + // objs[1] = ""; + // objs[0] = targetRev; + // SoaServerUtil.dwgToPDF(session,objs); + + objects.add(targetRev); + } + + } + ConfirmDialog dialog = new ConfirmDialog(null, objects); + TCComponentItemRevision selectedObjects = dialog.getSelectedObjects(); + if (selectedObjects != null) { + System.out.println("ѡ¶"); + System.out.println(selectedObjects.toString()); + targetRev = selectedObjects; + String name = targetRev.getStringProperty("object_name"); + String revID = targetRev.getStringProperty("item_revision_id"); + itemRevId1 = revID; + // 2022.3.8 + String dataName1 = name + "/" + revID; + String dataName = ""; + String datasetName = dataset.getStringProperty("object_name"); + System.out.println("dataName============" + dataName1); + System.out.println("datasetName============" + datasetName); + if (!(dataName1.equals(datasetName))) { + if (dataName1.startsWith("SF-") || dataName1.startsWith("XX-")) { + dataName = dataName1.substring(3); + } else { + dataName = dataName1; + } +// SoaServerUtil.openByPass(session); +// // dataset.setStringProperty("object_name", dataName); +// dataset.save(); + System.out.println("datasetName111====" + dataset.getStringProperty("object_name")); +// SoaServerUtil.closeByPass(session); + } + } else { + System.out.println("ûȡ˲"); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("qxzcadtzjxcz19_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + } else { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("qxzsjjdxjxcz22_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + + // ʾ + initUI(); + + } + + @SuppressWarnings("serial") + private void initUI() { + this.setTitle("öб"); + this.setLayout(new FlowLayout(FlowLayout.CENTER, 2, 3)); + this.setPreferredSize(new Dimension(width, 455)); + this.setLocation(2, 5); + Object[][] cellData = getRecords(); + model = new DefaultTableModel() { + private static final long serialVersionUID = 6905817304437097181L; + + public boolean isCellEditable(int row, int column) { + return false; + } + }; + + qryTable = new JTable(model) { + public String getToolTipText(MouseEvent e) { + int row = qryTable.rowAtPoint(e.getPoint()); + int col = qryTable.columnAtPoint(e.getPoint()); + String tiptextString = null; + if (row > -1 && col > -1) { + Object value = qryTable.getValueAt(row, col); + if (null != value && !"".equals(value)) + tiptextString = value.toString();// ʾԪ + } + return tiptextString; + } + }; + TableRowSorter sorter = new TableRowSorter(model); + qryTable.setRowSorter(sorter); // ΪJTable + model.setDataVector(cellData, columnNames); + qryTable.setDefaultRenderer(Object.class, new TableCellTextAreaRenderer()); + JScrollPane scrollPane = new JScrollPane(qryTable); + scrollPane.setPreferredSize(new Dimension(width - 5, 392)); + // JPanel qryPanel=new JPanel(new PropertyLayout(5,5,5,0,5,5)); + JPanel rootPanel = new JPanel(new ButtonLayout()); + rootPanel.add(okBtn); + rootPanel.add(celBtn); + addListeners(); + this.add(scrollPane); + this.add(rootPanel); + this.setResizable(false); + this.showDialog(); + } + + private void addListeners() { + this.okBtn.addActionListener(this); + this.celBtn.addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent event) { + Object obj = event.getSource(); + if (obj.equals(this.okBtn)) { // ȷ + + try { + + String signoff = ""; + if (dataset.getType().equals("RB3_QRT")) { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + String date = df.format(new Date()); + signoff = "ӡ=" + session.getUser().getStringProperty("user_id") + "|ӡʱ=" + date; + } else { + signoff = createTempFile(); + } + + if (signoff == null) { + this.disposeDialog(); + return; + } + Object[] objs = new Object[2]; + objs[1] = signoff; + objs[0] = targetRev; + if (session == null) { + session = (TCSession) app.getSession(); + } + TCComponent[] datasets = targetRev.getReferenceListProperty("IMAN_specification"); + List removeDatasets = new ArrayList<>(); + // + TCComponentItemType itemtype = (TCComponentItemType) session.getTypeComponent("RB3_CPT"); + TCComponentItem copyItem = itemtype.create( + "Ʒͼ" + String.valueOf(new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())), "A", "", + "", "", null); + TCComponentItemRevision copytargetRev = copyItem.getLatestItemRevision(); + boolean flag = false; + +// //ѡеcad½תpdfȡtarget + if (datasets.length > 1) { + for (TCComponent dat : datasets) { + if (dat instanceof TCComponentDataset) { + if (dat.getUid().equals(dataset.getUid())) { + try { + SoaServerUtil.openByPass(session); + copytargetRev.add("IMAN_specification", dat); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + SoaServerUtil.closeByPass(session); + } + + objs[0] = copytargetRev; + + flag = true; + break; + } + } + } + } + // תcadʱɾ + try { + SoaServerUtil.dwgToPDF(session, objs); + } catch (Exception e) { + System.out.println("===>SoaServerUtil.dwgToPDF(session,objs)ʧܣ"); + copyItem.delete(); + e.printStackTrace(); + } + +// System.out.println("====ɾݼ====="); +// for(TCComponent dat:removeDatasets) { +// targetRev.add("IMAN_specification", dat); +// } + if (flag) { + datasets = copytargetRev.getReferenceListProperty("IMAN_specification"); + for (TCComponent dat : datasets) { + if (dat instanceof TCComponentDataset) { + if (((TCComponentDataset) dat).getType().equals("PDF")) { + try { + SoaServerUtil.openByPass(session); + targetRev.add("IMAN_specification", dat); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + SoaServerUtil.closeByPass(session); + } + + break; + } + } + } + } + copyItem.delete(); + + this.disposeDialog(); + datasets = targetRev.getReferenceListProperty("IMAN_specification"); + try { + SoaServerUtil.openByPass(session); + for (int i = 0; i < datasets.length; i++) { + if (datasets[i] instanceof TCComponentDataset) { + // System.out.println("ѡеݼӡ====>"+dataset.getStringProperty("item_id")+"-"+dataset.getStringProperty("object_name")); + TCComponentDataset data = (TCComponentDataset) datasets[i]; + + String type = data.getType(); + + System.out.println("type:" + type); + if ("PDF".equals(type)) { + String proName = data.getProperty("object_name"); + // ݼʱ + TCProperty tcp = data.getTCProperty("creation_date"); + Date date1 = tcp.getDateValue(); + Date date = new Date(); + long time1 = date1.getTime(); + long time = date.getTime(); + // PDFݼʱڵʱʱ + long interval_time = time1 - time; + if (proName.contains(".")) { + proName = proName.substring(0, proName.lastIndexOf(".")); + } + if (proName.equals(setName)) {// pdfݼͼֽͬӡ + // statu = printPDF(files[0]); + + File[] files = data.getFiles(""); + String datasetName = data.getStringProperty("object_name"); + targetRev.remove("IMAN_specification", new TCComponent[] { data }); + + data.delete(); + String path = files[0].getAbsolutePath(); + + // ȡݼö,жǷȷͼеĻͲˮӡ +// AIFComponentContext[] contexts = dataset.whereReferenced(); +// boolean isQRT = false; +// int numWatch = 0; +// for (AIFComponentContext context : contexts) { +// if (context.getComponent().getType().contains("RB3_QRT")) { +// isQRT = true; +// break; +// } else if (context.getComponent().getType().contains("RB3_XZCPTRevision")) { +// System.out.println("ûȷͼΪxzcp"); +// numWatch = 1; +// } +// +// } +// +// if (!isQRT) { +// String userID = session.getUser().getUserId().toUpperCase(); +// System.out.println("ûIDΪ:" + userID); +// System.out.println("txtValueֵΪ:" + txtValue); +// System.out.println("pathֵΪ:" + path); +// SoaServerUtil.closeByPass(session); +// ProcessBuilder process = null; +// if (numWatch == 0) { +// process = new ProcessBuilder("java", "-jar", +// "C:\\Siemens\\Teamcenter12\\bin\\SetUser.jar", txtValue, path, userID); +// } else { +// System.out.println("׼setsuer"); +// process = new ProcessBuilder("java", "-jar", +// "C:\\Siemens\\Teamcenter12\\bin\\SetUser.jar", txtValue, path, +// userID + "%"); +// } +// +// Process pro; +//// String[] cmd = new String[] { +//// "cmd.exe","/C","java -jar C:\\Siemens\\Teamcenter12\\bin\\SetUser.jar " + txtValue + " "+ path+" "+userID}; +// try { +// System.out.println("ʼSetUser.jar"); +// pro = process.start(); +// pro.waitFor(); +// BufferedReader br = new BufferedReader( +// new InputStreamReader(pro.getInputStream())); +// String readLine = br.readLine(); +// if (readLine == null) { +// String getenv = System.getenv("FMS_HOME"); +// String replace = getenv.replace("tccs", "portal\\plugins");// ȡִjar· +// ProcessBuilder process1 = null; +// if (numWatch == 0) { +// process1 = new ProcessBuilder("java", "-jar", replace + "\\SetUser.jar", +// txtValue, path, userID); +// } else { +// System.out.println("׼setsuer"); +// process1 = new ProcessBuilder("java", "-jar", replace + "\\SetUser.jar", +// txtValue, path, userID + "%"); +// } +// Process pro1; +// pro1 = process1.start(); +// pro1.waitFor(); +// } +// +//// Runtime.getRuntime().exec(cmd); +// } catch (Exception e) { +// System.out.println("SetUserܳ쳣!"); +// e.printStackTrace(); +// } +// } + + // int statu = printPDF3(path, datasetName); + AtomicInteger result = new AtomicInteger(0); + result.set(printPDF3(path, datasetName)); + +// Thread pdfThread = new Thread(() -> { +// +// }); +// +// pdfThread.start(); +// +// try { +// pdfThread.join(300000); // ȴ5 +// if (pdfThread.isAlive()) { +// pdfThread.interrupt(); // ߳Уж߳ +// MessageBox.post("PDFӡʱ", "ʾ", MessageBox.INFORMATION); +// throw new TimeoutException(interval_time, "PDF print time out"); +// } +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } + + // ʹget()ȡ'statu'ֵ + int statu = result.get(); +// int statu = printPDF(files[0]); +// System.out.println("·===>"+path); +// if(new File(path).exists()) { +// System.out.println("ɾ===>"+path); +// new File(path).delete(); +// } +// files[0].delete(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle + .getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (statu != 0) { + MessageBox.post(rb.getString("dycg15_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + } else { + MessageBox.post(rb.getString("dysb15_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + } + + } else if (interval_time < 300000) {// pdfʱС5ӣɾݼ +// SoaServerUtil.openByPass(session); + targetRev.remove("IMAN_specification", new TCComponent[] { data }); + data.delete(); + + } + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date11 = new Date(); + String formattedDate = formatter.format(date11); + System.out.println("ʱ䣨ûˮӡ" + formattedDate); + } + } + } + } catch (Exception e) { + + } finally { + SoaServerUtil.closeByPass(session); + } + + // TCComponent[] refes = + // targetRev.getReferenceListProperty("IMAN_specification"); + // for (int j = 0; j < refes.length; j++) { + // TCComponent data = refes[j]; + // if("PDF".equals(data.getType())) { + // TCComponentDataset pdfData = (TCComponentDataset) data; + // File[] files = pdfData.getFiles(""); + // String path = files[0].getAbsolutePath(); + // System.out.println("path================"+path); + // print(path); + //// InterfaceAIFComponent[] contexts = new InterfaceAIFComponent[] {pdfData}; + //// AbstractAIFCommand abstractaifcommand = new + // OpenCommand(AIFUtility.getActiveDesktop(), contexts); + //// try { + //// abstractaifcommand.executeModal(); + //// } catch (Exception e) { + //// // TODO Auto-generated catch block + //// e.printStackTrace(); + //// } + // + // } + // } + + } catch (Exception e) { + e.printStackTrace(); + com.teamcenter.rac.util.MessageBox.post(e); + } + // InterfaceAIFComponent[] contexts = new InterfaceAIFComponent[] {dataset}; + // AbstractAIFCommand abstractaifcommand = new + // OpenCommand(AIFUtility.getActiveDesktop(), contexts); + // try { + // abstractaifcommand.executeModal(); + // } catch (Exception e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } + } + if (obj.equals(this.celBtn)) { // ȡ + this.disposeDialog(); + } + } + + private String createTempFile() { + StringBuilder content = new StringBuilder(); + StringBuilder txtSB = new StringBuilder(); + TCComponentItemRevision itemRev = getTargetItemRev(); + try { + if (isRelease) { + TCComponent revmaster = targetRev.getRelatedComponent("IMAN_master_form_rev"); + String[] strs = service.getStringValues("RB3_process_sign"); + if (strs == null || strs.length <= 0) { + MessageBox.post("ѡRB3_process_signδã飡", "WARNING", MessageBox.WARNING); + return ""; + } + for (int i = 0; i < strs.length; i++) { + System.out.println(":" + strs[i]); + String[] str = strs[i].split("="); + content.append(str[0]); + content.append("="); + String value = revmaster.getStringProperty(str[1]); + System.out.println("汾ϵֵΪ:" + value); + if (value == null) { + value = ""; + } else { + + // uidתcomponent + String uid = userMap.get(value); + if (uid != null) { + System.out.println("ǩͼƬuidΪ:" + uid); + txtSB.append(str[0]); + txtSB.append("="); + TCComponent data = session.stringToComponent(uid); + TCComponentDataset dataset = (TCComponentDataset) data; + File[] files = dataset.getFiles(""); + String path = files[0].getAbsolutePath(); + System.out.println("ǩͼƬ·:" + path); + txtSB.append(path); + txtSB.append("|"); + } + + } + content.append(value); + content.append("|"); + + } + txtValue = txtSB.toString(); + if (txtValue.equals("")) { + txtValue = "null"; + } + String revID = targetRev.getStringProperty("item_revision_id"); + String temp_item_id = targetRev.getStringProperty("item_id"); + String item_id1 = null; + String item_id = null; + if (temp_item_id.startsWith("XX-") || temp_item_id.startsWith("SF-")) { + temp_item_id = temp_item_id.substring(3); + } + if (temp_item_id.length() > 21) { + item_id = temp_item_id.substring(0, 21); + item_id1 = temp_item_id.substring(21); + } else { + item_id = temp_item_id; + } + AIFComponentContext[] refes = targetRev.whereReferenced(); + // String itemRevId1=null; + // if(refes!=null) { + // for(AIFComponentContext aifComp:refes) { + // InterfaceAIFComponent component = aifComp.getComponent(); + // if(component instanceof TCComponentItemRevision) { + // try { + // itemRevId1=component.getProperty("item_revision_id"); + // break; + // } catch (Exception e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } + // } + // } + // }else { + // itemRevId1=targetRev.getProperty("item_revision_id"); + // } + // String status=targetRev.getProperty("rb3_smzqzt"); + + // String userName = session.getUserName(); + String userID = session.getUser().getStringProperty("user_id"); + + System.out.println("userName==========" + userID); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + String date = df.format(new Date()); + content.append("ӡ"); + content.append("="); + content.append(userID); + content.append("|"); + content.append("ӡʱ"); + content.append("="); + content.append(date); + content.append("|"); + content.append("汾"); + content.append("="); + content.append(itemRevId1); + content.append("|"); + content.append("ϰ汾"); + content.append("="); + content.append(itemRevId); + content.append("|"); + content.append("ͼ1"); + content.append("="); + content.append(item_id); + if (item_id1 != null) { + content.append("|"); + content.append("ͼ2"); + content.append("="); + content.append(item_id1); + } + content.append("|"); + if (itemRev != null) { + ParseXMLUtil xml = new ParseXMLUtil(); + File file = xml.getSXX("RB3_CLASS_Xml", session); + List> attrList = xml.parseXMLCAD(file); + if (attrList == null || attrList.size() <= 0) { + MessageBox.post("ѡRB3_CLASS_Xmlδã飡", "WARNING", MessageBox.WARNING); + return ""; + } + String classValue = getClassValue(itemRev, attrList); + if (classValue == null) { + return null; + } + System.out.println("classValue===============" + classValue); + content.append(classValue); + // content.setLength(content.length() - 1); + } + } else { + txtValue = "null"; + String temp_item_id = targetRev.getStringProperty("item_id"); + String item_id1 = null; + String item_id = null; + if (temp_item_id.startsWith("XX-") || temp_item_id.startsWith("SF-")) { + temp_item_id = temp_item_id.substring(3); + } + if (temp_item_id.length() > 21) { + item_id = temp_item_id.substring(0, 21); + item_id1 = temp_item_id.substring(21); + } else { + item_id = temp_item_id; + } + content.append("ͼ1"); + content.append("="); + content.append(item_id); + if (item_id1 != null) { + content.append("|"); + content.append("ͼ2"); + content.append("="); + content.append(item_id1); + } + content.append("|"); + if (itemRev != null) { + ParseXMLUtil xml = new ParseXMLUtil(); + File file = xml.getSXX("RB3_CLASS_Xml", session); + List> attrList = xml.parseXMLCAD(file); + if (attrList == null || attrList.size() <= 0) { + MessageBox.post("ѡRB3_CLASS_Xmlδã飡", "WARNING", MessageBox.WARNING); + return ""; + } + String classValue = getClassValue(itemRev, attrList); + if (classValue == null) { + return null; + } + System.out.println("classValue(δ)===============" + classValue); + content.append(classValue); + // content.setLength(content.length() - 1); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + System.out.println("TC Data: " + content); + return content.toString(); + + } + + private TCComponentItemRevision getTargetItemRev() { + // TODO Auto-generated method stub + TCComponentItemRevision rev = null; + int tableRow = qryTable.getSelectedRow(); + qryTable.setRowSelectionInterval(tableRow, tableRow); + int indexRow = qryTable.convertRowIndexToModel(tableRow); + if (indexRow > 0) { + // 2022.3.8 + String selectedID1 = (String) qryTable.getModel().getValueAt(indexRow, 0); + itemRevId = (String) qryTable.getModel().getValueAt(indexRow, 1); + String selectedID; + if (selectedID1.startsWith("SF-") || selectedID1.startsWith("XX-")) { + selectedID = selectedID1.substring(3); + } else { + selectedID = selectedID1; + } + if (!("ͼֽ".equals(selectedID))) { + String selectedRev = (String) qryTable.getModel().getValueAt(indexRow, 1); + StringBuilder sb = new StringBuilder(selectedID); + sb.append(";"); + sb.append(selectedRev); + String str = sb.toString(); + System.out.println("selectedID===================" + selectedID); + System.out.println("selectedRev===================" + selectedRev); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + List compList = queryObject(rb.getString("item_revquery.TITLE"), + new String[] { rb.getString("item_idquery.TITLE"), rb.getString("revquery.TITLE") }, + new String[] { selectedID, selectedRev }); + if (compList != null) { + if (compList.size() > 0) { + rev = (TCComponentItemRevision) compList.get(0); + } + } + } + } + return rev; + } + + /** + * ͨѯѯĿ + * + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("myzdcx19_display.TITLE") + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + return null; + } + } + + /* + * ȡӳķ + */ + public String getClassValue(TCComponent comp, List> allList) { + // TODO Auto-generated method stub + List attrList = allList.get(0); + List revList = allList.get(1); + + List vals = new ArrayList(); + StringBuilder revSb = new StringBuilder(); + StringBuilder classSb = new StringBuilder(); + List classPropList = new ArrayList(); + try { + String className = comp.getClassificationClass(); + if ("".equals(className.trim())) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(comp.getStringProperty("item_id") + rb.getString("gwlmyfszfl19_display.TITLE"), "ʾ", + MessageBox.WARNING); + return null; + } + TCComponentICO[] icos = comp.getClassificationObjects(); + TCClassificationService classificationService = comp.getSession().getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(className); + // String icoPUID = icos[0].getUid(); + Map claMap = new HashMap(); + if (icos != null && icos.length > 0) { + ICSProperty[] icss = icos[0].getICSProperties(true); + for (ICSProperty ics : icss) { + claMap.put(ics.getId(), ics.getValue()); + } + } + for (Map.Entry entry : claMap.entrySet()) { + System.out.println("key = " + entry.getKey() + ", value = " + entry.getValue()); + } + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + + if (icsAttrS != null) { + for (ICSAdminClassAttribute attr : icsAttrS) { + if (attr.isReferenceAttribute()) { + continue; + } + if (attr.isReference()) { + continue; + } + ClassPropBean bean = new ClassPropBean(attr); + classPropList.add(bean); + } + } + for (int j = 0; j < attrList.size(); j++) { + String classValue = attrList.get(j); + String revValue = revList.get(j); + if (classValue.contains(";") && revValue.contains(";")) { + String[] classValues = classValue.split(";"); + String[] revValues = revValue.split(";"); + if (className.equals(classValues[0])) { + for (int k = 1; k < classValues.length; k++) { + String attrName = classValues[k]; + if (attrName.contains("+")) { + String[] attrs = attrName.split("\\+"); + for (int i = 0; i < classPropList.size(); i++) { + ClassPropBean bean = classPropList.get(i); + // ޸ + + if (attrs[1].equals(bean.propDisName)) { + String value = claMap.get(bean.propID); + if (bean.isLov) { + String lovValue = bean.lovMapping.get(value); + // classSb.append(attrs[0]); + if (attrs[0].contains("(")) { + String[] split = attrs[0].split("\\("); + classSb.append(split[0]); + } else { + classSb.append(attrs[0]); + } + classSb.append("="); + if (lovValue != null) { + + classSb.append(lovValue); + + } else { + classSb.append(""); + } + + if (k < classValues.length - 1) { + classSb.append("|"); + } + } else { + // classSb.append(attrs[0]); + if (attrs[0].contains("(")) { + String[] split = attrs[0].split("\\("); + classSb.append(split[0]); + } else { + classSb.append(attrs[0]); + } + classSb.append("="); + if (value != null) { + + classSb.append(value); + + } else { + classSb.append(""); + } + + if (k < classValues.length - 1) { + classSb.append("|"); + } + } + break; + } + } + } + + } + for (int k = 1; k < revValues.length; k++) { + String attrName = revValues[k]; + if (attrName.contains("+")) { + String[] attrs = attrName.split("\\+"); + + if (attrs[0].contains("(")) { + String[] split = attrs[0].split("\\("); + revSb.append(split[0]); + } else { + revSb.append(attrs[0]); + } + revSb.append("="); + String value = comp.getProperty(attrs[1]); + if (value != null) { + + revSb.append(value); + + } else { + revSb.append(""); + } + + revSb.append("|"); + } + } + break; + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + revSb.append(classSb.toString()); + String spec = revSb.toString(); + return spec; + } + + /** + * ѯĿϢȡ¼ + * + * @return tabledataVector + */ + private Object[][] getRecords() { + List list = new ArrayList<>(); + ChangeOwnerbean tzBean = new ChangeOwnerbean("ͼֽ", "ͼֽ", "ͼֽ", "ͼֽ", "ͼֽ"); + list.add(tzBean); + try { + if (targetRev != null) { + TCComponent[] targets = targetRev.getReferenceListProperty("representation_for"); + for (int i = 0; i < targets.length; i++) { + String id = targets[i].getStringProperty("item_id"); + String revID = targets[i].getStringProperty("item_revision_id"); + String name = targets[i].getStringProperty("object_name"); + if (name.startsWith("SF-") || name.startsWith("XX-")) { + name = name.substring(3); + } + String cph = targets[i].getStringProperty("rb3_cph"); + TCComponent user = targets[i].getRelatedComponent("owning_user"); + String owner = user.getStringProperty("user_name"); + ChangeOwnerbean bean = new ChangeOwnerbean(id, revID, name, cph, owner); + list.add(bean);// ͼֽ + } + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // װ + Object res[][] = new Object[list.size()][this.columnNames.length]; + int i = 0; + for (ChangeOwnerbean record : list) { + res[i++] = new Object[] { record.getId(), record.getRev(), record.getName(), record.getCph(), + record.getOwner() }; + } + return res; + } + + private class TableCellTextAreaRenderer extends JTextArea implements TableCellRenderer { + private static final long serialVersionUID = -7149062901533662226L; + + public TableCellTextAreaRenderer() { + // setLineWrap(true); //Զ + // setWrapStyleWord(true); + } + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, + int row, int column) { + if (isSelected) { + // ñѡеһеɫ + setBackground(new Color(51, 153, 255)); + setForeground(new Color(255, 255, 255)); + } else { + setBackground(table.getBackground()); + setForeground(table.getForeground()); + } + + // 㵱еѸ߶ + int maxPreferredHeight = 0; + for (int i = 0; i < table.getColumnCount(); i++) { + setText("" + table.getValueAt(row, i)); + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); + } + + if (table.getRowHeight(row) != maxPreferredHeight) + table.setRowHeight(row, maxPreferredHeight); + setText(value == null ? "" : value.toString()); + return this; + } + } + + public int printPDF3(String path, String datasetName) { + System.out.println("path================" + path); +// String newPath=path.split(".pdf")[0]+"CASH.pdf"; +// copy(new File(path), +// new File(newPath));//ȻһݳӡĬϽԭɾ +// System.out.println("===>"+newPath); + // ++++ + File file = new File(path); + int statu = 0; + try { + PDDocument document = PDDocument.load(file); + // سɴӡļ + PDFPrintable printable = new PDFPrintable(document); + PrinterJob job = PrinterJob.getPrinterJob(); + job.setPrintable(printable);// ӡĬϵѡ񵼳 + if (job.printDialog()) { + job.print(); + // ļ + // new saveFile(newPath,datasetName); + statu = 1; + document.close(); + file.delete(); + // file.deleteOnExit(); + // file.delete(); + } else { + document.close(); + new saveFile(path, datasetName); + // file.deleteOnExit(); + // file.delete(); + } + job.cancel(); + } catch (InvalidPasswordException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (PrinterException e) { + e.printStackTrace(); + } finally { + // file.delete(); + } + + return statu; + } +// public int printPDF3(String path,String datasetName) { +// System.out.println("path================"+path); +// String newPath=path.split(".pdf")[0]+"CASH.pdf"; +// copy(new File(path), +// new File(newPath));//ȻһݳӡĬϽԭɾ +// File file = new File(path); +// +// int statu = 0; +// try { +// PDDocument document = PDDocument.load(file); +// // سɴӡļ +// PDFPrintable printable = new PDFPrintable(document); +// PrinterJob job = PrinterJob.getPrinterJob(); +// //job.setPrintable(printable);//Ƿʾѡ񵼳ʾ +// if(job.printDialog()) +// { +// try { +// job.print(); +// } catch (PrinterException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// //ļ +// new saveFile(newPath,datasetName); +// +// statu = 1; +// document.close(); +// +// //file.deleteOnExit(); +// file.delete(); +// }else { +// document.close(); +// //file.deleteOnExit(); +// file.delete(); +// } +// } catch (InvalidPasswordException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +//// catch (PrinterException e) { +//// e.printStackTrace(); +//// } +// +// +// return statu; +// } + +// public int printPDF2(String path) { +// System.out.println("path================"+path); +// File file = new File(path); +// int statu = 0; +// try { +// PDDocument document = PDDocument.load(file); +// // سɴӡļ +// PDFPrintable printable = new PDFPrintable(document); +// PrinterJob job = PrinterJob.getPrinterJob(); +// job.setPrintable(printable); +// if(job.printDialog()) +// { +// job.print(); +// statu = 1; +// document.close(); +// //file.deleteOnExit(); +// file.delete(); +// }else { +// document.close(); +// //file.deleteOnExit(); +// file.delete(); +// } +// } catch (InvalidPasswordException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); +// } catch (PrinterException e) { +// e.printStackTrace(); +// } +// +// +// return statu; +// } + + public void copy(File oldFile, File newFile) { + + try (InputStream in = new FileInputStream(oldFile); OutputStream out = new FileOutputStream(newFile)) { + + byte[] arr = new byte[1024]; + int len; + while ((len = in.read(arr)) != -1) { + out.write(arr, 0, len); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + + private int printPDF(File file) { + int statu = 0; + PdfDocument document = new PdfDocument(); + document.loadFromFile(file.getAbsolutePath()); + // PrinterJob + PrinterJob printerJob = PrinterJob.getPrinterJob(); + + // ָӡҳΪĬϴСͷ + PageFormat pageFormat = printerJob.defaultPage(); + + // شӡѡ + Paper paper = pageFormat.getPaper(); + paper.setImageableArea(0, 0, pageFormat.getWidth(), pageFormat.getHeight()); + pageFormat.setPaper(paper); + printerJob.setCopies(1); + printerJob.setPrintable(document, pageFormat); + if (printerJob.printDialog()) { + + // ִдӡ + try { + printerJob.print(); + statu = 1; + file.delete(); + } catch (PrinterException e) { + e.printStackTrace(); + } + } + return statu; + } +} + +//class saveFile extends JFrame { +// // ؼ +// private JPanel mainPanel; +// private JFileChooser jfc; +// private JButton okButton; +// private JButton celButton; +// private JButton pictureButton; +// private JButton fileButton; +// private JTextField pathText; +// private JTextField fleName; +// private String path; +// private String datasetName; +// +// public saveFile(String path, String datasetName) { +// this.path = path; +// this.datasetName = datasetName; +// init(); +// } +// +// private void init() { +// this.setAlwaysOnTop(true); +// System.out.println("copyPath:" + path); +// this.setTitle("ѡ񱣴ַ"); +// this.setPreferredSize(new Dimension(480, 230)); +// Toolkit toolkit = Toolkit.getDefaultToolkit(); +// int x = (int) (toolkit.getScreenSize().getWidth() - this.getWidth()) / 3; +// +// int y = (int) (toolkit.getScreenSize().getHeight() - this.getHeight()) / 3; +// +// this.setLocation(x, y); +// this.okButton = new JButton(""); +// this.okButton.addActionListener(new ActionListener() { +// // ťʱͻᴥ ActionEvent¼ +// // actionPerformed ͻᱻִ +// +// @Override +// public void actionPerformed(ActionEvent e) { +// copy(new File(path), new File(pathText.getText() + "\\" + fleName.getText() + ".pdf")); +// new File(path).delete(); +// +// dispose(); +// } +// }); +// this.celButton = new JButton("ȡ"); +// this.celButton.addActionListener(new ActionListener() { +// // ťʱͻᴥ ActionEvent¼ +// // actionPerformed ͻᱻִ +// +// @Override +// public void actionPerformed(ActionEvent e) { +// new File(path).delete(); +// dispose(); +// } +// }); +// FileSystemView fsv = FileSystemView.getFileSystemView(); +// File com = fsv.getHomeDirectory(); +// this.fileButton = new JButton("..."); +// this.fileButton.addActionListener(new ActionListener() { +// // ťʱͻᴥ ActionEvent¼ +// // actionPerformed ͻᱻִ +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// jfc = new JFileChooser(); +// jfc.setCurrentDirectory(new File(com.getPath()));// ļѡijʼĿ¼Ϊd +// jfc.setFileSelectionMode(1);// 趨ֻѡļ +// int state = jfc.showOpenDialog(null);// ˾ǴļѡĴ +// if (state == 1) { +// return; +// } else { +// File f = jfc.getSelectedFile();// fΪѡ񵽵Ŀ¼ +// pathText.setText(f.toString()); +// } +// } +// }); +// this.pathText = new JTextField(); +// pathText.setText(com.getPath()); +// this.pathText.setPreferredSize(new Dimension(300, 30)); +// fleName = new JTextField(); +// fleName.setText(datasetName); +// this.fleName.setPreferredSize(new Dimension(300, 30)); +// JLabel label = new JLabel("ļ"); +// label.setPreferredSize(new Dimension(100, 30)); +// JLabel label2 = new JLabel("ѡļ"); +// label2.setPreferredSize(new Dimension(100, 30)); +// JPanel panel1 = new JPanel(new FlowLayout()); +// panel1.add(label); +// panel1.add(fleName); +// JPanel panel2 = new JPanel(new FlowLayout()); +// panel2.add(label2); +// panel2.add(pathText); +// panel2.add(fileButton); +// this.mainPanel = new JPanel(new PropertyLayout()); +// +// this.mainPanel.add("1.1.left.top", panel1); +// this.mainPanel.add("2.1.left.top", panel2); +// +// JPanel rootPanel = new JPanel(new FlowLayout()); +// rootPanel.add(new JLabel(" ")); +// rootPanel.add(this.okButton); +// rootPanel.add(new JLabel(" ")); +// rootPanel.add(this.celButton); +// +// this.setLayout(new BorderLayout()); +// this.add(mainPanel, BorderLayout.CENTER); +// this.add(rootPanel, BorderLayout.SOUTH); +// this.pack(); +// this.show(); +// testTimer01(this); +// } +// +// public void testTimer01(saveFile d) { +// Timer timer = new Timer(); +// TimerTask timerTask = new TimerTask() { +// @Override +// public void run() { +// d.setAlwaysOnTop(false); +// System.out.println("ȡö"); +// } +// }; +// timer.schedule(timerTask, 500); +// }// 5000Ϊ5 +// +// public void copy(File oldFile, File newFile) { +// +// try (InputStream in = new FileInputStream(oldFile); OutputStream out = new FileOutputStream(newFile)) { +// +// byte[] arr = new byte[1024]; +// int len; +// while ((len = in.read(arr)) != -1) { +// out.write(arr, 0, len); +// } +// +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +//} diff --git a/src/com/connor/rb/plm/rb023/Rb023Handler.java b/src/com/connor/rb/plm/rb023/Rb023Handler.java new file mode 100644 index 0000000..f199c64 --- /dev/null +++ b/src/com/connor/rb/plm/rb023/Rb023Handler.java @@ -0,0 +1,50 @@ +package com.connor.rb.plm.rb023; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; +import java.util.Set; + +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.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 Rb023Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + try { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent[] targets = app.getTargetComponents(); + for (InterfaceAIFComponent interfaceAIFComponent : targets) { + if (!(interfaceAIFComponent instanceof TCComponentItem)) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("qxzdxhzbbjxcz_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return null; + } + } + Rb023Operation operation = new Rb023Operation(session, targets); + session.queueOperation(operation); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + +} diff --git a/src/com/connor/rb/plm/rb023/Rb023Operation.java b/src/com/connor/rb/plm/rb023/Rb023Operation.java new file mode 100644 index 0000000..2fc3620 --- /dev/null +++ b/src/com/connor/rb/plm/rb023/Rb023Operation.java @@ -0,0 +1,900 @@ +package com.connor.rb.plm.rb023; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import org.apache.commons.lang.StringUtils; + +import com.connor.rb.plm.util.ClassAttributeBean; +import com.connor.rb.plm.util.ParseXML; +import com.connor.rb.plm.util.TCUtils; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; + + + +public class Rb023Operation extends AbstractAIFOperation { + + private TCSession session; + private InterfaceAIFComponent[] targets; + private Map> attrMap; + private Map> attrMap2; + private Map> attrMap3; + private Map> attrMap4; + private Map> attrMap5; + private List asList = new ArrayList(); + private List esList = new ArrayList(); + private TCPreferenceService service; + private String[] ss1 = { "RB3_ZC", "RB3_GQ", "RB3_GZ", "RB3_BZJ" }; + private String[] xzgn = { "RB3_GNZC", "RB3_GNLBJ", "RB3_XZCP" }; + private String[] ss2 = { "RB3_LBJ", "RB3_YZ" }; + // String[] ss3= {"RB3_GQ","RB3_GZ","RB3_BZJ"}; + private String[] ss4 = { "RB3_YCL" }; + //Դ 2025319 + private String[] ss5 = {"RB3_GYZY"}; + private TCComponentItem item123; + +// private String[] lovVal = new String[] { "ǰ", "׼", "޽Ӵ", "ʽ", "ͨ", "A:NBR", "0:", "", "", +// "SN:1805ػ", "ȴ", "", "S:(25% to 35%)", "C0","V0","Z0","׼","PC:ﵽC&UƷƾҪ" +// ,"P0:ﵽC&UƷƾҪ","ṹҪƹ","0:˫нǽӴ",":SECC൱",":벿Ŷȷ","BC:35"}; +// private String[] esLovVal = new String[] { "Non", "Standard ball", "Non", "Open", "Without vent hole", "A:NBR", +// "0:Black", "Non", "Ball", "SN:1805 temper","Conventional monolithic martensite quenching heat treatment", +// "Single", "S:(25% to 35%)", "C0","V0","Z0","Standard","PC:Meet the group C&U brand accuracy requirements" +// ,"P0:Meet the group C&U brand accuracy requirements","Other structures need to formulate rules","0:Double row angular contact ball bearing" +// ,"Not marked: SECC or equivalent","Other materials: confirm with department team for approval","BC:35"}; + public Rb023Operation(TCSession session, InterfaceAIFComponent[] targets) { + this.session = session; + this.targets = targets; + this.service = session.getPreferenceService(); + + } + + @Override + public void executeOperation() throws Exception { + Object[] obj = new Object[1]; + obj[0] = ""; + TCUserService userservice = this.session.getUserService(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + try { + TCUtils.openLogByPass(session, "ƴӱ"); + userservice.call("Connor_set_bypass", obj); + System.out.println("򣬿ʼִС"); + String lovVal = service.getStringValue("RB3_lovVal_default"); + String esLovVal = service.getStringValue("RB3_esLovVal_default"); + if (lovVal.contains(";")) { + String[] vals = lovVal.split(";"); + String[] esVals = esLovVal.split(";"); + for (int i = 0; i < vals.length; i++) { + asList.add(vals[i]); + esList.add(esVals[i]); + } + } + ParseXML xml = new ParseXML(); + File file = xml.getSXX("RB3_CPHPJFS", session); + + attrMap = xml.parseXMLAttr(file); + if (attrMap == null || attrMap.size() <= 0) { + MessageBox.post("ѡRB3_CPHPJFSδã飡", "WARNING", MessageBox.WARNING); + + return; + } + File file2 = xml.getSXX("RB3_THPJFS", session); + attrMap2 = xml.parseXMLAttr(file2); + if (attrMap2 == null || attrMap2.size() <= 0) { + MessageBox.post("ѡRB3_THPJFSδã飡", "WARNING", MessageBox.WARNING); + + return; + } + File file3 = xml.getSXX("RB3_BSHPJFS", session); + attrMap3 = xml.parseXMLAttr(file3); + if (attrMap3 == null || attrMap3.size() <= 0) { + MessageBox.post("ѡRB3_BSHPJFSδã飡", "WARNING", MessageBox.WARNING); + + return; + } + File file4 = xml.getSXX("RB3_SMPJFS", session); + attrMap4 = xml.parseXMLAttr(file4); + if (attrMap4 == null || attrMap4.size() <= 0) { + MessageBox.post("ѡRB3_SMPJFSδã飡", "WARNING", MessageBox.WARNING); + + return; + } + File file5 = xml.getSXX("RB3_JYMPJFS", session); + attrMap5 = xml.parseXMLAttr(file5); + if (attrMap5 == null || attrMap5.size() <= 0) { + MessageBox.post("ѡRB3_JYMPJFSδã飡", "WARNING", MessageBox.WARNING); + + return; + } + + StringBuilder infoBuilder = new StringBuilder(""); + for (int i = 0; i < targets.length; i++) { + if (targets[i] instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) targets[i]; + item123 = item; + System.out.println("itemֵΪ:" + item123); + String th = null; + String type = item.getType(); + + TCComponentItemRevision rev = item.getLatestItemRevision(); + + if (Arrays.asList(ss1).contains(type)) { + + th = saveCPHCOM(rev, attrMap2, "rb3_th"); + System.out.println("th:" + th); + saveCPHCOM(rev, attrMap3, "rb3_bsh"); + saveCPHCOM(rev, attrMap4, "rb3_sm2"); + String saveCPHCOM = saveCPHCOM(rev, attrMap, "rb3_cph"); + if (saveCPHCOM == null) { + return; + }else if("óɹ".equals(saveCPHCOM)) { + if (th != null) { + System.out.println("thֵΪ:" + th); + String[] keys = new String[] { " ID" }; + String[] values = new String[] { th }; + List compList = queryObject(" ID", keys, values); + if (compList == null || compList.size() <= 0) { + dealReferenceComp(rev, "TC_Is_Represented_By", th); + } else { + infoBuilder.append("ϵͳвѯidΪ" + th + "ͼֽͼֽϢ޸ġ\n"); +// MessageBox.post("", "WARNING", MessageBox.WARNING); +// try { +// TCUtils.closeLogByPass(session, "ƴӱ"); +// userservice.call("Connor_close_bypass", obj); +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// return; + } + } + continue; + } + System.out.println("cphӡΪ" + saveCPHCOM); + if (rev.getStringProperty("rb3_cph") == null) { + System.out.println("ƷŲڣ"); + } + // Ż + + List compList = null; + if (type.equals("RB3_LBJ")) { + System.out.println("ʼòѯRBSearchLBJCPHѯĿƷΪ" + saveCPHCOM); + compList = queryObject("RBSearchLBJCPH", new String[] { "Ʒ" }, + new String[] { saveCPHCOM }); + } else if (type.equals("RB3_YZ")) { + System.out.println("ʼòѯRBSearchYZCPHѯĿƷΪ" + saveCPHCOM); + compList = queryObject("RBSearchYZCPH", new String[] { "Ʒ" }, + new String[] { saveCPHCOM }); + } else if (type.equals("RB3_YCL")) { + System.out.println("ʼòѯRBSearchYCLCPHѯĿƷΪ" + saveCPHCOM); + compList = queryObject("RBSearchYCLCPH", new String[] { "Ʒ" }, + new String[] { saveCPHCOM }); + } else if (type.equals("RB3_GNZC")) { + System.out.println("ʼòѯRBSearchGNZCCPHѯĿƷΪ" + saveCPHCOM); + compList = queryObject("RBSearchGNZCCPH", new String[] { "Ʒ" }, + new String[] { saveCPHCOM }); + } else if (type.equals("RB3_GNLBJ")) { + System.out.println("ʼòѯRBSearchGNLBJCPHѯĿƷΪ" + saveCPHCOM); + compList = queryObject("RBSearchGNLBJCPH", new String[] { "Ʒ" }, + new String[] { saveCPHCOM }); + } else if (type.equals("RB3_XZCP")) { + System.out.println("ʼòѯRBSearchXZCPCPHѯĿƷΪ" + saveCPHCOM); + compList = queryObject("RBSearchXZCPCPH", new String[] { "Ʒ" }, + new String[] { saveCPHCOM }); + } else if (type.equals("RB3_ZC")) { + System.out.println("ʼòѯRBSearchZCCPHѯĿƷΪ" + saveCPHCOM); + compList = queryObject("RBSearchZCCPH", new String[] { "Ʒ" }, + new String[] { saveCPHCOM }); + } else if (type.equals("RB3_GQ")) { + System.out.println("ʼòѯRBSearchGQCPHѯĿƷΪ" + saveCPHCOM); + compList = queryObject("RBSearchGQCPH", new String[] { "Ʒ" }, + new String[] { saveCPHCOM }); + } else if (type.equals("RB3_GZ")) { + System.out.println("ʼòѯRBSearchGZCPHѯĿƷΪ" + saveCPHCOM); + compList = queryObject("RBSearchGZCPH", new String[] { "Ʒ" }, + new String[] { saveCPHCOM }); + } else if (type.equals("RB3_BZJ")) { + System.out.println("ʼòѯRBSearchBZJCPHѯĿƷΪ" + saveCPHCOM); + compList = queryObject("RBSearchBZJCPH", new String[] { "Ʒ" }, + new String[] { saveCPHCOM }); + } + if (compList != null) { + + if (compList.size() > 0) { + String nID = item.getStringProperty("item_id").substring(0, 2); + + for (int j = 0; j < compList.size(); j++) { + if (compList.get(j).getProperty("item_id").equals(rev.getProperty("item_id"))) { + continue; + } + System.out.println("жitem_idǰλǷͬ"); + String compID = compList.get(j).getProperty("item_id"); + String cID = compID.substring(0, 2); + System.out.println("compID:" + compID + ",cID:" + cID); + if (nID.equals(cID)) { + MessageBox.post("ϵͳѴڲƷΪ" + saveCPHCOM + "ϣ룡", "", + MessageBox.INFORMATION); + return; +// throw new Exception("ϵͳѴڲƷΪ" + saveCPHCOM + "ϣ룡򼴽˳"); +// + } + } + } + } else { + System.out.println("ʼòƷ" + saveCPHCOM); + rev.setStringProperty("rb3_cph", saveCPHCOM); + } + // endŻ + + } else if (Arrays.asList(ss2).contains(type)) { + saveCPHCOM(rev, attrMap, "rb3_cph"); + th = saveCPHCOM(rev, attrMap2, "rb3_th"); + } else if (Arrays.asList(ss4).contains(type)) { + saveCPHCOM(rev, attrMap, "rb3_cph"); + } else if (Arrays.asList(ss5).contains(type)) { + String saveCPHCOM = saveCPHCOM(rev, attrMap5, "rb3_jym"); + if (saveCPHCOM == null) { + return; + }else { + continue; + } + } else if (Arrays.asList(xzgn).contains(type)) { + System.out.println(""); + String saveCPHCOM = saveCPHCOM(rev, attrMap, "rb3_cph"); + System.out.println("cphӡΪ" + saveCPHCOM); + if (rev.getStringProperty("rb3_cph") == null) { + System.out.println("ƷŲڣ"); + } + // Ż + List compList = null; + if (type.equals("RB3_LBJ")) { + System.out.println("ʼòѯRBSearchLBJCPHѯĿƷΪ" + saveCPHCOM); + compList = queryObject("RBSearchLBJCPH", new String[] { "Ʒ" }, + new String[] { saveCPHCOM }); + } else if (type.equals("RB3_YZ")) { + System.out.println("ʼòѯRBSearchYZCPHѯĿƷΪ" + saveCPHCOM); + compList = queryObject("RBSearchYZCPH", new String[] { "Ʒ" }, + new String[] { saveCPHCOM }); + } else if (type.equals("RB3_YCL")) { + System.out.println("ʼòѯRBSearchYCLCPHѯĿƷΪ" + saveCPHCOM); + compList = queryObject("RBSearchYCLCPH", new String[] { "Ʒ" }, + new String[] { saveCPHCOM }); + } else if (type.equals("RB3_GNZC")) { + System.out.println("ʼòѯRBSearchGNZCCPHѯĿƷΪ" + saveCPHCOM); + compList = queryObject("RBSearchGNZCCPH", new String[] { "Ʒ" }, + new String[] { saveCPHCOM }); + } else if (type.equals("RB3_GNLBJ")) { + System.out.println("ʼòѯRBSearchGNLBJCPHѯĿƷΪ" + saveCPHCOM); + compList = queryObject("RBSearchGNLBJCPH", new String[] { "Ʒ" }, + new String[] { saveCPHCOM }); + } else if (type.equals("RB3_XZCP")) { + System.out.println("ʼòѯRBSearchXZCPCPHѯĿƷΪ" + saveCPHCOM); + compList = queryObject("RBSearchXZCPCPH", new String[] { "Ʒ" }, + new String[] { saveCPHCOM }); + } else if (type.equals("RB3_ZC")) { + System.out.println("ʼòѯRBSearchZCCPHѯĿƷΪ" + saveCPHCOM); + compList = queryObject("RBSearchZCCPH", new String[] { "Ʒ" }, + new String[] { saveCPHCOM }); + } else if (type.equals("RB3_GQ")) { + System.out.println("ʼòѯRBSearchGQCPHѯĿƷΪ" + saveCPHCOM); + compList = queryObject("RBSearchGQCPH", new String[] { "Ʒ" }, + new String[] { saveCPHCOM }); + } else if (type.equals("RB3_GZ")) { + System.out.println("ʼòѯRBSearchGZCPHѯĿƷΪ" + saveCPHCOM); + compList = queryObject("RBSearchGZCPH", new String[] { "Ʒ" }, + new String[] { saveCPHCOM }); + } else if (type.equals("RB3_BZJ")) { + System.out.println("ʼòѯRBSearchBZJCPHѯĿƷΪ" + saveCPHCOM); + compList = queryObject("RBSearchBZJCPH", new String[] { "Ʒ" }, + new String[] { saveCPHCOM }); + } + if (compList != null) { + if (compList.size() > 0) { + String nID = item.getStringProperty("item_id").substring(0, 2); + + for (int j = 0; j < compList.size(); j++) { + if (compList.get(j).getProperty("item_id").equals(rev.getProperty("item_id"))) { + continue; + } + System.out.println("жitem_idǰλǷͬ"); + String compID = compList.get(j).getProperty("item_id"); + String cID = compID.substring(0, 2); + System.out.println("compID:" + compID + ",cID:" + cID); + if (nID.equals(cID)) { + MessageBox.post("ϵͳѴڲƷΪ" + saveCPHCOM + "ϣ룡", "", + MessageBox.INFORMATION); + return; +// throw new Exception("ϵͳѴڲƷΪ" + saveCPHCOM + "ϣ룡򼴽˳"); +// throw new Exception("ϵͳѴڲƷΪ" + saveCPHCOM + "ϣ룡򼴽˳"); + } + } + } else { + // endŻ + System.out.println("ʼòƷ" + saveCPHCOM); + rev.setStringProperty("rb3_cph", saveCPHCOM); + } + } + + System.out.println("new run"); + } + + System.out.println("th:" + th); + if (th != null) { + System.out.println("thֵΪ:" + th); + String[] keys = new String[] { " ID" }; + String[] values = new String[] { th }; + List compList = queryObject(" ID", keys, values); + if (compList == null || compList.size() <= 0) { + dealReferenceComp(rev, "TC_Is_Represented_By", th); + } else { + infoBuilder.append("ϵͳвѯidΪ" + th + "ͼֽͼֽϢ޸ġ\n"); +// MessageBox.post("ϵͳвѯidΪ" + th + "ͼֽͼֽϢ޸ġ", "WARNING", MessageBox.WARNING); +// try { +// TCUtils.closeLogByPass(session, "ƴӱ"); +// userservice.call("Connor_close_bypass", obj); +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// return; + continue; + } + } +// if("RB3_ZC".equals(type)) { +// saveCPHCOM(rev,attrMap,"rb3_cph"); +// saveCPHCOM(rev,attrMap2,"rb3_th"); +// saveCPHCOM(rev,attrMap3,"rb3_bsh"); +// saveCPHCOM(rev,attrMap4,"rb3_sm2"); +// }else if("RB3_LBJ".equals(type) || "RB3_YZ".equals(type)) { +// saveCPHCOM(rev,attrMap,"rb3_cph"); +// saveCPHCOM(rev,attrMap2,"rb3_th"); +// }else if("RB3_YCL".equals(type)){ +// saveCPHCOM(rev,attrMap,"rb3_cph"); +// }else if("RB3_GQ".equals(type)) { +// saveCPHCOM(rev,attrMap,"rb3_cph"); +// saveCPHCOM(rev,attrMap,"rb3_cph"); +// saveCPHCOM(rev,attrMap,"rb3_cph"); +// } + + else { + continue; + } + } + } + + MessageBox.post(rb.getString("bmpjwc23_display.TITLE")+"\n"+infoBuilder.toString(), "ʾ", MessageBox.INFORMATION); + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + MessageBox.post(rb.getString("bmpjsb23_display.TITLE"), "ʾ", MessageBox.INFORMATION); + }finally { + try { + TCUtils.closeLogByPass(session, "ƴӱ"); + userservice.call("Connor_close_bypass", obj); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + + public String splicValue(TCComponentItemRevision rev, List attrList, List esAttrList, + List markList, List defaultValueList, List isNList, List objectAttrList, String attrName) + throws TCException { + String item_id = null; + try { + item_id = rev.getProperty("item_id"); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + StringBuilder sb = new StringBuilder(); + + if (item_id != null && attrName.equals("rb3_th")) { + if (item_id.startsWith("22")) { + sb.append("SF-"); + } else if (item_id.startsWith("XX22")) { + sb.append("XX"); + } + } +// List asList = Arrays.asList(lovVal); +// List esList = Arrays.asList(esLovVal); + try { + TCComponentICO[] icos = rev.getClassificationObjects(); + String className = rev.getClassificationClass(); + if (icos == null || icos.length <= 0) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("xzdwl23_display.TITLE") + rev.getStringProperty("item_id") + + rb.getString("myfsdfl23_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return null; + } + List classList = new ArrayList(); + Map claMap = new HashMap(); + if (icos != null && icos.length > 0) { + ICSProperty[] icss = icos[0].getICSProperties(true); + for (ICSProperty ics : icss) { + claMap.put(ics.getId(), ics.getValue()); + } + } + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(className); + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + System.out.println("ԵIDֵ:" + claMap); + if (icsAttrS != null) { + for (ICSAdminClassAttribute attr : icsAttrS) { + ClassAttributeBean bean = new ClassAttributeBean(); + if (attr.isReferenceAttribute()) {// + continue; + } + if (attr.isReference()) { + continue; + } + int propID = attr.getAttributeId(); + bean.setId(propID); + String propDisName = attr.getName(); + bean.setName(propDisName); + System.out.print("propDisName:" + propDisName); + int attrType = attr.getFormat1().getType(); + bean.setType(attrType); + if (claMap != null && claMap.containsKey(propID)) { + bean.setVal(claMap.get(propID)); + System.out.println("bean.setVal==" + claMap.get(propID) + "propID==" + propID); + } else { + bean.setVal(""); + } + ICSKeyLov lov1 = attr.getFormat1().getKeyLov(); + lov1 = (lov1 == null ? attr.getFormat2().getKeyLov() : lov1); + if (lov1 != null) { + bean.setIslov(true); + String[] keys = lov1.getKeys(); + Map map1 = new HashMap(); + for (String key : keys) { + String value = lov1.getValueOfKey(key); + map1.put(value, key);// <ʾֵ,ʵֵ> + System.out.println("keyֵΪ:" + key + ";" + "bean.getVal==" + bean.getVal()); + if (key.equals(bean.getVal()) && (!bean.getVal().equals(""))) { + + bean.setVal(value); + break; + } + } + System.out.println("ȡmap1Ϊ:" + map1); + bean.setLov(map1); + } else { + bean.setIslov(false); + } + classList.add(bean); + } + } + for (int i = 0; i < attrList.size(); i++) { + System.out.println("***************"); + String attr = attrList.get(i); + String esAttr = esAttrList.get(i); + TCComponentItem item = rev.getItem(); + String type = item.getType(); + if ("RB3_LBJ".equals(type)) { + if ("".equals(attr)) { + String jh = rev.getStringProperty("rb3_jh"); + if (!("".equals(jh.trim())) && jh != null) { + String mark = markList.get(i); + if (!("".equals(mark.trim()))) { + sb.append(mark); + } + sb.append(jh); + } + continue; + } + } + boolean flag = true; + for (int j = 0; j < classList.size(); j++) { + String colorString = ""; + ClassAttributeBean attrBean = classList.get(j); + if (attr.equals(attrBean.getName()) || esAttr.equals(attrBean.getName())) { + String value = attrBean.getVal(); + System.out.println(">>>>" + value); + if ("0:".equals(value)) { + colorString = "0"; + } +// if(attrBean.isIslov()) { +// Map lov = attrBean.getLov(); +// value = lov.get(value); +// System.out.print("lov.get(value)=="+value); +// } + if (asList.contains(value) || esList.contains(value)) { + if (isNList.get(i).trim().contains(value)) { + if (value.contains(":")) { + System.out.println("value============" + value); + String[] values = value.split(":"); + value = values[0]; + } else if (value.contains("")) { + System.out.println("value============" + value); + String[] values = value.split(""); + value = values[0]; + } + } else { + value = ""; + } + } else { + if (value.contains(":")) { + System.out.println("value============" + value); + String[] values = value.split(":"); + value = values[0]; + } else if (value.contains("")) { + System.out.println("value============" + value); + String[] values = value.split(""); + value = values[0]; + } + } + + if (value.indexOf("Ʒ") >= 0 || value.indexOf("Finished product") >= 0) { + value = ""; + } else if (value.indexOf("") >= 0 || value.indexOf("Turning workpiece") >= 0) { + value = "C"; + } else if (value.indexOf("ȴ") >= 0 || value.indexOf("Heat treatment parts") >= 0) { + value = "R"; + } else if (value.indexOf("շ伷") >= 0 + || value.indexOf("Cold rolled parts or cold extrusion parts") >= 0) { + value = "D"; + } else if (value.indexOf("ͼ") >= 0 || value.indexOf("Forge piece") >= 0) { + value = "D"; + } + +// if ("Ʒ".equals(value) || "Finished product".equals(value)) { +// value = ""; +// } else if ("".equals(value) || "C:Turning workpiece".equals(value)) { +// value = "C"; +// } else if ("ȴ".equals(value)) { +// value = "R"; +// } else if ("".equals(value)) { +// value = "L"; +// } else if ("ͼ".equals(value)) { +// value = "D"; +// } + String revType = rev.getStringProperty("object_type"); + if (revType.equals("RB3_GNZCRevision") || revType.equals("RB3_GNLBJRevision")) { + if (!"".equals(colorString)) { + value = colorString; + } + if (value == null || "".equals(value.trim())) { + value = "#"; + } + } + System.out.println("value2============" + value); + if (!("".equals(value.trim())) && value != null) { + String mark = markList.get(i); + if (!("".equals(mark.trim()))) { + sb.append(mark); + } + sb.append(value); + } + flag = false; + break; + } + + } + if (flag) { + System.out.println("flag"); + String defalutValue = defaultValueList.get(i); + if (!("".equals(defalutValue.trim())) && defalutValue != null) { + String mark = markList.get(i); + if (!("".equals(mark.trim()))) { + sb.append(mark); + } + sb.append(defalutValue); + } + } + } + TCComponentItem item = rev.getItem(); + + // Ż ƴӶ + StringBuilder allobjectAttrAppend=new StringBuilder(); + Boolean isFirst=null; + if( objectAttrList.size()>0) { + String isAppendFirst = objectAttrList.get(0); + if("TRUE".equals(isAppendFirst)) { + isFirst=Boolean.TRUE; + }else if("FAIL".equals(isAppendFirst)) { + isFirst=Boolean.FALSE; + } + } + for(String objectAttr:objectAttrList) { + if (objectAttr.contains(".")) { + String[] parts = objectAttr.split("\\."); + String Type = parts[0]; + String objectattrName = parts[1]; // ȡ . + String propValue = getPropValue(item,rev,Type,objectattrName); + System.out.println("ƴӶ:"+objectAttr+" ֵ:"+propValue); + allobjectAttrAppend.append(propValue); + } + } + if(isFirst==Boolean.TRUE) { + allobjectAttrAppend.append(sb); + sb=allobjectAttrAppend; + }else if(isFirst==Boolean.FALSE) { + sb.append(allobjectAttrAppend); + } + System.out.println("еƴӶ :"+allobjectAttrAppend.toString()); + // Ż + if (attrName.equals("rb3_cph")) { + List compList = null; + String type = rev.getItem().getType(); + if (type.equals("RB3_LBJ")) { + System.out.println("ʼòѯRBSearchLBJCPHѯĿƷΪ" + sb.toString()); + compList = queryObject("RBSearchLBJCPH", new String[] { "Ʒ" }, new String[] { sb.toString() }); + } else if (type.equals("RB3_YZ")) { + System.out.println("ʼòѯRBSearchYZCPHѯĿƷΪ" + sb.toString()); + compList = queryObject("RBSearchYZCPH", new String[] { "Ʒ" }, new String[] { sb.toString() }); + } else if (type.equals("RB3_YCL")) { + System.out.println("ʼòѯRBSearchYCLCPHѯĿƷΪ" + sb.toString()); + compList = queryObject("RBSearchYCLCPH", new String[] { "Ʒ" }, new String[] { sb.toString() }); + } else if (type.equals("RB3_GNZC")) { + System.out.println("ʼòѯRBSearchGNZCCPHѯĿƷΪ" + sb.toString()); + compList = queryObject("RBSearchGNZCCPH", new String[] { "Ʒ" }, new String[] { sb.toString() }); + } else if (type.equals("RB3_GNLBJ")) { + System.out.println("ʼòѯRBSearchGNLBJCPHѯĿƷΪ" + sb.toString()); + compList = queryObject("RBSearchGNLBJCPH", new String[] { "Ʒ" }, new String[] { sb.toString() }); + } else if (type.equals("RB3_XZCP")) { + System.out.println("ʼòѯRBSearchXZCPCPHѯĿƷΪ" + sb.toString()); + compList = queryObject("RBSearchXZCPCPH", new String[] { "Ʒ" }, new String[] { sb.toString() }); + } else if (type.equals("RB3_ZC")) { + System.out.println("ʼòѯRBSearchZCCPHѯĿƷΪ" + sb.toString()); + compList = queryObject("RBSearchZCCPH", new String[] { "Ʒ" }, new String[] { sb.toString() }); + } else if (type.equals("RB3_GQ")) { + System.out.println("ʼòѯRBSearchGQCPHѯĿƷΪ" + sb.toString()); + compList = queryObject("RBSearchGQCPH", new String[] { "Ʒ" }, new String[] { sb.toString() }); + } else if (type.equals("RB3_GZ")) { + System.out.println("ʼòѯRBSearchGZCPHѯĿƷΪ" + sb.toString()); + compList = queryObject("RBSearchGZCPH", new String[] { "Ʒ" }, new String[] { sb.toString() }); + } else if (type.equals("RB3_BZJ")) { + System.out.println("ʼòѯRBSearchBZJCPHѯĿƷΪ" + sb.toString()); + compList = queryObject("RBSearchBZJCPH", new String[] { "Ʒ" }, new String[] { sb.toString() }); + } + if (compList != null) { + if (compList.size() > 0) { + String nID = rev.getStringProperty("item_id").substring(0, 2); + + for (int j = 0; j < compList.size(); j++) { + if (compList.get(j).getProperty("item_id").equals(rev.getProperty("item_id"))) { + continue; + } + System.out.println("жitem_idǰλǷͬ"); + String compID = compList.get(j).getProperty("item_id"); + String cID = compID.substring(0, 2); + System.out.println("compID:" + compID + ",cID:" + cID); + if (nID.equals(cID)) { + MessageBox.post("ϵͳѴڲƷΪ" + sb.toString() + "ϣ룡", "", + MessageBox.INFORMATION); + return null; +// throw new Exception("ϵͳѴڲƷΪ" + sb.toString() + "ϣ룡򼴽˳"); +// throw new Exception("ϵͳѴڲƷΪ" + sb.toString() + "ϣ룡򼴽˳"); + } + } + } + } + }else if(attrName.equals("rb3_jym")) { + List compList = null; + compList = queryObject("RBSearchGYZYJYM", new String[] { "У" }, new String[] { sb.toString() }); + if (compList != null) { + if (compList.size() > 0) { + String nID = rev.getStringProperty("item_id").substring(0, 2); + + for (int j = 0; j < compList.size(); j++) { + if (compList.get(j).getProperty("item_id").equals(rev.getProperty("item_id"))) { + continue; + } + MessageBox.post("ϵͳѴУΪ" + sb.toString()+",IdΪ"+compList.get(j).getProperty("item_id")+ "ϣ룡", "", + MessageBox.INFORMATION); + return null; + } + } + } + } + + // endŻ + if (attrName.equals("rb3_cph")) { + System.out.println("ʼòƷ" + sb.toString()); + rev.setStringProperty(attrName, sb.toString()); +// Locale defaultLocale = Locale.getDefault(); +// ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", +// defaultLocale); +// MessageBox.post(rb.getString("bmpjwc23_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return "óɹ"; + } else { + System.out.println("ʼ["+attrName+"]: "+ sb.toString()); + rev.setStringProperty(attrName, sb.toString()); + return sb.toString(); + } + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + + } + + private String getPropValue(TCComponentItem item,TCComponentItemRevision rev,String propFrom,String propName) throws Exception { + if (rev == null||item==null) { + return ""; + } + if (StringUtils.isEmpty(propFrom) || StringUtils.isEmpty(propName)) { + return ""; + } + TCComponent target; + propFrom = propFrom.trim().toUpperCase(); + if ("ITEM".equals(propFrom)) { + target = item; + } else if ("REV".equals(propFrom)) { + target = rev; + } else if ("ITEMMASTER".equals(propFrom)) { + target = item.getRelatedComponent("IMAN_master_form"); + } else if ("REVMASTER".equals(propFrom)) { + target = rev.getRelatedComponent("IMAN_master_form_rev"); + } else { + System.out.println("Чλã"+propFrom+"."+propName); + return ""; + //throw new Exception("δ֪λá" + propFrom + ""); + } + TCProperty prop = target.getTCProperty(propName.trim()); + if (prop == null) { + return target.getType() + "Ͷ󲻴ԣ" + propName; + } + return prop.getDisplayableValue(); + } + + public void saveCOM(String xmlClassName, Map> attrMap, String attrName) { + List markList = new ArrayList(); + List attrList = new ArrayList(); + List esAttrList = new ArrayList(); + if (attrMap.containsKey(xmlClassName)) { + List nameMarkList = attrMap.get(xmlClassName); + String attrNames = nameMarkList.get(0); + String marks = nameMarkList.get(1); + if (attrNames.contains(";")) { + String[] attrs = attrNames.split(";"); + String[] markss = marks.split(";"); + for (int j = 0; j < attrs.length; j++) { + System.out.println("attrs==============" + attrs[j]); + if (attrs[j].contains("+")) { + String[] attrss = attrs[j].split("\\+"); + attrList.add(attrss[0]); + esAttrList.add(attrss[1]); + markList.add(markss[j]); + } + } + } + } + } + + public String saveCPHCOM(TCComponentItemRevision rev, Map> attrMap, String attrName) { + + List defaultValueList = new ArrayList(); + List markList = new ArrayList(); + List isNList = new ArrayList(); + List attrList = new ArrayList(); + List esAttrList = new ArrayList(); + List objectAttrList = new ArrayList(); + try { + String xmlClassName = rev.getClassificationClass(); + System.out.println("================" + xmlClassName); + System.out.println("*********" + attrMap + "*********"); + if (attrMap.containsKey(xmlClassName)) { + System.out.println("================"); + List nameMarkList = attrMap.get(xmlClassName); + String attrNames = nameMarkList.get(0); + String marks = nameMarkList.get(1); + String values = nameMarkList.get(2); + String isN = nameMarkList.get(3); + String objectAttrs = nameMarkList.get(4); + if (attrNames.contains(";")) { + String[] attrs = attrNames.split(";"); + String[] markss = marks.split(";"); + String[] valuess = values.split(";"); + String[] isNs = isN.split(";"); + for (int i = 0; i < attrs.length; i++) { + if (attrs[i].contains("+")) { + String[] attrss = attrs[i].split("\\+"); + attrList.add(attrss[0]); + esAttrList.add(attrss[1]); + markList.add(markss[i]); + defaultValueList.add(valuess[i]); + isNList.add(isNs[i]); + } + } + } + if(objectAttrs.contains(";")) { + String[] attrs = objectAttrs.split(";"); + Collections.addAll(objectAttrList, attrs); + } + } + String str = splicValue(rev, attrList, esAttrList, markList, defaultValueList, isNList, objectAttrList,attrName); + return str; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + + } + + public void dealReferenceComp(TCComponentItemRevision rev, String proName, String th) { + try { + + TCComponent[] comps = rev.getReferenceListProperty(proName); + // TCComponent comp=rev.getReferenceProperty(proName); + if (comps != null) { + for (TCComponent comp : comps) { + if (comp instanceof TCComponentItemRevision) { + TCComponentItemRevision itemRev = (TCComponentItemRevision) comp; + TCComponentItem itemComp = itemRev.getItem(); + String type = itemComp.getStringProperty("object_type"); + System.out.println("Ե:" + type); + if (type.equals("RB3_CPT") || type.equals("RB3_CGT")) { + itemComp.setProperty("object_name", th); + itemComp.setProperty("item_id", th); + itemRev.setProperty("object_name", th); + } + } + } + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("myzdcx19_display.TITLE") + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + System.out.print("compList-----------"+compList); + return compList; + } else { + return null; + } + } +} diff --git a/src/com/connor/rb/plm/rb024/Rb024Handler.java b/src/com/connor/rb/plm/rb024/Rb024Handler.java new file mode 100644 index 0000000..88db064 --- /dev/null +++ b/src/com/connor/rb/plm/rb024/Rb024Handler.java @@ -0,0 +1,25 @@ +package com.connor.rb.plm.rb024; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class Rb024Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Rb024Operation opeartion = new Rb024Operation(app); + session.queueOperation(opeartion); + return null; + } + +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/rb024/Rb024Operation.java b/src/com/connor/rb/plm/rb024/Rb024Operation.java new file mode 100644 index 0000000..634250a --- /dev/null +++ b/src/com/connor/rb/plm/rb024/Rb024Operation.java @@ -0,0 +1,324 @@ +package com.connor.rb.plm.rb024; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import com.connor.rb.plm.util.ClassPropBean; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; + +public class Rb024Operation extends AbstractAIFOperation { + private AbstractAIFUIApplication app; + private TCSession session; + private TCPreferenceService service; + private String preferenceName = "RB3_Description"; + private String[] ss1 = { "RB3_GZ", "RB3_GQ", "RB3_BZJ", "RB3_ZC", "RB3_LBJ", "RB3_BZJBJ", "RB3_GQBJ", "RB3_GZBJ" }; + private String[] ss2 = { "RB3_YCL", "RB3_YZ" }; + + public Rb024Operation(AbstractAIFUIApplication app) { + this.app = app; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + } + /* + * @Override public void executeOperation() throws Exception { + * InterfaceAIFComponent[] targets = app.getTargetComponents(); for (int k = 0; + * k < targets.length; k++) { if(targets[k] instanceof TCComponentItemRevision) + * { TCComponentItemRevision rev = (TCComponentItemRevision) targets[k]; + * StringBuilder sb = new StringBuilder(); TCComponentItem item = rev.getItem(); + * String type = item.getType(); if("RB3_ZC".equals(type) || + * "RB3_LBJ".equals(type)) { String cph = rev.getStringProperty("rb3_cph"); + * String th = rev.getStringProperty("rb3_th"); sb.append("ͼ:"); sb.append(th); + * sb.append(" Ʒ:"); sb.append(cph); }else if("RB3_YCL".equals(type) || + * "RB3_YZ".equals(type)){ String str = ""; if("RB3_YCL".equals(type)) { str = + * service.getStringValue("RB3_YCL_DESC"); if("".equals(str.trim())) { + * MessageBox.post("RB3_YCL_DESC,鿴!!!!!", "ʾ", MessageBox.WARNING); + * return; } }else { str = service.getStringValue("RB3_YZ_DESC"); + * if("".equals(str.trim())) { MessageBox.post("RB3_YZ_DESC,鿴!!!!!", "ʾ", + * MessageBox.WARNING); return; } } + * System.out.println("str==============="+str); if(str.contains("=")) { + * String[] strs = str.split("="); if(!("".equals(strs[0]))) { + * if(strs[0].contains("|")) { String[] strss = strs[0].split("\\|"); for (int i + * = 0; i < strss.length; i++) { String value = rev.getStringProperty(strss[i]); + * //value = modiefValue(value); if(!((sb.toString()).endsWith(value))) { + * sb.append(value); } } }else { String value = rev.getStringProperty(strs[0]); + * //value = modiefValue(value); sb.append(value); } if("RB3_YCL".equals(type)) + * { //rev.setStringProperty("rb3_cph", sb.toString()); sb.append(":"); } // + * else { // sb.append(";"); // } + * + * } if(!("".equals(strs[1]))) { boolean flag = getValues(rev,strs[1],sb); + * if(flag) { return; } } } } System.out.println("descValue==="+sb.toString()); + * rev.setStringProperty("rb3_ms", sb.toString()); + * + * }else { MessageBox.post("ѡеĶΪǰ汾,鿴!!!!!", "ʾ", MessageBox.WARNING); } + * } MessageBox.post("дɹ,鿴!!!!!", "ʾ", MessageBox.WARNING); + * + * } + */ + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + InterfaceAIFComponent[] targets = app.getTargetComponents(); + int len = targets.length; + String[] preVals = service.getStringValues(preferenceName); + Map preMap = new HashMap(); + + for (String s : preVals) { + System.out.println("ѡֵΪ:" + s); + String[] sss = s.split("::"); + preMap.put(sss[0], sss[1]); + } + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + for (int h = 0; h < len; h++) { + if (targets[h] instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) targets[h]; + String type = item.getType(); + TCComponent[] revs = item.getReferenceListProperty("revision_list"); + + // int preLen=preVals.length; + + if (Arrays.asList(ss2).contains(type)) { + if (preMap.containsKey(type)) { + String preVal = preMap.get(type); + StringBuilder sb = new StringBuilder(); + System.out.println("preVal===============" + preVal); + for (TCComponent re : revs) { + TCComponentItemRevision rev = (TCComponentItemRevision) re; + TCProperty tcProperty = rev.getTCProperty("release_status_list"); + TCComponent[] refs = tcProperty.getReferenceValueArray(); + if (refs != null && refs.length > 0) { + continue; + } + if (preVal.contains("=")) { + String[] strs = preVal.split("="); + if (!("".equals(strs[0]))) { + if (strs[0].contains("|")) { + String[] strss = strs[0].split("\\|"); + for (int i = 0; i < strss.length; i++) { + String value = rev.getStringProperty(strss[i]); + // value = modiefValue(value); + if (!((sb.toString()).endsWith(value))) { + sb.append(value); + } + } + } else { + String value = rev.getStringProperty(strs[0]); + // value = modiefValue(value); + sb.append(value); + } + if ("RB3_YCL".equals(type)) { + // rev.setStringProperty("rb3_cph", sb.toString()); + sb.append(":"); + } +// else { +// sb.append(";"); +// } + + } + if (!("".equals(strs[1]))) { + boolean flag = getValues(rev, strs[1], sb); + if (flag) { + return; + } + } + } + System.out.println("descValue===" + sb.toString()); + rev.setStringProperty("rb3_ms", sb.toString()); + } + } + } else { + if (Arrays.asList(ss1).contains(type)) { + for (TCComponent re : revs) { + TCProperty tcProperty = re.getTCProperty("release_status_list"); + + TCComponent[] refs = tcProperty.getReferenceValueArray(); + if (refs != null && refs.length > 0) { +// MessageBox.post("ѷ", +// "ʾ", MessageBox.WARNING); + continue; + } + StringBuilder sb = new StringBuilder(); + TCComponentItemRevision rev = (TCComponentItemRevision) re; + String cph = rev.getStringProperty("rb3_cph"); + String th = rev.getStringProperty("rb3_th"); + sb.append("ͼ:"); + sb.append(th); + sb.append(" Ʒ:"); + sb.append(cph); + System.out.println("descValue===" + sb.toString()); + rev.setStringProperty("rb3_ms", sb.toString()); + } + } + } + } else { + MessageBox.post(rb.getString("xzddxwflj24_display.TITLE"), "ʾ", MessageBox.WARNING); + } + } + MessageBox.post(rb.getString("mssxtxcg24_display.TITLE"), "ʾ", MessageBox.WARNING); + } + + public boolean getValues(TCComponentItemRevision rev, String strs, StringBuilder sb) { + // TODO Auto-generated method stub + System.out.println("strs================" + strs); + TCClassificationService classificationService = session.getClassificationService(); + List classPropList = new ArrayList(); + try { + String className = rev.getClassificationClass(); + if ("".equals(className.trim())) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rev.getStringProperty("item_id") + rb.getString("gwlmyfszfl19_display.TITLE"), "ʾ", + MessageBox.WARNING); + return true; + } + TCComponentICO[] icos = rev.getClassificationObjects(); + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(className); + Map claMap = new HashMap(); + if (icos != null && icos.length > 0) { + ICSProperty[] icss = icos[0].getICSProperties(true); + for (ICSProperty ics : icss) { + claMap.put(ics.getId(), ics.getValue()); + } + } + for (Map.Entry entry : claMap.entrySet()) { + System.out.println("key = " + entry.getKey() + ", value = " + entry.getValue()); + } + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + + if (icsAttrS != null) { + for (ICSAdminClassAttribute attr : icsAttrS) { + if (attr.isReferenceAttribute()) { + continue; + } + if (attr.isReference()) { + continue; + } + ClassPropBean bean = new ClassPropBean(attr); + classPropList.add(bean); + } + } + if (strs.contains("|")) { + String[] strss = strs.split("\\|"); + for (int i = 0; i < strss.length; i++) { + String attrName = strss[i]; + String fh = ""; + if (attrName.contains("+")) { + String[] strsss = strss[i].split("\\+"); + attrName = strsss[0]; + fh = strsss[1]; + } + System.out.println("name1==========" + attrName); + for (int j = 0; j < classPropList.size(); j++) { + ClassPropBean bean = classPropList.get(j); + System.out.println("name2==========" + bean.propDisName); + if (attrName.equals(bean.propDisName)) { + String value = claMap.get(bean.propID); + if (bean.isLov) { + value = bean.lovMapping.get(value); + } + // value = modiefValue(value); + sb.append(value); + if (!("".equals(fh.trim()))) { + sb.append(fh); + } + break; + } + } + } + } else { + String attrName = strs; + String fh = ""; + if (attrName.contains("+")) { + String[] strsss = strs.split("\\+"); + attrName = strsss[0]; + fh = strsss[1]; + } + for (int j = 0; j < classPropList.size(); j++) { + ClassPropBean bean = classPropList.get(j); + if (attrName.equals(bean.propDisName)) { + String value = claMap.get(bean.propID); + if (bean.isLov) { + value = bean.lovMapping.get(value); + } + // value = modiefValue(value); + sb.append(value); + if (!("".equals(fh.trim()))) { + sb.append(fh); + } + break; + } + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return false; + } + + public String modiefValue(String value) { + String val = value; + if (val.contains(":")) { + System.out.println("value============" + val); + String[] values = val.split(":"); + val = values[0]; + } else if (val.contains("")) { + System.out.println("value============" + val); + String[] values = val.split(""); + val = values[0]; + } + return val; + } + +} + +/* + * for(int j=0;j propMap; + private Map propMap2 = new HashMap();; + private Map SpecialAttrMap = new HashMap();;// + private TCClassificationService myService; + final EditClassificationDialog DIALOG = this; + private TCComponentItemRevision rev; + private int[] ids; + private String[] values; + private String[] names; + private boolean finished; + private ICSPropertyDescription[] desc; + private String url = ""; + private static PrintWriter writer; + private static FileWriter fileWriter; + private static File login_file; + private static AtomicBoolean iscalled = new AtomicBoolean(false); + private static int a = 0; + private SearchableComboBox searchCombo; + public EditClassificationDialog(AbstractAIFApplication app) throws TCException { + + + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HH-mm-ss-SSS"); + String dirsPath = "C:\\Session"; + + String filename = "EditClass-"+ sdf.format(new Date()) +".txt"; + login_file = new File(dirsPath,filename); + File path = new File(dirsPath); + if(!path.exists()) { + path.mkdirs(); + } + if(login_file.exists()) { + login_file.delete(); + } + try { + login_file.createNewFile(); + fileWriter = new FileWriter(login_file, true); + writer = new PrintWriter(fileWriter); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + if (iscalled.compareAndSet(false, true)) { + // ýӿڵ߼ + this.app = app; + this.session = (TCSession) app.getSession(); + this.myService = session.getClassificationService(); + this.target = (TCComponent) AIFUtility.getCurrentApplication().getTargetComponent(); + writer.println(target.getType()); + writer.println(target instanceof TCComponentItemRevision ? "" : ""); + this.url = JDMethodUtil.getPrefStr("Autocode_SendClassServer_URL", session); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (target instanceof TCComponentItemRevision) { + try { + rev = (TCComponentItemRevision) target; + boolean isAccess = session.getTCAccessControlService().checkPrivilege(rev, "WRITE"); + if (!isAccess) { + // JOptionPane.showMessageDialog(this, "ûа汾޸ȨޣϵϵͳԱ", "ʾ", + // JOptionPane.WARNING_MESSAGE); + MessageBox.post(rb.getString("mybbxgqx24_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + initUI(); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + MessageBox.post(rb.getString("qxzbb25_display.TITLE"), "", MessageBox.ERROR); + } + + addComponentListener(new ComponentAdapter() { + + @Override + public void componentMoved(ComponentEvent e) { + // ƶʱִеĴ + + if(searchCombo != null) { + + Point location = searchCombo.getLocationOnScreen(); // ȡťĻϵľλ + searchCombo.getPopupBottonDialog().setLocation(location.x, location.y + 26); + } + } + }); + writer.println("ӿִ" + a++); + iscalled.compareAndSet(true, false); + + } else { + writer.println("ӿѱù"); + } + writer.flush(); + writer.close(); + } + + /** + * ȡLOVʾֵ + * + * @param icsD + * @return + */ + public static String getClassDisplayableValue(ICSPropertyDescription icsD) { + String result = ""; + ICSKeyLov lov = icsD.getFormat().getKeyLov(); + if (lov != null) { + String[] keys = lov.getKeys(); + for (String key : keys) { + result = lov.getValueOfKey(key); + return result; + } + } + return result; + } + + private void initUI() { + this.setTitle("޸ķ"); + + // ȡͬʱʹıķ + TCPreferenceService service = session.getPreferenceService(); + String[] strs = service.getStringValues("RB3_EditClassification_Special_attributes"); + writer.println("strs===>" + Arrays.toString(strs)); + if (strs != null && strs.length > 0) { + for (String str : strs) { + if (str.contains("=")) { + writer.println("ѡֵ" + str.toString()); + SpecialAttrMap.put(str.split("=")[0], str.split("=")[1].split(";")); + } + } + } else { + writer.println("ѡRB3_EditClassification_Special_attributesδ"); + } + + JPanel rootPanel = new JPanel(); + rootPanel.setLayout(null); + rootPanel.setPreferredSize(new Dimension(600, 350)); + + Map displayMap = new LinkedHashMap(); + propMap = new HashMap(); + writer.println("rev : " + rev + "----" + rev.getUid()); + try { + if (rev.getClassificationClass() != null && !"".equals(rev.getClassificationClass())) { + try { + rev.refresh(); + writer.println("rev.getClassificationClass()=" + rev.getClassificationClass()); + TCComponentICO ico = rev.getClassificationObjects()[0]; + ICSProperty[] props = ico.getICSProperties(true); + desc = ico.getICSPropertyDescriptors(); + for (int i = 0; i < props.length; i++) { +// writer.println(props[i].getId() + "===>" + props[i].getValue());// 30101===> + // desc.getName=Type and size series ǷԵ||| desc.getId=30101ǷID +// writer.println("desc.getName=" + desc[i].getName() + " desc.getId=" + desc[i].getId()); + displayMap.put(props[i], desc[i]); + } + } catch (TCException e1) { + e1.printStackTrace(); + } + } else { + this.disposeDialog(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("dqbbwbfl25_display.TITLE"), "", MessageBox.ERROR); + return; + } + } catch (TCException e) { + e.printStackTrace(); + } + + if (displayMap.size() == 0) { + return; + } + + JPanel content = new JPanel(); + content.setLayout(null); + content.setPreferredSize(new Dimension(800, displayMap.size() * (25 + 10))); + + int num = 0; + // ͨȡеķԣȻ + for (Entry entry : displayMap.entrySet()) { + // +++ + writer.println("11111========" + entry.getValue().getName()); + if (entry.getValue().isHidden()) { + writer.println("22222========" + entry.getValue().getName()); + continue; + } + // +++ + JLabel label = new JLabel(entry.getValue().getName() + ""); + label.setBounds(10, num * 35 + 10, 100, 25); + + ICSKeyLov lov = entry.getValue().getFormat().getKeyLov(); + +// ArrayList list = new ArrayList<>(); + if (lov != null) { + String[] keys = lov.getKeys(); +// JAutoCompleteComboBox combo = new JAutoCompleteComboBox(); +// JComboBox combo = new JComboBox(); + List itemsList = new ArrayList(); +// combo.addItem(new ClassPropBean("", "", "")); +// for (String key : keys) { +// // +++ +// KeyLov lov_key = lov.getKeyLovOfKey(key); +// boolean deprecated = lov_key.isDeprecated(); +// if (deprecated) { +// continue; +// } +// // +++ +// combo.addItem(new ClassPropBean(key, lov.getValueOfKey(key), "")); +// } + for (String key : keys) { + // +++ + KeyLov lov_key = lov.getKeyLovOfKey(key); + boolean deprecated = lov_key.isDeprecated(); + if (deprecated) { + continue; + } + // +++ + writer.println("key========" + key + "=========lov.getValueOfKey(key)===========" + lov.getValueOfKey(key)); + itemsList.add(new ClassPropBean(key, lov.getValueOfKey(key), "")); + } + String v = entry.getKey().getValue(); + writer.println("v" + v); +// for (int i = 0; i < combo.getItemCount(); i++) { +// if (v.equals(((ClassPropBean) combo.getItemAt(i)).getId())) { +// combo.setSelectedIndex(i); +// break; +// } +// } + + SearchableComboBox combo = new SearchableComboBox(itemsList,lov.getValueOfKey(v),this); +// combo.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// searchCombo = combo; +// } +// }); +// combo.setSelectedItem(v); +// if (!Arrays.asList(lov.getDisplayValues()).contains(v)) { +// combo.addItem(v); +// combo.setSelectedItem(v); +// } + + combo.setBounds(130, num * 35 + 10, 350, 25); +// combo.setEditable(false); + propMap.put(entry.getValue().getName(), combo); + writer.println("ʼֵ()" + entry.getValue().getName() + "-----" + combo.getText()); + content.add(combo); + } else { + JTextField text = new JTextField(entry.getKey().getValue()); + text.setBounds(130, num * 35 + 10, 350, 25); + propMap.put(entry.getValue().getName(), text); + writer.println("ʼֵ(д)" + entry.getValue().getName() + "-----" + text.getText()); + + content.add(text); + if (SpecialAttrMap.containsKey(entry.getValue().getName())) { +// JAutoCompleteComboBox combo = new JAutoCompleteComboBox(); +// JComboBox combo = new JComboBox(); +// combo.addItem(new ClassPropBean("", "", "")); +// int flag = 0; +// int flag2 = 1; +// for (String key : SpecialAttrMap.get(entry.getValue().getName())) { +// combo.addItem(key); +// if (entry.getKey().getValue().equals(key)) { +// flag = flag2; +// } +// flag2++; +// } +// if (flag != 0) { +// text.setText(""); +// combo.setSelectedIndex(flag); +// } else { +// combo.setSelectedIndex(flag); +// } + + List list = Arrays.asList(SpecialAttrMap.get(entry.getValue().getName())); + String mr_str = entry.getKey().getValue(); + if(list.contains(mr_str)) { + text.setText(""); + }else { + mr_str = ""; + } + + SearchableComboBox combo = new SearchableComboBox(list + ,mr_str,this); + +// combo.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// searchCombo = combo; +// } +// }); + combo.setBounds(500, num * 35 + 10, 200, 25); + propMap2.put(entry.getValue().getName(), combo); + writer.println("ʼֵ()" + entry.getValue().getName() + "-----" + text.getText()); + content.add(combo); + + } + } + + content.add(label); + + num++; + } + + JButton okBtn = new JButton("ȷ"); + okBtn.setBounds(40, 310, 100, 25); + okBtn.setSelected(true); + okBtn.addActionListener(ok()); + JButton cancelBtn = new JButton("ȡ"); + cancelBtn.setBounds(160, 310, 100, 25); + cancelBtn.addActionListener(cancel()); + + JScrollPane jsp = new JScrollPane(content); + jsp.addMouseWheelListener(new MouseWheelListener() { + + @Override + public void mouseWheelMoved(MouseWheelEvent e) { + System.out.println("?????????????????" + searchCombo); +// System.out.println(e.getWheelRotation()); + // TODO Auto-generated method stub + if(searchCombo!=null && searchCombo.isWheel()) { + System.out.println("?1"); + searchCombo.setWheel(false); + searchCombo.validateInput(); + searchCombo.getPopupBottonDialog().setVisible(false); + + } + } + }); + + + + jsp.getVerticalScrollBar().setUnitIncrement(16); + jsp.setBounds(0, 0, 600, 300); + // jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + rootPanel.add(jsp); + rootPanel.add(okBtn); + rootPanel.add(cancelBtn); + this.add(rootPanel); + this.pack(); + this.centerToScreen(); + this.setAutoRequestFocus(true); +// this.setResizable(false); + this.setAlwaysOnTop(true); + this.showDialog(); + } + + + + + public SearchableComboBox getSearchCombo() { + return searchCombo; + } + + public void setSearchCombo(SearchableComboBox searchCombo) { + this.searchCombo = searchCombo; + } + + private ActionListener ok() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + + try { + fileWriter = new FileWriter(login_file, true); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + writer = new PrintWriter(fileWriter); + ((JButton) e.getSource()).setEnabled(false); + rev = (TCComponentItemRevision) target; +System.out.println("ʼִ"); + new Thread(new Runnable() { + + @Override + public void run() { + int i = 1; + while (!DIALOG.finished) { + try { + DIALOG.setTitle("޸ķ " + StringCreateUtil.createPoint(i++ % 3)); + Thread.sleep(200); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + }).start(); + + EditClassificationDialog.this.setAlwaysOnTop(false); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + System.out.println("ʼִ2"); + if (saveClassification(rev)) { + System.out.println("ʼִ32"); + MessageBox.post(rb.getString("xgflsxcg25_display.TITLE"), "ɹ", MessageBox.INFORMATION); + EditClassificationDialog.this.disposeDialog(); + try { + rev.refresh(); + Rb023Operation operation = new Rb023Operation(session, new TCComponent[] {rev.getItem()}); + session.queueOperation(operation); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + ((JButton) e.getSource()).setEnabled(true); + } else { + ((JButton) e.getSource()).setEnabled(true); + MessageBox.post(rb.getString("xgflsxsb25_display.TITLE"), "", MessageBox.ERROR); + } + writer.flush(); + writer.close(); + + } + }; + } + + private ActionListener cancel() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + DIALOG.disposeDialog(); + writer.flush(); + writer.close(); + } + }; + } + + @SuppressWarnings("unchecked") + private boolean saveClassification(TCComponentItemRevision rev) { + + try { + TCComponentForm form = (TCComponentForm) rev.getRelatedComponents("IMAN_master_form_rev")[0]; + TCComponent[] status = form.getRelatedComponents("release_status_list"); + for (TCComponent comp : status) { + if (comp.getProperty("object_name").contains("ʽ")) { + JOptionPane.showMessageDialog(this, "汾ʽ޸ķ", "ʾ", JOptionPane.WARNING_MESSAGE); + return false; + } + } + if (SpecialAttrMap.size() > 0) { + for (String key : SpecialAttrMap.keySet()) { + if (propMap.containsKey(key) && propMap2.containsKey(key)) { + writer.println("ѡѡеΪ" + ((SearchableComboBox) propMap2.get(key)).getSelectedItem()); + writer.println("ıΪ" + ((JTextField) propMap.get(key)).getText()); + writer.println("ıȥոΪ" + ((JTextField) propMap.get(key)).getText().trim()); + if (((SearchableComboBox) propMap2.get(key)).getSelectedItem() != null + && !((SearchableComboBox) propMap2.get(key)).getSelectedItem().getId().equals("") + && !((JTextField) propMap.get(key)).getText().trim().equals("")) { + JOptionPane.showMessageDialog(this, "ԣ" + key + "ͬʱд", "ʾ", + JOptionPane.WARNING_MESSAGE); + return false; + } + } + } + } + + TCComponentICO[] icoS = rev.getClassificationObjects(); + writer.println("======>ȡķ:" + icoS.length); + String classID = rev.getClassificationClass(); + if (icoS == null || icoS.length == 0) { + return false; + } + for (int i = 0; i < icoS.length; i++) { + List propList = new ArrayList<>(); + TCComponentICO ico = icoS[i]; + ICSPropertyDescription[] desc = ico.getICSPropertyDescriptors(); + ICSProperty[] oldICSProps = ico.getICSProperties(true); + ids = new int[oldICSProps.length]; + values = new String[oldICSProps.length]; + names = new String[oldICSProps.length]; + StringBuffer sb = new StringBuffer(); + for (int j = 0; j < oldICSProps.length; j++) { + ids[j] = oldICSProps[j].getId(); + String v = oldICSProps[j].getValue(); + + writer.println("1:"+desc[j].getName()); + if (propMap.get(desc[j].getName()) instanceof JComboBox) { + writer.println("ȡѡֵ" + desc[j].getName()); + ClassPropBean bean = (ClassPropBean) ((JComboBox) propMap.get(desc[j].getName())) + .getSelectedItem(); + String str = bean.getId(); + values[j] = " ".equals(str) ? "" : str; + }else if (propMap.get(desc[j].getName()) instanceof SearchableComboBox) { + writer.println("ȡѡֵ" + desc[j].getName()); + ClassPropBean bean = (ClassPropBean) ((SearchableComboBox) propMap.get(desc[j].getName())) + .getSelectedItem(); + + + String str = bean.getId(); + values[j] = " ".equals(str) ? "" : str; + } else { + writer.println("ȡѡ2ֵ"); + if (propMap2.containsKey(desc[j].getName()) + && ((SearchableComboBox) propMap2.get(desc[j].getName())).getText() != null + && !"".equals(((SearchableComboBox) propMap2.get(desc[j].getName())).getText().trim())) { + values[j] = (String) ((SearchableComboBox) propMap2.get(desc[j].getName())) + .getSelectedItem().getId(); + writer.println("22:"+values[j]); + } else { +// writer.println("desc[j]="+desc[j]); +// writer.println("desc[j].getName()="+desc[j].getName()); +// writer.println("propMap.get(desc[j].getName()))="+propMap.get(desc[j].getName())); +// writer.println("propMap.get(desc[j].getName())).getText()="+((JTextField) propMap.get(desc[j].getName())).getText()); +// writer.println("desc[j]="+desc[j]); + if (propMap.get(desc[j].getName()) != null) { + values[j] = ((JTextField) propMap.get(desc[j].getName())).getText(); + } + + } + + } + + names[j] = desc[j].getName(); + if(v!=null && !"".equals(v)&&"".equals(values[j])) { + sb.append(desc[j].getName()).append(";"); + } + ClassProperty prop = new ClassProperty(ids[j], values[j]); + propList.add(prop); + } + + if(sb.length() > 0) { + int choice = JOptionPane.showConfirmDialog( + null, + "пֵ("+sb.toString()+")ԭֵǷ񱣴ģ", + "ȷ", + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE + ); + + // ûѡ + switch (choice) { + case JOptionPane.YES_OPTION: + writer.println("ûѡYes"); + break; + case JOptionPane.NO_OPTION: + writer.println("ûѡNo"); + return false; + case JOptionPane.CLOSED_OPTION: + writer.println("ȡ"); + return false; + default: + break; + + } + + + } + String json = objectToJson(propList); + writer.println("classID=" + classID); + writer.println("json=" + json); + // +++· + writer.println("·"); + if (sendObjToClassficationByWebService(ico.getUid(), classID, rev, json)) { + return true; + } else { + return false; + } + + // +++ +// +// //+++ +// writer.println("ɾ..."); +// try { +// deleteClass(getICO(rev, classID).getUid()); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// //+++ +// writer.println("ͷ..."); +// if (sendToClass(rev.getUid(), classID, json)) { +// return true; +// } else { +// return false; +// } + } + } catch (TCException e1) { + e1.printStackTrace(); + JOptionPane.showMessageDialog(null, e1, "", JOptionPane.ERROR_MESSAGE); + return false; + } + return true; + } + + private TCComponentICO getICO(TCComponentItemRevision rev, String classId) throws Exception { + if (rev == null || classId.equals("")) { + return null; + } + TCComponentICO[] icos = rev.getClassificationObjects(); + writer.println(rev + " -> Ѵڷࣺ" + Arrays.toString(icos)); + int len = icos.length; + if (len == 0) { + return null; + } + TCClassificationService classService = session.getClassificationService(); + for (int i = 0; i < len; i++) { + TCComponentICO ico = icos[i]; + classService.loadICOs(new String[] { ico.getUid() }, ""); + if (ico.getClassId() == null || ico.getClassId().equals("")) { + throw new Exception("쳣ϵԱ"); + } + if (classId.equals(ico.getClassId())) { + return ico; + } + } + return null; + } + + public void deleteClass(String icoPuid) { + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + String url = JDMethodUtil.getPrefStr("Autocode_SendClassServer_URL", session);// "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("DeleteClass"); + sc.setOptions(opts); + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("DeleteClass", omNs); + OMElement value = fac.createOMElement("icoPuid", omNs); + value.setText(icoPuid); + + method.addChild(value); + + OMElement res = sc.sendReceive(method); + res.getFirstElement().getText(); + writer.println(res.getFirstElement().getText()); + } catch (AxisFault e) { + e.printStackTrace(); + } + + } + + public boolean sendToClass(String wsoPUID, String classID, String json) { + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + String url = JDMethodUtil.getPrefStr("Autocode_SendClassServer_URL", session); + // "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("SendToClass"); + sc.setOptions(opts); + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("SendToClass", omNs); + OMElement value = fac.createOMElement("wsoPuiid", omNs); + value.setText(wsoPUID); + OMElement value1 = fac.createOMElement("classID", omNs); + value1.setText(classID); + OMElement value2 = fac.createOMElement("JsonContainer", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + value2.setText(json); + + method.addChild(value); + method.addChild(value1); + method.addChild(value2); + + OMElement res = sc.sendReceive(method); + res.getFirstElement().getText(); + writer.println(res.getFirstElement().getText()); + } catch (AxisFault e) { +// MessageBox.post("ͷʧܣ", "", MessageBox.ERROR); + e.printStackTrace(); + return false; + } + return true; + + } + + public boolean sendObjToClassficationByWebService(String icoPUID, String class_id, TCComponentItemRevision rev, + String json) { + boolean updateToClass = false; + try { + String url = JDMethodUtil.getPrefStr("Autocode_SendClassServer_URL", session);// "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + writer.println("icoPUID---------->" + rev.getUid()); + writer.println("class_id---------->" + class_id); + writer.println("class_id---------->" + json); + writer.println("icoPUID---------->" + url); + writer.println("class_id---------->" + icoPUID); + if (!class_id.replace(" ", "").equals("")) { + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + updateToClass = SoaServerUtil.updateToClass(rev.getUid(), class_id, json, url, icoPUID);// ͵ +// SoaServerUtil.deleteAndSendToClass(icoPUID,rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + e.printStackTrace(); + } + return updateToClass; + } + + public static String objectToJson(List props) { + String str = null; + try { + JSONArray json = JSONArray.fromObject(props);// javaתΪjson + str = json.toString();// jsonתΪַ + } catch (Exception e) { + e.printStackTrace(); + } + if(writer != null) { + + writer.println("JSON =>" + str); + } + return str; + } +} diff --git a/src/com/connor/rb/plm/rb025/Example.java b/src/com/connor/rb/plm/rb025/Example.java new file mode 100644 index 0000000..1435ef3 --- /dev/null +++ b/src/com/connor/rb/plm/rb025/Example.java @@ -0,0 +1,23 @@ +package com.connor.rb.plm.rb025; + +import java.util.concurrent.atomic.AtomicBoolean; + +public class Example { + private static AtomicBoolean isCalled = new AtomicBoolean(false); + private static int a = 0; + public Example() { + if (isCalled.compareAndSet(false, true)) { + // ýӿڵ߼ + try { + new Thread().sleep(5000); + System.out.println("ӿִ" + a++); + isCalled.compareAndSet(true, false); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + System.out.println("ӿѱù"); + } + } +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/rb025/JAutoCompleteComboBox.java b/src/com/connor/rb/plm/rb025/JAutoCompleteComboBox.java new file mode 100644 index 0000000..ad80851 --- /dev/null +++ b/src/com/connor/rb/plm/rb025/JAutoCompleteComboBox.java @@ -0,0 +1,213 @@ +package com.connor.rb.plm.rb025; + +import javax.swing.*; +import javax.swing.Timer; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.util.*; +import java.util.List; +import java.util.function.Function; +import java.awt.event.InputMethodEvent; +import java.awt.event.InputMethodListener; +import java.text.AttributedCharacterIterator; + +public class JAutoCompleteComboBox extends JComboBox { + private JTextField comboBoxTextField; + private List originalContent = new ArrayList<>(); + private List filteredContent = new ArrayList<>(); + private Function matcher = Object::toString; + private Timer filterTimer; + private static final int FILTER_DELAY = 300; // ӳ٣룩 + private boolean isComposing = false; + private String lastText = ""; // ¼ϴ + + public JAutoCompleteComboBox() { + super(); + initialize(); + } + + public JAutoCompleteComboBox(T[] items) { + super(items); + originalContent.addAll(Arrays.asList(items)); + initialize(); + } + + public JAutoCompleteComboBox(List items) { + super(items.toArray((T[]) new Object[0])); + originalContent.addAll(items); + initialize(); + } + + private void initialize() { + setEditable(true); + comboBoxTextField = (JTextField) getEditor().getEditorComponent(); + + // DocumentListener ɾ + comboBoxTextField.getDocument().addDocumentListener(new DocumentListener() { + @Override + public void insertUpdate(DocumentEvent e) { + scheduleFilter(); + } + + @Override + public void removeUpdate(DocumentEvent e) { + scheduleFilter(); + } + + @Override + public void changedUpdate(DocumentEvent e) { + // + } + }); + + // 뷨 + comboBoxTextField.addInputMethodListener(new InputMethodListener() { + @Override + public void inputMethodTextChanged(InputMethodEvent e) { + AttributedCharacterIterator composedText = e.getText(); + if (composedText != null && composedText.getEndIndex() > 0) { + isComposing = true; + } else { + isComposing = false; + scheduleFilter(); + } + } + + @Override + public void caretPositionChanged(InputMethodEvent e) { + // + } + }); + + // + comboBoxTextField.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + validateInput(); // ʧʱ֤ + } + }); + + // ʼ Timer + filterTimer = new Timer(FILTER_DELAY, e -> performFilter()); + filterTimer.setRepeats(false); + + // ʼԭʼ + filteredContent.addAll(originalContent); + updateModel(filteredContent); + } + + private void validateInput() { + String input = comboBoxTextField.getText().trim(); + if (input.isEmpty()) return; + + boolean found = originalContent.stream() + .anyMatch(item -> matcher.apply(item).equalsIgnoreCase(input)); + + if (!found) { + // ʾ + comboBoxTextField.setText(""); + JOptionPane.showMessageDialog( + this, + " '" + input + "' бУ롣", + "", + JOptionPane.ERROR_MESSAGE + ); + } + } + + private void scheduleFilter() { + if (isComposing) return; + + String currentText = comboBoxTextField.getText().trim(); + if (currentText.equals(lastText)) return; + + lastText = currentText; + filterTimer.restart(); + } + + private void performFilter() { + String target = comboBoxTextField.getText().trim().toLowerCase(); + List newFilteredContent = new ArrayList<>(); + + if (target.isEmpty()) { + newFilteredContent.addAll(originalContent); + } else { + for (T item : originalContent) { + String text = matcher.apply(item).toLowerCase(); + if (text.contains(target)) { + newFilteredContent.add(item); + } + } + } + + // ݱ仯ʱģ + if (!Objects.equals(newFilteredContent, filteredContent)) { + filteredContent.clear(); + filteredContent.addAll(newFilteredContent); + updateModel(filteredContent); + } + + // ӳչ + SwingUtilities.invokeLater(() -> { + revalidate(); + repaint(); + if (isShowing() && !isPopupVisible() && !filteredContent.isEmpty()) { + setPopupVisible(true); + } + }); + } + + private void updateModel(List items) { + String currentInput = comboBoxTextField.getText(); // 浱ǰ + + DefaultComboBoxModel model = (DefaultComboBoxModel) getModel(); + model.removeAllElements(); + + for (T item : items) { + model.addElement(item); + } + + // ӳٻָıݣⴥĵ + SwingUtilities.invokeLater(() -> { + comboBoxTextField.setText(currentInput); + comboBoxTextField.setCaretPosition(currentInput.length()); + }); + } + + public void setMatchField(Function matcher) { + this.matcher = matcher; + } + + @Override + public void addItem(T item) { + super.addItem(item); + originalContent.add(item); + } + + public void refreshData(List newData) { + originalContent.clear(); + originalContent.addAll(newData); + filteredContent.clear(); + filteredContent.addAll(newData); + updateModel(newData); + } + + public String getText() { + return comboBoxTextField.getText(); + } + + public void setText(String text) { + comboBoxTextField.setText(text); + performFilter(); // ֶıʱ + } + + @Override + public void setSelectedItem(Object anObject) { + super.setSelectedItem(anObject); + if (anObject != null) { + comboBoxTextField.setText(matcher.apply((T) anObject)); + } + } +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/rb025/JDMethodUtil.java b/src/com/connor/rb/plm/rb025/JDMethodUtil.java new file mode 100644 index 0000000..188f8a6 --- /dev/null +++ b/src/com/connor/rb/plm/rb025/JDMethodUtil.java @@ -0,0 +1,47 @@ +package com.connor.rb.plm.rb025; + +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; + +public class JDMethodUtil { + + public static TCPreferenceService service; + public static TCUserService userservice; + + /** + * + * + * @param prefName + * @return + */ + public static String getPrefStr(String prefName, TCSession session) { + if (service == null) { + service = session.getPreferenceService(); + } + String str = service.getString(TCPreferenceService.TC_preference_site, prefName); + if (str == null) { + str = new String(""); + } + return str; + } + + /** + * + * + * @param prefName + * @return + */ + public static String[] getPrefStrArray(String prefName, TCSession session) { + if (service == null) { + service = session.getPreferenceService(); + } + String[] strs = service.getStringArray(TCPreferenceService.TC_preference_site, prefName); + service.getStringValues(prefName); + service.getStringValue(prefName); + if (strs == null) { + strs = new String[] { "" }; + } + return strs; + } +} diff --git a/src/com/connor/rb/plm/rb025/MyJComboBox.java b/src/com/connor/rb/plm/rb025/MyJComboBox.java new file mode 100644 index 0000000..76a8650 --- /dev/null +++ b/src/com/connor/rb/plm/rb025/MyJComboBox.java @@ -0,0 +1,143 @@ +package com.connor.rb.plm.rb025; + +import javax.swing.*; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.ArrayList; +import java.util.List; +import java.util.Vector; + +public class MyJComboBox extends JComboBox { + private final JTextField comboBoxTextField = (JTextField) this.getEditor().getEditorComponent(); + private DefaultComboBoxModel defaultModel; + private List originalItems; + + // ޲ι캯 + public MyJComboBox() { + super(); + initialize(); + } + + // ClassPropBeanбĹ캯 + public MyJComboBox(List items) { + super(new Vector<>(items)); + initialize(); + updateModel(items); + } + + // ʼ + private void initialize() { + setEditable(true); + enableAutoComplete(); + originalItems = new ArrayList<>(); + } + + // Զɹ + private void enableAutoComplete() { + comboBoxTextField.addKeyListener(new KeyListener() { + @Override + public void keyTyped(KeyEvent e) {} + + @Override + public void keyPressed(KeyEvent e) {} + + @Override + public void keyReleased(KeyEvent e) { + performAutoComplete(); + showPopup(); + } + }); + } + + // ִԶ߼ + private void performAutoComplete() { + String input = comboBoxTextField.getText().trim(); + if (input.isEmpty()) { + restoreOriginalItems(); + return; + } + + List filtered = filterItems(input); + if (filtered.isEmpty()) { + setModel(new DefaultComboBoxModel<>( + (E[]) new ClassPropBean[]{createEmptyItem()} + )); + } else { + updateModel(filtered); + } + refreshDisplay(input); + } + + // Ŀ + private List filterItems(String input) { + List results = new ArrayList<>(); + for (E item : originalItems) { + if (item.getName().contains(input) || item.getId().contains(input)) { + results.add(item); + } + } + return results; + } + + // ѡռλ + private E createEmptyItem() { + return (E) new ClassPropBean("", "", ""); + } + + // ģ + public void updateModel(List newItems) { + originalItems = new ArrayList<>(newItems); + defaultModel = new DefaultComboBoxModel<>(new Vector<>(originalItems)); + setModel(defaultModel); + refreshDisplay(""); + } + + // ָԭʼĿб + private void restoreOriginalItems() { + setModel(defaultModel); + } + + // ˢʾ + private void refreshDisplay(String text) { + setSelectedIndex(-1); + comboBoxTextField.setText(text); + } + + // ı + public void setText(String text) { + comboBoxTextField.setText(text); + } + + // ȡı + public String getText() { + return comboBoxTextField.getText(); + } + + // ȡı + public JTextField getTextField() { + return comboBoxTextField; + } + + // IDѡ + public void setSelectedById(String id) { + for (int i = 0; i < getItemCount(); i++) { + E item = getItemAt(i); + if (id.equals(item.getId())) { + setSelectedIndex(i); + return; + } + } + } + + // ȡѡID + public String getSelectedId() { + E selectedItem = (E) getSelectedItem(); + return selectedItem != null ? selectedItem.getId() : ""; + } + + // ȡѡʾ + public String getSelectedName() { + E selectedItem = (E) getSelectedItem(); + return selectedItem != null ? selectedItem.getName() : ""; + } +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/rb025/Rb025Handler.java b/src/com/connor/rb/plm/rb025/Rb025Handler.java new file mode 100644 index 0000000..f27cdc9 --- /dev/null +++ b/src/com/connor/rb/plm/rb025/Rb025Handler.java @@ -0,0 +1,24 @@ +package com.connor.rb.plm.rb025; + +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; + +public class Rb025Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + try { + new Thread(new EditClassificationDialog(app)).start(); + } catch (TCException e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/com/connor/rb/plm/rb025/SearchableComboBox.java b/src/com/connor/rb/plm/rb025/SearchableComboBox.java new file mode 100644 index 0000000..d50d1bd --- /dev/null +++ b/src/com/connor/rb/plm/rb025/SearchableComboBox.java @@ -0,0 +1,465 @@ +package com.connor.rb.plm.rb025; + + +import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.ScrollPaneConstants; +import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; +import javax.swing.border.LineBorder; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import org.apache.commons.lang.StringUtils; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.MouseInfo; +import java.awt.Point; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.AdjustmentEvent; +import java.awt.event.AdjustmentListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseWheelEvent; +import java.awt.event.MouseWheelListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.Function; +import java.util.stream.Collectors; + +public class SearchableComboBox extends JButton { +// private JTextField searchField; +// private JList list; +// private JPopupMenu popupMenu; +// private DefaultListModel listModel; + private Function matcher = Object::toString; + private List originalItems; + private PopupBottonDialog dialog; + private ClassPropBean bean = new ClassPropBean("", "", ""); + + private boolean isWheel = false; + private EditClassificationDialog editClassificationDialog; + + public PopupBottonDialog getPopupBottonDialog(){ + return dialog; + } + + + public SearchableComboBox(List items,String str ,EditClassificationDialog editClassificationDialog) { + this.originalItems = new ArrayList<>(items); + this.editClassificationDialog = editClassificationDialog; + setText(str); + initComponents(); + setupListeners(); + } + + private void initComponents() { + setHorizontalAlignment(SwingConstants.CENTER); + dialog = new PopupBottonDialog(this); + } + + //ж + public boolean processList(List list , Class classstr) { + if (list == null || list.isEmpty()) { + return false; + } + + Object firstElement = list.get(0); + Class elementType = firstElement.getClass(); + + + + return elementType == classstr; + + + } + + public void validateInput() { + + String str_tmp = dialog.getSearchField().getText(); + if (str_tmp!=null && !"".equals(str_tmp) && + ( processList(originalItems,ClassPropBean.class) ? !originalItems.stream() + .anyMatch(item -> matcher.apply(item).equalsIgnoreCase(str_tmp)) : !originalItems.contains(str_tmp)) + ) { + // ʾ + System.out.println("ʼ"); + JOptionPane.showMessageDialog( + dialog, + " '" + str_tmp + "' бУ롣", + "", + JOptionPane.ERROR_MESSAGE + ); + setText(""); + dialog.getSearchField().setText(""); + + + }else { + setText(str_tmp); + } + + + } + + @Override + public void setText(String text) { + + // TODO Auto-generated method stub + if(!"".equals(text) && processList(originalItems,ClassPropBean.class) ) { + + Optional found = originalItems.stream() + .filter(x -> ((ClassPropBean)x).getName().equals(text)) // + .findFirst(); // ҵһƥԪأеĻ + found.ifPresent(value -> bean = (ClassPropBean) value); + } + if(!"".equals(text) && processList(originalItems,String.class) ) { + + bean.setId(text); + bean.setValue(text); + } + if("".equals(text)) { + bean.setId(text); + bean.setValue(text); + } + + super.setToolTipText(text); + super.setText(text); + } + + + private void setupListeners() { + addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + isWheel = true; + editClassificationDialog.setSearchCombo(SearchableComboBox.this); + if(dialog != null ) { + + if(!dialog.isVisible() ) { + // + dialog.getSearchField().setText(getText()); + dialog.setVisible(true); + + }else { + validateInput(); + + dialog.setVisible(false); + } + + + + } + } + }); + + + dialog.addWindowFocusListener(new WindowAdapter() { + + @Override + public void windowLostFocus(WindowEvent e) { + + Point mousePosition = MouseInfo.getPointerInfo().getLocation(); + Point location = getLocationOnScreen(); // ȡťĻϵľλ +//System.out.println(mousePosition.x +"----"+mousePosition.y); +//System.out.println(location.x +"----"+location.y); +//System.out.println(mousePosition.x < location.x || mousePosition.x > (location.x+getWidth()) +// || mousePosition.y < location.y || mousePosition.y > (location.y+getHeight())); + if((mousePosition.x < location.x || mousePosition.x > (location.x+getWidth()) + || mousePosition.y < location.y || mousePosition.y > (location.y+getHeight()))&&isWheel) { + System.out.println("111111111111"); + validateInput(); + + dialog.setVisible(false); // JDialog ĵطʱر JDialog + } + + + } + }); + + + } + + public ClassPropBean getSelectedItem() { + return bean; + // TODO Auto-generated method stub + } + + + public static SearchableComboBox Combo; + + // Է + public boolean isWheel() { + return isWheel; + } + + + public void setWheel(boolean isWheel) { + this.isWheel = isWheel; + } + + + public static void main(String[] args) { + SwingUtilities.invokeLater(() -> { + // + JPanel rootPanel = new JPanel(); + rootPanel.setLayout(null); + rootPanel.setPreferredSize(new Dimension(600, 350)); + JPanel content = new JPanel(); + content.setLayout(null); + content.setPreferredSize(new Dimension(700, 20 * (25 + 10))); + JScrollPane scrollPane=new JScrollPane(); // + for (int i = 0; i < 3; i++) { + +// List items = new ArrayList<>(); +// +// +// items.add(new ClassPropBean("1", "Appleƻ", "")); +// items.add(new ClassPropBean("2", "Banana㽶", "")); +// items.add(new ClassPropBean("3", "Orange", "")); +// items.add(new ClassPropBean("4", "Grape", "")); +// items.add(new ClassPropBean("5", "Pineapple", "")); +// items.add(new ClassPropBean("6", "Strawberry", "")); +// items.add(new ClassPropBean("7", "Watermelon", "")); +// items.add(new ClassPropBean("8", "Mango", "")); +// items.add(new ClassPropBean("9", "Peach", "")); +// items.add(new ClassPropBean("0", "Pear", "")); + +List items = new ArrayList<>(); + + + items.add("Appleƻ"); +// items.add(new ClassPropBean("2", "Banana㽶", "")); +// items.add(new ClassPropBean("3", "Orange", "")); +// items.add(new ClassPropBean("4", "Grape", "")); +// items.add(new ClassPropBean("5", "Pineapple", "")); +// items.add(new ClassPropBean("6", "Strawberry", "")); +// items.add(new ClassPropBean("7", "Watermelon", "")); +// items.add(new ClassPropBean("8", "Mango", "")); +// items.add(new ClassPropBean("9", "Peach", "")); +// items.add(new ClassPropBean("0", "Pear", "")); + + // ؼ + SearchableComboBox searchCombo = new SearchableComboBox(items,i+"",null); + + searchCombo.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Combo = searchCombo; + ClassPropBean bean = (ClassPropBean) (Combo) + .getSelectedItem(); + String str = bean.getId(); + System.out.println(str); + } + }); + // ѡ + searchCombo.setBounds(130, i * 35 + 10, 350, 25); + JLabel label = new JLabel( "Search:"); + label.setBounds(10, i * 35 + 10, 100, 25); + content.add(searchCombo); + content.add(label); + } + + // Դ + JFrame frame = new JFrame("Searchable ComboBox Demo"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setLayout(new FlowLayout()); + frame.setSize(7, 400); + frame.addComponentListener(new ComponentAdapter() { + + @Override + public void componentMoved(ComponentEvent e) { + // ƶʱִеĴ + if(Combo != null) { + + Point location = Combo.getLocationOnScreen(); // ȡťĻϵľλ + Combo.getPopupBottonDialog().setLocation(location.x, location.y + 26); + + } + + + } + }); + + scrollPane.addMouseWheelListener(new MouseWheelListener() { + + @Override + public void mouseWheelMoved(MouseWheelEvent e) { + +// System.out.println(e.getWheelRotation()); + // TODO Auto-generated method stub + if(Combo!=null && Combo.isWheel()) { + Combo.setWheel(false); + Combo.validateInput(); + Combo.getPopupBottonDialog().setVisible(false); + + } + } + }); + + +// scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { +// +// @Override +// public void adjustmentValueChanged(AdjustmentEvent e) { +// // TODO Auto-generated method stub +//if(Combo!=null) { +// +// Combo.validateInput(); +// Combo.getPopupBottonDialog().setVisible(false); +// } +// } +// }); +// content.add(new JLabel("Search:")); + +// scrollPane.setViewportView(content); //ڹʾб + scrollPane.getViewport().setView(content); + + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + scrollPane.getVerticalScrollBar().setUnitIncrement(16); + scrollPane.setBounds(0, 0, 600, 300); + rootPanel.add(scrollPane); +// content.setBackground(Color.BLUE); +// frame.add(new JLabel("Search:")); + frame.add(rootPanel); + + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + } + + + class PopupBottonDialog extends JDialog{ + + + private JTextField searchField; + private JList list; + private DefaultListModel listModel; + private JButton button; + private PopupBottonDialog dialogp = this; + + public PopupBottonDialog(JButton button) { + // TODO Auto-generated constructor stub + setUndecorated(true); + setLayout(new BorderLayout()); + searchField = new JTextField(); + searchField.setBorder(new LineBorder(Color.black, 1)); + list = new JList(); + list.setListData((T[]) originalItems.toArray()); //Ϊб + list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + list.setBorder(new LineBorder(Color.black, 1)); + JScrollPane scrollPane=new JScrollPane(); // + scrollPane.setViewportView(list); //ڹʾб + add(searchField, BorderLayout.NORTH); + add(scrollPane, BorderLayout.CENTER); + setPreferredSize(new Dimension(350, 100)); + + this.button = button; + setAlwaysOnTop(true); +// setModal(true); + + + // ӵرյĹ + + + searchField.getDocument().addDocumentListener(new DocumentListener() { + + @Override + public void removeUpdate(DocumentEvent e) { + // TODO Auto-generated method stub + setList(); + } + + @Override + public void insertUpdate(DocumentEvent e) { + // TODO Auto-generated method stub + setList(); + + + } + + @Override + public void changedUpdate(DocumentEvent e) { + // TODO Auto-generated method stub + + } + + + }); + + + list.addMouseListener(new MouseAdapter() { + + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + if(e.getClickCount() >= 2) { + Object item = list.getSelectedValue(); + if(item instanceof ClassPropBean) { + bean = (ClassPropBean) item; + searchField.setText(((ClassPropBean)item).getName()); + }else { + searchField.setText(item.toString()); + } + } + + } + }); + pack(); +// center(); +// setVisible(true); + } + + + public void setList() { + String str_tmp = searchField.getText(); +// System.out.println("Key str_tmp: " + str_tmp); + list.setListData(str_tmp == null || str_tmp.trim().equals("") ? + (T[]) originalItems.toArray() : (T[]) originalItems.stream() + .filter(item -> StringUtils.containsIgnoreCase( + item instanceof ClassPropBean ? ((ClassPropBean)item).getName() : item.toString(), str_tmp)) + .collect(Collectors.toList()).toArray()); + } + + + + public JTextField getSearchField() { + return searchField; + } + + + + @Override + public void setVisible(boolean b) { + // TODO Auto-generated method stub + setList(); + Point location = button.getLocationOnScreen(); // ȡťĻϵľλ + setLocation(location.x, location.y + 26); + setPreferredSize(new Dimension(350, 100)); + super.setVisible(b); + super.repaint(); + } + + + } +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/rb025/SoaServerUtil.java b/src/com/connor/rb/plm/rb025/SoaServerUtil.java new file mode 100644 index 0000000..7014caf --- /dev/null +++ b/src/com/connor/rb/plm/rb025/SoaServerUtil.java @@ -0,0 +1,349 @@ +package com.connor.rb.plm.rb025; + +import java.util.List; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.client.Options; +import org.apache.axis2.client.ServiceClient; +import org.apache.axis2.transport.http.HTTPConstants; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCComponentUserType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; + +import net.sf.json.JSONArray; + +/** + * ͷUtil + * + * @author 61666 + * + */ +public class SoaServerUtil { + + public static void sendToClass(String wsoPUID, String classID, String json, String url) { + // AbstractAIFApplication app; + // app=AIFUtility.getCurrentApplication(); + // TCSession session; + // session=(TCSession) app.getSession(); + // TCPreferenceService preferenceService; + // preferenceService=session.getPreferenceService(); + // String account=preferenceService.getStringValue("Autocode_PriverUser_ID"); + // String url; + // url = preferenceService.getStringValue("Autocode_SendClassServer_URL"); + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + // url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("SendToClass"); + sc.setOptions(opts); + + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("SendToClass", omNs); + OMElement value = fac.createOMElement("wsoPuiid", omNs); + value.setText(wsoPUID); + OMElement value1 = fac.createOMElement("classID", omNs); + value1.setText(classID); + OMElement value2 = fac.createOMElement("JsonContainer", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + value2.setText(json); + + method.addChild(value); + method.addChild(value1); + method.addChild(value2); + + OMElement res = sc.sendReceive(method); + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { + e.printStackTrace(); + } + + } + + public static boolean updateToClass(String wsoPUID, String classID, String json, String url, String icoUid) { + // AbstractAIFApplication app; + // app=AIFUtility.getCurrentApplication(); + // TCSession session; + // session=(TCSession) app.getSession(); + // TCPreferenceService preferenceService; + // preferenceService=session.getPreferenceService(); + // String account=preferenceService.getStringValue("Autocode_PriverUser_ID"); + // String url; + // url = preferenceService.getStringValue("Autocode_SendClassServer_URL"); + String reMsgString = ""; + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + // url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("UpdateToClass"); + sc.setOptions(opts); + + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("UpdateToClass", omNs); + OMElement value = fac.createOMElement("wsoPuiid", omNs); + value.setText(wsoPUID); + OMElement value1 = fac.createOMElement("classID", omNs); + value1.setText(classID); + OMElement value2 = fac.createOMElement("JsonContainer", omNs); + + OMElement value3 = fac.createOMElement("icoPUID", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + value2.setText(json); + value3.setText(icoUid); + + method.addChild(value); + method.addChild(value1); + method.addChild(value2); + method.addChild(value3); + OMElement res = sc.sendReceive(method); + reMsgString = res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + + } catch (AxisFault e) { + e.printStackTrace(); + return false; + } + + return true; + + } + + public static void deleteAndSendToClass(String icoPUID, String wsoPUID, String classID, String json, String url) { + // AbstractAIFApplication app; + // app=AIFUtility.getCurrentApplication(); + // TCSession session; + // session=(TCSession) app.getSession(); + // TCPreferenceService preferenceService; + // preferenceService=session.getPreferenceService(); + // String account=preferenceService.getStringValue("Autocode_PriverUser_ID"); + // String url; + // url = preferenceService.getStringValue("Autocode_SendClassServer_URL"); + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + // url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("SendToClass"); + sc.setOptions(opts); + + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("editToClass", omNs); + OMElement icovalue = fac.createOMElement("icoPUID", omNs); + icovalue.setText(icoPUID); + OMElement value = fac.createOMElement("wsoPuiid", omNs); + value.setText(wsoPUID); + OMElement value1 = fac.createOMElement("classID", omNs); + value1.setText(classID); + OMElement value2 = fac.createOMElement("JsonContainer", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + value2.setText(json); + method.addChild(icovalue); + method.addChild(value); + method.addChild(value1); + method.addChild(value2); + + OMElement res = sc.sendReceive(method); + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { + e.printStackTrace(); + } + + } + + // public static void main(String[] args) { + // deleteClass("1111", ""); + // } + // ɾʱ + public static void deleteClass(String icoPUID, String url) { + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + // url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL";//TODO + // ѡAutocode_SendClassServer_URL + // url = preferenceService.getStringValue("Autocode_SendClassServer_URL");//TODO + // ѡAutocode_SendClassServer_URL + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("DeleteClass"); + opts.setProperty(HTTPConstants.CHUNKED, "false"); + sc.setOptions(opts); + + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("DeleteClass", omNs); + OMElement value = fac.createOMElement("icoPuid", omNs); + value.setText(icoPUID); + // OMElement value1 = fac.createOMElement("classID", omNs); + //// value1.setText(classID); + // OMElement value2 = fac.createOMElement("JsonContainer", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + // value2.setText(json); + + method.addChild(value); + // method.addChild(value1); + // method.addChild(value2); + + OMElement res = sc.sendReceive(method); + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { + e.printStackTrace(); + } + + } + + public static String objectToJson(List props) { + String str = null; + try { + JSONArray json = JSONArray.fromObject(props);// javaתΪjson + str = json.toString();// jsonתΪַ + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("JSON =>" + str); + return str; + } + + public static void grantReadPrivilege(TCSession tcSession, TCComponent tccomponent) { + AbstractAIFApplication app; + app = AIFUtility.getCurrentApplication(); + TCSession session; + session = (TCSession) app.getSession(); + TCPreferenceService preferenceService; + preferenceService = session.getPreferenceService(); + String account = preferenceService.getStringValue("Autocode_PriverUser_ID"); + try { + openByPass(tcSession); + TCAccessControlService accessControlService = tcSession.getTCAccessControlService(); + TCComponentUserType type = (TCComponentUserType) tcSession.getTypeComponent("User"); + TCComponentUser user = type.find(account); + + if (user == null) { + return; + } + if (tcSession.getUser().equals(user)) { + return; + } + + String[] as2 = new String[] { "READ" }; + + if (tccomponent instanceof TCComponentItemRevision) { + TCComponentItem tempItem = ((TCComponentItemRevision) tccomponent).getItem(); + accessControlService.grantPrivilege(tempItem, user, as2); + accessControlService.grantPrivilege(tccomponent, user, as2); + } else { + accessControlService.grantPrivilege(tccomponent, user, as2); + } + } catch (TCException e) { + e.printStackTrace(); + }finally { + try { + closeByPass(tcSession); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + public static void grantWritePrivilege(TCSession tcSession, TCComponent tccomponent) { + AbstractAIFApplication app; + app = AIFUtility.getCurrentApplication(); + TCSession session; + session = (TCSession) app.getSession(); + TCPreferenceService preferenceService; + preferenceService = session.getPreferenceService(); + String account = preferenceService.getStringValue("Autocode_PriverUser_ID"); + try { + setByPass(true, tcSession); + TCAccessControlService accessControlService = tcSession.getTCAccessControlService(); + TCComponentUserType type = (TCComponentUserType) tcSession.getTypeComponent("User"); + + TCComponentUser user = type.find(account); + if (user == null) { + return; + } + if (tcSession.getUser().equals(user)) { + return; + } + + String[] as2 = new String[] { "READ", "WRITE", "DELETE" }; + + if (tccomponent instanceof TCComponentItemRevision) { + TCComponentItem tempItem = ((TCComponentItemRevision) tccomponent).getItem(); + accessControlService.grantPrivilege(tempItem, user, as2); + accessControlService.grantPrivilege(tccomponent, user, as2); + } else { + accessControlService.grantPrivilege(tccomponent, user, as2); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + try { + setByPass(false, tcSession); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + public static void openByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = ""; + userservice.call("Connor_set_bypass", obj); + } + + public static void closeByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = ""; + userservice.call("Connor_close_bypass", obj); + +// session.getUserService().call("Connor_set_bypass", new Object[]{});//bypass +// session.getUserService().call("Connor_close_bypass", new Object[]{});//bypass + } + + public static void setByPass(boolean val, TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + if (userservice == null) { + userservice = session.getUserService(); + } + Object[] obj = new Object[1]; + obj[0] = "origin"; + if (val) { +// userservice.call("ORIGIN_set_bypass", obj); + userservice.call("Connor_set_bypass", obj); + } else { +// userservice.call("ORIGIN_close_bypass", obj); + userservice.call("Connor_close_bypass", obj); + } + } + +} diff --git a/src/com/connor/rb/plm/rb025/StringCreateUtil.java b/src/com/connor/rb/plm/rb025/StringCreateUtil.java new file mode 100644 index 0000000..e445f3e --- /dev/null +++ b/src/com/connor/rb/plm/rb025/StringCreateUtil.java @@ -0,0 +1,21 @@ +package com.connor.rb.plm.rb025; + +public class StringCreateUtil { + public static String createBlank(int num) { + StringBuilder sb = new StringBuilder(); + while (num > 0) { + sb.append(" "); + num--; + } + return sb.toString(); + } + + public static String createPoint(int num) { + StringBuilder sb = new StringBuilder(); + while (num > 0) { + sb.append("."); + num--; + } + return sb.toString(); + } +} diff --git a/src/com/connor/rb/plm/rb025/test.java b/src/com/connor/rb/plm/rb025/test.java new file mode 100644 index 0000000..5ab4fa3 --- /dev/null +++ b/src/com/connor/rb/plm/rb025/test.java @@ -0,0 +1,76 @@ + +package com.connor.rb.plm.rb025; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.swing.JFrame; + +public class test { + private static PrintWriter writer; + private static int aaa; + private static FileWriter fileWriter; + public static void main(String[] args) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HH-mm-ss-SSS"); + String dirsPath = "C:\\Session"; + + String filename = "EditClass"+ sdf.format(new Date()) +".txt"; + File login_file = new File(dirsPath,filename); + File path = new File(dirsPath); + if(!path.exists()) { + path.mkdirs(); + } + if(login_file.exists()) { + login_file.delete(); + } + try { + login_file.createNewFile(); + fileWriter = new FileWriter(login_file, true); + writer = new PrintWriter(fileWriter); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + JFrame frame = new JFrame("AutoComplete Test"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setSize(400, 300); + + JAutoCompleteComboBox comboBox = new JAutoCompleteComboBox( + new String[]{"Apple", "Banana", "Orange", "222"} + ); + + comboBox.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + try { + fileWriter = new FileWriter(login_file, true); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + writer = new PrintWriter(fileWriter); + // TODO Auto-generated method stub + writer.println(aaa++); + writer.flush(); + + writer.close(); + } + }); + + writer.println("asadf"); + writer.flush(); + + writer.close(); + frame.add(comboBox); + + frame.setVisible(true); + } +} diff --git a/src/com/connor/rb/plm/rb026/ClassAttributeBean.java b/src/com/connor/rb/plm/rb026/ClassAttributeBean.java new file mode 100644 index 0000000..c160336 --- /dev/null +++ b/src/com/connor/rb/plm/rb026/ClassAttributeBean.java @@ -0,0 +1,56 @@ +package com.connor.rb.plm.rb026; + +import java.util.Map; + +public class ClassAttributeBean { + private int id;//id + private String name;// + private boolean islov;//Ƿlov + private int type;// + private Map lov;//lovʾֵ(key),ʵֵ(val) + private String val;//ֵ + + public String getVal() { + return val; + } + public void setVal(String val) { + this.val = val; + } + public int getId() { + return id; + } + public void setId(int id) { + this.id = id; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public boolean isIslov() { + return islov; + } + public void setIslov(boolean islov) { + this.islov = islov; + } + public int getType() { + return type; + } + public void setType(int type) { + this.type = type; + } + + public Map getLov() { + return lov; + } + public void setLov(Map lov) { + this.lov = lov; + } + @Override + public String toString() { + return "ClassAttributeBean [id=" + id + ", name=" + name + ", islov=" + + islov + ", type=" + type + "]"; + } + +} diff --git a/src/com/connor/rb/plm/rb026/DbPool.java b/src/com/connor/rb/plm/rb026/DbPool.java new file mode 100644 index 0000000..e50c2e5 --- /dev/null +++ b/src/com/connor/rb/plm/rb026/DbPool.java @@ -0,0 +1,211 @@ +package com.connor.rb.plm.rb026; + +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.Locale; +import java.util.Properties; + +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +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(TCSession session) { + if (instance == null) { + instance = new DbPool(); + } + return instance._getConnection(session); + } + + private Connection _getConnection(TCSession session) { + try { + TCPreferenceService service = session.getPreferenceService(); + String[] array = service.getStringArray(TCPreferenceService.TC_preference_site, "TC12_Oracle_MSG"); + String driver_temp = null; + String url = null; + String dbName = null; + String dbPassword = null; + if (array != null) + for (String str : array) { + System.out.println(" ORACLE = " + str); + if (str != null && str.startsWith("ORACEL_DRIVER=")) { + driver_temp = str.substring(str.indexOf("=") + 1, str.length()); + } else if (str != null && str.startsWith("ORACEL_URL=")) { + url = str.substring(str.indexOf("=") + 1, str.length()); + } else if (str != null && str.startsWith("ORACEL_NAME=")) { + dbName = str.substring(str.indexOf("=") + 1, str.length()); + } else if (str != null && str.startsWith("ORACEL_PASSWORD=")) { + dbPassword = str.substring(str.indexOf("=") + 1, str.length()); + } + } + + if (driver_temp == null || url == null || dbName == null || dbPassword == null) { + Locale defaultLocale = Locale.getDefault(); + MessageBox.post("ѡTC12_Oracle_MSG", "ʾ", MessageBox.ERROR); + } + + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + return null; + // MessageBox.post("ORACEL CONNECT EXCEPTION + // \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + } + return connection; + } + + 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 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/rb/plm/rb026/InstallData.java b/src/com/connor/rb/plm/rb026/InstallData.java new file mode 100644 index 0000000..c3f941c --- /dev/null +++ b/src/com/connor/rb/plm/rb026/InstallData.java @@ -0,0 +1,38 @@ +package com.connor.rb.plm.rb026; + +public class InstallData { + protected String m_name; + protected int m_size; + protected boolean m_selected; + + public InstallData(String name, int size) { + m_name = name; + m_size = size; + m_selected = false; + } + + public String getName() { + return m_name; + } + + public int getSize() { + return m_size; + } + + public void setSelected(boolean selected) { + m_selected = selected; + } + + public void invertSelected() { + m_selected = !m_selected; + } + + public boolean isSelected() { + return m_selected; + } + + public String toString() { +// return m_name + " (" + m_size + " K)"; + return m_name; + } +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/rb026/KUtil.java b/src/com/connor/rb/plm/rb026/KUtil.java new file mode 100644 index 0000000..944c290 --- /dev/null +++ b/src/com/connor/rb/plm/rb026/KUtil.java @@ -0,0 +1,24 @@ +package com.connor.rb.plm.rb026; + +import java.awt.Window; + +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class KUtil { + public static void info(Window dialog, String msg) { + MessageBox.post(dialog, msg, "", MessageBox.INFORMATION); + } + + public static String[] getPrefVals(TCSession session, String prefName) throws Exception { + if (KUtil.isEmpty(prefName)) { + return null; + } + return session.getPreferenceService().getStringValues(prefName); + } + + public static boolean isEmpty(String str) { + return str == null || "".equals(str.trim()); + } + +} diff --git a/src/com/connor/rb/plm/rb026/MyJList.java b/src/com/connor/rb/plm/rb026/MyJList.java new file mode 100644 index 0000000..b09087a --- /dev/null +++ b/src/com/connor/rb/plm/rb026/MyJList.java @@ -0,0 +1,163 @@ +package com.connor.rb.plm.rb026; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; + +import javax.swing.JCheckBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListCellRenderer; +import javax.swing.ListModel; +import javax.swing.ListSelectionModel; +import javax.swing.UIManager; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; +import javax.swing.border.EtchedBorder; +import javax.swing.border.TitledBorder; + +public class MyJList extends JFrame { + + protected JList m_list; + protected JLabel m_total; + + public MyJList() { + super("Swing List [Check boxes]"); + setSize(260, 240); + getContentPane().setLayout(new FlowLayout()); + + InstallData[] options = { new InstallData("Program executable", 118), new InstallData("Help files", 52), + new InstallData("Tools and converters", 83), new InstallData("Source code", 133) }; + + m_list = new JList(options); + CheckListCellRenderer renderer = new CheckListCellRenderer(); + m_list.setCellRenderer(renderer); + m_list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + CheckListener lst = new CheckListener(this); + m_list.addMouseListener(lst); + m_list.addKeyListener(lst); + + JScrollPane ps = new JScrollPane(); + ps.getViewport().add(m_list); + + m_total = new JLabel("Space required: 0K"); + + JPanel p = new JPanel(); + p.setLayout(new BorderLayout()); + p.add(ps, BorderLayout.CENTER); + p.add(m_total, BorderLayout.SOUTH); + p.setBorder(new TitledBorder(new EtchedBorder(), "Please select options:")); + getContentPane().add(p); + + WindowListener wndCloser = new WindowAdapter() { + public void windowClosing(WindowEvent e) { + System.exit(0); + } + }; + addWindowListener(wndCloser); + + setVisible(true); + + recalcTotal(); + } + + public void recalcTotal() { + ListModel model = m_list.getModel(); + int total = 0; + for (int k = 0; k < model.getSize(); k++) { + InstallData data = (InstallData) model.getElementAt(k); + if (data.isSelected()) + total += data.getSize(); + } + m_total.setText("Space required: " + total + "K"); + } + + public static void main(String argv[]) { + new MyJList(); + } +} + +class CheckListCellRenderer extends JCheckBox implements ListCellRenderer { + protected static Border m_noFocusBorder = new EmptyBorder(1, 1, 1, 1); + + public CheckListCellRenderer() { + super(); + setOpaque(true); + setBorder(m_noFocusBorder); + } + + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, + boolean cellHasFocus) { + setText(value.toString()); + + setBackground(isSelected ? list.getSelectionBackground() : list.getBackground()); + setForeground(isSelected ? list.getSelectionForeground() : list.getForeground()); + + InstallData data = (InstallData) value; + setSelected(data.isSelected()); + + setFont(list.getFont()); + setBorder((cellHasFocus) ? UIManager.getBorder("List.focusCellHighlightBorder") : m_noFocusBorder); + + return this; + } +} + +class CheckListener implements MouseListener, KeyListener { + protected MyJList m_parent; + protected JList m_list; + + public CheckListener(MyJList parent) { + m_parent = parent; + m_list = parent.m_list; + } + + public void mouseClicked(MouseEvent e) { + if (e.getX() < 20) + doCheck(); + } + + public void mousePressed(MouseEvent e) { + } + + public void mouseReleased(MouseEvent e) { + } + + public void mouseEntered(MouseEvent e) { + } + + public void mouseExited(MouseEvent e) { + } + + public void keyPressed(KeyEvent e) { + if (e.getKeyChar() == ' ') + doCheck(); + } + + public void keyTyped(KeyEvent e) { + } + + public void keyReleased(KeyEvent e) { + } + + protected void doCheck() { + int index = m_list.getSelectedIndex(); + if (index < 0) + return; + InstallData data = (InstallData) m_list.getModel().getElementAt(index); + data.invertSelected(); + m_list.repaint(); + m_parent.recalcTotal(); + } +} diff --git a/src/com/connor/rb/plm/rb026/Rb026Dialog.java b/src/com/connor/rb/plm/rb026/Rb026Dialog.java new file mode 100644 index 0000000..430a0a0 --- /dev/null +++ b/src/com/connor/rb/plm/rb026/Rb026Dialog.java @@ -0,0 +1,762 @@ +package com.connor.rb.plm.rb026; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.FileOutputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListCellRenderer; +import javax.swing.ListSelectionModel; +import javax.swing.SwingUtilities; +import javax.swing.border.EmptyBorder; + +import org.apache.commons.lang.StringUtils; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.MessageBox; + +import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicBoolean; + +import javax.swing.SwingWorker; + +public class Rb026Dialog extends AbstractAIFOperation { + + // UI Components + private JButton okButton, cancelButton; + private JList propList; + private JLabel statusLabel; + private JCheckBox selectAllCheckBox; + + // Data + private List items; + private List revs; + private List> dataQueue; + private List allprops; + private String[] propConfigs; + private ArrayList idList; + private static String type = ""; + private List itemProList = new ArrayList(); + private List disItemProList = new ArrayList(); + private List revProList = new ArrayList(); + private List disRevProList = new ArrayList(); + + // Thread Control + private ExecutorService executor; + private CountDownLatch latch; + private AtomicBoolean processing; + private AbstractAIFApplication app; + private JFrame jFrame; + private static TCSession session; + private Map> writeTOMap; + private List header = null; + + public Rb026Dialog(AbstractAIFApplication app) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + initialize(app); + } + + /** + * һµʵ Rb026Dialog + * + * @param session2 + * @param selectedIds + */ + public Rb026Dialog(TCSession session2, ArrayList selectedIds) { + // TODO Auto-generated constructor stub + super(false); + this.session = session2; + this.idList = idList; + initialize(app); + } + + /** + * + * @Title: initialize @Description: ʼ @param @param app @return void + * @throws + */ + private void initialize(AbstractAIFApplication app) { + this.executor = Executors.newSingleThreadExecutor(); + this.dataQueue = new ArrayList<>(); + this.processing = new AtomicBoolean(false); + jFrame = new JFrame(); + jFrame.setTitle(""); + jFrame.setPreferredSize(new Dimension(600, 400)); + jFrame.setLayout(new BorderLayout(5, 5)); + + jFrame.add(initPropPanel(), BorderLayout.CENTER); + jFrame.add(initButtonPanel(), BorderLayout.SOUTH); + jFrame.setResizable(true); + jFrame.pack(); + jFrame.setLocationRelativeTo(null); + } + + /* + * Title: executeOperation Description: + * + * @throws Exception + * + * @see com.teamcenter.rac.aif.AbstractAIFOperation#executeOperation() + */ + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + try { + if (idList != null) { + List itemList = new ArrayList<>(); + List revList = new ArrayList<>(); + if (idList.isEmpty()) { + MessageBox.post(null, "ѡж󵼳", MessageBox.INFORMATION); + return; + } + + // ȡ֤ + for (String id : idList) { + TCComponentItem item = (TCComponentItem) getItemById(id); + if (item == null) + continue; // Ч + + if (type == null) { + type = item.getType(); // õһ + } + itemList.add(item); + revList.add(item.getLatestItemRevision()); + } + + items = itemList; // ֱʹ֤itemList + revs = revList; // ֱʹ֤itemList + } else { + items = new ArrayList<>(); + revs = new ArrayList<>(); + + InterfaceAIFComponent[] targets = app.getTargetComponents(); + if (targets == null || targets.length == 0) { + showMessage("ѡж󵼳"); + return; + } + List selectItemList = new ArrayList<>(); + List errorList = new ArrayList<>(); + // ֤һ + + for(InterfaceAIFComponent target:targets) { + + TCComponentItem item=null; + + if ((target instanceof TCComponentItem)) { + item=((TCComponentItem)target); + + }else if(target instanceof TCComponentItemRevision) { + item = ((TCComponentItemRevision)target).getItem(); + + }else { + errorList.add(target); + continue; + } + if(StringUtils.isEmpty(type)) { + type=item.getType(); + }else { + String type1 = item.getType(); + if (!type1.equals(type)) { + showMessage("Ͳһ£"); + return; + } + } + selectItemList.add(item); + } + if(errorList.size()>0) { + StringBuilder stringBuilder = new StringBuilder("ѡǶ߰汾޷").append("\n"); + for(InterfaceAIFComponent target:errorList) { + stringBuilder.append("[").append(target).append("] "); + } + showMessage(stringBuilder.toString()); + return; + } +// if (!(targets[0] instanceof TCComponentItem)) { +// +// showMessage("ѡItemͣ"); +// return; +// } + + +// if (!(targets[0] instanceof TCComponentItem)) { +// showMessage("ѡItemͣ"); +// return; +// } + + // ȡ + TCProperty[][] props = TCComponentType.getTCPropertiesSet( + selectItemList, + new String[] {"revision_list","object_type"}); + for (int i = 0; i < selectItemList.size(); i++) { + + TCComponent[] referenceValueArray = props[i][0].getReferenceValueArray(); + items.add(selectItemList.get(i)); + revs.add(((TCComponentItemRevision)referenceValueArray[referenceValueArray.length-1])); + + } + + } + + if (items.isEmpty()) + return; + + // ѡ + propConfigs = session.getPreferenceService().getStringValues("Rb_Config_Export_Props"); + //propConfigs = KUtil.getPrefVals(session, "Rb_Config_Export_Props"); + if (propConfigs == null || propConfigs.length == 0) { + showMessage("ѡ[Rb_Config_Export_Props]"); + return; + } + + // + for (String propConfig : propConfigs) { + String[] parts = propConfig.split("="); + if (parts.length == 2 && parts[0].equals(type)) { + allprops = Arrays.asList(parts[1].split(",")); + break; + } + } + + if (allprops == null || allprops.isEmpty()) { + showMessage("δҵƥã"); + return; + } + jFrame.setVisible(true); + startBackgroundProcessing(); + } catch (Exception e) { + e.printStackTrace(); + handleError("ʼʧ", e); + } + + } + + // ޸ startBackgroundProcessing + private void startBackgroundProcessing() { + processing.set(true); + int totalItems = items.size(); // ԭʼ + latch = new CountDownLatch(totalItems); + + // һ + processFirstItem(items.get(0)); + + //ݿѯ... + updateStatus("ݿѯ..."); + String ClassID; + try { + ClassID = revs.get(0).getClassificationClass();//ȡid + Object[] writeTOMap2 = TestOperation.writeTOMap(session, ClassID); + header = (List) writeTOMap2[0]; + writeTOMap = (Map>) writeTOMap2[1]; +// System.out.println("map:"+writeTOMap); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + executor.execute(() -> { + if (!items.isEmpty()) { + processBatchAsync(items, revs, totalItems); + } + processing.set(false); + updateStatus("׼ɣ " + totalItems + " ¼"); + }); + } + + /** + * + * @Title: processFirstItem @Description: һ @param @param item @return + * void @throws + */ + private void processFirstItem(TCComponentItem item) { + try { + LinkedHashMap data = processItem(item); + dataQueue.add(data); + updatePropList(); + latch.countDown(); + } catch (Exception e) { + handleError("ʧ", e); + } + } + + /** + * + * @Title: processItemAsync @Description: ̬ˢ´ @param @param item + * @return void @throws + */ + private void processBatchAsync(List itemsBatch, List revsBatch, + int totalItems) { + dataQueue.clear(); + try { + TCProperty[][] prop = TCComponentType.getTCPropertiesSet(revsBatch, + new String[] {"item_id","item_revision_id"}); + + // ȡ + TCProperty[][] itemProps = TCComponentType.getTCPropertiesSet(itemsBatch, + itemProList.toArray(new String[0])); + TCProperty[][] revProps = TCComponentType.getTCPropertiesSet(revsBatch, revProList.toArray(new String[0])); + + // ÿ1%ӦĴ⸡㣩 + int lastReportedPercent = 0; + + for (int i = 0; i < itemsBatch.size(); i++) { + LinkedHashMap map = new LinkedHashMap<>(); + + // ԣԭ߼䣩 + for (int j = 0; j < itemProList.size(); j++) { + map.put(disItemProList.get(j), itemProps[i][j].getDisplayableValue()); + } + for (int j = 0; j < revProList.size(); j++) { + map.put(disRevProList.get(j), revProps[i][j].getDisplayableValue()); + } + String key = prop[i][0].getDisplayableValue()+"/"+prop[i][1].getDisplayableValue(); + System.out.println("key:"+key); + if(writeTOMap.containsKey(key)) { + // ȡӦ value б + List valueList = writeTOMap.get(key); + System.out.println(valueList); + // ͷͱһӦ뵽µ map + for (int j = 0; j < header.size(); j++) { + String headerKey = header.get(j); + String value = valueList.get(j); + if(value == null) { + value = ""; + } + map.put("ԣ"+headerKey, value); + } + } + //addClassificationProperties(revsBatch.get(i), map); + dataQueue.add(map); + + // 㵱ǰȣ⸡ + int currentProcessed = 1 + i; // һ+ǰ + int currentPercent = (currentProcessed * 100) / totalItems; + + // ٷֱʱ״̬ + if (currentPercent > lastReportedPercent) { + updateStatus("Ѽ " + currentPercent + "%"); + lastReportedPercent = currentPercent; + } + + latch.countDown(); + } + + // ǿ100%ֹضϵµδ + if (lastReportedPercent < 100) { + updateStatus("Ѽ 100%"); + } + } catch (Exception e) { + handleError("ʧ", e); + } + } + + private LinkedHashMap processItem(TCComponentItem item) throws Exception { + TCComponentItemRevision rev = item.getLatestItemRevision(); + LinkedHashMap map = new LinkedHashMap<>(); + // ȡԷ + + for (String prop : allprops) { + System.out.println("prop:"+prop); + String[] parts = prop.split("\\."); + if (parts.length != 3) + continue; + + if ("ITEM".equals(parts[0])) { + itemProList.add(parts[1]); + disItemProList.add(parts[2]); + } else { + revProList.add(parts[1]); + disRevProList.add(parts[2]); + } + } + for (String prop : allprops) { + String[] parts = prop.split("\\."); + if (parts.length != 3) + continue; + + TCComponent target = "ITEM".equals(parts[0]) ? item : rev; + String value = target.getProperty(parts[1]); + map.put(parts[2], value); + } + + addClassificationProperties(rev, map); + return map; + } + + private void addClassificationProperties(TCComponentItemRevision rev, Map map) throws TCException { + TCComponentICO[] classObjects = rev.getClassificationObjects(); + if (classObjects != null && classObjects.length > 0) { + TCComponentICO ico = classObjects[0]; + ICSProperty[] props = ico.getICSProperties(true); + ICSPropertyDescription[] descs = ico.getICSPropertyDescriptors(); + for (int i = 0; i < props.length; i++) { + String propName = descs[i].getName(); + String propValue = props[i].getValue(); + map.put("ԣ" + propName, propValue); + } + } + } + + private JPanel initPropPanel() { + JPanel panel = new JPanel(new BorderLayout(5, 5)); + + statusLabel = new JLabel("׼..."); + panel.add(statusLabel, BorderLayout.NORTH); + + propList = new JList<>(); + propList.setCellRenderer(new CheckListCellRenderer()); + propList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); // ޸ѡģʽ + + // + propList.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + int index = propList.locationToIndex(e.getPoint()); + if (index >= 0) { + InstallData data = propList.getModel().getElementAt(index); + data.setSelected(!data.isSelected()); + propList.repaint(); + } + } + }); + + panel.add(new JScrollPane(propList), BorderLayout.CENTER); + + selectAllCheckBox = new JCheckBox("ȫѡ/ȡ"); + selectAllCheckBox.addActionListener(e -> { + boolean selected = selectAllCheckBox.isSelected(); + for (int i = 0; i < propList.getModel().getSize(); i++) { + InstallData data = propList.getModel().getElementAt(i); + data.setSelected(selected); + } + propList.repaint(); + }); + + JPanel rightPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5)); + rightPanel.add(selectAllCheckBox); + panel.add(rightPanel, BorderLayout.EAST); + + return panel; + } + + private void updatePropList() { + if (!dataQueue.isEmpty()) { + LinkedHashMap first = dataQueue.get(0); // ʹ get(0) ȡһԪ + List data = first.keySet().stream().map(InstallData::new).collect(Collectors.toList()); + propList.setListData(data.toArray(new InstallData[0])); + } + } + + private JPanel initButtonPanel() { + JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 15, 5)); + + okButton = new JButton("ȷ"); + okButton.setPreferredSize(new Dimension(100, 25)); + okButton.addActionListener(e -> exportData()); + + cancelButton = new JButton("ȡ"); + cancelButton.setPreferredSize(new Dimension(100, 25)); + cancelButton.addActionListener(e -> jFrame.dispose()); + + panel.add(okButton); + panel.add(cancelButton); + + return panel; + } + + private void exportData() { + okButton.setEnabled(false); + okButton.setText("..."); + + new SwingWorker() { + @Override + protected Void doInBackground() throws Exception { + try { + if (!latch.await(2, TimeUnit.MINUTES)) { + throw new TimeoutException("׼ʱ"); + } + + List selected = getSelectedProperties(); + if (selected.isEmpty()) { + throw new IllegalArgumentException("ѡҪԣ"); + } + + File file = chooseFile(); + if (file == null) + return null; + + try { + Workbook workbook = new XSSFWorkbook(); + FileOutputStream fos = new FileOutputStream(file); + Sheet sheet = workbook.createSheet(""); + createHeaderRow(sheet, selected); + createDataRows(sheet, selected); + workbook.write(fos); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + } catch (CancellationException e) { + // ûȡʾκʾ + return null; + } + return null; + } + + @Override + protected void done() { + try { + get(); // Ƿɹ + showMessage("ɹ"); + } catch (CancellationException e) { + // ûȡʾκʾ + // ¼־ѡ + System.out.println("ûȡ˵"); + } catch (Exception e) { + // 쳣 + handleError("ʧ", e); + } finally { + // ָť״̬ + okButton.setEnabled(true); + okButton.setText("ȷ"); + } + } + }.execute(); + } + + /** + * + * @Title: getItemById @Description: idòѯض @param @param + * id @param @return @return TCComponent @throws + */ + public static TCComponent getItemById(String id) { + + try { + System.out.println("ûĿ" + getText(session, "ItemID")); + // òѯ + String[] keys = new String[] { getText(session, "ItemID") }; + // òѯidֵ + String[] values = new String[] { id }; + List comps = queryObject("...", keys, values); + if (comps != null || comps.size() > 0) { + return comps.get(0); + } else { + MessageBox.post("ѡûвѯ", "", MessageBox.ERROR); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + + /** + * + * @Title: queryObject @Description: òѯ @param @param + * queryName @param @param keys @param @param values @param @return + * @return List @throws + */ + public static List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + MessageBox.post("ûвѯ", "", MessageBox.ERROR); + return null; + } + } + + /** + * + * @Title: getText @Description: ȡûĿֵ @param @param session @param @param + * str @param @return @param @throws Exception @return String + * @throws + */ + 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; + } + } + + /** + * + * @Title: isEmpty @Description: жǷΪ @param @param str @param @return + * @return boolean @throws + */ + public static boolean isEmpty(String str) { + return str == null || "".equals(str.trim()); + } + + private List getSelectedProperties() { + List selected = new ArrayList<>(); + for (int i = 0; i < propList.getModel().getSize(); i++) { + InstallData data = propList.getModel().getElementAt(i); + if (data.isSelected()) { + selected.add(data.getName()); + } + } + return selected; + } + + private File chooseFile() throws CancellationException { + JFileChooser chooser = new JFileChooser(); + chooser.setDialogTitle("ļ"); + chooser.setSelectedFile(new File("export.xlsx")); + + int result = chooser.showSaveDialog(jFrame); + if (result == JFileChooser.APPROVE_OPTION) { + File file = chooser.getSelectedFile(); + if (!file.getName().endsWith(".xlsx")) { + file = new File(file.getAbsolutePath() + ".xlsx"); + } + if (file.exists()) { + int confirm = JOptionPane.showConfirmDialog(jFrame, "ļѴڣǷ񸲸ǣ", "ȷ", JOptionPane.YES_NO_OPTION); + if (confirm != JOptionPane.YES_OPTION) { + throw new CancellationException("ûȡ"); + } + } + return file; + } + throw new CancellationException("ûȡ"); + } + + private void createHeaderRow(Sheet sheet, List headers) { + Row headerRow = sheet.createRow(0); + for (int i = 0; i < headers.size(); i++) { + headerRow.createCell(i).setCellValue(headers.get(i)); + } + } + + private void createDataRows(Sheet sheet, List columns) { + int rowNum = 1; + for (LinkedHashMap data : dataQueue) { + Row row = sheet.createRow(rowNum++); + for (int i = 0; i < columns.size(); i++) { + row.createCell(i).setCellValue(data.getOrDefault(columns.get(i), "")); + } + } + } + + private void updateStatus(String message) { + + SwingUtilities.invokeLater(() -> statusLabel.setText(message)); + } + + private void showMessage(String message) { + MessageBox.post(message, "ʾ", MessageBox.INFORMATION); + } + + private void handleError(String message, Exception e) { + MessageBox.post(message, "", MessageBox.ERROR); + + } + + private static class InstallData { + private final String name; + private boolean selected; + + public InstallData(String name) { + this.name = name; + this.selected = true; + } + + public String getName() { + return name; + } + + public boolean isSelected() { + return selected; + } + + public void setSelected(boolean selected) { + this.selected = selected; + } + + public void invertSelected() { + this.selected = !this.selected; + } + + @Override + public String toString() { + return name; + } + } + + private static class CheckListCellRenderer extends JCheckBox implements ListCellRenderer { + public CheckListCellRenderer() { + setOpaque(true); + setBorder(new EmptyBorder(1, 1, 1, 1)); + } + + @Override + public Component getListCellRendererComponent(JList list, InstallData value, int index, + boolean isSelected, boolean cellHasFocus) { + setText(value.toString()); + setSelected(value.isSelected()); + setBackground(isSelected ? list.getSelectionBackground() : list.getBackground()); + setForeground(isSelected ? list.getSelectionForeground() : list.getForeground()); + setFont(list.getFont()); + return this; + } + } + +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/rb026/Rb026Dialog2.java b/src/com/connor/rb/plm/rb026/Rb026Dialog2.java new file mode 100644 index 0000000..1f1bf39 --- /dev/null +++ b/src/com/connor/rb/plm/rb026/Rb026Dialog2.java @@ -0,0 +1,545 @@ +package com.connor.rb.plm.rb026; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JFileChooser; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListCellRenderer; +import javax.swing.ListSelectionModel; +import javax.swing.UIManager; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; +import javax.swing.filechooser.FileSystemView; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.aspose.cad.internal.ay.iF; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.MessageBox; + +@SuppressWarnings("serial") +public class Rb026Dialog2 extends AbstractAIFDialog { + + private AbstractAIFApplication app; + private static TCSession session; + private InterfaceAIFComponent[] targets; + private String props; + private JButton okButton; + private JButton cannelButton; + @SuppressWarnings("rawtypes") + protected JList jList; + private ArrayList> list; + private ArrayList idList; + private ArrayList itemList = new ArrayList();; + + public Rb026Dialog2(AbstractAIFApplication app) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + } + + public Rb026Dialog2(TCSession session,ArrayList idList) { + this.session = session; + this.idList = idList; + } + + @Override + public void run() { + try { + if (!init()) { + return; + } + initUI(); + addListeners(); + showDialog(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void addListeners() { + this.okButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + List selected = getSelectedProp(); + if (selected == null || selected.size() < 1) { + KUtil.info(Rb026Dialog2.this, "ѡҪԣ"); + return; + } + File file = getFile(); + if (file == null) { + return; + } + + try { + Workbook workBook = getworkbook(); + Sheet sheet = workBook.getSheetAt(0); + // + Row row0 = sheet.createRow(0); + for (int i = 0; i < selected.size(); i++) { + Cell cell = row0.createCell(i); + cell.setCellValue(selected.get(i)); + } + + for (int i = 0; i < list.size(); i++) { + Row row = sheet.createRow(i + 1); + for (int j = 0; j < selected.size(); j++) { + Cell cell = row.createCell(j); + cell.setCellValue(list.get(i).get(selected.get(j))); + } + } + + FileOutputStream fileOutputStream = new FileOutputStream(file); + workBook.write(fileOutputStream); + fileOutputStream.close(); + KUtil.info(Rb026Dialog2.this, "ɹ"); + disposeDialog(); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + }); + this.cannelButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + this.jList.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + super.mouseClicked(e); + int index = jList.getSelectedIndex(); + if (index < 0) + return; + InstallData data = (InstallData) jList.getModel().getElementAt(index); + data.invertSelected(); + jList.repaint(); + } + }); + } + + private List getSelectedProp() { + int size = jList.getModel().getSize(); + List list = new ArrayList(); + for (int i = 0; i < size; i++) { + InstallData data = (InstallData) jList.getModel().getElementAt(i); + if (data.isSelected()) { + list.add(data.getName()); + } + } + return list; + } + + private Workbook getworkbook() throws IOException { + Workbook workbook = new XSSFWorkbook(); + workbook.createSheet("sheet1"); + return workbook; + } + + private void initUI() { + this.setTitle(""); + Dimension dim = new Dimension(400, 300); + this.setPreferredSize(new Dimension(512, 320)); + this.setMinimumSize(dim); + this.setLayout(new BorderLayout()); + this.add(BorderLayout.CENTER, initPropPanel()); + this.add(BorderLayout.SOUTH, initBtnPanel()); + } + + private Component initBtnPanel() { + JPanel btnPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 15, 5)); + okButton = new JButton("ȷ"); + cannelButton = new JButton("ȡ"); + Dimension dim = new Dimension(100, 25); + okButton.setPreferredSize(dim); + cannelButton.setPreferredSize(dim); + btnPanel.add(okButton); + btnPanel.add(cannelButton); + return btnPanel; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + private Component initPropPanel() { + JPanel panel = new JPanel(new BorderLayout()); + + // ȡʾlist + ArrayList datas = new ArrayList<>(); + for (String name : list.get(0).keySet()) { + InstallData installData = new InstallData(name, 0); + datas.add(installData); + } + + jList = new JList(datas.toArray(new InstallData[] {})); + CheckListCellRenderer renderer = new CheckListCellRenderer(); + jList.setCellRenderer(renderer); + jList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + JScrollPane jsp = new JScrollPane(); + jsp.getViewport().add(jList); + panel.add(BorderLayout.CENTER, jsp); + + // ȫѡ/ȡѡ + JPanel rightPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5)); + JCheckBox selectAllCheckBox = new JCheckBox("ȫѡ/ȡ"); + selectAllCheckBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + boolean isSelected = selectAllCheckBox.isSelected(); + for (int i = 0; i < jList.getModel().getSize(); i++) { + InstallData data = (InstallData) jList.getModel().getElementAt(i); + data.setSelected(isSelected); + } + jList.repaint(); + } + }); + rightPanel.add(selectAllCheckBox); + + panel.add(BorderLayout.EAST, rightPanel); + + panel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); + return panel; + } + + private File getFile() { + JFileChooser jf = new JFileChooser(); + String name = "ExcelName.xlsx"; + jf.setDialogTitle("ļ" + name + "..."); + FileSystemView fileSystemView = FileSystemView.getFileSystemView(); + String homePath = fileSystemView.getHomeDirectory().getPath(); + jf.setCurrentDirectory(new File(homePath)); + jf.setSelectedFile(new File(name)); + boolean flag = false; + do { + int showOpenDialog = jf.showDialog(this, ""); + if (showOpenDialog == JFileChooser.APPROVE_OPTION) { + File file = new File(jf.getSelectedFile().getAbsolutePath()); + if (file.exists()) { + if (!file.getName().endsWith(".xlsx")) { + KUtil.info(this, "ʧܣļҪ\".xlsx\"β"); + return null; + } + int yesOrNo = JOptionPane.showConfirmDialog(this, "ļѴڣҪ", "ļ", + JOptionPane.YES_NO_OPTION); + if (yesOrNo == 0) { + // 0 + return file; + } else { + // 1 + flag = true; + } + } else { + return file; + } + } else { + return null; + } + } while (flag); + return null; + } + /** + * + * @Title: getItemById + * @Description: idòѯض + * @param @param id + * @param @return + * @return TCComponent + * @throws + */ + public static TCComponent getItemById(String id) { + + try { + System.out.println("ûĿ" + getText(session, "ItemID")); + // òѯ + String[] keys = new String[] { getText(session, "ItemID") }; + // òѯidֵ + String[] values = new String[] { id }; + List comps = queryObject("...", keys, values); + if (comps != null || comps.size() > 0) { + return comps.get(0); + } else { + MessageBox.post("ѡûвѯ", "", MessageBox.ERROR); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + + /** + * + * @Title: queryObject + * @Description: òѯ + * @param @param queryName + * @param @param keys + * @param @param values + * @param @return + * @return List + * @throws + */ + public static List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + MessageBox.post("ûвѯ", "", MessageBox.ERROR); + return null; + } + } + + /** + * + * @Title: getText + * @Description: ȡûĿֵ + * @param @param session + * @param @param str + * @param @return + * @param @throws Exception + * @return String + * @throws + */ + 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; + } + } + + /** + * + * @Title: isEmpty + * @Description: жǷΪ + * @param @param str + * @param @return + * @return boolean + * @throws + */ + public static boolean isEmpty(String str) { + return str == null || "".equals(str.trim()); + } + + private boolean init() throws Exception { + String type = ""; + if(this.idList != null) { + if(idList.size() == 0) { + KUtil.info(this, "ѡж󵼳"); + return false; + } + + for(String id : idList) { + TCComponentItem item = (TCComponentItem)getItemById(id); + type = item.getType(); + itemList.add(item); + } + }else { + targets = app.getTargetComponents(); + if (targets == null || targets.length == 0) { + KUtil.info(this, "ѡж󵼳"); + return false; + } + // ж϶Ƿͬһ + type = targets[0].getType(); + for (InterfaceAIFComponent target : targets) { + TCComponent comp = (TCComponent) target; + if (!comp.getType().equals(type)) { + KUtil.info(this, "Ͳһ£"); + return false; + } + if (!(comp instanceof TCComponentItem)) { + KUtil.info(this, "ѡItemͣ"); + return false; + } + } + } + + + + String[] propConfigs = KUtil.getPrefVals(session, "Rb_Config_Export_Props"); + if (propConfigs == null || propConfigs.length == 0) { + KUtil.info(this, "1ѡ[Rb_Config_Export_Props]"); + return false; + } + for (String propConfig : propConfigs) { + String[] column1 = propConfig.split("="); + if (column1.length != 2) { + KUtil.info(this, "2ѡ[Rb_Config_Export_Props]"); + return false; + } + if (column1[0].equals(type)) { + props = column1[1]; + break; + } + } + if (props == null || props.length() < 1) { + KUtil.info(this, "3ѡ[Rb_Config_Export_Props]"); + return false; + } + // ѡȡ + if (!getProp()) { + return false; + } + + return true; + } + + private boolean getProp() throws TCException { + String[] allprops = props.split(","); + if (allprops == null || allprops.length < 1) { + KUtil.info(this, "ѡ[Rb_Config_Export_Props]"); + return false; + } + + list = new ArrayList<>(); + List items; + if (idList != null) { + // idList Ϊգֱʹ itemList + items = itemList; + } else { + // 򣬽 targets תΪ TCComponentItem б + items = new ArrayList<>(); + for (InterfaceAIFComponent target : targets) { + items.add((TCComponentItem) target); + } + } + for (TCComponentItem item : items) { + TCComponentItemRevision rev = item.getLatestItemRevision(); + LinkedHashMap map = extractProperties(item, rev, allprops); + if (map == null) { + return false; // ǰأִ + } + + // ȡķ + addClassificationProperties(rev, map); + + list.add(map); + } + + if (list.isEmpty()) { + KUtil.info(this, "ûлȡԣ"); + return false; + } + + return true; + } + + /** + * ݸĶ޶汾ȡӳ䡣 + * @throws TCException + */ + private LinkedHashMap extractProperties(TCComponentItem item, TCComponentItemRevision rev, String[] allprops) throws TCException { + LinkedHashMap map = new LinkedHashMap<>(); + for (String allprop : allprops) { + String[] a_p = allprop.split("\\."); + if (a_p == null || a_p.length != 2) { + KUtil.info(this, "ѡ[Rb_Config_Export_Props]"); + return null; + } + String address = a_p[0]; + String realName = a_p[1]; + + switch (address) { + case "ITEM": + addProperty(map, item, realName, "item"); + break; + case "REV": + addProperty(map, rev, realName, "rev"); + break; + default: + KUtil.info(this, "ѡ[Rb_Config_Export_Props]"); + return null; + } + } + return map; + } + + /** + * ָ͵ԵӳС + * @throws TCException + */ + private void addProperty(LinkedHashMap map, TCComponent component, String propertyName, String type) throws TCException { + String name = component.getTCProperty(propertyName).getName(); + String value = component.getProperty(propertyName); + System.out.println(type + "" + name + " ֵ" + value); + map.put(name, value); + } + + /** + * ӷԵӳС + * @throws TCException + */ + private void addClassificationProperties(TCComponentItemRevision rev, LinkedHashMap map) throws TCException { + TCComponentICO[] classObjects = rev.getClassificationObjects(); + if (classObjects != null && classObjects.length > 0) { + TCComponentICO ico = classObjects[0]; + ICSProperty[] props = ico.getICSProperties(true); + ICSPropertyDescription[] descs = ico.getICSPropertyDescriptors(); + for (int i = 0; i < props.length; i++) { + ICSKeyLov keyLov = descs[i].getFormat().getKeyLov(); + String propName = descs[i].getName(); + String propValue = keyLov != null ? keyLov.getValueOfKey(props[i].getValue()) : props[i].getValue(); + System.out.println(propName + " , " + propValue); + map.put("ԣ" + propName, propValue); + } + } + } + +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/rb026/Rb026Dialog3.java b/src/com/connor/rb/plm/rb026/Rb026Dialog3.java new file mode 100644 index 0000000..284e89b --- /dev/null +++ b/src/com/connor/rb/plm/rb026/Rb026Dialog3.java @@ -0,0 +1,668 @@ +package com.connor.rb.plm.rb026; + +import java.awt.*; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.*; +import java.util.List; +import java.util.Map.Entry; +import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicBoolean; +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import javax.swing.filechooser.FileNameExtensionFilter; + +import com.alibaba.fastjson2.JSON; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.*; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.MessageBox; + +public class Rb026Dialog3 extends AbstractAIFOperation { + + // UI Components + private JFrame jFrame; + private JButton okButton, cancelButton; + private JList propList; + private JLabel statusLabel; + private JCheckBox selectAllCheckBox; + + // Data Collections + private final List itemUidList = new ArrayList<>(); + private final List revUidList = new ArrayList<>(); + private final List itemAttrList = new ArrayList<>(); + private final LinkedHashMap itemAttrMap = new LinkedHashMap<>(); + private final List revAttrList = new ArrayList<>(); + private final LinkedHashMap revAttrMap = new LinkedHashMap<>(); + private final List classAttrList = new ArrayList<>(); + private final LinkedHashMap classAttrMap = new LinkedHashMap<>(); + private ArrayList idList; // ԭidList + + // Thread Control + private ExecutorService executor; + private CountDownLatch latch; + private AtomicBoolean processing; + private static TCSession session; + private List items; + private List allprops; + private AbstractAIFApplication app; + + //prop ӳ + private Map propMap = new HashMap<>(); + + // 췽1ͨApplication + public Rb026Dialog3(AbstractAIFApplication app) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + initialize(); + } + + // 췽2ͨSessionIDб + public Rb026Dialog3(TCSession session, ArrayList selectedIds) { + super(false); + this.session = session; + this.idList = selectedIds; + initialize(); + } + + private void initialize() { + this.executor = Executors.newSingleThreadExecutor(); + this.processing = new AtomicBoolean(false); + + jFrame = new JFrame("ѡ"); + jFrame.setPreferredSize(new Dimension(600, 400)); + jFrame.setLayout(new BorderLayout(5, 5)); + + jFrame.add(initPropPanel(), BorderLayout.CENTER); + jFrame.add(initButtonPanel(), BorderLayout.SOUTH); + jFrame.pack(); + jFrame.setLocationRelativeTo(null); + } + + @Override + public void executeOperation() throws Exception { + try { + // ݹ췽ʽѡ߼ + if (idList != null && !idList.isEmpty()) { + loadItemsByIds(); + } else if (app != null) { + loadItemsFromSelection(); + } else { + MessageBox.post("δָЧԴ", "", MessageBox.ERROR); + return; + } + + if (items.isEmpty()) { + MessageBox.post("ѡһItem", "ʾ", MessageBox.INFORMATION); + return; + } + + // ѡ + String[] propConfigs = KUtil.getPrefVals(session, "RB_ExpoerExcelAttrConfig"); + if (propConfigs == null || propConfigs.length == 0) { + showMessage("ѡ[RB_ExpoerExcelAttrConfig]"); + return; + } + + // + String type = items.get(0).getType(); + for (String propConfig : propConfigs) { + String[] parts = propConfig.split("="); + if (parts.length == 2 && parts[0].equals(type)) { + allprops = Arrays.asList(parts[1].split(",")); + break; + } + } + + if (allprops == null || allprops.isEmpty()) { + showMessage("δҵƥã"); + return; + } + + startBackgroundProcessing(); + jFrame.setVisible(true); + } catch (Exception e) { + handleError("ʼʧ", e); + } + } + + private void loadItemsFromSelection() throws TCException { + items = new ArrayList<>(); + InterfaceAIFComponent[] targets = app.getTargetComponents(); + if (targets == null || targets.length == 0) { + showMessage("ѡж󵼳"); + return; + } + if (!(targets[0] instanceof TCComponentItem)) { + + showMessage("ѡItemͣ"); + return; + } + // ֤һ + String type = targets[0].getType(); + if (!(targets[0] instanceof TCComponentItem)) { + showMessage("ѡItemͣ"); + return; + } + // ȡ + TCProperty[][] props = TCComponentType.getTCPropertiesSet((List) Arrays.asList(targets),new String[] {"revision_list","object_type"}); + for (int i = 0; i < targets.length; i++) { + String type1 = props[i][1].getStringValue(); + if (!type1.equals(type)) { + showMessage("Ͳһ£"); + return; + } + TCComponent[] referenceValueArray = props[i][0].getReferenceValueArray(); + items.add((TCComponentItem) targets[i]); + itemUidList.add(((TCComponentItem) targets[i]).getUid()); + revUidList.add(((TCComponentItemRevision)referenceValueArray[referenceValueArray.length-1]).getUid()); + + } + } + + private void loadItemsByIds() throws TCException { + items = new ArrayList<>(); + for (String id : idList) { + TCComponentItem item = (TCComponentItem) getItemById(id); + if (item != null) { + items.add(item); + } + } + } + /** + * + * @Title: getItemById + * @Description: idòѯض + * @param @param id + * @param @return + * @return TCComponent + * @throws + */ + public static TCComponent getItemById(String id) { + + try { + System.out.println("ûĿ" + getText(session, "ItemID")); + // òѯ + String[] keys = new String[] { getText(session, "ItemID") }; + // òѯidֵ + String[] values = new String[] { id }; + List comps = queryObject("...", keys, values); + if (comps != null || comps.size() > 0) { + return comps.get(0); + } else { + MessageBox.post("ѡûвѯ", "", MessageBox.ERROR); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + + /** + * + * @Title: queryObject + * @Description: òѯ + * @param @param queryName + * @param @param keys + * @param @param values + * @param @return + * @return List + * @throws + */ + public static List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + MessageBox.post("ûвѯ", "", MessageBox.ERROR); + return null; + } + } + + /** + * + * @Title: getText + * @Description: ȡûĿֵ + * @param @param session + * @param @param str + * @param @return + * @param @throws Exception + * @return String + * @throws + */ + 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; + } + } + + /** + * + * @Title: isEmpty + * @Description: жǷΪ + * @param @param str + * @param @return + * @return boolean + * @throws + */ + public static boolean isEmpty(String str) { + return str == null || "".equals(str.trim()); + } + + private void startBackgroundProcessing() { + processing.set(true); + latch = new CountDownLatch(items.size()); + + // һȡԽṹ + executor.execute(() -> { + try { + processFirstItem(items.get(0)); + collectUidsAsync(); + } catch (Exception e) { + handleError("ռʧ", e); + } + }); + } + + private void processFirstItem(TCComponentItem item) throws Exception { + TCComponentItemRevision rev = item.getLatestItemRevision(); + + // ռItem + collectItemProperties(item); + // ռRevision + collectRevProperties(rev); + // ռ + collectClassificationProperties(rev); + + updateUI(); + } + + private void collectItemProperties(TCComponentItem item) throws TCException { + for (String prop : allprops) { + String[] parts = prop.split("\\."); + if (parts.length == 3 && "ITEM".equals(parts[0])) { + if (!itemAttrList.contains(parts[1])) { + itemAttrList.add(parts[1]); + itemAttrMap.put(parts[1] + "." + parts[2], parts[2]); + } + } + } + } + + private void collectRevProperties(TCComponentItemRevision rev) throws TCException { + for (String prop : allprops) { + String[] parts = prop.split("\\."); + if (parts.length == 3 && "REV".equals(parts[0])) { + if (!revAttrList.contains(parts[1])) { + revAttrList.add(parts[1]); + revAttrMap.put(parts[1] + "." + parts[2], parts[2]); + } + } + } + } + + private void collectClassificationProperties(TCComponentItemRevision rev) throws TCException { + TCComponentICO[] classObjects = rev.getClassificationObjects(); + if (classObjects != null && classObjects.length > 0) { + TCComponentICO ico = classObjects[0]; + ICSProperty[] props = ico.getICSProperties(true); + ICSPropertyDescription[] descs = ico.getICSPropertyDescriptors(); + for (int i = 0; i < props.length; i++) { + String propName = descs[i].getName(); + classAttrMap.put(props[i].getId() + "." + propName, propName); + if (!classAttrList.contains(propName)) { + classAttrList.add(propName); + } + } + } + } + + private void collectUidsAsync() { + executor.execute(() -> { + +// for (TCComponentItem item : items) { +// if (!processing.get()) break; +// itemUidList.add(item.getUid()); +// try { +// revUidList.add(item.getLatestItemRevision().getUid()); +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// latch.countDown(); +// updateStatus("Ѽ " + (items.size() - latch.getCount()) + "/" + items.size() + " "); +// } + processing.set(false); + updateStatus(""); + }); + } + + private void updateUI() { + SwingUtilities.invokeLater(() -> { + List data = new ArrayList<>(); + try { + // Item + data.add(new InstallData("", false)); + for (Entry entry : itemAttrMap.entrySet()) { + data.add(new InstallData(entry.getValue())); + } + + + // Revision + data.add(new InstallData("汾", false)); + for (Entry entry : revAttrMap.entrySet()) { + data.add(new InstallData(entry.getValue())); + } + + // ӷ + data.add(new InstallData("", false)); + for (String attr : classAttrList) { + data.add(new InstallData(attr)); + } + }catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + propList.setListData(data.toArray(new InstallData[0])); + }); + } + + private JPanel initPropPanel() { + JPanel panel = new JPanel(new BorderLayout(5, 5)); + + // ״̬ǩ + statusLabel = new JLabel("׼..."); + panel.add(statusLabel, BorderLayout.NORTH); + + // б + propList = new JList<>(); + propList.setCellRenderer(new CheckListCellRenderer()); + propList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + panel.add(new JScrollPane(propList), BorderLayout.CENTER); + + // ȫѡѡ + selectAllCheckBox = new JCheckBox("ȫѡ/ȡ"); + selectAllCheckBox.addActionListener(e -> { + boolean selected = selectAllCheckBox.isSelected(); + for (int i = 0; i < propList.getModel().getSize(); i++) { + InstallData data = propList.getModel().getElementAt(i); + if (data.isSelectable()) { + data.setSelected(selected); + } + } + propList.repaint(); + }); + + JPanel rightPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5)); + rightPanel.add(selectAllCheckBox); + panel.add(rightPanel, BorderLayout.EAST); + + return panel; + } + + private JPanel initButtonPanel() { + JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 15, 5)); + + okButton = new JButton("ȷ"); + okButton.setPreferredSize(new Dimension(100, 25)); + okButton.addActionListener(e -> onConfirm()); + + cancelButton = new JButton("ȡ"); + cancelButton.setPreferredSize(new Dimension(100, 25)); + cancelButton.addActionListener(e -> jFrame.dispose()); + + panel.add(okButton); + panel.add(cancelButton); + + return panel; + } + + private void onConfirm() { + // ȡûѡ + List selectedProps = getSelectedProperties(); + + // ûǷѡһ + if (selectedProps.isEmpty()) { + MessageBox.post("ѡһ", "ʾ", MessageBox.INFORMATION); + return; + } + + // ֯ + Map requestData = new HashMap<>(); + requestData.put("itemUidList", itemUidList); + requestData.put("revUidList", revUidList); + requestData.put("selectedProps", selectedProps); + + // Ƿַ + Map cleanedData = new HashMap<>(); + for (Map.Entry entry : requestData.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + + if (value instanceof List) { + List list = (List) value; + List cleanedList = new ArrayList<>(); + for (Object item : list) { + if (item instanceof String) { + String cleanedItem = ((String) item).replaceAll("[\\p{Cntrl}&&[^\r\n\t]]", ""); + cleanedList.add(cleanedItem); + } else { + cleanedList.add(item); + } + } + value = cleanedList; + } else if (value instanceof String) { + value = ((String) value).replaceAll("[\\p{Cntrl}&&[^\r\n\t]]", ""); + } + + cleanedData.put(key, value); + } + // ʹSwingWorker첽 + new SwingWorker() { + private byte[] fileData; + private Exception error; + + @Override + protected Void doInBackground() throws Exception { + try { + // + URL url = new URL("http://127.0.0.1:13025/api/exportProperties"); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("POST"); + conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8"); + conn.setDoOutput(true); + + // дJSON + System.out.println("cleanedData:"+cleanedData); + try (OutputStream os = conn.getOutputStream()) { + os.write(JSON.toJSONString(cleanedData).getBytes("UTF-8")); + os.flush(); + } + + // Ӧ״̬ + if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) { + throw new IOException("HTTP error code: " + conn.getResponseCode()); + } + + // ȡӦ + try (InputStream is = conn.getInputStream(); + ByteArrayOutputStream buffer = new ByteArrayOutputStream()) { + byte[] data = new byte[4096]; + int bytesRead; + while ((bytesRead = is.read(data, 0, data.length)) != -1) { + buffer.write(data, 0, bytesRead); + } + fileData = buffer.toByteArray(); + } + } catch (Exception e) { + e.printStackTrace(); + error = e; + } + return null; + } + + @Override + protected void done() { + jFrame.dispose(); + if (error != null) { + MessageBox.post("ʧ: " + error.getMessage(), "", MessageBox.ERROR); + return; + } + + // ʾļԻ + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setDialogTitle("浼ļ"); + fileChooser.setSelectedFile(new File("Ե.xlsx")); + fileChooser.setFileFilter(new FileNameExtensionFilter("Excelļ (*.xlsx)", "xlsx")); + + if (fileChooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { + File file = fileChooser.getSelectedFile(); + // ȷļչȷ + if (!file.getName().toLowerCase().endsWith(".xlsx")) { + file = new File(file.getAbsolutePath() + ".xlsx"); + } + + // дļ + try (FileOutputStream fos = new FileOutputStream(file)) { + fos.write(fileData); + MessageBox.post("ļɹ: " + file.getAbsolutePath(), "ɹ", MessageBox.INFORMATION); + } catch (IOException e) { + MessageBox.post("ļʧ: " + e.getMessage(), "", MessageBox.ERROR); + } + } + } + }.execute(); + } + + private List getSelectedProperties() { + List selected = new ArrayList<>(); + for (int i = 0; i < propList.getModel().getSize(); i++) { + InstallData data = propList.getModel().getElementAt(i); + if (data.isSelected() && data.isSelectable()) { + String name = null; + for(Entry entry : itemAttrMap.entrySet()) { + if(entry.getValue().equals(data.getName())) { + name = "ITEM." + entry.getKey(); + break; + } + } + if(name == null) { + for(Entry entry : revAttrMap.entrySet()) { + if(entry.getValue().equals(data.getName())) { + name = "REV." + entry.getKey(); + break; + } + } + } + if(name == null) { + for(Entry entry : classAttrMap.entrySet()) { + if(entry.getValue().equals(data.getName())) { + name = "Class." + entry.getKey(); + break; + } + } + } + selected.add(name); + } + } + return selected; + } + + private void updateStatus(String message) { + SwingUtilities.invokeLater(() -> statusLabel.setText(message)); + } + + private void showMessage(String message) { + MessageBox.post(message, "ʾ", MessageBox.INFORMATION); + } + + private void handleError(String message, Exception e) { + MessageBox.post(message + ": " + e.getMessage(), "", MessageBox.ERROR); + } + + public Map getResult1() { + Map result = new HashMap<>(); + result.put("itemUidList", itemUidList); + result.put("itemAttrList", itemAttrList); + result.put("revAttrList", revAttrList); + result.put("classAttrList", classAttrList); + result.put("selectedProps", getSelectedProperties()); + return result; + } + + private static class InstallData { + private final String name; + private boolean selected; + private final boolean selectable; + + public InstallData(String name) { + this(name, true); + } + + public InstallData(String name, boolean selectable) { + this.name = name; + this.selectable = selectable; + this.selected = selectable; + } + + public String getName() { return name; } + public boolean isSelected() { return selected; } + public void setSelected(boolean selected) { this.selected = selected; } + public boolean isSelectable() { return selectable; } + + @Override + public String toString() { + return name; + } + } + + private static class CheckListCellRenderer extends JCheckBox implements ListCellRenderer { + public CheckListCellRenderer() { + setOpaque(true); + setBorder(new EmptyBorder(1, 1, 1, 1)); + } + + @Override + public Component getListCellRendererComponent(JList list, + InstallData value, int index, boolean isSelected, boolean cellHasFocus) { + setText(value.toString()); + setSelected(value.isSelected()); + setEnabled(value.isSelectable()); + setBackground(isSelected ? list.getSelectionBackground() : list.getBackground()); + setForeground(isSelected ? list.getSelectionForeground() : list.getForeground()); + setFont(list.getFont()); + return this; + } + } +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/rb026/Rb026Handler.java b/src/com/connor/rb/plm/rb026/Rb026Handler.java new file mode 100644 index 0000000..123aed3 --- /dev/null +++ b/src/com/connor/rb/plm/rb026/Rb026Handler.java @@ -0,0 +1,23 @@ +package com.connor.rb.plm.rb026; + +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class Rb026Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Rb026Dialog rb026Dialog = new Rb026Dialog(app); + session.queueOperation(rb026Dialog); +// session.queueOperation(new Rb026Dialog(app)); + return null; + } + +} diff --git a/src/com/connor/rb/plm/rb026/TestOperation.java b/src/com/connor/rb/plm/rb026/TestOperation.java new file mode 100644 index 0000000..3b4f0cc --- /dev/null +++ b/src/com/connor/rb/plm/rb026/TestOperation.java @@ -0,0 +1,275 @@ +package com.connor.rb.plm.rb026; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; + +public class TestOperation { + static List childClassList = new ArrayList(); + static List childNameClassList = new ArrayList(); + + + + public static Object[] writeTOMap(TCSession session, String className) throws TCException { + childClassList.clear(); + childNameClassList.clear(); + System.out.println("className==========" + className); + + // ȡӷ + // getChildClass(className, session); + childClassList.add(className); + + // һ Map ڴ洢 + Map> resultMap = new LinkedHashMap<>(); + + // ڴ洢ͷȥǰУ + List header = null; + + // б + for (int k = 0; k < childClassList.size(); k++) { + // ѯ + List> data = queryPressed(childClassList.get(k), session); + + // ݲ resultMap + for (int i = 0; i < data.size(); i++) { // + List rowData = data.get(i); // ȡһ + if (!rowData.isEmpty()) { + if (i == 0) { + // һDZͷȥǰ + header = rowData.subList(2, rowData.size()); + } else { + // ݣһΪ keyȥǰкΪ value + String key = rowData.get(0); // һΪ key + List value = rowData.subList(2, rowData.size()); // ȥǰ + resultMap.put(key, value); // resultMap + } + } + } + } + + // һ飬һԪDZͷڶԪ resultMap + return new Object[]{header, resultMap}; + } + + public static List getClassMap(String classCodeName, TCSession session) { + List classPropList = new ArrayList(); + try { + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(classCodeName); + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + if (icsAttrS != null) { + for (ICSAdminClassAttribute attr : icsAttrS) { + ClassAttributeBean bean = new ClassAttributeBean(); + if (attr.isReferenceAttribute()) {// + continue; + } + if (attr.isReference()) { + continue; + } + int propID = attr.getAttributeId(); + bean.setId(propID); + String propDisName = attr.getName(); + bean.setName(propDisName); + + int attrType = attr.getFormat1().getType(); + bean.setType(attrType); + + ICSKeyLov lov1 = attr.getFormat1().getKeyLov(); + lov1 = (lov1 == null ? attr.getFormat2().getKeyLov() : lov1); + if (lov1 != null) { + bean.setIslov(true); + String[] keys = lov1.getKeys(); + Map map1 = new HashMap(); + for (String key : keys) { + String value = lov1.getValueOfKey(key); + map1.put(key, value);// <ʾֵ,ʵֵ> + // if(key.equals(bean.getVal())&&(!bean.getVal().equals(""))){ + // bean.setVal(value); + // } + } + bean.setLov(map1); + } else { + bean.setIslov(false); + } + classPropList.add(bean); + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + return classPropList; + } + + public static void getChildClass(String pvalString, TCSession session) throws TCException { + Map> classPropMap = new HashMap>(); + Map> proppNameMap = new HashMap>(); + // where b.PNAME like '%%' + String sqlString = "select a.*,b.PNAME from (select b0.pcid,b1.punct,b1.pdbindex,b0.PNAME className from PPARENT pa ,PSMLB0 b0,PSMLB1 b1 where pa.PVAL_0 = 'ICM010214' and pa.PSEQ = '1' and pa.puid = b0.puid and b1.rtag_to_headeru = b0.puid) a left join PUNCT_DICT b on b.PUNCT = a.PUNCT order by a.PCID asc"; + sqlString = sqlString.replace("ICM010214", pvalString); + System.out.println("Сѯ:" + sqlString); + try { + DbPool.getConnection(session); + ResultSet cnSet = DbPool.executeSelectSql(sqlString); + // Map> + while (cnSet.next()) { + String pcid = cnSet.getString("PCID"); + String pName = cnSet.getString("PNAME"); + String className = cnSet.getString("className"); + + if (!childClassList.contains(pcid)) { + childClassList.add(pcid); + childNameClassList.add(className); + } + String pdbindex = cnSet.getString("pdbindex"); + if (classPropMap.containsKey(pcid)) { + proppNameMap.get(pcid).add(pName); + classPropMap.get(pcid).put(cnSet.getString("punct"), pdbindex); + } else { + Map propMap = new HashMap(); + propMap.put(cnSet.getString("punct"), pdbindex); + classPropMap.put(pcid, propMap); + List propList = new ArrayList(); + // propList.add("Ʒ/汾"); + // propList.add("Ʒ"); + propList.add(pName); + proppNameMap.put(pcid, propList); + } + + } + System.out.println(classPropMap.toString()); + // System.out.println(pnNameMap.toString()); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + DbPool.freeAll(); + } + } + + public static void getClassMap(Map classMap, String pvalString, TCSession session) { + try { + DbPool.getConnection(session); + String insertSql = String.format("select puid from PSMLB0 where pcid = '%s' ", pvalString); + ResultSet executeSelectSql = DbPool.executeSelectSql(insertSql); + System.out.println("insertSql" + insertSql); + String puid = ""; + if (executeSelectSql.next()) { + puid = executeSelectSql.getString("puid"); + } + System.out.println(puid); + if (puid.equals("")) { + System.out.println("puid id null"); + } + DbPool.free(executeSelectSql); + String insertSql2 = String.format("select punct,pdbindex from PSMLB1 where rtag_to_headeru= '%s' ", puid); + ResultSet selectSql2 = DbPool.executeSelectSql(insertSql2); + while (selectSql2.next()) { + String punct = selectSql2.getString("punct"); + String pdbNo = selectSql2.getString("pdbindex"); + + classMap.put(punct, pdbNo); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + DbPool.freeAll(); + } + } + + // ѯťз + public static List> queryPressed(String pvalString, TCSession session) throws TCException { + Map classMap = new HashMap(); + String classCode = pvalString; + for (int i = 0; i < 3; i++) { + System.out.println("123"); + if (i != 0) { + classCode = classCode.substring(0, classCode.length() - 2); + } + getClassMap(classMap, classCode,session); + } + + List classList = new ArrayList(); + List> classlovList = new ArrayList>(); + List classTrueList = new ArrayList(); + List classPropList = getClassMap(pvalString,session); + StringBuffer sqlCt = new StringBuffer("select PID,xxxxxxxxtt from PICM0 where pcid ='"); + sqlCt.append(pvalString); + sqlCt.append("' and "); + StringBuffer sqlCN = new StringBuffer( + "select a.*,obj.pobject_name from (select * from PICM0 pi0 where pcid ='"); + sqlCN.append(pvalString); + sqlCN.append("'"); + // sqlCN.append("' and "); + // ԱPICM0 ֶζӦΪ psm0+() + + List> res = new ArrayList>(); + if (classPropList.size() > 0) { + classList.add("Ʒ/汾"); + classList.add("Ʒ"); + for (int i = 0; i < classPropList.size(); i++) { + ClassAttributeBean bean = classPropList.get(i); + System.out.println("11.29=====" + bean.getName()); + int propID = bean.getId(); // id + String idProp = String.valueOf(propID); + if (classMap.containsKey(idProp)) { + + int idNo = Integer.valueOf(classMap.get(idProp)); + String psm = "psm" + String.format("%02d", idNo); + classList.add(bean.getName()); + classTrueList.add(psm); + if (bean.isIslov()) { + Map lov = bean.getLov(); + classlovList.add(lov); + } else { + classlovList.add(null); + } + } + } + res.add(classList); + try { + sqlCN.append(") a left join PWORKSPACEOBJECT obj on obj.puid = a.rerefu order by PID desc"); + System.out.println("sqlCN ====>" + sqlCN.toString()); + DbPool.getConnection(session); + ResultSet cnSet = DbPool.executeSelectSql(sqlCN.toString()); + while (cnSet.next()) { + List vList = new ArrayList(); + String pid = cnSet.getString("PID"); + vList.add(pid); + vList.add(cnSet.getString("pobject_name")); + // if(pid.con) + for (int i = 0; i < classTrueList.size(); i++) { + Map hashMap = classlovList.get(i); + if (hashMap != null) { + String psmStr = cnSet.getString(classTrueList.get(i)); + String string = hashMap.get(psmStr); + vList.add(string); + } else { + vList.add(cnSet.getString(classTrueList.get(i))); + } + } + res.add(vList); + } + + } catch (SQLException e) { + e.printStackTrace(); + } finally { + DbPool.freeAll(); + } + } + + return res; + } +} diff --git a/src/com/connor/rb/plm/rb027/GetNumberCommand.java b/src/com/connor/rb/plm/rb027/GetNumberCommand.java new file mode 100644 index 0000000..a2faa56 --- /dev/null +++ b/src/com/connor/rb/plm/rb027/GetNumberCommand.java @@ -0,0 +1,165 @@ +package com.connor.rb.plm.rb027; + +import java.io.BufferedReader; +import java.net.HttpURLConnection; +import java.util.Iterator; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; +import java.io.InputStreamReader; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import java.net.URL; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +public class GetNumberCommand extends AbstractAIFCommand { + private AbstractAIFApplication app; + private TCSession session; + + public GetNumberCommand(AbstractAIFApplication app, TCSession session) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + // ȡѡж + InterfaceAIFComponent comp = app.getTargetComponent(); + + if (!(comp instanceof TCComponentItemRevision)) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("qxzbbdx27_display.TITLE"), "", MessageBox.ERROR); + return; + } + + TCComponentItemRevision itemRevision = (TCComponentItemRevision) comp; + String result = sendPost("http://192.168.213.133:9889/jde/getNumber");// +// String result = sendPost("https://erp.cugroup.com/iuap-api-gateway/inms9ujv/rb-dataquery/jdeauto/getnumber");//ʽ + System.out.println(result); + // ȡؽ + JSONObject resultJson = JSONObject.fromObject(result); + + // JSONArray jsonArray = resultJson.getJSONArray("data"); + // for (int i=0; i < jsonArray.size(); i++) { + + // ȡautoNextNumber + String autoNextNumber = ""; + JSONObject jsonObject = resultJson.getJSONObject("data"); + if (jsonObject != null) { + Iterator iter = jsonObject.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry entry = (Map.Entry) iter.next(); + System.out.println(entry.getKey().toString()); + switch (entry.getKey().toString()) { + case "autoNextNumber": + System.out.println(entry.getValue().toString()); + autoNextNumber = entry.getValue().toString(); + break; + default: + break; + } + } + itemRevision.setStringProperty("rb3_spm", autoNextNumber); + itemRevision.refresh(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("hqspmcg27_display.TITLE"), "ɹ", MessageBox.INFORMATION); + } + // return; + // } + super.executeModal(); + } + + public static String sendPost(String url) { + String response = null; + HttpURLConnection connection = null; + BufferedReader reader = null; + + try { + // URL + URL requestUrl = new URL(url); + // + connection = (HttpURLConnection) requestUrl.openConnection(); + // 󷽷Ϊ GETȻ sendPostʵ GET + connection.setRequestMethod("GET"); + // óʱʱ䣨ѡ + connection.setConnectTimeout(5000); // 5 + connection.setReadTimeout(5000); // 5 + + // ȡӦ + int responseCode = connection.getResponseCode(); + if (responseCode == HttpURLConnection.HTTP_OK) { + // ȡӦ + reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + StringBuilder responseBuilder = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + responseBuilder.append(line); + } + response = responseBuilder.toString(); + } else { + System.out.println("HTTP request failed with response code: " + responseCode); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + // رԴ + if (reader != null) { + try { + reader.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + if (connection != null) { + connection.disconnect(); + } + } + + return response; + } + + public static String sendPost2(String url) { + String response = null; + + try { + CloseableHttpClient httpclient = null; + CloseableHttpResponse httpresponse = null; + try { + httpclient = HttpClients.createDefault(); + HttpGet httpGet = new HttpGet(url); + httpresponse = httpclient.execute(httpGet); + response = EntityUtils.toString(httpresponse.getEntity()); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (httpclient != null) { + httpclient.close(); + } + if (httpresponse != null) { + httpresponse.close(); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return response; + } + +} diff --git a/src/com/connor/rb/plm/rb027/GetNumberHandler.java b/src/com/connor/rb/plm/rb027/GetNumberHandler.java new file mode 100644 index 0000000..329e905 --- /dev/null +++ b/src/com/connor/rb/plm/rb027/GetNumberHandler.java @@ -0,0 +1,31 @@ +package com.connor.rb.plm.rb027; + +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class GetNumberHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + + NewGetNumberCommand command = new NewGetNumberCommand(app, session);//½ӿ erpδ ʱ 2024712 +// GetNumberCommand command = new GetNumberCommand(app, session); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + +} diff --git a/src/com/connor/rb/plm/rb027/NewGetNumberCommand.java b/src/com/connor/rb/plm/rb027/NewGetNumberCommand.java new file mode 100644 index 0000000..1ff74a5 --- /dev/null +++ b/src/com/connor/rb/plm/rb027/NewGetNumberCommand.java @@ -0,0 +1,287 @@ +/** * @Title: NewGetNumberCommand.java + * @Package com.connor.rb.plm.rb027 + * @Description: erpȡƷ + * @author hcj * @date 202472 + * @version V1.0 + */ +package com.connor.rb.plm.rb027; + +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; + + + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.Base64; +import java.util.HashMap; +import java.io.IOException; +import java.io.UnsupportedEncodingException; + +/** + * @ClassName: NewGetNumberCommand + * @Description: erpȡƷ + * @author hcj + * @date 202472 + * + */ +public class NewGetNumberCommand extends AbstractAIFCommand { + private AbstractAIFApplication app; + private TCSession session; + private static final String APP_KEY = "9a752f220f244cba928ce7b20ef10368"; + private static final String APP_SECRET = "2414e502b637491f7a5c72b82825fac126666482"; + //private static final String TOKEN_URL = "https://ר/iuap-api-auth/open-auth/selfAppAuth/getAccessToken";//ʽַ +// private static final String TOKEN_URL = "https://erpdev.cugroup.com/iuap-api-auth/open-auth/selfAppAuth/getAccessToken";//ԭԵַ + private static final String TOKEN_URL = "https://erptest.cugroup.com/iuap-api-gateway/inms9ujv/rb-dataquery/jdeauto/getnumber?";//Եַ + + +// private static String requestUrl = "https://erpdev.cugroup.com/iuap-api-gateway/c8zxdxtw/rb-dataquery/jdeauto/getnumber"; + + private static String requestUrl = "https://erptest.cugroup.com/iuap-api-gateway/inms9ujv/rb-dataquery/jdeauto/getnumber"; + public NewGetNumberCommand(AbstractAIFApplication app, TCSession session) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + // ȡѡж + System.out.println("------------------ʼִ------------------"); + InterfaceAIFComponent comp = app.getTargetComponent(); + + System.out.println("жѡжǷΪ汾....."); + if (!(comp instanceof TCComponentItemRevision)) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("qxzbbdx27_display.TITLE"), "", MessageBox.ERROR); + return; + } + + TCComponentItemRevision itemRevision = (TCComponentItemRevision) comp; + + // ȡtoken¼Ϣ + System.out.println("ȡtoken¼Ϣ....."); + String accessToken = getAccessToken(); + System.out.println("accessToken" + accessToken); + + // ϱ + System.out.println("ȡϱ....."); + String productCode = itemRevision.getStringProperty("item_id"); + System.out.println("ϱ룺"+productCode); + + // URL + System.out.println("url......"); + requestUrl += "?access_token=" + accessToken + (productCode.isEmpty() ? "" : "&productCode=" + productCode); + System.out.println("url"+requestUrl); + + // GETȡƷ + System.out.println("GETȡƷ......"); + String response = sendGetRequest(requestUrl); + System.out.println("response"+response); + + // Ӧ + // ʹFastjsonparseObjectJSONַתΪJSONObject + JSONObject jsonObject = JSON.parseObject(response); + JSONObject dataObject = jsonObject.getJSONObject("data"); + if(dataObject == null) { + MessageBox.post("ȡʧܣ" + jsonObject.toString(), "ɹ", MessageBox.INFORMATION); + } + String number = dataObject.getString("number"); + System.out.println("Number: " + number); + + //ʼ汾ƷԸֵ + System.out.println("ʼ汾ƷԸֵ......"); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (number != null) { + itemRevision.setStringProperty("rb3_spm", number); + itemRevision.refresh(); + MessageBox.post(rb.getString("hqspmcg27_display.TITLE"), "ɹ", MessageBox.INFORMATION); + } else { + MessageBox.post(rb.getString("hqspmsb27_display.TITLE"), "ɹ", MessageBox.INFORMATION); + } + System.out.println("------------------ִн------------------"); + // return; + // } + super.executeModal(); + } + + /** + * + * @Title: getAccessToken + * @Description: ȡaccessToken + * @param @return + * @param @throws Exception + * @return String + * @throws + */ + private static String getAccessToken() throws Exception { + String appKey = "467192f406644533a1d18766b68cd7d1"; + String appSecret = "f90d3230f5ace27de4a376ffd6eedf403e5cd7d9"; + Map params = new HashMap<>(); + // ǩ + params.put("appKey", appKey); + params.put("timestamp", String.valueOf(System.currentTimeMillis())); + String signature = SignHelper.sign(params, appSecret); + // System.out.println("signature===="+signature); + params.put("signature", signature); + String tokenUrl = "https://erptest.cugroup.com/iuap-api-auth/open-auth/selfAppAuth/getAccessToken"; + String tokenResult = sendGetRequest(tokenUrl,params); + return parseResponse(tokenResult); + } + + /** + * + * @Title: hmacSHA256 + * @Description: HmacSHA256ǩ + * @param @param data + * @param @param secret + * @param @return + * @param @throws NoSuchAlgorithmException + * @param @throws InvalidKeyException + * @return String + * @throws + */ + public static byte[] hmacSHA256(String data, String key) { + try { + byte[] keyBytes = key.getBytes("UTF-8"); + SecretKeySpec secretKeySpec = new SecretKeySpec(keyBytes, "HmacSHA256"); + Mac mac = Mac.getInstance("HmacSHA256"); + + mac.init(secretKeySpec); + byte[] dataBytes = data.getBytes("UTF-8"); + return mac.doFinal(dataBytes); + } catch (InvalidKeyException | NoSuchAlgorithmException | UnsupportedEncodingException e) { + e.printStackTrace(); + } + return null; + } + + + /** + * + * @Title: sendGetRequest + * @Description: ȡtoken + * @param @param baseURL + * @param @param queryParams + * @param @return + * @param @throws IOException + * @return String + * @throws + */ + public static String sendGetRequest(String baseURL, Map queryParams) throws IOException { + // URL + StringBuilder urlBuilder = new StringBuilder(baseURL); + urlBuilder.append('?'); + for (Map.Entry entry : queryParams.entrySet()) { + urlBuilder.append(entry.getKey()).append('=').append(entry.getValue()).append('&'); + } + urlBuilder.setLength(urlBuilder.length() - 1); // Ƴһ'&' + + // URL + URL url = new URL(urlBuilder.toString()); + + // + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + + // 󷽷ΪGET + connection.setRequestMethod("GET"); + + // Ӧ + connection.connect(); + + // ȡӦ + BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)); + StringBuilder response = new StringBuilder(); + String inputLine; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + + // Ͽ + connection.disconnect(); + + return response.toString(); + } + + /** + * + * @Title: sendGetRequest + * @Description: get + * @param @param requestUrl + * @param @return + * @param @throws Exception + * @return String + * @throws + */ + private static String sendGetRequest(String requestUrl) throws Exception { + System.out.println("ʼGET"); + + // URL + URL url = new URL(requestUrl); + + // + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + + // 󷽷ΪGET + connection.setRequestMethod("GET"); + + // Ӧ + connection.connect(); + + // ȡӦ + BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)); + StringBuilder response = new StringBuilder(); + String inputLine; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + + // Ͽ + connection.disconnect(); + + return response.toString(); + } + + /** + * + * @Title: parseResponse + * @Description: access_token + * @param @param response + * @param @return + * @param @throws Exception + * @return String + * @throws + */ + private static String parseResponse(String response) throws Exception { + // ʹFastjsonparseObjectJSONַתΪJSONObject + JSONObject jsonObject = JSON.parseObject(response); + JSONObject dataObject = jsonObject.getJSONObject("data"); + String access_token = dataObject.getString("access_token"); + System.out.println("access_token: " + access_token); + return access_token; + } + +} diff --git a/src/com/connor/rb/plm/rb027/SignHelper.java b/src/com/connor/rb/plm/rb027/SignHelper.java new file mode 100644 index 0000000..6a939e3 --- /dev/null +++ b/src/com/connor/rb/plm/rb027/SignHelper.java @@ -0,0 +1,50 @@ +package com.connor.rb.plm.rb027; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.Base64; +import java.util.Map; +import java.util.TreeMap; + +/** + * 󿪷ƽ̨׼Ȩؽӿڵļǩ + */ +public class SignHelper { + + /** + * ƴӲֵ֮Ըַʹ HmacSHA256 ǩǩ base 64 + * @param params map + * @param suiteSecret ׼Կ mac key + * @return ǩ + * @throws NoSuchAlgorithmException + * @throws UnsupportedEncodingException + * @throws InvalidKeyException + */ + public static String sign(Map params, String suiteSecret) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException { + // use tree map to sort params by name + Map treeMap; + if (params instanceof TreeMap) { + treeMap = params; + } else { + treeMap = new TreeMap<>(params); + } + + StringBuilder stringBuilder = new StringBuilder(); + for (Map.Entry entry : treeMap.entrySet()) { + stringBuilder.append(entry.getKey()).append(entry.getValue()); + } + + Mac mac = Mac.getInstance("HmacSHA256"); + mac.init(new SecretKeySpec(suiteSecret.getBytes(StandardCharsets.UTF_8), "HmacSHA256")); + byte[] signData = mac.doFinal(stringBuilder.toString().getBytes(StandardCharsets.UTF_8)); + String base64String = Base64.getEncoder().encodeToString(signData); + return URLEncoder.encode(base64String, "UTF-8"); + } + +} diff --git a/src/com/connor/rb/plm/rb028/CreateDialogNew.java b/src/com/connor/rb/plm/rb028/CreateDialogNew.java new file mode 100644 index 0000000..ef2442f --- /dev/null +++ b/src/com/connor/rb/plm/rb028/CreateDialogNew.java @@ -0,0 +1,1417 @@ +package com.connor.rb.plm.rb028; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.Map.Entry; +import java.util.Set; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Text; + +import com.connor.rb.plm.entity.ZC_LBJ_list; +import com.connor.rb.plm.newcombox.RwDefaultComboBoxModel; +import com.connor.rb.plm.newcombox.RwJCheckBox; +import com.connor.rb.plm.newcombox.RwJComboBox; +import com.connor.rb.plm.newcombox.RwMetalComboBoxUI; +import com.connor.rb.plm.rb012.SearchJComItem; +import com.connor.rb.plm.util.ClassAttributeBean; +import com.connor.rb.plm.util.ClassProperty; +import com.connor.rb.plm.util.ParseXML; +import com.connor.rb.plm.util.PlmLocaleUtil; +import com.connor.rb.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSKeyLov.KeyLov; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class CreateDialogNew extends AbstractAIFDialog { + private AbstractAIFApplication app; + private TCSession session; + private TCPreferenceService service; + private List classList = new ArrayList(); + private JLabel[] labels1 = null; + private JComboBox comb = null; + private String className = ""; + private Map map2; + private List> values = new ArrayList>(); + private String type = ""; + private String targetType = ""; + private JScrollPane scr2; + private boolean flag = true; + private String url = ""; + private TCComponentItemRevision targetRev = null; + private boolean classFlag = true; + private JTextField idField = null; + private JTextField nameField = null; + private JComboBox revComb = null; + private List idList = new ArrayList(); + private List typeList = new ArrayList(); + private String productNumber = ""; + private String drawingNumber = ""; + private Map> attrMap; + private Map> attrMap2; + private Map> attrMap3; + private Map> attrMap4; + private Map> boxMap = new HashMap>(); + private Map objMap = new HashMap(); + private Map objMap2 = new HashMap(); + private Map objMap3 = new HashMap(); + private Map objMap4 = new HashMap(); + private Map lovMap = new HashMap(); + private Map lovMap2 = new HashMap(); + private Map lovMap3 = new HashMap(); + private Map lovMap4 = new HashMap(); + private List defaultValueList = new ArrayList(); + private List isNList = new ArrayList(); + private List isNList2 = new ArrayList(); + private List isNList3 = new ArrayList(); + private List isNList4 = new ArrayList(); + private List markList = new ArrayList(); + private List markList2 = new ArrayList(); + private List markList3 = new ArrayList(); + private List markList4 = new ArrayList(); + private List attrList = new ArrayList(); + private List esAttrList = new ArrayList(); + // private List objList = new ArrayList(); + // private List lovList = new ArrayList(); + private List attrList2 = new ArrayList(); + private List attrList3 = new ArrayList(); + private List attrList4 = new ArrayList(); + private List esAttrList2 = new ArrayList(); + private List esAttrList3 = new ArrayList(); + private List esAttrList4 = new ArrayList(); + private String bsNumber = ""; + private String smNumber = ""; + private List asList = new ArrayList(); + private List esList = new ArrayList(); + private InterfaceAIFComponent targetComp; + + // Ż + private Map zc_lbj_map = new HashMap<>(); + private List fieldList = new ArrayList<>(); + private List comboxList = new ArrayList(); + private List yylyList = new ArrayList(); + private Map yyly_map = new HashMap<>(); + private Map scgc1_map = new HashMap<>(); + private Map ptlov_map = new HashMap<>(); + private LovMsg msg = new LovMsg(); + // private int h=4; + private boolean boflag = false; + private Map fieldmap = new HashMap<>(); + private Map comboxmap = new HashMap<>(); + private String yyly = "rb3_yyly"; + private String scgc = "rb3_scgc1"; + private String yyly_text = null; + private String[] strss; + // endŻ + // private List objList2 = new ArrayList(); + // private List lovList2 = new ArrayList(); + // private String[] lovVal = new String[] { "ǰ", "׼", "޽Ӵ", "ʽ", + // "ͨ", "A:NBR", "0:", "", "", + // "SN:1805ػ", "ȴ", "", "S:(25% to 35%)", + // "C0","V0","Z0","׼","PC:ﵽC&UƷƾҪ" + // ,"P0:ﵽC&UƷƾҪ","ṹҪƹ","0:˫нǽӴ",":SECC൱",":벿Ŷȷ","BC:35"}; + // private String[] esLovVal = new String[] { "Non", "Standard ball", "Non", + // "Open", "Without vent hole", "A:NBR", + // "0:Black", "Non", "Ball", "SN:1805 temper","Conventional monolithic + // martensite quenching heat treatment", + // "Single", "S:(25% to 35%)", "C0","V0","Z0","Standard","PC:Meet the group C&U + // brand accuracy requirements" + // ,"P0:Meet the group C&U brand accuracy requirements","Other structures need + // to formulate rules","0:Double row angular contact ball bearing" + // ,"Not marked: SECC or equivalent","Other materials: confirm with department + // team for approval","BC:35"}; + + public CreateDialogNew(AbstractAIFApplication app) { + super(false); + this.app = app; + this.targetComp = app.getTargetComponent(); + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + } + + @Override + public void run() { + String lovVal = service.getStringValue("RB3_lovVal_default"); + String esLovVal = service.getStringValue("RB3_esLovVal_default"); + if (lovVal.contains(";")) { + String[] vals = lovVal.split(";"); + String[] esVals = esLovVal.split(";"); + for (int i = 0; i < vals.length; i++) { + asList.add(vals[i]); + esList.add(esVals[i]); + } + } + ParseXML xml = new ParseXML(); + File file = xml.getSXX("RB3_CPHPJFS", session); + + attrMap = xml.parseXMLAttr(file); + if (attrMap == null || attrMap.size() <= 0) { + MessageBox.post("ѡRB3_CPHPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + File file2 = xml.getSXX("RB3_THPJFS", session); + attrMap2 = xml.parseXMLAttr(file2); + if (attrMap2 == null || attrMap2.size() <= 0) { + MessageBox.post("ѡRB3_THPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + this.initUI(); + + } + + public void initUI() { + setTitle("Ϊ"); + int i = 1; + Dimension dimension = new Dimension(); + this.setLayout(new PropertyLayout()); + dimension.setSize(670, 820); + this.setMinimumSize(dimension); + this.setPreferredSize(dimension); + JPanel parentPanel = new JPanel(new PropertyLayout()); + scr2 = new JScrollPane(parentPanel); + scr2.setPreferredSize(new Dimension(640, 690)); + JPanel classJpanel = new JPanel(new PropertyLayout());// Խ + classJpanel.add("1.1.center.top", scr2); + // Żڼ + this.addComponentListener(new ComponentListener() { + @Override + public void componentResized(ComponentEvent e) { + // TODO Auto-generated method stub + Component component2 = e.getComponent(); + int h = component2.getHeight(); + if (h > 800) { + scr2.setPreferredSize(new Dimension(component2.getWidth() - 20, h - 120)); + scr2.revalidate(); + scr2.repaint(); + classJpanel.setPreferredSize(new Dimension(component2.getWidth(), h - 110)); + classJpanel.revalidate(); + classJpanel.repaint(); + } + } + + @Override + public void componentMoved(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void componentShown(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void componentHidden(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + }); + + // endŻ + + if (targetComp instanceof TCComponentItemRevision) { + targetRev = (TCComponentItemRevision) targetComp; + String revType = targetRev.getType(); + try { + targetType = targetRev.getItem().getType(); + System.out.println("revType============" + revType); + nameField = new JTextField(18); + parentPanel.add(i + ".1.center.top", new JLabel("")); + i += 1; + if ("RB3_ZCRevision".equals(revType)) { + type = targetRev.getStringProperty("rb3_zclx"); + flag = false; + } + parentPanel.add(i + ".1.center.top", new JLabel("")); + parentPanel.add(i + ".2.center.top", nameField); + i += 1; + String name = targetRev.getStringProperty("object_name"); + nameField.setText(name); + className = targetRev.getClassificationClass(); + String xmlClassName = ""; + + xmlClassName = className.substring(0, 6); + ParseXML xml = new ParseXML(); + File file3 = xml.getSXX("RB3_BSHPJFS", session); + attrMap3 = xml.parseXMLAttr(file3); + if (attrMap3 == null || attrMap3.size() <= 0) { + MessageBox.post("ѡRB3_BSHPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + File file4 = xml.getSXX("RB3_SMPJFS", session); + attrMap4 = xml.parseXMLAttr(file4); + if (attrMap4 == null || attrMap4.size() <= 0) { + MessageBox.post("ѡRB3_SMPJFSδã飡", "WARNING", MessageBox.WARNING); + return; + } + System.out.println("className===========" + className); + System.out.println("xmlClassName===========" + xmlClassName); + saveCOM2(xmlClassName, attrMap, attrList, esAttrList, markList, defaultValueList, isNList); + saveCOM(xmlClassName, attrMap2, attrList2, esAttrList2, markList2, isNList2); + if (attrMap3 != null) { + saveCOM(xmlClassName, attrMap3, attrList3, esAttrList3, markList3, isNList3); + saveCOM(xmlClassName, attrMap4, attrList4, esAttrList4, markList4, isNList4); + } + TCComponentICO[] icos = targetRev.getClassificationObjects(); + if (icos == null || icos.length <= 0) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("gwlmyfszfl19_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return; + } + Map claMap = new HashMap(); + if (icos != null && icos.length > 0) { + ICSProperty[] icss = icos[0].getICSProperties(true); + for (ICSProperty ics : icss) { + claMap.put(ics.getId(), ics.getValue()); + } + } + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(xmlClassName); + String cName = c.getName(); + System.out.println("cName===" + cName); + if (PlmLocaleUtil.getString("BearingAccessories").equals(cName)) { + classFlag = false; + } + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + if (icsAttrS != null) { + for (ICSAdminClassAttribute attr : icsAttrS) { + if (attr.isHidden()) { + continue; + } + ClassAttributeBean bean = new ClassAttributeBean(); + if (attr.isReferenceAttribute()) {// + continue; + } + if (attr.isReference()) { + continue; + } + int propID = attr.getAttributeId(); + bean.setId(propID); + String propDisName = attr.getName(); + bean.setName(propDisName); + System.out.print("propDisName:" + propDisName); + int attrType = attr.getFormat1().getType(); + bean.setType(attrType); + + if (claMap != null && claMap.containsKey(propID)) { + bean.setVal(claMap.get(propID)); + } else { + bean.setVal(""); + } + + ICSKeyLov lov1 = attr.getFormat1().getKeyLov(); + lov1 = (lov1 == null ? attr.getFormat2().getKeyLov() : lov1); + if (lov1 != null) { + bean.setIslov(true); + String[] keys = lov1.getKeys(); + Map map1 = new HashMap(); + for (String key : keys) { + KeyLov lov_key = lov1.getKeyLovOfKey(key); + boolean deprecated = lov_key.isDeprecated(); + if (deprecated) { + if (key.equals(bean.getVal())) { + bean.setVal(""); + } + continue; + } + String value = lov1.getValueOfKey(key); + map1.put(value, key);// <ʾֵ,ʵֵ> + if (key.equals(bean.getVal()) && (!bean.getVal().equals(""))) { + bean.setVal(value); + } + } + bean.setLov(map1); + } else { + bean.setIslov(false); + } + + classList.add(bean); + + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + + String[] revs = service.getStringValues("RB_Revision_id"); + if (revs == null || revs.length <= 0) { + MessageBox.post("ѡRB_Revision_idδ,ϵԱ!!", "", MessageBox.ERROR); + return; + } + + revComb = new JComboBox(); + revComb.addItem("B1"); + // Ż + revComb.setEditable(false); + // end + for (int j = 0; j < revs.length; j++) { + revComb.addItem(revs[j]); + } + + parentPanel.add(i + ".1.center.top", new JLabel("汾")); + parentPanel.add(i + ".2.center.top", revComb); + i += 1; + + labels1 = new JLabel[classList.size()]; + + for (int j = 0; j < classList.size(); j++, i++) { + ClassAttributeBean bean = classList.get(j); + labels1[j] = new JLabel(bean.getName()); + parentPanel.add(i + ".1.center.top", labels1[j]); + labels1[j].setBounds(5, 5, 5, 5); + String attrName = ""; + if ((bean.getName()).contains("\\")) { + attrName = (bean.getName()).split("\\\\")[0]; + System.out.println("attrName=============" + attrName); + } else { + attrName = bean.getName(); + } + if (bean.isIslov()) { + JComboBox comb = new JComboBox(); + // Ż + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + // end + comb.setEditable(false); + comb.setSize(new Dimension(60, 40)); + comb.addItem(bean.getVal()); + for (Entry entry : bean.getLov().entrySet()) { + if (!(bean.getVal().equals(entry.getKey()))) { + comb.addItem(entry.getKey()); + } + } + // Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + System.out.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(comb, tip); + } + } + + }); + // end + map2 = new HashMap(); + map2.put("JComboBox", comb); + values.add(map2); + parentPanel.add(i + ".2.center.top", comb); + parentPanel.add(i + ".3.center.top", jt); + parentPanel.add(i + ".4.center.top", bu); + + if (attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, comb); + lovMap.put(attrName, "yes"); + } + if (attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, comb); + lovMap2.put(attrName, "yes"); + } + if (attrMap3 != null) { + if (attrList3.contains(attrName) || esAttrList3.contains(attrName)) { + objMap3.put(attrName, comb); + lovMap3.put(attrName, "yes"); + } + if (attrList4.contains(attrName) || esAttrList4.contains(attrName)) { + objMap4.put(attrName, comb); + lovMap4.put(attrName, "yes"); + } + } + if ((PlmLocaleUtil.getString("Category")).equals(attrName)) { + typeList.add(comb); + } + } else { + JTextField field = new JTextField(18); + + map2 = new HashMap(); + map2.put("JTextField", field); + values.add(map2); + parentPanel.add(i + ".2.center.top", field); + if (bean.getVal() != null && bean.getVal() != "") { + field.setText(bean.getVal()); + } + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName)) { + JComboBox box = new JComboBox(); + // Ż + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + // end + box.addItem(" "); + String[] strs = new String[] { "C0", "C2", "C3", "C4", "C5" }; + for (int K = 0; K < strs.length; K++) { + box.addItem(strs[K]); + } + // Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + System.out.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(comb, tip); + } + } + + }); + // end + boxMap.put(attrName, box); + parentPanel.add((i) + ".3.center.top", box); + parentPanel.add((i) + ".3.center.top", jt); + parentPanel.add((i) + ".3.center.top", bu); + } + if (attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, field); + lovMap.put(attrName, "no"); + } + if (attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, field); + lovMap2.put(attrName, "no"); + } + if (attrMap3 != null) { + if (attrList3.contains(attrName) || esAttrList3.contains(attrName)) { + objMap3.put(attrName, field); + lovMap3.put(attrName, "no"); + } + if (attrList4.contains(attrName) || esAttrList4.contains(attrName)) { + objMap4.put(attrName, field); + lovMap4.put(attrName, "no"); + } + } + + } + + } + + // Ӷ + if (targetComp instanceof TCComponentItemRevision) { + targetRev = (TCComponentItemRevision) targetComp; + // List props = GetPros.getProps(targetRev); + Map realPros = GetPros.getRealPros(targetRev); + if (realPros != null) { + parentPanel.add(i + ".1.center.top", new JLabel(" ")); + parentPanel.add(i + ".2.center.top", new JLabel("**********************")); + int x = 0; + for (String sss : ZC_LBJ_list.ZCPros) { + + String realPro = sss; + String val = realPros.get(sss); + String disPro = ZC_LBJ_list.ZCDisPros.get(x); + x += 1; + if (ZC_LBJ_list.ZCPros.contains(realPro)) { + i += 1; + parentPanel.add(i + ".1.center.top", new JLabel(disPro)); + // жǷlov + + if (ZC_LBJ_list.map.containsKey(realPro)) { + try { + // жǷӦ + if (realPro.equals(yyly) || realPro.equals(scgc)) { + if (realPro.equals(yyly)) { + + String[] vals_list = targetRev.getTCProperty(realPro).getStringArrayValue(); + ; + strss = vals_list; + JComboBox nbox = new RwJComboBox(new String[] { "" }); + nbox.setEditable(true); + TCProperty zclov = targetRev.getTCProperty(realPro); + TCComponentListOfValues lov = zclov.getLOV(); + String[] vals = new String[vals_list.length]; + for (int u = 0; u < vals_list.length; u++) { + vals[u] = lov.getListOfValues().getDisplayableValue(vals_list[u]); + } + String[] disvals = lov.getListOfValues().getLOVDisplayValues(); + Map dis_real = LovUtils.valOf_real_dis(disvals, lov); + nbox = new RwJComboBox(disvals); + nbox.setEditable(true); + nbox.setSelectedIndex(-1); + RwJComboBox nbox2 = new RwJComboBox(new String[] { "" }); + nbox2.setEditable(true); + + StringBuilder sb = new StringBuilder(); + + if (vals.length > 0) { + for (int a = 0; a < vals.length; a++) { + if (a != vals.length - 1) { + sb.append(vals[a]); + sb.append(","); + } else { + sb.append(vals[a]); + } + } + } + + nbox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + // TODO Auto-generated method stub + RwJComboBox box = (RwJComboBox) e.getSource(); + // Object[] objs = box.getSelectedObjects(); + + System.out.println("nboxitem¼!"); + Set set = box.getSet(); + + int size = set.size(); + // System.out.println("sizeijΪ:"+size); + if (size > 0) { + List lists = new ArrayList(set); + String[] strs = new String[size]; + for (int h = 0; h < lists.size(); h++) { + System.out.println("ѡеΪ:" + (Integer) lists.get(h)); + strs[h] = (String) box.getItemAt((Integer) lists.get(h)); + } +// for(int h=0;h ss = msg.getSs(); + String[] sss = ss.toArray(new String[ss.size()]); + nbox2.removeAllItems(); + // nbox2.getSelectedIndex(); + nbox2.setEditable(true); + nbox2.setModel(new RwDefaultComboBoxModel(sss)); + nbox2.setSet(); + + nbox2.setSelectedIndex(-1); + + } else { + nbox2.removeAllItems(); + nbox2.setEditable(true); + } + } + }); + RwJComboBox nbox3 = new RwJComboBox(new String[] { "" }); + nbox3.setEditable(true); + nbox3.setName(realPro); + JTextField jt = (JTextField) nbox3.getEditor().getEditorComponent(); + if (sb != null) { + yyly_text = sb.toString(); + jt.setText(sb.toString()); + } + nbox2.addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + // TODO Auto-generated method stub + System.out.println("nbox2item¼!"); + RwJComboBox box = (RwJComboBox) e.getSource(); + // Object[] objs = box.getSelectedObjects(); + Set set = box.getSet(); + int size = set.size(); + if (size > 0) { + List lists = new ArrayList(set); + String[] strs = new String[size]; + for (int h = 0; h < lists.size(); h++) { + System.out.println("ѡеΪ:" + (Integer) lists.get(h)); + strs[h] = (String) box.getItemAt((Integer) lists.get(h)); + } + LovUtils.getLovObj2(strs, msg); + System.out.println("ӡmsgϢ:" + msg.toString()); + List sss = msg.getSss(); + String[] vals_strs = sss.toArray(new String[sss.size()]); + nbox3.removeAllItems(); + // nbox2.getSelectedIndex(); + nbox3.setEditable(true); + nbox3.setModel(new RwDefaultComboBoxModel(vals_strs)); + nbox3.setSet(); + nbox3.setSelectedIndex(-1); + } else { + nbox3.removeAllItems(); + nbox3.setEditable(true); + } + } + + }); + + parentPanel.add(i + ".2.center.top", nbox); + parentPanel.add(i + ".3.center.top", nbox2); + parentPanel.add(i + ".4.center.top", nbox3); + comboxList.add(nbox3); + } else { + String[] valss = targetRev.getTCProperty(realPro).getStringArrayValue(); + JComboBox nbox = new RwJComboBox(new String[] { "" }); + nbox.setEditable(true); + TCProperty zclov = targetRev.getTCProperty(realPro); + TCComponentListOfValues lov = zclov.getLOV(); + List disVal = new ArrayList(); + for (int a = 0; a < valss.length; a++) { + if (valss[a] != null && !valss[a].equals("")) { + String disname = lov.getListOfValues().getDisplayableValue(valss[a]); + disVal.add(disname); + } + } + if (lov != null) { + String[] comboxitems = lov.getListOfValues().getLOVDisplayValues(); + nbox = new RwJComboBox(comboxitems); + nbox.setEditable(true); + nbox.setName(realPro); + nbox.setSize(new Dimension(60, 40)); + for (String s : comboxitems) { + String lov_realValue = (String) lov.getListOfValues().getRealValue(s); + if (lov_realValue != null) { + scgc1_map.put(s, lov_realValue); + } + } + if (disVal.size() > 0) { + StringBuilder sb = new StringBuilder(); + for (int t = 0; t < disVal.size(); t++) { + if (t != (valss.length - 1)) { + sb.append(disVal.get(t)); + sb.append(","); + } else { + sb.append(disVal.get(t)); + } + } + JTextField ed = (JTextField) nbox.getEditor().getEditorComponent(); + ed.setText(sb.toString()); + } + comboxList.add(nbox); + } + parentPanel.add(i + ".2.center.top", nbox); + } + } else { + JComboBox zcBox = new JComboBox(); + zcBox.setSize(new Dimension(60, 40)); + zcBox.setName(realPro); + + TCProperty zclov = targetRev.getTCProperty(realPro); + TCComponentListOfValues lov = zclov.getLOV(); + JTextField jt = new JTextField(9); + JButton bu = new JButton(""); + if (lov != null) { + String[] disvals = lov.getListOfValues().getLOVDisplayValues(); + ComboBoxModel model = new DefaultComboBoxModel(disvals); + zcBox.setModel(model); + for (String s : disvals) { + String lov_realValue = (String) lov.getListOfValues().getRealValue(s); + if (lov_realValue != null) { + ptlov_map.put(s, lov_realValue); + } + } + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip = jt.getText(); + System.out.println("" + tip); + if (tip.length() > 0) { + SearchJComItem.changeBox(zcBox, tip); + } + } + + }); + comboxList.add(zcBox); + } + zcBox.setSelectedItem(val); + if (disPro.equals("ʱϱʶ")) { + zcBox.setSelectedIndex(-1); + } + parentPanel.add(i + ".2.center.top", zcBox); + parentPanel.add(i + ".3.center.top", jt); + parentPanel.add(i + ".4.center.top", bu); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else { + JTextField field = new JTextField(18); + field.setName(realPro); + field.setText(val); + parentPanel.add(i + ".2.center.top", field); + fieldList.add(field); + } + } + } + } + } + + JPanel southPanel = new JPanel(new FlowLayout()); + southPanel.setPreferredSize(new Dimension(250, 80)); + JButton button = new JButton(""); + JButton button1 = new JButton("ȡ"); + button.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // objList.clear(); + // objList2.clear(); + // lovList.clear(); + // lovList2.clear(); + createItem(); + // disposeDialog(); + } + + }); + button1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + + }); + southPanel.add(button); + southPanel.add(button1); + this.add("1.1.center.top", new JLabel(" ")); + this.add("2.1.center.top", classJpanel); + this.add("3.1.center.top", southPanel); + pack(); + centerToScreen(1.0D, 0.75D); + this.showDialog(); + } + + private void saveCOM2(String xmlClassName, Map> attrMap, List attrList, + List esAttrList, List markList, List defaultValueList, List isNList) { + if (attrMap.containsKey(xmlClassName)) { + List nameMarkList = attrMap.get(xmlClassName); + String attrNames = nameMarkList.get(0); + String marks = nameMarkList.get(1); + String values = nameMarkList.get(2); + String isN = nameMarkList.get(3); + if (attrNames.contains(";")) { + String[] attrs = attrNames.split(";"); + String[] markss = marks.split(";"); + String[] valuess = values.split(";"); + String[] isNs = isN.split(";"); + for (int i = 0; i < attrs.length; i++) { + if (attrs[i].contains("+")) { + String[] attrss = attrs[i].split("\\+"); + attrList.add(attrss[0]); + esAttrList.add(attrss[1]); + markList.add(markss[i]); + defaultValueList.add(valuess[i]); + isNList.add(isNs[i]); + } + } + } + } + } + + private void saveCOM(String xmlClassName, Map> attrMap, List attrList, + List esAttrList, List markList, List isNList) { + if (attrMap.containsKey(xmlClassName)) { + List nameMarkList = attrMap.get(xmlClassName); + String attrNames = nameMarkList.get(0); + String marks = nameMarkList.get(1); + String isN = nameMarkList.get(3); + if (attrNames.contains(";")) { + String[] attrs = attrNames.split(";"); + String[] markss = marks.split(";"); + String[] isNs = isN.split(";"); + for (int i = 0; i < attrs.length; i++) { + if (attrs[i].contains("+")) { + String[] attrss = attrs[i].split("\\+"); + attrList.add(attrss[0]); + esAttrList.add(attrss[1]); + markList.add(markss[i]); + isNList.add(isNs[i]); + } + } + } + } + } + + protected void createItem() { + + // TODO Auto-generated method stub + List zcList = null; + String jhID = ""; + if (classFlag) { + productNumber = splicValue(attrList, esAttrList, objMap, markList, isNList, lovMap); + drawingNumber = splicValue(attrList2, esAttrList2, objMap2, markList2, isNList2, lovMap2); + + System.out.println("productNumber============" + productNumber); + System.out.println("drawingNumber============" + drawingNumber); + if (productNumber == null || drawingNumber == null) { + return; + } + } + TCComponentItemRevision newRev = null; + String newID = ""; + try { + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent(targetType); + if (!flag) { + /* + * TCUserService userservice = session.getUserService(); Object[] params = { + * targetRev.getStringProperty("item_id").substring(0, 6), 7, 1, 9999, 1, "" }; + * try { String str = "";// DM,8,400,99999999,1,"" newID = (String) + * userservice.call("queryPartNo", params); + * System.out.println("newID==============="+newID); } catch (Exception e) { + * e.printStackTrace(); } + */ + String ssss = targetRev.getStringProperty("item_id"); + newID = ssss + "H"; + bsNumber = splicValue(attrList3, esAttrList3, objMap3, markList3, isNList3, lovMap3); + smNumber = splicValue(attrList4, esAttrList4, objMap4, markList4, isNList4, lovMap4); + System.out.println("bsNumber============" + bsNumber); + System.out.println("smNumber============" + smNumber); + if (bsNumber == null || smNumber == null) { + return; + } + } + String[] keys = new String[] { " ID" }; + String[] values = new String[] { newID }; + List compList = queryObject(" ID", keys, values); + if (compList != null) { + if (compList.size() > 0) { + // Ż + String nID = newID.substring(0, 2); + + for (int j = 0; j < compList.size(); j++) { + System.out.println("жitem_idǰλǷͬ"); + String compID = compList.get(j).getProperty("item_id"); + String cID = compID.substring(0, 2); + if (nID.equals(cID)) { + MessageBox.post("ϵͳѴڲƷΪ" + productNumber + "ϣ룡", "", + MessageBox.INFORMATION); + return; + } + } + } + // endŻ + } + + String revID = (String) revComb.getSelectedItem(); + String name = nameField.getText(); + TCComponentItem newItem = typeComponent.create(newID, revID, targetType, name, "", null); + if (newItem != null) { + session.getUser().getHomeFolder().add("contents", newItem); + session.getUser().getHomeFolder().refresh(); + } + String statu = ""; + if ("A1".equals(revID)) { + statu = ":Conceptual design"; + } else if ("B1".equals(revID)) { + statu = ":Product design"; + } else if ("R1".equals(revID)) { + statu = ":Process design/Sample delivery"; + } else if ("P1".equals(revID)) { + statu = "P:Pilot production/small batch"; + } else if ("M1".equals(revID)) { + statu = "M:Mass production"; + } + newRev = newItem.getLatestItemRevision(); + newRev.setStringProperty("rb3_th", drawingNumber); + newRev.setStringProperty("rb3_cph", productNumber); + newRev.setStringProperty("rb3_smzqzt", statu); + if (!("".equals(jhID))) { + newRev.setStringProperty("rb3_jh", jhID); + } + if (!("".equals(bsNumber))) { + newRev.setStringProperty("rb3_bsh", bsNumber); + newRev.setStringProperty("rb3_sm2", smNumber); + } + + for (int k = 0; k < fieldList.size(); k++) { + JTextField jt = (JTextField) fieldList.get(k); + String key = jt.getName(); + String val = jt.getText(); + fieldmap.put(key, val); + } + for (int m = 0; m < comboxList.size(); m++) { + JComboBox cbo = (JComboBox) comboxList.get(m); + String key = cbo.getName(); + System.out.println("comboxNameΪ:" + key); + if (key.equals(yyly) || key.equals(scgc)) { + if (key.equals(yyly)) { + RwJComboBox rjbox = (RwJComboBox) cbo; + Set set = rjbox.getSet(); + int size = set.size(); + if (size > 0) { + List lists = new ArrayList(set); + String[] strs = new String[size]; + Map valMap = msg.getValMap(); + if (valMap != null) { + for (int ob = 0; ob < lists.size(); ob++) { + String itemAt = (String) rjbox.getItemAt((Integer) lists.get(ob)); + String str = valMap.get(itemAt); + strs[ob] = str; + } + newRev.getTCProperty(key).setStringValueArray(strs); + } + + } else { + if (yyly_text != null) { + newRev.getTCProperty(key).setStringValueArray(strss); + } + } + } + if (key.equals(scgc)) { + JTextField ed = (JTextField) cbo.getEditor().getEditorComponent(); + String text = ed.getText(); + if (!text.equals("") && text != null) { + String[] split = text.split(","); + List proList = new ArrayList<>(); + for (String s : split) { + String realval = scgc1_map.get(s); + if (realval != null) { + proList.add(realval); + } + } + if (proList.size() > 0) { + Object[] array = proList.toArray(); + String[] svals = new String[array.length]; + for (int s = 0; s < array.length; s++) { + svals[s] = (String) array[s]; + } + newRev.getTCProperty(key).setStringValueArray(svals); + } + } + } + } else { + String val = (String) cbo.getSelectedItem(); + String real = ptlov_map.get(val); + comboxmap.put(key, real); + } + + } + newRev.setProperties(fieldmap); + newRev.setProperties(comboxmap); + + TCTypeService typeService = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) typeService.getTypeComponent("BOMWindow"); + // һµwindow + TCComponentBOMWindow view = winType.create(null); + if (flag) { + newRev.setStringProperty("rb3_lbjlx", type); + if (zcList != null) { + if (zcList.get(0) instanceof TCComponentItem) { + TCComponentItem zcItem = (TCComponentItem) zcList.get(0); + TCComponentItemRevision zcRev = zcItem.getLatestItemRevision(); + // + view.lock(); + // öbomline + TCComponentBOMLine line = view.setWindowTopLine(zcItem, zcRev, null, null); + // bomline + TCComponentBOMLine childBomline = line.add(newRev.getItem(), newRev, null, false, ""); + // + view.save(); + // + view.unlock(); + // ر + view.close(); + } + } + } else { + List revList = new ArrayList(); + // öbomline + TCComponentBOMLine line = view.setWindowTopLine(targetRev.getItem(), targetRev, null, null); + // BOMLINEµbomline + AIFComponentContext[] contexts = line.getChildren(); + for (AIFComponentContext context : contexts) { + InterfaceAIFComponent child = context.getComponent(); + if (child instanceof TCComponentBOMLine) { + TCComponentBOMLine childLine = (TCComponentBOMLine) child; + TCComponentItemRevision itemRevision = childLine.getItemRevision(); + revList.add(itemRevision); + } + } + // ر + view.close(); + view = winType.create(null); + // + view.lock(); + // öbomline + TCComponentBOMLine line1 = view.setWindowTopLine(newRev.getItem(), newRev, null, null); + for (TCComponentItemRevision revComp : revList) { + // bomline + TCComponentBOMLine childBomline = line1.add(revComp.getItem(), revComp, null, false, ""); + } + + // + view.save(); + // + view.unlock(); + // ر + view.close(); + newRev.setStringProperty("rb3_zclx", type); + } + TCComponent[] references = targetRev.getReferenceListProperty("TC_Is_Represented_By"); + for (int i = 0; i < references.length; i++) { + if (references[i] instanceof TCComponentItemRevision) { + TCComponentItemRevision pic = (TCComponentItemRevision) references[i]; + newRev.add("TC_Is_Represented_By", pic); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("wllcsb28_display.TITLE"), "ʾ", MessageBox.INFORMATION); + e.printStackTrace(); + return; + } + List vals = new ArrayList(); + for (Map value : values) { + for (Map.Entry entry : value.entrySet()) { + String type = entry.getKey(); + if (type.equals("JComboBox")) { + JComboBox comb1 = (JComboBox) entry.getValue(); + String val = (String) comb1.getSelectedItem(); + vals.add(val); + } else { + JTextField field1 = (JTextField) entry.getValue(); + String val = field1.getText(); + vals.add(val); + } + } + } + Integer[] classKeys = new Integer[classList.size()]; + String[] classVals = new String[classList.size()]; + System.out.println("size============================" + classList.size()); + for (int i = 0; i < labels1.length; i++) { + String val = vals.get(i); + if (val == null || val.trim() == "") { + continue; + } + String val2 = ""; + if (classList.get(i).isIslov()) { + val2 = classList.get(i).getLov().get(val);// ʵֵ + System.out.println("val2================" + val2); + System.out.println("val================" + val); + } else { + val2 = val; + } + classKeys[i] = classList.get(i).getId(); + String attrName = classList.get(i).getName(); + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName) + || (PlmLocaleUtil.getString("PartNumber")).equals(attrName)) { + if ("".equals(val2.trim())) { + JComboBox box = boxMap.get(attrName); + val2 = (String) box.getSelectedItem(); + } + } + classVals[i] = val2; + } + sendObjToClassficationByWebService(className, newRev, classKeys, classVals);// ͷ + disposeDialog(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("wllccg28_display.TITLE"), "", MessageBox.INFORMATION); + + } + + /** + * ͷ + */ + public void sendObjToClassficationByWebService(String class_id, TCComponentItemRevision rev, Integer[] keys, + String[] vals) { + try { + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList(); + + for (int i = 0; i < keys.length; i++) { + + if (keys[i] != null && vals[i] != null) { + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + } + // +++9-28 + new Thread() { + @Override + public void run() { + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + }.start(); + // +++ + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * ͨѯѯĿ + * + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("myzdcx19_display.TITLE") + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + return null; + } + } + + public String splicValue(List attrList, List esAttrList, Map map, + List markList, List isNList, Map lovMap) { + // List asList = Arrays.asList(lovVal); + // List esList = Arrays.asList(esLovVal); + List objList = new ArrayList(); + List lovList = new ArrayList(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < attrList.size(); i++) { + String attr = attrList.get(i); + System.out.println("attr======112" + attr); + String esAttr = esAttrList.get(i); + if (map.get(attr) == null && map.get(esAttr) == null) { + if ((PlmLocaleUtil.getString("PartNumber")).equals(attr) + || (PlmLocaleUtil.getString("PartNumber")).equals(esAttr)) { + JComboBox idbox = boxMap.get(PlmLocaleUtil.getString("PartNumber")); + JTextField idfield = (JTextField) idList.get(0); + String fieldText = idfield.getText(); + String boxText = (String) idbox.getSelectedItem(); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post( + PlmLocaleUtil.getString("PartNumber") + rb.getString("bntstxlgz28_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + return null; + } +// if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { +// MessageBox.post(PlmLocaleUtil.getString("PartNumber")+"дһֵ", "ʾ", MessageBox.INFORMATION); +// return null; +// } + if (!("".equals(fieldText.trim()))) { + objList.add(idfield); + lovList.add("no"); + } else { + objList.add(idbox); + lovList.add("yes"); + } + continue; + } + objList.add(defaultValueList.get(i)); + lovList.add("string"); + continue; + } + if (!("".equals(attr.trim()))) { + Object obj = map.get(attr); + JComboBox box = null; + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attr)) { + box = boxMap.get(attr); + } + if ((PlmLocaleUtil.getString("RadialInternalClearance")).equals(esAttr)) { + box = boxMap.get(esAttr); + } + if (obj == null) { + obj = map.get(esAttr); + if (box != null) { + JTextField field = (JTextField) obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(esAttr + rb.getString("bntstxlgz28_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + return null; + } + if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(esAttr + rb.getString("bxtxygz28_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + } else { + objList.add(box); + lovList.add("yes"); + } + } else { + objList.add(obj); + lovList.add(lovMap.get(esAttr)); + } + } else { + if (box != null) { + JTextField field = (JTextField) obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + if (!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(attr + rb.getString("bntstxlgz28_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + return null; + } + if ("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(attr + rb.getString("bxtxygz28_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + return null; + } + if (!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + } else { + objList.add(box); + lovList.add("yes"); + } + } else { + objList.add(obj); + lovList.add(lovMap.get(attr)); + } + } + } + } + for (int i = 0; i < objList.size(); i++) { + String attrValue = ""; + Object obj = objList.get(i); + if (obj != null) { + if ("yes".equals(lovList.get(i))) { + String value = (String) ((JComboBox) obj).getSelectedItem(); + if (asList.contains(value) || esList.contains(value)) { + if (isNList.get(i).trim().contains(value)) { + if (value.contains(":")) { + System.out.println("value============" + value); + String[] values = value.split(":"); + value = values[0]; + } else if (value.contains("")) { + System.out.println("value============" + value); + String[] values = value.split(""); + value = values[0]; + } + } else { + value = ""; + } + } else { + if (value.contains(":")) { + System.out.println("value============" + value); + String[] values = value.split(":"); + value = values[0]; + } else if (value.contains("")) { + System.out.println("value============" + value); + String[] values = value.split(""); + value = values[0]; + } + } + if ("Ʒ".equals(value) || "Finished product".equals(value)) { + value = ""; + } else if ("".equals(value) || "Turning workpiece".equals(value)) { + value = "C"; + } else if ("ȴ".equals(value) || "Heat treatment parts".equals(value)) { + value = "R"; + } else if ("շ伷".equals(value) || "Cold rolled parts or cold extrusion parts".equals(value)) { + value = "D"; + } else if ("ͼ".equals(value) || "Forge piece".equals(value)) { + value = "D"; + } + attrValue = value; + } else if ("no".equals(lovList.get(i))) { + attrValue = ((JTextField) obj).getText(); + + } else { + attrValue = (String) obj; + } + if (asList.contains(attrValue) || esList.contains(attrValue)) { + attrValue = ""; + } else { + if (attrValue.contains(":")) { + System.out.println("attrValue============" + attrValue); + String[] values = attrValue.split(":"); + attrValue = values[0]; + } else if (attrValue.contains("")) { + System.out.println("attrValue============" + attrValue); + String[] values = attrValue.split(""); + attrValue = values[0]; + } + } + + String mark = markList.get(i); + System.out.println("mark============" + mark); + if (!("".equals(attrValue.trim())) && mark != null) { + sb.append(mark.trim()); + sb.append(attrValue); + } + } + } + return sb.toString(); + } +} diff --git a/src/com/connor/rb/plm/rb028/CreateHandlerNew.java b/src/com/connor/rb/plm/rb028/CreateHandlerNew.java new file mode 100644 index 0000000..5c9cee9 --- /dev/null +++ b/src/com/connor/rb/plm/rb028/CreateHandlerNew.java @@ -0,0 +1,43 @@ +package com.connor.rb.plm.rb028; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.rb.plm.rb007.Rb007Action; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.util.MessageBox; + +public class CreateHandlerNew extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (targetComponent instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) targetComponent; + System.out.println("rev.getType()=====" + rev.getType()); + if ("RB3_ZCRevision".equals(rev.getType())) { + CreateDialogNew dialog = new CreateDialogNew(app); + new Thread(dialog).start(); + } else { + MessageBox.post(rb.getString("qxzzcbb28_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return null; + } + } else { + MessageBox.post(rb.getString("qxzbbdxjxcj28_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return null; + } + + return null; + } + +} diff --git a/src/com/connor/rb/plm/rb028/GetPros.java b/src/com/connor/rb/plm/rb028/GetPros.java new file mode 100644 index 0000000..6e72b0a --- /dev/null +++ b/src/com/connor/rb/plm/rb028/GetPros.java @@ -0,0 +1,81 @@ +package com.connor.rb.plm.rb028; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.soa.exceptions.NotLoadedException; + +public class GetPros { + + // ȡ汾Եļֵ + public static Map getRealPros(TCComponentItemRevision revision) { + Map properties = null; + try { + properties = revision.getProperties(); + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (properties != null) { + return properties; + } else { + return null; + } + } + + // ȡ汾Եʾ + public static List getDisPros(TCComponentItemRevision revision) { + Map realPros = getRealPros(revision); + Set keySet = realPros.keySet(); + List lists = new ArrayList(); + for (String s : keySet) { + try { + String disVal = revision.getPropertyDisplayableValue(s); + lists.add(disVal); + } catch (NotLoadedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if (lists.size() > 0) { + return lists; + } else { + return null; + } + } + + public static List getProps(TCComponentItemRevision revision) { + Map properties = null; + List props = new ArrayList(); + try { + properties = revision.getProperties();// ֵֵ + Set keySet = properties.keySet(); + for (String s : keySet) { + ReProps pro = new ReProps(); + // String disVal = revision.getPropertyDisplayableValue(s); + TCComponentType typeComponent = revision.getTypeComponent(); + String disVal = typeComponent.getPropertyDescriptor(s).getDisplayName(); + String val = properties.get(s); + pro.setDisPro(disVal); + pro.setRealPro(s); + pro.setVal(val); + props.add(pro); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (props.size() > 0) { + return props; + } else { + return null; + } + } + +} diff --git a/src/com/connor/rb/plm/rb028/LovMsg.java b/src/com/connor/rb/plm/rb028/LovMsg.java new file mode 100644 index 0000000..ab95038 --- /dev/null +++ b/src/com/connor/rb/plm/rb028/LovMsg.java @@ -0,0 +1,71 @@ +package com.connor.rb.plm.rb028; + +import java.util.List; +import java.util.Map; + +import com.teamcenter.rac.kernel.TCComponentListOfValues; + +public class LovMsg { + private List ss; + private Map lovMap = null; + private List sss; + private Map valMap = null; + private Map lov4Map = null; + + public List getSss() { + return sss; + } + + public void setSss(List sss) { + this.sss = sss; + } + + public Map getValMap() { + return valMap; + } + + public void setValMap(Map valMap) { + this.valMap = valMap; + } + + private List lovs; + + public Map getLov4Map() { + return lov4Map; + } + + public void setLov4Map(Map lov4Map) { + this.lov4Map = lov4Map; + } + + public List getLovs() { + return lovs; + } + + public void setLovs(List lovs) { + this.lovs = lovs; + } + + public List getSs() { + return ss; + } + + public void setSs(List ss) { + this.ss = ss; + } + + public Map getLovMap() { + return lovMap; + } + + public void setLovMap(Map lovMap) { + this.lovMap = lovMap; + } + + @Override + public String toString() { + return "LovMsg [ss=" + ss + ", lovMap=" + lovMap + ", sss=" + sss + ", valMap=" + valMap + ", lov4Map=" + + lov4Map + ", lovs=" + lovs + "]"; + } + +} diff --git a/src/com/connor/rb/plm/rb028/LovUtils.java b/src/com/connor/rb/plm/rb028/LovUtils.java new file mode 100644 index 0000000..dc4b271 --- /dev/null +++ b/src/com/connor/rb/plm/rb028/LovUtils.java @@ -0,0 +1,95 @@ +package com.connor.rb.plm.rb028; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCException; + +public class LovUtils { + public static void getLovObj(TCComponentListOfValues lov, String[] ss, LovMsg msg) { + try { + // String[] vals = lov.getListOfValues().getStringListOfValues(); + List l = new ArrayList(); + Map map1 = new HashMap(); + Map map2 = new HashMap(); + // List lovList=new + // ArrayList(); + for (String s : ss) { + String realValue = (String) lov.getListOfValues().getRealValue(s); + System.out.println(realValue); + TCComponentListOfValues zilov = lov.getListOfFilterOfValue(realValue); + String[] vals1 = zilov.getListOfValues().getStringListOfValues(); + String[] disVals = zilov.getListOfValues().getLOVDisplayValues(); + + for (int i = 0; i < vals1.length; i++) { + // System.out.println(vals1[i]); + // System.out.println(disVals[i]); + + map1.put(disVals[i], vals1[i]); + map2.put(disVals[i], zilov); + l.add(disVals[i]); + } + + } + // msg.setLovs(lovList); + msg.setLovMap(map1); + msg.setLov4Map(map2); + msg.setSs(l); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public static void getLovObj2(String[] ss, LovMsg msg) { + System.out.println("getLovObj2!"); + Map lovmap = msg.getLov4Map(); + if (lovmap == null) { + return; + } + List strs = new ArrayList(); + Map valMap = new HashMap(); + for (String s : ss) { + TCComponentListOfValues lov = lovmap.get(s); + try { + String realValue = (String) lov.getListOfValues().getRealValue(s); + TCComponentListOfValues zilov = lov.getListOfFilterOfValue(realValue); + String[] disVals = zilov.getListOfValues().getLOVDisplayValues(); + String[] realVals = zilov.getListOfValues().getStringListOfValues(); + if (disVals.length > 0) { + for (int i = 0; i < disVals.length; i++) { + + strs.add(disVals[i]); + valMap.put(disVals[i], realVals[i]); + } + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + msg.setValMap(valMap); + msg.setSss(strs); + + } + + public static Map valOf_real_dis(String[] ss, TCComponentListOfValues lov) { + Map map = new HashMap(); + for (String s : ss) { + try { + String realVal = (String) lov.getListOfValues().getRealValue(s); + map.put(s, realVal); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return map; + } + +} diff --git a/src/com/connor/rb/plm/rb028/ReProps.java b/src/com/connor/rb/plm/rb028/ReProps.java new file mode 100644 index 0000000..6ab5ec8 --- /dev/null +++ b/src/com/connor/rb/plm/rb028/ReProps.java @@ -0,0 +1,37 @@ +package com.connor.rb.plm.rb028; + +public class ReProps { + private String realPro; + private String val; + private String disPro; + + public String getRealPro() { + return realPro; + } + + public void setRealPro(String realPro) { + this.realPro = realPro; + } + + public String getVal() { + return val; + } + + public void setVal(String val) { + this.val = val; + } + + public String getDisPro() { + return disPro; + } + + public void setDisPro(String disPro) { + this.disPro = disPro; + } + + @Override + public String toString() { + return "ReProps [realPro=" + realPro + ", val=" + val + ", disPro=" + disPro + "]"; + } + +} diff --git a/src/com/connor/rb/plm/rb029/LovUtil.java b/src/com/connor/rb/plm/rb029/LovUtil.java new file mode 100644 index 0000000..dc289b9 --- /dev/null +++ b/src/com/connor/rb/plm/rb029/LovUtil.java @@ -0,0 +1,334 @@ +package com.connor.rb.plm.rb029; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.soa.client.model.LovValue; + +public class LovUtil { + + private static Logger logger = LoggerFactory.getLogger(LovUtil.class); + + public static void setTCArrProperty(TCProperty property, String[] value) { + try { + if (value == null) { + return; + } + TCPropertyDescriptor descriptor = property.getPropertyDescriptor(); + boolean isArray = descriptor.isArray(); + if (isArray) { + property.setStringValueArray(value); + } + } catch (Exception e) { + logger.info("ֵ쳣", e); + } + } + + /** + * + * @param property + * @param value + * @throws TCException + */ + public static void setTCProperty(TCProperty property, String value) { + try { + TCPropertyDescriptor descriptor = property.getPropertyDescriptor(); + boolean isArray = descriptor.isArray(); + if (!isArray) { + switch (descriptor.getType()) { + + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + property.setStringValueData(value); + break; + case TCProperty.PROP_char: + if (value.length() > 0) { + property.setCharValueData(value.charAt(0)); + } + break; + case TCProperty.PROP_double: + property.setDoubleValueData(Double.parseDouble(value)); + break; + case TCProperty.PROP_float: + property.setFloatValueData(Float.parseFloat(value)); + break; + case TCProperty.PROP_int: + case TCProperty.PROP_short: + property.setIntValueData(Integer.parseInt(value)); + break; + case TCProperty.PROP_logical: + property.setLogicalValueData(Boolean.parseBoolean(value)); + break; + case TCProperty.PROP_date: + try { + if (!value.isEmpty()) { + property.setDateValueData(new SimpleDateFormat("yyyy/MM/dd").parse(value)); + } + } catch (ParseException e) { + e.printStackTrace(); + } + break; + } + } else { + if (value.indexOf(",") > 0) { + property.setStringValueArray(value.split(",")); + } else { + property.setStringValueArray(new String[] { value }); + } + // System.out.println("ӦΪͣԴ"); + } + } catch (Exception e) { + logger.info("ֵ쳣", e); + } + + } + + public static Map getLovThree(TCSession session, String lovName) { + Map notSaveAsMap = new HashMap(); + Map SaveAsMap = new HashMap(); + notSaveAsMap.clear(); + SaveAsMap.clear(); + try { + TCComponentListOfValues lov = TCComponentListOfValuesType.findLOVByName(session, lovName); + if (lov != null) { + ListOfValuesInfo lovInfo = lov.getListOfValues(); + System.out.println("lovInfo:" + lovInfo); + String[] size = lovInfo.getLOVDisplayValues(); + for (int i = 0; i < size.length; i++) { + TCComponentListOfValues Component = lovInfo.getListOfFilters()[i]; + ListOfValuesInfo child = Component.getListOfValues(); + String[] arr = child.getLOVDisplayValues(); + System.out.println("size:" + size[i]); + System.out.println("Component:" + Component); + System.out.println("arr:" + arr.length); + notSaveAsMap.put(size[i], arr); + for (int j = 0; j < arr.length; j++) { +// if(!"H8_ckxd_LOV".equals(child.toString())) { +// continue; +// } + TCComponentListOfValues children = child.getListOfFilters()[j]; + ListOfValuesInfo childs = children.getListOfValues(); + String[] number = childs.getLOVDisplayValues(); + SaveAsMap.put(arr[j], number); + } + } + return SaveAsMap; + } + } catch (TCException e) { + e.printStackTrace(); + } + return null; + } + + public static Map getLovThreeRealValue(TCSession session, String lovName) { + Map SaveAsMap = new HashMap(); + SaveAsMap.clear(); + try { + TCComponentListOfValues lov = TCComponentListOfValuesType.findLOVByName(session, lovName); + if (lov != null) { + ListOfValuesInfo lovInfo = lov.getListOfValues(); + String[] size = lovInfo.getLOVDisplayValues(); + for (int i = 0; i < size.length; i++) { + TCComponentListOfValues Component = lovInfo.getListOfFilters()[i]; + ListOfValuesInfo child = Component.getListOfValues(); + String[] arr = child.getLOVDisplayValues(); + for (int j = 0; j < arr.length; j++) { + + TCComponentListOfValues children = child.getListOfFilters()[j]; + ListOfValuesInfo childs = children.getListOfValues(); + String[] number = childs.getLOVDisplayValues(); + List values = childs.getValues(); + for (int k = 0; k < number.length; k++) { + SaveAsMap.put(number[k], values.get(k).getStringValue()); + } + } + } + return SaveAsMap; + } + } catch (TCException e) { + e.printStackTrace(); + } + return null; + } + + public static Map getLovTWO(TCSession session, String lovName) { + Map notSaveAsMap = new HashMap(); + Map SaveAsMap = new HashMap(); + notSaveAsMap.clear(); + SaveAsMap.clear(); + try { + TCComponentListOfValues lov = TCComponentListOfValuesType.findLOVByName(session, lovName); + if (lov != null) { + ListOfValuesInfo lovInfo = lov.getListOfValues(); + System.out.println("lovInfo:" + lovInfo); + String[] size = lovInfo.getLOVDisplayValues(); + for (int i = 0; i < size.length; i++) { + TCComponentListOfValues Component = lovInfo.getListOfFilters()[i]; + ListOfValuesInfo child = Component.getListOfValues(); + String[] arr = child.getLOVDisplayValues(); + System.out.println("size:" + size[i]); + System.out.println("Component:" + Component); + System.out.println("arr:" + arr.length); + notSaveAsMap.put(size[i], arr); + } + return notSaveAsMap; + } + } catch (TCException e) { + e.printStackTrace(); + } + return null; + } + + public static Map getPropertyone(TCSession session, String lovName) { + Map notSaveAsMap = new HashMap(); + notSaveAsMap.clear(); + try { + TCComponentListOfValues lov = TCComponentListOfValuesType.findLOVByName(session, lovName); + if (lov != null) { + ListOfValuesInfo lovInfo = lov.getListOfValues(); + System.out.println("lovInfo:" + lovInfo); + String[] size = lovInfo.getStringListOfValues(); + String[] arr = lovInfo.getLOVDisplayValues(); + for (int i = 0; i < size.length; i++) { + System.out.println("size:" + size[i]); + notSaveAsMap.put(arr[i], size[i]); + } + return notSaveAsMap; + } + } catch (TCException e) { + e.printStackTrace(); + } + + return null; + } + + public static Map getLov(TCSession session, String lovName) { + Map SaveAsMap = new LinkedHashMap(); + SaveAsMap.clear(); + try { + TCComponentListOfValues lov = TCComponentListOfValuesType.findLOVByName(session, lovName); + if (lov != null) { + ListOfValuesInfo lovInfo = lov.getListOfValues(); + + System.out.println("lovInfo:" + lovInfo); + String[] size = lovInfo.getLOVDisplayValues(); + for (int i = 0; i < size.length; i++) { + TCComponentListOfValues Component = lovInfo.getListOfFilters()[i]; + ListOfValuesInfo child = Component.getListOfValues(); + System.out.println("size:" + size[i]); + System.out.println("Component:" + Component); + SaveAsMap.put(size[i], Component.toString()); + } + return SaveAsMap; + + } + } catch (TCException e) { + e.printStackTrace(); + } + return null; + } + + public static Map getPropertytwo(TCSession session, String lovName) { + Map SaveAsMap = new HashMap(); + SaveAsMap.clear(); + try { + TCComponentListOfValues lov = TCComponentListOfValuesType.findLOVByName(session, lovName); + if (lov != null) { + ListOfValuesInfo lovInfo = lov.getListOfValues(); + System.out.println("lovInfo:" + lovInfo); + String[] size = lovInfo.getLOVDisplayValues(); + for (int i = 0; i < size.length; i++) { + TCComponentListOfValues Component = lovInfo.getListOfFilters()[i]; + ListOfValuesInfo child = Component.getListOfValues(); + String[] arr = child.getStringListOfValues(); + String[] arrs = child.getLOVDisplayValues(); + System.out.println("size:" + size[i]); + System.out.println("Component:" + Component); + System.out.println("child:" + child); + for (int j = 0; j < arr.length; j++) { + System.out.println("arr:" + arr[j]); + System.out.println("arrs:" + arrs[j]); + SaveAsMap.put(arrs[j], arr[j]); + } + } + System.out.println(SaveAsMap.toString()); + return SaveAsMap; + + } + } catch (TCException e) { + e.printStackTrace(); + } + return null; + } + + public static Map getPropertythree(TCSession session, String lovName) { + Map SaveAsMap = new HashMap(); + SaveAsMap.clear(); + try { + TCComponentListOfValues lov = TCComponentListOfValuesType.findLOVByName(session, lovName); + if (lov != null) { + ListOfValuesInfo lovInfo = lov.getListOfValues(); + System.out.println("lovInfo:" + lovInfo); + String[] size = lovInfo.getLOVDisplayValues(); + for (int i = 0; i < size.length; i++) { + TCComponentListOfValues Component = lovInfo.getListOfFilters()[i]; + ListOfValuesInfo child = Component.getListOfValues(); + String[] arr = child.getStringListOfValues(); + System.out.println("size:" + size[i]); + System.out.println("Component:" + Component); + System.out.println("arr:" + arr.length); + for (int j = 0; j < arr.length; j++) { + TCComponentListOfValues children = Component.getListOfFilters()[j]; + ListOfValuesInfo childs = children.getListOfValues(); + String[] number = childs.getStringListOfValues(); + String[] numbers = childs.getLOVDisplayValues(); + for (int k = 0; k < number.length; k++) { + SaveAsMap.put(numbers[k], number[k]); + } + + } + } + return SaveAsMap; + } + } catch (TCException e) { + e.printStackTrace(); + } + return null; + } + + /** + * ȡLOVʵֵ + * + * @param session + * @param lovName + * @return + */ + public static String getLovRealValue(TCSession session, String lovName, String displayValue) { + try { + TCComponentListOfValues lov = TCComponentListOfValuesType.findLOVByName(session, lovName); + if (lov != null) { + ListOfValuesInfo lovInfo = lov.getListOfValues(); + System.out.println("lovInfo:" + lovInfo); + String realVal = (String) lovInfo.getRealValue(displayValue); + return realVal; + } + } catch (TCException e) { + logger.warn("ȡlovʵֵwarn", e); + } + return null; + } +} diff --git a/src/com/connor/rb/plm/rb029/Rb029Command.java b/src/com/connor/rb/plm/rb029/Rb029Command.java new file mode 100644 index 0000000..426ab74 --- /dev/null +++ b/src/com/connor/rb/plm/rb029/Rb029Command.java @@ -0,0 +1,26 @@ +package com.connor.rb.plm.rb029; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCSession; + +public class Rb029Command extends AbstractAIFCommand { + + private InterfaceAIFComponent[] targets; + + private final static Logger logger = LoggerFactory.getLogger(Rb029Operation.class); + + public Rb029Command(InterfaceAIFComponent[] targets) { + this.targets = targets; + } + + @Override + public void executeModal() throws Exception { + + super.executeModal(); + } + +} diff --git a/src/com/connor/rb/plm/rb029/Rb029Handler.java b/src/com/connor/rb/plm/rb029/Rb029Handler.java new file mode 100644 index 0000000..a281564 --- /dev/null +++ b/src/com/connor/rb/plm/rb029/Rb029Handler.java @@ -0,0 +1,34 @@ +package com.connor.rb.plm.rb029; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.rb.plm.rb023.Rb023Operation; +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 Rb029Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent[] targets = app.getTargetComponents(); + Rb029Operation operation = new Rb029Operation(session, targets); +// TestOperation operation = new TestOperation(session, targets); + session.queueOperation(operation); + +// Rb029Command command = new Rb029Command(targets); +// try { +// command.executeModal(); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + return null; + } + +} diff --git a/src/com/connor/rb/plm/rb029/Rb029Operation.java b/src/com/connor/rb/plm/rb029/Rb029Operation.java new file mode 100644 index 0000000..89d118f --- /dev/null +++ b/src/com/connor/rb/plm/rb029/Rb029Operation.java @@ -0,0 +1,147 @@ +package com.connor.rb.plm.rb029; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class Rb029Operation extends AbstractAIFOperation { + + private TCSession session; + private InterfaceAIFComponent[] targets; + + private final static Logger logger = LoggerFactory.getLogger(Rb029Operation.class); + + public Rb029Operation(TCSession session, InterfaceAIFComponent[] targets) { + this.session = session; + this.targets = targets; + } + + private final String[] columns = { "rb3_khmc", "rb3_khdj", "rb3_xmmc", "rb3_xmbh", "rb3_xmlx", "rb3_xmdj", "rb3_ms", + "rb3_sybw", "rb3_ptcxhsbmc" }; + + private HashMap map = new HashMap(); + + @Override + public void executeOperation() throws Exception { + for (InterfaceAIFComponent interfaceAIFComponent : targets) { + if (interfaceAIFComponent instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) interfaceAIFComponent; + logger.info("ʼ"); +// TCComponent form = rev.getRelatedComponent("IMAN_master_form_rev"); +// String one = (String) form.getTCProperty("h8_remark").getPropertyValue(); +// String two = (String)rev.getTCProperty("h8_ctsb").getPropertyValue(); +// TCProperty stringProperty = form.getTCProperty("h8_ctsb"); +// TCComponentListOfValues lov = stringProperty.getLOV(); +// String realVal = (String)lov.getListOfValues().getRealValue("豸"); +// Map propertyone = LovUtil.getPropertyone(session, "H8_ckxd_LOV"); +// System.err.println(); +// TCProperty stringProperty = form.getTCProperty("h8_testArray"); +// String[] stringArrayValue = stringProperty.getStringArrayValue(); +// Object propertyValue = stringProperty.getPropertyValue(); +// String[] test = (String[])propertyValue; +// TCProperty stringProperty2 = form.getTCProperty("h8_remark"); +// String propertyValue2 = (String) stringProperty2.getPropertyValue(); +// System.out.println(); +// String[] stringValueArray = stringProperty.getStringValueArray(); +// //form.setStringProperty("h8_ckxd", "danyi"); + + if ("RB3_XMKFRevision".equals(rev.getType())) { + TCComponent[] relatedComponents = null; + String[] eights = null; + String[] nines = null; + String[] tens = null; + String[] xmtds = null; + try { + for (int i = 0; i < columns.length; i++) { + String value = (String) rev.getTCProperty(columns[i]).getPropertyValue(); + map.put(columns[i], value); + logger.info("ԡ" + columns[i] + "ֵΪ" + value); + } + // 鷵 + Object eight = rev.getTCProperty("rb3_zclx").getPropertyValue(); + Object nine = rev.getTCProperty("rb3_scgc").getPropertyValue(); + Object ten = rev.getTCProperty("rb3_yyly").getPropertyValue(); + Object xmtd = rev.getTCProperty("rb3_xmtd").getPropertyValue(); + eights = (String[]) eight; + nines = (String[]) nine; + tens = (String[]) ten; + xmtds = (String[]) xmtd; + relatedComponents = rev.getRelatedComponents("RB3_GXWJJ"); + } catch (Exception e) { + logger.info("ȡֵ쳣", e); + } + for (TCComponent tcComponent : relatedComponents) { + String type = tcComponent.getType(); + if ("RB3_QRTRevision".equals(type) || "RB3_APQPRevision".equals(type) + || "RB3_JSFXWTDRevision".equals(type) || "RB3_WTDRevision".equals(type) + || "RB3_SYWTDRevision".equals(type)) { + logger.info("ʼֵ" + tcComponent.toString()); + if ("RB3_QRTRevision".equals(type) || "RB3_APQPRevision".equals(type)) { + try { + LovUtil.setTCArrProperty(tcComponent.getTCProperty("rb3_zclx1"), eights); + } catch (TCException e) { + logger.info("ûи쳣", e); + } + } else { + try { + LovUtil.setTCArrProperty(tcComponent.getTCProperty("rb3_zclx"), eights); + } catch (TCException e) { + logger.info("ûи쳣", e); + } + } + try { + LovUtil.setTCArrProperty(tcComponent.getTCProperty("rb3_scgc"), nines); + } catch (TCException e) { + logger.info("ûи쳣", e); + } + try { + LovUtil.setTCArrProperty(tcComponent.getTCProperty("rb3_yyly"), tens); + } catch (TCException e) { + logger.info("ûи쳣", e); + } + try { + LovUtil.setTCArrProperty(tcComponent.getTCProperty("rb3_xmtd"), xmtds); + } catch (TCException e) { + logger.info("ûи쳣", e); + } + for (String key : map.keySet()) { + try { + tcComponent.setStringProperty(key, map.get(key)); + // LovUtil.setTCProperty(tcComponent.getTCProperty(key),map.get(key)); + } catch (TCException e) { + logger.info("ûи쳣", e); + } + } + } + } + } + logger.info(""); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("sxgxwc29_display.TITLE"), "ʾ", 2); + } + } + + } + +} diff --git a/src/com/connor/rb/plm/rb029/TestOperation.java b/src/com/connor/rb/plm/rb029/TestOperation.java new file mode 100644 index 0000000..5c9d3ba --- /dev/null +++ b/src/com/connor/rb/plm/rb029/TestOperation.java @@ -0,0 +1,80 @@ +package com.connor.rb.plm.rb029; + +import java.util.HashMap; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class TestOperation extends AbstractAIFOperation { + + private TCSession session; + private InterfaceAIFComponent[] targets; + + private final static Logger logger = LoggerFactory.getLogger(Rb029Operation.class); + + public TestOperation(TCSession session, InterfaceAIFComponent[] targets) { + this.session = session; + this.targets = targets; + } + + private final String[] columns = { "h8_remark", "h8_Material_type", "h8_ckxd", "h8_ctsb", "h8_linghao", + "h8_material_class", "h8_material_source", "h8_ppsm", "source" }; + + @Override + public void executeOperation() throws Exception { + HashMap map = new HashMap(); + for (InterfaceAIFComponent interfaceAIFComponent : targets) { + if (interfaceAIFComponent instanceof TCComponentItemRevision) { + TCComponentItemRevision itemRev = (TCComponentItemRevision) interfaceAIFComponent; + System.out.println(); + TCComponent rev = null; + try { + rev = itemRev.getRelatedComponent("IMAN_master_form_rev"); + LovUtil.setTCProperty(rev.getTCProperty("h8_ctsb"), "ڳ豸"); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + if ("H8_wuliaoRevision".equals(itemRev.getType())) { + TCComponent[] relatedComponents = null; + String[] eights = null; + try { + for (int i = 0; i < columns.length; i++) { + String value = (String) rev.getTCProperty(columns[i]).getPropertyValue(); + map.put(columns[i], value); + logger.info("ԡ" + columns[i] + "ֵΪ" + value); + } + } catch (Exception e) { + logger.info("ȡֵ쳣", e); + } + // 鷵 + Object eight = rev.getTCProperty("h8_testArray").getPropertyValue(); + eights = (String[]) eight; + relatedComponents = itemRev.getRelatedComponents("IMAN_specification"); + for (TCComponent tcComponent : relatedComponents) { + TCComponent form = tcComponent.getRelatedComponent("IMAN_master_form_rev"); + for (String key : map.keySet()) { + try { + form.setStringProperty(key, map.get(key)); + // LovUtil.setTCProperty(form.getTCProperty(key),map.get(key)); + } catch (TCException e) { + logger.info("ûи쳣", e); + } + } + + LovUtil.setTCArrProperty(form.getTCProperty("h8_testArray"), eights); + } + } + } + } + + } + +} diff --git a/src/com/connor/rb/plm/rb030/CheckListCellRenderer.java b/src/com/connor/rb/plm/rb030/CheckListCellRenderer.java new file mode 100644 index 0000000..742417a --- /dev/null +++ b/src/com/connor/rb/plm/rb030/CheckListCellRenderer.java @@ -0,0 +1,48 @@ +package com.connor.rb.plm.rb030; + +import java.awt.Component; +import java.io.Serializable; + +import javax.swing.JCheckBox; +import javax.swing.JList; +import javax.swing.ListCellRenderer; +import javax.swing.UIManager; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; + +public class CheckListCellRenderer extends JCheckBox implements ListCellRenderer, Serializable { + protected static Border noFocusBorder; + + /** + * Constructs a default renderer object for an item in a list. + */ + public CheckListCellRenderer() { + super(); + if (noFocusBorder == null) { + noFocusBorder = new EmptyBorder(1, 1, 1, 1); + } + setOpaque(true); + setBorder(noFocusBorder); + } + + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, + boolean cellHasFocus) { + setComponentOrientation(list.getComponentOrientation()); + if (isSelected) { + setBackground(list.getSelectionBackground()); + setForeground(list.getSelectionForeground()); + } else { + setBackground(list.getBackground()); + setForeground(list.getForeground()); + } + if (value instanceof CheckValue) { + CheckValue ckValue = (CheckValue) value; + this.setText(ckValue.value == null ? "" : ckValue.value); + this.setSelected(ckValue.bolValue); + } + setEnabled(list.isEnabled()); + setFont(list.getFont()); + setBorder((cellHasFocus) ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder); + return this; + } +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/rb030/CheckValue.java b/src/com/connor/rb/plm/rb030/CheckValue.java new file mode 100644 index 0000000..65bb64f --- /dev/null +++ b/src/com/connor/rb/plm/rb030/CheckValue.java @@ -0,0 +1,14 @@ +package com.connor.rb.plm.rb030; + +public class CheckValue { + public boolean bolValue = false; + public String value = null; + + public CheckValue() { + } + + public CheckValue(boolean bolValue, String value) { + this.bolValue = bolValue; + this.value = value; + } +} diff --git a/src/com/connor/rb/plm/rb030/MultiComboBox.java b/src/com/connor/rb/plm/rb030/MultiComboBox.java new file mode 100644 index 0000000..15c54ca --- /dev/null +++ b/src/com/connor/rb/plm/rb030/MultiComboBox.java @@ -0,0 +1,209 @@ +package com.connor.rb.plm.rb030; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JTextField; +import javax.swing.UIManager; +import javax.swing.plaf.basic.BasicArrowButton; + +/** + * ѡ + * + */ +public class MultiComboBox extends JComponent implements ActionListener { + + private Object[] values; + private MultiPopup popup; + private JTextField editor; + protected JButton arrowButton; + + public MultiComboBox(Object[] value) { + values = value; + initComponent(); + } + + private void initComponent() { + this.setLayout(new BorderLayout()); + popup = new MultiPopup(values); + editor = new JTextField(); + editor.setBackground(Color.WHITE); + editor.setEditable(false); + editor.setPreferredSize(new Dimension(140, 22)); + editor.addActionListener(this); + arrowButton = createArrowButton(); + arrowButton.addActionListener(this); + add(editor, BorderLayout.WEST); + add(arrowButton, BorderLayout.CENTER); + } + + // ȡѡе + public Object[] getSelectedValues() { + return popup.getSelectedValues(); + } + + // Ҫѡеֵ + public void setSelectValues(Object[] selectvalues) { + popup.setSelectValues(selectvalues); + setText(selectvalues); + } + + private void setText(Object[] values) { + if (values.length > 0) { + String value = Arrays.toString(values); + value = value.replace("[", ""); + value = value.replace("]", ""); + editor.setText(value); + } else { + editor.setText(""); + } + } + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + if (!popup.isVisible()) { + popup.show(this, 0, getHeight()); + } + } + + protected JButton createArrowButton() { + JButton button = new BasicArrowButton(BasicArrowButton.SOUTH, UIManager.getColor("ComboBox.buttonBackground"), + UIManager.getColor("ComboBox.buttonShadow"), UIManager.getColor("ComboBox.buttonDarkShadow"), + UIManager.getColor("ComboBox.buttonHighlight")); + button.setName("ComboBox.arrowButton"); + return button; + } + + // ڲMultiPopup + + public class MultiPopup extends JPopupMenu implements ActionListener { + private Object[] values; + private List checkBoxList = new ArrayList(); + private JButton commitButton; + private JButton cancelButton; + + public MultiPopup(Object[] value) { + super(); + values = value; + initComponent(); + } + + private void initComponent() { + JPanel checkboxPane = new JPanel(); + JPanel buttonPane = new JPanel(); + this.setLayout(new BorderLayout()); + for (Object v : values) { + JCheckBox temp = new JCheckBox(v.toString()); + checkBoxList.add(temp); + } + + if (checkBoxList.get(0).getText().equals("ȫѡ")) { + checkBoxList.get(0).addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + if (checkBoxList.get(0).isSelected()) { + for (int i = 1; i < checkBoxList.size(); i++) { + if (!checkBoxList.get(i).isSelected()) { + checkBoxList.get(i).setSelected(true); + } + } + } else { + for (int i = 1; i < checkBoxList.size(); i++) { + if (checkBoxList.get(i).isSelected()) { + checkBoxList.get(i).setSelected(false); + } + } + } + } + }); + } + + checkboxPane.setLayout(new GridLayout(checkBoxList.size(), 1, 3, 3)); + for (JCheckBox box : checkBoxList) { + checkboxPane.add(box); + } + + commitButton = new JButton("ȷ"); + commitButton.addActionListener(this); + + cancelButton = new JButton("ȡ"); + cancelButton.addActionListener(this); + + buttonPane.add(commitButton); + buttonPane.add(cancelButton); + this.add(checkboxPane, BorderLayout.CENTER); + this.add(buttonPane, BorderLayout.SOUTH); + + } + + public void setSelectValues(Object[] values) { + if (values.length > 0) { + for (int i = 0; i < values.length; i++) { + for (int j = 0; j < checkBoxList.size(); j++) { + if (values[i].equals(checkBoxList.get(j).getText())) { + checkBoxList.get(j).setSelected(true); + } + } + } + setText(getSelectedValues()); + } + } + + public Object[] getSelectedValues() { + List selectedValues = new ArrayList(); + + if (checkBoxList.get(0).getText().equals("ȫѡ")) { + if (checkBoxList.get(0).isSelected()) { + for (int i = 1; i < checkBoxList.size(); i++) { + selectedValues.add(values[i]); + } + } else { + for (int i = 1; i < checkBoxList.size(); i++) { + if (checkBoxList.get(i).isSelected()) { + selectedValues.add(values[i]); + } + } + } + } else { + for (int i = 0; i < checkBoxList.size(); i++) { + if (checkBoxList.get(i).isSelected()) { + selectedValues.add(values[i]); + } + } + } + + return selectedValues.toArray(new Object[selectedValues.size()]); + } + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + Object source = arg0.getSource(); + if (source instanceof JButton) { + JButton button = (JButton) source; + if (button.equals(commitButton)) { + setText(getSelectedValues()); + popup.setVisible(false); + } else if (button.equals(cancelButton)) { + popup.setVisible(false); + } + } + } + + } + +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/rb030/MyComboBox.java b/src/com/connor/rb/plm/rb030/MyComboBox.java new file mode 100644 index 0000000..b0043a7 --- /dev/null +++ b/src/com/connor/rb/plm/rb030/MyComboBox.java @@ -0,0 +1,61 @@ +package com.connor.rb.plm.rb030; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Vector; + +import javax.swing.JComboBox; +import javax.swing.SwingUtilities; + +public class MyComboBox extends JComboBox implements ActionListener { + public MyComboBox() { + addItem(new CheckValue(false, "Select All")); + this.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + itemSelected(); + } + }); + } + + private void itemSelected() { + if (getSelectedItem() instanceof CheckValue) { + if (getSelectedIndex() == 0) { + selectedAllItem(); + } else { + CheckValue jcb = (CheckValue) getSelectedItem(); + jcb.bolValue = (!jcb.bolValue); + setSelectedIndex(getSelectedIndex()); + } + SwingUtilities.invokeLater(new Runnable() { + public void run() { + /* ѡкȻֵǰ״̬ */ + showPopup(); + } + }); + } + } + + private void selectedAllItem() { + boolean bl = false; + for (int i = 0; i < getItemCount(); i++) { + CheckValue jcb = (CheckValue) getItemAt(i); + if (i == 0) { + bl = !jcb.bolValue; + } + jcb.bolValue = (bl); + } + setSelectedIndex(0); + } + + /* ȡѡȡĶ */ + public Vector getComboVc() { + Vector vc = new Vector(); + for (int i = 1; i < getItemCount(); i++) { + CheckValue jcb = (CheckValue) getItemAt(i); + if (jcb.bolValue) { + vc.add(jcb.value); + } + } + return vc; + } +} diff --git a/src/com/connor/rb/plm/rb030/Rb030Dialog.java b/src/com/connor/rb/plm/rb030/Rb030Dialog.java new file mode 100644 index 0000000..f1b2378 --- /dev/null +++ b/src/com/connor/rb/plm/rb030/Rb030Dialog.java @@ -0,0 +1,479 @@ +package com.connor.rb.plm.rb030; + +import com.connor.rb.plm.newcombox.RwJComboBox; +import com.connor.rb.plm.rb029.LovUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import javax.swing.*; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; + +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 org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.Set; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.CalendarPanel; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class Rb030Dialog extends AbstractAIFDialog { + + private static Logger logger = LoggerFactory.getLogger(Rb030Dialog.class); + + private AbstractAIFApplication app; + private TCSession session; + private TCComponentItemRevision rev; + + public Rb030Dialog(AbstractAIFApplication app, InterfaceAIFComponent rev) { + super(false); + this.app = app; + this.rev = (TCComponentItemRevision) rev; + this.session = (TCSession) app.getSession(); + } + + private JScrollPane leftScroll; + private JScrollPane rightScroll; + private JSplitPane splitPane; + private JPanel rightPanel; + private JPanel buttonPanel; + private JButton okButton; + private JButton celButton; + + private LinkedHashMap map1 = new LinkedHashMap(); + private LinkedHashMap map2 = new LinkedHashMap(); + private LinkedHashMap map3 = new LinkedHashMap(); + private LinkedHashMap map4 = new LinkedHashMap(); + private HashMap map1Type = new HashMap(); + private HashMap map2Type = new HashMap(); + private HashMap map3Type = new HashMap(); + private HashMap map4Type = new HashMap(); + + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); + + final String[] centerArr = { "ͻ", "ͻȼ", "Ŀ", "Ŀ", "Ŀ", "Ŀȼ", "" }; + final String[] centerPro = { "rb3_khmc", "rb3_khdj", "rb3_xmmc", "rb3_xmbh", "rb3_xmlx", "rb3_xmdj", "rb3_ms" }; + private HashMap mapParent = new HashMap(); + + int uiType = 0; // 1,2,3,4ֱΪӶ + + @Override + public void run() { + init(); + getData(); + for (int i = 0; i < centerArr.length; i++) { + mapParent.put(centerArr[i], centerPro[i]); + } + } + + private void init() { + this.setTitle("CUPMӶ"); + rightPanel = new JPanel(new PropertyLayout()); + rightScroll = new JScrollPane(rightPanel); + // ڵ + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("CUPMӶ"); + // ڵ + DefaultMutableTreeNode gdNode = new DefaultMutableTreeNode("Ŀ-"); + DefaultMutableTreeNode fjNode = new DefaultMutableTreeNode("Ŀ-"); + DefaultMutableTreeNode shNode = new DefaultMutableTreeNode("Ŀ-ͨ"); + DefaultMutableTreeNode jzNode = new DefaultMutableTreeNode("Ŀ-"); + // ѶڵΪӽڵӵڵ + rootNode.add(gdNode); + rootNode.add(fjNode); + rootNode.add(shNode); + rootNode.add(jzNode); + // ʹøڵ㴴 + JTree tree = new JTree(rootNode); + // ʾڵ + tree.setShowsRootHandles(true); + // ڵɱ༭ + tree.setEditable(false); + // ýڵѡм + tree.addTreeSelectionListener(new TreeSelectionListener() { + @Override + public void valueChanged(TreeSelectionEvent e) { + if ("[CUPMӶ, Ŀ-]".equals(e.getPath().toString())) { + uiType = 1; + refreshRightPane(map1, map1Type); + + } else if ("[CUPMӶ, Ŀ-]".equals(e.getPath().toString())) { + uiType = 3; + refreshRightPane(map3, map3Type); + + } else if ("[CUPMӶ, Ŀ-ͨ]".equals(e.getPath().toString())) { + uiType = 2; + refreshRightPane(map2, map2Type); + + } else if ("[CUPMӶ, Ŀ-]".equals(e.getPath().toString())) { + uiType = 4; + refreshRightPane(map4, map4Type); + + } + } + }); + // 壬ΪڵչҪܴĿռʾҪһ + leftScroll = new JScrollPane(tree); + + rightScroll.setPreferredSize(new Dimension(640, 820)); + // ָ + splitPane = new JSplitPane(); + // ʾ + splitPane.setLeftComponent(leftScroll); + splitPane.setRightComponent(rightScroll); + // ָʾ ۵/չ Сť + splitPane.setOneTouchExpandable(true); + // ϶ָʱػ + splitPane.setContinuousLayout(true); + // ÷ָijʼλ + splitPane.setDividerLocation(188); + // + splitPane.revalidate(); + splitPane.setEnabled(false); + + buttonPanel = new JPanel(); + okButton = new JButton(""); + celButton = new JButton("ȡ"); + okButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent var1) { + try { + createItem(); + } catch (TCException | ParseException e) { + MessageBox.post(e.getMessage(), "ʾ", 2); + logger.warn("CUPMӶWARN:", e); + } + } + }); + celButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent var1) { + setVisible(false); + + } + }); + buttonPanel.add(okButton); + buttonPanel.add(celButton); + this.setLayout(new BorderLayout()); + this.add(BorderLayout.CENTER, splitPane); + this.add(BorderLayout.SOUTH, buttonPanel); + pack(); + centerToScreen(1.0D, 0.75D); + this.showDialog(); + + } + + /** + * + * + * @throws TCException + * @throws ParseException + */ + private void createItem() throws TCException, ParseException { + LinkedHashMap map = new LinkedHashMap(); + HashMap mapType = new HashMap(); + String revType = ""; + switch (uiType) { + case 1: + map = map1; + mapType = map1Type; + revType = "RB3_LGXM"; + break; + case 2: + map = map2; + mapType = map2Type; + revType = "RB3_TYXM"; + break; + case 3: + map = map3; + mapType = map3Type; + revType = "RB3_BSXXM"; + break; + case 4: + map = map4; + mapType = map4Type; + revType = "RB3_JZQXM"; + break; + default: + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(this, rb.getString("qxzycjdzdx30_display.TITLE"), "ʾ", 2); + return; + } + Component[] components = rightPanel.getComponents(); + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item"); + // id汾ͣƣ + System.out.println("Ҫİ汾Ϊ" + revType); + JTextField idFiled = (JTextField) components[1]; + JTextField nameFiled = (JTextField) components[3]; + String idValue = idFiled.getText(); + String nameValue = nameFiled.getText(); + if (idValue == null || nameValue == null || nameValue.isEmpty() || idValue.isEmpty()) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(this, rb.getString("qtxzdxdIDhmc30_display.TITLE"), "ʾ", 2); + return; + } + TCComponentItem newItem = itemType.create(rev.getStringProperty("item_id") + "." + idValue, "A", revType, + nameValue, "", null); + TCComponentFolder folder = session.getUser().getHomeFolder(); + folder.add("contents", newItem); + TCComponentItemRevision itemRevision = newItem.getLatestItemRevision(); + for (int i = 4; i < components.length; i++) { + String name = components[i].getName(); + if (name != null) { + if (components[i] instanceof JTextField) { + JTextField center = (JTextField) components[i]; + if ("Ӧ".equals(name)) { + // ͵ļLOV + String text = center.getText(); + if (!text.equals("") && text != null) { + Map lovThreeRealValue = LovUtil.getLovThreeRealValue(session, "RB3_YYLY"); + String[] split = text.split(","); + String[] svals = new String[split.length]; + for (int j = 0; j < svals.length; j++) { + svals[j] = lovThreeRealValue.get(split[j].trim()); + } + TCProperty tclov = itemRevision.getTCProperty(map.get(name)); + tclov.setStringValueArray(svals); + } + } else { + String value = center.getText(); + logger.info("µΪ" + map.get(name) + "===µֵΪ" + value); + itemRevision.setStringProperty(map.get(name), value); + // LovUtil.setTCProperty(itemRevision.getTCProperty(map.get(name)), value); + } + } else if (components[i] instanceof JComboBox) { + JComboBox combox = (JComboBox) components[i]; + if ("ܳ".equals(name)) { + // ͵LOV + JTextField ed = (JTextField) combox.getEditor().getEditorComponent(); + String text = ed.getText(); + if (!text.equals("") && text != null) { + List proList = new ArrayList<>(); + String[] split = text.split(","); + TCProperty tclov = itemRevision.getTCProperty(map.get(name)); + TCComponentListOfValues lov = tclov.getLOV(); + for (int p = 0; p < split.length; p++) { + String realVal = (String) lov.getListOfValues().getRealValue(split[p]); + proList.add(realVal); + } + String[] svals = new String[proList.size()]; + for (int s = 0; s < proList.size(); s++) { + svals[s] = proList.get(s); + } + tclov.setStringValueArray(svals); + } + } else { + Object selectedItem = combox.getSelectedItem(); + if (selectedItem != null) { +// String value = LovUtil.getPropertyone(session, mapType.get(name)).get(selectedItem.toString()); +// LovUtil.setTCProperty(itemRevision.getTCProperty(map.get(name)), value); + TCProperty tclov = itemRevision.getTCProperty(map.get(name)); + TCComponentListOfValues lov = tclov.getLOV(); + String realVal = (String) lov.getListOfValues().getRealValue(selectedItem.toString()); + logger.info("µΪ" + map.get(name) + "===µֵΪ" + realVal); + itemRevision.setStringProperty(map.get(name), realVal); + // LovUtil.setTCProperty(tclov, realVal); + } + } + } else if (components[i] instanceof DateButton) { + DateButton dateButton = (DateButton) components[i]; + String value = dateButton.getText(); + logger.info("µΪ" + map.get(name) + "===µֵΪ" + value); + if (value != null && !value.isEmpty()) { + itemRevision.setDateProperty(map.get(name), new SimpleDateFormat("yyyy/MM/dd").parse(value)); + } + // LovUtil.setTCProperty(itemRevision.getTCProperty(map.get(name)), value); + } + } + } + // ӶŵѡжBOM + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(rev.getItem(), rev, null, null); + bomWindow.lock(); + topline.lock(); + topline.add(newItem, itemRevision, null, false, ""); + topline.unlock(); + bomWindow.unlock(); + bomWindow.save(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(this, rb.getString("cjcg30_display.TITLE"), "ʾ", 2); + setVisible(false); + } + + /** + * ˢ´ + * + * @param ceneterColumns + */ + private void refreshRightPane(LinkedHashMap map, HashMap typeMap) { + rightPanel.removeAll(); + rightPanel.setVisible(false); + JLabel idlabel = new JLabel("ID"); + rightPanel.add("1.1.center.center", idlabel); + JTextField idfile = new JTextField(""); + idfile.setName("ID"); + idfile.setPreferredSize(new Dimension(200, 30)); + rightPanel.add("1.2.center.center", idfile); + JLabel namelabel = new JLabel(""); + rightPanel.add("2.1.center.center", namelabel); + JTextField namefile = new JTextField(""); + namefile.setName(""); + namefile.setPreferredSize(new Dimension(200, 30)); + rightPanel.add("2.2.center.center", namefile); + int i = 3; + for (String key : map.keySet()) { + try { + if (key.isEmpty()) { + continue; + } + JLabel label = new JLabel(key); + rightPanel.add(i + ".1.center.center", label); + JTextField file = new JTextField(""); + if ("String".equals(typeMap.get(key)) || typeMap.get(key).contains("RB3_YYLY")) { + file.setPreferredSize(new Dimension(200, 30)); + file.setName(key); + rightPanel.add(i + ".2.center.center", file); + } else if (typeMap.get(key).contains("")) { + JComboBox nbox = new RwJComboBox(new String[] { "" }); + nbox.setEditable(true); + String lovName = typeMap.get(key).split(" ")[0]; + logger.info("lovΪ:" + lovName); + TCComponentListOfValues lov = TCComponentListOfValuesType.findLOVByName(session, lovName); + String[] comboxitems = lov.getListOfValues().getLOVDisplayValues(); + nbox = new RwJComboBox(comboxitems); + nbox.setEditable(true); + nbox.setName(key); + nbox.setPreferredSize(new Dimension(200, 30)); + rightPanel.add(i + ".2.center.center", nbox); + + } else if ("Date".equals(typeMap.get(key))) { + DateButton createDataStartButton = new DateButton(dateFormat); + createDataStartButton.setText(null); + createDataStartButton.setName(key); + createDataStartButton.setPreferredSize(new Dimension(200, 30)); + rightPanel.add(i + ".2.center.center", createDataStartButton); + } else { + JComboBox comBox = new JComboBox(); + comBox.setName(key); + comBox.setPreferredSize(new Dimension(200, 30)); + logger.info("lovΪ:" + typeMap.get(key)); + TCComponentListOfValues lov = TCComponentListOfValuesType.findLOVByName(session, typeMap.get(key)); + String[] comboxitems; + comboxitems = lov.getListOfValues().getLOVDisplayValues(); + for (int j = 0; j < comboxitems.length; j++) { + comBox.addItem(comboxitems[j]); + } + + rightPanel.add(i + ".2.center.center", comBox); + } + if ("Ӧ".equals(key)) { + JButton button = new JButton(""); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent var1) { + new Thread(new Rb030YylyDialog(app, file)).start(); + } + }); + rightPanel.add(i + ".3.center.center", button); + } + // ӸĬֵ + if (mapParent.containsKey(key)) { + TCProperty property = rev.getTCProperty(mapParent.get(key)); + file.setText(property == null ? "" : (String) property.getPropertyValue()); + } + i++; + } catch (Exception e) { + logger.warn("ӿؼwarn things ", e); + } + } + rightPanel.setVisible(true); + rightPanel.validate(); + rightPanel.repaint(); + rightScroll.validate(); + } + + /** + * õӶԺԶӦʵֵϤΪlov飬string + */ + private void getData() { + InputStream fis = this.getClass().getResourceAsStream("/ĿӶ.xlsx");// õsrc· + try { + XSSFWorkbook wb = new XSSFWorkbook(fis); + XSSFSheet xssfSheet = wb.getSheetAt(0); + int rows = xssfSheet.getPhysicalNumberOfRows(); + for (int i = 2; i < rows; i++) { + XSSFRow row = xssfSheet.getRow(i); + XSSFCell cell0 = row.getCell(0); + XSSFCell cell1 = row.getCell(1); + XSSFCell cell2 = row.getCell(2); + XSSFCell cell4 = row.getCell(4); + XSSFCell cell5 = row.getCell(5); + XSSFCell cell6 = row.getCell(6); + XSSFCell cell8 = row.getCell(8); + XSSFCell cell9 = row.getCell(9); + XSSFCell cell10 = row.getCell(10); + XSSFCell cell12 = row.getCell(8); + XSSFCell cell13 = row.getCell(9); + XSSFCell cell14 = row.getCell(10); + map1.put(cell0 == null ? "" : cell0.toString(), cell1 == null ? "" : cell1.toString()); + map2.put(cell4 == null ? "" : cell4.toString(), cell5 == null ? "" : cell5.toString()); + map3.put(cell8 == null ? "" : cell8.toString(), cell9 == null ? "" : cell9.toString()); + map4.put(cell12 == null ? "" : cell12.toString(), cell13 == null ? "" : cell13.toString()); + map1Type.put(cell0 == null ? "" : cell0.toString(), cell2 == null ? "" : cell2.toString()); + map2Type.put(cell4 == null ? "" : cell4.toString(), cell6 == null ? "" : cell6.toString()); + map3Type.put(cell8 == null ? "" : cell8.toString(), cell10 == null ? "" : cell10.toString()); + map4Type.put(cell12 == null ? "" : cell12.toString(), cell14 == null ? "" : cell14.toString()); + + } + } catch (IOException e) { + logger.warn("ȡģexcel ", e); + } + } +} diff --git a/src/com/connor/rb/plm/rb030/Rb030Handler.java b/src/com/connor/rb/plm/rb030/Rb030Handler.java new file mode 100644 index 0000000..36ef6fc --- /dev/null +++ b/src/com/connor/rb/plm/rb030/Rb030Handler.java @@ -0,0 +1,79 @@ +package com.connor.rb.plm.rb030; + +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Locale; +import java.util.ResourceBundle; + +import javax.swing.JTextField; + +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 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.util.MessageBox; + +public class Rb030Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if (!targetComponent.getType().equals("RB3_XMKFRevision")) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("qxzcupm30_display.TITLE"), "ʾ", 2); + return null; + } + Rb030Dialog dialog = new Rb030Dialog(app, targetComponent); + new Thread(dialog).start(); +// Rb030YylyDialog dialog = new Rb030YylyDialog(app,new JTextField()); +// new Thread(dialog).start(); + +// LinkedHashMap map1 = new LinkedHashMap(); +// LinkedHashMap map2 = new LinkedHashMap(); +// LinkedHashMap map3 = new LinkedHashMap(); +// HashMap map1Type = new HashMap(); +// HashMap map2Type = new HashMap(); +// HashMap map3Type = new HashMap(); +// InputStream fis = this.getClass().getResourceAsStream("/ĿӶ.xlsx");//õsrc· +// try { +// XSSFWorkbook wb = new XSSFWorkbook(fis); +// XSSFSheet xssfSheet = wb.getSheetAt(0); +// int rows = xssfSheet.getPhysicalNumberOfRows(); +// for (int i = 2; i < rows; i++) { +// XSSFRow row = xssfSheet.getRow(i); +// XSSFCell cell0 = row.getCell(0); +// XSSFCell cell1 = row.getCell(1); +// XSSFCell cell2 = row.getCell(2); +// XSSFCell cell4 = row.getCell(4); +// XSSFCell cell5 = row.getCell(5); +// XSSFCell cell6 = row.getCell(6); +// XSSFCell cell8 = row.getCell(8); +// XSSFCell cell9 = row.getCell(9); +// XSSFCell cell10 = row.getCell(10); +// map1.put(cell0==null?"":cell0.toString(), cell1==null?"":cell1.toString()); +// map2.put(cell4==null?"":cell4.toString(), cell5==null?"":cell5.toString()); +// map3.put(cell8==null?"":cell8.toString(), cell9==null?"":cell9.toString()); +// map1Type.put(cell0==null?"":cell0.toString(), cell2==null?"":cell2.toString()); +// map2Type.put(cell4==null?"":cell4.toString(), cell6==null?"":cell6.toString()); +// map3Type.put(cell8==null?"":cell8.toString(), cell10==null?"":cell10.toString()); +// +// } +// } catch (IOException e) { +// } +// System.out.println(); + return null; + } + +} diff --git a/src/com/connor/rb/plm/rb030/Rb030YylyDialog.java b/src/com/connor/rb/plm/rb030/Rb030YylyDialog.java new file mode 100644 index 0000000..74bedb2 --- /dev/null +++ b/src/com/connor/rb/plm/rb030/Rb030YylyDialog.java @@ -0,0 +1,190 @@ +package com.connor.rb.plm.rb030; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.connor.rb.plm.rb029.LovUtil; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class Rb030YylyDialog extends AbstractAIFDialog { + + private Logger logger = LoggerFactory.getLogger(Rb030YylyDialog.class); + + private AbstractAIFApplication app; + private TCSession session; + + public Rb030YylyDialog(AbstractAIFApplication app, JTextField jf) { + super(true); + this.app = app; + this.session = (TCSession) app.getSession(); + this.jf = jf; + } + + private Map lovThree; + private Map lovTWO; + private Map lovOne; + + private JTextArea area; + private ArrayList list; + private JTextField jf; + + @Override + public void run() { + getData(); + lovThree = LovUtil.getLovThree(session, "RB3_YYLY"); + lovTWO = LovUtil.getLovTWO(session, "RB3_YYLY"); + lovOne = LovUtil.getLov(session, "RB3_YYLY"); +// lovThree = LovUtil.getLovThree(session, "H8_testArr"); +// lovTWO = LovUtil.getLovTWO(session, "H8_testArr"); +// lovOne = LovUtil.getLov(session, "H8_testArr"); + init(); + } + + /** + * õLOVֵ + */ + private void getData() { + + } + + private void init() { + // ڵ + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Ӧֵ"); + for (Entry entry1 : lovOne.entrySet()) { + DefaultMutableTreeNode oneNode = new DefaultMutableTreeNode(entry1.getKey()); + rootNode.add(oneNode); + for (Entry entry2 : lovTWO.entrySet()) { + if (entry2.getKey().equals(entry1.getKey())) { + String[] value2 = entry2.getValue(); + for (int i = 0; i < value2.length; i++) { + DefaultMutableTreeNode twoNode = new DefaultMutableTreeNode(value2[i]); + oneNode.add(twoNode); + for (Entry entry3 : lovThree.entrySet()) { + if (entry3.getKey().equals(value2[i])) { + String[] value3 = entry3.getValue(); + for (int j = 0; j < value3.length; j++) { + DefaultMutableTreeNode threeNode = new DefaultMutableTreeNode(value3[j]); + twoNode.add(threeNode); + } + } + } + } + } + } + } +// // ڵ +// DefaultMutableTreeNode gdNode = new DefaultMutableTreeNode("Ŀ-"); +// DefaultMutableTreeNode fjNode = new DefaultMutableTreeNode("Ŀ-"); +// DefaultMutableTreeNode shNode = new DefaultMutableTreeNode("Ŀ-ͨ"); +// // ѶڵΪӽڵӵڵ +// rootNode.add(gdNode); +// rootNode.add(fjNode); +// rootNode.add(shNode); + // ʹøڵ㴴 + JTree tree = new JTree(rootNode); + // ʾڵ + tree.setShowsRootHandles(true); + // ڵɱ༭ + tree.setEditable(false); + // ýڵѡм + tree.addTreeSelectionListener(new TreeSelectionListener() { + @Override + public void valueChanged(TreeSelectionEvent e) { + String path = e.getPath().toString(); + String[] split = path.split(","); + if (split.length == 4) { + String newValue = split[3].substring(0, split[3].length() - 1); + if (area.getText().isEmpty()) { + area.setText(newValue); + } else { + area.setText(area.getText() + "," + newValue); + } + } + + } + }); + // 壬ΪڵչҪܴĿռʾҪһ + JScrollPane jsp = new JScrollPane(tree); + jsp.setPreferredSize(new Dimension(555, 555)); + expandTree(tree); + + JPanel endPanel = new JPanel(); + JButton okButton = new JButton("ȷ"); + okButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent var1) { + jf.setText(area.getText()); + setVisible(false); + } + }); + endPanel.add(okButton); + + JPanel topPanel = new JPanel(); + area = new JTextArea(); + area.setEnabled(false); + topPanel.add(area); + + this.setLayout(new BorderLayout()); + this.add(BorderLayout.NORTH, topPanel); + this.add(BorderLayout.CENTER, jsp); + this.add(BorderLayout.SOUTH, endPanel); + pack(); + centerToScreen(1.0D, 0.75D); + this.showDialog(); + } + + private void expandTree(JTree tree) { + TreeNode root = (TreeNode) tree.getModel().getRoot(); + expandAll(tree, new TreePath(root), true); + } + + private void expandAll(JTree tree, TreePath parent, boolean expand) { + // Traverse children + TreeNode node = (TreeNode) parent.getLastPathComponent(); + if (node.getChildCount() >= 0) { + for (Enumeration e = node.children(); e.hasMoreElements();) { + TreeNode n = (TreeNode) e.nextElement(); + TreePath path = parent.pathByAddingChild(n); + expandAll(tree, path, expand); + } + } + + // Expansion or collapse must be done bottom-up + if (expand) { + tree.expandPath(parent); + } else { + tree.collapsePath(parent); + } + } +} diff --git a/src/com/connor/rb/plm/rb031/Rb031Command.java b/src/com/connor/rb/plm/rb031/Rb031Command.java new file mode 100644 index 0000000..64eec77 --- /dev/null +++ b/src/com/connor/rb/plm/rb031/Rb031Command.java @@ -0,0 +1,392 @@ +package com.connor.rb.plm.rb031; + +import java.util.Map.Entry; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.text.SimpleDateFormat; +import java.util.*; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.connor.rb.plm.util.ProcessBarDialog; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +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.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentProjectType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import antlr.collections.List; + +public class Rb031Command extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private TCComponentItemRevision comp; + private ArrayList BomLines = new ArrayList(); + private HashMap> ProjectRemoveRev = new HashMap>(); + private HashMap> ProjectAssignRev = new HashMap>(); + + private HashMap FactoryMap = new HashMap(); + private HashMap PurchaseMap = new HashMap(); + private ArrayList DefaultList = new ArrayList(); + private PrintWriter writer; + private FileWriter fileWriter; + private File login_file; + + public Rb031Command(AbstractAIFApplication app, TCSession session, TCComponentItemRevision comp) { + this.session = session; + this.app = app; + this.comp = comp; + } + + @Override + public void executeModal() throws Exception { +// new Thread() { +// public void run() { + + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HH-mm-ss-SSS"); + String dirsPath = "C:\\Session"; + + String filename = "bzjlscj_display-"+ sdf.format(new Date()) +".txt"; + login_file = new File(dirsPath,filename); + File path = new File(dirsPath); + if(!path.exists()) { + path.mkdirs(); + } + if(login_file.exists()) { + login_file.delete(); + } + try { + login_file.createNewFile(); + fileWriter = new FileWriter(login_file, true); + writer = new PrintWriter(fileWriter); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + TCPreferenceService service = session.getPreferenceService(); + String[] Factorys = service.getStringValues("RB3_Distribution_Factory"); + String[] Purchases = service.getStringValues("RB3_Distribution_Purchase"); + String[] Defaults = service.getStringValues("RB3_Distribution_Default"); + if (Factorys == null) { + MessageBox.post("δѡRB3_Distribution_Factory", "ʾ", MessageBox.INFORMATION); + return; + } + if (Purchases == null) { + MessageBox.post("δѡRB3_Distribution_Purchase", "ʾ", MessageBox.INFORMATION); + return; + } + if (Defaults == null) { + MessageBox.post("δѡRB3_Distribution_Default", "ʾ", MessageBox.INFORMATION); + return; + } + + // ȡѡ + for (int i = 0; i < Factorys.length; i++) { + FactoryMap.put(Factorys[i].split("=")[0], Factorys[i].split("=")[1]); + } + for (int i = 0; i < Purchases.length; i++) { + PurchaseMap.put(Purchases[i].split("=")[0], Purchases[i].split("=")[1]); + } + for (int i = 0; i < Defaults.length; i++) { + DefaultList.add(Defaults[i]); + } + + writer.println("Factorys:" + Arrays.toString(Factorys)); + writer.println("Purchases:" + Arrays.toString(Purchases)); + writer.println("Defaults:" + Arrays.toString(Defaults)); + + writer.println("--------1-------"); + + writer.println("BomLines=====>" + BomLines.size()); + + + getAssignProject(comp); + getRemoveOldRevProject(comp.getItem()); + + writer.println("Ƴ" + ProjectRemoveRev.size() + "===ָɵ" + ProjectAssignRev.size()); + // Ƴʷ汾ָ + if (ProjectRemoveRev.size() > 0) { + removeProject(); + } + + // ָĿ + if (ProjectAssignRev.size() > 0) { + AssignProject(); + } + + super.executeModal(); + + } + + /** + * Ƴʷ汾ָɵĿ + */ + public void removeProject() { + writer.println("-----------Ƴʷ汾ָɵĿ-------"); + for (Entry> entry : ProjectRemoveRev.entrySet()) { + TCComponentProject project = entry.getKey(); + ArrayList lisTRevisions = entry.getValue(); + // Listת + TCComponentItemRevision[] revitions = lisTRevisions + .toArray(new TCComponentItemRevision[lisTRevisions.size()]); + try { + project.removeFromProject(revitions); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * ָɰ汾Ŀ + */ + public void AssignProject() { + writer.println("--------------ָɰ汾Ŀ-------------"); + for (Entry> entry : ProjectAssignRev.entrySet()) { + TCComponentProject project = entry.getKey(); + + ArrayList lisTRevisions = entry.getValue(); + // Listת + TCComponentItemRevision[] revitions = lisTRevisions + .toArray(new TCComponentItemRevision[lisTRevisions.size()]); + try { + writer.println("-----Ŀ" + project.getStringProperty("object_name") + "ָɵİ汾-----"); + for (TCComponentItemRevision revision : revitions) { + writer.println(revision.getStringProperty("object_name")); + } + writer.println("----------"); + + project.assignToProject(revitions); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * ռҪָĿĶ + * + * @param rev + */ + public void getAssignProject(TCComponentItemRevision rev) { + try { + + // ͨѡRB3_Distribution_Factoryָ + + TCComponentProject project = null; + String[] Scgcs = null; + String type = rev.getType(); + writer.println("type="+type); + if(type.startsWith("RB3_YZ") || type.startsWith("RB3_ZC") || type.startsWith("RB3_GQ") || type.startsWith("RB3_GZ") || type.startsWith("RB3_LBJ") || type.startsWith("RB3_TaskPackage")) { + Scgcs = rev.getTCProperty("rb3_scgc1").getStringValueArray();// ȡ + }else { + Scgcs = rev.getTCProperty("rb3_scgc").getStringValueArray();// ȡ + } + + + writer.println("====>" + rev.getStringProperty("object_name") + ",ֵΪ:" + Arrays.toString(Scgcs)); + for (int i = 0; i < Scgcs.length; i++) { + if (FactoryMap.containsKey(Scgcs[i])) { + String projectID = FactoryMap.get(Scgcs[i]); + project = ((TCComponentProjectType) (session.getTypeComponent("TC_Project"))).find(projectID); + if (project != null) { + if (ProjectAssignRev.containsKey(project)) { + ArrayList revList = ProjectAssignRev.get(project); + revList.add(rev); + writer.print("Ŀ" + project.getStringProperty("object_name") + "ӵָɶ"); + for (int k = 0; k < revList.size(); k++) { + writer.print(revList.get(k).getStringProperty("object_name") + ";"); + } + ProjectAssignRev.put(project, revList); + } else { + ArrayList revList = new ArrayList(); + revList.add(rev); + writer.print("Ŀ" + project.getStringProperty("object_name") + "ӵָɶ"); + for (int k = 0; k < revList.size(); k++) { + writer.print(revList.get(k).getStringProperty("object_name") + ";"); + } + ProjectAssignRev.put(project, revList); + } + getAssignRelationProject(rev, project); + } + + } + + } + boolean isFindProject = false; + project = null; + // ͨѡRB3_Distribution_Purchaseָ + if (rev.getItem().getType().equals("RB3_LBJ") || rev.getItem().getType().equals("RB3_GQBJ") + || rev.getItem().getType().equals("RB3_GZBJ") || rev.getItem().getType().equals("RB3_BZJBJ")) { + String itemID = rev.getStringProperty("item_id");// ID.substring(ID.length() - 1)ȡһλ + String projectID = null; + if (PurchaseMap.containsKey(itemID.substring(itemID.length() - 1))) { + projectID = PurchaseMap.get(itemID.substring(itemID.length() - 1)); + } else if (PurchaseMap.containsKey(itemID.substring(itemID.length() - 2))) { + projectID = PurchaseMap.get(itemID.substring(itemID.length() - 2)); + } + if (projectID != null) { + project = ((TCComponentProjectType) (session.getTypeComponent("TC_Project"))).find(projectID); + if (project != null) { + isFindProject = true; + if (ProjectAssignRev.containsKey(project)) { + ArrayList revList = ProjectAssignRev.get(project); + revList.add(rev); + writer.print("Ŀ" + project.getStringProperty("object_name") + "ӵָɶ"); + for (int k = 0; k < revList.size(); k++) { + writer.print(revList.get(k).getStringProperty("object_name") + ";"); + } + ProjectAssignRev.put(project, revList); + } else { + ArrayList revList = new ArrayList(); + revList.add(rev); + writer.print("Ŀ" + project.getStringProperty("object_name") + "ӵָɶ"); + for (int k = 0; k < revList.size(); k++) { + writer.print(revList.get(k).getStringProperty("object_name") + ";"); + } + ProjectAssignRev.put(project, revList); + } + getAssignRelationProject(rev, project); + } + } + + if (!isFindProject) { + project = null; + // ͨѡRB3_Distribution_Defaultָ + for (int i = 0; i < DefaultList.size(); i++) { + project = ((TCComponentProjectType) (session.getTypeComponent("TC_Project"))) + .find(DefaultList.get(i)); + if (project != null) { + if (ProjectAssignRev.containsKey(project)) { + ArrayList revList = ProjectAssignRev.get(project); + revList.add(rev); + writer.print("Ŀ" + project.getStringProperty("object_name") + "ӵָɶ"); + for (int k = 0; k < revList.size(); k++) { + writer.print(revList.get(k).getStringProperty("object_name") + ";"); + } + ProjectAssignRev.put(project, revList); + } else { + ArrayList revList = new ArrayList(); + revList.add(rev); + writer.print("Ŀ" + project.getStringProperty("object_name") + "ӵָɶ"); + for (int k = 0; k < revList.size(); k++) { + writer.print(revList.get(k).getStringProperty("object_name") + ";"); + } + ProjectAssignRev.put(project, revList); + } + getAssignRelationProject(rev, project); + } + } + } + + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * ռָɹϵµĿ + * + * @param rev + */ + public void getAssignRelationProject(TCComponentItemRevision rev, TCComponentProject project) { + try { + TCComponent[] items = rev.getReferenceListProperty("TC_Is_Represented_by"); + if (items == null || items.length == 0) { + writer.println(rev.getStringProperty("object_name") + "µTC_Is_Represented_byûж"); + return; + } + for (int i = 0; i < items.length; i++) { + TCComponentItemRevision itemRev = (TCComponentItemRevision) items[i]; + if (itemRev.getType().equals("RB3_CPTRevision") || itemRev.getType().equals("RB3_CGTRevision")) { + if (project != null) { + if (ProjectAssignRev.containsKey(project)) { + ArrayList revList = ProjectAssignRev.get(project); + revList.add(itemRev); + ProjectAssignRev.put(project, revList); + } else { + ArrayList revList = new ArrayList(); + revList.add(itemRev); + ProjectAssignRev.put(project, revList); + } + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * ȡʷ汾Ŀ + */ + public void getRemoveOldRevProject(TCComponentItem item) { + TCComponent[] itemRevs; + try { + itemRevs = item.getReferenceListProperty("revision_list"); + for (int i = 0; i < itemRevs.length - 1; i++) {// µİ汾ҪƳָɵĿ-1 + TCComponentItemRevision itemRev = (TCComponentItemRevision) itemRevs[i]; + TCComponent[] projects = itemRev.getReferenceListProperty("project_list"); + writer.println("projects:" + projects.length); + for (int j = 0; j < projects.length; j++) { + TCComponentProject project = (TCComponentProject) projects[j]; + if (project != null) { + if (ProjectRemoveRev.containsKey(project)) { + ArrayList revList = ProjectRemoveRev.get(project); + revList.add(itemRev); + ProjectRemoveRev.put(project, revList); + } else { + ArrayList revList = new ArrayList(); + revList.add(itemRev); + ProjectRemoveRev.put(project, revList); + } + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /** + * ȡз϶bom + */ + public void getAllBom(TCComponentBOMLine comp) { + BomLines.add(comp); + try { + AIFComponentContext[] childs = comp.getChildren(); + if (childs.length > 0) { + for (int i = 0; i < childs.length; i++) { + TCComponentBOMLine BomLine = (TCComponentBOMLine) childs[i].getComponent(); + getAllBom(BomLine); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +} diff --git a/src/com/connor/rb/plm/rb031/Rb031Handler.java b/src/com/connor/rb/plm/rb031/Rb031Handler.java new file mode 100644 index 0000000..60cd795 --- /dev/null +++ b/src/com/connor/rb/plm/rb031/Rb031Handler.java @@ -0,0 +1,102 @@ +package com.connor.rb.plm.rb031; + +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.rb.plm.util.ProcessBarDialog; +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.TCComponentDataset; +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 Rb031Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + //ȡѡ жѡǷѡ + String[] stringValues = session.getPreferenceService().getStringValues("RB3_XMZPTYPECONFIG"); + if(stringValues == null || stringValues.length == 0) { + MessageBox.post(rb.getString("sxxpzyw031_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return null; + } + List typeList = Arrays.asList(stringValues); + + // ȡѡеĶitem + + InterfaceAIFComponent[] comps = app.getTargetComponents(); + if (comps.length <= 0) { + return null; + } +// new Thread() { +// public void run() { +// +// }; +// }.start(); + String value1 = ""; + String value2 = ""; +// ProcessBarDialog processBar = new ProcessBarDialog("ڴ..."); +// processBar.open(); + for (InterfaceAIFComponent comp : comps) { + try { + if (comp instanceof TCComponentItemRevision) { + TCComponentItemRevision beforeRev = (TCComponentItemRevision) comp; +// if (beforeRev.getType().equals("RB3_ZCRevision") +// || beforeRev.getType().equals("RB3_LBJRevision")) { + if (typeList.contains(beforeRev.getType())) { + Rb031Command command = new Rb031Command(app, session, beforeRev); + command.executeModal(); + } else { + value2 += (comp.getProperty("item_id") + "-" + comp.getProperty("object_name") + ";"); + } + } else { + // ѡеĶΪǰ汾 + value1 += (comp.getProperty("item_id") + "-" + comp.getProperty("object_name") + ";"); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } +// processBar.close(); + + if (!value1.equals("") && !value2.equals("")) { + MessageBox.post(value1.substring(0, value1.length() - 1) + rb.getString("xzdwfbbdx31_display.TITLE") + + "\n" + value2.substring(0, value2.length() - 1) + + rb.getString("xzdwfzcdx31_display.TITLE"), "ʾ", MessageBox.INFORMATION); + } else if (!value1.equals("")) { + MessageBox.post( + value1.substring(0, value1.length() - 1) + rb.getString("xzdwfbbdx31_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + } else if (!value2.equals("")) { + MessageBox.post( + value2.substring(0, value2.length() - 1) + rb.getString("xzdwfzcdx31_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + } else { + MessageBox.post(rb.getString("zpwc31_display.TITLE"), "ʾ", MessageBox.INFORMATION); + } + + return null; + } +} diff --git a/src/com/connor/rb/plm/rb032/JAutoCompleteComboBox.java b/src/com/connor/rb/plm/rb032/JAutoCompleteComboBox.java new file mode 100644 index 0000000..2cdb75d --- /dev/null +++ b/src/com/connor/rb/plm/rb032/JAutoCompleteComboBox.java @@ -0,0 +1,155 @@ +package com.connor.rb.plm.rb032; + +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.List; +import java.util.Vector; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.JTextField; + +public class JAutoCompleteComboBox extends JComboBox { + private AutoCompleter completer; + + public JAutoCompleteComboBox() { + super(); + addCompleter(); + } + + public JAutoCompleteComboBox(ComboBoxModel cm) { + super(cm); + addCompleter(); + } + + public JAutoCompleteComboBox(Object[] items) { + super(items); + addCompleter(); + } + + public JAutoCompleteComboBox(List v) { + super((Vector) v); + addCompleter(); + } + + private void addCompleter() { + setEditable(true); + completer = new AutoCompleter(this); + } + + public void autoComplete(String str) { + this.completer.autoComplete(str, str.length()); + } + + public String getText() { + return ((JTextField) getEditor().getEditorComponent()).getText(); + } + + public void setText(String text) { + ((JTextField) getEditor().getEditorComponent()).setText(text); + } + + public boolean containsItem(String itemString) { + for (int i = 0; i < this.getModel().getSize(); i++) { + String _item = " " + this.getModel().getElementAt(i); + if (_item.equals(itemString)) + return true; + } + return false; + } + +} + +class AutoCompleter implements KeyListener, ItemListener { + + private JComboBox owner = null; + private JTextField editor = null; + + private ComboBoxModel model = null; + + public AutoCompleter(JComboBox comboBox) { + owner = comboBox; + editor = (JTextField) comboBox.getEditor().getEditorComponent(); + editor.addKeyListener(this); + model = comboBox.getModel(); + owner.addItemListener(this); + } + + public void keyTyped(KeyEvent e) { + } + + public void keyPressed(KeyEvent e) { + } + + public void keyReleased(KeyEvent e) { + char ch = e.getKeyChar(); + // if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch) + // || ch == KeyEvent.VK_DELETE) + // return; + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + int caretPosition = editor.getCaretPosition(); + String str = editor.getText(); + if (str.length() == 0) + return; + autoComplete(str, caretPosition); + } + } + + protected void autoComplete(String strf, int caretPosition) { + Object[] opts; + opts = getMatchingOptions(strf.substring(0, caretPosition)); + if (owner != null) { + model = new DefaultComboBoxModel(opts); + owner.setModel(model); + } + if (opts.length > 0) { + String str = opts[0].toString(); + editor.setCaretPosition(caretPosition); + if (owner != null) { + try { + owner.showPopup(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + } + + protected Object[] getMatchingOptions(String str) { + List v = new Vector(); + List v1 = new Vector(); + // v.add(str); + for (int k = 0; k < model.getSize(); k++) { + Object itemObj = model.getElementAt(k); + if (itemObj != null) { + String item = itemObj.toString().toLowerCase(); + if (item.indexOf((str.toLowerCase())) > -1) + v.add(model.getElementAt(k)); + else + v1.add(model.getElementAt(k)); + } else + v1.add(model.getElementAt(k)); + } + for (int i = 0; i < v1.size(); i++) { + v.add(v1.get(i)); + } + // if (v.isEmpty()) + return v.toArray(); + } + + public void itemStateChanged(ItemEvent event) { + if (event.getStateChange() == ItemEvent.SELECTED) { + int caretPosition = editor.getCaretPosition(); + if (caretPosition != -1) { + try { + editor.moveCaretPosition(caretPosition); + } catch (IllegalArgumentException ex) { + ex.printStackTrace(); + } + } + } + } +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/rb032/MultiComboBox.java b/src/com/connor/rb/plm/rb032/MultiComboBox.java new file mode 100644 index 0000000..89a141a --- /dev/null +++ b/src/com/connor/rb/plm/rb032/MultiComboBox.java @@ -0,0 +1,212 @@ +package com.connor.rb.plm.rb032; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.GridLayout; +import java.awt.Insets; +import java.awt.LayoutManager; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.UIManager; +import javax.swing.plaf.basic.BasicArrowButton; + +import com.teamcenter.rac.util.PropertyLayout; + +import cn.com.origin.autocode.newitem.generatcode.BorderLayout; + +public class MultiComboBox extends JComponent { + + private Object[] values; + + public Object[] defaultValues; + + private List listeners = new ArrayList(); + + public MultiPopup popup; + + public JTextField editor; + + protected JButton arrowButton; + + private String valueSperator; + + private static final String DEFAULT_VALUE_SPERATOR = ","; + + public MultiComboBox(Object[] value, Object[] defaultValue) { + this(value, defaultValue, DEFAULT_VALUE_SPERATOR); + } + + public MultiComboBox(Object[] value, Object[] defaultValue, String valueSperator) { + values = value; + defaultValues = defaultValue; + this.valueSperator = valueSperator; + initComponent(); + } + + private void initComponent() { + // ʱʹøò,Լд + this.setLayout(new PropertyLayout()); + // this.set + popup = new MultiPopup(values, defaultValues); + popup.addActionListener(new PopupAction()); + + editor = new JTextField(); + editor.setBackground(Color.WHITE); + editor.setEditable(false); + editor.setPreferredSize(new Dimension(900, 40)); +// editor.setBorder(getBorder()); + editor.addMouseListener(new EditorHandler()); + arrowButton = createArrowButton(); + arrowButton.addMouseListener(new EditorHandler()); + + add("1.1.left.top", editor); + // add(arrowButton); + setText(); + + } + + public Object[] getSelectedValues() { + return popup.getSelectedValues(); + } + + public void addActionListener(ActionListener listener) { + if (!listeners.contains(listener)) + listeners.add(listener); + } + + public void removeActionListener(ActionListener listener) { + if (listeners.contains(listener)) + listeners.remove(listener); + } + + protected void fireActionPerformed(ActionEvent e) { + for (ActionListener l : listeners) { + l.actionPerformed(e); + } + } + + private class PopupAction implements ActionListener { + + public void actionPerformed(ActionEvent e) { + + if (e.getActionCommand().equals(MultiPopup.CANCEL_EVENT)) { + + } else if (e.getActionCommand().equals(MultiPopup.COMMIT_EVENT)) { + defaultValues = popup.getSelectedValues(); + setText(); + // ¼ݳȥ + fireActionPerformed(e); + } + + togglePopup(); + + } + + } + + private void togglePopup() { + if (popup.isVisible()) { + popup.setVisible(false); + } else { + popup.setDefaultValue(defaultValues); + popup.show(this, 0, getHeight()); + } + } + + private void setText() { + StringBuilder builder = new StringBuilder(); + for (Object dv : defaultValues) { + builder.append(dv); + builder.append(valueSperator); + } + + editor.setText(builder.substring(0, builder.length() > 0 ? builder.length() - 1 : 0).toString()); + } + + private class EditorHandler implements MouseListener { + + public void mouseClicked(MouseEvent e) { + togglePopup(); + } + + public void mousePressed(MouseEvent e) { + + } + + public void mouseReleased(MouseEvent e) { + + } + + public void mouseEntered(MouseEvent e) { + + } + + public void mouseExited(MouseEvent e) { + + } + + } + + public void paintComponent(Graphics g) { + g.setColor(Color.white); + g.fillRect(0, 0, getWidth(), getHeight()); + } + + protected JButton createArrowButton() { + JButton button = new BasicArrowButton(BasicArrowButton.SOUTH, UIManager.getColor("ComboBox.buttonBackground"), + UIManager.getColor("ComboBox.buttonShadow"), UIManager.getColor("ComboBox.buttonDarkShadow"), + UIManager.getColor("ComboBox.buttonHighlight")); + button.setName("ComboBox.arrowButton"); + return button; + } + + private class MulitComboboxLayout implements LayoutManager { + + public void addLayoutComponent(String name, Component comp) { + // TODO Auto-generated method stub + + } + + public void removeLayoutComponent(Component comp) { + // TODO Auto-generated method stub + + } + + public Dimension preferredLayoutSize(Container parent) { + return parent.getPreferredSize(); + } + + public Dimension minimumLayoutSize(Container parent) { + return parent.getMinimumSize(); + } + + public void layoutContainer(Container parent) { + int w = parent.getWidth(); + int h = parent.getHeight(); + Insets insets = parent.getInsets(); + h = h - insets.top - insets.bottom; + + } + + } + +} diff --git a/src/com/connor/rb/plm/rb032/MultiPopup.java b/src/com/connor/rb/plm/rb032/MultiPopup.java new file mode 100644 index 0000000..b08075c --- /dev/null +++ b/src/com/connor/rb/plm/rb032/MultiPopup.java @@ -0,0 +1,173 @@ +package com.connor.rb.plm.rb032; + +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; + +public class MultiPopup extends JPopupMenu { + + private List listeners = new ArrayList(); + + private Object[] values; + + private Object[] defaultValues; + + private List checkBoxList = new ArrayList(); + + private JButton commitButton; + + private JButton cancelButton; + + public static final String COMMIT_EVENT = "commit"; + + public static final String CANCEL_EVENT = "cancel"; + + public MultiPopup(Object[] value, Object[] defaultValue) { + super(); + values = value; + defaultValues = defaultValue; + initComponent(); + } + + public void addActionListener(ActionListener listener) { + if (!listeners.contains(listener)) + listeners.add(listener); + } + + public void removeActionListener(ActionListener listener) { + if (listeners.contains(listener)) + listeners.remove(listener); + } + + private void initComponent() { + + JPanel checkboxPane = new JPanel(); + + JPanel buttonPane = new JPanel(); + + this.setLayout(new BorderLayout()); + + for (Object v : values) { + JCheckBox temp = new JCheckBox(v.toString(), selected(v)); + checkBoxList.add(temp); + } + + if (checkBoxList.get(0).getText().equals("Selected All")) + checkBoxList.get(0).addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + System.out.println("ѡ״̬ " + checkBoxList.get(0).isSelected()); + if (checkBoxList.get(0).isSelected())// Select All ѡ + { + // Ƿѡ鹵ûоѡ + for (int i = 1; i < checkBoxList.size(); i++) { + if (!checkBoxList.get(i).isSelected()) + checkBoxList.get(i).setSelected(true); + } + } else { + for (int i = 1; i < checkBoxList.size(); i++) { + if (checkBoxList.get(i).isSelected()) + checkBoxList.get(i).setSelected(false); + } + } + } + }); + + checkboxPane.setLayout(new GridLayout(checkBoxList.size(), 1, 3, 3)); + for (JCheckBox box : checkBoxList) { + checkboxPane.add(box); + } + + commitButton = new JButton("ok"); + + commitButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + commit(); + } + + }); + + cancelButton = new JButton("cancel"); + + cancelButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + cancel(); + } + + }); + + buttonPane.add(commitButton); + + buttonPane.add(cancelButton); + + this.add(checkboxPane, BorderLayout.CENTER); + + this.add(buttonPane, BorderLayout.SOUTH); + + } + + private boolean selected(Object v) { + for (Object dv : defaultValues) { + if (dv.equals(v)) { + return true; + } + } + return false; + } + + protected void fireActionPerformed(ActionEvent e) { + for (ActionListener l : listeners) { + l.actionPerformed(e); + } + } + + public Object[] getSelectedValues() { + List selectedValues = new ArrayList(); + + if (checkBoxList.get(0).getText().equals("Selected All")) { + if (checkBoxList.get(0).isSelected()) { + for (int i = 1; i < checkBoxList.size(); i++) { + selectedValues.add(values[i]); + } + } else { + for (int i = 1; i < checkBoxList.size(); i++) { + + if (checkBoxList.get(i).isSelected()) + selectedValues.add(values[i]); + } + } + } else + for (int i = 0; i < checkBoxList.size(); i++) { + + if (checkBoxList.get(i).isSelected()) + selectedValues.add(values[i]); + } + + return selectedValues.toArray(new Object[selectedValues.size()]); + } + + public void setDefaultValue(Object[] defaultValue) { + defaultValues = defaultValue; + + } + + public void commit() { + fireActionPerformed(new ActionEvent(this, 0, COMMIT_EVENT)); + } + + public void cancel() { + fireActionPerformed(new ActionEvent(this, 0, CANCEL_EVENT)); + } + +} diff --git a/src/com/connor/rb/plm/rb032/Rb032Command.java b/src/com/connor/rb/plm/rb032/Rb032Command.java new file mode 100644 index 0000000..6db0596 --- /dev/null +++ b/src/com/connor/rb/plm/rb032/Rb032Command.java @@ -0,0 +1,93 @@ +package com.connor.rb.plm.rb032; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.swing.JTextField; + +import com.teamcenter.rac.kernel.*; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.kernel.tcservices.TcServicesService; +import com.teamcenter.rac.util.MessageBox; + +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; + +public class Rb032Command extends AbstractAIFCommand { + + private TCSession session; + private HashMap ProToValue = new HashMap();// ƶӦʵ + private ArrayList Properties = new ArrayList();// + + public Rb032Command(TCSession session) { + this.session = session; + // TODO Auto-generated constructor stub + try { + executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + + TCPreferenceService service = session.getPreferenceService(); + // ȡ̣connor_rb_task + String[] str = service.getStringValues("connor_rb_task"); + if (str == null || str.length == 0) { + MessageBox.post("ѡconnor_rb_task", "ʾ", MessageBox.INFORMATION); + return; + } + + // ȡԵĶӦʵƵϢconnor_rb_PropertyName + String[] strs = service.getStringValues("connor_rb_PropertyName"); + if (strs == null || strs.length == 0) { + MessageBox.post("ѡconnor_rb_PropertyName", "ʾ", MessageBox.INFORMATION); + return; + } + + ArrayList p1Values = new ArrayList(); + ArrayList p2Values = new ArrayList(); + for (int i = 0; i < str.length; i++) { + if (str[i].contains("*")) { + p1Values.add(str[i].substring(1, str[i].length())); + } else { + p2Values.add(str[i]); + } + } + + ArrayList mustSelect = new ArrayList(); + for (int i = 0; i < strs.length; i++) { + if (strs[i].contains("=")) { + if (strs[i].contains("*")) { + mustSelect.add(strs[i].split("=")[0].substring(1, strs[i].split("=")[0].length())); + ProToValue.put(strs[i].split("=")[0].substring(1, strs[i].split("=")[0].length()), + strs[i].split("=")[1]); + } else { + ProToValue.put(strs[i].split("=")[0], strs[i].split("=")[1]); + Properties.add(strs[i].split("=")[0]); + } + + } + } + System.out.println(Properties); + + new Rb032Dialog(session, ProToValue, Properties, p1Values, p2Values, mustSelect); + // new hourCDialog(comp,session,top,PtoCMap); + } + +} diff --git a/src/com/connor/rb/plm/rb032/Rb032Dialog.java b/src/com/connor/rb/plm/rb032/Rb032Dialog.java new file mode 100644 index 0000000..7805b88 --- /dev/null +++ b/src/com/connor/rb/plm/rb032/Rb032Dialog.java @@ -0,0 +1,395 @@ +package com.connor.rb.plm.rb032; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; +import java.util.Vector; + +import javax.swing.Box; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.ListSelectionModel; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; + +import com.connor.rb.plm.util.ProcessBarDialog; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class Rb032Dialog extends AbstractAIFDialog implements ActionListener { + + private TCSession session; + private TCComponentBOMLine comp; + private Box box = Box.createVerticalBox(); + + private String[] header1 = new String[] { "", "ƺ", "ղ", "ղԴ", "ʵֵָ", "ע" }; + private JLabel Label0;// д + + private Vector headVector = new Vector();// ͷ + private Vector tableVector = new Vector();// + private HashMap ProToValue = new HashMap();// ƶӦʵ + private ArrayList Properties = new ArrayList();// + + private JTable mainTable1; + private JLabel p1Label;// + private ArrayList p1Values = new ArrayList();// + private JAutoCompleteComboBox p1ComboBox; + private JLabel p2Label;// + private JAutoCompleteComboBox p2ComboBox; + private ArrayList p2Values = new ArrayList();// + private JButton searchButton; + private String task;// + private String procedure;// + + private ArrayList mustSelectPro = new ArrayList(); + private ArrayList showProperties = new ArrayList(); + private String SelectPro = ""; + private MultiComboBox selectPropertyComboBox; + private JButton reButton; + private JButton sendToTC; + + private List> WeldDatas = new ArrayList>();// ͷ + + public Rb032Dialog(TCSession session, HashMap ProToValue, ArrayList Properties, + ArrayList p1Values, ArrayList p2Values, ArrayList mustSelect) throws IOException { + super(); + // TODO Auto-generated constructor stub + this.session = session; + this.ProToValue = ProToValue; + this.Properties = Properties; + this.p1Values = p1Values; + this.p2Values = p2Values; + this.mustSelectPro = mustSelect; + init(); + } + + private void init() throws IOException { + this.setTitle("б"); + this.setSize(new Dimension(1200, 650)); + this.setLayout(new BorderLayout()); + this.setResizable(true); + this.setAlwaysOnTop(false); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.setLocationRelativeTo(null); + this.setVisible(true); + + JPanel mainPanel1 = new JPanel(new PropertyLayout()); + + this.p1Label = new JLabel(""); + // this.p1Label.setForeground(Color.RED); + this.p1Label.setPreferredSize(new Dimension(80, 40)); + this.p1ComboBox = new JAutoCompleteComboBox(); + this.p1ComboBox.setPreferredSize(new Dimension(180, 40)); + p1ComboBox.setEditable(false); + this.p1ComboBox.setSelectedItem(""); + for (String string : p1Values) { + p1ComboBox.addItem(string); + } + this.p2Label = new JLabel(""); + this.p2Label.setPreferredSize(new Dimension(80, 40)); + this.p2ComboBox = new JAutoCompleteComboBox(); + p2ComboBox.setEditable(false); + this.p2ComboBox.setPreferredSize(new Dimension(250, 40)); + this.p2ComboBox.setSelectedItem(""); + for (String string : p2Values) { + p2ComboBox.addItem(string); + } + this.searchButton = new JButton(""); + this.searchButton.setPreferredSize(new Dimension(130, 40)); + + mainPanel1.add("1.1.left.top", p1Label); + mainPanel1.add("1.2.left.top", p1ComboBox); + mainPanel1.add("1.3.left.top", p2Label); + mainPanel1.add("1.4.left.top", p2ComboBox); + mainPanel1.add("1.5.left.top", searchButton); + + DefaultTableModel dtm1 = new DefaultTableModel(tableVector, headVector); + mainTable1 = new JTable(dtm1) {// JtableѡУ޷༭ + public boolean isCellEditable(int row, int column) { + return false; + } + }; + mainTable1.setRowHeight(30); + mainTable1.setDefaultRenderer(Object.class, new TableCellTextAreaRenderers()); + mainTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);// ñֻѡ + + // mainTable1.setPreferredSize(new Dimension(900,900)); + // mainTable.setEnabled(false);//ñ񲻿ɱ༭ + mainTable1.addMouseListener(new MouseAdapter() { + /** + * + */ + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2) { + + } + } + }); + JScrollPane J1 = new JScrollPane(); + J1.setPreferredSize(new Dimension(1175, 480)); + J1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + J1.getVerticalScrollBar().setUnitIncrement(10); + J1.setViewportView(mainTable1); + + JPanel mainPanel2 = new JPanel(new PropertyLayout()); + this.selectPropertyComboBox = new MultiComboBox(Properties.toArray(), new String[] { "" }); + selectPropertyComboBox.addActionListener(p1ComboBox); + ; + + this.reButton = new JButton("±"); + this.reButton.setPreferredSize(new Dimension(130, 40)); + + this.sendToTC = new JButton("͵TC"); + this.sendToTC.setPreferredSize(new Dimension(100, 40)); + mainPanel2.add("1.1.left.top", selectPropertyComboBox); + mainPanel2.add("1.2.left.top", reButton); + mainPanel2.add("1.3.left.top", sendToTC); + + this.add(mainPanel1, BorderLayout.NORTH); + this.add(J1, BorderLayout.CENTER); + this.add(mainPanel2, BorderLayout.SOUTH); + addListeners(); + this.setVisible(true); + } + + private void addListeners() { + this.searchButton.addActionListener(this); + this.sendToTC.addActionListener(this); + this.reButton.addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent event) { + Object obj = event.getSource(); + if (obj.equals(this.searchButton)) { + + task = p1ComboBox.getSelectedItem().toString(); + procedure = p2ComboBox.getSelectedItem().toString(); + if (task.equals("")) { + MessageBox.post("δѡ", "ʾ", MessageBox.INFORMATION); + } else { + if (procedure.equals("")) { + MessageBox.post("δѡ", "ʾ", MessageBox.INFORMATION); + } else { + headVector.clear(); + tableVector.clear(); + showProperties.clear(); + ProcessBarDialog processBar = new ProcessBarDialog("УԺ..."); + processBar.open(); + getTable(); + processBar.close(); + } + } + // processBar.close(); + } else if (obj.equals(this.reButton)) { + if (!selectPropertyComboBox.editor.getText().equals(SelectPro)) { + int option = JOptionPane.showOptionDialog(null, "ѱ仯Ƿȷ޸?", "", 0, 1, null, null, + Integer.valueOf(0)); + if (option == 0) { + SelectPro = selectPropertyComboBox.editor.getText(); + + } else { + System.out.println("޸"); + } + } + + } else if (obj.equals(this.sendToTC)) { + String UID = (String) mainTable1.getValueAt(mainTable1.getSelectedRow(), mainTable1.getColumnCount() - 1); + System.out.println(UID); + sendTC(UID); + this.dispose(); + } + + } + + /** + * ˢ± + */ + private void getTable() { + try { + + TCComponent[] sear = session.search("...", new String[] { "", "Ȩû" }, + new String[] { task, session.getUser().getUserId() }); + if (sear == null || sear.length == 0) { + System.out.println("δҵļ" + task); + return; + } + + TCComponent[] search = sear[0].getRelatedComponents("contents"); + if (search == null || search.length == 0) { + System.out.println("ļ" + task + "δҵ"); + return; + } + System.out.println("ҵ===>" + search.length); + + if (mustSelectPro != null && mustSelectPro.size() > 0) { + for (String str : mustSelectPro) { + showProperties.add(str); + } + } + if (SelectPro != null && !SelectPro.equals("")) { + for (String str : SelectPro.split(",")) { + showProperties.add(str); + } + } + showProperties.add("uid");// һuid + for (int i = 0; i < showProperties.size(); i++) { + headVector.add(showProperties.get(i)); + } + for (int i = 0; i < search.length; i++) { + if (!getProperty(search[i], "fnd0RootTask").equals(procedure)) { + continue; + } + Vector rowVector = new Vector(); + for (int j = 0; j < showProperties.size() - 1; j++) {// һuidͨԲ + String value = getProperty(search[i], ProToValue.get(showProperties.get(j))); + if (!value.equals("")) { + rowVector.add(value); + } else { + rowVector.add("(δҵ)"); + } + } + rowVector.add(search[i].getUid()); + tableVector.add(rowVector); + } + DefaultTableModel dtm = (DefaultTableModel) mainTable1.getModel();// ȡģ + dtm.setDataVector(tableVector, headVector);// + + mainTable1.updateUI();// ʾ + mainTable1.getTableHeader().getColumnModel().getColumn(showProperties.size() - 1).setMaxWidth(0); + mainTable1.getTableHeader().getColumnModel().getColumn(showProperties.size() - 1).setMinWidth(0); + mainTable1.getTableHeader().getColumnModel().getColumn(showProperties.size() - 1).setPreferredWidth(0); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public void sendTC(String uid) { + TCComponentTask item = null; + try { + item = (TCComponentTask) session.stringToComponent(uid); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + com.teamcenter.rac.common.Activator.getDefault() + .openPerspective("com.teamcenter.rac.ui.perspectives.navigatorPerspective"); + com.teamcenter.rac.common.Activator.getDefault().openComponents( + "com.teamcenter.rac.ui.perspectives.navigatorPerspective", new InterfaceAIFComponent[] { item }); + } + + // ȡͬ͵ + private static String getProperty(TCComponent c, String propName) throws Exception { + if (c == null) { + return ""; + } + TCProperty prop = c.getTCProperty(propName); + if (prop == null) { + System.out.println(propName + " property not defined"); + return ""; + } + if (prop.getPropertyType() == TCProperty.PROP_date) { + Date dateValue = prop.getDateValue(); + if (dateValue == null) { + return ""; + } + SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss SSS"); + String dateStr = fmt.format(dateValue); + return dateStr; + } else if (prop.getPropertyType() == TCProperty.PROP_double + || prop.getPropertyType() == TCProperty.PROP_float) { + String disValue = prop.getDisplayableValue(); + if (disValue != null && !disValue.equals("")) { + try { + double num = Double.parseDouble(disValue); + disValue = String.format("%.2f", num); + } catch (NumberFormatException e) { + e.printStackTrace(); + } + } + return disValue; + } + return prop.getDisplayableValue(); + } + + // ڹ涨ʱִ + public void testTimer01(ProcessBarDialog processBar) { + Timer timer = new Timer(); + TimerTask timerTask = new TimerTask() { + @Override + public void run() { + System.out.println("ԓУ"); + processBar.close(); + } + }; + timer.schedule(timerTask, 5000); + }// 5000Ϊ5 + +} + +/** + * ԶӦи + * + * @author Administrator + * + */ +class TableCellTextAreaRenderers extends JTextArea implements TableCellRenderer { + public TableCellTextAreaRenderers() { + setLineWrap(true); + setWrapStyleWord(true); + } + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, + int row, int column) { + + if (isSelected) { + setBackground(new Color(176, 224, 230)); + setForeground(Color.black); + } else { + setBackground(Color.white); + setForeground(Color.black); + } + // 㵱еѸ߶ + int maxPreferredHeight = 0; + for (int i = 0; i < table.getColumnCount(); i++) { + setText("" + table.getValueAt(row, i)); + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); + } + + if (table.getRowHeight(row) != maxPreferredHeight) // Ϲæ + table.setRowHeight(row, maxPreferredHeight); + setText(value == null ? "" : value.toString()); + return this; + } + +} diff --git a/src/com/connor/rb/plm/rb032/Rb032Handler.java b/src/com/connor/rb/plm/rb032/Rb032Handler.java new file mode 100644 index 0000000..6cfc0b8 --- /dev/null +++ b/src/com/connor/rb/plm/rb032/Rb032Handler.java @@ -0,0 +1,68 @@ +package com.connor.rb.plm.rb032; + +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.util.Timer; +import java.util.TimerTask; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.rb.plm.util.ProcessBarDialog; +import com.spire.pdf.tables.DataSet; +import com.spire.xls.ExcelVersion; +import com.spire.xls.ViewMode; +import com.spire.xls.Workbook; +import com.spire.xls.Worksheet; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import static java.awt.image.BufferedImage.TYPE_INT_ARGB; + +public class Rb032Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); +// try { +// TCComponentTask item = (TCComponentTask) session.stringToComponent("iliJHX3FJxNqRC"); +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + new Rb032Command(session); +// System.out.println("====>"); +// try { +// TCComponent comp1 = session.stringToComponent("iliJHX3FJxNqRC"); +// com.teamcenter.rac.common.Activator +// .getDefault() +// .openPerspective( +// "com.teamcenter.rac.ui.perspectives.navigatorPerspective"); +// com.teamcenter.rac.common.Activator +// .getDefault() +// .openComponents( +// "com.teamcenter.rac.ui.perspectives.navigatorPerspective", +// new InterfaceAIFComponent[] { comp1 }); +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + + return null; + } +} diff --git a/src/com/connor/rb/plm/rb032/test.java b/src/com/connor/rb/plm/rb032/test.java new file mode 100644 index 0000000..c46b836 --- /dev/null +++ b/src/com/connor/rb/plm/rb032/test.java @@ -0,0 +1,332 @@ +package com.connor.rb.plm.rb032; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; + +import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException; +import org.apache.pdfbox.printing.PDFPrintable; + +import com.teamcenter.rac.util.PropertyLayout; + +public class test extends JFrame { + // ؼ + private JPanel mainPanel; + private JFileChooser jfc; + private JButton okButton; + private JButton celButton; + private JButton pictureButton; + private JButton fileButton; + private JTextField pathText; + private JTextField fleName; + + public test() { + init(); + } + + private void init() { + this.setTitle("ѡ񱣴ַ"); + this.setPreferredSize(new Dimension(480, 230)); + Toolkit toolkit = Toolkit.getDefaultToolkit(); + int x = (int) (toolkit.getScreenSize().getWidth() - this.getWidth()) / 3; + + int y = (int) (toolkit.getScreenSize().getHeight() - this.getHeight()) / 3; + + this.setLocation(x, y); + this.okButton = new JButton(""); + this.okButton.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + + @Override + public void actionPerformed(ActionEvent e) { + copy(new File("C:\\\\plugins\\ּ.pdf"), + new File(pathText.getText() + "\\" + fleName.getText() + ".pdf")); + dispose(); + } + }); + this.celButton = new JButton("ȡ"); + this.celButton.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + + @Override + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + FileSystemView fsv = FileSystemView.getFileSystemView(); + File com = fsv.getHomeDirectory(); + this.fileButton = new JButton("..."); + this.fileButton.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + jfc = new JFileChooser(); + jfc.setCurrentDirectory(new File(com.getPath()));// ļѡijʼĿ¼Ϊd + jfc.setFileSelectionMode(1);// 趨ֻѡļ + int state = jfc.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jfc.getSelectedFile();// fΪѡ񵽵Ŀ¼ + pathText.setText(f.toString()); + } + } + }); + this.pathText = new JTextField(); + pathText.setText(com.getPath()); + this.pathText.setPreferredSize(new Dimension(300, 30)); + fleName = new JTextField(); + fleName.setText("ݼ"); + this.fleName.setPreferredSize(new Dimension(300, 30)); + JLabel label = new JLabel("ļ"); + label.setPreferredSize(new Dimension(100, 30)); + JLabel label2 = new JLabel("ѡļ"); + label2.setPreferredSize(new Dimension(100, 30)); + JPanel panel1 = new JPanel(new FlowLayout()); + panel1.add(label); + panel1.add(fleName); + JPanel panel2 = new JPanel(new FlowLayout()); + panel2.add(label2); + panel2.add(pathText); + panel2.add(fileButton); + this.mainPanel = new JPanel(new PropertyLayout()); + + this.mainPanel.add("1.1.left.top", panel1); + this.mainPanel.add("2.1.left.top", panel2); + + JPanel rootPanel = new JPanel(new FlowLayout()); + rootPanel.add(new JLabel(" ")); + rootPanel.add(this.okButton); + rootPanel.add(new JLabel(" ")); + rootPanel.add(this.celButton); + + this.setLayout(new BorderLayout()); + this.add(mainPanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + public static void main(String[] args) { + // new test(); + String path = "C:\\Users\\Administrator\\Desktop\\½ļ (4)\\test.pdf"; + System.out.println("path================" + path); + String newPath = path.split(".pdf")[0] + "CASH.pdf"; + copy(new File(path), new File(newPath));// ȻһݳӡĬϽԭɾ + File file = new File(newPath); + int statu = 0; + try { + PDDocument document = PDDocument.load(file); + // سɴӡļ + PDFPrintable printable = new PDFPrintable(document); + PrinterJob job = PrinterJob.getPrinterJob(); + // job.setPrintable(printable); + if (job.printDialog()) { + try { + job.print(); + } catch (PrinterException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } +// //ļ + new saveFile(path, "aaaa"); + + statu = 1; + document.close(); + System.out.println("1111"); + // file.deleteOnExit(); + file.delete(); + } else { + document.close(); + // file.deleteOnExit(); + file.delete(); + } + } catch (InvalidPasswordException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static void copy(File oldFile, File newFile) { + + try (InputStream in = new FileInputStream(oldFile); OutputStream out = new FileOutputStream(newFile)) { + + byte[] arr = new byte[1024]; + int len; + while ((len = in.read(arr)) != -1) { + out.write(arr, 0, len); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } +} + +class saveFile extends JFrame { + // ؼ + private JPanel mainPanel; + private JFileChooser jfc; + private JButton okButton; + private JButton celButton; + private JButton pictureButton; + private JButton fileButton; + private JTextField pathText; + private JTextField fleName; + private String path; + private String datasetName; + + public saveFile(String path, String datasetName) { + this.path = path; + this.datasetName = datasetName; + init(); + } + + private void init() { + this.setAlwaysOnTop(true); + System.out.println("copyPath:" + path); + this.setTitle("ѡ񱣴ַ"); + this.setPreferredSize(new Dimension(480, 230)); + Toolkit toolkit = Toolkit.getDefaultToolkit(); + int x = (int) (toolkit.getScreenSize().getWidth() - this.getWidth()) / 3; + + int y = (int) (toolkit.getScreenSize().getHeight() - this.getHeight()) / 3; + + this.setLocation(x, y); + this.okButton = new JButton(""); + this.okButton.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + + @Override + public void actionPerformed(ActionEvent e) { + copy(new File(path), new File(pathText.getText() + "\\" + fleName.getText() + ".pdf")); + new File(path).delete(); + + dispose(); + } + }); + this.celButton = new JButton("ȡ"); + this.celButton.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + + @Override + public void actionPerformed(ActionEvent e) { + new File(path).delete(); + dispose(); + } + }); + FileSystemView fsv = FileSystemView.getFileSystemView(); + File com = fsv.getHomeDirectory(); + this.fileButton = new JButton("..."); + this.fileButton.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + jfc = new JFileChooser(); + jfc.setCurrentDirectory(new File(com.getPath()));// ļѡijʼĿ¼Ϊd + jfc.setFileSelectionMode(1);// 趨ֻѡļ + int state = jfc.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jfc.getSelectedFile();// fΪѡ񵽵Ŀ¼ + pathText.setText(f.toString()); + } + } + }); + this.pathText = new JTextField(); + pathText.setText(com.getPath()); + this.pathText.setPreferredSize(new Dimension(300, 30)); + fleName = new JTextField(); + fleName.setText(datasetName); + this.fleName.setPreferredSize(new Dimension(300, 30)); + JLabel label = new JLabel("ļ"); + label.setPreferredSize(new Dimension(100, 30)); + JLabel label2 = new JLabel("ѡļ"); + label2.setPreferredSize(new Dimension(100, 30)); + JPanel panel1 = new JPanel(new FlowLayout()); + panel1.add(label); + panel1.add(fleName); + JPanel panel2 = new JPanel(new FlowLayout()); + panel2.add(label2); + panel2.add(pathText); + panel2.add(fileButton); + this.mainPanel = new JPanel(new PropertyLayout()); + + this.mainPanel.add("1.1.left.top", panel1); + this.mainPanel.add("2.1.left.top", panel2); + + JPanel rootPanel = new JPanel(new FlowLayout()); + rootPanel.add(new JLabel(" ")); + rootPanel.add(this.okButton); + rootPanel.add(new JLabel(" ")); + rootPanel.add(this.celButton); + + this.setLayout(new BorderLayout()); + this.add(mainPanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + testTimer01(this); + } + + public void testTimer01(saveFile d) { + Timer timer = new Timer(); + TimerTask timerTask = new TimerTask() { + @Override + public void run() { + d.setAlwaysOnTop(false); + System.out.println("ȡö"); + } + }; + timer.schedule(timerTask, 500); + }// 5000Ϊ5 + + public void copy(File oldFile, File newFile) { + + try (InputStream in = new FileInputStream(oldFile); OutputStream out = new FileOutputStream(newFile)) { + + byte[] arr = new byte[1024]; + int len; + while ((len = in.read(arr)) != -1) { + out.write(arr, 0, len); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/com/connor/rb/plm/rb033/Rb033Handler01.java b/src/com/connor/rb/plm/rb033/Rb033Handler01.java new file mode 100644 index 0000000..8553894 --- /dev/null +++ b/src/com/connor/rb/plm/rb033/Rb033Handler01.java @@ -0,0 +1,57 @@ +package com.connor.rb.plm.rb033; + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.rb.plm.rb032.Rb032Command; +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.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class Rb033Handler01 extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent comp = app.getTargetComponent(); + if (comp instanceof TCComponentBOMLine) { + System.out.println("bomID"); + try { + String text = ((TCComponentBOMLine) comp).getItemRevision().getStringProperty("item_id"); + if (text != null && !text.equals("")) { + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + // װı + Transferable trans = new StringSelection(text); + // ıõϵͳ + clipboard.setContents(trans, null); + } else { + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + // װı + Transferable trans = new StringSelection(""); + // ıõϵͳ + clipboard.setContents(trans, null); + System.out.println("text:" + text); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + System.out.println("ƶΪbom޷ƣ"); + } + + return null; + } +} diff --git a/src/com/connor/rb/plm/rb033/Rb033Handler02.java b/src/com/connor/rb/plm/rb033/Rb033Handler02.java new file mode 100644 index 0000000..770289a --- /dev/null +++ b/src/com/connor/rb/plm/rb033/Rb033Handler02.java @@ -0,0 +1,56 @@ +package com.connor.rb.plm.rb033; + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; + +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.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class Rb033Handler02 extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent comp = app.getTargetComponent(); + if (comp instanceof TCComponentBOMLine) { + System.out.println("bomIJƷ"); + try { + String text = ((TCComponentBOMLine) comp).getItemRevision().getStringProperty("rb3_cph"); + if (text != null && !text.equals("")) { + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + // װı + Transferable trans = new StringSelection(text); + // ıõϵͳ + clipboard.setContents(trans, null); + } else { + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + // װı + Transferable trans = new StringSelection(""); + // ıõϵͳ + clipboard.setContents(trans, null); + System.out.println("text:" + text); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + System.out.println("ƶΪbom޷ƣ"); + } + + return null; + } +} diff --git a/src/com/connor/rb/plm/rb033/Rb033Handler03.java b/src/com/connor/rb/plm/rb033/Rb033Handler03.java new file mode 100644 index 0000000..2c4cfa7 --- /dev/null +++ b/src/com/connor/rb/plm/rb033/Rb033Handler03.java @@ -0,0 +1,56 @@ +package com.connor.rb.plm.rb033; + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; + +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.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class Rb033Handler03 extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent comp = app.getTargetComponent(); + if (comp instanceof TCComponentBOMLine) { + System.out.println("bomͼ"); + try { + String text = ((TCComponentBOMLine) comp).getItemRevision().getStringProperty("rb3_th"); + if (text != null && !text.equals("")) { + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + // װı + Transferable trans = new StringSelection(text); + // ıõϵͳ + clipboard.setContents(trans, null); + } else { + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + // װı + Transferable trans = new StringSelection(""); + // ıõϵͳ + clipboard.setContents(trans, null); + System.out.println("text:" + text); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + System.out.println("ƶΪbom޷ƣ"); + } + + return null; + } +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/rb034/Rb034Dialog.java b/src/com/connor/rb/plm/rb034/Rb034Dialog.java new file mode 100644 index 0000000..590041a --- /dev/null +++ b/src/com/connor/rb/plm/rb034/Rb034Dialog.java @@ -0,0 +1,210 @@ +package com.connor.rb.plm.rb034; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.Locale; +import java.util.ResourceBundle; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; + +import com.sun.xml.xsom.impl.scd.Iterators.Map; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class Rb034Dialog { + + private AbstractAIFApplication app; + private TCSession session; + private TCComponent targetComponent; + private HashMap pros = new HashMap(); + + public Rb034Dialog(AbstractAIFApplication app, TCSession session, TCComponent targetComponent, + HashMap pros) { + + this.app = app; + this.session = session; + this.targetComponent = targetComponent; + this.pros = pros; + init(); + } + + private void init() { + // ȡʻ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + // TODO Auto-generated method stub + // rb.getString("cjgy_display.TITLE"); + System.out.println("+++++++++++++++++++++++++++"); + System.out.println("map=======>" + pros.toString()); + System.out.println("+++++++++++++++++++++++++++"); + + TCComponent Item = null; + try { + AIFComponentContext[] contexts = targetComponent.whereReferenced(); + System.out.println("øΪ" + contexts.length); + for (AIFComponentContext context : contexts) { + System.out.println("Ϊ" + context.getComponent().getType()); + if (context.getComponent().getType().contains("RB3_APQP")) { + + Item = (TCComponent) context.getComponent(); + System.out.println("ȡAPQPΪ" + Item.getStringProperty("object_string")); + break; + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + try { + System.out.println("item" + Item.getStringProperty("object_string")); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + if (Item == null) { + MessageBox.post(rb.getString("wzdyydAQPQdx34_display.TITLE"), "ʾ", MessageBox.INFORMATION); + } else { + TCComponent relationItem = Item; + System.out.println("APQPDΪգʼ======="); + for (String key : pros.keySet()) { + System.out.println("ԶӦΪ" + key + "==" + pros.get(key)); + try { + String value = getProperty(relationItem, pros.get(key)); + System.out.println("ȡֵΪ" + value); + setTCProperty(targetComponent, key, value); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + MessageBox.post(rb.getString("sxhqwc34_display.TITLE"), "ʾ", MessageBox.INFORMATION); + + } + + } + + public void setTCProperty(TCComponent item, String name, String value) throws TCException { + TCProperty property = item.getTCProperty(name); + if (property == null) { + System.out.println("ԣ" + name + ""); + return; + } + System.out.println("setTCProperty(TCProperty property =" + property.getPropertyName() + ", String value=" + + value + ") - start"); + + TCPropertyDescriptor descriptor = property.getPropertyDescriptor(); + boolean isArray = descriptor.isArray(); + if (!isArray) { + switch (descriptor.getType()) { + + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + property.setStringValue(value); + break; + case TCProperty.PROP_char: + if (value.length() > 0) { + property.setCharValue(value.charAt(0)); + } + break; + case TCProperty.PROP_double: + property.setDoubleValue(Double.parseDouble(value)); + break; + case TCProperty.PROP_float: + property.setFloatValue(Float.parseFloat(value)); + break; + case TCProperty.PROP_int: + case TCProperty.PROP_short: + property.setIntValue(Integer.parseInt(value)); + break; + case TCProperty.PROP_logical: + property.setLogicalValue(Boolean.parseBoolean(value)); + break; + case TCProperty.PROP_date: + try { + if (!value.isEmpty()) { + property.setDateValue(new SimpleDateFormat("yyyy-M-d HH:mm").parse(value)); + } + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + break; + } + } else { + System.out.println("ֵ===>" + value); + value = value.substring(3); + if (value.indexOf("+++") > 0) { + property.setStringValueArray(value.split("\\+++")); + } else { + property.setStringValueArray(new String[] { value }); + } + // System.out.println("ӦΪͣԴ"); + // ȡStringItemRevision().getTCProperty("").getStringValueArray(); + } + + System.out.println("setTCProperty(TCProperty property, String value) - end"); + } + + // ȡͬ͵ + private String getProperty(TCComponent c, String propName) throws Exception { + if (c == null) { + return ""; + } + TCProperty prop = c.getTCProperty(propName); + if (prop == null) { + return propName + " property not defined"; + } + if (prop.getPropertyType() == TCProperty.PROP_date) { + Date dateValue = prop.getDateValue(); + if (dateValue == null) { + return ""; + } + SimpleDateFormat propDateFormat = new SimpleDateFormat("yyyy-M-d HH:mm"); + return propDateFormat.format(dateValue); + } else if (prop.getPropertyType() == TCProperty.PROP_double + || prop.getPropertyType() == TCProperty.PROP_float) { + String disValue = prop.getDisplayableValue(); + if (disValue != null && disValue != "") { + try { + double num = Double.parseDouble(disValue); + disValue = String.format("%.2f", num); + } catch (NumberFormatException e) { + e.printStackTrace(); + } + } + return disValue; + } + if (prop.getPropertyDescriptor().isArray()) { + System.out.println("ҵֵͣΪ" + prop.getStringArrayValue()); + String values = ""; + for (String value : prop.getStringArrayValue()) { + values = values + "+++" + value; + } + return values; + } else { + System.out.println("صֵΪ" + prop.getStringValue()); + return prop.getStringValue(); + } + + } + +} diff --git a/src/com/connor/rb/plm/rb034/Rb034Handler.java b/src/com/connor/rb/plm/rb034/Rb034Handler.java new file mode 100644 index 0000000..91481fe --- /dev/null +++ b/src/com/connor/rb/plm/rb034/Rb034Handler.java @@ -0,0 +1,97 @@ +package com.connor.rb.plm.rb034; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class Rb034Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCPreferenceService service = session.getPreferenceService(); + + List types = new ArrayList<>(); + HashMap> typeTOpros = new HashMap(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); +// try { +// setTCProperty((TCComponent) app.getTargetComponent(),"object_name","sssss"); +// //((TCComponent) app.getTargetComponent()).setStringProperty("object_name", "teeeeee"); +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +//// try { +//// TCComponent[] Items = ((TCComponent) app.getTargetComponent()).getRelatedComponents("TC_Attaches"); +//// +//// System.out.println("====>"+Items.toString()); +//// } catch (TCException e) { +//// // TODO Auto-generated catch block +//// e.printStackTrace(); +//// } + // ȡ + String[] strs = service.getStringValues("RB3_EntrustCopyProperty"); + if (strs == null || strs.length == 0) { + MessageBox.post("ѡRB3_EntrustCopyPropertyδã", "ʾ", MessageBox.INFORMATION); + return null; + } + for (String trs : strs) { + if (trs.contains(":")) { + HashMap pros = new HashMap(); + types.add(trs.split(":")[0]); + String[] propers = trs.split(":")[1].split(";"); + for (String pro : propers) { + if (pro.contains("=")) { + System.out.println("----------------------------"); + System.out.println("ԶӦϵ" + pro); + String value1 = pro.split("=")[0]; + String value2 = pro.split("=")[1].substring(2); + System.out.println("value1====>" + value1); + System.out.println("value2====>" + value2); + pros.put(value1, value2); + } + } + System.out.println("ͣ" + trs.split(":")[0] + ",ԣ" + pros.toString()); + typeTOpros.put(trs.split(":")[0], pros); + } + } + if (app.getTargetComponent() == null) { + MessageBox.post(rb.getString("qxz34_display.TITLE") + types + rb.getString("dxjxcz34_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + } + System.out.println("ѡжΪ:" + app.getTargetComponent().getType()); + if (types.contains(app.getTargetComponent().getType())) { + + new Rb034Dialog(app, session, (TCComponent) app.getTargetComponent(), + typeTOpros.get(app.getTargetComponent().getType())); + + } else { + MessageBox.post(rb.getString("lxwx34_display.TITLE"), "ʾ", MessageBox.INFORMATION); + } + return null; + } + +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/rb035/BatchConversion.java b/src/com/connor/rb/plm/rb035/BatchConversion.java new file mode 100644 index 0000000..9523f0a --- /dev/null +++ b/src/com/connor/rb/plm/rb035/BatchConversion.java @@ -0,0 +1,54 @@ +package com.connor.rb.plm.rb035; + +import java.util.List; + +/** + * json + */ +public class BatchConversion { + + private String folderUid; + private String userId; + private List dwgFiles; + + public BatchConversion() { + } + + public BatchConversion(String folderUid, String userId, List dwgFiles) { + super(); + this.folderUid = folderUid; + this.userId = userId; + this.dwgFiles = dwgFiles; + } + + public String getFolderUid() { + return folderUid; + } + + public void setFolderUid(String folderUid) { + this.folderUid = folderUid; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public List getDwgFiles() { + return dwgFiles; + } + + public void setDwgFiles(List dwgFiles) { + this.dwgFiles = dwgFiles; + } + + @Override + public String toString() { + return "BatchConversion{" + "folderUid='" + folderUid + '\'' + ", userId='" + userId + '\'' + ", dwgFiles=" + + dwgFiles + '}'; + } + +} diff --git a/src/com/connor/rb/plm/rb035/DWGFile.java b/src/com/connor/rb/plm/rb035/DWGFile.java new file mode 100644 index 0000000..27c8496 --- /dev/null +++ b/src/com/connor/rb/plm/rb035/DWGFile.java @@ -0,0 +1,50 @@ +package com.connor.rb.plm.rb035; + +/** + * dwgļ + */ +public class DWGFile { + private String itemId; + private String fileName; + private String fileUid; + + public DWGFile() { + } + + public DWGFile(String itemId, String fileName, String filePath) { + super(); + this.itemId = itemId; + this.fileName = fileName; + this.fileUid = filePath; + } + + public String getItemId() { + return itemId; + } + + public void setItemId(String itemId) { + this.itemId = itemId; + } + + public String getFileUid() { + return fileUid; + } + + public void setFileUid(String fileUid) { + this.fileUid = fileUid; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + @Override + public String toString() { + return "DWGFile [itemId=" + itemId + ", fileName=" + fileName + ", fileUid=" + fileUid + "]"; + } + +} diff --git a/src/com/connor/rb/plm/rb035/batchConversionOfDrawingsHandler.java b/src/com/connor/rb/plm/rb035/batchConversionOfDrawingsHandler.java new file mode 100644 index 0000000..34697e5 --- /dev/null +++ b/src/com/connor/rb/plm/rb035/batchConversionOfDrawingsHandler.java @@ -0,0 +1,241 @@ +/** * @Title: batchConversionOfDrawingsHandler.java + * @Package com.connor.rb.plm.rb035 + * @Description: TODO(һ仰ļʲô) + * @author admin * @date 2024131 + * @version V1.0 + */ +package com.connor.rb.plm.rb035; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.pdmodel.PDPage; +import org.apache.pdfbox.pdmodel.PDPageContentStream; +import org.apache.pdfbox.pdmodel.font.PDFont; +import org.apache.pdfbox.pdmodel.font.PDType1Font; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.aspose.cad.Color; +import com.aspose.cad.Image; +import com.aspose.cad.imageoptions.CadRasterizationOptions; +import com.aspose.cad.imageoptions.PdfOptions; +import com.aspose.cad.internal.ay.iF; +import com.connor.rb.plm.util.ProcessBarDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFolderType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +/** + * @ClassName: batchConversionOfDrawingsHandler + * @Description: ͼֽת + * @author hcj + * @date 2024131 + * + */ +public class batchConversionOfDrawingsHandler extends AbstractHandler { + private static final String IMANSPECIFICATION = "IMAN_specification"; + private static final String[] REVTYPES = { "RB3_ZCRevision", "RB3_LBJRevision", "RB3_GZRevision", "RB3_GQRevision", + "RB3_BZJRevision", "RB3_GZBJRevision", "RB3_GQBJRevision", "RB3_BZJBJRevision" }; + + private String URL; + private String port; + + /* + * Title: execute Description: + * + * @param arg0 + * + * @return + * + * @throws ExecutionException + * + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands. + * ExecutionEvent) + */ + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + // ȡռ + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + + // ȡsesson + TCSession session = (TCSession) app.getSession(); + + // ȡػ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + + if (targetComponent == null) { + // ѡв + MessageBox.post(rb.getString("qxz34_display.TITLE") + rb.getString("dxjxcz34_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + return null; + } else if (!(targetComponent instanceof TCComponentFolder)) { + // ѡļжв + MessageBox.post(rb.getString("qxz34_display.TITLE") + rb.getString("wjj35_display.TITLE=") + + rb.getString("dxjxcz34_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return null; + } + new Thread() { + public void run() { + ProcessBarDialog processBar = new ProcessBarDialog("תУԺ(Start Waiting)..."); + processBar.open(); + + TCComponentFolder folder = (TCComponentFolder) targetComponent; + try { + List dwgFiles = new ArrayList(); + for (AIFComponentContext component : folder.getChildren()) { + InterfaceAIFComponent interfaceAIFComponent = component.getComponent(); + // ˷ǰ汾 + if (interfaceAIFComponent instanceof TCComponentItemRevision) { + TCComponentItemRevision revision = (TCComponentItemRevision) interfaceAIFComponent; + // + if (Arrays.asList(REVTYPES).contains(revision.getStringProperty("object_type"))) { + // ȡdwgļ + TCComponent[] spectficationObj = revision.getReferenceListProperty(IMANSPECIFICATION); + if (spectficationObj != null && spectficationObj.length > 0) { + for (TCComponent tcComponent : spectficationObj) { + if (tcComponent instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) tcComponent; + TCComponentTcFile[] file = dataset.getTcFiles(); + File fmsFile = file[0].getFmsFile(); + String path = fmsFile.getPath(); + // json + dwgFiles.add(new DWGFile(revision.getStringProperty("item_id"), + dataset.getRelatedComponent("ref_list").getStringProperty( + "original_file_name"), + dataset.getUid())); + } + } + } + } + } + } + if (dwgFiles.size() > 0) { + // ļ + TCComponentFolderType type = (TCComponentFolderType) session.getTypeComponent("Folder"); + TCComponentFolder newFolder = type.create("תͼֽ", "", "Folder"); + + // ѡеļ + folder.add("contents", newFolder); + + // ȡuidjsonbean + String uid = newFolder.getUid(); + String userID = session.getUser().getUserId().toUpperCase(); + BatchConversion batchConversion = new BatchConversion(uid, userID, dwgFiles); + + // JSON + String json = JSON.toJSONString(batchConversion); + System.out.println("json:" + json); + + // ȡѡȡurlƴַ + String preficStrings = session.getPreferenceService().getStringValue("RB_BatchConversionURL"); + String preficUrl = ""; + if (preficStrings != null) { + preficUrl = preficStrings; + } else { + MessageBox.post("ѡRB_BatchConversionURLδã", "ʾ", MessageBox.INFORMATION); + return; + } + + System.out.println("url:" + preficUrl + ":13022/api/batchCconversionDWGToPDF"); + + System.out.println("================================================================"); + System.out.println("=================תpost================="); + System.out.println("================================================================"); + + // postת + String sendPostRequest = sendPostRequest(preficUrl + ":13022/api/batchCconversionDWGToPDF", + json); + + MessageBox.post(sendPostRequest, "ʾ", MessageBox.INFORMATION); + } else { + MessageBox.post("ûҵdwgͼֽ", "ʾ", MessageBox.INFORMATION); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + processBar.close(); + System.out.println("================================================================"); + System.out.println("========================================================"); + System.out.println("================================================================"); + }; + + }.start(); + + return null; + } + + /** + * + * @Title: sendPostRequest + * @Description: post + * @param @param url + * @param @param json + * @param @return + * @return String + * @throws + */ + 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/rb/plm/rb035/batchDownloadOfDrawingsHandler.java b/src/com/connor/rb/plm/rb035/batchDownloadOfDrawingsHandler.java new file mode 100644 index 0000000..8410afd --- /dev/null +++ b/src/com/connor/rb/plm/rb035/batchDownloadOfDrawingsHandler.java @@ -0,0 +1,179 @@ +package com.connor.rb.plm.rb035; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Locale; +import java.util.ResourceBundle; +import javax.swing.JFileChooser; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.rb.plm.util.ProcessBarDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +/** + * @ClassName: batchDownloadOfDrawings + * @Description: pdf + * @author hcj + * @date 2024131 + * + */ +public class batchDownloadOfDrawingsHandler extends AbstractHandler { + + private String path; + + /* + * Title: execute Description: + * + * @param arg0 + * + * @return + * + * @throws ExecutionException + * + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands. + * ExecutionEvent) + */ + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + // ȡռ + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + + // ȡsesson + TCSession session = (TCSession) app.getSession(); + + // ȡػ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + + if (targetComponent == null) { + // ѡв + MessageBox.post(rb.getString("qxz34_display.TITLE") + rb.getString("dxjxcz34_display.TITLE"), "ʾ", + MessageBox.INFORMATION); + return null; + } else if (!(targetComponent instanceof TCComponentFolder)) { + // ѡļжв + MessageBox.post(rb.getString("qxz34_display.TITLE") + rb.getString("wjj35_display.TITLE=") + + rb.getString("dxjxcz34_display.TITLE"), "ʾ", MessageBox.INFORMATION); + return null; + } + + TCComponentFolder folder = (TCComponentFolder) targetComponent; + + new Thread() { + public void run() { + try { + // һµ JFileChooser + JFileChooser fileChooser = new JFileChooser(); + + // öԻģʽΪѡĿ¼ + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + + // öԻ + fileChooser.setDialogTitle(rb.getString("xzwjj_display.TITLE")); + + // ʾԻ򲢻ȡûѡ + int result = fileChooser.showOpenDialog(null); // Դȷ + + if (result == JFileChooser.APPROVE_OPTION) { + // ûˡ׼ťѡijļУ + File selectedDirectory = fileChooser.getSelectedFile(); + path = selectedDirectory.getAbsolutePath(); + + System.out.println("ûѡļ·: " + path); + // ﴦûѡ· + } else { + System.out.println("ûȡѡ"); + return; + } + // ý + ProcessBarDialog processBar = new ProcessBarDialog("УԺ(Start Waiting)..."); + processBar.open(); + // ѭfolder + for (AIFComponentContext component : folder.getChildren()) { + InterfaceAIFComponent interfaceAIFComponent = component.getComponent(); + if (interfaceAIFComponent instanceof TCComponentDataset) { + // ȡݼ + TCComponentDataset dataset = (TCComponentDataset) interfaceAIFComponent; + TCComponentTcFile[] file = dataset.getTcFiles(); + if (file != null && file.length > 0) { + for (TCComponentTcFile f : file) { + File datasetFile = f.getFmsFile(); + // ļصͻѡĿ¼ + copyFileToFile(datasetFile, path); + } + } + } + } + // رս + processBar.close(); + // ɹ + MessageBox.post(rb.getString("czcg_display.TITLE"), "ʾ", MessageBox.INFORMATION); + } catch (TCException e) { + // TODO Auto-generated catch block + // ʧ + MessageBox.post(rb.getString("czsb_display.TITLE"), "ʾ", MessageBox.INFORMATION); + e.printStackTrace(); + } + }; + }.start(); + + return null; + } + + /** + * + * @Title: copyFileToFile + * @Description: ָļصӦĿ¼ + * @param @param datasetFile + * @param @param destinationPath + * @return void + * @throws + */ + public static void copyFileToFile(File datasetFile, String destinationPath) { + if (!datasetFile.exists()) { + System.out.println("Դļ: " + datasetFile.getAbsolutePath()); + return; + } + + // Ŀ·תΪFile + File destination = new File(destinationPath, datasetFile.getName()); + + try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(datasetFile)); + BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(destination))) { + + byte[] buffer = new byte[1024]; + int read; + + while ((read = in.read(buffer)) != -1) { + out.write(buffer, 0, read); + } + + // رļд + out.flush(); + System.out.println("ļѳɹƵ: " + destination.getAbsolutePath()); + + } catch (IOException e) { + System.err.println("ļƹз: " + e.getMessage()); + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/rb/plm/rb035/test.java b/src/com/connor/rb/plm/rb035/test.java new file mode 100644 index 0000000..efffac3 --- /dev/null +++ b/src/com/connor/rb/plm/rb035/test.java @@ -0,0 +1,44 @@ +/** * @Title: test.java + * @Package com.connor.rb.plm.rb035 + * @Description: TODO(һ仰ļʲô) + * @author admin * @date 2024131 + * @version V1.0 + */ +package com.connor.rb.plm.rb035; + +import com.aspose.cad.Color; +import com.aspose.cad.Image; +import com.aspose.cad.imageoptions.CadRasterizationOptions; +import com.aspose.cad.imageoptions.PdfOptions; + +/** + * @ClassName: test + * @Description: TODO(һ仰) + * @author admin + * @date 2024131 + * + */ +public class test { + public static void main(String[] args) { + DWGFileToPDF("D:\\Project\\105\\105DOC\\plugins\\plugins\\CCK.dwg", + "D:\\Project\\105\\105DOC\\plugins\\plugins\\demo3.pdf"); + System.out.println("ִн"); + } + + public static void DWGFileToPDF(String srcFile, String dataDir) { + + Image objImage = Image.load(srcFile); + CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); + rasterizationOptions.setBackgroundColor(Color.getWhite()); + rasterizationOptions.setPageWidth(1600); + rasterizationOptions.setPageHeight(1600); + + // Create an instance of PdfOptions + PdfOptions pdfOptions = new PdfOptions(); + // Set the VectorRasterizationOptions property + pdfOptions.setVectorRasterizationOptions(rasterizationOptions); + // Export the DWG to PDF + objImage.save(dataDir, pdfOptions); + } + +} diff --git a/src/com/connor/rb/plm/rb036/BOMPropertyChangeHandler.java b/src/com/connor/rb/plm/rb036/BOMPropertyChangeHandler.java new file mode 100644 index 0000000..fe59630 --- /dev/null +++ b/src/com/connor/rb/plm/rb036/BOMPropertyChangeHandler.java @@ -0,0 +1,90 @@ +/** * @Title: BOMPropertyChangeHandler.java + * @Package com.connor.rb.plm.rb036 + * @Description: TODO(һ仰ļʲô) + * @author admin * @date 2025225 + * @version V1.0 + */ +package com.connor.rb.plm.rb036; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.aspose.cad.internal.ay.iF; +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.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +/** + * @ClassName: BOMPropertyChangeHandler + * @Description: TODO(һ仰) + * @author admin + * @date 2025225 + * + */ +public class BOMPropertyChangeHandler extends AbstractHandler{ + + /* + * Title: execute + * Description: + * @param arg0 + * @return + * @throws ExecutionException + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + private static AbstractAIFApplication app; + private static TCSession session; + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); + + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if(targetComponent == null) { + MessageBox.post("ѡItem󡢰汾BOMе", "ʾ", MessageBox.INFORMATION); + return null; + } + String type = ""; + try { + if(targetComponent instanceof TCComponentItem) { + type = ((TCComponentItem)targetComponent).getType(); + }else if(targetComponent instanceof TCComponentItemRevision) { + type = ((TCComponentItemRevision)targetComponent).getItem().getType(); + }else if(targetComponent instanceof TCComponentBOMLine) { + type = ((TCComponentBOMLine)targetComponent).getItem().getType(); + }else { + MessageBox.post("ѡItem󡢰汾BOMе", "ʾ", MessageBox.INFORMATION); + return null; + } + } catch (Exception e) { + e.printStackTrace(); + } + + //ȡѡ + String sxx = type + "Bom_Import_Properties"; + System.out.println("ѡ"+sxx); + String[] stringValues = session.getPreferenceService().getStringValues(sxx); + if(stringValues == null || stringValues.length == 0) { + MessageBox.post("ѡ" + sxx + "в", "", MessageBox.ERROR); + return null; + } + LinkedHashMap proHashMap = new LinkedHashMap(); + for(String stringValue : stringValues) { + String[] split = stringValue.split("="); + proHashMap.put(split[0], split[1]); + } + session.queueOperation(new BOMPropertyChangeOperations(session,proHashMap,sxx)); + return null; + } + +} diff --git a/src/com/connor/rb/plm/rb036/BOMPropertyChangeOperation.java b/src/com/connor/rb/plm/rb036/BOMPropertyChangeOperation.java new file mode 100644 index 0000000..65849b4 --- /dev/null +++ b/src/com/connor/rb/plm/rb036/BOMPropertyChangeOperation.java @@ -0,0 +1,165 @@ +/** * @Title: BOMPropertyChangeOperation.java + * @Package com.connor.rb.plm.rb036 + * @Description: TODO(һ仰ļʲô) + * @author admin * @date 2025225 + * @version V1.0 + */ +package com.connor.rb.plm.rb036; + +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +/** + * @ClassName: BOMPropertyChangeOperation + * @Description: + * @author hcj + * @date 2025225 + * + */ +public class BOMPropertyChangeOperation extends AbstractAIFOperation { + private JLabel[] jLabels; + private JTextField[] jTextFields; + private TCSession session; + private List bomLines; + private LinkedHashMap proHashMap; + private final static String TITLE = ""; + private final static String OK = "ȷ"; + private final static String EXIT = "ȡ"; + /** + * һµʵ BOMPropertyChangeOperation + * + * @param session + * @param proHashMap + * @param bomLines + */ + public BOMPropertyChangeOperation(TCSession session, List bomLines, LinkedHashMap proHashMap) { + // TODO Auto-generated constructor stub + this.session = session; + this.bomLines = bomLines; + this.proHashMap = proHashMap; + + this.jLabels = new JLabel[proHashMap.size()]; + this.jTextFields = new JTextField[proHashMap.size()]; + + int i = 0; + for (String key : proHashMap.keySet()) { + jLabels[i] = new JLabel(key); + jTextFields[i] = new JTextField(17); + i++; + } + } + + /* + * Title: executeOperation + * Description: + * @throws Exception + * @see com.teamcenter.rac.aif.AbstractAIFOperation#executeOperation() + */ + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + JFrame jFrame = new JFrame(); + jFrame.setTitle(TITLE); + jFrame.setSize(400, 500); + + JButton okButton = new JButton(OK); + JButton cancelButton = new JButton(EXIT); + + JScrollPane centerPanel = getCenterPanel(); + JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 70, 10)); + bottomPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); + bottomPanel.add(okButton); + bottomPanel.add(cancelButton); + + okButton.addActionListener(e -> { + // ѭҳԪأbomиֵ + List keysAsList = new ArrayList<>(proHashMap.keySet()); + List proNameList = new ArrayList<>(); + List proValueList = new ArrayList<>(); + + for(int i = 0; i < keysAsList.size(); i++) { + String key = keysAsList.get(i); + String value = proHashMap.get(key); + + String text = jTextFields[i].getText() != null ? jTextFields[i].getText().trim() : ""; + if(text.isEmpty()) continue; + + proNameList.add(value); + proValueList.add(text); + } + + if (!proNameList.isEmpty() && !proValueList.isEmpty()) { + for(TCComponentBOMLine bomLine : bomLines) { + try { + bomLine.setProperties(proNameList.toArray(new String[0]), proValueList.toArray(new String[0])); + } catch (TCException e1) { + } + } + } + MessageBox.post("", "ʾ", MessageBox.INFORMATION); + }); + + cancelButton.addActionListener(e -> { + jFrame.dispose(); // رմ + }); + + jFrame.getContentPane().add(centerPanel, java.awt.BorderLayout.CENTER); + jFrame.getContentPane().add(bottomPanel, java.awt.BorderLayout.SOUTH); + jFrame.setLocationRelativeTo(null); + jFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + jFrame.setVisible(true); + } + + /** + * + * @Title: getCenterPanel + * @Description: + * @param @return + * @return JScrollPane + * @throws + */ + private JScrollPane getCenterPanel() { + JPanel centerPanel = new JPanel(new GridBagLayout()); + GridBagConstraints customLayout = new GridBagConstraints(); + + for (int i = 0; i < proHashMap.size(); i++) { + customLayout.insets = new Insets(5, 30, 5, 20); // ߾ + customLayout.gridx = 0; + customLayout.weightx = 0; + customLayout.anchor = GridBagConstraints.LINE_START; + jLabels[i].setFont(new Font("΢ź", Font.BOLD, 13)); + centerPanel.add(jLabels[i], customLayout); + + customLayout.insets = new Insets(5, 3, 5, 30); // ߾ + customLayout.gridx = 1; + customLayout.weightx = 0; + customLayout.fill = GridBagConstraints.HORIZONTAL; + JTextField jTextField = jTextFields[i]; + jTextField.setFont(new Font("΢ź", Font.BOLD, 15)); + centerPanel.add(jTextField, customLayout); + } + + return new JScrollPane(centerPanel); + } + +} diff --git a/src/com/connor/rb/plm/rb036/BOMPropertyChangeOperation2.java b/src/com/connor/rb/plm/rb036/BOMPropertyChangeOperation2.java new file mode 100644 index 0000000..9f77770 --- /dev/null +++ b/src/com/connor/rb/plm/rb036/BOMPropertyChangeOperation2.java @@ -0,0 +1,18 @@ +/** * @Title: BOMPropertyChangeOperation2.java + * @Package com.connor.rb.plm.rb036 + * @Description: TODO(һ仰ļʲô) + * @author admin * @date 202536 + * @version V1.0 + */ +package com.connor.rb.plm.rb036; + +/** + * @ClassName: BOMPropertyChangeOperation2 + * @Description: TODO(һ仰) + * @author admin + * @date 202536 + * + */ +public class BOMPropertyChangeOperation2 { + +} diff --git a/src/com/connor/rb/plm/rb036/BOMPropertyChangeOperations.java b/src/com/connor/rb/plm/rb036/BOMPropertyChangeOperations.java new file mode 100644 index 0000000..c20bd92 --- /dev/null +++ b/src/com/connor/rb/plm/rb036/BOMPropertyChangeOperations.java @@ -0,0 +1,295 @@ +/** * @Title: BOMPropertyChangeOperations.java + * @Package com.connor.rb.plm.rb036 + * @Description: TODO(һ仰ļʲô) + * @author admin * @date 202535 + * @version V1.0 + */ +package com.connor.rb.plm.rb036; + +import java.awt.Dimension; +import java.io.File; +import java.io.FileInputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.filechooser.FileNameExtensionFilter; + +import org.apache.commons.lang.StringUtils; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.DataFormatter; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.rb.plm.exportBOM.WaitingDialog; +import com.connor.rb.plm.util.TCUtils; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.schemas.soa._2011_06.metamodel.LovValue; + +/** + * @ClassName: BOMPropertyChangeOperations + * @Description: TODO(һ仰) + * @author admin + * @date 202535 + * + */ +public class BOMPropertyChangeOperations extends AbstractAIFOperation { + private static TCSession session; + private static Map bomAttrAndDisAttrMap; + private static String sxx; + private static final String SETPASS = "Connor_set_bypass"; + private static final String CLOSSPASS = "Connor_close_bypass"; + + public BOMPropertyChangeOperations(TCSession session, Map bomAttrAndDisAttrMap, String sxx) { + // TODO Auto-generated constructor stub + this.session = session; + this.bomAttrAndDisAttrMap = bomAttrAndDisAttrMap; + this.sxx = sxx; + } + + @Override + public void executeOperation() throws Exception { + StringBuilder builder = new StringBuilder(); + Object[] obj = new Object[] { "" }; + TCUserService userservice = this.session.getUserService(); + WaitingDialog dia = new WaitingDialog(AIFUtility.getCurrentApplication().getDesktop(), "INFOMATION", + "ڵBOM......"); + dia.setVisible(true); + try { + // · + TCUtils.openLogByPass(session, "BOM"); + userservice.call(SETPASS, obj); + // TODO Auto-generated method stub + File selectedFile = null; + // ѡļԻ + JFileChooser fileChooser = new JFileChooser(); + + // ļɸѡֻѡ.xlsxļ + FileNameExtensionFilter filter = new FileNameExtensionFilter("Excel ļ", "xlsx"); + fileChooser.setFileFilter(filter); + + // ʾԻ + int returnValue = fileChooser.showOpenDialog(null); + + // ûǷѡļ + if (returnValue == JFileChooser.APPROVE_OPTION) { + // ȡûѡļ + selectedFile = fileChooser.getSelectedFile(); + + // ļǷϺ׺Ҫ + if (isXlsxFile(selectedFile)) { + System.out.println("ѡļ: " + selectedFile.getName()); + } else { + MessageBox.post("ѡexcelļв", "", MessageBox.ERROR); + return; + } + } else { + System.out.println("ûѡκļ"); + return; + } + FileInputStream fis = new FileInputStream(selectedFile); + Workbook workbook = new XSSFWorkbook(fis); + Sheet sheet = workbook.getSheetAt(0); // ȡһ + + // ͷȡ ========== + Row headerRow = sheet.getRow(0); + List headers = new ArrayList<>(); + for (int i = 4; i < headerRow.getLastCellNum(); i++) { // IDID + headers.add(headerRow.getCell(i).getStringCellValue()); + } + + String[] attrs = headers.toArray(new String[0]); + // һ attrs ͬ洢ӳֵ + String[] mappedAttrs = new String[attrs.length]; + + // attrs 飬 bomAttrAndDisAttrMap ӳ + List skipCellIndexList = new ArrayList(); + for (int i = 0; i < attrs.length; i++) { + String attr = attrs[i]; + if (bomAttrAndDisAttrMap.containsKey(attr)) { + mappedAttrs[i] = bomAttrAndDisAttrMap.get(attr); + } else { + skipCellIndexList.add(i + 4); + builder.append("ѡ" + sxx + "δҵͷ" + attr + "Ӧֵ" + "\n"); + continue; + } + } + + // BOMṹ ========== + Map> bomStructureMap = new HashMap<>(); + + for (int rowIdx = 1; rowIdx <= sheet.getLastRowNum(); rowIdx++) { + Row row = sheet.getRow(rowIdx); + if (row == null) + continue; + + // ȡIDID + String parentId = getCellStringValue(row.getCell(0)); + String parentRevId = getCellStringValue(row.getCell(1)); + String childId = getCellStringValue(row.getCell(2)); + String childRevId = getCellStringValue(row.getCell(3)); + + // Ч + if (parentId.isEmpty() || parentRevId.isEmpty() || childId.isEmpty() || childRevId.isEmpty()) + continue; + + TCComponent[] search = session.search("汾...", new String[] { " ID", "汾" }, + new String[] { parentId, parentRevId }); + if (search == null || search.length == 0) { + builder.append("==> ID:" + parentId + "汾" + parentRevId + "\n"); + continue; + } + + TCComponent[] search2 = session.search("汾...", new String[] { " ID", "汾" }, + new String[] { childId, childRevId }); + if (search2 == null || search2.length == 0) { + builder.append("==> ID:" + childId + "汾" + childRevId + "\n"); + continue; + } + + // ȡУӵ5пʼ + List propValueList = new ArrayList(); + for (int i = 4; i < row.getLastCellNum(); i++) { + // жǷ + if (skipCellIndexList.contains(i)) + continue; + propValueList.add(getCellStringValue(row.getCell(i))); + } + String[] propValues = propValueList.toArray(new String[0]); + + // 㼶ṹ + bomStructureMap.computeIfAbsent((TCComponentItemRevision) search[0], k -> new HashMap<>()) + .put(((TCComponentItemRevision) search2[0]).getUid(), propValues); + } + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + + + // ֲ㴦BOM ========== + for (Entry> parentEntry : bomStructureMap.entrySet()) { + TCComponentItemRevision parentLine = parentEntry.getKey(); + Map childrenMap = parentEntry.getValue(); + + // BOM + TCComponentBOMWindow view = winType.create(null); + view.lock(); + TCComponentBOMLine bomLine = view.setWindowTopLine(parentLine.getItem(), parentLine, null, null); + if (bomLine.hasChildren()) { + AIFComponentContext[] childrens = bomLine.getChildren(); + for (AIFComponentContext children : childrens) { + TCComponentBOMLine component = (TCComponentBOMLine) children.getComponent(); + String uid = component.getItemRevision().getUid(); + if (childrenMap.containsKey(uid)) { + // + try { + String[] values = childrenMap.get(uid); +// component.setProperties(mappedAttrs, values); + component.lock(); + TCProperty[] tcProperties = component.getTCProperties(mappedAttrs); + for(int m=0; m 0) { + JTextArea textArea = new JTextArea(builder.toString()); + textArea.setEditable(false); + JScrollPane scrollPane = new JScrollPane(textArea); + scrollPane.setPreferredSize(new Dimension(400, 300)); + JOptionPane.showMessageDialog(null, scrollPane, "ʾ", JOptionPane.INFORMATION_MESSAGE); + } + } + + // ȫȡԪ + private String getCellStringValue(Cell cell) { + if (cell == null) + return ""; + switch (cell.getCellType()) { + case Cell.CELL_TYPE_STRING: + return cell.getStringCellValue().trim(); + case Cell.CELL_TYPE_NUMERIC: + DataFormatter formatter = new DataFormatter(); + return formatter.formatCellValue(cell); + default: + return ""; + } + } + + /** + * ֤ļǷΪ.xlsxʽ + */ + private static boolean isXlsxFile(java.io.File file) { + return file != null && file.isFile() && (file.getName().toLowerCase().endsWith(".xlsx")); + } +} diff --git a/src/com/connor/rb/plm/rb036/Test.java b/src/com/connor/rb/plm/rb036/Test.java new file mode 100644 index 0000000..2a374c4 --- /dev/null +++ b/src/com/connor/rb/plm/rb036/Test.java @@ -0,0 +1,138 @@ +/** * @Title: Test.java + * @Package com.connor.rb.plm.rb036 + * @Description: TODO(һ仰ļʲô) + * @author admin * @date 2025225 + * @version V1.0 + */ +package com.connor.rb.plm.rb036; + + +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCSession; + +import cn.com.origin.autocode.newitem.generatcode.BorderLayout; +import cn.hutool.db.Session; + +/** + * @ClassName: Test + * @Description: TODO(һ仰) + * @author admin + * @date 2025225 + * + */ +public class Test extends JFrame { + private JLabel[] jLabels; + private JTextField[] jTextFields; + private LinkedHashMap proHashMap; + + public Test(LinkedHashMap proHashMap) { + this.proHashMap = proHashMap; + this.jLabels = new JLabel[proHashMap.size()]; + this.jTextFields = new JTextField[proHashMap.size()]; + + int i = 0; + for (String key : proHashMap.keySet()) { + jLabels[i] = new JLabel(key); + jTextFields[i] = new JTextField(17); // ʹ JButton Ϊʾ + i++; + } + } + + public void showUI() { + this.setTitle(""); + this.setSize(400, 500); + + JButton okButton = new JButton("ȷ"); + JButton cancelButton = new JButton("ȡ"); + + JScrollPane centerPanel = getCenterPanel(); + JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 70, 10)); + bottomPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); + bottomPanel.add(okButton); + bottomPanel.add(cancelButton); + + okButton.addActionListener(e -> { + System.out.println("ȷť"); + // Ӵ߼ + }); + + cancelButton.addActionListener(e -> { + System.out.println("ȡť"); + this.dispose(); // رմ + }); + + this.getContentPane().add(centerPanel, java.awt.BorderLayout.CENTER); + this.getContentPane().add(bottomPanel, java.awt.BorderLayout.SOUTH); + this.setLocationRelativeTo(null); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.setVisible(true); + } + + private JScrollPane getCenterPanel() { + JPanel centerPanel = new JPanel(new GridBagLayout()); + GridBagConstraints customLayout = new GridBagConstraints(); + + for (int i = 0; i < proHashMap.size(); i++) { + customLayout.insets = new Insets(5, 30, 5, 20); // ߾ + customLayout.gridx = 0; + customLayout.weightx = 0; + customLayout.anchor = GridBagConstraints.LINE_START; + jLabels[i].setFont(new Font("΢ź", Font.BOLD, 13)); + centerPanel.add(jLabels[i], customLayout); + + customLayout.insets = new Insets(5, 3, 5, 30); // ߾ + customLayout.gridx = 1; + customLayout.weightx = 0; + customLayout.fill = GridBagConstraints.HORIZONTAL; + JTextField jTextField = jTextFields[i]; + jTextField.setFont(new Font("΢ź", Font.BOLD, 15)); + centerPanel.add(jTextField, customLayout); + } + + return new JScrollPane(centerPanel); + } + + public static void main(String[] args) { + LinkedHashMap map = new LinkedHashMap<>(); + map.put("1", "ֵ1"); + map.put("2", "ֵ2"); + map.put("3", "ֵ3"); + map.put("4", "ֵ1"); + map.put("5", "ֵ2"); + map.put("6", "ֵ3"); + map.put("7", "ֵ1"); + map.put("8", "ֵ2"); + map.put("9", "ֵ3"); + map.put("11", "ֵ1"); + map.put("21", "ֵ2"); + map.put("31", "ֵ3"); + map.put("41", "ֵ1"); + map.put("51", "ֵ2"); + map.put("61", "ֵ3"); + map.put("71", "ֵ1"); + map.put("81", "ֵ2"); + map.put("91", "ֵ3"); + Test operationTest = new Test(map); + operationTest.showUI(); + } +} diff --git a/src/com/connor/rb/plm/rb037/SetResponsiblePersonHandler.java b/src/com/connor/rb/plm/rb037/SetResponsiblePersonHandler.java new file mode 100644 index 0000000..a8c93db --- /dev/null +++ b/src/com/connor/rb/plm/rb037/SetResponsiblePersonHandler.java @@ -0,0 +1,47 @@ +package com.connor.rb.plm.rb037; + +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.jobs.Job; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class SetResponsiblePersonHandler extends AbstractHandler { + private static AbstractAIFApplication app; + private static TCSession session; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); + + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if(targetComponent == null) { + MessageBox.post("ѡ̶в", "ʾ", MessageBox.INFORMATION); + return null; + } + if(targetComponent instanceof TCComponentTask) { + + session.queueOperation(new SetResponsiblePersonOperation((TCComponentTask) targetComponent,session)); + + }else { + MessageBox.post("ѡ̶в", "ʾ", MessageBox.INFORMATION); + } + return null; + } + + + +} diff --git a/src/com/connor/rb/plm/rb037/SetResponsiblePersonOperation.java b/src/com/connor/rb/plm/rb037/SetResponsiblePersonOperation.java new file mode 100644 index 0000000..cd5907f --- /dev/null +++ b/src/com/connor/rb/plm/rb037/SetResponsiblePersonOperation.java @@ -0,0 +1,87 @@ +package com.connor.rb.plm.rb037; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.connor.rb.plm.util.SoaServerUtil; +import com.connor.rb.plm.util.TCUtils; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponentProcess; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class SetResponsiblePersonOperation extends AbstractAIFOperation{ + private static TCComponentTask componentTask; + private static TCSession session; + + public SetResponsiblePersonOperation(TCComponentTask targetComponent, TCSession session) { + // TODO Auto-generated constructor stub + this.componentTask = targetComponent; + this.session = session; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + // JLabel ΪʾϢ + JLabel label = new JLabel("ˣ"); + + // JTextField ı򣬳ʼΪ 20 ַ + JTextField textField = new JTextField(20); + + // ʹ JPanel + JPanel panel = new JPanel(); + panel.add(label); + panel.add(textField); + + // ʾԻ򣬻ȡû OK Cancel + int option = JOptionPane.showConfirmDialog(null, panel, "", JOptionPane.OK_CANCEL_OPTION); + + // û OK򷵻ıݣ򷵻 null + if (option == JOptionPane.OK_OPTION) { + SoaServerUtil.openByPass(session); + TCUtils.openLogByPass(session, "д"); + String text = textField.getText(); + System.out.println("û: " + text); + try { + //дobject_desc£жǷд + componentTask.setProperty("object_desc", text); + //жϵǰǷѾеĻԭ¹ֱӹ + String jobName = componentTask.getProperty("job_name"); + System.out.println("jobName:"+jobName); + //ȡǰʱ + LocalDateTime now = LocalDateTime.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + String formattedTime = now.format(formatter); + // + String taskName = ""; + if(jobName.contains("##")) { + taskName = jobName.split("##")[0] + "##" + text + "-" + formattedTime; + }else { + taskName = jobName + "##" + text + "-" + formattedTime; + } + // + TCComponentProcess process = componentTask.getProcess(); + process.setProperty("object_name",taskName); + componentTask.refresh(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + TCUtils.closeLogByPass(session, "д"); + SoaServerUtil.closeByPass(session); + } + return ; + } else { + System.out.println("ûȡΪա"); + } + } + +} diff --git a/src/com/connor/rb/plm/util/CNClassPropBean.java b/src/com/connor/rb/plm/util/CNClassPropBean.java new file mode 100644 index 0000000..676e6e5 --- /dev/null +++ b/src/com/connor/rb/plm/util/CNClassPropBean.java @@ -0,0 +1,127 @@ +package com.connor.rb.plm.util; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import javax.swing.DefaultComboBoxModel; + +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; + +public class CNClassPropBean { + // ICSFormate + public int propID; + public String propDisName; + public String relValue; + public String displayValue; + + public int attrType; + public boolean isLov; + public HashMap lovMapping; + public List keyList; + public ICSAdminClassAttribute icsAttr; + public int intsize = 0; + public int floatsize = 0; + public String formate; + private DefaultComboBoxModel model; + + public CNClassPropBean(ICSAdminClassAttribute icsAttr) { + // System.out.println("attr id :"+icsAttr.getAttributeId()+" attr naem + // :"+icsAttr.getName()); + this.icsAttr = icsAttr; + this.propID = icsAttr.getAttributeId(); + this.propDisName = icsAttr.getName(); + this.formate = icsAttr.getFormat2().getDisplayString(); + if (icsAttr.getFormat1().isReal()) { + floatsize = icsAttr.getFormat2().getFlagB(); + intsize = icsAttr.getFormat2().getFlagC(); + } + + this.attrType = icsAttr.getFormat1().getType(); + ICSKeyLov lov1 = icsAttr.getFormat1().getKeyLov(); + + lov1 = (lov1 == null ? icsAttr.getFormat2().getKeyLov() : lov1); + lovMapping = new HashMap<>(); + keyList = new ArrayList<>(); + if (lov1 != null) { + this.isLov = true; +// String[] keys = lov1.getKeys(); +// for (String key : keys) { +// String value = lov1.getValueOfKey(key); +// lovMapping.put(value, key); +// keyList.add(value); +// } + String[] dvalue = lov1.getValues(); + this.model = new DefaultComboBoxModel(dvalue); + } else { + this.isLov = false; + } + } + + public DefaultComboBoxModel getModel() { + return model; + } + + public void setModel(DefaultComboBoxModel model) { + this.model = model; + } + + public int getPropID() { + return propID; + } + + public String getPropDisName() { + return propDisName; + } + + public String getRelValue() { + return relValue; + } + + public String getDisplayValue() { + return displayValue; + } + + public int getAttrType() { + return attrType; + } + + public boolean isLov() { + return isLov; + } + + public HashMap getLovMapping() { + return lovMapping; + } + + public List getKeyList() { + return keyList; + } + + public ICSAdminClassAttribute getIcsAttr() { + return icsAttr; + } + + public int getIntsize() { + return intsize; + } + + public int getFloatsize() { + return floatsize; + } + + public String getFormate() { + return formate; + } + + public void setDisplayValue(String displayValue) { + this.displayValue = displayValue; + } + + @Override + public String toString() { + return propDisName + ":"; + } + +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/util/CalendarPanel.java b/src/com/connor/rb/plm/util/CalendarPanel.java new file mode 100644 index 0000000..47e0c2d --- /dev/null +++ b/src/com/connor/rb/plm/util/CalendarPanel.java @@ -0,0 +1,519 @@ +package com.connor.rb.plm.util; + +/** + * Calender + * @author BAOMH www.hotheme.com + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import javax.swing.AbstractAction; +import javax.swing.InputMap; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JSpinner; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.KeyStroke; +import javax.swing.ListSelectionModel; +import javax.swing.SpinnerNumberModel; +import javax.swing.SwingConstants; +import javax.swing.UIManager; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; + +public class CalendarPanel extends JDialog { + private JComboBox comboBoxMonth; + private JSpinner spinnerYear; + private JTable2 table; + private JTableModel2 tableModel; + private Calendar calendar; + public Date selecttime; + private String[] days = { "", "һ", "ڶ", "", "", "", "" }; + private String[] months = { "һ", "", "", "", "", "", "", "", "", "ʮ", "ʮһ", "ʮ" }; + private int year = -1; + private int month = -1; + private int date = -1; + private int oldYear = -1; + private int oldMonth = -1; + private int oldDate = -1; + private boolean flag = true; + private JButton okButton; + private JButton cancelButton; + private JTextField text; +// private TableWithRowHead twrh; + private boolean bo; + + public Date getSelecttime() { + return selecttime; + } + + public void setSelecttime(Date selecttime) { + this.selecttime = selecttime; + } + + public CalendarPanel(JFrame frame) { + + super(frame, true); + this.setTitle("ѡ"); + calendar = Calendar.getInstance(); + initComponent(); + setSize(350, 300); + center(); + setVisible(true); + } + + public CalendarPanel(JTextField arg0) { + this.text = arg0; + this.setTitle("ѡ"); + calendar = Calendar.getInstance(); + initComponent(); + setSize(350, 300); + center(); + setVisible(true); + } + + /* + * public CalendarPanel(TableWithRowHead twrh,boolean bo) { this.twrh = twrh; + * this.bo=bo; this.setTitle("ѡ"); calendar = Calendar.getInstance(); + * initComponent(); setSize(350, 300); center(); setAlwaysOnTop(true); + * setVisible(true); } + */ + public CalendarPanel() { + this.setTitle("ѡ"); + calendar = Calendar.getInstance(); + initComponent(); + setSize(350, 300); + center(); + setVisible(true); + } + + public CalendarPanel(Calendar calendar) { + + super(); + this.calendar = calendar; + initComponent(); + setSize(350, 300); + center(); + setVisible(true); + } + + public CalendarPanel(Date date) { + + super(); + this.calendar = Calendar.getInstance(); + this.calendar.setTime(date); + initComponent(); + setSize(350, 300); + center(); + setVisible(true); + } + + public CalendarPanel(int year, int month, int date) { + + super(); + this.calendar = Calendar.getInstance(); + calendar.set(Calendar.YEAR, year); + calendar.set(Calendar.MONTH, month - 1); + calendar.set(Calendar.DATE, date); + oldYear = calendar.get(Calendar.YEAR); + oldMonth = calendar.get(Calendar.MONTH); + oldDate = calendar.get(Calendar.DATE); + initComponent(); + setSize(350, 300); + center(); + setVisible(true); + } + + public void center() { + + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + Dimension frameSize = getSize(); + + if (frameSize.height > screenSize.height) { + frameSize.height = screenSize.height; + } + if (frameSize.width > screenSize.width) { + frameSize.width = screenSize.width; + } + + super.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); + } + + public Calendar getCalendar() { + return calendar; + } + + public String getCalendarByDate(String tag) { + + StringBuffer strRet = new StringBuffer(); + if (calendar != null) { + oldYear = calendar.get(Calendar.YEAR); + oldMonth = calendar.get(Calendar.MONTH) + 1; + oldDate = calendar.get(Calendar.DATE); + + strRet.append(oldYear); + strRet.append(tag); + if (oldMonth < 10) + strRet.append("0" + oldMonth); + else + strRet.append(oldMonth); + strRet.append(tag); + if (oldDate < 10) + strRet.append("0" + oldDate); + else + strRet.append(oldDate); + + return strRet.toString(); + } + return null; + } + + public Date getCalendarByDate() { + if (calendar != null) + return calendar.getTime(); + return null; + } + + // ʼpanel + private void initComponent() { + oldYear = calendar.get(Calendar.YEAR); + oldMonth = calendar.get(Calendar.MONTH); + oldDate = calendar.get(Calendar.DATE); + // this.setBorder(new TitledBorder("Date")); + this.getContentPane().setLayout(new BorderLayout()); + setNorthPanel(); + setCenterPanel(); + setSouthPanel(); + eventListenter(); + setData(); + } + + // Ĭϵʱ伴Ϊǰʱ + private void setData() { + + year = calendar.get(Calendar.YEAR); + month = calendar.get(Calendar.MONTH); + date = calendar.get(Calendar.DATE); + comboBoxMonth.setSelectedIndex(month); + spinnerYear.setValue(new Integer(year)); + } + + private void eventListenter() { + + spinnerYear.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + year = Integer.parseInt(String.valueOf(spinnerYear.getValue())); + refreshTable(); + } + }); + + comboBoxMonth.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + month = comboBoxMonth.getSelectedIndex(); + refreshTable(); + } + }); + + table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + public void valueChanged(ListSelectionEvent e) { + if (table.getSelectedRow() > -1 && table.getSelectedColumn() > -1) { + date = Integer.parseInt( + String.valueOf(table.getValueAt(table.getSelectedRow(), table.getSelectedColumn()))); + calendar.set(Calendar.YEAR, year); + calendar.set(Calendar.MONTH, month); + calendar.set(Calendar.DATE, date); + } + } + }); + + AbstractAction right = (new AbstractAction() { + private static final long serialVersionUID = -3429888240127305492L; + + public void actionPerformed(ActionEvent e) { + if (table.getColumnCount() == table.getSelectedColumn() + 1) { + table.changeSelection(table.getSelectedRow() + 1, 0, false, false); + } else { + table.changeSelection(table.getSelectedRow(), table.getSelectedColumn() + 1, false, false); + } + } + }); + + AbstractAction left = (new AbstractAction() { + private static final long serialVersionUID = -2487040789339112435L; + + public void actionPerformed(ActionEvent e) { + if (0 > table.getSelectedColumn() - 1) { + table.changeSelection(table.getSelectedRow() - 1, table.getColumnCount() - 1, false, false); + } else { + table.changeSelection(table.getSelectedRow(), table.getSelectedColumn() - 1, false, false); + } + } + }); + + InputMap inputMap = table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0); + table.getActionMap().put(inputMap.get(keyStroke), right); + keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0); + table.getActionMap().put(inputMap.get(keyStroke), left); + okButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + calendar.set(Calendar.YEAR, Integer.parseInt(String.valueOf(spinnerYear.getValue()))); + calendar.set(Calendar.MONTH, comboBoxMonth.getSelectedIndex()); + calendar.set(Calendar.DATE, Integer + .parseInt(String.valueOf(table.getValueAt(table.getSelectedRow(), table.getSelectedColumn())))); + + oldYear = calendar.get(Calendar.YEAR); + oldMonth = calendar.get(Calendar.MONTH); + oldDate = calendar.get(Calendar.DATE); + selecttime = CalendarPanel.this.getCalendarByDate(); +// TableWithRowHead tw = new TableWithRowHead(twrh,selecttime,bo); + SimpleDateFormat sdf = new SimpleDateFormat("YYYY-M-d HH:MM"); + text.setText(sdf.format(selecttime)); + setVisible(false); + } + + }); + + cancelButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + setVisible(false); + } + }); + /* + * addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent + * e) { calendar = null; super.windowClosing(e); } }); + */ + + } + + private void refreshTable() { + for (int i = tableModel.getRowCount() - 1; i > 0; i--) { + tableModel.removeRow(i); + } + calendar.set(Calendar.YEAR, year); + calendar.set(Calendar.MONTH, month); + int maxDate = calendar.getActualMaximum(Calendar.DATE); + calendar.set(Calendar.DATE, 1); + int startDay = calendar.get(Calendar.DAY_OF_WEEK); + for (int i = 0; i < 6; i++) { + tableModel.addRow(new Object[7]); + } + int selectRow = -1; + int selectColumn = -1; + for (int i = 0; i < maxDate; i++) { + int m = (int) ((startDay - 1) / 7) + 1; + int n = (startDay - 1) % 7; + tableModel.setValueAt(String.valueOf(i + 1), m, n); + startDay = startDay + 1; + if (date != -1 && date == i + 1) { + selectRow = m; + selectColumn = n; + } + } + table.changeSelection(selectRow, selectColumn, false, false); + } + + private void setSouthPanel() { + + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout(FlowLayout.RIGHT)); + okButton = new JButton("OK"); + panel.add(okButton); + cancelButton = new JButton("Cancel"); + panel.add(cancelButton); + this.getContentPane().add(panel, BorderLayout.SOUTH); + } + + private void setCenterPanel() { + + table = new JTable2(); + tableModel = new JTableModel2(); + tableModel.setColumnIdentifiers(days); + tableModel.addRow(days); + table.setModel(tableModel); + for (int i = 0; i < 7; i++) { + table.getColumnModel().getColumn(i).setCellRenderer(new DefaultTableCellRenderer2()); + } + this.getContentPane().add(table, BorderLayout.CENTER); + } + + private void setNorthPanel() { + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout()); + comboBoxMonth = new JComboBox(); + for (int i = 0; i < months.length; i++) { + comboBoxMonth.addItem(months[i]); + } + comboBoxMonth.setSelectedIndex(-1); + panel.add(comboBoxMonth); + RolloverSpinnerListModel numberModel = new RolloverSpinnerListModel(1980, 1980, 2099, 1); + spinnerYear = new JSpinner(numberModel); + JSpinner.NumberEditor numberEditor = new JSpinner.NumberEditor(spinnerYear, ""); + spinnerYear.setEditor(numberEditor); + panel.add(spinnerYear); + this.getContentPane().add(panel, BorderLayout.NORTH); + } + + public static void main(String[] args) { + + JFrame frame = new JFrame(); + frame.setDefaultCloseOperation(EXIT_ON_CLOSE); + CalendarPanel calendarPanel = new CalendarPanel(frame); + // frame.getContentPane().add(calendarPanel, BorderLayout.CENTER); + // calendarPanel.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + calendarPanel.setVisible(true); + } + + protected void validateTree() { + + super.validateTree(); + if (flag) { + table.requestFocus(); + flag = false; + } + } +} + +class RolloverSpinnerListModel extends SpinnerNumberModel { + + private static final long serialVersionUID = 7366455425120197392L; + + public RolloverSpinnerListModel(int value, int minimum, int maximum, int stepSize) { + super(value, minimum, maximum, stepSize); + } + + public Object getNextValue() { + + Object returnValue = super.getNextValue(); + if (returnValue == null) { + returnValue = super.getMinimum(); + } + return returnValue; + } + + public Object getPreviousValue() { + + Object returnValue = super.getPreviousValue(); + if (returnValue == null) { + returnValue = super.getMaximum(); + } + return returnValue; + } +} + +class JTable2 extends JTable { + + private static final long serialVersionUID = 2092799354481792367L; + + public JTable2() { + this.getTableHeader().setReorderingAllowed(false); + this.getTableHeader().setResizingAllowed(false); + this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + this.setCellSelectionEnabled(true); + this.setGridColor(Color.white); + } + + public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) { + + if (this.getValueAt(rowIndex, columnIndex) == null) { + return; + } + + if (rowIndex == 0) { + return; + } + super.changeSelection(rowIndex, columnIndex, toggle, extend); + } + + public void repaint(int x, int y, int width, int height) { + + super.repaint(x, y, width, height); + if (height > 0) { + makeTableRowHeight(); + } + } + + protected void validateTree() { + super.validateTree(); + makeTableRowHeight(); + } + + private void makeTableRowHeight() { + + int rowHeight = (int) ((this.getHeight() / 7) * 0.6); + if (rowHeight > 0) { + this.setRowHeight(0, rowHeight); + } + + rowHeight = (int) ((this.getHeight() - rowHeight) / 6); + if (rowHeight > 0) { + for (int i = 1; i < 8; i++) { + this.setRowHeight(i, rowHeight); + } + } + } +} + +class JTableModel2 extends DefaultTableModel { + + private static final long serialVersionUID = 3655520869200784738L; + + public boolean isCellEditable(int row, int column) { + return false; + } +} + +class DefaultTableCellRenderer2 extends DefaultTableCellRenderer { + + private static final long serialVersionUID = -8779549993366848535L; + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, + int row, int column) { + Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + this.setHorizontalAlignment(SwingConstants.CENTER); + + if (row == 0) { + component.setBackground(UIManager.getColor("Table.focusCellForeground")); + + component.setForeground(UIManager.getColor("Table.focusCellBackground")); + return component; + } else { + if (isSelected) { + component.setBackground(UIManager.getColor("Table.focusCellForeground")); + component.setForeground(UIManager.getColor("Table.focusCellBackground")); + } else { + component.setBackground(UIManager.getColor("Table.focusCellBackground")); + component.setForeground(UIManager.getColor("Table.focusCellForeground")); + } + + if (column == 0 || column == 6) { + component.setForeground(Color.red); + } + } + return component; + } +} diff --git a/src/com/connor/rb/plm/util/ClassAttributeBean.java b/src/com/connor/rb/plm/util/ClassAttributeBean.java new file mode 100644 index 0000000..9c13853 --- /dev/null +++ b/src/com/connor/rb/plm/util/ClassAttributeBean.java @@ -0,0 +1,66 @@ +package com.connor.rb.plm.util; + +import java.util.Map; + +public class ClassAttributeBean { + private int id;// id + private String name;// + private boolean islov;// Ƿlov + private int type;// + private Map lov;// lovʾֵ(key),ʵֵ(val) + private String val;// ֵ + + public String getVal() { + return val; + } + + public void setVal(String val) { + this.val = val; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public boolean isIslov() { + return islov; + } + + public void setIslov(boolean islov) { + this.islov = islov; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public Map getLov() { + return lov; + } + + public void setLov(Map lov) { + this.lov = lov; + } + + @Override + public String toString() { + return "ClassAttributeBean [id=" + id + ", name=" + name + ", islov=" + islov + ", type=" + type + "]"; + } + +} diff --git a/src/com/connor/rb/plm/util/ClassAttributeBean2.java b/src/com/connor/rb/plm/util/ClassAttributeBean2.java new file mode 100644 index 0000000..d2c2294 --- /dev/null +++ b/src/com/connor/rb/plm/util/ClassAttributeBean2.java @@ -0,0 +1,75 @@ +package com.connor.rb.plm.util; + +import java.util.Map; + +public class ClassAttributeBean2 { + private int id;// id + private String name;// + private boolean islov;// Ƿlov + private int type;// + private Map lov;// lovʾֵ(key),ʵֵ(val) + private String val;// ֵ + private String val2; + + public String getVal2() { + return val2; + } + + public void setVal2(String val2) { + this.val2 = val2; + } + + public String getVal() { + return val; + } + + public void setVal(String val) { + this.val = val; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public boolean isIslov() { + return islov; + } + + public void setIslov(boolean islov) { + this.islov = islov; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public Map getLov() { + return lov; + } + + public void setLov(Map lov) { + this.lov = lov; + } + + @Override + public String toString() { + return "ClassAttributeBean [id=" + id + ", name=" + name + ", islov=" + islov + ", type=" + type + "]"; + } + +} diff --git a/src/com/connor/rb/plm/util/ClassPropBean.java b/src/com/connor/rb/plm/util/ClassPropBean.java new file mode 100644 index 0000000..73c41b4 --- /dev/null +++ b/src/com/connor/rb/plm/util/ClassPropBean.java @@ -0,0 +1,63 @@ +package com.connor.rb.plm.util; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; + +public class ClassPropBean { + // ICSFormate + public int propID; + public String propDisName; + public String relValue; + public String displayValue; + + public int attrType; + public boolean isLov; + public HashMap lovMapping; + public List keyList; + public ICSAdminClassAttribute icsAttr; + public int intsize = 0; + public int floatsize = 0; + public String formate; + + public ClassPropBean(ICSAdminClassAttribute icsAttr) { + // System.out.println("attr id :"+icsAttr.getAttributeId()+" attr naem + // :"+icsAttr.getName()); + this.icsAttr = icsAttr; + this.propID = icsAttr.getAttributeId(); + this.propDisName = icsAttr.getName(); + this.formate = icsAttr.getFormat2().getDisplayString(); + if (icsAttr.getFormat1().isReal()) { + floatsize = icsAttr.getFormat2().getFlagB(); + intsize = icsAttr.getFormat2().getFlagC(); + } + this.attrType = icsAttr.getFormat1().getType(); + ICSKeyLov lov1 = icsAttr.getFormat1().getKeyLov(); + + lov1 = (lov1 == null ? icsAttr.getFormat2().getKeyLov() : lov1); + lovMapping = new HashMap(); + keyList = new ArrayList(); + if (lov1 != null) { + this.isLov = true; + String[] keys = lov1.getKeys(); + for (String key : keys) { + String value = lov1.getValueOfKey(key); + if (!("".equals(value)) && !(" ".equals(value)) && !(" ".equals(key)) && !(" ".equals(key))) { + lovMapping.put(key, value); + keyList.add(value); + } + } + } else { + this.isLov = false; + } + } + + @Override + public String toString() { + return propDisName + ":"; + } + +} diff --git a/src/com/connor/rb/plm/util/ClassProperty.java b/src/com/connor/rb/plm/util/ClassProperty.java new file mode 100644 index 0000000..3f4484b --- /dev/null +++ b/src/com/connor/rb/plm/util/ClassProperty.java @@ -0,0 +1,42 @@ +package com.connor.rb.plm.util; + +/** + * @copyRight 㽭տƼ޹˾ + * @author E-mail:hub@connor.net.cn + * @date ʱ䣺2017-7-3 11:47:03 + * @version v1.0 + * @parameter + * @since + * @return + */ + +public class ClassProperty { + private int propertyID; + private String value; + + public ClassProperty() { + + } + + public ClassProperty(int propertyID, String value) { + this.propertyID = propertyID; + this.value = value; + } + + public int getPropertyID() { + return propertyID; + } + + public void setPropertyID(int propertyID) { + this.propertyID = propertyID; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/src/com/connor/rb/plm/util/CodeBean.java b/src/com/connor/rb/plm/util/CodeBean.java new file mode 100644 index 0000000..c5b09f5 --- /dev/null +++ b/src/com/connor/rb/plm/util/CodeBean.java @@ -0,0 +1,118 @@ +package com.connor.rb.plm.util; + +import java.util.List; + +/** + * ʵ + * + * @author zl + * + */ +public class CodeBean { + private String type; // + private List names; // + private String name; // + private List codes; // + private String code; // ǰ׺ + private String min; // ˮСֵ + private String max; // ˮֵ + private String num; // ˮλ(0ʾ) 5λΪ00000 + private String end; // ׺ + private String classID; // id + private CopyPropsBean copyPropBean;// Ҫͬ(->) + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public List getNames() { + return names; + } + + public void setNames(List names) { + this.names = names; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getCodes() { + return codes; + } + + public void setCodes(List codes) { + this.codes = codes; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMin() { + return min; + } + + public void setMin(String min) { + this.min = min; + } + + public String getMax() { + return max; + } + + public void setMax(String max) { + this.max = max; + } + + public String getNum() { + return num; + } + + public void setNum(String num) { + this.num = num; + } + + public String getEnd() { + return end; + } + + public void setEnd(String end) { + this.end = end; + } + + public String getClassID() { + return classID; + } + + public void setClassID(String classID) { + this.classID = classID; + } + + public CopyPropsBean getCopyPropBean() { + return copyPropBean; + } + + public void setCopyPropBean(CopyPropsBean copyPropBean) { + this.copyPropBean = copyPropBean; + } + + @Override + public String toString() { + return "CodeBean [type=" + type + ", names=" + names + ", name=" + name + ", codes=" + codes + ", code=" + code + + ", min=" + min + ", max=" + max + ", num=" + num + ", end=" + end + ", classID=" + classID + "]"; + } + +} diff --git a/src/com/connor/rb/plm/util/CopyPropsBean.java b/src/com/connor/rb/plm/util/CopyPropsBean.java new file mode 100644 index 0000000..7f8a57d --- /dev/null +++ b/src/com/connor/rb/plm/util/CopyPropsBean.java @@ -0,0 +1,31 @@ +package com.connor.rb.plm.util; + +import java.util.List; + +/** + * ͬ + * + * @author zl + * + */ +public class CopyPropsBean { + private String type; // WF2_finPartRevision + private List props;// REV.object_desc=FORM.wf3_oldmaterial ... + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public List getProps() { + return props; + } + + public void setProps(List props) { + this.props = props; + } + +} diff --git a/src/com/connor/rb/plm/util/DataBaseControl.java b/src/com/connor/rb/plm/util/DataBaseControl.java new file mode 100644 index 0000000..aef56e6 --- /dev/null +++ b/src/com/connor/rb/plm/util/DataBaseControl.java @@ -0,0 +1,460 @@ +package com.connor.rb.plm.util; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.Statement; +import java.text.DecimalFormat; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; +import java.util.Vector; + +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class DataBaseControl { + + /** ************************ݿ:*********************************** */ + /** + * kelsen .... + */ + Connection conn; + + ResultSet rs; + + PreparedStatement pstmt; + + Statement stmt; + + String strSQLQuery; + + public String str_Information = ""; + + private String strDriver = "oracle.jdbc.driver.OracleDriver"; + private String strUrl = ""; + private String strUserName = ""; + private String strPassword = ""; + + /** + * + */ + public DataBaseControl(String strDriver, String strUrl, String strUserName, String strPassword) { + // this.strDriver ="oracle.jdbc.driver.OracleDriver";// + // this.strUrl = "jdbc:oracle:thin:@127.0.0.1:1521:tc";//· + // this.strUserName = "infodba";//ݿû + // this.strPassword = "infodba";//ݿ + + this.strDriver = strDriver; // "oracle.jdbc.driver.OracleDriver";// + this.strUrl = strUrl; // "jdbc:oracle:thin:@127.0.0.1:1521:tceng";//· + this.strUserName = strUserName; // "infodba";//ݿû + this.strPassword = strPassword; // "infodba";//ݿ + + // + try { + Class.forName(strDriver);// ͨڴ + } catch (ClassNotFoundException cnfe) { + cnfe.printStackTrace(); + } + // try { + // Class.forName("org.objectweb.rmijdbc.Driver").newInstance(); + // } catch (InstantiationException e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } catch (IllegalAccessException e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } catch (ClassNotFoundException e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } + } + + /** + * + */ + public DataBaseControl(TCSession session) { + + String[] stringArray = session.getPreferenceService().getStringArray(4, "WF2_SQL_Connect"); + if (stringArray != null && stringArray.length == 3) { + strUrl = "jdbc:oracle:thin:@" + stringArray[0]; + strUserName = stringArray[1]; + strPassword = stringArray[2]; + } else { + MessageBox.post("δWF2_SQL_Connectѡ޷Ϣ!", "", MessageBox.ERROR); + } + + // + try { + Class.forName(strDriver);// ͨڴ + } catch (ClassNotFoundException cnfe) { + cnfe.printStackTrace(); + } + + } + + /** + * + * + * @param strSQLQuery + */ + public void dbModify(String strSQLQuery) { + + openDataBase(); + + try { + stmt = conn.createStatement(); + stmt.executeUpdate(strSQLQuery); + } catch (SQLException sqle2) { + sqle2.printStackTrace(); + } + + closeDataBase(); + } + + /** + * ѯ + * + * @param strSQLQuery + * @return + */ + public ResultSet dbQuery(String strSQLQuery) { + ResultSet rs_result = null; + if (conn == null) + openDataBase(); + try { + stmt = conn.createStatement(); + rs_result = stmt.executeQuery(strSQLQuery); + + } catch (SQLException sqle2) { + sqle2.printStackTrace(); + } + return rs_result; + } + + /** + * ѯ2 + * + * @param strSQLQuery + * @return + */ + public ResultSet dbQuery2(String strSQLQuery, Object[] strs) { + ResultSet rs_result = null; + if (conn == null) + openDataBase(); + try { + // stmt = conn.createStatement(); + PreparedStatement ps = conn.prepareStatement(strSQLQuery); + for (int i = 0; i < strs.length; i++) { + ps.setObject(i + 1, strs[i]); + } + rs_result = ps.executeQuery(); + + } catch (SQLException sqle2) { + sqle2.printStackTrace(); + } + return rs_result; + } + + /** + * 2 + * + * @param strSQLQuery + */ + public void dbModify2(String strSQLQuery, Object[] strs) { + + openDataBase(); + + try { + // stmt = conn.createStatement(); + PreparedStatement ps = conn.prepareStatement(strSQLQuery); + for (int i = 0; i < strs.length; i++) { + ps.setObject(i + 1, strs[i]); + } + ps.executeUpdate(); + } catch (SQLException sqle2) { + sqle2.printStackTrace(); + } + + closeDataBase(); + } + + /** + * + * + */ + public void openDataBase() { + try { + // this.strUrl="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.29)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=tcprod)))"; + if (conn == null || conn.isClosed()) + conn = DriverManager.getConnection(strUrl, strUserName, strPassword); + } catch (SQLException sqle) { + sqle.printStackTrace(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("sjkljcwutil_display.TITLE") + sqle.getMessage(), "", 1); + } + } + + /** + * رݿ + * + */ + public void closeDataBase() { + try { + if (rs != null) { + try { + rs.close(); + } catch (SQLException sqlec) { + sqlec.printStackTrace(); + } + } + if (stmt != null) { + try { + stmt.close(); + } catch (SQLException sqlec) { + sqlec.printStackTrace(); + } + } + if (conn != null && !conn.isClosed()) { + try { + conn.close(); + } catch (SQLException sqlecon) { + sqlecon.printStackTrace(); + } + + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 䴫ݿвѯ ѯõĽÿһ¼װһHashMap,keyԱֶ + * ѯ¼VectorжٸHasnMapԪ + * + * @param strSQLQuery + * @return + * @author xuk + */ + public Vector orgQuery(String strSQLQuery) { + openDataBase(); + Vector v_result = new Vector(); + try { + ResultSet rs_get = dbQuery(strSQLQuery); + // System.out.println("RS_GET:"+rs_get); + if (rs_get != null) { + ResultSetMetaData metaData = rs_get.getMetaData(); + + int i_ColumnCount = metaData.getColumnCount(); + // System.out.println("i_ColumnCount:"+i_ColumnCount); + while (rs_get.next()) { + // System.out.println("BJZJ2"+rs_get.getString("BJZJ2"));; + HashMap hm_unit = new HashMap(); + for (int i = 1; i <= i_ColumnCount; i++) { + hm_unit.put(metaData.getColumnName(i), rs_get.getString(i)); + // System.out.println("metaData.getColumnName(i):"+metaData.getColumnName(i)); + // System.out.println("rs_get.getString(i):"+rs_get.getString(i)); + } + v_result.add(hm_unit); + } + } else { + str_Information = "" + strSQLQuery + "" + "ѯĽΪ\n"; + } + } catch (Exception e) { + e.printStackTrace(); + } + return v_result; + } + + /** + * ˮ + * + * @param type ˮ + * @param prefix ǰ׺ + * @param col ˮλ 4λ"0000" + * @return + * @throws Exception + */ + public String getNewCode(String type, String prefix, String col) throws Exception { + openDataBase(); + String query = "select PREFIX,LSH from PLM_LSH where PLMTYPE= ? and PREFIX= ?"; + // ѯidݿе + ResultSet rs = dbQuery2(query, new Object[] { type, prefix }); + String lshstr = col; + String pre = ""; + String lsh = ""; + if (rs.next()) { + pre = rs.getString(1); + lsh = rs.getString(2); + System.out.println("sspre=" + pre); + System.out.println("sslsh=" + lsh); + if ("".equals(lsh)) { + throw new Exception("ˮΪգ"); + } + int ls = Integer.parseInt(lsh) + 1;// µˮ + lshstr = ls + ""; + if (col != null) { + DecimalFormat df = new DecimalFormat(col); + lshstr = df.format(ls); + } + String upin = "update PLM_LSH set LSH= ? where PLMTYPE= ? and PREFIX= ? "; + dbModify2(upin, new Object[] { lshstr, type, prefix }); + } else { + String upin = "insert into PLM_LSH(PLMTYPE,PREFIX,LSH) values ( ? , ? , ? )"; + dbModify2(upin, new Object[] { type, prefix, lshstr }); + + } + + closeDataBase(); + String newId = prefix + lshstr; + + return newId; + + } + + /** + * ˮ + * + * @param type ˮ + * @param prefix ǰ׺ + * @param col ˮλ 4λ"0000" + * @return + * @throws Exception + */ + public String getNewCode(String type, CodeBean selCodeBean) throws Exception { + String prefix = selCodeBean.getCode(); + String col = selCodeBean.getNum(); + String min = selCodeBean.getMin(); + String max = selCodeBean.getMax(); + openDataBase(); + String query = "select PREFIX,LSH from PLM_LSH where PLMTYPE= ? and PREFIX= ?"; + // ѯidݿе + ResultSet rs = dbQuery2(query, new Object[] { type, prefix }); + String lshstr = col; + String pre = ""; + String lsh = ""; + if (rs.next()) { + pre = rs.getString(1); + lsh = rs.getString(2); + System.out.println("sspre=" + pre); + System.out.println("sslsh=" + lsh); + if ("".equals(lsh)) { + throw new Exception("ˮΪգ"); + } + int ls = Integer.parseInt(lsh) + 1;// µˮ + int minls = Integer.parseInt(min); + int maxls = Integer.parseInt(max); + if (minls > ls) { + ls = minls; + } + if (ls > maxls) { + System.out.println(":ˮѳֵ"); + return "MAXERR"; + } + lshstr = ls + ""; + if (col != null) { + DecimalFormat df = new DecimalFormat(col); + lshstr = df.format(ls); + } + String upin = "update PLM_LSH set LSH= ? where PLMTYPE= ? and PREFIX= ? "; + dbModify2(upin, new Object[] { lshstr, type, prefix }); + } else { + if (col != null) { + int minls = Integer.parseInt(min); + DecimalFormat df = new DecimalFormat(col); + lshstr = df.format(minls); + } + String upin = "insert into PLM_LSH(PLMTYPE,PREFIX,LSH) values ( ? , ? , ? )"; + dbModify2(upin, new Object[] { type, prefix, lshstr }); + + } + + closeDataBase(); + String newId = prefix + lshstr; + + return newId; + + } + + /** + * ģ» + * + * @param v3 + * @param v16 + * @param time + * @param user + * @throws Exception + */ + public void setSqlConn(String v3, String v16, String time, String user) throws Exception { + openDataBase(); +// WF_MJID varchar2(200),-- +// WF_YXJ varchar2(200),--» +// WF_DATE varchar2(200),--ϴ +// WF_USER varchar2(200),--ϴԱ + String query = "select WF_MJID from WF_MJ_XJ_T where WF_MJID = ? "; + // ѯidݿе + ResultSet rs = dbQuery2(query, new Object[] { v3 }); + String wfmjid = ""; + if (rs.next()) { + System.out.println(""); + wfmjid = rs.getString(1); + System.out.println("wfmjid=" + wfmjid); + String upup = "UPDATE WF_MJ_XJ_T set WF_YXJ = ? ,WF_DATE= ?, WF_USER = ? WHERE WF_MJID = ? "; + dbModify2(upup, new Object[] { v16, time, user, v3 }); + + } else { + System.out.println(""); + System.out.println("wfmjid=" + v3); + String upin = "insert into WF_MJ_XJ_T(WF_MJID,WF_YXJ,WF_DATE,WF_USER) values ( ?,? , ? , ? )"; + dbModify2(upin, new Object[] { v3, v16, time, user }); + + } + + closeDataBase(); + + return; + + } + + /** + * + * + * @param args + */ + public static void main(String args[]) { + try { + + String str_DataBaseDriver = "oracle.jdbc.driver.OracleDriver"; + String str_URL = "jdbc:oracle:thin:@localhost:1521:tc11"; + String str_UserName = "infodba"; + String str_Password = "infodba"; + DataBaseControl dbc = new DataBaseControl(str_DataBaseDriver, str_URL, str_UserName, str_Password); + // dbc.openDataBase(); + System.out.println("ӳɹ"); + // dbc.stmt = dbc.conn.createStatement(); + // String sql = "select * from PLM_LSH"; + // Vector rs_result = dbc.orgQuery(sql); + // for (int i = 0; i < rs_result.size(); i++) { + // HashMap map = (HashMap) + // rs_result.get(i); + // + // for (Map.Entry entry: map.entrySet()) { + // System.out.println(entry.getKey()+"---"+entry.getValue()); + // } + // } + String newid = dbc.getNewCode("PLMITEMID", "pz", "0000"); + System.out.println(newid); + // dbc.closeDataBase(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/rb/plm/util/ExcelUtil.java b/src/com/connor/rb/plm/util/ExcelUtil.java new file mode 100644 index 0000000..16ca04b --- /dev/null +++ b/src/com/connor/rb/plm/util/ExcelUtil.java @@ -0,0 +1,284 @@ +package com.connor.rb.plm.util; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.swing.JOptionPane; + +import org.apache.poi.ddf.EscherBSERecord; +import org.apache.poi.ddf.EscherBitmapBlip; +import org.apache.poi.hssf.model.InternalWorkbook; +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFClientAnchor; +import org.apache.poi.hssf.usermodel.HSSFPatriarch; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.hssf.util.HSSFCellUtil; + +/** + * Excelд + */ +public class ExcelUtil { + /** + * ܣHSSFSheet + * + * @param wb HSSFWorkbook + * @param sheetName String + * @return HSSFSheet + */ + public static HSSFSheet createSheet(HSSFWorkbook wb, String sheetName) { + HSSFSheet sheet = wb.createSheet(sheetName); + sheet.setDefaultColumnWidth(12); + sheet.setGridsPrinted(false); + sheet.setDisplayGridlines(false); + return sheet; + } + + /** + * ܣHSSFRow + * + * @param sheet HSSFSheet + * @param rowNum int + * @param height int + * @return HSSFRow + */ + public static HSSFRow createRow(HSSFSheet sheet, int rowNum, int height) { + HSSFRow row = sheet.createRow(rowNum); + row.setHeight((short) height); + return row; + } + + public static HSSFCell createCell0(HSSFRow row, int cellNum) { + HSSFCell cell = row.createCell(cellNum); + return cell; + } + + /** + * ܣCELL + * + * @param row HSSFRow + * @param cellNum int + * @param style HSSFStyle + * @return HSSFCell + */ + public static HSSFCell createCell(HSSFRow row, int cellNum, CellStyle style) { + HSSFCell cell = row.createCell(cellNum); + cell.setCellStyle(style); + return cell; + } + + /** + * ܣCellStyleʽ + * + * @param wb HSSFWorkbook + * @param backgroundColor ɫ + * @param foregroundColor ǰɫ + * @param font + * @return CellStyle + */ + public static CellStyle createCellStyle(HSSFWorkbook wb, short backgroundColor, short foregroundColor, short halign, + Font font) { + CellStyle cs = wb.createCellStyle(); + cs.setAlignment(CellStyle.ALIGN_CENTER);// halign + cs.setVerticalAlignment(CellStyle.VERTICAL_CENTER); + cs.setFillBackgroundColor(backgroundColor); + cs.setFillForegroundColor(foregroundColor); + cs.setFillPattern(CellStyle.SOLID_FOREGROUND); + cs.setFont(font); + return cs; + } + + /** + * ܣ߿CellStyleʽ + * + * @param wb HSSFWorkbook + * @param backgroundColor ɫ + * @param foregroundColor ǰɫ + * @param font + * @return CellStyle + */ + public static CellStyle createBorderCellStyle(HSSFWorkbook wb, short backgroundColor, short foregroundColor, + short halign, Font font) { + CellStyle cs = wb.createCellStyle(); + cs.setAlignment(halign); + cs.setVerticalAlignment(CellStyle.VERTICAL_CENTER); + cs.setFillBackgroundColor(backgroundColor); + cs.setFillForegroundColor(foregroundColor); + cs.setFillPattern(CellStyle.SOLID_FOREGROUND); + cs.setFont(font); + cs.setBorderLeft(CellStyle.BORDER_DASHED); + cs.setBorderRight(CellStyle.BORDER_DASHED); + cs.setBorderTop(CellStyle.BORDER_DASHED); + cs.setBorderBottom(CellStyle.BORDER_DASHED); + return cs; + } + + /** + * ܣже뵽Excelñʽ + */ + public static void writeArrayToExcel(HSSFSheet sheet, int rows, int cells, Object[][] value) { + Row row[] = new HSSFRow[rows]; + Cell cell[] = new HSSFCell[cells]; + for (int i = 0; i < row.length; i++) { + row[i] = sheet.createRow(i); + for (int j = 0; j < cell.length; j++) { + cell[j] = row[i].createCell(j); + cell[j].setCellValue(convertString(value[i][j])); + } + } + } + + /** + * ܣже뵽Excelñʽ + */ + public static void writeArrayToExcel(HSSFWorkbook wb, HSSFSheet sheet, int rows, int cells, Object[][] value) { + Row row[] = new HSSFRow[rows]; + Cell cell[] = new HSSFCell[cells]; + HSSFCellStyle ztStyle = (HSSFCellStyle) wb.createCellStyle(); + ztStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); + Font ztFont = wb.createFont(); + // ztFont.setBoldweight(Font.BOLDWEIGHT_BOLD); + // ztFont.setItalic(true); // Ϊб + // ztFont.setColor(Font.COLOR_RED); // Ϊɫ + ztFont.setFontHeightInPoints((short) 14); // СΪ18px + ztFont.setFontName(""); // пӦõǰԪ + // ztFont.setUnderline(Font.U_DOUBLE); + ztStyle.setFont(ztFont); + + HSSFCellStyle ztStyle1 = (HSSFCellStyle) wb.createCellStyle(); + ztStyle1.setAlignment(HSSFCellStyle.ALIGN_CENTER); + + // ͼĶһsheetֻܻȡһһҪע㣩 + HSSFPatriarch patriarch = sheet.createDrawingPatriarch(); + for (int i = 0; i < row.length; i++) { + row[i] = sheet.createRow(i); + for (int j = 0; j < cell.length; j++) { + cell[j] = row[i].createCell(j); + if (0 == i) { + cell[j].setCellValue(convertString(value[i][j])); + cell[j].setCellStyle(ztStyle); + } else if (1 == i) { + cell[j].setCellValue(convertString(value[i][j])); + cell[j].setCellStyle(ztStyle1); + } else { + if (1 == j) { + // anchorҪͼƬ + if (value[i][j] != null) { + HSSFClientAnchor anchor = new HSSFClientAnchor(50, 10, 1000, 240, (short) j, i, (short) j, + i); + anchor.setAnchorType(3); + patriarch.createPicture(anchor, + wb.addPicture(((ByteArrayOutputStream) value[i][j]).toByteArray(), + HSSFWorkbook.PICTURE_TYPE_JPEG)); + } + } else { + cell[j].setCellValue(convertString(value[i][j])); + } + cell[j].setCellStyle(ztStyle1); + row[i].setHeight((short) 600); + } + } + } + sheet.setColumnWidth(4, 4000); + sheet.setColumnWidth(6, 4000); + mergeCell(sheet, 0, 0, 0, cell.length - 1); + } + + /** + * ܣϲԪ + * + * @param sheet HSSFSheet + * @param firstRow int + * @param lastRow int + * @param firstColumn int + * @param lastColumn int + * @return int ϲ + */ + public static int mergeCell(HSSFSheet sheet, int firstRow, int lastRow, int firstColumn, int lastColumn) { + return sheet.addMergedRegion(new CellRangeAddress(firstRow, lastRow, firstColumn, lastColumn)); + } + + /** + * ܣ + * + * @param wb HSSFWorkbook + * @param boldweight short + * @param color short + * @return Font + */ + public static Font createFont(HSSFWorkbook wb, short boldweight, short color, short size) { + Font font = wb.createFont(); + font.setBoldweight(boldweight); + font.setColor(color); + font.setFontHeightInPoints(size); + return font; + } + + /** + * úϲԪı߿ʽ + * + * @param sheet HSSFSheet + * @param ca CellRangAddress + * @param style CellStyle + */ + public static void setRegionStyle(HSSFSheet sheet, CellRangeAddress ca, CellStyle style) { + for (int i = ca.getFirstRow(); i <= ca.getLastRow(); i++) { + HSSFRow row = HSSFCellUtil.getRow(i, sheet); + for (int j = ca.getFirstColumn(); j <= ca.getLastColumn(); j++) { + HSSFCell cell = HSSFCellUtil.getCell(row, j); + cell.setCellStyle(style); + } + } + } + + /** + * ܣHSSFWorkbookдExcelļ + * + * @param wb HSSFWorkbook + * @param absPath дļ· + * @param wbName ļ + */ + public static void writeWorkbook(HSSFWorkbook wb, String fileName) { + FileOutputStream fos = null; + File f = new File(fileName); + try { + fos = new FileOutputStream(f); + wb.write(fos); + int dialog = JOptionPane.showConfirmDialog(null, f.getName() + "ɹǷ򿪣", "ܰʾ", + JOptionPane.YES_NO_OPTION); + if (dialog == JOptionPane.YES_OPTION) { + Runtime.getRuntime().exec("cmd /c start \"\" \"" + fileName + "\""); + } + } catch (FileNotFoundException e) { + JOptionPane.showMessageDialog(null, "ǰرչ"); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "ûнɸѡ"); + } finally { + try { + if (fos != null) { + fos.close(); + } + } catch (IOException e) { + } + } + } + + public static String convertString(Object value) { + if (value == null) { + return ""; + } else { + return value.toString(); + } + } + +} diff --git a/src/com/connor/rb/plm/util/GetCodeBean.java b/src/com/connor/rb/plm/util/GetCodeBean.java new file mode 100644 index 0000000..81c3f77 --- /dev/null +++ b/src/com/connor/rb/plm/util/GetCodeBean.java @@ -0,0 +1,76 @@ +package com.connor.rb.plm.util; + +import java.io.File; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class GetCodeBean { + private MenuCodeBean bean; + private List codeBeanList; + + public GetCodeBean(TCSession session) { + ParseXML xml = new ParseXML(); + File file = xml.getSXX("RB3_Code_Xml", session); + bean = xml.parseXMLCode(file); + } + + /** + * + * һµʵ GetCodeBean 췽 + * + * @param session + * @param XZLS + */ + public GetCodeBean(TCSession session, String XZLS) { + ParseXML xml = new ParseXML(); + File file = xml.getSXX("RB3_Code_Xml_XZLS", session); + bean = xml.parseXMLCode(file); + } + + /** + * ñ + * + * @param names :Ʒ& + * @return + */ + public CodeBean getCodebean(String names) { + codeBeanList = bean.getCodeBeanList(); + CodeBean selCodeBean = null; + for (int i = 0; i < codeBeanList.size(); i++) { + CodeBean codeBean = codeBeanList.get(i); + String codename = codeBean.getName(); + if (codename.equals(names)) { + selCodeBean = codeBean; + break; + } + } + return selCodeBean; + } + + /** + * ò˵㼶ṹ + * + * @param name :Ʒ + * @return + */ + public MenuBean getMenuBean(String name) { + + Map menuMap = bean.getMenuMap(); + MenuBean menuBean = null; + if (menuMap.containsKey(name)) { + menuBean = menuMap.get(name); + } else { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("wzdglxddxutil_display.TITLE"), "", MessageBox.ERROR); + } + + return menuBean; + } +} diff --git a/src/com/connor/rb/plm/util/GetCodeBean1.java b/src/com/connor/rb/plm/util/GetCodeBean1.java new file mode 100644 index 0000000..f3d1922 --- /dev/null +++ b/src/com/connor/rb/plm/util/GetCodeBean1.java @@ -0,0 +1,66 @@ +package com.connor.rb.plm.util; + +import java.io.File; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class GetCodeBean1 { + private MenuCodeBean bean; + private List codeBeanList; + + public GetCodeBean1(TCSession session) { + ParseXML xml = new ParseXML(); + File file = xml.getSXX("RB3_BZJCode_Xml", session); + // if(file==null)System.out.println("================>ͨRB3_BZJCode_XmlѡҲļ"); + bean = xml.parseXMLCode(file); + // if(bean==null)System.out.println("================>bean = + // xml.parseXMLCode(file);beanΪ"); + } + + /** + * ñ + * + * @param names :Ʒ& + * @return + */ + public CodeBean getCodebean(String names) { + codeBeanList = bean.getCodeBeanList(); + CodeBean selCodeBean = null; + for (int i = 0; i < codeBeanList.size(); i++) { + CodeBean codeBean = codeBeanList.get(i); + String codename = codeBean.getName(); + if (codename.equals(names)) { + selCodeBean = codeBean; + break; + } + } + return selCodeBean; + } + + /** + * ò˵㼶ṹ + * + * @param name :Ʒ + * @return + */ + public MenuBean getMenuBean(String name) { + + Map menuMap = bean.getMenuMap(); + MenuBean menuBean = null; + if (menuMap.containsKey(name)) { + menuBean = menuMap.get(name); + } else { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("wzdglxddxutil_display.TITLE"), "", MessageBox.ERROR); + } + + return menuBean; + } +} diff --git a/src/com/connor/rb/plm/util/GetNewCode.java b/src/com/connor/rb/plm/util/GetNewCode.java new file mode 100644 index 0000000..d30a2bd --- /dev/null +++ b/src/com/connor/rb/plm/util/GetNewCode.java @@ -0,0 +1,128 @@ +package com.connor.rb.plm.util; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class GetNewCode { + private static String prefixPattern; + private static Integer codeLength; + private static Integer maxCode; + private static Integer minCode; + private static Long minThreshold; + private static String URL; + +// Object[] params = new Object[] { build.toString(), 4, 1, 9999, 1, "" }; + public GetNewCode(Object[] params, String oldCode) { + if (params.length == 6) { + prefixPattern = params[0].toString(); + codeLength = Integer.parseInt(params[1].toString()) + prefixPattern.length(); + minCode = Integer.parseInt(params[2].toString()); + maxCode = Integer.parseInt(params[3].toString()); + // ȡ oldCode λΪ minThreshold + String codePart = oldCode.substring(oldCode.length() - Integer.parseInt(params[1].toString())); + System.out.println(codePart); + minThreshold = Long.parseLong(codePart); // ʹ Long.parseLong + if(URL == null || URL.isEmpty()) { + //ѡȡurl + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)app.getSession(); + URL = session.getPreferenceService().getStringValue("RB3_GETNEWCODESERVERURL"); + } + } + } + + + + public static String getCode() { + try { + // ַ + URL url = new URL(URL); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("POST"); + conn.setRequestProperty("Content-Type", "application/json; utf-8"); + conn.setRequestProperty("Accept", "application/json"); + conn.setDoOutput(true); + + // JSON + String jsonInputString = String.format( + "{ \"prefixPattern\": \"%s\", \"codeLength\": %d, \"maxCode\": %d, \"minCode\": %d, \"minThreshold\": %d }", + prefixPattern, codeLength, maxCode, minCode, minThreshold + ); + + System.out.println(jsonInputString); + // + try (OutputStream os = conn.getOutputStream()) { + byte[] input = jsonInputString.getBytes("utf-8"); + os.write(input, 0, input.length); + } + + // ȡӦ + int responseCode = conn.getResponseCode(); + System.out.println("Response Code: " + responseCode); + + // ȡӦ + StringBuilder response = new StringBuilder(); + try (BufferedReader br = new BufferedReader( + new InputStreamReader(conn.getInputStream(), "utf-8"))) { + String responseLine; + while ((responseLine = br.readLine()) != null) { + response.append(responseLine.trim()); + } + } + + // ر + System.out.println(buildFullCode(prefixPattern, response.toString(), codeLength)); + return buildFullCode(prefixPattern, response.toString(), codeLength); + + } catch (Exception e) { + e.printStackTrace(); + return "Error: " + e.getMessage(); + } + } + + public static String buildFullCode(String prefixPattern, String code, int totalLength) { + // ϲǰ׺ͱ + String combined = prefixPattern + code; + + // жǷҪ + if (combined.length() >= totalLength) { + return combined; // 㴦ֱӷ + } + + // 㲿֣ܹҪٸ 0 + int zerosNeeded = totalLength - combined.length(); + + // м䲹ַ + StringBuilder sb = new StringBuilder(prefixPattern); + for (int i = 0; i < zerosNeeded; i++) { + sb.append('0'); + } + sb.append(code); + + return sb.toString(); + } + +// // ʾ main +// public static void main(String[] args) { +// String oldCode = "1106020000229"; // ʾɱ +// String[] parameters = { +// "110602", // prefixPattern +// "7", // codeLength (ʵܳ) +// "1", // minCode +// "9999", // maxCode +// "1", // +// "" +// }; +// +// GetNewCode generator = new GetNewCode(parameters, oldCode,"http://127.0.0.1:8080/generate-code"); +// String newCode = generator.getCode(); +// System.out.println("Generated Code: " + newCode); +// } +} \ No newline at end of file diff --git a/src/com/connor/rb/plm/util/MenuBean.java b/src/com/connor/rb/plm/util/MenuBean.java new file mode 100644 index 0000000..1ed0c0f --- /dev/null +++ b/src/com/connor/rb/plm/util/MenuBean.java @@ -0,0 +1,36 @@ +package com.connor.rb.plm.util; + +import java.util.List; + +/** + * ˵ʵ + * + * @author zl + * + */ +public class MenuBean { + private String name; // ǰ˵ + private List list; // Ӳ˵ + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + @Override + public String toString() { + return "{ MenuBean --" + name + " " + list + "}"; + } + +} diff --git a/src/com/connor/rb/plm/util/MenuCodeBean.java b/src/com/connor/rb/plm/util/MenuCodeBean.java new file mode 100644 index 0000000..63b2b4f --- /dev/null +++ b/src/com/connor/rb/plm/util/MenuCodeBean.java @@ -0,0 +1,32 @@ +package com.connor.rb.plm.util; + +import java.util.List; +import java.util.Map; + +/** + * ˵ù + * + * @author zl + * + */ +public class MenuCodeBean { + private Map menuMap; // ˵ + private List codeBeanList;// + + public Map getMenuMap() { + return menuMap; + } + + public void setMenuMap(Map menuMap) { + this.menuMap = menuMap; + } + + public List getCodeBeanList() { + return codeBeanList; + } + + public void setCodeBeanList(List codeBeanList) { + this.codeBeanList = codeBeanList; + } + +} diff --git a/src/com/connor/rb/plm/util/ParseXML.java b/src/com/connor/rb/plm/util/ParseXML.java new file mode 100644 index 0000000..236bc4e --- /dev/null +++ b/src/com/connor/rb/plm/util/ParseXML.java @@ -0,0 +1,469 @@ +package com.connor.rb.plm.util; + +import java.io.File; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import org.apache.commons.lang.StringUtils; +import org.dom4j.Document; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; + +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +/** + * xml + * + * @author zl + * + */ +public class ParseXML { + /** + * XML + * + * @param file + */ + public Map> parseXMLAttr(File file,PrintWriter writer) { + Map> attrMap = new HashMap>(); + List typelist = new ArrayList(); + List namelist = new ArrayList(); + List markList = new ArrayList(); + List valueList = new ArrayList(); + List isNList = new ArrayList(); + List objectAtrtList = new ArrayList(); + try { + SAXReader saxReader = new SAXReader(); + Document document = saxReader.read(file); + Element root = document.getRootElement(); + Iterator iter = root.elementIterator("largeclass");// largeclassǩ + while (iter.hasNext()) { + Element recordEle = (Element) iter.next(); + Iterator iter2 = recordEle.elementIterator("subclass");// subclassǩ + while (iter2.hasNext()) { + Element recordEle2 = (Element) iter2.next(); + String type = recordEle2.attributeValue("type"); +// System.out.println("Type====================" + type); + typelist.add(type); + Iterator iter3 = recordEle2.elementIterator("prop");// propǩ + StringBuilder sb = new StringBuilder(); + StringBuilder sb1 = new StringBuilder(); + StringBuilder sb2 = new StringBuilder(); + StringBuilder sb3 = new StringBuilder(); + StringBuilder sb4 = new StringBuilder(); + boolean isFirstObjectAttr=false; + boolean isFirstRow=false; + while (iter3.hasNext()) { + + Element recordEle3 = (Element) iter3.next(); + String objectAttrName = recordEle3.attributeValue("objectAttrName"); + if(StringUtils.isNotBlank(objectAttrName)) { + if(!isFirstRow) { + isFirstObjectAttr=true; + } + isFirstRow=true; + sb4.append(objectAttrName); + sb4.append(";"); + continue; + } + isFirstRow=true; + String name = recordEle3.attributeValue("attrName"); + String mark = recordEle3.attributeValue("mark"); + String value = recordEle3.attributeValue("value"); + String isN = recordEle3.attributeValue("isN"); +// System.out.println("value=====" + value); + if (mark == null || "".equals(mark)) { + mark = " "; + } + if (value == null || "".equals(value)) { + value = " "; + } + if (isN == null || "".equals(isN)) { + isN = " "; + } + sb.append(name); + sb1.append(mark); + sb2.append(value); + sb3.append(isN); + sb.append(";"); + sb1.append(";"); + sb2.append(";"); + sb3.append(";"); + } + namelist.add(sb.toString()); + markList.add(sb1.toString()); + valueList.add(sb2.toString()); + isNList.add(sb3.toString()); + String appendFirst=isFirstObjectAttr?"TRUE;" :";FAIL;"; + objectAtrtList.add(appendFirst+sb4.toString()); + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + for (int i = 0; i < typelist.size(); i++) { + List nameMarkList = new ArrayList(); + nameMarkList.add(namelist.get(i)); + nameMarkList.add(markList.get(i)); + nameMarkList.add(valueList.get(i)); + nameMarkList.add(isNList.get(i)); + nameMarkList.add(objectAtrtList.get(i)); + attrMap.put(typelist.get(i), nameMarkList); + } +// System.out.println("<><><><>" + attrMap.toString()); + return attrMap; + } + + public Map> parseXMLAttr(File file ) { + Map> attrMap = new HashMap>(); + List typelist = new ArrayList(); + List namelist = new ArrayList(); + List markList = new ArrayList(); + List valueList = new ArrayList(); + List isNList = new ArrayList(); + List objectAtrtList = new ArrayList(); + try { + SAXReader saxReader = new SAXReader(); + Document document = saxReader.read(file); + Element root = document.getRootElement(); + Iterator iter = root.elementIterator("largeclass");// largeclassǩ + while (iter.hasNext()) { + Element recordEle = (Element) iter.next(); + Iterator iter2 = recordEle.elementIterator("subclass");// subclassǩ + while (iter2.hasNext()) { + Element recordEle2 = (Element) iter2.next(); + String type = recordEle2.attributeValue("type"); +// System.out.println("Type====================" + type); + typelist.add(type); + Iterator iter3 = recordEle2.elementIterator("prop");// propǩ + StringBuilder sb = new StringBuilder(); + StringBuilder sb1 = new StringBuilder(); + StringBuilder sb2 = new StringBuilder(); + StringBuilder sb3 = new StringBuilder(); + StringBuilder sb4 = new StringBuilder(); + boolean isFirstObjectAttr=false; + boolean isFirstRow=false; + while (iter3.hasNext()) { + + Element recordEle3 = (Element) iter3.next(); + String objectAttrName = recordEle3.attributeValue("objectAttrName"); + if(StringUtils.isNotBlank(objectAttrName)) { + if(!isFirstRow) { + isFirstObjectAttr=true; + } + isFirstRow=true; + sb4.append(objectAttrName); + sb4.append(";"); + continue; + } + isFirstRow=true; + String name = recordEle3.attributeValue("attrName"); + String mark = recordEle3.attributeValue("mark"); + String value = recordEle3.attributeValue("value"); + String isN = recordEle3.attributeValue("isN"); +// System.out.println("value=====" + value); + if (mark == null || "".equals(mark)) { + mark = " "; + } + if (value == null || "".equals(value)) { + value = " "; + } + if (isN == null || "".equals(isN)) { + isN = " "; + } + sb.append(name); + sb1.append(mark); + sb2.append(value); + sb3.append(isN); + sb.append(";"); + sb1.append(";"); + sb2.append(";"); + sb3.append(";"); + } + namelist.add(sb.toString()); + markList.add(sb1.toString()); + valueList.add(sb2.toString()); + isNList.add(sb3.toString()); + String appendFirst=isFirstObjectAttr?"TRUE;" :";FAIL;"; + objectAtrtList.add(appendFirst+sb4.toString()); + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + for (int i = 0; i < typelist.size(); i++) { + List nameMarkList = new ArrayList(); + nameMarkList.add(namelist.get(i)); + nameMarkList.add(markList.get(i)); + nameMarkList.add(valueList.get(i)); + nameMarkList.add(isNList.get(i)); + nameMarkList.add(objectAtrtList.get(i)); + attrMap.put(typelist.get(i), nameMarkList); + } +// System.out.println("<><><><>" + attrMap.toString()); + return attrMap; + } + /** + * XML + * + * @param file + * @return + */ + public List parseXML(File file) { + List partList = new ArrayList(); + try { + SAXReader saxReader = new SAXReader(); + Document document = saxReader.read(file); + Element root = document.getRootElement(); + Iterator iter = root.elementIterator("part");// partǩ + while (iter.hasNext()) { + PartBean partbean = new PartBean(); + List propList = new ArrayList(); + Element recordEle = (Element) iter.next(); + String itemtype = recordEle.attributeValue("type"); + System.out.println("itemtype=" + itemtype); + Iterator iter2 = recordEle.elementIterator("compontent");// compontentǩ + while (iter2.hasNext()) { + Element recordEle2 = (Element) iter2.next(); + String type = recordEle2.attributeValue("type"); + String compententType = recordEle2.attributeValue("compententType"); + Iterator iter3 = recordEle2.elementIterator("property");// propertyǩ + while (iter3.hasNext()) { + PropBean propbean = new PropBean(); + Element recordEle3 = (Element) iter3.next(); + String realName = recordEle3.attributeValue("realName"); + String displayName = recordEle3.attributeValue("displayName"); + String propertyType = recordEle3.attributeValue("propertyType"); + String defaultValue = recordEle3.attributeValue("defaultValue"); + String isMust = recordEle3.attributeValue("isMust"); + String isLov = recordEle3.attributeValue("isLov"); + String lovName = recordEle3.attributeValue("lovName"); + String isMutiLov = recordEle3.attributeValue("isMutiLov"); + propbean.setType(type); + propbean.setCompententType(compententType); + propbean.setRealName(realName); + propbean.setDisplayName(displayName); + propbean.setPropertyType(propertyType); + propbean.setDefaultValue(defaultValue); + propbean.setIsMust(isMust); + propbean.setIsLov(isLov); + propbean.setLovName(lovName); + propbean.setIsMutiLov(isMutiLov); + propList.add(propbean); + // System.out.println(propbean); + } + } + + partbean.setPropList(propList); + partbean.setType(itemtype); + partList.add(partbean); + } + } catch (Exception e) { + e.printStackTrace(); + } + return partList; + } + + /** + * XML + * + * @param file + */ + public MenuCodeBean parseXMLCode(File file) { + MenuCodeBean bean = new MenuCodeBean(); + List codeList = new ArrayList(); + Map menuMap = new HashMap(); + try { + SAXReader saxReader = new SAXReader(); + Document document = saxReader.read(file); + Element root = document.getRootElement(); + Iterator iter = root.elementIterator("largeclass");// partǩ + while (iter.hasNext()) { + MenuBean menuBean = new MenuBean(); + Element recordEle = (Element) iter.next(); + String type = recordEle.attributeValue("type"); + String name = recordEle.attributeValue("name"); + name = PlmLocaleUtil.getString(name); + String code = recordEle.attributeValue("code"); + List namelist = new ArrayList<>(); + namelist.add(name); + List codelist = new ArrayList<>(); + codelist.add(code); + System.out.println("itemtype=" + type); + Iterator iter2 = recordEle.elementIterator("subclass");// subclassǩ + menuBean.setName(name); + menuBean.setList(new ArrayList()); + getCode(iter2, codeList, type, namelist, codelist, menuBean); + menuMap.put(name, menuBean); + System.out.println("-------" + menuBean); + } + + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println(codeList); + bean.setCodeBeanList(codeList); + bean.setMenuMap(menuMap); + return bean; + } + + /** + * ݹxml + * + * @param iter2 + * @param codeList + * @param futype + * @param namelist1 + * @param codelist1 + */ + private void getCode(Iterator iter2, List codeList, String futype, List namelist1, + List codelist1, MenuBean menuBean) { + while (iter2.hasNext()) { + MenuBean zimenuBean = new MenuBean(); + Element recordEle2 = (Element) iter2.next(); + String type = recordEle2.attributeValue("type"); + String name = recordEle2.attributeValue("name"); + name = PlmLocaleUtil.getString(name); + String code = recordEle2.attributeValue("code"); + List namelist = new ArrayList<>(); + List codelist = new ArrayList<>(); + for (int i = 0; i < namelist1.size(); i++) { + namelist.add(namelist1.get(i)); + } + for (int i = 0; i < codelist1.size(); i++) { + codelist.add(codelist1.get(i)); + } + namelist.add(name); + codelist.add(code); + zimenuBean.setName(name); + zimenuBean.setList(new ArrayList()); + List list = menuBean.getList(); + list.add(zimenuBean); + // System.out.println(list); + menuBean.setList(list); + if (type != null && type.toUpperCase().equals("S")) { + CodeBean codebean = new CodeBean(); + String min = recordEle2.attributeValue("min"); + String max = recordEle2.attributeValue("max"); + String num = recordEle2.attributeValue("num"); + String end = recordEle2.attributeValue("end"); + String classid = recordEle2.attributeValue("class"); + String allname = ""; + for (int i = 0; i < namelist.size(); i++) { + if (i != 0) { + allname = allname + "&"; + } + allname = allname + namelist.get(i); + } + String allcode = ""; + for (int i = 0; i < codelist.size(); i++) { + allcode = allcode + codelist.get(i); + } + + Iterator iterprops = recordEle2.elementIterator("props"); + if (iterprops.hasNext()) { + CopyPropsBean copyPropBean = new CopyPropsBean(); + Element recordEle3 = (Element) iterprops.next(); + String seltype = recordEle3.attributeValue("type"); + Iterator iterprop = recordEle3.elementIterator("prop"); + List listprop = new ArrayList(); + while (iterprop.hasNext()) { + Element recordEle4 = (Element) iterprop.next(); + String type1 = recordEle4.attributeValue("type1"); + String type2 = recordEle4.attributeValue("type2"); + String name1 = recordEle4.attributeValue("name1"); + String name2 = recordEle4.attributeValue("name2"); + String str = type1 + "." + name1 + "=" + type2 + "." + name2; + listprop.add(str); + } + copyPropBean.setType(seltype); + copyPropBean.setProps(listprop); + codebean.setCopyPropBean(copyPropBean); + } + codebean.setType(futype); + codebean.setName(allname); + codebean.setNames(namelist); + codebean.setCodes(codelist); + codebean.setCode(allcode); + codebean.setMin(min); + codebean.setMax(max); + codebean.setNum(num); + codebean.setEnd(end); + codebean.setClassID(classid); + // System.out.println(codebean); + codeList.add(codebean); + } else { + Iterator iter3 = recordEle2.elementIterator("subclass"); + if (iter3.hasNext()) { + getCode(iter3, codeList, futype, namelist, codelist, zimenuBean); + } + } + + } + } + + /** + * ͨѡUidļ + * + * @param pernaem ѡ + * @param session session + * @return + */ + public File getSXX(String pernaem, TCSession session) { + TCPreferenceService pref = session.getPreferenceService(); + String puid = pref.getStringValue(pernaem);// ѡpuid + if (puid != null) { + try { + TCComponentDataset dataset = (TCComponentDataset) session.stringToComponent(puid); + if (dataset == null) { + return null; + } + TCComponentTcFile[] file = dataset.getTcFiles(); + if (file.length == 0 || file.length != 1) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("sjjmymmutil_display.TITLE"), "WARNING", MessageBox.WARNING); + return null; + } else { + File fmsFile = file[0].getFmsFile(); + return fmsFile; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } else { + MessageBox.post("δҵѡ[" + pernaem + "]ѡô", "", MessageBox.ERROR); + return null; + } + return null; + } + +// /** +// * +// * @param args +// */ + public static void main(String[] args) { + // TODO Auto-generated method stub + File file = new File("D:\\1.xml"); + File file2 = new File( + "D:\\\\΢\\\\WeChat Files\\\\wxid_5jr2lwrados122\\\\FileStorage\\\\File\\\\2022-04\\\\ϴV3.xml"); + ParseXML t = new ParseXML(); + // t.parseXML(file); + t.parseXMLCode(file2); + } +} diff --git a/src/com/connor/rb/plm/util/ParseXMLUtil.java b/src/com/connor/rb/plm/util/ParseXMLUtil.java new file mode 100644 index 0000000..7eee3ac --- /dev/null +++ b/src/com/connor/rb/plm/util/ParseXMLUtil.java @@ -0,0 +1,183 @@ +package com.connor.rb.plm.util; + +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.dom4j.Document; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; + +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +/** + * xml + * + * @author wangc + * + */ +public class ParseXMLUtil { + + /** + * XML + * + * @param file + */ + public List parseXMLCode(File file) { + List attrList = new ArrayList(); + List idlist = new ArrayList(); + List namelist = new ArrayList(); + try { + SAXReader saxReader = new SAXReader(); + Document document = saxReader.read(file); + Element root = document.getRootElement(); + Iterator iter = root.elementIterator("largeclass");// largeclassǩ + while (iter.hasNext()) { + Element recordEle = (Element) iter.next(); + Iterator iter2 = recordEle.elementIterator("subclass");// subclassǩ + while (iter2.hasNext()) { + Element recordEle2 = (Element) iter2.next(); + String classID = recordEle2.attributeValue("id"); + idlist.add(classID); + Iterator iter3 = recordEle2.elementIterator("prop");// propǩ + StringBuilder sb = new StringBuilder(); + while (iter3.hasNext()) { + Element recordEle3 = (Element) iter3.next(); + String name = recordEle3.attributeValue("attrName"); + sb.append(";"); + sb.append(name); + } + namelist.add(sb.toString()); + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + for (int i = 0; i < idlist.size(); i++) { + StringBuilder sb = new StringBuilder(idlist.get(i)); + sb.append(namelist.get(i)); + attrList.add(sb.toString()); + } + return attrList; + } + + /** + * XML + * + * @param file + */ + public List> parseXMLCAD(File file) { + List> attrList = new ArrayList>(); + + try { + SAXReader saxReader = new SAXReader(); + Document document = saxReader.read(file); + Element root = document.getRootElement(); + Iterator iter = root.elementIterator("largeclass");// largeclassǩ + while (iter.hasNext()) { + List namelist = new ArrayList(); + List itemAttrlist = new ArrayList(); + Element recordEle = (Element) iter.next(); + Iterator iter2 = recordEle.elementIterator("subclass");// subclassǩ + while (iter2.hasNext()) { + StringBuilder sb = new StringBuilder(); + StringBuilder sb1 = new StringBuilder(); + Element recordEle2 = (Element) iter2.next(); + String classID = recordEle2.attributeValue("id"); + sb.append(classID); + sb1.append(classID); + Iterator iter3 = recordEle2.elementIterator("prop");// propǩ + while (iter3.hasNext()) { + Element recordEle3 = (Element) iter3.next(); + String name = recordEle3.attributeValue("classAttr"); + String attrName = recordEle3.attributeValue("itemAttr"); + // System.out.println("name======="+name); + // System.out.println("attrName======="+attrName); + if ("".equals(name)) { + name = " "; + } + if ("".equals(attrName)) { + attrName = " "; + } + sb.append(";"); + sb1.append(";"); + sb.append(name); + sb1.append(attrName); + } + namelist.add(sb.toString()); + itemAttrlist.add(sb1.toString()); + } + attrList.add(namelist); + attrList.add(itemAttrlist); + } + + } catch (Exception e) { + e.printStackTrace(); + } + + return attrList; + } + + /** + * ͨѡUidļ + * + * @param pernaem ѡ + * @param session session + * @return + */ + public File getSXX(String pernaem, TCSession session) { + TCPreferenceService pref = session.getPreferenceService(); + String puid = pref.getStringValue(pernaem);// ѡpuid + if (puid != null) { + try { + TCComponentDataset dataset = (TCComponentDataset) session.stringToComponent(puid); + if (dataset == null) { + return null; + } + TCComponentTcFile[] file = dataset.getTcFiles(); + if (file.length == 0 || file.length != 1) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("sjjmymmutil_display.TITLE"), "WARNING", MessageBox.WARNING); + return null; + } else { + File fmsFile = file[0].getFmsFile(); + return fmsFile; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } else { + MessageBox.post("δҵѡ[" + pernaem + "]ѡô", "", MessageBox.ERROR); + return null; + } + return null; + } + + /** + * + * + * @param args + */ + /* + * public static void main(String[] args) { // TODO Auto-generated method stub + * File file = new File("C:\\Users\\wangc\\Desktop\\ƳCAD\\˱ӳCAD.xml"); + * ParseXMLUtil t = new ParseXMLUtil(); // t.parseXML(file); List> + * list = t.parseXMLCAD(file); System.out.println("size==="+list.size()); } + */ +} diff --git a/src/com/connor/rb/plm/util/PartBean.java b/src/com/connor/rb/plm/util/PartBean.java new file mode 100644 index 0000000..25b7dfc --- /dev/null +++ b/src/com/connor/rb/plm/util/PartBean.java @@ -0,0 +1,31 @@ +package com.connor.rb.plm.util; + +import java.util.List; + +/** + * ¼xmlõĶ + * + * @author zl + * + */ +public class PartBean { + private String type;// part + private List propList;// Զ + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public List getPropList() { + return propList; + } + + public void setPropList(List propList) { + this.propList = propList; + } + +} diff --git a/src/com/connor/rb/plm/util/PlmLocaleUtil.java b/src/com/connor/rb/plm/util/PlmLocaleUtil.java new file mode 100644 index 0000000..1c4659a --- /dev/null +++ b/src/com/connor/rb/plm/util/PlmLocaleUtil.java @@ -0,0 +1,38 @@ +package com.connor.rb.plm.util; + +import com.teamcenter.rac.util.Registry; + +public class PlmLocaleUtil { + + public static final Registry reg = Registry.getRegistry(PlmLocaleUtil.class); + public static boolean isCN = "cn".equals(PlmLocaleUtil.getString("language")); + + public static String getString(String title) { + if (isEmpty(title)) { + return ""; + } + String res = reg.getString(title); + return isEmpty(res) ? title : res; + } + + /** + * 获取当前语言的字符串,格式?英文内容@@中文内容? + * + * @param str + * @return + */ + public String getStringByLanguage(String str) { + if (isEmpty(str)) { + return ""; + } + int ind = str.lastIndexOf("@@"); + if (ind < 0) { + return str; + } + return isCN ? str.substring(ind + 2) : str.substring(0, ind); + } + + private static boolean isEmpty(String title) { + return title == null || "".equals(title.trim()); + } +} diff --git a/src/com/connor/rb/plm/util/ProcessBarDialog.java b/src/com/connor/rb/plm/util/ProcessBarDialog.java new file mode 100644 index 0000000..5ae0a7f --- /dev/null +++ b/src/com/connor/rb/plm/util/ProcessBarDialog.java @@ -0,0 +1,59 @@ +package com.connor.rb.plm.util; + +import javax.swing.Box; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; + +import java.awt.Dimension; +import java.util.TimerTask; +import java.util.Timer; +import javax.swing.*; + +public class ProcessBarDialog extends JFrame { + + private JProgressBar progressBar = new JProgressBar(); + + private Box box = Box.createVerticalBox(); + + private Box box2 = Box.createHorizontalBox(); + private String name; + + public ProcessBarDialog(String name) { + this.name = name; + } + + public void open() { + this.setTitle("..."); + + setBounds(200, 200, 300, 100); + + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setLocationRelativeTo(null); + progressBar.setIndeterminate(true);// ýʽΪȷĽʽ(ع)falseΪȷĽʽ(ͷβʾ) + + progressBar.setStringPainted(true);// ýʾʾϢ + + progressBar.setString(name);// ʾϢ + progressBar.setPreferredSize(new Dimension(300, 100)); + + box2.add(progressBar); + box.add(box2); + add(box); + setVisible(true); + // Timer timer = new Timer(); + // TimerTask timerTask = new TimerTask(){ + // @Override + // public void run() { + // System.out.println("ԓУ"); + // dispose(); + // } + // }; + // timer.schedule(timerTask,5000);//5000Ϊ5 + } + + public void close() { + dispose(); + } + +} diff --git a/src/com/connor/rb/plm/util/ProgressBar.java b/src/com/connor/rb/plm/util/ProgressBar.java new file mode 100644 index 0000000..90d9ad9 --- /dev/null +++ b/src/com/connor/rb/plm/util/ProgressBar.java @@ -0,0 +1,173 @@ +/** + * @file ProgressBar.java + * + * @brief Create progress bar + * + * @author Yanghui + * + * @history + * ================================================================ + * Date Name Description of Change + * 25-July-2008 Yanghui this class is used to create + * progress bar. + */ +package com.connor.rb.plm.util; + +import java.awt.Container; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.Timer; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Registry; + +/** + * @class ProgressBar + * @brief Create progress bar + * @author Yanghui + */ +public class ProgressBar extends AbstractAIFDialog implements ActionListener { + /** + * @var ProgressBar.progressbar + * @brief JProgressBar + */ + private JProgressBar progressbar; + + /** + * @var ProgressBar.label + * @brief label used to tips + */ + private JLabel label; + + /** + * @var ProgressBar.timer + * @brief timer used to timing operation + */ + private Timer timer; + + /** + * @var ProgressBar.bool + * @brief bool used to flag thread return + */ + private boolean bool = false; + + /** + * @var Progressbar.registry + * @brief Registry + */ + private Registry registry; + + /** + * @fn public ProgressBar() + * @brief constructor + * @param[in] null + */ + private String showLable = null; + + public ProgressBar(String showlable) { + super(true); + showLable = showlable; + this.setAlwaysOnTop(true); + } + + /** + * @fn public void setBool(boolean bool) + * @brief set bool value + * @param[in] bool + * @param[out] null + */ + public void setBool(boolean bool) { + this.bool = bool; + } + + /** + * @fn private void initUI() + * @brief createDialog method + * @param[in] null + * @param[out] null + */ + public void initUI() { + Container container = getContentPane(); + JPanel mainPanel = new JPanel(new PropertyLayout()); + this.label = new JLabel(showLable, JLabel.CENTER); + this.progressbar = new JProgressBar(); + this.progressbar.setOrientation(JProgressBar.HORIZONTAL); + this.progressbar.setMinimum(0); + this.progressbar.setMaximum(100); + this.progressbar.setValue(0); + this.progressbar.setPreferredSize(new Dimension(200, 15)); + this.progressbar.setBorderPainted(true); + this.timer = new Timer(50, (ActionListener) this); + this.timer.setRepeats(false); + mainPanel.add("1.1.center", new JLabel(" ")); + mainPanel.add("2.1.center", label); + mainPanel.add("3.1.center", progressbar); + mainPanel.add("4.1.center", new JLabel(" ")); + container.add(mainPanel); + pack(); + setLocation(500, 200); + TaskThread thread = new TaskThread(this); + thread.start(); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + bool = true; + } + }); + this.setVisible(true); + } + + /** + * @class TaskThread + * @brief Create progressbar + * + */ + class TaskThread extends Thread { + private ProgressBar bar; + + public TaskThread(ProgressBar bar) { + this.bar = bar; + } + + public void run() { + if (bool == false) { + // Set Status is running. + // session.setStatus(registry.getString("export Running")); + } + for (int i = 0; i < i + 1; i++) { + timer.start(); + int value = progressbar.getValue(); + if (value < 100) { + value = value + 5; + progressbar.setValue(value); + } else { + timer.stop(); + progressbar.setValue(0); + } + try { + sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (bool == true) { + bar.setVisible(false); + bar.dispose(); + return; + + } + + } + } + } + + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + + } +} diff --git a/src/com/connor/rb/plm/util/ProgressBarThread.java b/src/com/connor/rb/plm/util/ProgressBarThread.java new file mode 100644 index 0000000..8c64f19 --- /dev/null +++ b/src/com/connor/rb/plm/util/ProgressBarThread.java @@ -0,0 +1,41 @@ +/** + * @file ProgressBarThread.java + * + * @brief control progressBar. + * + * @author Yanghui + * + * @history + * ================================================================ + * Date Name Description of Change + * 08-Auguest-2008 Yanghui this class is used to control + * progress bar. + */ +package com.connor.rb.plm.util; + +/** + * @class ProgressBarThread + * @brief Create progress bar thread + * @author Yanghui + */ +public class ProgressBarThread extends Thread { + + private ProgressBar bar; + + private String title; + + public ProgressBarThread(String title, String showLable) { + this.title = title; + bar = new ProgressBar(showLable); + } + + public void run() { + bar.setTitle(title); + bar.initUI(); + } + + public void setBool(boolean bool) { + bar.setBool(true); + bar.setAlwaysOnTop(true); + } +} diff --git a/src/com/connor/rb/plm/util/PropBean.java b/src/com/connor/rb/plm/util/PropBean.java new file mode 100644 index 0000000..ec1fa7f --- /dev/null +++ b/src/com/connor/rb/plm/util/PropBean.java @@ -0,0 +1,108 @@ +package com.connor.rb.plm.util; + +/** + * + * + * @author zl + * + */ +public class PropBean { + private String type;// [I]Item[IM]ItemMaster[R]ItemRevision[RM]ItemRevisionMaster + private String compententType;// ʵ + private String realName;// Եʵ + private String displayName;// Եʾ + private String propertyType;// Ե [string]ַ[integer]Ρ[date]ڡ[boolean] + private String defaultValue;// ԵĬֵ + private String isMust;// Ƿ [true][false]DZ + private String isLov;// Ƿlov [true]lov[false]ûйlov + private String lovName;// LOV LOVдLOV + private String isMutiLov;// LOV [true]lov[false]ûйlov + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getCompententType() { + return compententType; + } + + public void setCompententType(String compententType) { + this.compententType = compententType; + } + + public String getRealName() { + return realName; + } + + public void setRealName(String realName) { + this.realName = realName; + } + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getPropertyType() { + return propertyType; + } + + public void setPropertyType(String propertyType) { + this.propertyType = propertyType; + } + + public String getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + public String getIsMust() { + return isMust; + } + + public void setIsMust(String isMust) { + this.isMust = isMust; + } + + public String getIsLov() { + return isLov; + } + + public void setIsLov(String isLov) { + this.isLov = isLov; + } + + public String getLovName() { + return lovName; + } + + public void setLovName(String lovName) { + this.lovName = lovName; + } + + public String getIsMutiLov() { + return isMutiLov; + } + + public void setIsMutiLov(String isMutiLov) { + this.isMutiLov = isMutiLov; + } + + @Override + public String toString() { + return "PropBean [type=" + type + ", compententType=" + compententType + ", realName=" + realName + + ", displayName=" + displayName + ", propertyType=" + propertyType + ", defaultValue=" + defaultValue + + ", isMust=" + isMust + ", isLov=" + isLov + ", lovName=" + lovName + ", isMutiLov=" + isMutiLov + "]"; + } + +} diff --git a/src/com/connor/rb/plm/util/RealBean.java b/src/com/connor/rb/plm/util/RealBean.java new file mode 100644 index 0000000..7872be9 --- /dev/null +++ b/src/com/connor/rb/plm/util/RealBean.java @@ -0,0 +1,47 @@ +package com.connor.rb.plm.util; + +public class RealBean { + private String hzm; + private String daType; + private String toolType; + private String realname; + + public String getHzm() { + return hzm; + } + + public void setHzm(String hzm) { + this.hzm = hzm; + } + + public String getDaType() { + return daType; + } + + public void setDaType(String daType) { + this.daType = daType; + } + + public String getToolType() { + return toolType; + } + + public void setToolType(String toolType) { + this.toolType = toolType; + } + + public String getRealname() { + return realname; + } + + public void setRealname(String realname) { + this.realname = realname; + } + + @Override + public String toString() { + return "RealBean [hzm=" + hzm + ", daType=" + daType + ", toolType=" + toolType + ", realname=" + realname + + "]"; + } + +} diff --git a/src/com/connor/rb/plm/util/SearchJComItem.java b/src/com/connor/rb/plm/util/SearchJComItem.java new file mode 100644 index 0000000..75d5d3c --- /dev/null +++ b/src/com/connor/rb/plm/util/SearchJComItem.java @@ -0,0 +1,45 @@ +package com.connor.rb.plm.util; + +import java.util.List; +import java.util.Vector; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; + +public class SearchJComItem { + public static Object[] getNewmodel(String str, ComboBoxModel model) { + List v = new Vector(); + List v1 = new Vector(); + for (int k = 0; k < model.getSize(); k++) { + Object obj = model.getElementAt(k); + System.out.println("еitemֵΪ:" + obj.toString()); + if (obj != null) { + String item = obj.toString().toLowerCase(); + if (item.contains(str.toLowerCase())) { + v.add(model.getElementAt(k)); + } else { + v1.add(model.getElementAt(k)); + } + } else { + v1.add(model.getElementAt(k)); + } + } + for (int i = 0; i < v1.size(); i++) { + v.add(v1.get(i)); + } + if (v.isEmpty()) { + return v1.toArray(); + } + return v.toArray(); + } + + public static void changeBox(JComboBox comb, String str) { + ComboBoxModel model = comb.getModel(); + + Object[] newmodel = getNewmodel(str, model); + ComboBoxModel mod = new DefaultComboBoxModel(newmodel); + comb.setModel(mod); + } + +} diff --git a/src/com/connor/rb/plm/util/SoaServerUtil.java b/src/com/connor/rb/plm/util/SoaServerUtil.java new file mode 100644 index 0000000..53f0e28 --- /dev/null +++ b/src/com/connor/rb/plm/util/SoaServerUtil.java @@ -0,0 +1,245 @@ +package com.connor.rb.plm.util; + +import java.util.List; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.client.Options; +import org.apache.axis2.client.ServiceClient; +import org.apache.axis2.transport.http.HTTPConstants; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCComponentUserType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; + +import net.sf.json.JSONArray; + +/** + * ͷUtil + * + * @author 61666 + * + */ +public class SoaServerUtil { + + public static void sendToClass(String wsoPUID, String classID, String json, String url) { + // AbstractAIFApplication app; + // app=AIFUtility.getCurrentApplication(); + // TCSession session; + // session=(TCSession) app.getSession(); + // TCPreferenceService preferenceService; + // preferenceService=session.getPreferenceService(); + // String account=preferenceService.getStringValue("Autocode_PriverUser_ID"); + // String url; + // url = preferenceService.getStringValue("Autocode_SendClassServer_URL"); + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + // url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("SendToClass"); + sc.setOptions(opts); + + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("SendToClass", omNs); + OMElement value = fac.createOMElement("wsoPuiid", omNs); + value.setText(wsoPUID); + OMElement value1 = fac.createOMElement("classID", omNs); + value1.setText(classID); + OMElement value2 = fac.createOMElement("JsonContainer", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + value2.setText(json); + + method.addChild(value); + method.addChild(value1); + method.addChild(value2); + + OMElement res = sc.sendReceive(method); + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { + e.printStackTrace(); + } + + } + + // public static void main(String[] args) { + // deleteClass("1111", ""); + // } + // ɾʱ + public static void deleteClass(String icoPUID, String url) { + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + // url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL";//TODO + // ѡAutocode_SendClassServer_URL + // url = preferenceService.getStringValue("Autocode_SendClassServer_URL");//TODO + // ѡAutocode_SendClassServer_URL + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("DeleteClass"); + opts.setProperty(HTTPConstants.CHUNKED, "false"); + sc.setOptions(opts); + + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("DeleteClass", omNs); + OMElement value = fac.createOMElement("icoPuid", omNs); + value.setText(icoPUID); + // OMElement value1 = fac.createOMElement("classID", omNs); + //// value1.setText(classID); + // OMElement value2 = fac.createOMElement("JsonContainer", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + // value2.setText(json); + + method.addChild(value); + // method.addChild(value1); + // method.addChild(value2); + + OMElement res = sc.sendReceive(method); + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { + e.printStackTrace(); + } + + } + + public static String objectToJson(List props) { + String str = null; + try { + JSONArray json = JSONArray.fromObject(props);// javaתΪjson + str = json.toString();// jsonתΪַ + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("JSON =>" + str); + return str; + } + + public static void grantReadPrivilege(TCSession tcSession, TCComponent tccomponent) { + AbstractAIFApplication app; + app = AIFUtility.getCurrentApplication(); + TCSession session; + session = (TCSession) app.getSession(); + TCPreferenceService preferenceService; + preferenceService = session.getPreferenceService(); + String account = preferenceService.getStringValue("Autocode_PriverUser_ID"); + try { + openByPass(tcSession); + TCAccessControlService accessControlService = tcSession.getTCAccessControlService(); + TCComponentUserType type = (TCComponentUserType) tcSession.getTypeComponent("User"); + TCComponentUser user = type.find(account); + + if (user == null) { + return; + } + if (tcSession.getUser().equals(user)) { + return; + } + + String[] as2 = new String[] { "READ" }; + + if (tccomponent instanceof TCComponentItemRevision) { + TCComponentItem tempItem = ((TCComponentItemRevision) tccomponent).getItem(); + accessControlService.grantPrivilege(tempItem, user, as2); + accessControlService.grantPrivilege(tccomponent, user, as2); + } else { + accessControlService.grantPrivilege(tccomponent, user, as2); + + } + } catch (TCException e) { + e.printStackTrace(); + } finally { + try { + closeByPass(tcSession); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + public static void grantWritePrivilege(TCSession tcSession, TCComponent tccomponent) { + AbstractAIFApplication app; + app = AIFUtility.getCurrentApplication(); + TCSession session; + session = (TCSession) app.getSession(); + TCPreferenceService preferenceService; + preferenceService = session.getPreferenceService(); + String account = preferenceService.getStringValue("Autocode_PriverUser_ID"); + try { + openByPass(tcSession); + TCAccessControlService accessControlService = tcSession.getTCAccessControlService(); + TCComponentUserType type = (TCComponentUserType) tcSession.getTypeComponent("User"); + + TCComponentUser user = type.find(account); + if (user == null) { + return; + } + if (tcSession.getUser().equals(user)) { + return; + } + + String[] as2 = new String[] { "READ", "WRITE", "DELETE" }; + + if (tccomponent instanceof TCComponentItemRevision) { + TCComponentItem tempItem = ((TCComponentItemRevision) tccomponent).getItem(); + + accessControlService.grantPrivilege(tempItem, user, as2); + accessControlService.grantPrivilege(tccomponent, user, as2); + } else { + accessControlService.grantPrivilege(tccomponent, user, as2); + + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + try { + closeByPass(tcSession); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + public static void dwgToPDF(TCSession session, Object[] obj) throws TCException { + TCUserService userservice = session.getUserService(); + userservice.call("connor_dwg_to_pdf", obj); + } + + public static void openByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = ""; + userservice.call("Connor_set_bypass", obj); + } + + public static void closeByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = ""; + userservice.call("Connor_close_bypass", obj); + +// session.getUserService().call("Connor_set_bypass", new Object[]{});//bypass +// session.getUserService().call("Connor_close_bypass", new Object[]{});//bypass + } + +} diff --git a/src/com/connor/rb/plm/util/TCUtils.java b/src/com/connor/rb/plm/util/TCUtils.java new file mode 100644 index 0000000..5c09b92 --- /dev/null +++ b/src/com/connor/rb/plm/util/TCUtils.java @@ -0,0 +1,100 @@ +/** * @Title: TCUtils.java + * @Package com.connor.rb.plm.util + * @Description: TODO(һ仰ļʲô) + * @author admin * @date 2024108 + * @version V1.0 + */ +package com.connor.rb.plm.util; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +import com.teamcenter.rac.aif.IPerspectiveDef; +import com.teamcenter.rac.aif.IPerspectiveDefService; +import com.teamcenter.rac.aifrcp.AifrcpPlugin; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.OSGIUtil; + +/** + * @ClassName: TCUtils + * @Description: TODO(һ仰) + * @author admin + * @date 2024108 + * + */ +public class TCUtils { + +// private static final String LOG_FILE_PATH = "D:\\ByPassLog.txt"; + private static final String LOG_FILE_PATH = System.getenv("TEMP") + "\\ByPassLog.txt"; + + /** + * + * @Title: setLogByPass + * @Description: TODO(һ仰) + * @param @param session ǰỰsession + * @param @param name + * @param @throws TCException + * @return void + * @throws + */ + public static void openLogByPass(TCSession session, String name) throws TCException { + //ȡǰû + String userName = session.getUser().getUserName(); + + //ȡǰʱ + LocalDateTime now = LocalDateTime.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String timestamp = now.format(formatter); + + // ־ + String logContent = timestamp + " " + "û" + userName + "ʹ" + name + "" + "·" + "\n"; + + // ׷־ļ + try (BufferedWriter writer = new BufferedWriter(new FileWriter(LOG_FILE_PATH, true))) { + writer.write(logContent); + } catch (IOException e) { + e.printStackTrace(); + System.err.println("д־ļʱ: " + e.getMessage()); + } + } + + public static void closeLogByPass(TCSession session, String name) throws TCException { + //ȡǰû + String userName = session.getUser().getUserName(); + + //ȡǰʱ + LocalDateTime now = LocalDateTime.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String timestamp = now.format(formatter); + + // ־ + String logContent = timestamp + " " + "û" + userName + "ʹ" + name + "" + "ر·" + "\n"; + + // ׷־ļ + try (BufferedWriter writer = new BufferedWriter(new FileWriter(LOG_FILE_PATH, true))) { + writer.write(logContent); + } catch (IOException e) { + e.printStackTrace(); + System.err.println("д־ļʱ: " + e.getMessage()); + } + } + + /** + * tccomponent´ڴTCcomponent + * @param tcComponent + */ + public static void openComponent(TCComponent tcComponent) { + IPerspectiveDefService iperspectivedefservice = (IPerspectiveDefService) OSGIUtil.getService(AifrcpPlugin.getDefault(), IPerspectiveDefService.class); + String s = "com.teamcenter.rac.ui.perspectives.navigatorPerspective"; + IPerspectiveDef iperspectivedef = iperspectivedefservice.findByLegacyAppId(s); + TCComponent[] comps = new TCComponent[] { tcComponent }; + iperspectivedef.openPerspective(comps); + } +} diff --git a/src/com/connor/rb/plm/util/Test.java b/src/com/connor/rb/plm/util/Test.java new file mode 100644 index 0000000..2064e5d --- /dev/null +++ b/src/com/connor/rb/plm/util/Test.java @@ -0,0 +1,10 @@ +package com.connor.rb.plm.util; + +public class Test { + + public static void main(String[] args) { + // TODO Auto-generated method stub + SoaServerUtil.deleteClass("", "http://192.168.244.131:8090/ErpWebService.asmx?WSDL"); + } + +} diff --git a/src/com/connor/rb/plm/util/util_locale.properties b/src/com/connor/rb/plm/util/util_locale.properties new file mode 100644 index 0000000..33ee5cb --- /dev/null +++ b/src/com/connor/rb/plm/util/util_locale.properties @@ -0,0 +1,249 @@ +#Forgings +#Tue Feb 23 11:21:13 CST 2021 +Selfaligningballbearings=Self aligning ball bearings +Singlerowsphericalrollerbearings=Single row spherical roller bearings +Doublerowsphericalrollerbearings=Double row spherical roller bearings +Metrictaperedrollerbearings=Metric tapered roller bearings +Inchtaperedrollerbearings=Inch tapered roller bearings +Cylindricalrollerbearing=Cylindrical roller bearing +Thrustballbearing=Thrust ball bearing +Thrustballbearingunit=Thrust ball bearing unit +Deepgrooveballbearing=Deep groove ball bearing +Singlerowangularcontactballbearings=Single row angular contact ball bearings +Doublerowangularcontactballbearings=Double row angular contact ball bearings +ThrustCRB=Thrust CRB +Drawncupneedlerollerbearing=Drawn cup needle roller bearing +Solidneedlerollerbearings=Solid needle roller bearings +Cagecomponents=Cage components +Thrustneedlerollerbearing=Thrust needle roller bearing +Thrustangularcontactballbearing=Thrust angular contact ball bearing +Taperrollerthrustbearing=Taper roller thrust bearing +Thrustsphericalrollerbearing=Thrust spherical roller bearing +Waterpumpbearing=Water pump bearing +Tensionwheelbearing=Tension wheel bearing +HUB1=HUB1 +HUB2=HUB2 +HUB3=HUB3 +Automotiveelectromagneticclutchbearing=Automotive electromagnetic clutch bearing +ExternalSphericalBallBearing=External Spherical Ball Bearing +Jointbearing=Joint bearing +TypeMGMastGuideBearing=Type MG Mast Guide Bearing +TypeCGChainGuideBearings=Type CG Chain Guide Bearings +TypeSRSideRollerBearings=Type SR Side Roller Bearings +Combinedroller=Combined roller +Slewingbearingandwindpowerbearing=Slewing bearing and wind power bearing +Unilateralbearingandunilateralclutches=Unilateral bearing and unilateral clutches +Clutchreleasebearingforautomobiles=Clutch release bearing for automobiles +Linearballbearings=Linear ball bearings +Automobileshockabsorberbearing=Automobile shock absorber bearing +Rollerbearing=Roller bearing +Wanxiangjie(includingrepairkit)=Wanxiangjie(includingrepairkit) +Wanxiangjieassembly=Wanxiangjie assembly +Wanxiangjieneedlerollerbearing=Wanxiangjie needle roller bearing +Tripodproducts=Tripod products +Miniaturedeepgrooveballbearing=Miniature deep groove ball bearing +Otherpartsandproducts=Other parts and products +Autorockarmbearing=Auto rock arm bearing +BZRotorbearing=BZ Rotor bearing +GZOpeningrollerbearing=GZ Opening roller bearing +SLToprollerbearing=SL Top roller bearing +LZBottomrollerbearing=LZ Bottom roller bearing +TypeDZspindlebearing=TypeDZspindlebearing +TypeFGeneralbearingforspinningmachine=Type F General bearing for spinning machine +Non-standradsphericalrollerbearings=Non-standrad spherical roller bearings +Non-standradtaperedrollerbearings=Non-standrad tapered roller bearings +Non-standradcylindricalrollerbearings=Non-standrad cylindrical roller bearings +Non-standradthrustballbearings=Non-standrad thrust ball bearings +Non-standraddeepgrooveballbearings=Non-standrad deep groove ball bearings +Non-standradangularcontactbearings=Non-standrad angular contact bearings +Non-standradstampingbearings=Non-standrad stamping bearings +Non-standardentitybearings=Non-standard entity bearings +Non-standardcagecomponents=Non-standard cage components +Componentbearing=Component bearing +Sanxing-Selfaligningballbearings=Sanxing-Self aligning ball bearings +Sanxing-Singlerowsphericalrollerbearings=Sanxing-Single row spherical roller bearings +Sanxing-Doublerowsphericalrollerbearings=Sanxing-Double row spherical roller bearings +Sanxing-Metrictaperedrollerbearings=Sanxing-Metric tapered roller bearings +Sanxing-Inchtaperedrollerbearings=Sanxing-Inch tapered roller bearings +Sanxing-Cylindricalrollerbearing=Sanxing-Cylindrical roller bearing +Sanxing-Thrustballbearing=Sanxing-Thrust ball bearing +Sanxing-Thrustballbearingunit=Sanxing-Thrust ball bearing unit +Sanxing-Deepgrooveballbearing=Sanxing-Deep groove ball bearing +Sanxing-Singlerowangularcontactballbearings=Sanxing-Single row angular contact ball bearings +Sanxing-Doublerowangularcontactballbearings=Sanxing-Double row angular contact ball bearings +Sanxing-ThrustCRB=Sanxing-Thrust CRB +Sanxing-Drawncupneedlerollerbearing=Sanxing-Drawn cup needle roller bearing +Sanxing-Solidneedlerollerbearings=Sanxing-Solid needle roller bearings +Sanxing-Cagecomponents=Sanxing-Cage components +Sanxing-Thrustneedlerollerbearing=Sanxing-Thrust needle roller bearing +Sanxing-Thrustangularcontactballbearing=Sanxing-Thrust angular contact ball bearing +Sanxing-Taperrollerthrustbearing=Sanxing-Taper roller thrust bearing +Sanxing-Thrustsphericalrollerbearing=Sanxing-Thrust spherical roller bearing +Sanxing-Waterpumpbearing=Sanxing-Water pump bearing +Sanxing-Tensionwheelbearing=Sanxing-Tension wheel bearing +Sanxing-HUB1=Sanxing-HUB1 +Sanxing-HUB2=Sanxing-HUB2 +Sanxing-HUB3=Sanxing-HUB3 +Sanxing-Automotiveelectromagneticclutchbearing=Sanxing-Automotive electromagnetic clutch bearing +Sanxing-ExternalSphericalBallBearing=Sanxing-External Spherical Ball Bearing +Sanxing-Jointbearing=Sanxing-Joint bearing +Sanxing-TypeMGMastGuideBearing=Sanxing-Type MG Mast Guide Bearing +Sanxing-TypeCGChainGuideBearings=Sanxing-Type CG Chain Guide Bearings +Sanxing-TypeSRSideRollerBearings=Sanxing-Type SR Side Roller Bearings +Sanxing-Combinedroller=Sanxing-Combined roller +Sanxing-Slewingbearingandwindpowerbearing=Sanxing-Slewing bearing and wind power bearing +Sanxing-Unilateralbearingandunilateralclutches=Sanxing-Unilateral bearing and unilateral clutches +Sanxing-Clutchreleasebearingforautomobiles=Sanxing-Clutch release bearing for automobiles +Sanxing-Linearballbearings=Sanxing-Linear ball bearings +Sanxing-Automobileshockabsorberbearing=Sanxing-Automobile shock absorber bearing +Sanxing-Rollerbearing=Sanxing-Roller bearing +Sanxing-Wanxiangjie(includingrepairkit)=Sanxing-Wanxiangjie(includingrepairkit) +Sanxing-Wanxiangjieassembly=Sanxing-Wanxiangjie assembly +Sanxing-Wanxiangjieneedlerollerbearing=Sanxing-Wanxiangjie needle roller bearing +Sanxing-Tripodproducts=Sanxing-Tripod products +Sanxing-Miniaturedeepgrooveballbearing=Sanxing-Miniature deep groove ball bearing +Sanxing-Otherpartsandproducts=Sanxing-Other parts and products +Sanxing-Autorockarmbearing=Sanxing-Auto rock arm bearing +Sanxing-BZRotorbearing=Sanxing-BZ Rotor bearing +Sanxing-GZOpeningrollerbearing=Sanxing-GZ Opening roller bearing +Sanxing-SLToprollerbearing=Sanxing-SL Top roller bearing +Sanxing-LZBottomrollerbearing=Sanxing-LZ Bottom roller bearing +Sanxing-TypeDZspindlebearing=Sanxing-TypeDZspindlebearing +Sanxing-TypeFGeneralbearingforspinningmachine=Sanxing-Type F General bearing for spinning machine +Sanxing-Non-standradsphericalrollerbearings=Sanxing-Non-standrad spherical roller bearings +Sanxing-Non-standradtaperedrollerbearings=Sanxing-Non-standrad tapered roller bearings +Sanxing-Non-standradcylindricalrollerbearings=Sanxing-Non-standrad cylindrical roller bearings +Sanxing-Non-standradthrustballbearings=Sanxing-Non-standrad thrust ball bearings +Sanxing-Non-standraddeepgrooveballbearings=Sanxing-Non-standrad deep groove ball bearings +Sanxing-Non-standradangularcontactbearings=Sanxing-Non-standrad angular contact bearings +Sanxing-Non-standradstampingbearings=Sanxing-Non-standrad stamping bearings +Sanxing-Non-standardentitybearings=Sanxing-Non-standard entity bearings +Sanxing-Non-standardcagecomponents=Sanxing-Non-standard cage components +Sanxing-Componentbearing=Sanxing-Component bearing +Sanxing-Firstgenerationwheelrepairkit=Sanxing-First generation wheel repair kit +Sanxing-Secondgenerationwheelrepairkit=Sanxing-Second generation wheel repair kit +Sanxing-Thirdgenerationwheelrepairkit=Sanxing-Third generation wheel repair kit +Sanxing-Singlerowconerepairkit=Sanxing-Single row cone repair kit +OuterRing=Outer Ring +InnerRing=Inner Ring +Cage=Cage +Seal=Seal +Bearingaccessories=Bearing accessories +Cover=Cover +Mandrel=Mandrel +Hotpiece=Hot piece +Carparts=Car parts +Forgings=Forgings +Dustcover=Dust cover +Seat=Seat +Shaftring=Shaft ring +Sealingstrip=Sealing strip +Adjustmentblock=Adjustment block +Outerringofmainroller=Outer ring of main roller +Innerringofmainroller=Inner ring of main roller +Mainrollercage=Main roller cage +Mainrollerseal=Main roller seal +Mainrollerdustcover=Main roller dust cover +Siderollerouterring=Side roller outer ring +Siderollercage=Side roller cage +Siderollerseal=Side roller seal +Siderollerdustcover=Side roller dust cover +Outringwithflange=Out ring with flange +Innerseal=Inner seal +Flangeinnerring=Flange inner ring +Outerseal=Outer seal +Seatring=Seat ring +Washer=Washer +Middleretainingring=Middle retaining ring +Bearingseat=Bearing seat +Isolatedblock=Isolated block +Shell=Shell +Innerwheel=Inner wheel +Connectingshaft=Connecting shaft +Retainingring=Retaining ring +PartNumber=Part Number +RadialInternalClearance=Radial Internal Clearance +Semi-finishedproduct=Semi-finished product +Steelproducts=Steel products +Castiron=Cast iron +Coppermaterial=Copper material +Bar=Bar +Plate=Plate +Wire=Wire +Coil=Coil +Tube=Tube +Category=Category +Assemblymaterialcode=Assembly material code +Name=Name +Edition=Edition +Steelballcomponnents=Steel ball componnents +Sanxing-Steelballcomponnents=Sanxing-Steel ball componnents +Taperedrollercomponents=Tapered roller components +Needlerollercomponents=Needle roller components +Cylindricalrollercomponents=Cylindrical roller components +Sphericalrollercomponents=Spherical roller components +Sanxing-Taperedrollercomponents=Sanxing-Tapered roller components +Sanxing-Needlerollercomponents=Sanxing-Needle roller components +Sanxing-Cylindricalrollercomponents=Sanxing-Cylindrical roller components +Sanxing-Sphericalrollercomponents=Sanxing-Spherical roller components +Wheelboltcomponents=Wheel bolt components +Rivetcomponents=Rivet components +Stopringcomponents=Stop ring components +Oilcupcomponents=Oil cup components +Setscrewcomponents=Set screw components +Adaptersleevecomponents=Adapter sleeve components +Withdrawalsleevecomponents=Withdrawal sleeve components +Splitverticalbearingseatcomponents=Split vertical bearing seat components +Sanxing-Wheelboltcomponents=Sanxing-Wheel bolt components +Sanxing-Rivetcomponents=Sanxing-Rivet components +Sanxing-Stopringcomponents=Sanxing-Stop ring components +Sanxing-Oilcupcomponents=Sanxing-Oil cup components +Sanxing-Setscrewcomponents=Sanxing-Set screw components +Sanxing-Adaptersleevecomponents=Sanxing-Adapter sleeve components +Sanxing-Withdrawalsleevecomponents=Sanxing-Withdrawal sleeve components +Sanxing-Splitverticalbearingseatcomponents=Sanxing-Split vertical bearing seat components +Otheraccessories=Other accessories +Universaljointcrossshaft=Universal joint cross shaft +Thespider=The spider +Oilcup=Oil cup +Sanxing-Universaljointcrossshaft=Sanxing-Universal joint cross shaft +Slewingbearingandwindpowerbearingstandardtype=Slewing bearing and wind power bearing(standard type) +SlewingbearingandwindpowerbearingWireracewayassembly=Slewing bearing and wind power bearing(Wire raceway assembly) +Slewingbearingandwindpowerbearingspecialtype=Slewing bearing and wind power bearing(special type) +Sanxing-Slewingbearingandwindpowerbearingstandardtype=Slewing bearing and wind power bearing(standard type) +Sanxing-SlewingbearingandwindpowerbearingWireracewayassembly=Slewing bearing and wind power bearing(Wire raceway assembly) +Sanxing-Slewingbearingandwindpowerbearingspecialtype=Slewing bearing and wind power bearing(special type) +Plainbearing=Plain bearing +Bearinghousing=Bearing housing +Thrustdisc=Thrust disc +Bearingbody=Bearing body +Thrusttile=Thrust tile +Balanceblock=Balance block +screw=screw +adjustmentplate=adjustment plate +Sanxing-Plainbearing=Sanxing-Plain bearing +Ballscrew=Ball screw +nut=nut +screw=screw +reverser=reverser +Sanxing-Ballscrew=Sanxing-Ball screw +Spring=Spring +Insert=Insert +Sealinginsert=Sealing insert +Oilsealinginsert=Oil sealing insert +Dustcap=Dust cap +Others=Others +Ring=Ring +Bearing=Bearing +Pulley=Pulley +Slidinggatebearing=Sliding gate bearing +Plasticcoatingbearing=Plastic coating bearing +Nut=Nut +Rivet=Rivet +Conventionalproducts=Conventional products +Rollerbodypin=Roller body, pin +forging=forging +Turning=Turning +heattreatmentpiece=heat treatment piece +ColdPierpieces=Cold Pier pieces +PartCategory=Part Category \ No newline at end of file diff --git a/src/com/connor/rb/plm/util/util_locale_zh_CN.properties b/src/com/connor/rb/plm/util/util_locale_zh_CN.properties new file mode 100644 index 0000000..464b430 --- /dev/null +++ b/src/com/connor/rb/plm/util/util_locale_zh_CN.properties @@ -0,0 +1,250 @@ +# +#Tue Feb 23 11:21:13 CST 2021 +Selfaligningballbearings=\u8c03\u5fc3\u7403\u8f74\u627f +Singlerowsphericalrollerbearings=\u5355\u5217\u8c03\u5fc3\u6eda\u5b50\u8f74\u627f +Doublerowsphericalrollerbearings=\u53cc\u5217\u8c03\u5fc3\u6eda\u5b50\u8f74\u627f +Metrictaperedrollerbearings=\u516c\u5236\u5706\u9525\u6eda\u5b50\u8f74\u627f +Inchtaperedrollerbearings=\u82f1\u5236\u5706\u9525\u6eda\u5b50\u8f74\u627f +Cylindricalrollerbearing=\u5706\u67f1\u6eda\u5b50\u8f74\u627f +Thrustballbearing=\u63a8\u529b\u7403\u8f74\u627f +Thrustballbearingunit=\u63a8\u529b\u7403\u7ec4\u4ef6 +Deepgrooveballbearing=\u6df1\u6c9f\u7403\u8f74\u627f +Singlerowangularcontactballbearings=\u5355\u5217\u89d2\u63a5\u89e6\u7403\u8f74\u627f +Doublerowangularcontactballbearings=\u53cc\u5217\u89d2\u63a5\u89e6\u7403\u8f74\u627f +ThrustCRB=\u63a8\u529b\u5706\u67f1\u6eda\u5b50\u8f74\u627f +Drawncupneedlerollerbearing=\u51b2\u538b\u5916\u5708\u6eda\u9488\u8f74\u627f +Solidneedlerollerbearings=\u5b9e\u4f53\u6eda\u9488\u8f74\u627f +Cagecomponents=\u4fdd\u6301\u67b6\u7ec4\u4ef6 +Thrustneedlerollerbearing=\u63a8\u529b\u6eda\u9488\u8f74\u627f +Thrustangularcontactballbearing=\u63a8\u529b\u89d2\u63a5\u89e6\u7403\u8f74\u627f +Taperrollerthrustbearing=\u63a8\u529b\u5706\u9525\u6eda\u5b50\u8f74\u627f +Thrustsphericalrollerbearing=\u63a8\u529b\u8c03\u5fc3\u6eda\u5b50\u8f74\u627f +Waterpumpbearing=\u6c34\u6cf5\u8f74\u627f +Tensionwheelbearing=\u5f20\u7d27\u8f6e\u8f74\u627f +HUB1=\u4e00\u4ee3\u8f6e\u6bc2\u8f74\u627f +HUB2=\u4e8c\u4ee3\u8f6e\u6bc2\u8f74\u627f +HUB3=\u4e09\u4ee3\u8f6e\u6bc2\u8f74\u627f +Automotiveelectromagneticclutchbearing=\u7535\u78c1\u79bb\u5408\u5668\u8f74\u627f +ExternalSphericalBallBearing=\u5916\u7403\u9762\u7403\u8f74\u627f +Jointbearing=\u5173\u8282\u8f74\u627f +TypeMGMastGuideBearing=\u004d\u0047\u578b\u53c9\u8f66\u95e8\u67b6\u6eda\u8f6e\u8f74\u627f +TypeCGChainGuideBearings=\u0043\u0047\u578b\u53c9\u8f66\u95e8\u67b6\u94fe\u8f6e\u8f74\u627f +TypeSRSideRollerBearings=\u0053\u0052\u578b\u53c9\u8f66\u95e8\u67b6\u4fa7\u5411\u8f74\u627f +Combinedroller=\u7ec4\u5408\u6eda\u8f6e +Slewingbearingandwindpowerbearing=\u56de\u8f6c\u652f\u627f\u4e0e\u98ce\u7535\u8f74\u627f +Unilateralbearingandunilateralclutches=\u5355\u5411\u8f74\u627f\u548c\u5355\u5411\u79bb\u5408\u5668 +Clutchreleasebearingforautomobiles=\u6c7d\u8f66\u79bb\u5408\u5668\u8f74\u627f +Linearballbearings=\u76f4\u7ebf\u8f74\u627f +Automobileshockabsorberbearing=\u6c7d\u8f66\u51cf\u632f\u5668\u8f74\u627f +Rollerbearing=\u6eda\u8f6e\u8f74\u627f +Wanxiangjie(includingrepairkit)=\u4e07\u5411\u8282\uff08\u542b\u4fee\u7406\u5305\uff09 +Wanxiangjieassembly=\u4e07\u5411\u8282\u603b\u6210 +Wanxiangjieneedlerollerbearing=\u4e07\u5411\u8282\u6eda\u9488\u8f74\u627f +Tripodproducts=\u4e09\u9500\u67b6\u4ea7\u54c1 +Miniaturedeepgrooveballbearing=\u5fae\u578b\u6df1\u6c9f\u7403\u8f74\u627f +Otherpartsandproducts=\u5176\u4ed6\u96f6\u4ef6\u4ea7\u54c1 +Autorockarmbearing=\u6c7d\u8f66\u6447\u81c2\u8f74\u627f +BZRotorbearing=\u0042\u005a\u8f6c\u676f\u8f74\u627f +GZOpeningrollerbearing=\u0047\u005a\u5206\u68b3\u8f8a\u8f74\u627f +SLToprollerbearing=\u0053\u004c\u4e0a\u7f57\u62c9\u8f74\u627f +LZBottomrollerbearing=\u004c\u005a\u4e0b\u7f57\u62c9\u8f74\u627f +TypeDZspindlebearing=\u0044\u005a\u7eba\u952d\u8f74\u627f +TypeFGeneralbearingforspinningmachine=\u0046\u578b\u7eba\u673a\u901a\u7528\u8f74\u627f +Non-standradsphericalrollerbearings=\u975e\u6807\u8c03\u5fc3\u6eda\u5b50\u8f74\u627f +Non-standradtaperedrollerbearings=\u975e\u6807\u5706\u9525\u6eda\u5b50\u8f74\u627f +Non-standradcylindricalrollerbearings=\u975e\u6807\u5706\u67f1\u6eda\u5b50\u8f74\u627f +Non-standradthrustballbearings=\u975e\u6807\u63a8\u529b\u7403\u8f74\u627f +Non-standraddeepgrooveballbearings=\u975e\u6807\u6df1\u6c9f\u7403\u8f74\u627f +Non-standradangularcontactbearings=\u975e\u6807\u89d2\u63a5\u89e6\u8f74\u627f +Non-standradstampingbearings=\u975e\u6807\u51b2\u538b +Non-standardentitybearings=\u975e\u6807\u5b9e\u4f53 +Non-standardcagecomponents=\u975e\u6807\u4fdd\u6301\u67b6\u7ec4\u4ef6 +Componentbearing=\u7ec4\u4ef6\u8f74\u627f +Sanxing-Selfaligningballbearings=\u4e09\u884c\u8c03\u5fc3\u7403\u8f74\u627f +Sanxing-Singlerowsphericalrollerbearings=\u4e09\u884c\u5355\u5217\u8c03\u5fc3\u6eda\u5b50\u8f74\u627f +Sanxing-Doublerowsphericalrollerbearings=\u4e09\u884c\u53cc\u5217\u8c03\u5fc3\u6eda\u5b50\u8f74\u627f +Sanxing-Metrictaperedrollerbearings=\u4e09\u884c\u516c\u5236\u5706\u9525\u6eda\u5b50\u8f74\u627f +Sanxing-Inchtaperedrollerbearings=\u4e09\u884c\u82f1\u5236\u5706\u9525\u6eda\u5b50\u8f74\u627f +Sanxing-Cylindricalrollerbearing=\u4e09\u884c\u5706\u67f1\u6eda\u5b50\u8f74\u627f +Sanxing-Thrustballbearing=\u4e09\u884c\u63a8\u529b\u7403\u8f74\u627f +Sanxing-Thrustballbearingunit=\u4e09\u884c\u63a8\u529b\u7403\u7ec4\u4ef6 +Sanxing-Deepgrooveballbearing=\u4e09\u884c\u6df1\u6c9f\u7403\u8f74\u627f +Sanxing-Singlerowangularcontactballbearings=\u4e09\u884c\u5355\u5217\u89d2\u63a5\u89e6\u7403\u8f74\u627f +Sanxing-Doublerowangularcontactballbearings=\u4e09\u884c\u53cc\u5217\u89d2\u63a5\u89e6\u7403\u8f74\u627f +Sanxing-ThrustCRB=\u4e09\u884c\u63a8\u529b\u5706\u67f1\u6eda\u5b50\u8f74\u627f +Sanxing-Drawncupneedlerollerbearing=\u4e09\u884c\u51b2\u538b\u5916\u5708\u6eda\u9488\u8f74\u627f +Sanxing-Solidneedlerollerbearings=\u4e09\u884c\u5b9e\u4f53\u6eda\u9488\u8f74\u627f +Sanxing-Cagecomponents=\u4e09\u884c\u4fdd\u6301\u67b6\u7ec4\u4ef6 +Sanxing-Thrustneedlerollerbearing=\u4e09\u884c\u63a8\u529b\u6eda\u9488\u8f74\u627f +Sanxing-Thrustangularcontactballbearing=\u4e09\u884c\u63a8\u529b\u89d2\u63a5\u89e6\u7403\u8f74\u627f +Sanxing-Taperrollerthrustbearing=\u4e09\u884c\u63a8\u529b\u5706\u9525\u6eda\u5b50\u8f74\u627f +Sanxing-Thrustsphericalrollerbearing=\u4e09\u884c\u63a8\u529b\u8c03\u5fc3\u6eda\u5b50\u8f74\u627f +Sanxing-Waterpumpbearing=\u4e09\u884c\u6c34\u6cf5\u8f74\u627f +Sanxing-Tensionwheelbearing=\u4e09\u884c\u5f20\u7d27\u8f6e\u8f74\u627f +Sanxing-HUB1=\u4e09\u884c\u4e00\u4ee3\u8f6e\u6bc2\u8f74\u627f +Sanxing-HUB2=\u4e09\u884c\u4e8c\u4ee3\u8f6e\u6bc2\u8f74\u627f +Sanxing-HUB3=\u4e09\u884c\u4e09\u4ee3\u8f6e\u6bc2\u8f74\u627f +Sanxing-Automotiveelectromagneticclutchbearing=\u4e09\u884c\u7535\u78c1\u79bb\u5408\u5668\u8f74\u627f +Sanxing-ExternalSphericalBallBearing=\u4e09\u884c\u5916\u7403\u9762\u7403\u8f74\u627f +Sanxing-Jointbearing=\u4e09\u884c\u5173\u8282\u8f74\u627f +Sanxing-TypeMGMastGuideBearing=\u4e09\u884c\u004d\u0047\u578b\u53c9\u8f66\u95e8\u67b6\u6eda\u8f6e\u8f74\u627f +Sanxing-TypeCGChainGuideBearings=\u4e09\u884c\u0043\u0047\u578b\u53c9\u8f66\u95e8\u67b6\u94fe\u8f6e\u8f74\u627f +Sanxing-TypeSRSideRollerBearings=\u4e09\u884c\u0053\u0052\u578b\u53c9\u8f66\u95e8\u67b6\u4fa7\u5411\u8f74\u627f +Sanxing-Combinedroller=\u4e09\u884c\u7ec4\u5408\u6eda\u8f6e +Sanxing-Slewingbearingandwindpowerbearing=\u4e09\u884c\u56de\u8f6c\u652f\u627f\u4e0e\u98ce\u7535\u8f74\u627f +Sanxing-Unilateralbearingandunilateralclutches=\u4e09\u884c\u5355\u5411\u8f74\u627f\u548c\u5355\u5411\u79bb\u5408\u5668 +Sanxing-Clutchreleasebearingforautomobiles=\u4e09\u884c\u6c7d\u8f66\u79bb\u5408\u5668\u8f74\u627f +Sanxing-Linearballbearings=\u4e09\u884c\u76f4\u7ebf\u8f74\u627f +Sanxing-Automobileshockabsorberbearing=\u4e09\u884c\u6c7d\u8f66\u51cf\u632f\u5668\u8f74\u627f +Sanxing-Rollerbearing=\u4e09\u884c\u6eda\u8f6e\u8f74\u627f +Sanxing-Wanxiangjie(includingrepairkit)=\u4e09\u884c\u4e07\u5411\u8282\uff08\u542b\u4fee\u7406\u5305\uff09 +Sanxing-Wanxiangjieassembly=\u4e09\u884c\u4e07\u5411\u8282\u603b\u6210 +Sanxing-Wanxiangjieneedlerollerbearing=\u4e09\u884c\u4e07\u5411\u8282\u6eda\u9488\u8f74\u627f +Sanxing-Tripodproducts=\u4e09\u884c\u4e09\u9500\u67b6\u4ea7\u54c1 +Sanxing-Miniaturedeepgrooveballbearing=\u4e09\u884c\u5fae\u578b\u6df1\u6c9f\u7403\u8f74\u627f +Sanxing-Otherpartsandproducts=\u4e09\u884c\u5176\u4ed6\u96f6\u4ef6\u4ea7\u54c1 +Sanxing-Autorockarmbearing=\u4e09\u884c\u6c7d\u8f66\u6447\u81c2\u8f74\u627f +Sanxing-BZRotorbearing=\u4e09\u884c\u0042\u005a\u8f6c\u676f\u8f74\u627f +Sanxing-GZOpeningrollerbearing=\u4e09\u884c\u0047\u005a\u5206\u68b3\u8f8a\u8f74\u627f +Sanxing-SLToprollerbearing=\u4e09\u884c\u0053\u004c\u4e0a\u7f57\u62c9\u8f74\u627f +Sanxing-LZBottomrollerbearing=\u4e09\u884c\u004c\u005a\u4e0b\u7f57\u62c9\u8f74\u627f +Sanxing-TypeDZspindlebearing=\u4e09\u884c\u0044\u005a\u7eba\u952d\u8f74\u627f +Sanxing-TypeFGeneralbearingforspinningmachine=\u4e09\u884c\u0046\u578b\u7eba\u673a\u901a\u7528\u8f74\u627f +Sanxing-Non-standradsphericalrollerbearings=\u4e09\u884c\u975e\u6807\u8c03\u5fc3\u6eda\u5b50\u8f74\u627f +Sanxing-Non-standradtaperedrollerbearings=\u4e09\u884c\u975e\u6807\u5706\u9525\u6eda\u5b50\u8f74\u627f +Sanxing-Non-standradcylindricalrollerbearings=\u4e09\u884c\u975e\u6807\u5706\u67f1\u6eda\u5b50\u8f74\u627f +Sanxing-Non-standradthrustballbearings=\u4e09\u884c\u975e\u6807\u63a8\u529b\u7403\u8f74\u627f +Sanxing-Non-standraddeepgrooveballbearings=\u4e09\u884c\u975e\u6807\u6df1\u6c9f\u7403\u8f74\u627f +Sanxing-Non-standradangularcontactbearings=\u4e09\u884c\u975e\u6807\u89d2\u63a5\u89e6\u8f74\u627f +Sanxing-Non-standradstampingbearings=\u4e09\u884c\u975e\u6807\u51b2\u538b +Sanxing-Non-standardentitybearings=\u4e09\u884c\u975e\u6807\u5b9e\u4f53 +Sanxing-Non-standardcagecomponents=\u4e09\u884c\u975e\u6807\u4fdd\u6301\u67b6\u7ec4\u4ef6 +Sanxing-Componentbearing=\u4e09\u884c\u7ec4\u4ef6\u8f74\u627f +Sanxing-Firstgenerationwheelrepairkit=\u4e09\u884c\u4e00\u4ee3\u8f6e\u6bc2\u4fee\u7406\u5305 +Sanxing-Secondgenerationwheelrepairkit=\u4e09\u884c\u4e8c\u4ee3\u8f6e\u6bc2\u4fee\u7406\u5305 +Sanxing-Thirdgenerationwheelrepairkit=\u4e09\u884c\u4e09\u4ee3\u8f6e\u6bc2\u4fee\u7406\u5305 +Sanxing-Singlerowconerepairkit=\u4e09\u884c\u5355\u5217\u5706\u9525\u4fee\u7406\u5305 +OuterRing=\u5916\u5708 +InnerRing=\u5185\u5708 +Cage=\u4FDD\u6301\u67B6 +Seal=\u5BC6\u5C01\u5708 +Bearingaccessories=\u8f74\u627f\u914d\u4ef6 +Cover=\u5916\u7f69 +Mandrel=\u82af\u8f74 +Hotpiece=\u70ed\u4ef6 +Carparts=\u8f66\u4ef6 +Forgings=\u953b\u4ef6 +Dustcover=\u9632\u5c18\u76d6 +Seat=\u5ea7\u5708 +Shaftring=\u8f74\u5708 +Sealingstrip=\u5bc6\u5c01\u6761 +Adjustmentblock=\u8c03\u6574\u5757 +Outerringofmainroller=\u4e3b\u6eda\u8f6e\u5916\u5708 +Innerringofmainroller=\u4e3b\u6eda\u8f6e\u5185\u5708 +Mainrollercage=\u4e3b\u6eda\u8f6e\u4fdd\u6301\u67b6 +Mainrollerseal=\u4e3b\u6eda\u8f6e\u5BC6\u5C01\u5708 +Mainrollerdustcover=\u4e3b\u6eda\u8f6e\u9632\u5c18\u76d6 +Siderollerouterring=\u4fa7\u6eda\u8f6e\u5916\u5708 +Siderollercage=\u4fa7\u6eda\u8f6e\u4fdd\u6301\u67b6 +Siderollerseal=\u4fa7\u6eda\u8f6e\u5BC6\u5C01\u5708 +Siderollerdustcover=\u4fa7\u6eda\u8f6e\u9632\u5c18\u76d6 +Outringwithflange=\u6cd5\u5170\u5916\u5708 +Innerseal=\u5185\u5bc6\u5c01\u4ef6 +Flangeinnerring=\u6cd5\u5170\u5185\u5708 +Outerseal=\u5916\u5bc6\u5c01\u4ef6 +Seatring=\u5ea7\u5708 +Washer=\u57ab\u5708 +Middleretainingring=\u4e2d\u6321\u5708 +Bearingseat=\u8f74\u627f\u5ea7 +Isolatedblock=\u9694\u79bb\u5757 +Shell=\u5916\u58f3 +Innerwheel=\u5185\u8f6e +Connectingshaft=\u8fde\u63a5\u8f74 +Retainingring=\u6321\u5708 +PartNumber=\u4EF6\u53F7 +RadialInternalClearance=\u5F84\u5411\u5185\u90E8\u6E38\u9699 +Semi-finishedproduct=\u534a\u6210\u54c1 +Category=\u7C7B\u522B +Steelproducts=\u94a2\u6750 +Castiron=\u94f8\u94c1 +Coppermaterial=\u94dc\u6750 +Bar=\u68d2\u6750 +Plate=\u677f\u6750 +Wire=\u7ebf\u6750 +Coil=\u5377\u6750 +Tube=\u7ba1\u6750 +Assemblymaterialcode=\u603b\u6210\u7269\u6599\u7f16\u7801 +Name=\u540d\u79f0 +Edition=\u7248\u672c +Steelballcomponnents=\u94a2\u7403\u7ec4\u4ef6 +Sanxing-Steelballcomponnents=\u4e09\u884c\u94a2\u7403\u7ec4\u4ef6 +Taperedrollercomponents=\u5706\u9525\u6eda\u5b50\u7ec4\u4ef6 +Needlerollercomponents=\u6eda\u9488\u7ec4\u4ef6 +Cylindricalrollercomponents=\u5706\u67f1\u6eda\u5b50\u7ec4\u4ef6 +Sphericalrollercomponents=\u7403\u9762\u6eda\u5b50\u7ec4\u4ef6 +Sanxing-Taperedrollercomponents=\u4e09\u884c\u5706\u9525\u6eda\u5b50\u7ec4\u4ef6 +Sanxing-Needlerollercomponents=\u4e09\u884c\u6eda\u9488\u7ec4\u4ef6 +Sanxing-Cylindricalrollercomponents=\u4e09\u884c\u5706\u67f1\u6eda\u5b50\u7ec4\u4ef6 +Sanxing-Sphericalrollercomponents=\u4e09\u884c\u7403\u9762\u6eda\u5b50\u7ec4\u4ef6 +Wheelboltcomponents=\u8f66\u8f6e\u87ba\u6813\u7ec4\u4ef6 +Rivetcomponents=\u94c6\u9489\u7ec4\u4ef6 +Stopringcomponents=\u6b62\u52a8\u73af\u7ec4\u4ef6 +Oilcupcomponents=\u6cb9\u676f\u7ec4\u4ef6 +Setscrewcomponents=\u7d27\u5b9a\u87ba\u9489\u7ec4\u4ef6 +Adaptersleevecomponents=\u7d27\u5b9a\u5957\u7ec4\u4ef6 +Withdrawalsleevecomponents=\u9000\u5378\u5957\u7ec4\u4ef6 +Splitverticalbearingseatcomponents=\u5256\u5206\u7acb\u5f0f\u8f74\u627f\u5ea7\u7ec4\u4ef6 +Sanxing-Wheelboltcomponents=\u4e09\u884c\u8f66\u8f6e\u87ba\u6813\u7ec4\u4ef6 +Sanxing-Rivetcomponents=\u4e09\u884c\u94c6\u9489\u7ec4\u4ef6 +Sanxing-Stopringcomponents=\u4e09\u884c\u6b62\u52a8\u73af\u7ec4\u4ef6 +Sanxing-Oilcupcomponents=\u4e09\u884c\u6cb9\u676f\u7ec4\u4ef6 +Sanxing-Setscrewcomponents=\u4e09\u884c\u7d27\u5b9a\u87ba\u9489\u7ec4\u4ef6 +Sanxing-Adaptersleevecomponents=\u4e09\u884c\u7d27\u5b9a\u5957\u7ec4\u4ef6 +Sanxing-Withdrawalsleevecomponents=\u4e09\u884c\u9000\u5378\u5957\u7ec4\u4ef6 +Sanxing-Splitverticalbearingseatcomponents=\u4e09\u884c\u5256\u5206\u7acb\u5f0f\u8f74\u627f\u5ea7\u7ec4\u4ef6 +Otheraccessories=\u5176\u5b83\u914d\u4ef6 +Universaljointcrossshaft=\u4e07\u5411\u8282\u5341\u5b57\u8f74 +Thespider=\u5341\u5b57\u8f74 +Oilcup=\u6cb9\u676f +Sanxing-Universaljointcrossshaft=\u4e09\u884c\u4e07\u5411\u8282\u5341\u5b57\u8f74 +Slewingbearingandwindpowerbearingstandardtype=\u56de\u8f6c\u652f\u627f\uff08\u6807\u51c6\u578b\uff09 +SlewingbearingandwindpowerbearingWireracewayassembly=\u56de\u8f6c\u652f\u627f\uff08\u94a2\u4e1d\u6eda\u9053\u7ec4\u4ef6\uff09 +Slewingbearingandwindpowerbearingspecialtype=\u56de\u8f6c\u652f\u627f\uff08\u7279\u6b8a\u578b\uff09 +Sanxing-Slewingbearingandwindpowerbearingstandardtype=\u4e09\u884c\u56de\u8f6c\u652f\u627f\uff08\u6807\u51c6\u578b\uff09 +Sanxing-SlewingbearingandwindpowerbearingWireracewayassembly=\u4e09\u884c\u56de\u8f6c\u652f\u627f\uff08\u94a2\u4e1d\u6eda\u9053\u7ec4\u4ef6\uff09 +Sanxing-Slewingbearingandwindpowerbearingspecialtype=\u4e09\u884c\u56de\u8f6c\u652f\u627f\uff08\u7279\u6b8a\u578b\uff09 +Plainbearing=\u6ed1\u52a8\u8f74\u627f +Bearinghousing=\u8f74\u627f\u5ea7 +Thrustdisc=\u63a8\u529b\u76d8 +Bearingbody=\u8f74\u627f\u4f53 +Thrusttile=\u63a8\u529b\u74e6 +Balanceblock=\u5e73\u8861\u5757 +screw=\u87ba\u9489 +adjustmentplate=\u8c03\u6574\u677f +Sanxing-Plainbearing=\u4e09\u884c\u6ed1\u52a8\u8f74\u627f +Ballscrew=\u6eda\u73e0\u4e1d\u6760 +nut=\u87ba\u6bcd +screw=\u4e1d\u6746 +reverser=\u53cd\u5411\u5668 +Sanxing-Ballscrew=\u4e09\u884c\u6eda\u73e0\u4e1d\u6760 +Spring=\u5f39\u7c27 +Insert=\u9aa8\u67b6 +Sealinginsert=\u5bc6\u5c01\u4ef6\u9aa8\u67b6 +Oilsealinginsert=\u6cb9\u5c01\u9aa8\u67b6 +Dustcap=\u9632\u5c18\u76d6 +Others=\u5176\u5b83 +Ring=\u5957\u5708 +Bearing=\u8f74\u627f +Pulley=\u6da8\u7d27\u8f6e +Slidinggatebearing=\u79fb\u95e8\u8f74\u627f +Plasticcoatingbearing=\u5305\u5851\u8f74\u627f +Nut=\u87ba\u6bcd +Rivet=\u94c6\u9489 +Conventionalproducts=\u5e38\u89c4\u4ea7\u54c1 +Rollerbodypin=\u6eda\u52a8\u4f53\u3001\u9500\u5b50 +forging=\u953b\u4ef6 +Turning=\u8f66\u4ef6 +heattreatmentpiece=\u70ed\u5904\u7406\u4ef6 +ColdPierpieces=\u51b7\u9566\u4ef6 +PartCategory=\u96f6\u4ef6\u7c7b\u522b + diff --git a/src/com/connor/rb/plm/youhua/GetZC_LBJ_Pro.java b/src/com/connor/rb/plm/youhua/GetZC_LBJ_Pro.java new file mode 100644 index 0000000..86783c4 --- /dev/null +++ b/src/com/connor/rb/plm/youhua/GetZC_LBJ_Pro.java @@ -0,0 +1,8 @@ +package com.connor.rb.plm.youhua; + +public class GetZC_LBJ_Pro { + + public void getObjPro() { + + } +} diff --git a/src/com/connor/renben/process/plm/message/Message.properties b/src/com/connor/renben/process/plm/message/Message.properties new file mode 100644 index 0000000..f25596e --- /dev/null +++ b/src/com/connor/renben/process/plm/message/Message.properties @@ -0,0 +1,98 @@ +qxzsjjdxjxcz15_display.TITLE=Please select a dataset object for operation! +lcygq15_display.TITLE=The process has expired. Please re send the process for approval before printing! +lcz15_display.TITLE=In the process, please print after approval! +xddxxdsjj15_display.TITLE=Please send the data set under the restricted object to the process for approval before printing! +dycg15_display.TITLE=Printing succeeded! +dysb15_display.TITLE=Printing failed! +lccg15_display.TITLE=Save successfully! +qxzbdzmdbbjxsj01_display.TITLE=Please select the version without letters to upgrade! +qxzygbbjxsj01_display.TITLE=Please select a version to upgrade! +xdwc01_display.TITLE=Revision completed! +xdsb01_display.TITLE=Revision failed! +qxztzbbdxjxsbcz01_display.TITLE=Please select a drawing version object to upgrade! +qxzbbdx01_display.TITLE=Please select a version object! +qxzysyddx07_display.TITLE=Please select the object to use +qxzdhsj07_display.TITLE=Please select a single row of data +tzyycg07_display.TITLE=Drawing reference succeeded! +xzdsj07_display.TITLE=The selected data is not an ICO object +qxzzdcjd07_display.TITLE=Please select the lowest level node! +xzdwlmyfsdfl07_display.TITLE=The selected material has not been sent to the classification, please send! +zcwlbm_display.TITLE=Assembly material code\uff1a +banben_display.TITLE=Revision: +mingcheng_display.TITLE=Name: +sxwtx07_display.TITLE=Attribute not filled! +qtxwlzcbh07_display.TITLE=Please fill in the assembly material number! +wlcjcg07_display.TITLE=Material created successfully! +wlcjsb07_display.TITLE=Material creation failed! +qxzzcbbhlbj07_display.TITLE=Please select assembly version or component version object to create! +qxzbbdx07_display.TITLE=Please select a version object to create! +nstwl11_display.TITLE=The assembly material ID you filled does not exist in the system, please check and re-enter! +qxzypzddxcj11_display.TITLE=Please select the configured object creation! +jhbntstxlgz12_display.TITLE=Two values cannot be filled in for part number at the same time! +xtzycz12_display.TITLE=The material with this ID number already exists in the system, please check and create it! +lswlcjsb12_display.TITLE=Failed to create temporary material! +lswlcjwc12_display.TITLE=Temporary material creation completed! +qxzzchlbj013_display.TITLE=Please select assembly or component version object to upgrade! +sbcg13_display.TITLE=Upgrade succeeded! +qxz13_display.TITLE=Please select assembly version or component version! +_display.TITLE=Please select assembly or components! +gbcz13_display.TITLE=Please select an assembly, component version, or standard part object for revision operation! +bbghcg13_display.TITLE=Version changed successfully! +bomzczbf16_display.TITLE=If there are materials or temporary materials in scrap status in the BOM, please check the BOM and adjust +bomwfbclswl_display.TITLE=The material is temporary and cannot be built into a formal BOM! BOM cannot be saved +qxzggtzbb18_display.TITLE=Please select the change notification version! +qxzcadtzjxcz19_display.TITLE=Please select CAD drawing for operation! +qxzwlbb19_display.TITLE=Please select material version object for operation! +qxzsjjdx19_display.TITLE=Please select dataset object or material version object for operation! +myzdcx19_display.TITLE=Query not found: +gwlmyfszfl19_display.TITLE=This material has not been sent to classification, please send classification first! +qxzshrw19_display.TITLE=Please select the approval task! +nmydyqx19_display.TITLE=You have no permission to print, please contact the administrator! +qxzsjjdxjxcz22_display.TITLE=Please select a dataset object for operation! +bmpjwc23_display.TITLE=Code splicing completed! +bmpjsb23_display.TITLE=Code splicing failed! +xzdwl23_display.TITLE=Selected materials: +myfsdfl23_display.TITLE=not sent to category, please send! +xzddxwflj24_display.TITLE=The selected object is a non component object, please check! +mssxtxcg24_display.TITLE=The description attribute is filled successfully, please check! +mybbxgqx24_display.TITLE=No permission to modify version, please contact the system administrator! +qxzbb25_display.TITLE=Please select a version! +dqbbwbfl25_display.TITLE=The current version is not classified +xgflsxcg25_display.TITLE=Successfully modified classification attribute! +xgflsxsb25_display.TITLE=Failed to modify classification property! +qxzbbdx27_display.TITLE=Please select a version object! +hqspmcg27_display.TITLE=Get commodity code successfully! +wllcsb28_display.TITLE=Failed to save the material! +wllccg28_display.TITLE=Material saved successfully! +bntstxlgz28_display.TITLE=Two values cannot be filled in at the same time! +bxtxygz28_display.TITLE=You must fill in a value! +qxzzcbb28_display.TITLE=Please select assembly version object to create! +qxzbbdxjxcj28_display.TITLE=Please select a version object to create! +sxgxwc29_display.TITLE=Property updated successfully! +qxzycjdzdx30_display.TITLE=Please select the sub object to be created! +qtxzdxdIDhmc30_display.TITLE=Please fill in the ID and name of the sub object! +cjcg30_display.TITLE=Created successfully! +qxzcupm30_display.TITLE=Please select CUPM project development object version! +zpwc31_display.TITLE=Assignment completed! +xzdwfbbdx31_display.TITLE=: Selected non version objects cannot be assigned +xzdwfzcdx31_display.TITLE=: Selected non assembly objects cannot be assigned +wzdyydAQPQdx34_display.TITLE=No referenced AQPQ object found! +sxhqwc34_display.TITLE=Property acquisition completed! +qxz34_display.TITLE=Please select: +dxjxcz34_display.TITLE=,object type operation +lxwx34_display.TITLE=Invalid type! +sjkljcwutil_display.TITLE=Database connection error +wzdglxddxutil_display.TITLE=The object configuration information of this type is not found, please contact the administrator! +sjjmymmutil_display.TITLE=Dataset has no named and referenced files or there are too many files, please check! +gnzcdx_display.TITLE=Please select the object of solid resistance assembly! +item_revquery.TITLE=Item Revision... +item_idquery.TITLE=Item ID +revquery.TITLE=Revision +fabu_TITLE=TCM Released +wjj35_display.TITLE=Folder +czsb_display.TITLE=Operation failed +xzwjj_display.TITLE=Select folder +czcg_display.TITLE=Operation successful +qxzdxhzbbjxcz_display.TITLE=Please select an object for operation +sxxpzyw031_display.TITLE=Preference option [RB3_XMZPTYPECOFIG] configuration exception! +xdsb01111_display.TITLE=Preference option [RB3_ProcessOPReviseAddress] configuration exception! \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/message/Message_zh_CN.properties b/src/com/connor/renben/process/plm/message/Message_zh_CN.properties new file mode 100644 index 0000000..e917eae --- /dev/null +++ b/src/com/connor/renben/process/plm/message/Message_zh_CN.properties @@ -0,0 +1,99 @@ +qxzsjjdxjxcz15_display.TITLE=\u8bf7\u9009\u62e9\u6570\u636e\u96c6\u5bf9\u8c61\u8fdb\u884c\u64cd\u4f5c\uff01 +lcygq15_display.TITLE=\u6d41\u7a0b\u5df2\u8fc7\u671f\uff0c\u8bf7\u91cd\u65b0\u53d1\u9001\u6d41\u7a0b\u5ba1\u6838\u901a\u8fc7\u540e\u518d\u6253\u5370\uff01 +lcz15_display.TITLE=\u6d41\u7a0b\u4e2d\uff0c\u8bf7\u5728\u5ba1\u6838\u901a\u8fc7\u540e\u6253\u5370\uff01 +xddxxdsjj15_display.TITLE=\u9650\u5b9a\u5bf9\u8c61\u4e0b\u7684\u6570\u636e\u96c6\u8bf7\u5148\u53d1\u9001\u6d41\u7a0b\u5ba1\u6838\u901a\u8fc7\u540e\u518d\u6253\u5370\uff01 +dycg15_display.TITLE=\u6253\u5370\u6210\u529f\uff01 +dysb15_display.TITLE=\u6253\u5370\u5931\u8d25\uff01 +lccg15_display.TITLE=\u53e6\u5b58\u6210\u529f\uff01 +qxzbdzmdbbjxsj01_display.TITLE=\u8bf7\u9009\u62e9\u4e0d\u5e26\u5b57\u6bcd\u7684\u7248\u672c\u8fdb\u884c\u5347\u7248\uff01 +qxzygbbjxsj01_display.TITLE=\u8bf7\u9009\u62e9\u4e00\u4e2a\u7248\u672c\u8fdb\u884c\u5347\u7248\uff01 +xdwc01_display.TITLE=\u4fee\u8ba2\u5b8c\u6210! +xdsb01_display.TITLE=\u4fee\u8ba2\u5931\u8d25! +qxztzbbdxjxsbcz01_display.TITLE=\u8bf7\u9009\u62e9\u56fe\u7eb8\u7248\u672c\u5bf9\u8c61\u8fdb\u884c\u5347\u7248\u64cd\u4f5c\uff01 +qxzbbdx01_display.TITLE=\u8bf7\u9009\u62e9\u7248\u672c\u5bf9\u8c61\uff01 +qxzysyddx07_display.TITLE=\u8bf7\u9009\u62e9\u8981\u4f7f\u7528\u7684\u5bf9\u8c61 +qxzdhsj07_display.TITLE=\u8bf7\u9009\u62e9\u5355\u884c\u6570\u636e +tzyycg07_display.TITLE=\u56fe\u7eb8\u5f15\u7528\u6210\u529f\uff01 +xzdsj07_display.TITLE=\u9009\u62e9\u7684\u6570\u636e\u4e0d\u662fICO\u5bf9\u8c61 +qxzzdcjd07_display.TITLE=\u8bf7\u9009\u62e9\u6700\u5e95\u5c42\u8282\u70b9\uff01 +xzdwlmyfsdfl07_display.TITLE=\u9009\u4e2d\u7684\u7269\u6599\u6ca1\u6709\u53d1\u9001\u5230\u5206\u7c7b\uff0c\u8bf7\u53d1\u9001\uff01 +zcwlbm_display.TITLE=\u603b\u6210\u7269\u6599\u7f16\u7801\uff1a +banben_display.TITLE=\u7248\u672c\uff1a +mingcheng_display.TITLE=\u540d\u79f0\uff1a +sxwtx07_display.TITLE=\u5c5e\u6027\u672a\u586b\u5199\uff01 +qtxwlzcbh07_display.TITLE=\u8bf7\u586b\u5199\u603b\u6210\u7269\u6599\u7f16\u53f7\uff01 +wlcjcg07_display.TITLE=\u7269\u6599\u521b\u5efa\u6210\u529f\uff01 +wlcjsb07_display.TITLE=\u7269\u6599\u521b\u5efa\u5931\u8d25\uff01 +qxzzcbbhlbj07_display.TITLE=\u8bf7\u9009\u62e9\u603b\u6210\u7248\u672c\u6216\u96f6\u90e8\u4ef6\u7248\u672c\u5bf9\u8c61\u8fdb\u884c\u521b\u5efa! +qxzbbdx07_display.TITLE=\u8bf7\u9009\u62e9\u7248\u672c\u5bf9\u8c61\u8fdb\u884c\u521b\u5efa! +nstwl11_display.TITLE=\u60a8\u6240\u586b\u7684\u603b\u6210\u7269\u6599ID\u5728\u7cfb\u7edf\u4e2d\u672a\u5b58\u5728\uff0c\u8bf7\u68c0\u67e5\u540e\u91cd\u65b0\u8f93\u5165\uff01 +qxzypzddxcj11_display.TITLE=\u8bf7\u9009\u62e9\u5df2\u914d\u7f6e\u7684\u5bf9\u8c61\u521b\u5efa\uff01 +jhbntstxlgz12_display.TITLE=\u4ef6\u53f7\u4e0d\u80fd\u540c\u65f6\u586b\u5199\u4e24\u4e2a\u503c\uff01 +xtzycz12_display.TITLE=\u7cfb\u7edf\u4e2d\u5df2\u7ecf\u5b58\u5728\u8be5ID\u53f7\u7684\u7269\u6599,\u8bf7\u68c0\u67e5\u540e\u521b\u5efa! +lswlcjsb12_display.TITLE=\u4e34\u65f6\u7269\u6599\u521b\u5efa\u5931\u8d25! +lswlcjwc12_display.TITLE=\u4e34\u65f6\u7269\u6599\u521b\u5efa\u5b8c\u6210! +qxzzchlbj013_display.TITLE=\u8bf7\u9009\u62e9\u603b\u6210\u6216\u96f6\u90e8\u4ef6\u7248\u672c\u5bf9\u8c61\u8fdb\u884c\u5347\u7248\u64cd\u4f5c! +sbcg13_display.TITLE=\u5347\u7248\u6210\u529f\uff01 +qxz13_display.TITLE=\u8bf7\u9009\u62e9\u603b\u6210\u7248\u672c\u6216\u96f6\u7ec4\u4ef6\u7248\u672c\uff01 +qxzz13_display.TITLE=\u8bf7\u9009\u62e9\u603b\u6210\u6216\u96f6\u7ec4\u4ef6\uff01 +gbcz13_display.TITLE=\u8bf7\u9009\u62e9\u603b\u6210\u3001\u96f6\u90e8\u4ef6\u7248\u672c\u6216\u6807\u51c6\u4ef6\u5bf9\u8c61\u8fdb\u884c\u6539\u7248\u64cd\u4f5c! +bbghcg13_display.TITLE=\u7248\u672c\u66f4\u6362\u6210\u529f\uff01 +bomzczbf16_display.TITLE=BOM\u4e2d\u5b58\u5728\u62a5\u5e9f\u72b6\u6001\u7684\u7269\u6599\u6216\u4e34\u65f6\u7269\u6599\uff0c\u8bf7\u68c0\u67e5BOM\u5e76\u8c03\u6574 +bomwfbclswl_display.TITLE=\u7269\u6599\u4e3a\u4e34\u65f6\u7269\u6599\uff0c\u4e0d\u5141\u8bb8\u642d\u5efa\u5230\u6b63\u5f0fBOM\uff01BOM\u65e0\u6cd5\u4fdd\u5b58 +qxzggtzbb18_display.TITLE=\u8bf7\u9009\u4e2d\u66f4\u6539\u901a\u77e5\u7248\u672c\uff01 +qxzcadtzjxcz19_display.TITLE=\u8bf7\u9009\u62e9CAD\u56fe\u7eb8\u8fdb\u884c\u64cd\u4f5c\uff01 +qxzwlbb19_display.TITLE=\u8bf7\u9009\u62e9\u7269\u6599\u7248\u672c\u5bf9\u8c61\u8fdb\u884c\u64cd\u4f5c\uff01 +qxzsjjdx19_display.TITLE=\u8bf7\u9009\u62e9\u6570\u636e\u96c6\u5bf9\u8c61\u6216\u8005\u7269\u6599\u7248\u672c\u5bf9\u8c61\u8fdb\u884c\u64cd\u4f5c\uff01 +myzdcx19_display.TITLE=\u6ca1\u6709\u627e\u5230\u67e5\u8be2: +gwlmyfszfl19_display.TITLE=\u8be5\u7269\u6599\u6ca1\u6709\u53d1\u9001\u81f3\u5206\u7c7b\uff0c\u8bf7\u5148\u53d1\u9001\u5206\u7c7b! +qxzshrw19_display.TITLE=\u8bf7\u9009\u4e2d\u5ba1\u6838\u4efb\u52a1\uff01 +nmydyqx19_display.TITLE=\u60a8\u6ca1\u6709\u6253\u5370\u6743\u9650,\u8bf7\u8054\u7cfb\u7ba1\u7406\u5458\uff01 +qxzsjjdxjxcz22_display.TITLE=\u8bf7\u9009\u62e9\u6570\u636e\u96c6\u5bf9\u8c61\u8fdb\u884c\u64cd\u4f5c\uff01 +bmpjwc23_display.TITLE=\u7f16\u7801\u62fc\u63a5\u5b8c\u6210\uff01 +bmpjsb23_display.TITLE=\u7f16\u7801\u62fc\u63a5\u5931\u8d25\uff01 +xzdwl23_display.TITLE=\u9009\u4e2d\u7684\u7269\u6599\uff1a +myfsdfl23_display.TITLE=\u6ca1\u6709\u53d1\u9001\u5230\u5206\u7c7b\uff0c\u8bf7\u53d1\u9001\uff01 +xzddxwflj24_display.TITLE=\u9009\u4e2d\u7684\u5bf9\u8c61\u4e3a\u975e\u96f6\u7ec4\u4ef6\u5bf9\u8c61,\u8bf7\u67e5\u770b! +mssxtxcg24_display.TITLE=\u63cf\u8ff0\u5c5e\u6027\u586b\u5199\u6210\u529f,\u8bf7\u67e5\u770b! +mybbxgqx24_display.TITLE=\u6ca1\u6709\u7248\u672c\u4fee\u6539\u6743\u9650\uff0c\u8bf7\u8054\u7cfb\u7cfb\u7edf\u7ba1\u7406\u5458\uff01 +qxzbb25_display.TITLE=\u8bf7\u9009\u62e9\u7248\u672c\uff01 +dqbbwbfl25_display.TITLE=\u5f53\u524d\u7248\u672c\u672a\u88ab\u5206\u7c7b +xgflsxcg25_display.TITLE=\u4fee\u6539\u5206\u7c7b\u5c5e\u6027\u6210\u529f\uff01 +xgflsxsb25_display.TITLE=\u4fee\u6539\u5206\u7c7b\u5c5e\u6027\u5931\u8d25\uff01 +qxzbbdx27_display.TITLE=\u8bf7\u9009\u4e2d\u7248\u672c\u5bf9\u8c61\uff01 +hqspmcg27_display.TITLE=\u83b7\u53d6\u5546\u54c1\u7801\u6210\u529f\uff01 +hqspmsb27_display.TITLE=\u83b7\u53d6\u5546\u54c1\u7801\u5931\u8d25\uff01 +wllcsb28_display.TITLE=\u7269\u6599\u53e6\u5b58\u5931\u8d25! +wllccg28_display.TITLE=\u7269\u6599\u53e6\u5b58\u6210\u529f! +bntstxlgz28_display.TITLE=\u4e0d\u80fd\u540c\u65f6\u586b\u5199\u4e24\u4e2a\u503c\uff01 +bxtxygz28_display.TITLE=\u5fc5\u987b\u586b\u5199\u4e00\u4e2a\u503c\uff01 +qxzzcbb28_display.TITLE=\u8bf7\u9009\u62e9\u603b\u6210\u7248\u672c\u5bf9\u8c61\u8fdb\u884c\u521b\u5efa! +qxzbbdxjxcj28_display.TITLE=\u8bf7\u9009\u62e9\u7248\u672c\u5bf9\u8c61\u8fdb\u884c\u521b\u5efa! +sxgxwc29_display.TITLE=\u5c5e\u6027\u66f4\u65b0\u5b8c\u6210\uff01 +qxzycjdzdx30_display.TITLE=\u8bf7\u9009\u4e2d\u8981\u521b\u5efa\u7684\u5b50\u5bf9\u8c61\uff01 +qtxzdxdIDhmc30_display.TITLE=\u8bf7\u586b\u5199\u5b50\u5bf9\u8c61\u7684ID\u548c\u540d\u79f0\uff01 +cjcg30_display.TITLE=\u521b\u5efa\u6210\u529f\uff01 +qxzcupm30_display.TITLE=\u8bf7\u9009\u4e2dCUPM\u9879\u76ee\u5f00\u53d1\u5bf9\u8c61\u7248\u672c\uff01 +zpwc31_display.TITLE=\u6307\u6d3e\u5b8c\u6210\uff01 +xzdwfbbdx31_display.TITLE=:\u9009\u4e2d\u7684\u4e3a\u975e\u7248\u672c\u5bf9\u8c61\u65e0\u6cd5\u6307\u6d3e +xzdwfzcdx31_display.TITLE=:\u9009\u4e2d\u7684\u4e3a\u975e\u603b\u6210\u5bf9\u8c61\u65e0\u6cd5\u6307\u6d3e +wzdyydAQPQdx34_display.TITLE=\u672a\u627e\u5230\u5f15\u7528\u7684AQPQ\u5bf9\u8c61\uff01 +sxhqwc34_display.TITLE=\u5c5e\u6027\u83b7\u53d6\u5b8c\u6210\uff01 +qxz34_display.TITLE=\u8bf7\u9009\u62e9\uff1a +dxjxcz34_display.TITLE=\uff0c\u5bf9\u8c61\u8fdb\u884c\u64cd\u4f5c +lxwx34_display.TITLE=\u7c7b\u578b\u65e0\u6548\uff01 +sjkljcwutil_display.TITLE=\u6570\u636e\u5e93\u8fde\u63a5\u9519\u8bef +wzdglxddxutil_display.TITLE=\u672a\u627e\u5230\u8be5\u7c7b\u578b\u7684\u5bf9\u8c61\u914d\u7f6e\u4fe1\u606f\uff0c\u8bf7\u8054\u7cfb\u7ba1\u7406\u5458\uff01 +sjjmymmutil_display.TITLE=\u6570\u636e\u96c6\u6ca1\u6709\u547d\u540d\u5f15\u7528\u7684\u6587\u4ef6\u6216\u6587\u4ef6\u8fc7\u591a\uff0c\u8bf7\u68c0\u67e5\uff01 +gnzcdx_display.TITLE=\u8bf7\u9009\u62e9\u56fa\u8010\u603b\u6210\u5bf9\u8c61\u7c7b\u578b +item_revquery.TITLE=\u96f6\u7ec4\u4ef6\u7248\u672c... +item_idquery.TITLE=\u96f6\u7ec4\u4ef6 ID +revquery.TITLE=\u7248\u672c +fabu_TITLE=TCM \u5df2\u53d1\u5e03 +wjj35_display.TITLE=\u6587\u4ef6\u5939 +czsb_display.TITLE=\u64cd\u4f5c\u5931\u8d25 +xzwjj_display.TITLE=\u9009\u62e9\u6587\u4ef6\u5939 +czcg_display.TITLE=\u64cd\u4f5c\u6210\u529f +qxzdxhzbbjxcz_display.TITLE=\u8bf7\u9009\u62e9\u5bf9\u8c61\u8fdb\u884c\u64cd\u4f5c +sxxpzyw031_display.TITLE=\u9996\u9009\u9879\u3010RB3_XMZPTYPECONFIG\u3011\u914d\u7f6e\u5f02\u5e38\uff01 +xdsb01111_display.TITLE=\u9996\u9009\u9879\u3010RB3_ProcessOPReviseAddress\u3011\u914d\u7f6e\u5f02\u5e38\uff01 \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/updataBOM/BOMManageTableBean.java b/src/com/connor/renben/process/plm/updataBOM/BOMManageTableBean.java new file mode 100644 index 0000000..59cac96 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/BOMManageTableBean.java @@ -0,0 +1,74 @@ +package com.connor.renben.process.plm.updataBOM; + +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; + +public class BOMManageTableBean { + + private String parentString; + private String childString; + private TCComponentItemRevision parentRev; + private TCComponentItemRevision childRev; + private TCComponentBOMLine parentLine; + private TCComponentBOMLine childLine; + + public BOMManageTableBean(String parentString, String childString, TCComponentItemRevision parentRev, + TCComponentItemRevision childRev, TCComponentBOMLine parentLine, TCComponentBOMLine childLine) { + super(); + this.parentString = parentString; + this.childString = childString; + this.parentRev = parentRev; + this.childRev = childRev; + this.parentLine = parentLine; + this.childLine = childLine; + } + + public String getParentString() { + return parentString; + } + + public void setParentString(String parentString) { + this.parentString = parentString; + } + + public String getChildString() { + return childString; + } + + public void setChildString(String childString) { + this.childString = childString; + } + + public TCComponentItemRevision getParentRev() { + return parentRev; + } + + public void setParentRev(TCComponentItemRevision parentRev) { + this.parentRev = parentRev; + } + + public TCComponentItemRevision getChildRev() { + return childRev; + } + + public void setChildRev(TCComponentItemRevision childRev) { + this.childRev = childRev; + } + + public TCComponentBOMLine getParentLine() { + return parentLine; + } + + public void setParentLine(TCComponentBOMLine parentLine) { + this.parentLine = parentLine; + } + + public TCComponentBOMLine getChildLine() { + return childLine; + } + + public void setChildLine(TCComponentBOMLine childLine) { + this.childLine = childLine; + } + +} diff --git a/src/com/connor/renben/process/plm/updataBOM/BOMManagementAction.java b/src/com/connor/renben/process/plm/updataBOM/BOMManagementAction.java new file mode 100644 index 0000000..84f419c --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/BOMManagementAction.java @@ -0,0 +1,29 @@ +package com.connor.renben.process.plm.updataBOM; + +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.common.actions.AbstractAIFAction; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class BOMManagementAction extends AbstractAIFAction { + + private AbstractAIFApplication app; + + public BOMManagementAction(AbstractAIFApplication arg0, String arg1) { + super(arg0, arg1); + // TODO Auto-generated constructor stub + this.app = arg0; + } + + @Override + public void run() { + // TODO Auto-generated method stub + new BOMManagementFrame(app); + } + +} diff --git a/src/com/connor/renben/process/plm/updataBOM/BOMManagementFrame.java b/src/com/connor/renben/process/plm/updataBOM/BOMManagementFrame.java new file mode 100644 index 0000000..5c1bd73 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/BOMManagementFrame.java @@ -0,0 +1,2281 @@ +package com.connor.renben.process.plm.updataBOM; + +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.Vector; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.RowSorter; +import javax.swing.filechooser.FileSystemView; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableRowSorter; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeSelectionModel; + +import com.eltima.components.ui.DatePicker; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.workflow.commands.newprocess.NewProcessCommand; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.db.Db; +import cn.hutool.db.Entity; +import cn.hutool.db.sql.Condition; + +public class BOMManagementFrame extends JFrame { + private AbstractAIFApplication app; + private TCSession session; + private CardLayout rootSwitch = new CardLayout(); + private String[] colDisplayNames = new String[] { "ѡ", "", "Ӽ", "λ", "", "״̬" }; + private String[] colDisplayNames2 = new String[] { "", "޸û", "ʱ", "" }; + private JPanel root; + private Map tableDataMap = new HashMap(); + private BOMManagementFrame $this; + private List logDataList; + private Map winMap = new HashMap(); + private TCComponentItemRevision targetRev; + private TCComponentItemRevision targetRev2; + private boolean isLogcreated = false; + private int doIndex = 0; + private boolean complate = false; + private List checkItemType = new ArrayList(); + private JButton[] topBtns; + private TCComponentBOMWindowType winType; + private int width = 1200; + private int height = 800; + private int widthOffset = 0; + private int heightOffset = 0; + private JLabel p1TargetLabel; + private JButton p1TargetBtn; + private JLabel p1ReplaceLabel; + private JButton p1ReplaceBtn; + private JLabel p1UnitLabel; + private KeyValComboBox p1UnitCombo; + private JLabel p1NumLabel; + private JTextField p1NumText; + private JCheckBox p1SelectAll; +// private JCheckBox p1SelectAllRE; + private JTable p1Table; + private JScrollPane p1jsp; + private JButton p1BottomBtn1; + private JButton p1BottomBtn2; + private JButton p1BottomBtn3; + private JButton p1BottomBtn4; + private JPanel p1Left; + private JScrollPane p1TreePanel; + private JPanel p1Right; + private JLabel p2TargetLabel; + private JButton p2TargetBtn; + private JLabel p2ChangeNumLabel; + private JTextField p2NumText; + private JCheckBox p2SelectAll; + // private JCheckBox p2SelectAllRE; + private JTable p2Table; + private JScrollPane p2jsp; + private JButton p2BottomBtn1; + private JButton p2BottomBtn2; + private JButton p2BottomBtn3; + private JButton p2BottomBtn4; + private JPanel p2Left; + private JScrollPane p2TreePanel; + private JPanel p2Right; + private JLabel p3TargetLabel; + private JButton p3TargetBtn; + private JLabel p3AddLabel; + private JButton p3AddBtn; + private JLabel p3UnitLabel; + private KeyValComboBox p3UnitCombo; + private JLabel p3NumLabel; + private JTextField p3NumText; + private JCheckBox p3SelectAll; + // private JCheckBox p3SelectAllRE; + private JTable p3Table; + private JScrollPane p3jsp; + private JButton p3BottomBtn1; + private JButton p3BottomBtn2; + private JButton p3BottomBtn3; + private JButton p3BottomBtn4; + private JPanel p3Left; + private JScrollPane p3TreePanel; + private JPanel p3Right; + private JLabel p4TargetLabel; + private JButton p4TargetBtn; + private JCheckBox p4SelectAll; + // private JCheckBox p4SelectAllRE; + private JTable p4Table; + private JScrollPane p4jsp; + private JButton p4BottomBtn1; + private JButton p4BottomBtn2; + private JButton p4BottomBtn3; + private JButton p4BottomBtn4; + private JPanel p4Left; + private JScrollPane p4TreePanel; + private JPanel p4Right; + private JLabel p5UserLabel; + private JTextField p5UserText; + private JLabel p5TimeLabel; + private DatePicker p5TimeStartText; + private JLabel toLabel; + private DatePicker p5TimeEndText; + private JLabel p5ContentLabel; + private JTextArea p5ContentText; + private JScrollPane p5Contentjsp; + private JButton p5Search; + private JComboBox p5Download; + private JTable p5Table; + private JScrollPane p5jsp; + private Map uiSize = new HashMap<>(); + private JPanel p1; + private JPanel p2; + private JPanel p3; + private JPanel p4; + private JPanel p5; + private Set addedBOMLine = new HashSet<>(); + + private List TopRev = new ArrayList(); + + public BOMManagementFrame(AbstractAIFApplication app) { + super(); + this.app = app; + this.session = (TCSession) app.getSession(); + $this = this; + String[] prefArray = JDMethodUtil.getPrefStrArray("connor_bom_check_type", session); + if (prefArray != null) { + checkItemType = Arrays.asList(prefArray); + } + TCTypeService service = session.getTypeService(); + try { + this.winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + init(); + } + + private void init() { + this.setTitle("BOM"); + this.setSize(new Dimension(1200, 800)); + this.setLayout(new BorderLayout()); + this.setResizable(true); + // this.setAlwaysOnTop(true); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.setLocationRelativeTo(null); + this.addComponentListener(new ComponentAdapter() { + @Override + public void componentResized(ComponentEvent e) { + // TODO Auto-generated method stub + super.componentResized(e); + Component comp = e.getComponent(); + $this.widthOffset = comp.getWidth() - $this.width; + $this.heightOffset = comp.getHeight() - $this.height; + if ($this.widthOffset != 0 || $this.heightOffset != 0) { + System.out.println("width===>" + comp.getWidth()); + System.out.println("height===>" + comp.getHeight()); + $this.width = comp.getWidth(); + $this.height = comp.getHeight(); + $this.resize(); + } + } + }); + this.addFocusListener(new FocusListener() { + + @Override + public void focusLost(FocusEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void focusGained(FocusEvent e) { + // TODO Auto-generated method stub + $this.setAlwaysOnTop(true); + } + }); + + Container container = this.getContentPane(); + container.setLayout(new BorderLayout()); + container.setSize(new Dimension(1200, 800)); + + TCTypeService typeService = session.getTypeService(); + Vector unitVector = new Vector(); + try { + TCComponent[] uomArray = typeService.getTypeComponent("UnitOfMeasure").extent(); + unitVector.add(new CheckBoxPo(" ", " ")); + for (TCComponent comp : uomArray) { + unitVector.add(new CheckBoxPo(comp.toString(), comp)); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // ͷ + JPanel topBtnPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + topBtns = new JButton[5]; + topBtns[0] = new JButton("滻"); + topBtns[1] = new JButton(""); + topBtns[2] = new JButton(""); + topBtns[3] = new JButton("ɾ"); + topBtns[4] = new JButton("־"); +// topBtns[5] = new JButton("԰ť"); + topBtns[0].setSelected(true); + for (JButton btn : topBtns) { + topBtnPanel.add(btn); + btn.addActionListener(panelSwitch()); + } + container.add(topBtnPanel, BorderLayout.NORTH); + + // root + root = new JPanel(rootSwitch); + + // 滻 + p1 = new JPanel(); + p1.setLayout(null); + + // 滻 + p1Left = new JPanel(); + p1Left.setLayout(null); + p1Left.setBounds(0, 0, 800, 800); + p1Left.setBorder(BorderFactory.createEtchedBorder()); + + p1TargetLabel = new JLabel("Ŀϱ"); + p1TargetLabel.setBounds(20, 20, 100, 25); + p1TargetBtn = new JButton(); + p1TargetBtn.setBounds(130, 20, 400, 25); + p1ReplaceLabel = new JLabel("滻ϱ"); + p1ReplaceLabel.setBounds(20, 60, 100, 25); + p1ReplaceBtn = new JButton(); + p1ReplaceBtn.setBounds(130, 60, 400, 25); + p1UnitLabel = new JLabel("λ"); + p1UnitLabel.setBounds(560, 60, 50, 25); + p1UnitCombo = new KeyValComboBox(unitVector); + p1UnitCombo.setBounds(610, 60, 50, 25); + p1NumLabel = new JLabel(""); + p1NumLabel.setBounds(680, 60, 50, 25); + p1NumText = new JTextField(); + p1NumText.setBounds(730, 60, 50, 25); + p1SelectAll = new JCheckBox("ȫѡ"); + p1SelectAll.setBounds(20, 100, 100, 25); +// p1SelectAllRE = new JCheckBox("ȫѡѷ"); +// p1SelectAllRE.setBounds(20, 100, 120, 25); + DefaultTableModel p1model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + if (paramInt2 == 0) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p1Table = new JTable(p1model); + p1Table.getColumnModel().getColumn(0).setMinWidth(60); + p1Table.getColumnModel().getColumn(0).setMaxWidth(60); + p1Table.getColumnModel().getColumn(1).setMinWidth(200); + p1Table.getColumnModel().getColumn(2).setMinWidth(200); + p1Table.getColumnModel().getColumn(3).setMinWidth(100); + p1Table.getColumnModel().getColumn(4).setMinWidth(100); + p1Table.getColumnModel().getColumn(5).setMinWidth(100); + p1Table.getColumnModel().getColumn(0).setCellRenderer(new MyCellRenderer()); + p1Table.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor4(new JTextField())); + p1Table.setRowHeight(25); + p1Table.setAutoscrolls(true); + p1Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p1Table.getTableHeader().setReorderingAllowed(false); + p1Table.putClientProperty("terminateEditOnFocusLost", true); + RowSorter p1sorter = new TableRowSorter(p1model); + p1Table.setRowSorter(p1sorter); + p1jsp = new JScrollPane(p1Table); + p1jsp.setBounds(20, 130, 760, 500); + + p1BottomBtn1 = new JButton(""); + p1BottomBtn1.setBounds(80, 650, 100, 25); + p1BottomBtn2 = new JButton("滻"); + p1BottomBtn2.setBounds(260, 650, 100, 25); + p1BottomBtn3 = new JButton(""); + p1BottomBtn3.setBounds(440, 650, 100, 25); + p1BottomBtn4 = new JButton("ȡ"); + p1BottomBtn4.setBounds(620, 650, 100, 25); + + p1Left.add(p1TargetLabel); + p1Left.add(p1TargetBtn); + p1Left.add(p1ReplaceLabel); + p1Left.add(p1ReplaceBtn); + p1Left.add(p1UnitLabel); + p1Left.add(p1UnitCombo); + p1Left.add(p1NumLabel); + p1Left.add(p1NumText); + p1Left.add(p1SelectAll); + // p1Left.add(p1SelectAllRE); + p1Left.add(p1jsp); + p1Left.add(p1BottomBtn1); + p1Left.add(p1BottomBtn2); + p1Left.add(p1BottomBtn3); + p1Left.add(p1BottomBtn4); + + // 滻ұ + p1Right = new JPanel(); + p1Right.setLayout(null); + p1Right.setBounds(800, 0, 400, 800); + p1Right.setBorder(BorderFactory.createEtchedBorder()); + + p1TreePanel = new JScrollPane(); + p1TreePanel.setBounds(20, 130, 360, 500); + p1Right.add(p1TreePanel); + + // ¼ + p1SelectAll.addItemListener(selectAll(p1Table)); +// p1SelectAllRE.addItemListener(selectAllRE(p1Table)); + p1Table.addMouseListener(showTree(p1Right)); + p1BottomBtn4.addActionListener(cancel()); + p1BottomBtn1.addActionListener(batchRevise(p1Table, p1SelectAll)); + p1BottomBtn2.addActionListener(batchReplace()); + p1BottomBtn3.addActionListener(startWorkFlow(p1Table)); + p1TargetBtn.addActionListener(clickSearch(p1Table, p1SelectAll)); + p1ReplaceBtn.addActionListener(clickSearch(null, null)); + + p1.add(p1Left); + p1.add(p1Right); + + // + p2 = new JPanel(); + p2.setLayout(null); + + // + p2Left = new JPanel(); + p2Left.setLayout(null); + p2Left.setBounds(0, 0, 800, 800); + p2Left.setBorder(BorderFactory.createEtchedBorder()); + + p2TargetLabel = new JLabel("Ŀϱ"); + p2TargetLabel.setBounds(20, 20, 100, 25); + p2TargetBtn = new JButton(); + p2TargetBtn.setBounds(130, 20, 400, 25); + p2ChangeNumLabel = new JLabel(""); + p2ChangeNumLabel.setBounds(20, 60, 100, 25); + p2NumText = new JTextField(); + p2NumText.setBounds(130, 60, 50, 25); + + p2SelectAll = new JCheckBox("ȫѡ"); + p2SelectAll.setBounds(20, 100, 100, 25); +// p2SelectAllRE = new JCheckBox("ȫѡѷ"); +// p2SelectAllRE.setBounds(20, 100, 120, 25); + DefaultTableModel p2model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + if (paramInt2 == 0) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p2Table = new JTable(p2model); + p2Table.getColumnModel().getColumn(0).setMinWidth(60); + p2Table.getColumnModel().getColumn(0).setMaxWidth(60); + p2Table.getColumnModel().getColumn(1).setMinWidth(200); + p2Table.getColumnModel().getColumn(2).setMinWidth(200); + p2Table.getColumnModel().getColumn(3).setMinWidth(100); + p2Table.getColumnModel().getColumn(4).setMinWidth(100); + p2Table.getColumnModel().getColumn(5).setMinWidth(100); + p2Table.getColumnModel().getColumn(0).setCellRenderer(new MyCellRenderer()); + p2Table.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor4(new JTextField())); + p2Table.setRowHeight(25); + p2Table.setAutoscrolls(true); + p2Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p2Table.getTableHeader().setReorderingAllowed(false); + p2Table.putClientProperty("terminateEditOnFocusLost", true); + RowSorter p2sorter = new TableRowSorter(p2model); + p2Table.setRowSorter(p2sorter); + p2jsp = new JScrollPane(p2Table); + p2jsp.setBounds(20, 130, 760, 500); + + p2BottomBtn1 = new JButton(""); + p2BottomBtn1.setBounds(80, 650, 100, 25); + p2BottomBtn2 = new JButton(""); + p2BottomBtn2.setBounds(260, 650, 100, 25); + p2BottomBtn3 = new JButton(""); + p2BottomBtn3.setBounds(440, 650, 100, 25); + p2BottomBtn4 = new JButton("ȡ"); + p2BottomBtn4.setBounds(620, 650, 100, 25); + + p2Left.add(p2TargetLabel); + p2Left.add(p2TargetBtn); + p2Left.add(p2ChangeNumLabel); + p2Left.add(p2NumText); + p2Left.add(p2SelectAll); + // p2Left.add(p2SelectAllRE); + p2Left.add(p2jsp); + p2Left.add(p2BottomBtn1); + p2Left.add(p2BottomBtn2); + p2Left.add(p2BottomBtn3); + p2Left.add(p2BottomBtn4); + + // ұ + p2Right = new JPanel(); + p2Right.setLayout(null); + p2Right.setBounds(800, 0, 400, 800); + p2Right.setBorder(BorderFactory.createEtchedBorder()); + + p2TreePanel = new JScrollPane(); + p2TreePanel.setBounds(20, 130, 360, 500); + p2Right.add(p2TreePanel); + + // ¼ + p2SelectAll.addItemListener(selectAll(p2Table)); + // p2SelectAllRE.addItemListener(selectAllRE(p2Table)); + p2Table.addMouseListener(showTree(p2Right)); + p2BottomBtn4.addActionListener(cancel()); + p2BottomBtn1.addActionListener(batchRevise(p2Table, p2SelectAll)); + p2BottomBtn2.addActionListener(batchModify()); + p2BottomBtn3.addActionListener(startWorkFlow(p2Table)); + p2TargetBtn.addActionListener(clickSearch(p2Table, p2SelectAll)); + + p2.add(p2Left); + p2.add(p2Right); + + // + p3 = new JPanel(); + p3.setLayout(null); + + // + p3Left = new JPanel(); + p3Left.setLayout(null); + p3Left.setBounds(0, 0, 800, 800); + p3Left.setBorder(BorderFactory.createEtchedBorder()); + + p3TargetLabel = new JLabel("οϱ"); + p3TargetLabel.setBounds(20, 20, 100, 25); + p3TargetBtn = new JButton(); + p3TargetBtn.setBounds(130, 20, 400, 25); + p3AddLabel = new JLabel("ϱ"); + p3AddLabel.setBounds(20, 60, 100, 25); + p3AddBtn = new JButton(); + p3AddBtn.setBounds(130, 60, 400, 25); + p3UnitLabel = new JLabel("λ"); + p3UnitLabel.setBounds(560, 60, 50, 25); + p3UnitCombo = new KeyValComboBox(unitVector); + p3UnitCombo.setBounds(610, 60, 50, 25); + p3NumLabel = new JLabel(""); + p3NumLabel.setBounds(680, 60, 50, 25); + p3NumText = new JTextField(); + p3NumText.setBounds(730, 60, 50, 25); + + p3SelectAll = new JCheckBox("ȫѡ"); + p3SelectAll.setBounds(20, 100, 100, 25); +// p3SelectAllRE = new JCheckBox("ȫѡѷ"); +// p3SelectAllRE.setBounds(20, 100, 120, 25); + DefaultTableModel p3model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + if (paramInt2 == 0) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p3Table = new JTable(p3model); + p3Table.getColumnModel().getColumn(0).setMinWidth(60); + p3Table.getColumnModel().getColumn(0).setMaxWidth(60); + p3Table.getColumnModel().getColumn(1).setMinWidth(200); + p3Table.getColumnModel().getColumn(2).setMinWidth(200); + p3Table.getColumnModel().getColumn(3).setMinWidth(100); + p3Table.getColumnModel().getColumn(4).setMinWidth(100); + p3Table.getColumnModel().getColumn(5).setMinWidth(100); + p3Table.getColumnModel().getColumn(0).setCellRenderer(new MyCellRenderer()); + p3Table.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor4(new JTextField())); + p3Table.setRowHeight(25); + p3Table.setAutoscrolls(true); + p3Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p3Table.getTableHeader().setReorderingAllowed(false); + p3Table.putClientProperty("terminateEditOnFocusLost", true); + RowSorter p3sorter = new TableRowSorter(p3model); + p3Table.setRowSorter(p3sorter); + p3jsp = new JScrollPane(p3Table); + p3jsp.setBounds(20, 130, 760, 500); + + p3BottomBtn1 = new JButton(""); + p3BottomBtn1.setBounds(80, 650, 100, 25); + p3BottomBtn2 = new JButton(""); + p3BottomBtn2.setBounds(260, 650, 100, 25); + p3BottomBtn3 = new JButton(""); + p3BottomBtn3.setBounds(440, 650, 100, 25); + p3BottomBtn4 = new JButton("ȡ"); + p3BottomBtn4.setBounds(620, 650, 100, 25); + + p3Left.add(p3TargetLabel); + p3Left.add(p3TargetBtn); + p3Left.add(p3AddLabel); + p3Left.add(p3AddBtn); + p3Left.add(p3UnitLabel); + p3Left.add(p3UnitCombo); + p3Left.add(p3NumLabel); + p3Left.add(p3NumText); + p3Left.add(p3SelectAll); +// p3Left.add(p3SelectAllRE); + p3Left.add(p3jsp); + p3Left.add(p3BottomBtn1); + p3Left.add(p3BottomBtn2); + p3Left.add(p3BottomBtn3); + p3Left.add(p3BottomBtn4); + + // ұ + p3Right = new JPanel(); + p3Right.setLayout(null); + p3Right.setBounds(800, 0, 400, 800); + p3Right.setBorder(BorderFactory.createEtchedBorder()); + + p3TreePanel = new JScrollPane(); + p3TreePanel.setBounds(20, 130, 360, 500); + p3Right.add(p3TreePanel); + + // ¼ + p3SelectAll.addItemListener(selectAll(p3Table)); +// p3SelectAllRE.addItemListener(selectAllRE(p3Table)); + p3Table.addMouseListener(showTree(p3Right)); + p3BottomBtn4.addActionListener(cancel()); + p3BottomBtn1.addActionListener(batchRevise(p3Table, p3SelectAll)); + p3BottomBtn2.addActionListener(batchAdd()); + p3BottomBtn3.addActionListener(startWorkFlow(p3Table)); + p3TargetBtn.addActionListener(clickSearch(p3Table, p3SelectAll)); + p3AddBtn.addActionListener(clickSearch(null, null)); + + p3.add(p3Left); + p3.add(p3Right); + + // ɾ + p4 = new JPanel(); + p4.setLayout(null); + + // ɾ + p4Left = new JPanel(); + p4Left.setLayout(null); + p4Left.setBounds(0, 0, 800, 800); + p4Left.setBorder(BorderFactory.createEtchedBorder()); + + p4TargetLabel = new JLabel("Ŀϱ"); + p4TargetLabel.setBounds(20, 20, 100, 25); + p4TargetBtn = new JButton(); + p4TargetBtn.setBounds(130, 20, 400, 25); + + p4SelectAll = new JCheckBox("ȫѡ"); + p4SelectAll.setBounds(20, 100, 100, 25); +// p4SelectAllRE = new JCheckBox("ȫѡѷ"); +// p4SelectAllRE.setBounds(20, 100, 120, 25); + DefaultTableModel p4model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + if (paramInt2 == 0) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p4Table = new JTable(p4model); + p4Table.getColumnModel().getColumn(0).setMinWidth(60); + p4Table.getColumnModel().getColumn(0).setMaxWidth(60); + p4Table.getColumnModel().getColumn(1).setMinWidth(200); + p4Table.getColumnModel().getColumn(2).setMinWidth(200); + p4Table.getColumnModel().getColumn(3).setMinWidth(100); + p4Table.getColumnModel().getColumn(4).setMinWidth(100); + p4Table.getColumnModel().getColumn(5).setMinWidth(100); + p4Table.getColumnModel().getColumn(0).setCellRenderer(new MyCellRenderer()); + p4Table.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor4(new JTextField())); + p4Table.setRowHeight(25); + p4Table.setAutoscrolls(true); + p4Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p4Table.getTableHeader().setReorderingAllowed(false); + p4Table.putClientProperty("terminateEditOnFocusLost", true); + RowSorter p4sorter = new TableRowSorter(p4model); + p4Table.setRowSorter(p4sorter); + p4jsp = new JScrollPane(p4Table); + p4jsp.setBounds(20, 130, 760, 500); + + p4BottomBtn1 = new JButton(""); + p4BottomBtn1.setBounds(80, 650, 100, 25); + p4BottomBtn2 = new JButton("ɾ"); + p4BottomBtn2.setBounds(260, 650, 100, 25); + p4BottomBtn3 = new JButton(""); + p4BottomBtn3.setBounds(440, 650, 100, 25); + p4BottomBtn4 = new JButton("ȡ"); + p4BottomBtn4.setBounds(620, 650, 100, 25); + + p4Left.add(p4TargetLabel); + p4Left.add(p4TargetBtn); + p4Left.add(p4SelectAll); +// p4Left.add(p4SelectAllRE); + p4Left.add(p4jsp); + p4Left.add(p4BottomBtn1); + p4Left.add(p4BottomBtn2); + p4Left.add(p4BottomBtn3); + p4Left.add(p4BottomBtn4); + + // ұ + p4Right = new JPanel(); + p4Right.setLayout(null); + p4Right.setBounds(800, 0, 400, 800); + p4Right.setBorder(BorderFactory.createEtchedBorder()); + + p4TreePanel = new JScrollPane(); + p4TreePanel.setBounds(20, 130, 360, 500); + p4Right.add(p4TreePanel); + + // ¼ + p4SelectAll.addItemListener(selectAll(p4Table)); +// p4SelectAllRE.addItemListener(selectAllRE(p4Table)); + p4Table.addMouseListener(showTree(p4Right)); + p4BottomBtn4.addActionListener(cancel()); + p4BottomBtn1.addActionListener(batchRevise(p4Table, p4SelectAll)); + p4BottomBtn2.addActionListener(batchRemove()); + p4BottomBtn3.addActionListener(startWorkFlow(p4Table)); + p4TargetBtn.addActionListener(clickSearch(p4Table, p4SelectAll)); + + p4.add(p4Left); + p4.add(p4Right); + + // ־ + p5 = new JPanel(); + p5.setLayout(null); + + p5UserLabel = new JLabel("޸û"); + p5UserLabel.setBounds(20, 40, 70, 25); + p5UserText = new JTextField(); + p5UserText.setBounds(100, 40, 150, 25); + p5TimeLabel = new JLabel("޸ʱ"); + p5TimeLabel.setBounds(300, 40, 70, 25); + p5TimeStartText = DatePickerUtil.getDatePicker(null); + p5TimeStartText.setBounds(380, 40, 100, 25); + toLabel = new JLabel(""); + toLabel.setBounds(490, 40, 20, 25); + p5TimeEndText = DatePickerUtil.getDatePicker(null); + p5TimeEndText.setBounds(520, 40, 100, 25); + p5ContentLabel = new JLabel("޸"); + p5ContentLabel.setBounds(670, 40, 70, 25); + p5ContentText = new JTextArea(); + p5ContentText.setLineWrap(true); + p5ContentText.setWrapStyleWord(true); + p5Contentjsp = new JScrollPane(p5ContentText); + p5Contentjsp.setBounds(750, 20, 200, 80); + p5Search = new JButton(""); + p5Search.setBounds(1000, 40, 60, 25); + p5Download = new JComboBox(); + p5Download.addItem("־"); + p5Download.addItem("Ϊtxt"); + p5Download.addItem("Ϊexcel"); + p5Download.setSelectedItem("־"); + p5Download.setBounds(1080, 40, 100, 25); + + DefaultTableModel p5model = new DefaultTableModel(colDisplayNames2, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p5Table = new JTable(p5model); + p5Table.getColumnModel().getColumn(0).setMinWidth(60); + p5Table.getColumnModel().getColumn(0).setMaxWidth(60); + p5Table.getColumnModel().getColumn(1).setMinWidth(200); + p5Table.getColumnModel().getColumn(2).setMinWidth(200); + p5Table.getColumnModel().getColumn(3).setMinWidth(700); + p5Table.setRowHeight(25); + p5Table.setAutoscrolls(true); + p5Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p5Table.getTableHeader().setReorderingAllowed(false); + RowSorter p5sorter = new TableRowSorter(p5model); + p5Table.setRowSorter(p5sorter); + p5jsp = new JScrollPane(p5Table); + p5jsp.setBounds(20, 130, 1160, 580); + + // ¼ + p5Search.addActionListener(searchLog()); + p5Download.addItemListener(downloadLog(p5Table)); + p5UserText.addKeyListener(logSearchEnter()); + p5TimeStartText.addKeyListener(logSearchEnter()); + p5TimeEndText.addKeyListener(logSearchEnter()); + + p5.add(p5UserLabel); + p5.add(p5UserText); + p5.add(p5TimeLabel); + p5.add(p5TimeStartText); + p5.add(toLabel); + p5.add(p5TimeEndText); + p5.add(p5ContentLabel); + p5.add(p5Contentjsp); + p5.add(p5Search); + p5.add(p5Download); + p5.add(p5jsp); + + root.add("batchReplace", p1); + root.add("batchModify", p2); + root.add("batchAdd", p3); + root.add("batchRemove", p4); + root.add("updateLog", p5); + + rootSwitch.show(root, "batchReplace"); + container.add(root, BorderLayout.CENTER); + this.setVisible(true); + } + + private ActionListener panelSwitch() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String text = ((JButton) e.getSource()).getText(); + for (int i = 0; i < topBtns.length; i++) { + topBtns[i].setSelected(topBtns[i].getText().equals(text)); + } + switch (text) { + case "滻": + clearTable(p1Table, p1SelectAll); + p1Right.removeAll(); + JScrollPane panel1 = new JScrollPane(); + panel1.setBounds(p1TreePanel.getX(), p1TreePanel.getY(), p1TreePanel.getWidth(), + p1TreePanel.getHeight()); + p1TreePanel = panel1; + p1Right.add(panel1); + p1Right.revalidate(); + p1Right.repaint(); + rootSwitch.show(root, "batchReplace"); + break; + case "": + clearTable(p2Table, p2SelectAll); + p2Right.removeAll(); + JScrollPane panel2 = new JScrollPane(); + panel2.setBounds(p2TreePanel.getX(), p2TreePanel.getY(), p2TreePanel.getWidth(), + p2TreePanel.getHeight()); + p2TreePanel = panel2; + p2Right.add(panel2); + p2Right.revalidate(); + p2Right.repaint(); + rootSwitch.show(root, "batchModify"); + break; + case "": + clearTable(p3Table, p3SelectAll); + p3Right.removeAll(); + JScrollPane panel3 = new JScrollPane(); + panel3.setBounds(p3TreePanel.getX(), p3TreePanel.getY(), p3TreePanel.getWidth(), + p3TreePanel.getHeight()); + p3TreePanel = panel3; + p3Right.add(panel3); + p3Right.revalidate(); + p3Right.repaint(); + rootSwitch.show(root, "batchAdd"); + break; + case "ɾ": + clearTable(p4Table, p4SelectAll); + p4Right.removeAll(); + JScrollPane panel4 = new JScrollPane(); + panel4.setBounds(p4TreePanel.getX(), p4TreePanel.getY(), p4TreePanel.getWidth(), + p4TreePanel.getHeight()); + p4TreePanel = panel4; + p4Right.add(panel4); + p4Right.revalidate(); + p4Right.repaint(); + rootSwitch.show(root, "batchRemove"); + break; + case "־": + createLogDataSourceTable(); + clearTable(p5Table, null); + rootSwitch.show(root, "updateLog"); + break; + default: +// createLogDataSourceTable(); + } + } + }; + } + + private void showWhereUesd(JTable table, JCheckBox selectAll) { + DefaultTableModel model = (DefaultTableModel) table.getModel(); + // TODO Auto-generated method stub + clearTable(table, selectAll); + if (table == null || targetRev == null) { + return; + } + long startTime = System.currentTimeMillis(); + List tableDataList = new ArrayList(); + try { + String revString = targetRev.getProperty("object_string"); + TCComponent[] usedComps = targetRev.whereUsed((short) 0); + System.out.println("װ======>" + usedComps.length); + + tableDataMap.clear(); +// Map usedMap = usedFilter(usedComps); +// for (Entry entry : usedMap.entrySet()) { + for (TCComponentItemRevision parentRev : usedFilter(usedComps)) { +// TCComponentItemRevision parentRev = entry.getValue(); + String parentString = parentRev.getProperty("object_string"); + TCComponent[] statusArray = parentRev.getRelatedComponents("release_status_list"); + String status = ""; + if (statusArray != null && statusArray.length > 0) { + status = statusArray[statusArray.length - 1].getProperty("object_name"); + } + TCComponentBOMWindow win = winType.create(null); + TCComponentBOMLine topLine = win.setWindowTopLine(parentRev.getItem(), parentRev, null, null); + winMap.put(parentString, win); + AIFComponentContext[] aifs = topLine.getChildren(); + for (AIFComponentContext aif : aifs) { + TCComponentBOMLine child = (TCComponentBOMLine) aif.getComponent(); + if (revString.equals(child.getItemRevision().getProperty("object_string"))) { + + String unit = child.getProperty("bl_uom"); + String num = child.getProperty("bl_quantity"); + + Object[] rowData = new Object[] { new JCheckBox(), parentString, revString, unit, num, status }; + rowPrint(rowData); + tableDataList.add(rowData); + tableDataMap.put(parentString, + new BOMManageTableBean(parentString, revString, parentRev, targetRev, topLine, child)); + // TODO bomһchildܻ쳣ֻӰһ + break; + } + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + if (tableDataList == null || tableDataList.size() == 0) { + JOptionPane.showMessageDialog($this, "ҵӦ汾ð汾ûκװװð汾ľ°汾ȷϱǷȷ", "ʾ", + JOptionPane.WARNING_MESSAGE); + return; + } + + for (Object[] rowData : tableDataList) { + model.addRow(rowData); + } + table.revalidate(); + table.repaint(); + System.out.println("װʾɣʱ" + (System.currentTimeMillis() - startTime) + "ms"); + } + + // ++++ + // private MouseAdapter showTree(JPanel panelRight) { + // ++++ + private MouseAdapter showTree(final JPanel panelRight) { + return new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { + JTable table = (JTable) e.getSource(); + String parentString = table.getValueAt(table.getSelectedRow(), 1).toString(); + System.out.println("select row=====>" + table.getSelectedRow()); + System.out.println("parentName=====>" + parentString); + CustomLovBean lovBean = null; + try { + lovBean = new CustomLovBean(tableDataMap.get(parentString).getChildString()); + CustomLovBean subBean = new CustomLovBean(parentString); + lovBean.addSub(subBean); + getTreeData(tableDataMap.get(parentString).getParentRev(), subBean); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + panelRight.removeAll(); + JTree tree = createTree(lovBean); + JScrollPane treePanel = new JScrollPane(tree); + treePanel.setBounds(20, 130, 360, 500); + panelRight.add(treePanel); + panelRight.revalidate(); + panelRight.repaint(); + } + } + }; + } + + private void getTreeData(TCComponent rev, CustomLovBean lov) throws TCException { + TCComponent[] comps = rev.whereUsed((short) 0); + if (comps == null || comps.length == 0) { + return; + } + for (TCComponent comp : comps) { + CustomLovBean sub = new CustomLovBean(comp.getProperty("object_string")); + System.out.println(sub.displayName); + lov.addSub(sub); + getTreeData(comp, sub); + } + } + + private void getTopBom(TCComponent rev) throws TCException { + TCComponent[] comps = rev.whereUsed((short) 0); + if (comps == null || comps.length == 0) { + if (!TopRev.contains((TCComponentItemRevision) rev)) { + TopRev.add((TCComponentItemRevision) rev); + } + return; + } else { + for (TCComponent comp : comps) { + getTopBom(comp); + } + } + } + + private void clearTable(JTable table, JCheckBox selectAll) { + DefaultTableModel model = (DefaultTableModel) table.getModel(); + int cnt = model.getRowCount(); + for (int i = 0; i < cnt; i++) { + model.removeRow(0); + } + table.revalidate(); + table.repaint(); + if (selectAll != null) { + selectAll.setSelected(false); + } + tableDataMap.clear(); + addedBOMLine.clear(); + try { + closeWin(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private JTree createTree(CustomLovBean lovData) { + if (lovData == null || "".equals(lovData.displayName)) { + return new JTree(); + } + DefaultMutableTreeNode root = new DefaultMutableTreeNode(lovData.displayName); + DefaultMutableTreeNode parent = root; + DefaultTreeModel treeModel = new DefaultTreeModel(root); + + initTree(lovData, parent, treeModel); + + JTree tree = new JTree(treeModel); + tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); + DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) tree.getCellRenderer(); + cellRenderer.setTextNonSelectionColor(Color.black); + cellRenderer.setTextSelectionColor(Color.blue); + return tree; + } + + private void initTree(CustomLovBean lovData, DefaultMutableTreeNode parent, DefaultTreeModel treeModel) { + if (!lovData.hasChild()) { + return; + } + List subList = lovData.getSub(); + for (CustomLovBean sub : subList) { + DefaultMutableTreeNode temp = new DefaultMutableTreeNode(sub.displayName); + treeModel.insertNodeInto(temp, parent, parent.getChildCount()); + initTree(sub, temp, treeModel); + } + } + + // ++++ + // private ItemListener selectAll(JTable table) { + // ++++ + private ItemListener selectAll(final JTable table) { + return new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + // TODO Auto-generated method stub + boolean select = ((JCheckBox) e.getSource()).isSelected(); + int option = JOptionPane.showOptionDialog(null, "Ƿֻѡѷġ", "ѡ", 0, 1, null, null, + Integer.valueOf(0)); + if (option == 0) { + for (int i = 0; i < table.getRowCount(); i++) { + if (table.getValueAt(i, 5) != null && !table.getValueAt(i, 5).equals("")) { + JCheckBox checkBox = (JCheckBox) table.getValueAt(i, 0); + checkBox.setSelected(select); + table.revalidate(); + table.repaint(); + } + } + System.out.println("0"); + return; + } else if (option == 1) { + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox checkBox = (JCheckBox) table.getValueAt(i, 0); + checkBox.setSelected(select); + table.revalidate(); + table.repaint(); + + } + System.out.println("1"); + return; + } + + } + }; + } + +// //+++ȫѡѷ +// private ItemListener selectAllRE(final JTable table) { +// return new ItemListener() { +// +// @Override +// public void itemStateChanged(ItemEvent e) { +// System.out.println("ȫѡѷ"); +// // TODO Auto-generated method stub +// boolean select = ((JCheckBox) e.getSource()).isSelected(); +// for (int i = 0; i < table.getRowCount(); i++) { +// if(table.getValueAt(i, 5)!=null&&!table.getValueAt(i, 5).equals("")) { +// JCheckBox checkBox = (JCheckBox) table.getValueAt(i, 0); +// checkBox.setSelected(select); +// table.revalidate(); +// table.repaint(); +// } +// } +// } +// }; +// } +// //+++ + + private ActionListener cancel() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + $this.dispose(); + } + }; + } + + private ActionListener batchRevise(final JTable table, final JCheckBox selectAll) {// ++++final + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + List selectedRowList = getselectedRow(table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkAccess(selectedRowList).isRes()) { + return; + } + List msgData = new ArrayList(); + for (int i = 0; i < selectedRowList.size(); i++) { + try { + TCComponentItemRevision newRev = selectedRowList.get(i).getParentRev().saveAs(null); + String parentString = newRev.getProperty("object_string"); + selectedRowList.get(i).setParentRev(newRev); + selectedRowList.get(i).setParentString(parentString); + msgData.add(new String[] { msgData.size() + 1 + "", selectedRowList.get(i).getParentString(), + newRev.getProperty("object_string"), "ɹ" }); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); +// JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + msgData.add(new String[] { msgData.size() + 1 + "", selectedRowList.get(i).getParentString(), + "", "ʧܣ" + e1.getMessage() }); + } + } + +// showWhereUesd(table, selectAll); + updateSelectedRow(table, selectedRowList); + JScrollPane jsp = DialogUtil.createTableMsg(new String[] { "", "汾(ǰ)", "汾()", "" }, + msgData).panel; + JOptionPane.showMessageDialog($this, jsp, "", JOptionPane.PLAIN_MESSAGE); + } + }; + } + + private List usedFilter(TCComponent[] comps) throws TCException { +// Map sameParentUsedMap = new HashMap(); + List list = new ArrayList<>(); + for (TCComponent comp : comps) { + if (comp instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) comp; +// String itemId; +// if (sameParentUsedMap.containsKey(itemId = comp.getProperty("item_id"))) { +// if (sameParentUsedMap.get(itemId).getProperty("item_revision_id") +// .compareTo(comp.getProperty("item_revision_id")) < 0) { +// sameParentUsedMap.put(itemId, rev); +// } +// } else { + if (rev.getItem().getLatestItemRevision().getUid().equals(rev.getUid())) { + list.add(rev); + } +// sameParentUsedMap.put(itemId, rev); +// } + } + } + return list; + } + + private void createLogDataSourceTable() { + if (isLogcreated) { + return; + } + String sql1 = "CREATE TABLE JD2_BOMManageLog ( id NUMBER ( 38, 0 ) primary key, modify_user VARCHAR2 ( 200 ), modify_time DATE, modify_content VARCHAR2 ( 500 ))"; + String sql2 = "CREATE sequence JD2_BOMManageLog_seq minvalue 1 maxvalue 99999999 INCREMENT BY 1 START WITH 1"; + String sql3 = "CREATE OR REPLACE TRIGGER JD2_BOMManageLog_tri before INSERT ON JD2_BOMManageLog FOR each ROW BEGIN SELECT JD2_BOMManageLog_seq.nextval INTO : new.id FROM dual; END;"; + try { + List temp = null; + temp = Db.use(DBUtil.getDataSource(session)).findBy("user_tables", + new Condition("table_name", "JD2_BOMMANAGELOG")); + if (temp == null || temp.size() == 0) { + Db.use(DBUtil.getDataSource(session)).execute(sql1); + System.out.println("JD2_BOMMANAGELOG create success"); + } + temp = null; + temp = Db.use(DBUtil.getDataSource(session)).findBy("user_sequences", + new Condition("sequence_name", "JD2_BOMMANAGELOG_SEQ")); + if (temp == null || temp.size() == 0) { + Db.use(DBUtil.getDataSource(session)).execute(sql2); + System.out.println("JD2_BOMMANAGELOG_SEQ create success"); + } + temp = null; + temp = Db.use(DBUtil.getDataSource(session)).findBy("all_triggers", + new Condition("trigger_name", "JD2_BOMMANAGELOG_TRI")); + if (temp == null || temp.size() == 0) { + DBConnectionUtil.dbConn(session).createStatement().execute(sql3); + System.out.println("JD2_BOMManageLog_tri create success"); + } + isLogcreated = true; + System.out.println("init log success"); + } catch (Exception e) { + // TODO Auto-generated catch block + JOptionPane.showMessageDialog($this, "ݿʧܣѡrb_db_settings", "", JOptionPane.ERROR_MESSAGE); + e.printStackTrace(); + } + } + + private ActionListener searchLog() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String username = p5UserText.getText().trim(); + String content = p5ContentText.getText(); + if (username == null || "".equals(username)) { + return; + } + + String sql = "select * from JD2_BOMMANAGELOG where "; + if (!"*".equals(username)) { + sql += "modify_user like '%" + username + "%' and"; + } + sql += " modify_time between to_date('" + p5TimeStartText.getText() + + " 00:00:00','yyyy-MM-dd hh24:mi:ss') and to_date('" + p5TimeEndText.getText() + + " 23:59:59','yyyy-MM-dd hh24:mi:ss')"; + if (content != null && !"".equals(content)) { + sql += " and modify_content like '%" + content + "%'"; + } + sql += "order by MODIFY_TIME asc"; + System.out.println(sql); + try { + logDataList = Db.use(DBUtil.getDataSource(session)).query(sql); + System.out.println("log size=====>" + logDataList.size()); + DefaultTableModel model = (DefaultTableModel) p5Table.getModel(); + for (Entity entity : logDataList) { + Object[] objArr = new Object[] { entity.get("ID"), entity.get("MODIFY_USER"), + entity.get("MODIFY_TIME"), entity.get("MODIFY_CONTENT") }; + model.addRow(objArr); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + return; + } + p5Table.revalidate(); + p5Table.repaint(); + } + }; + } + + private ItemListener downloadLog(final JTable table) {// ++++final + return new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent paramItemEvent) { + // TODO Auto-generated method stub + if (paramItemEvent.getStateChange() == ItemEvent.DESELECTED) { + return; + } + String selectItem = ((JComboBox) paramItemEvent.getSource()).getSelectedItem().toString(); + System.out.println(selectItem); + if (!selectItem.contains("txt") && !selectItem.contains("excel")) { + return; + } + if (table.getRowCount() > 0) { + JFileChooser chooser = new JFileChooser(); + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + chooser.setMultiSelectionEnabled(false); + chooser.setCurrentDirectory(FileSystemView.getFileSystemView().getHomeDirectory()); + chooser.showOpenDialog($this); + File folder = chooser.getSelectedFile(); + if (folder == null) { + p5Download.setSelectedItem("־"); + return; + } + String fileName = ""; + if (selectItem.contains("txt")) { + FileWriter fileWriter = null; + fileName = "BOM־-" + new SimpleDateFormat("yyyyMMddHHmm").format(new Date()) + ".txt"; + try { + fileWriter = new FileWriter(folder.getPath() + File.separator + fileName);// ıļ + String temp; + System.out.println(logDataList.size()); + for (Entity entity : logDataList) { + fileWriter.write((temp = entity.get("ID").toString()) + + StringCreateUtil.createBlank(10 - temp.length()) + + (temp = entity.get("MODIFY_USER").toString()) + + StringCreateUtil.createBlank(20 - temp.length()) + + (temp = entity.get("MODIFY_TIME").toString()) + + StringCreateUtil.createBlank(30 - temp.length()) + + entity.get("MODIFY_CONTENT").toString() + "\r\n"); + } + fileWriter.flush(); + fileWriter.close(); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + return; + } + } else { + fileName = "BOM־-" + new SimpleDateFormat("yyyyMMddHHmm").format(new Date()) + ".xlsx"; + String[] header = new String[] { "", "޸û", "ʱ", "" }; + List data = new ArrayList<>(); + System.out.println(logDataList.size()); + for (Entity entity : logDataList) { + data.add(new String[] { entity.get("ID").toString(), entity.get("MODIFY_USER").toString(), + entity.get("MODIFY_TIME").toString(), entity.get("MODIFY_CONTENT").toString() }); + } + SimpleExcelUtil.exportExcel(folder.getPath() + File.separator + fileName, header, data); + + } + + JOptionPane.showMessageDialog($this, "־ɹ\r\n·" + folder + File.separator + fileName, "ʾ", + JOptionPane.WARNING_MESSAGE); + p5Download.setSelectedItem("־"); + } + } + }; + + } + + private ActionListener batchReplace() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String numStr = p1NumText.getText().trim(); + String text = p1UnitCombo.getSelectedText().trim(); + Object value = p1UnitCombo.getSelectedValue(); + System.out.println(numStr); + if ("".equals(numStr) || "".equals(text) || targetRev2 == null) { + JOptionPane.showMessageDialog($this, "δдϢд", "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } + List selectedRowList = getselectedRow(p1Table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkTargetAndSelect(targetRev, selectedRowList)) { + return; + } + long startTime = System.currentTimeMillis(); + updateTitleShowProgress(selectedRowList); + List msgData = new ArrayList(); + L1: for (int i = 0; i < selectedRowList.size(); i++) { + try { + doIndex++; + BOMManageTableBean bean = selectedRowList.get(i); + System.out.println(value.toString()); + if (!addedBOMLine.add(bean.getParentRev().getUid() + targetRev2.getUid())) { + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), targetRev2.getProperty("object_string"), value.toString(), + numStr, "ʧܣ滻һΣ滻" }); + continue L1; + } + AIFComponentContext[] aifs = bean.getParentLine().getChildren(); + for (AIFComponentContext aif : aifs) { + String objStr = ((TCComponentBOMLine) aif.getComponent()).getItemRevision() + .getProperty("object_string"); + if (objStr.equals(targetRev2.getProperty("object_string"))) { + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), targetRev2.getProperty("object_string"), + value.toString(), numStr, "ʧܣѴͬӼ" }); + continue L1; + } + } + String seq = selectedRowList.get(i).getChildLine().getProperty("bl_sequence_no"); + bean.getParentLine().remove("", bean.getChildLine()); + TCComponentBOMLine childLine = bean.getParentLine().add(targetRev2.getItem(), targetRev2, null, + false, ""); + childLine.setReferenceProperty("bl_uom", (TCComponent) value); + childLine.setProperties(new String[] { "bl_quantity", "bl_sequence_no" }, + new String[] { numStr, seq }); + msgData.add( + new String[] { msgData.size() + 1 + "", bean.getParentString(), bean.getChildString(), + targetRev2.getProperty("object_string"), value.toString(), numStr, "ɹ" }); + selectedRowList.get(i).setChildString(targetRev2.getProperty("object_string")); + selectedRowList.get(i).setChildRev(targetRev2); + selectedRowList.get(i).setChildLine(childLine); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + complate = true; + return; + } + } + try { + saveWin(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } finally { + complate = true; + } + long endTime = System.currentTimeMillis(); + System.out.println("滻ִϣʱ" + (endTime - startTime) + "ms"); + doLog("滻", msgData); + JScrollPane jsp = DialogUtil + .createTableMsg(new String[] { "", "", "ԭӼ", "滻Ӽ", "λ", "", "" }, msgData).panel; + JOptionPane + .showMessageDialog( + $this, jsp, "滻 ɹ(" + getResultNum(msgData, true) + ") ʧ(" + + getResultNum(msgData, false) + ") ʱ" + (endTime - startTime) + "ms", + JOptionPane.PLAIN_MESSAGE); + updateSelectedRow2(p1Table, selectedRowList); + } + }; + } + + private ActionListener batchModify() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String numStr = p2NumText.getText(); + List selectedRowList = getselectedRow(p2Table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkTargetAndSelect(targetRev, selectedRowList)) { + return; + } + long startTime = System.currentTimeMillis(); + updateTitleShowProgress(selectedRowList); + List msgData = new ArrayList(); + for (BOMManageTableBean bean : selectedRowList) { + String oldNumStr = ""; + try { + doIndex++; + oldNumStr = bean.getChildLine().getProperty("bl_quantity"); + bean.getChildLine().setProperties(new String[] { "bl_quantity" }, new String[] { numStr }); + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), oldNumStr, numStr, "ɹ" }); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + complate = true; + return; + } + } + try { + saveWin(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } finally { + complate = true; + } + long endTime = System.currentTimeMillis(); + System.out.println("ִϣʱ" + (endTime - startTime) + "ms"); + doLog("޸", msgData); + JScrollPane jsp = DialogUtil.createTableMsg(new String[] { "", "", "Ӽ", "ԭ", "", "" }, + msgData).panel; + JOptionPane + .showMessageDialog( + $this, jsp, "Ľ ɹ(" + getResultNum(msgData, true) + ") ʧ(" + + getResultNum(msgData, false) + ") ʱ" + (endTime - startTime) + "ms", + JOptionPane.PLAIN_MESSAGE); + updateSelectedRow(p2Table, selectedRowList); + } + }; + } + + private ActionListener batchAdd() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String numStr = p3NumText.getText().trim(); + String text = p3UnitCombo.getSelectedText().trim(); + Object value = p3UnitCombo.getSelectedValue(); + System.out.println(numStr); + if ("".equals(numStr) || "".equals(text) || targetRev2 == null) { + JOptionPane.showMessageDialog($this, "δдϢд", "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } + List selectedRowList = getselectedRow(p3Table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkTargetAndSelect(targetRev, selectedRowList)) { + return; + } + long startTime = System.currentTimeMillis(); + updateTitleShowProgress(selectedRowList); + List msgData = new ArrayList(); + L1: for (BOMManageTableBean bean : selectedRowList) { + try { + doIndex++; + System.out.println(value.toString()); + if (!addedBOMLine.add(bean.getParentRev().getUid() + targetRev2.getUid())) { + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + targetRev2.getProperty("object_string"), value.toString(), numStr, + "ʧܣӹһΣظ" }); + continue L1; + } + AIFComponentContext[] aifs = bean.getParentLine().getChildren(); + for (AIFComponentContext aif : aifs) { + String objStr = ((TCComponentBOMLine) aif.getComponent()).getItemRevision() + .getProperty("object_string"); + if (objStr.equals(targetRev2.getProperty("object_string"))) { + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + targetRev2.getProperty("object_string"), value.toString(), numStr, + "ʧܣѴͬӼ" }); + continue L1; + } + } + TCComponentBOMLine childLine = bean.getParentLine().add(targetRev2.getItem(), targetRev2, null, + false, ""); + childLine.setReferenceProperty("bl_uom", (TCComponent) value); + childLine.setProperties(new String[] { "bl_quantity" }, new String[] { numStr }); + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + targetRev2.getProperty("object_string"), value.toString(), numStr, "ɹ" }); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + complate = true; + return; + } + } + try { + saveWin(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } finally { + complate = true; + } + long endTime = System.currentTimeMillis(); + System.out.println("ִϣʱ" + (endTime - startTime) + "ms"); + doLog("", msgData); + JScrollPane jsp = DialogUtil.createTableMsg(new String[] { "", "", "Ӽ", "λ", "", "" }, + msgData).panel; + JOptionPane + .showMessageDialog( + $this, jsp, " ɹ(" + getResultNum(msgData, true) + ") ʧ(" + + getResultNum(msgData, false) + ") ʱ" + (endTime - startTime) + "ms", + JOptionPane.PLAIN_MESSAGE); +// showWhereUesd(p3Table, p3SelectAll); + } + }; + } + + private ActionListener batchRemove() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + List selectedRowList = getselectedRow(p4Table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkTargetAndSelect(targetRev, selectedRowList)) { + return; + } + long startTime = System.currentTimeMillis(); + updateTitleShowProgress(selectedRowList); + List msgData = new ArrayList(); + for (BOMManageTableBean bean : selectedRowList) { + try { + doIndex++; + if (bean.getChildLine() == null) { + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), "bomLineڣѾɹɾ" }); + } else { + bean.getParentLine().remove("", bean.getChildLine()); + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), "ɹ" }); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + complate = true; + return; + } + } + try { + saveWin(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } finally { + complate = true; + } + long endTime = System.currentTimeMillis(); + System.out.println("ɾִϣʱ" + (endTime - startTime) + "ms"); + doLog("ɾ", msgData); + JScrollPane jsp = DialogUtil.createTableMsg(new String[] { "", "", "ɾӼ", "" }, msgData).panel; + JOptionPane + .showMessageDialog( + $this, jsp, "ɾ ɹ(" + getResultNum(msgData, true) + ") ʧ(" + + getResultNum(msgData, false) + ") ʱ" + (endTime - startTime) + "ms", + JOptionPane.PLAIN_MESSAGE); +// removeSelectRow(p4Table); + updateSelectedRow3(p4Table, selectedRowList); + } + }; + } + + private List getselectedRow(JTable table) { + List selectedList = new ArrayList(); + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + System.out.println("select=====>" + table.getValueAt(i, 1)); + selectedList.add(tableDataMap.get(table.getValueAt(i, 1))); + } + } + return selectedList; + } + + private void updateSelectedRow(JTable table, List newRowData) { + int index = 0; + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + try { + TCComponentItemRevision parentRev = newRowData.get(index).getParentRev(); + String parentString = newRowData.get(index).getParentString(); + TCComponentBOMWindow win = winType.create(null); + TCComponentBOMLine topLine = win.setWindowTopLine(parentRev.getItem(), parentRev, null, null); + winMap.get(table.getValueAt(i, 1).toString()).close(); + winMap.remove(table.getValueAt(i, 1)); + winMap.put(parentString, win); + tableDataMap.remove(table.getValueAt(i, 1).toString()); + TCComponent[] statusArray = parentRev.getRelatedComponents("release_status_list"); + String status = ""; + if (statusArray != null && statusArray.length > 0) { + status = statusArray[statusArray.length - 1].getProperty("object_name"); + } + AIFComponentContext[] aifs = topLine.getChildren(); + for (AIFComponentContext aif : aifs) { + TCComponentBOMLine child = (TCComponentBOMLine) aif.getComponent(); + if (newRowData.get(index).getChildString() + .equals(child.getItemRevision().getProperty("object_string"))) { + + String unit = child.getProperty("bl_uom"); + String num = child.getProperty("bl_quantity"); + + JCheckBox selected = new JCheckBox(); + selected.setSelected(true); + Object[] rowData = new Object[] { selected, parentString, + newRowData.get(index).getChildString(), unit, num, status }; + rowPrint(rowData); + for (int ii = 0; ii < rowData.length; ii++) { + table.setValueAt(rowData[ii], i, ii); + } + tableDataMap.put(parentString, new BOMManageTableBean(parentString, + newRowData.get(index).getChildString(), parentRev, targetRev, topLine, child)); + break; + } + } + index++; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + table.revalidate(); + table.repaint(); + } + + private void updateSelectedRow2(JTable table, List newRowData) { + int index = 0; + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + BOMManageTableBean bean = newRowData.get(index); + try { + TCComponentBOMLine child = bean.getChildLine(); + String unit = child.getProperty("bl_uom"); + String num = child.getProperty("bl_quantity"); + table.setValueAt(bean.getChildString(), i, 2); + table.setValueAt(unit, index, 3); + table.setValueAt(num, index, 4); + tableDataMap.get(bean.getParentString()).setChildRev(bean.getChildRev()); + tableDataMap.get(bean.getParentString()).setChildString(bean.getChildString()); + tableDataMap.get(bean.getParentString()).setChildLine(child); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + index++; + } + } + table.revalidate(); + table.repaint(); + } + + private void updateSelectedRow3(JTable table, List newRowData) { + int index = 0; + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + BOMManageTableBean bean = newRowData.get(index); + table.setValueAt("", i, 2); + table.setValueAt("", index, 3); + table.setValueAt("", index, 4); + tableDataMap.get(bean.getParentString()).setChildLine(null); + index++; + } + } + table.revalidate(); + table.repaint(); + } + + private void removeSelectRow(JTable table) { + DefaultTableModel model = (DefaultTableModel) table.getModel(); + int i = 0; + while (i < table.getRowCount()) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + model.removeRow(i); + continue; + } + i++; + } + table.revalidate(); + table.repaint(); + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + + new Thread(new Runnable() { + + @Override + public void run() { + // TODO Auto-generated method stub + try { + closeWin(); + System.out.println("closed"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }).start(); + + super.dispose(); + } + + private void saveWin() throws TCException { + for (Entry entry : winMap.entrySet()) { + if (entry.getValue() != null) { + entry.getValue().save(); + } + + } + } + + private void closeWin() throws TCException { + saveWin(); + + for (Entry entry : winMap.entrySet()) { + entry.getValue().close(); + } + winMap.clear(); + } + + private void doLog(String operation, List msgData) { + createLogDataSourceTable(); + String content = ""; + if ("滻".equals(operation)) { + content = "%sӼ%s滻Ϊ%s;%s;%s"; + } else if ("޸".equals(operation)) { + content = "%sӼ%s%sΪ%s"; + } else if ("".equals(operation)) { + content = "%sӼ%s;%s;%s"; + } else if ("ɾ".equals(operation)) { + content = "%sɾӼ%s"; + } + String username = ""; + try { + username = session.getUser().getUserName() + "(" + session.getUser().getUserId() + ")"; + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + String datetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + + List sqls = new ArrayList(); + int num = StrUtil.count(content, "%s"); + for (String[] arr : msgData) { + String temp; + String[] row = new String[num]; + for (int i = 0; i < num; i++) { + row[i] = arr[i + 1]; + } + temp = String.format(content, row); + String sql = "insert into JD2_BOMMANAGELOG (MODIFY_USER,MODIFY_TIME,MODIFY_CONTENT) VALUES ('" + username + + "',to_date('" + datetime + "','yyyy-MM-dd hh24:mi:ss'),'" + temp + "')"; + sqls.add(sql); + } + + try { + Db.use(DBUtil.getDataSource(session)).executeBatch(sqls.toArray(new String[sqls.size()])); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private ActionListener clickSearch(final JTable table, final JCheckBox selectAll) {// ++++final + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + final JDialog content = DialogUtil.createSearchAndSelectRevDialog($this, table, selectAll, // ++++final + (JButton) e.getSource()); + } + }; + } + + public void okCallback(JTable revTable, JTable table, JCheckBox selectAll, JButton field) { + // TODO Auto-generated method stub + int rowIndex = revTable.getSelectedRow(); + if (rowIndex < 0) { + return; + } + String text = revTable.getValueAt(rowIndex, 0).toString(); + System.out.println(text); + field.setText(text); + if ("".equals(text)) { + return; + } + if (table != null) { + targetRev = (TCComponentItemRevision) revTable.getValueAt(rowIndex, 5); + showWhereUesd(table, selectAll); + } else { + targetRev2 = (TCComponentItemRevision) revTable.getValueAt(rowIndex, 5); + } + } + + private KeyAdapter logSearchEnter() { + return new KeyAdapter() { + @Override + public void keyTyped(KeyEvent e) { + // TODO Auto-generated method stub + super.keyTyped(e); + if (e.getKeyChar() == KeyEvent.VK_ENTER) { + p5Search.doClick(); + } + } + }; + } + + private void updateTitleShowProgress(final List list) {// ++++final + new Thread(new Runnable() { + + @Override + public void run() { + int num = 1; + String temp; + doIndex = 0; + while (!complate) { + $this.setTitle("ڴ" + (temp = StringCreateUtil.createPoint(num % 3)) + + StringCreateUtil.createBlank(5 - temp.length()) + list.get(doIndex).getParentString() + + " " + (doIndex + 1) + "/" + list.size()); + try { + Thread.sleep(200); + } catch (InterruptedException e) { + e.printStackTrace(); + } + num++; + } + $this.setTitle("BOM"); + doIndex = -1; + complate = false; + } + }).start(); + } + + private String checkp1TableReleaseStatus(JTable table) { + for (int i = 0; i < table.getRowCount(); i++) { + if (table.getValueAt(i, 5) != null && !table.getValueAt(i, 5).equals("")) { + return table.getValueAt(i, 1).toString(); + } + } + return null; + } + + private String checkSelectRowReleaseStatus(JTable table,int index) { + if (table.getValueAt(index, 5) != null + && !table.getValueAt(index, 5).equals("")) { + return table.getValueAt(index, 1).toString(); + } + return null; + } + + private boolean checkReleaseStatus(TCComponentItemRevision rev) { + try { + System.out.println("item type======>" + rev.getItem().getType()); + if (checkItemType.contains(rev.getItem().getType())) { + return true; + } + TCComponent form = rev.getRelatedComponents("IMAN_master_form_rev")[0]; + TCComponent[] statusArray = form.getRelatedComponents("release_status_list"); + String status = ""; + if (statusArray != null && statusArray.length > 0) { + status = statusArray[statusArray.length - 1].getProperty("object_name"); + } + if (!"".equals(status) || !" ".equals(status) || status != null) { + return false; + } + return true; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return true; + } + + private ResultData checkAccess(List data) { + for (BOMManageTableBean bean : data) { + boolean isAccess = true; + try { + isAccess = session.getTCAccessControlService().checkPrivilege(bean.getParentLine(), "WRITE"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (!isAccess) { + try { + return new ResultData(false, "ǰûûж" + bean.getParentLine().getProperty("object_string") + "дȨ", + bean.getParentLine()); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + return new ResultData(true, "", null); + } + + private boolean checkTargetAndSelect(TCComponentItemRevision rev, List data) { +// if (!checkReleaseStatus(rev)) { +// JOptionPane.showMessageDialog($this, "Ŀδߴڶ״̬޷BOM", "ʾ", JOptionPane.WARNING_MESSAGE); +// return false; +// } + for (int i = 0; i < p1Table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) p1Table.getValueAt(i, 0); + if (select.isSelected()) { + if (checkSelectRowReleaseStatus(p1Table,i) != null) { + JOptionPane.showMessageDialog($this, "汾:" + checkSelectRowReleaseStatus(p1Table,i) + ",Ϊѷ޷滻", "ʾ", + JOptionPane.WARNING_MESSAGE); + return false; + } + } + } + + ResultData res = checkAccess(data); + if (!res.isRes()) { + JOptionPane.showMessageDialog($this, res.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return false; + } + return true; + } + + // ̷̣ + private ActionListener startWorkFlow(final JTable table) {// ++++final + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + final List select = getselectedRow(table); + List parentRev = new ArrayList<>(); + + // +++++ȡbom + if (select.size() == 0 || select == null) {// ȫûѡͷж + try { + getTopBom(targetRev); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else {// ѡ˾ͷѡbom͹ѡĶbom + for (BOMManageTableBean bean : select) { + parentRev.add(bean.getParentRev()); + try { + getTopBom(bean.getParentRev()); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + } + for (TCComponentItemRevision Rev : TopRev) { + parentRev.add(Rev); + } + TopRev.clear(); + // TopRev.clear(); + // ++++ + $this.setExtendedState(JFrame.ICONIFIED); + NewProcessCommand command = new NewProcessCommand(AIFUtility.getActiveDesktop(), app, + parentRev.toArray(new TCComponentItemRevision[parentRev.size()])); + } + }; + } + + private void rowPrint(Object[] arr) { + StringBuilder sb = new StringBuilder(); + sb.append("["); + for (Object obj : arr) { + if (obj instanceof JCheckBox) { + sb.append(((JCheckBox) obj).isSelected()); + } else { + sb.append(obj.toString()); + } + sb.append(","); + } + if (sb.length() > 1) { + sb.deleteCharAt(sb.length() - 1); + } + sb.append("]"); + System.out.println(sb.toString()); + } + + private void resize() { + double left = 2 * this.widthOffset / 3.0; + double right = this.widthOffset - left; + + int bottom1 = p1BottomBtn2.getX() - p1BottomBtn1.getX() - p1BottomBtn1.getWidth(); + int bottom2 = p1BottomBtn3.getX() - p1BottomBtn2.getX() - p1BottomBtn2.getWidth(); + int botttom3 = p1BottomBtn4.getX() - p1BottomBtn3.getX() - p1BottomBtn3.getWidth(); + + // p1 + int p1x1 = p1TargetBtn.getX() - p1TargetLabel.getX() - p1TargetLabel.getWidth(); + int p1x2 = p1ReplaceBtn.getX() - p1ReplaceLabel.getX() - p1ReplaceLabel.getWidth(); + int p1x3 = p1UnitLabel.getX() - p1ReplaceBtn.getX() - p1ReplaceBtn.getWidth(); + int p1x4 = p1NumLabel.getX() - p1UnitCombo.getX() - p1UnitCombo.getWidth(); + // int p1x5 = p1SelectAllRE.getX() - p1SelectAll.getX(); + p1TargetLabel.setBounds(p1TargetLabel.getX() + getOffset(left, 20, 800), 20, + p1TargetLabel.getWidth() + getOffset(left, 100, 800), 25); + p1TargetBtn.setBounds(p1TargetLabel.getX() + p1TargetLabel.getWidth() + p1x1 + getOffset(left, 10, 800), 20, + p1TargetBtn.getWidth() + getOffset(left, 400, 800), 25); + p1ReplaceLabel.setBounds(p1ReplaceLabel.getX() + getOffset(left, 20, 800), 60, + p1ReplaceLabel.getWidth() + getOffset(left, 100, 800), 25); + p1ReplaceBtn.setBounds(p1ReplaceLabel.getX() + p1ReplaceLabel.getWidth() + p1x2 + getOffset(left, 10, 800), 60, + p1ReplaceBtn.getWidth() + getOffset(left, 400, 800), 25); + p1UnitLabel.setBounds(p1ReplaceBtn.getX() + p1ReplaceBtn.getWidth() + p1x3 + getOffset(left, 30, 800), 60, + p1UnitLabel.getWidth() + getOffset(left, 50, 800), 25); + p1UnitCombo.setBounds(p1UnitLabel.getX() + p1UnitLabel.getWidth(), 60, + p1UnitCombo.getWidth() + getOffset(left, 50, 800), 25); + p1NumLabel.setBounds(p1UnitCombo.getX() + p1UnitCombo.getWidth() + p1x4 + getOffset(left, 20, 800), 60, + p1NumLabel.getWidth() + getOffset(left, 50, 800), 25); + p1NumText.setBounds(p1NumLabel.getX() + p1NumLabel.getWidth(), 60, + p1NumText.getWidth() + getOffset(left, 50, 800), 25); + p1SelectAll.setBounds(p1SelectAll.getX() + getOffset(left, 20, 800), 100, + p1SelectAll.getWidth() + getOffset(left, 100, 800), 25); + p1jsp.setBounds(p1jsp.getX() + getOffset(left, 20, 800), p1jsp.getY(), + p1jsp.getWidth() + getOffset(left, 760, 800), p1jsp.getHeight() + this.heightOffset); + p1BottomBtn1.setBounds(p1BottomBtn1.getX() + getOffset(left, 80, 800), p1BottomBtn1.getY() + this.heightOffset, + p1BottomBtn1.getWidth() + getOffset(left, 100, 800), 25); + p1BottomBtn2.setBounds(p1BottomBtn1.getX() + p1BottomBtn1.getWidth() + bottom1 + getOffset(left, 80, 800), + p1BottomBtn2.getY() + this.heightOffset, p1BottomBtn2.getWidth() + getOffset(left, 100, 800), 25); + p1BottomBtn3.setBounds(p1BottomBtn2.getX() + p1BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), + p1BottomBtn3.getY() + this.heightOffset, p1BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p1BottomBtn4.setBounds(p1BottomBtn3.getX() + p1BottomBtn3.getWidth() + botttom3 + getOffset(left, 80, 800), + p1BottomBtn4.getY() + this.heightOffset, p1BottomBtn4.getWidth() + getOffset(left, 100, 800), 25); + p1Left.setBounds(0, 0, p1Left.getWidth() + getOffset(this.widthOffset, 800, 1200), + p1Left.getHeight() + this.heightOffset); + p1TreePanel.setBounds(p1TreePanel.getX() + getOffset(right, 20, 400), 130, + p1TreePanel.getWidth() + getOffset(right, 360, 400), p1TreePanel.getHeight() + this.heightOffset); + p1Right.setBounds(p1Left.getX() + p1Left.getWidth(), 0, + p1Right.getWidth() + getOffset(this.widthOffset, 400, 1200), p1Right.getHeight() + this.heightOffset); + p1.revalidate(); + p1.repaint(); + + // p2 + int p2x1 = p2TargetBtn.getX() - p2TargetLabel.getX() - p2TargetLabel.getWidth(); + int p2x2 = p2NumText.getX() - p2ChangeNumLabel.getX() - p2ChangeNumLabel.getWidth(); + p2TargetLabel.setBounds(p2TargetLabel.getX() + getOffset(left, 20, 800), 20, + p2TargetLabel.getWidth() + getOffset(left, 100, 800), 25); + p2TargetBtn.setBounds(p2TargetLabel.getX() + p2TargetLabel.getWidth() + p2x1 + getOffset(left, 10, 800), 20, + p2TargetBtn.getWidth() + getOffset(left, 400, 800), 25); + p2ChangeNumLabel.setBounds(p2ChangeNumLabel.getX() + getOffset(left, 20, 800), 60, + p2ChangeNumLabel.getWidth() + getOffset(left, 100, 800), 25); + p2NumText.setBounds(p2ChangeNumLabel.getX() + p2ChangeNumLabel.getWidth() + p2x2 + getOffset(left, 10, 800), 60, + p2NumText.getWidth() + getOffset(left, 50, 800), 25); + p2SelectAll.setBounds(p2SelectAll.getX() + getOffset(left, 20, 800), 100, + p2SelectAll.getWidth() + getOffset(left, 100, 800), 25); + p2jsp.setBounds(p2jsp.getX() + getOffset(left, 20, 800), p2jsp.getY(), + p2jsp.getWidth() + getOffset(left, 760, 800), p2jsp.getHeight() + this.heightOffset); + p2BottomBtn1.setBounds(p2BottomBtn1.getX() + getOffset(left, 80, 800), p2BottomBtn1.getY() + this.heightOffset, + p2BottomBtn1.getWidth() + getOffset(left, 100, 800), 25); + p2BottomBtn2.setBounds(p2BottomBtn1.getX() + p2BottomBtn1.getWidth() + bottom1 + getOffset(left, 80, 800), + p2BottomBtn2.getY() + this.heightOffset, p2BottomBtn2.getWidth() + getOffset(left, 100, 800), 25); + p2BottomBtn3.setBounds(p2BottomBtn2.getX() + p2BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), + p2BottomBtn3.getY() + this.heightOffset, p2BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p2BottomBtn4.setBounds(p2BottomBtn3.getX() + p2BottomBtn3.getWidth() + botttom3 + getOffset(left, 80, 800), + p2BottomBtn4.getY() + this.heightOffset, p2BottomBtn4.getWidth() + getOffset(left, 100, 800), 25); + p2Left.setBounds(0, 0, p2Left.getWidth() + getOffset(this.widthOffset, 800, 1200), + p2Left.getHeight() + this.heightOffset); + p2TreePanel.setBounds(p2TreePanel.getX() + getOffset(right, 20, 400), 130, + p2TreePanel.getWidth() + getOffset(right, 360, 400), p2TreePanel.getHeight() + this.heightOffset); + p2Right.setBounds(p2Left.getX() + p2Left.getWidth(), 0, + p2Right.getWidth() + getOffset(this.widthOffset, 400, 1200), p2Right.getHeight() + this.heightOffset); + p2.revalidate(); + p2.repaint(); + + // p3 + int p3x1 = p3TargetBtn.getX() - p3TargetLabel.getX() - p3TargetLabel.getWidth(); + int p3x2 = p3AddBtn.getX() - p3AddLabel.getX() - p3AddLabel.getWidth(); + int p3x3 = p3UnitLabel.getX() - p3AddBtn.getX() - p3AddBtn.getWidth(); + int p3x4 = p3NumLabel.getX() - p3UnitCombo.getX() - p3UnitCombo.getWidth(); + p3TargetLabel.setBounds(p3TargetLabel.getX() + getOffset(left, 20, 800), 20, + p3TargetLabel.getWidth() + getOffset(left, 100, 800), 25); + p3TargetBtn.setBounds(p3TargetLabel.getX() + p3TargetLabel.getWidth() + p3x1 + getOffset(left, 10, 800), 20, + p3TargetBtn.getWidth() + getOffset(left, 400, 800), 25); + p3AddLabel.setBounds(p3AddLabel.getX() + getOffset(left, 20, 800), 60, + p3AddLabel.getWidth() + getOffset(left, 100, 800), 25); + p3AddBtn.setBounds(p3AddLabel.getX() + p3AddLabel.getWidth() + p3x2 + getOffset(left, 10, 800), 60, + p3AddBtn.getWidth() + getOffset(left, 400, 800), 25); + p3UnitLabel.setBounds(p3AddBtn.getX() + p3AddBtn.getWidth() + p3x3 + getOffset(left, 30, 800), 60, + p3UnitLabel.getWidth() + getOffset(left, 50, 800), 25); + p3UnitCombo.setBounds(p3UnitLabel.getX() + p3UnitLabel.getWidth(), 60, + p3UnitCombo.getWidth() + getOffset(left, 50, 800), 25); + p3NumLabel.setBounds(p3UnitCombo.getX() + p3UnitCombo.getWidth() + p3x4 + getOffset(left, 20, 800), 60, + p3NumLabel.getWidth() + getOffset(left, 50, 800), 25); + p3NumText.setBounds(p3NumLabel.getX() + p3NumLabel.getWidth(), 60, + p3NumText.getWidth() + getOffset(left, 50, 800), 25); + p3SelectAll.setBounds(p3SelectAll.getX() + getOffset(left, 20, 800), 100, + p3SelectAll.getWidth() + getOffset(left, 100, 800), 25); + p3jsp.setBounds(p3jsp.getX() + getOffset(left, 20, 800), p3jsp.getY(), + p3jsp.getWidth() + getOffset(left, 760, 800), p3jsp.getHeight() + this.heightOffset); + p3BottomBtn1.setBounds(p3BottomBtn1.getX() + getOffset(left, 80, 800), p3BottomBtn1.getY() + this.heightOffset, + p3BottomBtn1.getWidth() + getOffset(left, 100, 800), 25); + p3BottomBtn2.setBounds(p3BottomBtn1.getX() + p3BottomBtn1.getWidth() + bottom1 + getOffset(left, 80, 800), + p3BottomBtn2.getY() + this.heightOffset, p3BottomBtn2.getWidth() + getOffset(left, 100, 800), 25); + p3BottomBtn3.setBounds(p3BottomBtn2.getX() + p3BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), + p3BottomBtn3.getY() + this.heightOffset, p3BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p3BottomBtn4.setBounds(p3BottomBtn3.getX() + p3BottomBtn3.getWidth() + botttom3 + getOffset(left, 80, 800), + p3BottomBtn4.getY() + this.heightOffset, p3BottomBtn4.getWidth() + getOffset(left, 100, 800), 25); + p3Left.setBounds(0, 0, p3Left.getWidth() + getOffset(this.widthOffset, 800, 1200), + p3Left.getHeight() + this.heightOffset); + p3TreePanel.setBounds(p3TreePanel.getX() + getOffset(right, 20, 400), 130, + p3TreePanel.getWidth() + getOffset(right, 360, 400), p3TreePanel.getHeight() + this.heightOffset); + p3Right.setBounds(p3Left.getX() + p3Left.getWidth(), 0, + p3Right.getWidth() + getOffset(this.widthOffset, 400, 1200), p3Right.getHeight() + this.heightOffset); + p3.revalidate(); + p3.repaint(); + + // p4 + int p4x1 = p4TargetBtn.getX() - p4TargetLabel.getX() - p4TargetLabel.getWidth(); + p4TargetLabel.setBounds(p4TargetLabel.getX() + getOffset(left, 20, 800), 20, + p4TargetLabel.getWidth() + getOffset(left, 100, 800), 25); + p4TargetBtn.setBounds(p4TargetLabel.getX() + p4TargetLabel.getWidth() + p4x1 + getOffset(left, 10, 800), 20, + p4TargetBtn.getWidth() + getOffset(left, 400, 800), 25); + p4SelectAll.setBounds(p4SelectAll.getX() + getOffset(left, 20, 800), 100, + p4SelectAll.getWidth() + getOffset(left, 100, 800), 25); + p4jsp.setBounds(p4jsp.getX() + getOffset(left, 20, 800), p4jsp.getY(), + p4jsp.getWidth() + getOffset(left, 760, 800), p4jsp.getHeight() + this.heightOffset); + p4BottomBtn1.setBounds(p4BottomBtn1.getX() + getOffset(left, 80, 800), p4BottomBtn1.getY() + this.heightOffset, + p4BottomBtn1.getWidth() + getOffset(left, 100, 800), 25); + p4BottomBtn2.setBounds(p4BottomBtn1.getX() + p4BottomBtn1.getWidth() + bottom1 + getOffset(left, 80, 800), + p4BottomBtn2.getY() + this.heightOffset, p4BottomBtn2.getWidth() + getOffset(left, 100, 800), 25); + p4BottomBtn3.setBounds(p4BottomBtn2.getX() + p4BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), + p4BottomBtn3.getY() + this.heightOffset, p4BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p4BottomBtn4.setBounds(p4BottomBtn3.getX() + p4BottomBtn3.getWidth() + botttom3 + getOffset(left, 80, 800), + p4BottomBtn4.getY() + this.heightOffset, p4BottomBtn4.getWidth() + getOffset(left, 100, 800), 25); + p4Left.setBounds(0, 0, p4Left.getWidth() + getOffset(this.widthOffset, 800, 1200), + p4Left.getHeight() + this.heightOffset); + p4TreePanel.setBounds(p4TreePanel.getX() + getOffset(right, 20, 400), 130, + p4TreePanel.getWidth() + getOffset(right, 360, 400), p4TreePanel.getHeight() + this.heightOffset); + p4Right.setBounds(p4Left.getX() + p4Left.getWidth(), 0, + p4Right.getWidth() + getOffset(this.widthOffset, 400, 1200), p4Right.getHeight() + this.heightOffset); + p4.revalidate(); + p4.repaint(); + + // p5 + int p5x1 = p5UserText.getX() - p5UserLabel.getX() - p5UserLabel.getWidth(); + int p5x2 = p5TimeLabel.getX() - p5UserText.getX() - p5UserText.getWidth(); + int p5x3 = p5TimeStartText.getX() - p5TimeLabel.getX() - p5TimeLabel.getWidth(); + int p5x4 = toLabel.getX() - p5TimeStartText.getX() - p5TimeStartText.getWidth(); + int p5x5 = p5TimeEndText.getX() - toLabel.getX() - toLabel.getWidth(); + int p5x6 = p5ContentLabel.getX() - p5TimeEndText.getX() - p5TimeEndText.getWidth(); + int p5x7 = p5Contentjsp.getX() - p5ContentLabel.getX() - p5ContentLabel.getWidth(); + int p5x8 = p5Search.getX() - p5Contentjsp.getX() - p5Contentjsp.getWidth(); + int p5x9 = p5Download.getX() - p5Search.getX() - p5Search.getWidth(); + p5UserLabel.setBounds(p5UserLabel.getX(), 40, p5UserLabel.getWidth() + getOffset(this.widthOffset, 70, 1200), + 25); + p5UserText.setBounds(p5UserLabel.getX() + p5UserLabel.getWidth() + p5x1 + getOffset(this.widthOffset, 10, 1200), + 40, p5UserText.getWidth() + getOffset(this.widthOffset, 150, 1200), 25); + p5TimeLabel.setBounds(p5UserText.getX() + p5UserText.getWidth() + p5x2 + getOffset(this.widthOffset, 50, 1200), + 40, p5TimeLabel.getWidth() + getOffset(this.widthOffset, 70, 1200), 25); + p5TimeStartText.setBounds( + p5TimeLabel.getX() + p5TimeLabel.getWidth() + p5x3 + getOffset(this.widthOffset, 10, 1200), 40, + p5TimeStartText.getWidth() + getOffset(this.widthOffset, 100, 1200), 25); + toLabel.setBounds( + p5TimeStartText.getX() + p5TimeStartText.getWidth() + p5x4 + getOffset(this.widthOffset, 10, 1200), 40, + toLabel.getWidth() + getOffset(this.widthOffset, 20, 1200), 25); + p5TimeEndText.setBounds(toLabel.getX() + toLabel.getWidth() + p5x5 + getOffset(this.widthOffset, 10, 1200), 40, + p5TimeEndText.getWidth() + getOffset(this.widthOffset, 100, 1200), 25); + p5ContentLabel.setBounds( + p5TimeEndText.getX() + p5TimeEndText.getWidth() + p5x6 + getOffset(this.widthOffset, 50, 1200), 40, + p5ContentLabel.getWidth() + getOffset(this.widthOffset, 70, 1200), 25); + p5Contentjsp.setBounds( + p5ContentLabel.getX() + p5ContentLabel.getWidth() + p5x7 + getOffset(this.widthOffset, 10, 1200), 20, + p5Contentjsp.getWidth() + getOffset(this.widthOffset, 200, 1200), 80); + p5Search.setBounds(p5Contentjsp.getX() + p5Contentjsp.getWidth() + p5x8 + getOffset(this.widthOffset, 50, 1200), + 40, p5Search.getWidth() + getOffset(this.widthOffset, 60, 1200), 25); + p5Download.setBounds(p5Search.getX() + p5Search.getWidth() + p5x9 + getOffset(this.widthOffset, 20, 1200), 40, + p5Download.getWidth() + getOffset(this.widthOffset, 100, 1200), 25); + p5jsp.setBounds(p5jsp.getX() + getOffset(this.widthOffset, 20, 1200), p5jsp.getY(), + p5jsp.getWidth() + getOffset(this.widthOffset, 1160, 1200), p5jsp.getHeight() + this.heightOffset); + p5.revalidate(); + p5.repaint(); + } + + private int getOffset(double num1, int num2, int num3) { + return (int) (num1 * num2 / num3); + } + + private int getResultNum(List msgData, boolean success) { + int num = 0; + String str = success ? "ɹ" : "ʧ"; + for (String[] row : msgData) { + if (row[row.length - 1].contains(str)) { + num++; + } + } + return num; + } + +} diff --git a/src/com/connor/renben/process/plm/updataBOM/BOMManagementHandler.java b/src/com/connor/renben/process/plm/updataBOM/BOMManagementHandler.java new file mode 100644 index 0000000..e2de761 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/BOMManagementHandler.java @@ -0,0 +1,24 @@ +package com.connor.renben.process.plm.updataBOM; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class BOMManagementHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + BOMManagementAction action = new BOMManagementAction(app, ""); + new Thread(action).start(); + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/updataBOM/CheckBoxPo.java b/src/com/connor/renben/process/plm/updataBOM/CheckBoxPo.java new file mode 100644 index 0000000..7feb7a3 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/CheckBoxPo.java @@ -0,0 +1,14 @@ +package com.connor.renben.process.plm.updataBOM; + +public class CheckBoxPo { + public Object value = null; + public String text = null; + + public CheckBoxPo() { + } + + public CheckBoxPo(String text, Object value) { + this.value = value; + this.text = text; + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/updataBOM/CustomLovBean.java b/src/com/connor/renben/process/plm/updataBOM/CustomLovBean.java new file mode 100644 index 0000000..8821cfa --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/CustomLovBean.java @@ -0,0 +1,38 @@ +package com.connor.renben.process.plm.updataBOM; + +import java.util.ArrayList; +import java.util.List; + +public class CustomLovBean { + private List sub = new ArrayList(); + public String displayName = ""; + + public CustomLovBean(String displayName) { + super(); + this.displayName = displayName; + } + + public CustomLovBean(String displayName, String[] subArray) { + super(); + this.displayName = displayName; + translateArrayToSub(subArray); + } + + public void translateArrayToSub(String[] subArray) { + for (int i = 0; i < subArray.length; i++) { + sub.add(new CustomLovBean(subArray[i])); + } + } + + public List getSub() { + return sub; + } + + public boolean hasChild() { + return sub.size() != 0; + } + + public void addSub(CustomLovBean clb) { + sub.add(clb); + } +} diff --git a/src/com/connor/renben/process/plm/updataBOM/DBConnectionUtil.java b/src/com/connor/renben/process/plm/updataBOM/DBConnectionUtil.java new file mode 100644 index 0000000..1291aaa --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/DBConnectionUtil.java @@ -0,0 +1,50 @@ +package com.connor.renben.process.plm.updataBOM; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; + +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class DBConnectionUtil { + + public static Connection dbConn(TCSession session) { + Connection c = null; + try { + Class.forName("oracle.jdbc.driver.OracleDriver"); + // ҪǵûгɹĻǻclassnotfoundException.ԼDz,classpathЩ + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + try { + String[] dbSettings = JDMethodUtil.getPrefStrArray("rb_db_settings", session); + if (dbSettings.length != 3) { + MessageBox.post("rb_db_settingsݿô", "", MessageBox.ERROR); + throw new Exception("rb_db_settingsݿô"); + } else { + Map settingMap = new HashMap(); + for (String s : dbSettings) { + settingMap.put(s.substring(0, s.indexOf(":")), s.substring(s.indexOf(":") + 1, s.length())); + } + System.out.println(settingMap.get("url") + settingMap.get("user") + settingMap.get("pass")); + c = DriverManager.getConnection(settingMap.get("url"), settingMap.get("user"), settingMap.get("pass")); + } +// c = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:TC", name, pass); + // ݵķ, 򵥵,һҳ TCݿʵƣصļtest.sqlпִ鿴 + // "jdbc:oracle:thin:@:˿:ϵͳʵ", username, password, + // ,ҪԼ֪ڼԲ֪. + // ˿һĬ1521, ҪǸı˾ͿԼļļlistener.ora + // ϵͳʵһĬorcl, ҪDzǵĻ select name from v$database; + // username,password,ǵ½ݿû. + + } catch (SQLException e) { + e.printStackTrace(); + } catch (Exception e1) { + e1.printStackTrace(); + } + return c; + } +} diff --git a/src/com/connor/renben/process/plm/updataBOM/DBUtil.java b/src/com/connor/renben/process/plm/updataBOM/DBUtil.java new file mode 100644 index 0000000..ef4f2b7 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/DBUtil.java @@ -0,0 +1,38 @@ +package com.connor.renben.process.plm.updataBOM; + +import java.util.HashMap; +import java.util.Map; + +import javax.sql.DataSource; +import javax.swing.JOptionPane; + +import com.teamcenter.rac.kernel.TCSession; + +import cn.hutool.db.ds.simple.SimpleDataSource; + +public class DBUtil { + + public static DataSource getDataSource(TCSession session) { + + Map settingMap = getDbSetting(session); + String str = settingMap.get("url") + settingMap.get("user") + settingMap.get("pass"); + DataSource dataSource = new SimpleDataSource(settingMap.get("url"), settingMap.get("user"), + settingMap.get("pass")); + return dataSource; + } + + private static Map getDbSetting(TCSession session) { + Map settingMap = null; + String[] dbSettings = JDMethodUtil.getPrefStrArray("rb_db_settings", session); + if (dbSettings.length != 3) { + JOptionPane.showMessageDialog(null, "rb_db_settingsݿô", "", JOptionPane.ERROR); + } else { + settingMap = new HashMap(); + for (String s : dbSettings) { + settingMap.put(s.substring(0, s.indexOf(":")), s.substring(s.indexOf(":") + 1, s.length())); + } + } + return settingMap; + } + +} diff --git a/src/com/connor/renben/process/plm/updataBOM/DatePickerUtil.java b/src/com/connor/renben/process/plm/updataBOM/DatePickerUtil.java new file mode 100644 index 0000000..dd146e7 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/DatePickerUtil.java @@ -0,0 +1,80 @@ +package com.connor.renben.process.plm.updataBOM; + +import java.awt.Dimension; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Date; +import java.util.Locale; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JOptionPane; + +import com.eltima.components.ui.DatePicker; + +public class DatePickerUtil { + public static void main(String[] args) { + + final JFrame f = new JFrame("LoL");// ++++final + f.setSize(400, 300); + f.setLocation(200, 200); + f.setLayout(null); + + final DatePicker datepick; + datepick = getDatePicker("yyyy-MM-dd hh:mm"); + + f.add(datepick); + + JButton b = new JButton("ȡʱ"); + b.setBounds(137, 183, 100, 30); + f.add(b); + + b.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + JOptionPane.showMessageDialog(f, "ȡؼеڣ" + datepick.getText()); + System.out.println(datepick.getValue()); + } + }); + + f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + f.setVisible(true); + } + + public static DatePicker getDatePicker(String format) { + final DatePicker datepick; + // ʽ ¼ʱѡUI + String DefaultFormat = "yyyy-MM-dd"; + // ǰʱ + Date date = new Date(); + // + Font font = new Font("Times New Roman", Font.BOLD, 14); + + Dimension dimension = new Dimension(180, 24); + +// int[] hilightDays = { 1, 3, 5, 7 }; + +// int[] disabledDays = { 4, 6, 5, 9 }; + + datepick = new DatePicker(date, format == null ? DefaultFormat : format, font, dimension); + + datepick.setLocation(137, 83); + datepick.setBounds(137, 83, 180, 24); + // һ·Ҫʾ +// datepick.setHightlightdays(hilightDays, Color.red); + // һ·вҪӣʻɫʾ +// datepick.setDisableddays(disabledDays); + // ù + datepick.setLocale(Locale.CHINA); + // ʱɼ + if (format != null) { + datepick.setTimePanleVisible(true); + } else { + datepick.setTimePanleVisible(false); + } + return datepick; + } +} diff --git a/src/com/connor/renben/process/plm/updataBOM/DialogUtil.java b/src/com/connor/renben/process/plm/updataBOM/DialogUtil.java new file mode 100644 index 0000000..8efac2a --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/DialogUtil.java @@ -0,0 +1,288 @@ +package com.connor.renben.process.plm.updataBOM; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dialog.ModalityType; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +import com.connor.renben.process.plm.updataBOM.BOMManagementFrame; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class DialogUtil { + + public static TableMsg createTableMsg(String[] header, List msgContent) { + DefaultTableModel msgModel = new DefaultTableModel(header, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + // TODO Auto-generated method stub + return false; + } + }; + JTable msgTable = new JTable(msgModel); + for (int columnIndex = 0; columnIndex < msgTable.getColumnCount(); columnIndex++) { + // msgTable.getColumnModel().getColumn(columnIndex).setMinWidth(100); + msgTable.getColumnModel().getColumn(columnIndex).setPreferredWidth(200); + } + msgTable.setRowHeight(25); + msgTable.setShowGrid(false); + msgTable.setAutoscrolls(true); + msgTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + msgTable.getTableHeader().setReorderingAllowed(false); +// msgTable.getTableHeader().setVisible(false); + + for (String[] row : msgContent) { + msgModel.addRow(row); + } + + msgTable.invalidate(); + msgTable.repaint(); + JScrollPane msgPanel = new JScrollPane(msgTable); + msgPanel.setPreferredSize(new Dimension(header.length * 200, 400)); + msgPanel.setBorder(BorderFactory.createEmptyBorder()); + return new TableMsg(msgPanel, msgTable); + } + + public static JDialog createSearchAndSelectRevDialog(final BOMManagementFrame frame, final JTable paramTable, // ++++final + final JCheckBox selectAll, final JButton field) {// ++++final + final JDialog dialog = new JDialog();// ++++final + dialog.setTitle("汾"); + dialog.setSize(520, 400); + dialog.setResizable(true); + dialog.setAutoRequestFocus(true); + dialog.setAlwaysOnTop(true); + dialog.setLocationRelativeTo(frame); + dialog.setModalityType(ModalityType.APPLICATION_MODAL); + + final JPanel content = new JPanel();// ++++final + content.setLayout(null); + content.setPreferredSize(new Dimension(520, 400)); + JLabel targetLabel = new JLabel("Ŀ"); + targetLabel.setBounds(10, 10, 50, 25); + final JTextField targetText = new JTextField();// ++++final + targetText.setText("ҪID"); + targetText.setForeground(Color.GRAY); + if (!"".equals(field.getText())) { + targetText.setText(field.getText().substring(0, field.getText().indexOf("/"))); + targetText.setForeground(Color.BLACK); + } + targetText.setBounds(20, 50, 300, 25); + final JButton searchBtn = new JButton("");// ++++final + searchBtn.setBounds(380, 50, 100, 25); + + String[] colDisplayNames = new String[] { "", "", "״̬", "", "ID", "" }; + final DefaultTableModel model = new DefaultTableModel(colDisplayNames, 0) {// ++++final + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + return false; + } + }; + final JTable table = new JTable(model);// ++++final + table.getColumnModel().getColumn(0).setMinWidth(100); + table.getColumnModel().getColumn(1).setMinWidth(100); + table.getColumnModel().getColumn(2).setMinWidth(100); + table.getColumnModel().getColumn(3).setMinWidth(100); + table.getColumnModel().getColumn(4).setMinWidth(60); + table.getColumnModel().getColumn(4).setPreferredWidth(60); + TableColumnModel tcm = table.getColumnModel(); + TableColumn tc = tcm.getColumn(5); + tc.setWidth(0); + tc.setPreferredWidth(0); + tc.setMaxWidth(0); + tc.setMinWidth(0); + table.getTableHeader().getColumnModel().getColumn(5).setMaxWidth(0); + table.getTableHeader().getColumnModel().getColumn(5).setMinWidth(0); + table.setRowHeight(25); + table.setAutoscrolls(true); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + table.getTableHeader().setReorderingAllowed(false); + JScrollPane jsp = new JScrollPane(table); + jsp.setBounds(20, 100, 460, 200); + + JButton okBtn = new JButton("ȷ"); + okBtn.setBounds(140, 320, 100, 25); + JButton cancelBtn = new JButton("ȡ"); + cancelBtn.setBounds(260, 320, 100, 25); + + targetText.addFocusListener(new FocusListener() { + + @Override + public void focusLost(FocusEvent e) { + // TODO Auto-generated method stub + if ("".equals(targetText.getText())) { + targetText.setText("ҪID"); + targetText.setForeground(Color.GRAY); + } + } + + @Override + public void focusGained(FocusEvent e) { + // TODO Auto-generated method stub + if ("ҪID".equals(targetText.getText())) { + targetText.setText(""); + targetText.setForeground(Color.BLACK); + } + } + }); + + targetText.addKeyListener(new KeyAdapter() { + @Override + public void keyTyped(KeyEvent paramKeyEvent) { + // TODO Auto-generated method stub + super.keyTyped(paramKeyEvent); + if (paramKeyEvent.getKeyChar() == KeyEvent.VK_ENTER) { + searchBtn.doClick(); + } + } + }); + + searchBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + int cnt = model.getRowCount(); + for (int i = 0; i < cnt; i++) { + model.removeRow(0); + } + table.revalidate(); + table.repaint(); + String text = targetText.getText(); + System.out.println(text); + if ("ҪID".equals(text)) { + return; + } + long startTime = System.currentTimeMillis(); + TCSession session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + TCComponentItem[] items = getTarget(content, text, session); + if (items == null) { + return; + } + List tableDataList = new ArrayList(); + for (TCComponentItem item : items) { + try { + item.refresh(); + TCComponent[] comps = item.getRelatedComponents("revision_list"); + for (TCComponent comp : comps) { + String objetcString = comp.getProperty("object_string"); + TCComponent[] forms = comp.getRelatedComponents("IMAN_master_form_rev"); + String desc = ""; + if (forms.length > 0) { + desc = forms[0].getProperty("jd2_wlms"); + } + TCComponent[] statusArray = comp.getRelatedComponents("release_status_list"); + String status = ""; + if (statusArray != null && statusArray.length > 0) { + status = statusArray[statusArray.length - 1].getProperty("object_name"); + } + String owningUser = comp.getProperty("owning_user"); + String groupId = comp.getProperty("owning_group"); + tableDataList.add(new Object[] { objetcString, desc, status, owningUser, groupId, comp }); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + for (Object[] rowData : tableDataList) { + model.addRow(rowData); + } + table.revalidate(); + table.repaint(); + System.out.println("ʾʱ" + (System.currentTimeMillis() - startTime) + "ms"); + } + }); + + okBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent paramActionEvent) { + // TODO Auto-generated method stub + frame.okCallback(table, paramTable, selectAll, field); +// dialog.setVisible(false); + dialog.dispose(); + } + }); + + cancelBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent paramActionEvent) { + // TODO Auto-generated method stub +// dialog.setVisible(false); + dialog.dispose(); + } + }); + + content.add(targetLabel); + content.add(targetText); + content.add(searchBtn); + content.add(jsp); + content.add(okBtn); + content.add(cancelBtn); + + dialog.add(content); + dialog.setVisible(true); + + return dialog; + } + + private static TCComponentItem[] getTarget(Component parent, String itemId, TCSession session) { + TCComponent[] comps = null; + try { + comps = session.search("Item ID", new String[] { " ID" }, new String[] { itemId }); +// TCComponentItemType type = new TCComponentItemType(); +// comps = type.findItems(itemId); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + return null; + } + if (comps == null || comps.length == 0) { + JOptionPane.showMessageDialog(parent, "Чϱ룬ȷϱǷȷ", "ʾ", JOptionPane.WARNING_MESSAGE); + return null; + } + TCComponentItem[] items = new TCComponentItem[comps.length]; + for (int i = 0; i < comps.length; i++) { + items[i] = (TCComponentItem) comps[i]; + } + return items; + } + + public static class TableMsg { + public JScrollPane panel; + public JTable table; + + public TableMsg(JScrollPane panel, JTable table) { + super(); + this.panel = panel; + this.table = table; + } + + } +} diff --git a/src/com/connor/renben/process/plm/updataBOM/JDMethodUtil.java b/src/com/connor/renben/process/plm/updataBOM/JDMethodUtil.java new file mode 100644 index 0000000..28e2fed --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/JDMethodUtil.java @@ -0,0 +1,47 @@ +package com.connor.renben.process.plm.updataBOM; + +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; + +public class JDMethodUtil { + + public static TCPreferenceService service; + public static TCUserService userservice; + + /** + * + * + * @param prefName + * @return + */ + public static String getPrefStr(String prefName, TCSession session) { + if (service == null) { + service = session.getPreferenceService(); + } + String str = service.getString(TCPreferenceService.TC_preference_site, prefName); + if (str == null) { + str = new String(""); + } + return str; + } + + /** + * + * + * @param prefName + * @return + */ + public static String[] getPrefStrArray(String prefName, TCSession session) { + if (service == null) { + service = session.getPreferenceService(); + } + String[] strs = service.getStringArray(TCPreferenceService.TC_preference_site, prefName); + service.getStringValues(prefName); + service.getStringValue(prefName); + if (strs == null) { + strs = new String[] { "" }; + } + return strs; + } +} diff --git a/src/com/connor/renben/process/plm/updataBOM/KeyValComboBox.java b/src/com/connor/renben/process/plm/updataBOM/KeyValComboBox.java new file mode 100644 index 0000000..8122e47 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/KeyValComboBox.java @@ -0,0 +1,94 @@ +package com.connor.renben.process.plm.updataBOM; + +import java.awt.Component; +import java.util.Vector; + +import javax.swing.DefaultComboBoxModel; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JComboBox; +import javax.swing.JList; + +public class KeyValComboBox extends JComboBox { + + public KeyValComboBox(Vector values) { + super(values); + rendererData(); // Ⱦ + } + + public void rendererData() { + DefaultListCellRenderer render = new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, + boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof CheckBoxPo) { + CheckBoxPo po = (CheckBoxPo) value; + this.setText(po.text); + } + return this; + } + }; + this.setRenderer(render); + } + + // ޸Comboxе + public void updateData(Vector values) { + setModel(new DefaultComboBoxModel(values)); + rendererData(); + } + + @Override + public void setSelectedItem(Object anObject) { // ѡtext봫IJͬ + if (anObject != null) { + if (anObject instanceof CheckBoxPo) { + super.setSelectedItem(anObject); + } + if (anObject instanceof String) { + for (int index = 0; index < getItemCount(); index++) { + CheckBoxPo po = (CheckBoxPo) getItemAt(index); + if (po.text.equals(anObject.toString())) { + super.setSelectedIndex(index); + } + } + } + } else { + super.setSelectedItem(anObject); + } + } + + public void setSelectedValue(Object anObject) { // ѡvalue봫IJͬ + if (anObject != null) { + if (anObject instanceof CheckBoxPo) { + super.setSelectedItem(anObject); + } + if (anObject instanceof String) { + for (int index = 0; index < getItemCount(); index++) { + CheckBoxPo po = (CheckBoxPo) getItemAt(index); + if (po.value.equals(anObject.toString())) { + super.setSelectedIndex(index); + } + } + } + } else { + super.setSelectedItem(anObject); + } + } + + // ѡļֵ + public Object getSelectedValue() { + if (getSelectedItem() instanceof CheckBoxPo) { + CheckBoxPo po = (CheckBoxPo) getSelectedItem(); + return po.value; + } + return (getSelectedItem() != null) ? getSelectedItem().toString() : null; + } + + // ѡʾı + public String getSelectedText() { + if (getSelectedItem() instanceof CheckBoxPo) { + CheckBoxPo po = (CheckBoxPo) getSelectedItem(); + return po.text; + } + return (getSelectedItem() != null) ? getSelectedItem().toString() : null; + } +} diff --git a/src/com/connor/renben/process/plm/updataBOM/MyCellEditor4.java b/src/com/connor/renben/process/plm/updataBOM/MyCellEditor4.java new file mode 100644 index 0000000..ef811f1 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/MyCellEditor4.java @@ -0,0 +1,38 @@ +package com.connor.renben.process.plm.updataBOM; + +import java.awt.Component; + +import javax.swing.DefaultCellEditor; +import javax.swing.JCheckBox; +import javax.swing.JTable; +import javax.swing.JTextField; + +public class MyCellEditor4 extends DefaultCellEditor { + private int type = -1; + private JCheckBox check; + + public MyCellEditor4(JTextField arg0) { + super(arg0); + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (value instanceof JCheckBox) { + System.out.println("123456789abcdefg"); + check = (JCheckBox) value; + type = 1; + return check; + } + type = 0; + return super.getTableCellEditorComponent(table, value, isSelected, row, column); + } + + @Override + public Object getCellEditorValue() { + if (type == 1) { + return check; + } + return super.getCellEditorValue(); + } + +} diff --git a/src/com/connor/renben/process/plm/updataBOM/MyCellRenderer.java b/src/com/connor/renben/process/plm/updataBOM/MyCellRenderer.java new file mode 100644 index 0000000..a41f93f --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/MyCellRenderer.java @@ -0,0 +1,19 @@ +package com.connor.renben.process.plm.updataBOM; + +import java.awt.Component; + +import javax.swing.JCheckBox; +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; + +public class MyCellRenderer extends DefaultTableCellRenderer { + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, + int row, int column) { + // TODO Auto-generated method stub + if (value instanceof JCheckBox) { + return (JCheckBox) value; + } + return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + } +} diff --git a/src/com/connor/renben/process/plm/updataBOM/ResultData.java b/src/com/connor/renben/process/plm/updataBOM/ResultData.java new file mode 100644 index 0000000..2e09686 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/ResultData.java @@ -0,0 +1,39 @@ +package com.connor.renben.process.plm.updataBOM; + +public class ResultData { + private boolean res; + private String Message; + private Object data; + + public ResultData(boolean res, String message, Object data) { + super(); + this.res = res; + Message = message; + this.data = data; + } + + public boolean isRes() { + return res; + } + + public void setRes(boolean res) { + this.res = res; + } + + public String getMessage() { + return Message; + } + + public void setMessage(String message) { + Message = message; + } + + public Object getData() { + return data; + } + + public void setData(Object data) { + this.data = data; + } + +} diff --git a/src/com/connor/renben/process/plm/updataBOM/SimpleExcelUtil.java b/src/com/connor/renben/process/plm/updataBOM/SimpleExcelUtil.java new file mode 100644 index 0000000..2c26ada --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/SimpleExcelUtil.java @@ -0,0 +1,69 @@ +package com.connor.renben.process.plm.updataBOM; + +import java.io.File; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import com.aspose.cells.Cells; +import com.aspose.cells.License; +import com.aspose.cells.Workbook; +import com.aspose.cells.WorksheetCollection; + +public class SimpleExcelUtil { + public static void exportExcel(String path, String[] header, List data) { + if (path == null || data == null) { + return; + } + try { + File file = new File(path); + file.createNewFile(); + + getLicense(); + + Workbook excel = new Workbook(path); + WorksheetCollection wc = excel.getWorksheets(); + Cells cells = wc.get(0).getCells(); + int rowIndex = 0; + if (header != null) { + for (int columnIndex = 0; columnIndex < header.length; columnIndex++) { + cells.get(rowIndex, columnIndex).setValue(header[columnIndex]); + } + rowIndex++; + } + for (String[] arr : data) { + for (int columnIndex = 0; columnIndex < arr.length; columnIndex++) { + cells.get(rowIndex, columnIndex).setValue(arr[columnIndex]); + } + rowIndex++; + } + excel.save(path); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public static boolean getLicense() throws Exception { + boolean result = false; + try { + InputStream is = com.aspose.cells.Cell.class.getResourceAsStream("/com/aspose/cells/resources/license.xml"); + License aposeLic = new License(); + aposeLic.setLicense(is); + result = true; + is.close(); + } catch (Exception e) { + e.printStackTrace(System.out); + throw e; + } + return result; + } + + public static void main(String[] args) { + List test = new ArrayList(); + test.add(new String[] { "zzz", "xxx" }); + SimpleExcelUtil.exportExcel(System.getenv("temp") + File.separator + "xxxxxxxxxxxxxxxxxxxx.xlsx", + new String[] { "1", "2" }, test); + System.out.println(System.getenv("temp")); + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/updataBOM/StringCreateUtil.java b/src/com/connor/renben/process/plm/updataBOM/StringCreateUtil.java new file mode 100644 index 0000000..3d40a60 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/StringCreateUtil.java @@ -0,0 +1,21 @@ +package com.connor.renben.process.plm.updataBOM; + +public class StringCreateUtil { + public static String createBlank(int num) { + StringBuilder sb = new StringBuilder(); + while (num > 0) { + sb.append(" "); + num--; + } + return sb.toString(); + } + + public static String createPoint(int num) { + StringBuilder sb = new StringBuilder(); + while (num > 0) { + sb.append("."); + num--; + } + return sb.toString(); + } +} diff --git a/src/com/teamcenter/rac/pse/pse_user.properties b/src/com/teamcenter/rac/pse/pse_user.properties new file mode 100644 index 0000000..a6c7d7e --- /dev/null +++ b/src/com/teamcenter/rac/pse/pse_user.properties @@ -0,0 +1,5 @@ + + +saveBOMCommand=com.connor.rb.plm.rb016.BomCheckSaveCommand + + diff --git a/src/logback.xml b/src/logback.xml new file mode 100644 index 0000000..4f29eeb --- /dev/null +++ b/src/logback.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + ${LOG_HOME}/consumer.%d{yyyy-MM-dd}.%i.log + + 5MB + 30 + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + + + + + + + + diff --git a/src/rb25(李义替换)2022.3.10 b/src/rb25(李义替换)2022.3.10 new file mode 100644 index 0000000..cdfc7d6 --- /dev/null +++ b/src/rb25(李义替换)2022.3.10 @@ -0,0 +1,432 @@ +package com.connor.rb.plm.rb025; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.client.Options; +import org.apache.axis2.client.ServiceClient; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCClassService; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONArray; + +/** + * ޸ķ + */ +public class EditClassificationDialog extends AbstractAIFDialog { + + private static final long serialVersionUID = 1L; + private AbstractAIFApplication app; + private TCSession session; + private TCComponent target; + private Map propMap; + private TCClassificationService myService; + final EditClassificationDialog DIALOG = this; + private TCComponentItemRevision rev; + private int[] ids; + private String[] values; + private String[] names; + private boolean finished; + private ICSPropertyDescription[] desc; + + public EditClassificationDialog(AbstractAIFApplication app) throws TCException { + this.app = app; + this.session = (TCSession) app.getSession(); + this.myService = session.getClassificationService(); + this.target = (TCComponent) AIFUtility.getCurrentApplication().getTargetComponent(); + System.out.println(target.getType()); + System.out.println(target instanceof TCComponentItemRevision ? "" : ""); + + if (target instanceof TCComponentItemRevision) { + try { + rev = (TCComponentItemRevision) target; + boolean isAccess = session.getTCAccessControlService().checkPrivilege(rev, "WRITE"); + if (!isAccess) { + JOptionPane.showMessageDialog(this, "ûа汾޸ȨޣϵϵͳԱ", "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } + initUI(); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + MessageBox.post("ѡ汾", "", MessageBox.ERROR); + } + } + + /** + * ȡLOVʾֵ + * @param icsD + * @return + */ + public static String getClassDisplayableValue(ICSPropertyDescription icsD) { + String result = ""; + ICSKeyLov lov = icsD.getFormat().getKeyLov(); + if (lov != null) { + String[] keys = lov.getKeys(); + for (String key : keys) { + result = lov.getValueOfKey(key); + return result; + } + } + return result; + } + + private void initUI() { + this.setTitle("޸ķ"); + + JPanel rootPanel = new JPanel(); + rootPanel.setLayout(null); + rootPanel.setPreferredSize(new Dimension(600, 350)); + + Map displayMap = new LinkedHashMap(); + propMap = new HashMap(); + + try { + if (rev.getClassificationClass() != null && !"".equals(rev.getClassificationClass())) { + try { + rev.refresh(); + System.out.println("rev.getClassificationClass()=" + rev.getClassificationClass()); + TCComponentICO ico = rev.getClassificationObjects()[0]; + ICSProperty[] props = ico.getICSProperties(true); + desc = ico.getICSPropertyDescriptors(); + for (int i = 0; i < props.length; i++) { +// System.out.println(props[i].getId() + "===>" + props[i].getValue());// 30101===> + // desc.getName=Type and size series ǷԵ||| desc.getId=30101ǷID +// System.out.println("desc.getName=" + desc[i].getName() + " desc.getId=" + desc[i].getId()); + displayMap.put(props[i], desc[i]); + } + } catch (TCException e1) { + e1.printStackTrace(); + } + } else { + this.disposeDialog(); + MessageBox.post("ǰ汾δ", "", MessageBox.ERROR); + return; + } + } catch (TCException e) { + e.printStackTrace(); + } + + if (displayMap.size() == 0) { + return; + } + + JPanel content = new JPanel(); + content.setLayout(null); + content.setPreferredSize(new Dimension(600, displayMap.size() * (25 + 10))); + + int num = 0; + // ͨȡеķԣȻ + for (Entry entry : displayMap.entrySet()) { + JLabel label = new JLabel(entry.getValue().getName() + ""); + label.setBounds(10, num * 35 + 10, 100, 25); + + ICSKeyLov lov = entry.getValue().getFormat().getKeyLov(); +// ArrayList list = new ArrayList<>(); + if (lov != null) { + String[] keys = lov.getKeys(); + JComboBox combo = new JComboBox(); + for (String key : keys) { + combo.addItem(new ClassPropBean(key, lov.getValueOfKey(key), "")); + } + + String v = entry.getKey().getValue(); + for (int i = 0; i < combo.getItemCount(); i++) { + if (v.equals(combo.getItemAt(i).getId())) { + combo.setSelectedIndex(i); + break; + } + } +// combo.setSelectedItem(v); +// if (!Arrays.asList(lov.getDisplayValues()).contains(v)) { +// combo.addItem(v); +// combo.setSelectedItem(v); +// } + + combo.setBounds(130, num * 35 + 10, 350, 25); + + propMap.put(entry.getValue().getName(), combo); + content.add(combo); + } else { + JTextField text = new JTextField(entry.getKey().getValue()); + text.setBounds(130, num * 35 + 10, 350, 25); + propMap.put(entry.getValue().getName(), text); + content.add(text); + } + + content.add(label); + + num++; + } + + JButton okBtn = new JButton("ȷ"); + okBtn.setBounds(40, 310, 100, 25); + okBtn.setSelected(true); + okBtn.addActionListener(ok()); + JButton cancelBtn = new JButton("ȡ"); + cancelBtn.setBounds(160, 310, 100, 25); + cancelBtn.addActionListener(cancel()); + + JScrollPane jsp = new JScrollPane(content); + jsp.getVerticalScrollBar().setUnitIncrement(16); + jsp.setBounds(0, 0, 600, 300); + jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + rootPanel.add(jsp); + rootPanel.add(okBtn); + rootPanel.add(cancelBtn); + this.add(rootPanel); + this.pack(); + this.centerToScreen(); + this.setAutoRequestFocus(true); +// this.setResizable(false); + this.setAlwaysOnTop(true); + this.showDialog(); + } + + private ActionListener ok() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + ((JButton) e.getSource()).setEnabled(false); + rev = (TCComponentItemRevision) target; + + new Thread(new Runnable() { + + @Override + public void run() { + int i = 1; + while (!DIALOG.finished) { + try { + DIALOG.setTitle("޸ķ " + StringCreateUtil.createPoint(i++ % 3)); + Thread.sleep(200); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + }).start(); + + EditClassificationDialog.this.setAlwaysOnTop(false); + if (saveClassification(rev)) { + MessageBox.post("޸ķԳɹ", "", MessageBox.ERROR); + EditClassificationDialog.this.disposeDialog(); + } else { + MessageBox.post("޸ķʧܣ", "", MessageBox.ERROR); + } + + } + }; + } + + private ActionListener cancel() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + DIALOG.disposeDialog(); + } + }; + } + + @SuppressWarnings("unchecked") + private boolean saveClassification(TCComponentItemRevision rev) { + + try { + TCComponentForm form = (TCComponentForm) rev.getRelatedComponents("IMAN_master_form_rev")[0]; + TCComponent[] status = form.getRelatedComponents("release_status_list"); + for (TCComponent comp : status) { + if (comp.getProperty("object_name").contains("ʽ")) { + JOptionPane.showMessageDialog(this, "汾ʽ޸ķ", "ʾ", JOptionPane.WARNING_MESSAGE); + return false; + } + } + TCComponentICO[] icoS = rev.getClassificationObjects(); + System.out.println("======>ȡķ:" + icoS.length); + String classID = rev.getClassificationClass(); + if (icoS == null || icoS.length == 0) { + return false; + } + for (int i = 0; i < icoS.length; i++) { + List propList = new ArrayList<>(); + TCComponentICO ico = icoS[i]; + ICSPropertyDescription[] desc = ico.getICSPropertyDescriptors(); + ICSProperty[] oldICSProps = ico.getICSProperties(true); + ids = new int[oldICSProps.length]; + values = new String[oldICSProps.length]; + names = new String[oldICSProps.length]; + for (int j = 0; j < oldICSProps.length; j++) { + ids[j] = oldICSProps[j].getId(); + if (propMap.get(desc[j].getName()) instanceof JComboBox) { + ClassPropBean bean = (ClassPropBean) ((JComboBox) propMap.get(desc[j].getName())).getSelectedItem(); + String str = bean.getId(); + values[j] = " ".equals(str) ? "" : str; + } else { + values[j] = ((JTextField) propMap.get(desc[j].getName())).getText(); + } + names[j] = desc[j].getName(); + ClassProperty prop = new ClassProperty(ids[j], values[j]); + propList.add(prop); + } + String json = objectToJson(propList); + System.out.println("classID=" + classID); + System.out.println("json=" + json); + System.out.println("ɾ..."); + try { + deleteClass(getICO(rev, classID).getUid()); + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("ͷ..."); + if (sendToClass(rev.getUid(), classID, json)) { + return true; + } else { + return false; + } + } + } catch (TCException e1) { + e1.printStackTrace(); + JOptionPane.showMessageDialog(null, e1, "", JOptionPane.ERROR_MESSAGE); + return false; + } + return true; + } + + private TCComponentICO getICO(TCComponentItemRevision rev, String classId) throws Exception { + if (rev == null || classId.equals("")) { + return null; + } + TCComponentICO[] icos = rev.getClassificationObjects(); + System.out.println(rev + " -> Ѵڷࣺ" + Arrays.toString(icos)); + int len = icos.length; + if (len == 0) { + return null; + } + TCClassificationService classService = session.getClassificationService(); + for (int i = 0; i < len; i++) { + TCComponentICO ico = icos[i]; + classService.loadICOs(new String[] { ico.getUid() }, ""); + if (ico.getClassId() == null || ico.getClassId().equals("")) { + throw new Exception("쳣ϵԱ"); + } + if (classId.equals(ico.getClassId())) { + return ico; + } + } + return null; + } + + public void deleteClass(String icoPuid) { + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + String url = JDMethodUtil.getPrefStr("Autocode_SendClassServer_URL", session);// "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("DeleteClass"); + sc.setOptions(opts); + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("DeleteClass", omNs); + OMElement value = fac.createOMElement("icoPuid", omNs); + value.setText(icoPuid); + + method.addChild(value); + + OMElement res = sc.sendReceive(method); + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { + e.printStackTrace(); + } + + } + + public boolean sendToClass(String wsoPUID, String classID, String json) { + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + String url = JDMethodUtil.getPrefStr("Autocode_SendClassServer_URL", session); + // "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("SendToClass"); + sc.setOptions(opts); + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("SendToClass", omNs); + OMElement value = fac.createOMElement("wsoPuiid", omNs); + value.setText(wsoPUID); + OMElement value1 = fac.createOMElement("classID", omNs); + value1.setText(classID); + OMElement value2 = fac.createOMElement("JsonContainer", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + value2.setText(json); + + method.addChild(value); + method.addChild(value1); + method.addChild(value2); + + OMElement res = sc.sendReceive(method); + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { +// MessageBox.post("ͷʧܣ", "", MessageBox.ERROR); + e.printStackTrace(); + return false; + } + return true; + + } + + public static String objectToJson(List props) { + String str = null; + try { + JSONArray json = JSONArray.fromObject(props);// javaתΪjson + str = json.toString();// jsonתΪַ + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("JSON =>" + str); + return str; + } +} diff --git a/src/test.java b/src/test.java new file mode 100644 index 0000000..2eb4097 --- /dev/null +++ b/src/test.java @@ -0,0 +1,13 @@ +/** + * + */ + +/** + * @author ½ + * @date 2021128 + */ +public class test { + public static void main(String[] args) { + + } +} diff --git a/src/临时 b/src/临时 new file mode 100644 index 0000000..3c536ef --- /dev/null +++ b/src/临时 @@ -0,0 +1,923 @@ +package com.connor.rb.plm.rb012; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSeparator; +import javax.swing.JTextField; +import javax.swing.SwingConstants; + +import com.connor.rb.plm.entity.ZC_LBJ_list; +import com.connor.rb.plm.newcombox.RwJComboBox; +import com.connor.rb.plm.util.ClassAttributeBean; +import com.connor.rb.plm.util.ClassProperty; +import com.connor.rb.plm.util.PlmLocaleUtil; +import com.connor.rb.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.classification.common.G4MUnitSystemOptionButton; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class CreatDialog extends AbstractAIFDialog { + private AbstractAIFApplication app; + private TCSession session; + private TCPreferenceService service; + private List classList = new ArrayList(); + private JLabel[] labels1 = null; + private JComboBox comb = null; + private String className = ""; + private Map map2; + private List idList = new ArrayList(); + //Ż:TextField + private List fieldList=new ArrayList(); + //box + private List comboxList=new ArrayList(); + private Map fieldmap=new HashMap<>(); + private Map comboxmap=new HashMap<>(); + //end + private List clearanceList = new ArrayList(); + private Map> boxMap = new HashMap>(); + private List> values = new ArrayList>(); + private String cph = ""; + private String th = ""; + private String revId = ""; + private String newID = ""; + private String type = ""; + private String targetType = ""; + private boolean flag = true; + private String url = ""; + private JTextField showDate1; + private JScrollPane scr2; + private SimpleDateFormat df = new SimpleDateFormat("yyyy-M-d HH:mm"); + private JTextField nameField = null; + private TCComponentItemRevision targetRev = null; + private Map zc_lbj_map;//ܳɻ㲿Լֵ + private int f=0; + private int h=4; + private int v=4; + private boolean boflag=false; + private InterfaceAIFComponent targetComp; + public CreatDialog (AbstractAIFApplication app) { + super(false); + this.app = app; + this.targetComp=app.getTargetComponent(); + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + } + + @Override + public void run() { + this.initUI(); + + } + + public void initUI(){ + setTitle("ʱϴ"); + this.setLayout(new PropertyLayout()); + Dimension dimension = new Dimension(); + dimension.setSize(750,630); + Dimension mindis=new Dimension(); + Dimension maxdis=new Dimension(); + mindis.setSize(750,640); + maxdis.setSize(760,1200); + this.setMaximumSize(maxdis); + this.setMinimumSize(mindis); + this.setPreferredSize(dimension); +// this.setLayout(new BorderLayout()); +// Dimension dimension = new Dimension(); +// dimension.setSize(450,630); +// this.setPreferredSize(dimension); + JPanel parentPanel = new JPanel(new PropertyLayout()); + scr2 = new JScrollPane(parentPanel); + scr2.setPreferredSize(new Dimension(720, 530)); + JPanel classJpanel = new JPanel(new PropertyLayout());// Խ + classJpanel.add("1.1.center.top",scr2); + //"1.1.center.top", + //ʱϴӴڸĶ + this.addComponentListener(new ComponentListener() { + + @Override + public void componentResized(ComponentEvent e) { + // TODO Auto-generated method stub + Component component2=e.getComponent(); + int h=component2.getHeight(); + if(h>630) { + scr2.setPreferredSize(new Dimension(component2.getWidth()-30,h-110)); + scr2.revalidate(); + scr2.repaint(); + classJpanel.setPreferredSize(new Dimension(component2.getWidth(),h-110)); + classJpanel.revalidate(); + classJpanel.repaint(); + } + } + + @Override + public void componentMoved(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void componentShown(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void componentHidden(ComponentEvent e) { + // TODO Auto-generated method stub + + } + }); + + + + + //Ż + try { + zc_lbj_map = targetComp.getProperties(); + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + String objtype = targetComp.getType(); + System.out.println("汾:"+objtype); + if(objtype.equals("RB3_ZCRevision")) { + System.out.println(objtype); + boflag=true; + + }else { + System.out.println(objtype); + + } + //endŻ + + + + if(targetComp instanceof TCComponentItemRevision) { + targetRev = (TCComponentItemRevision) targetComp; + try { + targetType = targetRev.getItem().getType(); + if("RB3_ZC".equals(targetType)) { + type = targetRev.getStringProperty("rb3_zclx"); + flag = false; + }else if("RB3_LBJ".equals(targetType)){ + type = targetRev.getStringProperty("rb3_lbjlx"); + } + String name = targetRev.getStringProperty("object_name"); + nameField = new JTextField(18); + nameField.setText(name); + DateChooser dateChooser1 = DateChooser.getInstance("yyyy-M-d HH:mm"); + Date date = new Date(); + Date newDate = stepMonth(date, +3); + System.out.println("ǰʱ3µڣ" + df.format(newDate)); + String time = df.format(newDate); + showDate1 = new JTextField(time); + dateChooser1.register(showDate1); + + parentPanel.add("1.1.center.top", new JLabel("")); + parentPanel.add("2.1.center.top", new JLabel("")); + parentPanel.add("2.2.center.top", nameField); + parentPanel.add("3.1.center.top", new JLabel("Ч")); + parentPanel.add("3.2.center.top", showDate1); + + + + + + + + + + + + + + + + + + cph = targetRev.getStringProperty("rb3_cph"); + th = targetRev.getStringProperty("rb3_th"); + String id = targetRev.getStringProperty("item_id"); + revId = targetRev.getStringProperty("item_revision_id"); + + StringBuilder sb = new StringBuilder("LS-"); + sb.append(id); + newID = sb.toString(); + className = targetRev.getClassificationClass(); + TCComponentICO[] icos = targetRev.getClassificationObjects(); + if(icos == null || icos.length <= 0){ + MessageBox.post("ѡеûз͵࣬뷢ͣ","ʾ",MessageBox.INFORMATION); + return; + } + Map claMap = new HashMap(); + if(icos != null && icos.length>0){ + ICSProperty[] icss = icos[0].getICSProperties(true); + for (ICSProperty ics : icss) { + claMap.put(ics.getId(), ics.getValue()); + } + } + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(className); + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + if (icsAttrS != null) { + for (ICSAdminClassAttribute attr : icsAttrS) { + ClassAttributeBean bean = new ClassAttributeBean(); + if (attr.isReferenceAttribute()) {// + continue; + } + if (attr.isReference()) { + continue; + } + int propID = attr.getAttributeId(); + bean.setId(propID); + String propDisName = attr.getName(); + bean.setName(propDisName); + + int attrType = attr.getFormat1().getType(); + bean.setType(attrType); + + if (claMap != null + && claMap.containsKey(propID)) { + bean.setVal(claMap.get(propID)); + } else { + bean.setVal(""); + } + + ICSKeyLov lov1 = attr.getFormat1().getKeyLov(); + lov1 = (lov1 == null ? attr.getFormat2().getKeyLov() : lov1); + if (lov1 != null) { + bean.setIslov(true); + String[] keys = lov1.getKeys(); + Map map1 = new HashMap(); + for (String key : keys) { + String value = lov1.getValueOfKey(key); + map1.put(value, key);// <ʾֵ,ʵֵ> + if(key.equals(bean.getVal())&&(!bean.getVal().equals(""))){ + bean.setVal(value); + } + } + bean.setLov(map1); + } else { + bean.setIslov(false); + } + classList.add(bean); + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + labels1 = new JLabel[classList.size()]; + + for (int i = 0; i(); + comb.setEditable(true); + comb.setSize(new Dimension(60,40)); + comb.addItem(bean.getVal()); + for (Entry entry : bean.getLov().entrySet()) { + if(!(bean.getVal().equals(entry.getKey()))) { + comb.addItem(entry.getKey()); + } + } + map2 = new HashMap(); + map2.put("JComboBox", comb); + values.add(map2); + parentPanel.add((h+i)+".2.center.top", comb); + + }else{ + JTextField field = new JTextField(18); + map2 = new HashMap(); + map2.put("JTextField", field); + values.add(map2); + parentPanel.add((h+i)+".2.center.top", field); + field.setText(bean.getVal()); + System.out.println("attrName================"+attrName); + System.out.println("PlmLocale.getString(\"PartNumber\")================"+PlmLocaleUtil.getString("PartNumber")); + if((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName)) { + clearanceList.add(field); + JComboBox box = new JComboBox(); + box.addItem(" "); + clearanceList.add(box); + String[] strs = new String[] {"C0","C2","C3","C4","C5"}; + for (int K = 0; K < strs.length; K++) { + box.addItem(strs[K]); + } + boxMap.put(attrName, box); + parentPanel.add((h+i)+".3.center.top", box); + v+=h+i+1; + }else if((PlmLocaleUtil.getString("PartNumber")).equals(attrName)){ + + idList.add(field); + JComboBox box = new JComboBox(); + idList.add(box); + box.addItem(" "); + String[] strs = new String[99]; + for (int K = 0; K < 99; K++) { + if(K < 9) { + strs[K] = "0"+(K+1); + }else { + strs[K] = (K+1)+""; + } + } + for (int K = 0; K < strs.length; K++) { + box.addItem(strs[K]); + } + boxMap.put(attrName, box); + parentPanel.add((h+i)+".3.center.top", box); + } + } + v=h+i+1; + } + + + + + + //Ż + parentPanel.add(v+".1.center.top",new JLabel("******")); + v+=1; + if(boflag) { + //System.out.println("ӵԸ:"+h); + for(int i=0;i disVal=null; + for(int a=0;a(); + disVal.add(disname); + } + } + if(zcprolov!=null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + //ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + + nbox=new RwJComboBox(comboxitems); + nbox.setEditable(true); + nbox.setName("rb3_scgc1"); + nbox.setSize(new Dimension(60,40)); + if(disVal.size()>0) { + StringBuilder sb=new StringBuilder(); + for(int t=0;t(); + zcBox.setSize(new Dimension(60,40)); + zcBox.setName(ZC_LBJ_list.ZCPros.get(i)); + TCProperty zclov = ((TCComponentItemRevision) targetComp).getTCProperty(ZC_LBJ_list.ZCPros.get(i)); + TCComponentListOfValues zcprolov = zclov.getLOV(); + String[] comboxitems; + if(zcprolov!=null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + zcBox.setModel(model); + comboxList.add(zcBox); + } + + zcBox.setSelectedItem(zc_lbj_map.get(ZC_LBJ_list.ZCPros.get(i))); + parentPanel.add((v+i)+".2.center.top",zcBox); + } + + + }else { + JTextField field=new JTextField(18); + field.setName(ZC_LBJ_list.ZCPros.get(i)); + field.setText(zc_lbj_map.get(ZC_LBJ_list.ZCPros.get(i))); + parentPanel.add((v+i)+".2.center.top",field); + fieldList.add(field); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + }else { + for(int i=0;i disVal=null; + for(int a=0;a(); + disVal.add(disname); + } + } + if(zcprolov!=null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + //ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + + nbox=new RwJComboBox(comboxitems); + nbox.setEditable(true); + nbox.setName("rb3_scgc1"); + nbox.setSize(new Dimension(60,40)); + if(disVal.size()>0) { + StringBuilder sb=new StringBuilder(); + for(int t=0;t(); + zcBox.setSize(new Dimension(60,40)); + zcBox.setName(ZC_LBJ_list.LBJPros.get(i)); + TCProperty zclov = ((TCComponentItemRevision) targetComp).getTCProperty(ZC_LBJ_list.LBJPros.get(i)); + TCComponentListOfValues zcprolov = zclov.getLOV(); + String[] comboxitems; + if(zcprolov!=null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + zcBox.setModel(model); + comboxList.add(zcBox); + } + + zcBox.setSelectedItem(zc_lbj_map.get(ZC_LBJ_list.LBJPros.get(i))); + parentPanel.add((v+i)+".2.center.top",zcBox); + } + }else { + JTextField field=new JTextField(18); + field.setName(ZC_LBJ_list.LBJPros.get(i)); + field.setText(zc_lbj_map.get(ZC_LBJ_list.LBJPros.get(i))); + parentPanel.add((v+i)+".2.center.top",field); + fieldList.add(field); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + +// for(Map.Entry e:zc_lbj_map.entrySet()) { +// System.out.println(e.getKey()+"==="+e.getValue()); +// parentPanel.add(h+".1.center.top",new JLabel(e.getKey())); +// JTextField field=new JTextField(18); +// field.setName(e.getKey()); +// field.setText(e.getValue()); +// parentPanel.add(h+".2.center.top",field); +// h++; +// } + + //endŻ + + + + + + + JPanel southPanel = new JPanel(new FlowLayout()); + southPanel.setPreferredSize(new Dimension(250, 50)); + JButton button = new JButton("½"); + JButton button1 = new JButton("ȡ"); + button.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + createItem(); + + } + + }); + button1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + + }); + southPanel.add(button); + southPanel.add(button1); + this.add("1.1.center.top",new JLabel(" ")); + //this.add(new JLabel(" "),BorderLayout.NORTH); + //this.add(classJpanel,BorderLayout.CENTER); + this.add("2.1.center.top",classJpanel); + + //this.add(southPanel,BorderLayout.SOUTH); + this.add("3.1.center.top",southPanel); + + pack(); + centerToScreen(1.0D, 0.75D); + this.showDialog(); + } + protected void createItem() { + // TODO Auto-generated method stub + if(idList.size() > 0) { + JTextField idField = (JTextField) idList.get(0); + JComboBox idBox = (JComboBox) idList.get(1); + String idFieldText = idField.getText(); + String idBoxText = (String) idBox.getSelectedItem(); + if(!("".equals(idFieldText.trim())) && !("".equals(idBoxText.trim()))) { + MessageBox.post("Ųͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return; + } +// if("".equals(idFieldText.trim()) && "".equals(idBoxText.trim())) { +// MessageBox.post("űдһֵ", "ʾ", MessageBox.INFORMATION); +// return; +// } + } + if(clearanceList.size() > 0) { + JTextField clearanceField = (JTextField) clearanceList.get(0); + JComboBox clearanceBox = (JComboBox) clearanceList.get(1); + String clearanceFieldText = clearanceField.getText(); + String clearanceBoxText = (String) clearanceBox.getSelectedItem(); + if(!("".equals(clearanceFieldText.trim())) && !("".equals(clearanceBoxText.trim()))) { + MessageBox.post("ڲ϶ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return; + } + if("".equals(clearanceFieldText.trim()) && "".equals(clearanceBoxText.trim())) { + MessageBox.post("ڲ϶дһֵ", "ʾ", MessageBox.INFORMATION); + return; + } + } + + String[] keys1 = new String[]{" ID"}; + String[] values1 = new String[]{newID}; + List compList = queryObject(" ID", keys1, values1); + if(compList != null && compList.size() > 0) { + MessageBox.post("ϵͳѾڸIDŵ,󴴽!!!!", "ʾ", MessageBox.INFORMATION); + return; + } + TCComponentItemRevision newRev = null; + try { + TCComponentItemType typeComponent = (TCComponentItemType) session + .getTypeComponent(targetType); + + TCComponentItem newItem = typeComponent.create(newID, revId, targetType, + nameField.getText(), "", null); + if (newItem != null) { + session.getUser().getHomeFolder() + .add("contents", newItem); + session.getUser().getHomeFolder().refresh(); + } + newRev = newItem.getLatestItemRevision(); + + + + + //Ż + for(int k=0;k proList=new ArrayList<>(); + String[] split = text.split(","); + TCProperty tclov = ((TCComponentItemRevision) targetComp).getTCProperty(key); + TCComponentListOfValues lov = tclov.getLOV(); + for(int p=0;p pics = new ArrayList(); + List picID = new ArrayList(); + for (int i = 0; i < references.length; i++) { + if(references[i] instanceof TCComponentItemRevision) { + TCComponentItemRevision pic = (TCComponentItemRevision) references[i]; + String pic_type = pic.getItem().getType(); + String rev_id = pic.getStringProperty("item_revision_id"); + String id = pic.getStringProperty("item_id"); + String pic_name = pic.getStringProperty("object_name"); + StringBuilder sb = new StringBuilder("LS-"); + sb.append(id); + String picNewID = sb.toString(); + String[] keys2 = new String[]{" ID"}; + String[] values2 = new String[]{picNewID}; + List picList = queryObject(" ID", keys2, values2); + if(picList != null) { + if(picList.size() > 0) { + TCComponent tcComponent = picList.get(0); + if(tcComponent instanceof TCComponentItem) { + TCComponentItemRevision rev = ((TCComponentItem) tcComponent).getLatestItemRevision(); + if(!(picID.contains(picNewID))) { + picID.add(picNewID); + pics.add(rev); + } + } + } + }else { + TCComponentItemType picType = (TCComponentItemType) session + .getTypeComponent(pic_type); + TCComponentItem picItem = picType.create(picNewID, rev_id, pic_type, + pic_name, "", null); + TCComponentItemRevision picRev = picItem.getLatestItemRevision(); + newRev.add("TC_Is_Represented_By", picRev); + picID.add(picNewID); + } + + } + } + if(pics.size() > 0) { + for (int i = 0; i < pics.size(); i++) { + TCComponentItemRevision rev = pics.get(i); + newRev.add("TC_Is_Represented_By",rev); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + MessageBox.post("ʱϴʧ!!!!", "", MessageBox.INFORMATION); + e.printStackTrace(); + return; + } + List vals = new ArrayList(); + for (Map value : values) { + for (Map.Entry entry : value.entrySet()) { + String type = entry.getKey(); + if(type.equals("JComboBox")){ + JComboBox comb1 = (JComboBox) entry.getValue(); + String val = (String) comb1.getSelectedItem(); + vals.add(val); + }else{ + JTextField field1 = (JTextField) entry.getValue(); + String val = field1.getText(); + vals.add(val); + } + } + } + Integer[] classKeys = new Integer[classList.size()]; + String[] classVals = new String[classList.size()]; + System.out.println("size============================"+classList.size()); + for(int i=0;i box = boxMap.get(attrName); + val2 = (String) box.getSelectedItem(); + } + } + classVals[i] = val2; + } + + disposeDialog(); + sendObjToClassficationByWebService(className,newRev, classKeys, classVals);//ͷ + MessageBox.post("ʱϴ!!!!", "", MessageBox.INFORMATION); + + } + /** + * ͷ + */ + public void sendObjToClassficationByWebService(String class_id, + TCComponentItemRevision rev, Integer[] keys, String[] vals) { + try { + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList(); + + for (int i = 0; i < keys.length; i++) { + if(keys[i] != null && vals[i] != null) { + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + public static Date stepMonth(Date sourceDate, int month) { + Calendar c = Calendar.getInstance(); + c.setTime(sourceDate); + c.add(Calendar.MONTH, month); + + return c.getTime(); + } + + /** + * ͨѯѯĿ + * + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + return null; + } + } + +} diff --git a/src/临时2 b/src/临时2 new file mode 100644 index 0000000..cda874b --- /dev/null +++ b/src/临时2 @@ -0,0 +1,1092 @@ +package com.connor.rb.plm.rb012; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSeparator; +import javax.swing.JTextField; +import javax.swing.SwingConstants; + +import com.connor.rb.plm.entity.ZC_LBJ_list; +import com.connor.rb.plm.newcombox.RwJComboBox; +import com.connor.rb.plm.util.ClassAttributeBean; +import com.connor.rb.plm.util.ClassProperty; +import com.connor.rb.plm.util.PlmLocaleUtil; +import com.connor.rb.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.classification.common.G4MUnitSystemOptionButton; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class CreatDialog extends AbstractAIFDialog { + private AbstractAIFApplication app; + private TCSession session; + private TCPreferenceService service; + private List classList = new ArrayList(); + private JLabel[] labels1 = null; + //private JComboBox comb = null; + private String className = ""; + private Map map2; + private List idList = new ArrayList(); + //Ż:TextField + private List fieldList=new ArrayList(); + //box + private List comboxList=new ArrayList(); + private Map fieldmap=new HashMap<>(); + private Map comboxmap=new HashMap<>(); + private List yylyList=new ArrayList(); + //end + private List clearanceList = new ArrayList(); + private Map> boxMap = new HashMap>(); + private List> values = new ArrayList>(); + private String cph = ""; + private String th = ""; + private String revId = ""; + private String newID = ""; + private String type = ""; + private String targetType = ""; + private boolean flag = true; + private String url = ""; + private JTextField showDate1; + private JScrollPane scr2; + private SimpleDateFormat df = new SimpleDateFormat("yyyy-M-d HH:mm"); + private JTextField nameField = null; + private TCComponentItemRevision targetRev = null; + private Map zc_lbj_map;//ܳɻ㲿Լֵ + private int f=0; + private int h=4; + private int v=4; + private boolean boflag=false; + private InterfaceAIFComponent targetComp; + public CreatDialog (AbstractAIFApplication app) { + super(false); + this.app = app; + this.targetComp=app.getTargetComponent(); + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + } + + @Override + public void run() { + this.initUI(); + + } + + public void initUI(){ + setTitle("ʱϴ"); + this.setLayout(new PropertyLayout()); + Dimension dimension = new Dimension(); + dimension.setSize(750,630); + Dimension mindis=new Dimension(); + Dimension maxdis=new Dimension(); + mindis.setSize(750,640); + maxdis.setSize(760,1200); + this.setMaximumSize(maxdis); + this.setMinimumSize(mindis); + this.setPreferredSize(dimension); +// this.setLayout(new BorderLayout()); +// Dimension dimension = new Dimension(); +// dimension.setSize(450,630); +// this.setPreferredSize(dimension); + JPanel parentPanel = new JPanel(new PropertyLayout()); + scr2 = new JScrollPane(parentPanel); + scr2.setPreferredSize(new Dimension(720, 530)); + JPanel classJpanel = new JPanel(new PropertyLayout());// Խ + classJpanel.add("1.1.center.top",scr2); + //"1.1.center.top", + //ʱϴӴڸĶ + this.addComponentListener(new ComponentListener() { + + @Override + public void componentResized(ComponentEvent e) { + // TODO Auto-generated method stub + Component component2=e.getComponent(); + int h=component2.getHeight(); + if(h>630) { + scr2.setPreferredSize(new Dimension(component2.getWidth()-30,h-110)); + scr2.revalidate(); + scr2.repaint(); + classJpanel.setPreferredSize(new Dimension(component2.getWidth(),h-110)); + classJpanel.revalidate(); + classJpanel.repaint(); + } + } + + @Override + public void componentMoved(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void componentShown(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void componentHidden(ComponentEvent e) { + // TODO Auto-generated method stub + + } + }); + + + + + //Ż + try { + zc_lbj_map = targetComp.getProperties(); + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + String objtype = targetComp.getType(); + System.out.println("汾:"+objtype); + if(objtype.equals("RB3_ZCRevision")) { + System.out.println(objtype); + boflag=true; + + }else { + System.out.println(objtype); + + } + //endŻ + + + + if(targetComp instanceof TCComponentItemRevision) { + targetRev = (TCComponentItemRevision) targetComp; + try { + targetType = targetRev.getItem().getType(); + if("RB3_ZC".equals(targetType)) { + type = targetRev.getStringProperty("rb3_zclx"); + flag = false; + }else if("RB3_LBJ".equals(targetType)){ + type = targetRev.getStringProperty("rb3_lbjlx"); + } + String name = targetRev.getStringProperty("object_name"); + nameField = new JTextField(18); + nameField.setText(name); + DateChooser dateChooser1 = DateChooser.getInstance("yyyy-M-d HH:mm"); + Date date = new Date(); + Date newDate = stepMonth(date, +3); + System.out.println("ǰʱ3µڣ" + df.format(newDate)); + String time = df.format(newDate); + showDate1 = new JTextField(time); + dateChooser1.register(showDate1); + + parentPanel.add("1.1.center.top", new JLabel("")); + parentPanel.add("2.1.center.top", new JLabel("")); + parentPanel.add("2.2.center.top", nameField); + parentPanel.add("3.1.center.top", new JLabel("Ч")); + parentPanel.add("3.2.center.top", showDate1); + + + + + + + + + + + + + + + + + + cph = targetRev.getStringProperty("rb3_cph"); + th = targetRev.getStringProperty("rb3_th"); + String id = targetRev.getStringProperty("item_id"); + revId = targetRev.getStringProperty("item_revision_id"); + + StringBuilder sb = new StringBuilder("LS-"); + sb.append(id); + newID = sb.toString(); + className = targetRev.getClassificationClass(); + TCComponentICO[] icos = targetRev.getClassificationObjects(); + if(icos == null || icos.length <= 0){ + MessageBox.post("ѡеûз͵࣬뷢ͣ","ʾ",MessageBox.INFORMATION); + return; + } + Map claMap = new HashMap(); + if(icos != null && icos.length>0){ + ICSProperty[] icss = icos[0].getICSProperties(true); + for (ICSProperty ics : icss) { + claMap.put(ics.getId(), ics.getValue()); + } + } + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(className); + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + if (icsAttrS != null) { + for (ICSAdminClassAttribute attr : icsAttrS) { + ClassAttributeBean bean = new ClassAttributeBean(); + if (attr.isReferenceAttribute()) {// + continue; + } + if (attr.isReference()) { + continue; + } + int propID = attr.getAttributeId(); + bean.setId(propID); + String propDisName = attr.getName(); + bean.setName(propDisName); + + int attrType = attr.getFormat1().getType(); + bean.setType(attrType); + + if (claMap != null + && claMap.containsKey(propID)) { + bean.setVal(claMap.get(propID)); + } else { + bean.setVal(""); + } + + ICSKeyLov lov1 = attr.getFormat1().getKeyLov(); + lov1 = (lov1 == null ? attr.getFormat2().getKeyLov() : lov1); + if (lov1 != null) { + bean.setIslov(true); + String[] keys = lov1.getKeys(); + Map map1 = new HashMap(); + for (String key : keys) { + String value = lov1.getValueOfKey(key); + map1.put(value, key);// <ʾֵ,ʵֵ> + if(key.equals(bean.getVal())&&(!bean.getVal().equals(""))){ + bean.setVal(value); + } + } + bean.setLov(map1); + } else { + bean.setIslov(false); + } + classList.add(bean); + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + labels1 = new JLabel[classList.size()]; + + for (int i = 0; i comb = new JComboBox(); + + //Ż + JTextField jt=new JTextField(9); + JButton bu=new JButton(""); + //end + + comb.setEditable(false); + comb.setSize(new Dimension(60,40)); + comb.addItem(bean.getVal()); + for (Entry entry : bean.getLov().entrySet()) { + if(!(bean.getVal().equals(entry.getKey()))) { + comb.addItem(entry.getKey()); + } + } + //Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip=jt.getText(); + System.out.println(""+tip); + if(tip.length()>0) { + SearchJComItem.changeBox(comb, tip); + } + } + + }); + //end + map2 = new HashMap(); + map2.put("JComboBox", comb); + values.add(map2); + parentPanel.add((h+i)+".2.center.top", comb); + parentPanel.add((h+i)+".3.center.top", jt); + parentPanel.add((h+i)+".4.center.top", bu); + + }else{ + JTextField field = new JTextField(18); + map2 = new HashMap(); + map2.put("JTextField", field); + values.add(map2); + parentPanel.add((h+i)+".2.center.top", field); + field.setText(bean.getVal()); + System.out.println("attrName================"+attrName); + System.out.println("PlmLocale.getString(\"PartNumber\")================"+PlmLocaleUtil.getString("PartNumber")); + if((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName)) { + clearanceList.add(field); + JComboBox box = new JComboBox(); + //Ż + JTextField jt=new JTextField(9); + JButton bu=new JButton(""); + //end + box.addItem(" "); + clearanceList.add(box); + String[] strs = new String[] {"C0","C2","C3","C4","C5"}; + for (int K = 0; K < strs.length; K++) { + box.addItem(strs[K]); + } + //Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip=jt.getText(); + System.out.println(""+tip); + if(tip.length()>0) { + SearchJComItem.changeBox(box, tip); + } + } + + }); + //end + boxMap.put(attrName, box); + parentPanel.add((h+i)+".3.center.top", box); + //Ż + parentPanel.add((h+i)+".4.center.top",jt); + parentPanel.add((h+i)+".5.center.top",bu); + //end + v+=h+i+1; + }else if((PlmLocaleUtil.getString("PartNumber")).equals(attrName)){ + + idList.add(field); + JComboBox box = new JComboBox(); + JTextField jt=new JTextField(9); + JButton bu=new JButton(""); + idList.add(box); + box.addItem(" "); + String[] strs = new String[99]; + for (int K = 0; K < 99; K++) { + if(K < 9) { + strs[K] = "0"+(K+1); + }else { + strs[K] = (K+1)+""; + } + } + for (int K = 0; K < strs.length; K++) { + box.addItem(strs[K]); + } + //Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip=jt.getText(); + System.out.println(""+tip); + if(tip.length()>0) { + SearchJComItem.changeBox(box, tip); + } + } + + }); + //end + + boxMap.put(attrName, box); + parentPanel.add((h+i)+".3.center.top", box); + parentPanel.add((h+i)+".4.center.top",jt); + parentPanel.add((h+i)+".5.center.top",bu); + } + } + v=h+i+1; + } + + + + + + //Ż + parentPanel.add(v+".1.center.top",new JLabel(" ")); + parentPanel.add(v+".2.center.top",new JLabel("**********************")); + v+=1; + if(boflag) { + //System.out.println("ӵԸ:"+h); + for(int i=0;i disVal=new ArrayList(); + for(int a=0;a0) { + StringBuilder sb=new StringBuilder(); + for(int t=0;t disVal=new ArrayList(); + if(vals.length>0) { + for(int e=0;e0) { + comboxitems=new String[yylyList.size()]; + for(int g=0;g0) { + StringBuilder sb=new StringBuilder(); + for(int t=0;t(); + zcBox.setSize(new Dimension(60,40)); + zcBox.setName(ZC_LBJ_list.ZCPros.get(i)); + TCProperty zclov = ((TCComponentItemRevision) targetComp).getTCProperty(ZC_LBJ_list.ZCPros.get(i)); + TCComponentListOfValues zcprolov = zclov.getLOV(); + String[] comboxitems; + + JTextField jt=new JTextField(9); + JButton bu=new JButton(""); + if(zcprolov!=null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + zcBox.setModel(model); + + + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip=jt.getText(); + System.out.println(""+tip); + if(tip.length()>0) { + SearchJComItem.changeBox(zcBox, tip); + } + } + + }); + + comboxList.add(zcBox); + } + + zcBox.setSelectedItem(zc_lbj_map.get(ZC_LBJ_list.ZCPros.get(i))); + if((ZC_LBJ_list.ZCDisPros.get(i)).equals("ʱϱʶ")) { + zcBox.setSelectedIndex(-1); + } + parentPanel.add((v+i)+".2.center.top",zcBox); + parentPanel.add((v+i)+".3.center.top",jt); + parentPanel.add((v+i)+".4.center.top",bu); + } + + + }else { + JTextField field=new JTextField(18); + field.setName(ZC_LBJ_list.ZCPros.get(i)); + field.setText(zc_lbj_map.get(ZC_LBJ_list.ZCPros.get(i))); + parentPanel.add((v+i)+".2.center.top",field); + fieldList.add(field); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + }else { + for(int i=0;i disVal=new ArrayList(); + for(int a=0;a0) { + StringBuilder sb=new StringBuilder(); + for(int t=0;t(); + zcBox.setSize(new Dimension(60,40)); + zcBox.setName(ZC_LBJ_list.LBJPros.get(i)); + TCProperty zclov = ((TCComponentItemRevision) targetComp).getTCProperty(ZC_LBJ_list.LBJPros.get(i)); + TCComponentListOfValues zcprolov = zclov.getLOV(); + String[] comboxitems; + + + JTextField jt=new JTextField(9); + JButton bu=new JButton(""); + if(zcprolov!=null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + zcBox.setModel(model); + + + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip=jt.getText(); + System.out.println(""+tip); + if(tip.length()>0) { + SearchJComItem.changeBox(zcBox, tip); + } + } + + }); + + comboxList.add(zcBox); + } + zcBox.setSelectedItem(zc_lbj_map.get(ZC_LBJ_list.LBJPros.get(i))); + if((ZC_LBJ_list.LBJDisPros.get(i)).equals("ʱϱʶ")) { + zcBox.setSelectedIndex(-1); + } + parentPanel.add((v+i)+".2.center.top",zcBox); + parentPanel.add((v+i)+".3.center.top",jt); + parentPanel.add((v+i)+".4.center.top",bu); + } + }else { + JTextField field=new JTextField(18); + field.setName(ZC_LBJ_list.LBJPros.get(i)); + field.setText(zc_lbj_map.get(ZC_LBJ_list.LBJPros.get(i))); + parentPanel.add((v+i)+".2.center.top",field); + fieldList.add(field); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + +// for(Map.Entry e:zc_lbj_map.entrySet()) { +// System.out.println(e.getKey()+"==="+e.getValue()); +// parentPanel.add(h+".1.center.top",new JLabel(e.getKey())); +// JTextField field=new JTextField(18); +// field.setName(e.getKey()); +// field.setText(e.getValue()); +// parentPanel.add(h+".2.center.top",field); +// h++; +// } + + //endŻ + + + + + + + JPanel southPanel = new JPanel(new FlowLayout()); + southPanel.setPreferredSize(new Dimension(250, 50)); + JButton button = new JButton("½"); + JButton button1 = new JButton("ȡ"); + button.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + createItem(); + + } + + }); + button1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + + }); + southPanel.add(button); + southPanel.add(button1); + this.add("1.1.center.top",new JLabel(" ")); + //this.add(new JLabel(" "),BorderLayout.NORTH); + //this.add(classJpanel,BorderLayout.CENTER); + this.add("2.1.center.top",classJpanel); + + //this.add(southPanel,BorderLayout.SOUTH); + this.add("3.1.center.top",southPanel); + + pack(); + centerToScreen(1.0D, 0.75D); + this.showDialog(); + } + protected void createItem() { + // TODO Auto-generated method stub + if(idList.size() > 0) { + JTextField idField = (JTextField) idList.get(0); + JComboBox idBox = (JComboBox) idList.get(1); + String idFieldText = idField.getText(); + String idBoxText = (String) idBox.getSelectedItem(); + if(!("".equals(idFieldText.trim())) && !("".equals(idBoxText.trim()))) { + MessageBox.post("Ųͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return; + } +// if("".equals(idFieldText.trim()) && "".equals(idBoxText.trim())) { +// MessageBox.post("űдһֵ", "ʾ", MessageBox.INFORMATION); +// return; +// } + } + if(clearanceList.size() > 0) { + JTextField clearanceField = (JTextField) clearanceList.get(0); + JComboBox clearanceBox = (JComboBox) clearanceList.get(1); + String clearanceFieldText = clearanceField.getText(); + String clearanceBoxText = (String) clearanceBox.getSelectedItem(); + if(!("".equals(clearanceFieldText.trim())) && !("".equals(clearanceBoxText.trim()))) { + MessageBox.post("ڲ϶ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return; + } + if("".equals(clearanceFieldText.trim()) && "".equals(clearanceBoxText.trim())) { + MessageBox.post("ڲ϶дһֵ", "ʾ", MessageBox.INFORMATION); + return; + } + } + + String[] keys1 = new String[]{" ID"}; + String[] values1 = new String[]{newID}; + List compList = queryObject(" ID", keys1, values1); + if(compList != null && compList.size() > 0) { + MessageBox.post("ϵͳѾڸIDŵ,󴴽!!!!", "ʾ", MessageBox.INFORMATION); + return; + } + TCComponentItemRevision newRev = null; + try { + TCComponentItemType typeComponent = (TCComponentItemType) session + .getTypeComponent(targetType); + + TCComponentItem newItem = typeComponent.create(newID, revId, targetType, + nameField.getText(), "", null); + if (newItem != null) { + session.getUser().getHomeFolder() + .add("contents", newItem); + session.getUser().getHomeFolder().refresh(); + } + newRev = newItem.getLatestItemRevision(); + + + + + //Ż + for(int k=0;k proList=new ArrayList<>(); + String[] split = text.split(","); + TCProperty tclov = ((TCComponentItemRevision) targetComp).getTCProperty(key); + TCComponentListOfValues lov = tclov.getLOV(); + for(int p=0;p pics = new ArrayList(); + List picID = new ArrayList(); + for (int i = 0; i < references.length; i++) { + if(references[i] instanceof TCComponentItemRevision) { + TCComponentItemRevision pic = (TCComponentItemRevision) references[i]; + String pic_type = pic.getItem().getType(); + String rev_id = pic.getStringProperty("item_revision_id"); + String id = pic.getStringProperty("item_id"); + String pic_name = pic.getStringProperty("object_name"); + StringBuilder sb = new StringBuilder("LS-"); + sb.append(id); + String picNewID = sb.toString(); + String[] keys2 = new String[]{" ID"}; + String[] values2 = new String[]{picNewID}; + List picList = queryObject(" ID", keys2, values2); + if(picList != null) { + if(picList.size() > 0) { + TCComponent tcComponent = picList.get(0); + if(tcComponent instanceof TCComponentItem) { + TCComponentItemRevision rev = ((TCComponentItem) tcComponent).getLatestItemRevision(); + if(!(picID.contains(picNewID))) { + picID.add(picNewID); + pics.add(rev); + } + } + } + }else { + TCComponentItemType picType = (TCComponentItemType) session + .getTypeComponent(pic_type); + TCComponentItem picItem = picType.create(picNewID, rev_id, pic_type, + pic_name, "", null); + TCComponentItemRevision picRev = picItem.getLatestItemRevision(); + newRev.add("TC_Is_Represented_By", picRev); + picID.add(picNewID); + } + + } + } + if(pics.size() > 0) { + for (int i = 0; i < pics.size(); i++) { + TCComponentItemRevision rev = pics.get(i); + newRev.add("TC_Is_Represented_By",rev); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + MessageBox.post("ʱϴʧ!!!!", "", MessageBox.INFORMATION); + e.printStackTrace(); + return; + } + List vals = new ArrayList(); + for (Map value : values) { + for (Map.Entry entry : value.entrySet()) { + String type = entry.getKey(); + if(type.equals("JComboBox")){ + JComboBox comb1 = (JComboBox) entry.getValue(); + String val = (String) comb1.getSelectedItem(); + vals.add(val); + }else{ + JTextField field1 = (JTextField) entry.getValue(); + String val = field1.getText(); + vals.add(val); + } + } + } + Integer[] classKeys = new Integer[classList.size()]; + String[] classVals = new String[classList.size()]; + System.out.println("size============================"+classList.size()); + for(int i=0;i box = boxMap.get(attrName); + val2 = (String) box.getSelectedItem(); + } + } + classVals[i] = val2; + } + + disposeDialog(); + sendObjToClassficationByWebService(className,newRev, classKeys, classVals);//ͷ + MessageBox.post("ʱϴ!!!!", "", MessageBox.INFORMATION); + + } + /** + * ͷ + */ + public void sendObjToClassficationByWebService(String class_id, + TCComponentItemRevision rev, Integer[] keys, String[] vals) { + try { + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList(); + + for (int i = 0; i < keys.length; i++) { + if(keys[i] != null && vals[i] != null) { + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + public static Date stepMonth(Date sourceDate, int month) { + Calendar c = Calendar.getInstance(); + c.setTime(sourceDate); + c.add(Calendar.MONTH, month); + + return c.getTime(); + } + + /** + * ͨѯѯĿ + * + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + return null; + } + } + +} diff --git a/src/另存 b/src/另存 new file mode 100644 index 0000000..a0dd0b2 --- /dev/null +++ b/src/另存 @@ -0,0 +1,1595 @@ +package com.connor.rb.plm.rb011; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Text; + +import com.connor.rb.plm.entity.ZC_LBJ_list; +import com.connor.rb.plm.newcombox.RwJComboBox; +import com.connor.rb.plm.util.ClassAttributeBean; +import com.connor.rb.plm.util.ClassProperty; +import com.connor.rb.plm.util.ParseXML; +import com.connor.rb.plm.util.PlmLocaleUtil; +import com.connor.rb.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + + +public class CreatDialog extends AbstractAIFDialog { + private AbstractAIFApplication app; + private TCSession session; + private TCPreferenceService service; + private List classList = new ArrayList(); + private JLabel[] labels1 = null; + private JComboBox comb = null; + private String className = ""; + private Map map2; + private List> values = new ArrayList>(); + private String type = ""; + private String targetType = ""; + private JScrollPane scr2; + private boolean flag = true; + private String url = ""; + private TCComponentItemRevision targetRev = null; + private boolean classFlag = true; + private JTextField idField = null; + private JTextField nameField = null; + private JComboBox revComb = null; + private List idList = new ArrayList(); + private List typeList = new ArrayList(); + private String productNumber = ""; + private String drawingNumber = ""; + private Map> attrMap; + private Map> attrMap2; + private Map> attrMap3; + private Map> attrMap4; + private Map> boxMap = new HashMap>(); + private Map objMap = new HashMap(); + private Map objMap2 = new HashMap(); + private Map objMap3 = new HashMap(); + private Map objMap4 = new HashMap(); + private Map lovMap = new HashMap(); + private Map lovMap2 = new HashMap(); + private Map lovMap3 = new HashMap(); + private Map lovMap4 = new HashMap(); + private List defaultValueList = new ArrayList(); + private List isNList = new ArrayList(); + private List isNList2 = new ArrayList(); + private List isNList3 = new ArrayList(); + private List isNList4 = new ArrayList(); + private List markList = new ArrayList(); + private List markList2 = new ArrayList(); + private List markList3 = new ArrayList(); + private List markList4 = new ArrayList(); + private List attrList = new ArrayList(); + private List esAttrList = new ArrayList(); + // private List objList = new ArrayList(); + // private List lovList = new ArrayList(); + private List attrList2 = new ArrayList(); + private List attrList3 = new ArrayList(); + private List attrList4 = new ArrayList(); + private List esAttrList2 = new ArrayList(); + private List esAttrList3 = new ArrayList(); + private List esAttrList4 = new ArrayList(); + private String bsNumber = ""; + private String smNumber = ""; + private List asList = new ArrayList(); + private List esList = new ArrayList(); + private InterfaceAIFComponent targetComp; + //Ż + private Map zc_lbj_map=new HashMap<>(); + private List fieldList=new ArrayList<>(); + private List comboxList=new ArrayList(); + //private int h=4; + private boolean boflag=false; + private Map fieldmap=new HashMap<>(); + private Map comboxmap=new HashMap<>(); + //endŻ + // private List objList2 = new ArrayList(); + // private List lovList2 = new ArrayList(); + // private String[] lovVal = new String[] { "ǰ", "׼", "޽Ӵ", "ʽ", "ͨ", "A:NBR", "0:", "", "", + // "SN:1805ػ", "ȴ", "", "S:(25% to 35%)", "C0","V0","Z0","׼","PC:ﵽC&UƷƾҪ" + // ,"P0:ﵽC&UƷƾҪ","ṹҪƹ","0:˫нǽӴ",":SECC൱",":벿Ŷȷ","BC:35"}; + // private String[] esLovVal = new String[] { "Non", "Standard ball", "Non", "Open", "Without vent hole", "A:NBR", + // "0:Black", "Non", "Ball", "SN:1805 temper","Conventional monolithic martensite quenching heat treatment", + // "Single", "S:(25% to 35%)", "C0","V0","Z0","Standard","PC:Meet the group C&U brand accuracy requirements" + // ,"P0:Meet the group C&U brand accuracy requirements","Other structures need to formulate rules","0:Double row angular contact ball bearing" + // ,"Not marked: SECC or equivalent","Other materials: confirm with department team for approval","BC:35"}; + + public CreatDialog (AbstractAIFApplication app) { + super(false); + this.app = app; + this.targetComp = app.getTargetComponent(); + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + } + + @Override + public void run() { + String lovVal = service.getStringValue("RB3_lovVal_default"); + String esLovVal = service.getStringValue("RB3_esLovVal_default"); + if(lovVal.contains(";")) { + String[] vals = lovVal.split(";"); + String[] esVals = esLovVal.split(";"); + for (int i = 0; i < vals.length; i++) { + asList.add(vals[i]); + esList.add(esVals[i]); + } + } + ParseXML xml=new ParseXML(); + File file=xml.getSXX("RB3_CPHPJFS", session); + + attrMap =xml.parseXMLAttr(file); + if(attrMap == null || attrMap.size() <= 0) { + MessageBox.post("ѡRB3_CPHPJFSδã飡", "WARNING", + MessageBox.WARNING); + return; + } + File file2=xml.getSXX("RB3_THPJFS", session); + attrMap2 =xml.parseXMLAttr(file2); + if(attrMap2 == null || attrMap2.size() <= 0) { + MessageBox.post("ѡRB3_THPJFSδã飡", "WARNING", + MessageBox.WARNING); + return; + } + this.initUI(); + + } + + public void initUI(){ + setTitle("Ϊ"); + int i = 1; + Dimension dimension = new Dimension(); + this.setLayout(new PropertyLayout()); + dimension.setSize(650,800); + this.setMinimumSize(dimension); + this.setPreferredSize(dimension); + JPanel parentPanel = new JPanel(new PropertyLayout()); + scr2 = new JScrollPane(parentPanel); + scr2.setPreferredSize(new Dimension(640, 700)); + JPanel classJpanel = new JPanel(new PropertyLayout());// Խ + classJpanel.add("1.1.center.top", scr2); + //Żڼ + this.addComponentListener(new ComponentListener() { + + + @Override + public void componentResized(ComponentEvent e) { + // TODO Auto-generated method stub + Component component2=e.getComponent(); + int h=component2.getHeight(); + if(h>800) { + scr2.setPreferredSize(new Dimension(component2.getWidth()-10,h-100)); + scr2.revalidate(); + scr2.repaint(); + classJpanel.setPreferredSize(new Dimension(component2.getWidth(),h-100)); + classJpanel.revalidate(); + classJpanel.repaint(); + } + } + + @Override + public void componentMoved(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void componentShown(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void componentHidden(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + }); + + + //endŻ + + + + + + + if(targetComp instanceof TCComponentItemRevision) { + targetRev = (TCComponentItemRevision) targetComp; + String revType = targetRev.getType(); + try { + targetType = targetRev.getItem().getType(); + System.out.println("revType============"+revType); + nameField = new JTextField(18); + parentPanel.add(i+".1.center.top", new JLabel("")); + i += 1; + if("RB3_ZCRevision".equals(revType)) { + type = targetRev.getStringProperty("rb3_zclx"); + flag = false; + }else if("RB3_LBJRevision".equals(revType)){ + idField = new JTextField(18); + + parentPanel.add(i+".1.center.top", new JLabel("ܳϱ")); + parentPanel.add(i+".2.center.top", idField); + i += 1; + type = targetRev.getStringProperty("rb3_lbjlx"); + } + parentPanel.add(i+".1.center.top", new JLabel("")); + parentPanel.add(i+".2.center.top", nameField); + i += 1; + String name = targetRev.getStringProperty("object_name"); + nameField.setText(name); + className = targetRev.getClassificationClass(); + String xmlClassName = ""; + if(flag) { + xmlClassName = className; + JTextField idfield = new JTextField(18); + idList.add(idfield); + JComboBox idbox = new JComboBox(); + idList.add(idbox); + idbox.addItem(" "); + String[] idstrs = new String[99]; + for (int K = 0; K < 99; K++) { + if(K < 9) { + idstrs[K] = "0"+(K+1); + }else { + idstrs[K] = (K+1)+""; + } + } + for (int K = 0; K < idstrs.length; K++) { + idbox.addItem(idstrs[K]); + } + boxMap.put(PlmLocaleUtil.getString("PartNumber"), idbox); + parentPanel.add((i)+".1.center.top", new JLabel(PlmLocaleUtil.getString("PartNumber"))); + parentPanel.add((i)+".2.center.top", idfield); + parentPanel.add((i)+".3.center.top", idbox); + i += 1; + }else { + xmlClassName = className.substring(0, 6); + ParseXML xml=new ParseXML(); + File file3=xml.getSXX("RB3_BSHPJFS", session); + attrMap3 =xml.parseXMLAttr(file3); + if(attrMap3 == null || attrMap3.size() <= 0) { + MessageBox.post("ѡRB3_BSHPJFSδã飡", "WARNING", + MessageBox.WARNING); + return; + } + File file4=xml.getSXX("RB3_SMPJFS", session); + attrMap4 =xml.parseXMLAttr(file4); + if(attrMap4 == null || attrMap4.size() <= 0) { + MessageBox.post("ѡRB3_SMPJFSδã飡", "WARNING", + MessageBox.WARNING); + return; + } + } + System.out.println("className==========="+className); + System.out.println("xmlClassName==========="+xmlClassName); + saveCOM2(xmlClassName,attrMap,attrList,esAttrList,markList,defaultValueList,isNList); + saveCOM(xmlClassName,attrMap2,attrList2,esAttrList2,markList2,isNList2); + if(attrMap3 != null) { + saveCOM(xmlClassName,attrMap3,attrList3,esAttrList3,markList3,isNList3); + saveCOM(xmlClassName,attrMap4,attrList4,esAttrList4,markList4,isNList4); + } + TCComponentICO[] icos = targetRev.getClassificationObjects(); + if(icos == null || icos.length <= 0){ + MessageBox.post("ѡеûз͵࣬뷢ͣ","ʾ",MessageBox.INFORMATION); + return; + } + Map claMap = new HashMap(); + if(icos != null && icos.length>0){ + ICSProperty[] icss = icos[0].getICSProperties(true); + for (ICSProperty ics : icss) { + claMap.put(ics.getId(), ics.getValue()); + } + } + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(xmlClassName); + String cName = c.getName(); + System.out.println("cName==="+cName); + if(PlmLocaleUtil.getString("BearingAccessories").equals(cName)) { + classFlag = false; + } + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + if (icsAttrS != null) { + for (ICSAdminClassAttribute attr : icsAttrS) { + ClassAttributeBean bean = new ClassAttributeBean(); + if (attr.isReferenceAttribute()) {// + continue; + } + if (attr.isReference()) { + continue; + } + int propID = attr.getAttributeId(); + bean.setId(propID); + String propDisName = attr.getName(); + bean.setName(propDisName); + System.out.print("propDisName:"+propDisName); + int attrType = attr.getFormat1().getType(); + bean.setType(attrType); + + if (claMap != null + && claMap.containsKey(propID)) { + bean.setVal(claMap.get(propID)); + } else { + bean.setVal(""); + } + + ICSKeyLov lov1 = attr.getFormat1().getKeyLov(); + lov1 = (lov1 == null ? attr.getFormat2().getKeyLov() : lov1); + if (lov1 != null) { + bean.setIslov(true); + String[] keys = lov1.getKeys(); + Map map1 = new HashMap(); + for (String key : keys) { + String value = lov1.getValueOfKey(key); + map1.put(value, key);// <ʾֵ,ʵֵ> + if(key.equals(bean.getVal())&&(!bean.getVal().equals(""))){ + bean.setVal(value); + } + } + bean.setLov(map1); + } else { + bean.setIslov(false); + } + + classList.add(bean); + + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + + + + + } + + String[] revs = service.getStringValues("RB_Revision_id"); + if(revs == null || revs.length <= 0) { + MessageBox.post("ѡRB_Revision_idδ,ϵԱ!!", + "", MessageBox.ERROR); + return; + } + + revComb = new JComboBox(); + revComb.addItem("B1"); + for (int j = 0; j < revs.length; j++) { + revComb.addItem(revs[j]); + } + + parentPanel.add(i+".1.center.top", new JLabel("汾")); + parentPanel.add(i+".2.center.top", revComb); + i += 1; + + labels1 = new JLabel[classList.size()]; + + for (int j = 0; j(); + comb.setEditable(true); + comb.setSize(new Dimension(60,40)); + comb.addItem(bean.getVal()); + for (Entry entry : bean.getLov().entrySet()) { + if(!(bean.getVal().equals(entry.getKey()))) { + comb.addItem(entry.getKey()); + } + } + map2 = new HashMap(); + map2.put("JComboBox", comb); + values.add(map2); + parentPanel.add(i+".2.center.top", comb); + if(attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, comb); + lovMap.put(attrName, "yes"); + } + if(attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, comb); + lovMap2.put(attrName, "yes"); + } + if(attrMap3 != null) { + if(attrList3.contains(attrName) || esAttrList3.contains(attrName)) { + objMap3.put(attrName, comb); + lovMap3.put(attrName, "yes"); + } + if(attrList4.contains(attrName) || esAttrList4.contains(attrName)) { + objMap4.put(attrName, comb); + lovMap4.put(attrName, "yes"); + } + } + if((PlmLocaleUtil.getString("Category")).equals(attrName)) { + typeList.add(comb); + } + }else{ + JTextField field = new JTextField(18); + map2 = new HashMap(); + map2.put("JTextField", field); + values.add(map2); + parentPanel.add(i+".2.center.top", field); + if(bean.getVal() != null && bean.getVal()!=""){ + field.setText(bean.getVal()); + } + if((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName)) { + JComboBox box = new JComboBox(); + box.addItem(" "); + String[] strs = new String[] {"C0","C2","C3","C4","C5"}; + for (int K = 0; K < strs.length; K++) { + box.addItem(strs[K]); + } + boxMap.put(attrName, box); + parentPanel.add((i)+".3.center.top", box); + } + if(attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, field); + lovMap.put(attrName, "no"); + } + if(attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, field); + lovMap2.put(attrName, "no"); + } + if(attrMap3 != null) { + if(attrList3.contains(attrName) || esAttrList3.contains(attrName)) { + objMap3.put(attrName, field); + lovMap3.put(attrName, "no"); + } + if(attrList4.contains(attrName) || esAttrList4.contains(attrName)) { + objMap4.put(attrName, field); + lovMap4.put(attrName, "no"); + } + } + + } + + } + + + + //Ż + if(targetComp instanceof TCComponentItemRevision) { + targetRev = (TCComponentItemRevision) targetComp; + String revType = targetRev.getType(); + try { + zc_lbj_map = targetRev.getProperties(); + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + + System.out.println("汾:"+revType); + if(revType.equals("RB3_ZCRevision")) { + System.out.println(revType); + boflag=true; + + }else { + System.out.println(revType); + + } + parentPanel.add(i+".1.center.top",new JLabel("******")); + i+=1; + if(boflag) { + // System.out.println("ӵԸ:"+h); + for(int n=0;n disVal=null; + for(int a=0;a(); + disVal.add(disname); + } + } + if(zcprolov!=null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + //ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + + nbox=new RwJComboBox(comboxitems); + nbox.setEditable(true); + nbox.setName("rb3_scgc1"); + nbox.setSize(new Dimension(60,40)); + if(disVal.size()>0) { + StringBuilder sb=new StringBuilder(); + for(int t=0;t(); + zcBox.setSize(new Dimension(60,40)); + zcBox.setName(ZC_LBJ_list.ZCPros.get(n)); + TCProperty zclov = ((TCComponentItemRevision) targetComp).getTCProperty(ZC_LBJ_list.ZCPros.get(n)); + TCComponentListOfValues zcprolov = zclov.getLOV(); + String[] comboxitems; + if(zcprolov!=null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + zcBox.setModel(model); + comboxList.add(zcBox); + } + + zcBox.setSelectedItem(zc_lbj_map.get(ZC_LBJ_list.ZCPros.get(n))); + parentPanel.add((n+i)+".2.center.top",zcBox); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + }else { + JTextField field=new JTextField(18); + field.setName(ZC_LBJ_list.ZCPros.get(n)); + field.setText(zc_lbj_map.get(ZC_LBJ_list.ZCPros.get(n))); + parentPanel.add((n+i)+".2.center.top",field); + fieldList.add(field); + } + } + }else { + for(int n=0;n disVal=null; + for(int a=0;a(); + disVal.add(disname); + } + } + if(zcprolov!=null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + //ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + + nbox=new RwJComboBox(comboxitems); + nbox.setEditable(true); + nbox.setName("rb3_scgc1"); + nbox.setSize(new Dimension(60,40)); + if(disVal.size()>0) { + StringBuilder sb=new StringBuilder(); + for(int t=0;t(); + zcBox.setSize(new Dimension(60,40)); + zcBox.setName(ZC_LBJ_list.LBJPros.get(n)); + TCProperty zclov = ((TCComponentItemRevision) targetComp).getTCProperty(ZC_LBJ_list.LBJPros.get(n)); + TCComponentListOfValues zcprolov = zclov.getLOV(); + String[] comboxitems; + if(zcprolov!=null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + zcBox.setModel(model); + comboxList.add(zcBox); + } + + zcBox.setSelectedItem(zc_lbj_map.get(ZC_LBJ_list.LBJPros.get(n))); + parentPanel.add((n+i)+".2.center.top",zcBox); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }else { + JTextField field=new JTextField(18); + field.setName(ZC_LBJ_list.LBJPros.get(n)); + field.setText(zc_lbj_map.get(ZC_LBJ_list.LBJPros.get(n))); + parentPanel.add((n+i)+".2.center.top",field); + fieldList.add(field); + } + } + } + + } + + + + + + //end Ż + + + + JPanel southPanel = new JPanel(new FlowLayout()); + southPanel.setPreferredSize(new Dimension(250, 80)); + JButton button = new JButton(""); + JButton button1 = new JButton("ȡ"); + button.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // objList.clear(); + // objList2.clear(); + // lovList.clear(); + // lovList2.clear(); + createItem(); + //disposeDialog(); + } + + }); + button1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + + }); + southPanel.add(button); + southPanel.add(button1); + this.add("1.1.center.top",new JLabel(" ")); + this.add("2.1.center.top",classJpanel); + this.add("3.1.center.top",southPanel); + pack(); + centerToScreen(1.0D, 0.75D); + this.showDialog(); + } + private void saveCOM2(String xmlClassName, Map> attrMap, List attrList, + List esAttrList, List markList,List defaultValueList,List isNList) { + if(attrMap.containsKey(xmlClassName)) { + List nameMarkList = attrMap.get(xmlClassName); + String attrNames = nameMarkList.get(0); + String marks = nameMarkList.get(1); + String values = nameMarkList.get(2); + String isN = nameMarkList.get(3); + if(attrNames.contains(";")) { + String[] attrs = attrNames.split(";"); + String[] markss = marks.split(";"); + String[] valuess = values.split(";"); + String[] isNs = isN.split(";"); + for (int i = 0; i < attrs.length; i++) { + if(attrs[i].contains("+")) { + String[] attrss = attrs[i].split("\\+"); + attrList.add(attrss[0]); + esAttrList.add(attrss[1]); + markList.add(markss[i]); + defaultValueList.add(valuess[i]); + isNList.add(isNs[i]); + } + } + } + } + } + private void saveCOM(String xmlClassName, Map> attrMap, List attrList, + List esAttrList, List markList,List isNList) { + if(attrMap.containsKey(xmlClassName)) { + List nameMarkList = attrMap.get(xmlClassName); + String attrNames = nameMarkList.get(0); + String marks = nameMarkList.get(1); + String isN = nameMarkList.get(3); + if(attrNames.contains(";")) { + String[] attrs = attrNames.split(";"); + String[] markss = marks.split(";"); + String[] isNs = isN.split(";"); + for (int i = 0; i < attrs.length; i++) { + if(attrs[i].contains("+")) { + String[] attrss = attrs[i].split("\\+"); + attrList.add(attrss[0]); + esAttrList.add(attrss[1]); + markList.add(markss[i]); + isNList.add(isNs[i]); + } + } + } + } + } + + protected void createItem() { + + // TODO Auto-generated method stub + List zcList = null; + String jhID = ""; + // List asList = Arrays.asList(lovVal); + // List esList = Arrays.asList(esLovVal); + // StringBuilder sb = new StringBuilder(); + // for (int i = 0; i < attrList.size(); i++) { + // String attr = attrList.get(i); + // String esAttr = esAttrList.get(i); + // if(!("".equals(attr.trim()))) { + // JComboBox box = null; + // if((PlmLocale.getString("RadialInternalClearance")).equals(attr) + // || (PlmLocale.getString("PartNumber")).equals(attr)) { + // box = boxMap.get(attr); + // } + // Object obj = objMap.get(attr); + // if(obj == null) { + // JTextField field = (JTextField)objMap.get(esAttr); + // if(box != null) { + // String fieldText = field.getText(); + // String boxText = (String) box.getSelectedItem(); + // if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + // MessageBox.post(esAttr+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + // MessageBox.post(esAttr+"дһֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if(!("".equals(fieldText.trim()))) { + // objList.add(field); + // lovList.add("no"); + // }else { + // objList.add(box); + // lovList.add("yes"); + // } + // }else { + // objList.add(field); + // lovList.add(lovMap.get(esAttr)); + // } + // }else { + // if(box != null) { + // JTextField field = (JTextField)obj; + // String fieldText = field.getText(); + // String boxText = (String) box.getSelectedItem(); + // if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + // MessageBox.post(attr+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + // MessageBox.post(attr+"дһֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if(!("".equals(fieldText.trim()))) { + // objList.add(field); + // lovList.add("no"); + // }else { + // objList.add(box); + // lovList.add("yes"); + // } + // }else { + // objList.add(obj); + // lovList.add(lovMap.get(attr)); + // } + // } + // } + // } + // for (int i = 0; i < attrList2.size(); i++) { + // String attr = attrList2.get(i); + // String esAttr = esAttrList2.get(i); + // if(!("".equals(attr.trim()))) { + // JComboBox box = null; + // if((PlmLocale.getString("RadialInternalClearance")).equals(attr) + // || (PlmLocale.getString("PartNumber")).equals(attr)) { + // box = boxMap.get(attr); + // } + // Object obj = objMap2.get(attr); + // if(obj == null) { + // JTextField field = (JTextField)objMap.get(esAttr); + // if(box != null) { + // String fieldText = field.getText(); + // String boxText = (String) box.getSelectedItem(); + // if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + // MessageBox.post(esAttr+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + // MessageBox.post(esAttr+"дһֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if(!("".equals(fieldText.trim()))) { + // objList2.add(field); + // lovList2.add("no"); + // }else { + // objList2.add(box); + // lovList2.add("yes"); + // } + // }else { + // objList2.add(field); + // lovList2.add(lovMap2.get(esAttr)); + // } + // }else { + // if(box != null) { + // JTextField field = (JTextField)obj; + // String fieldText = field.getText(); + // String boxText = (String) box.getSelectedItem(); + // if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + // MessageBox.post(attr+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + // MessageBox.post(attr+"дһֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if(!("".equals(fieldText.trim()))) { + // objList2.add(field); + // lovList2.add("no"); + // }else { + // objList2.add(box); + // lovList2.add("yes"); + // } + // }else { + // objList2.add(obj); + // lovList2.add(lovMap2.get(attr)); + // } + // } + // } + // } + // for (int i = 0; i < objList.size(); i++) { + // String attrValue = ""; + // if("yes".equals(lovList.get(i))) { + // String value = (String) ((JComboBox) objList.get(i)).getSelectedItem(); + // if(asList.contains(value) || esList.contains(value)) { + // value = ""; + // }else { + // if(value.contains(":")) { + // System.out.println("value============"+value); + // String[] values = value.split(":"); + // value = values[0]; + // }else if(value.contains("")) { + // System.out.println("value============"+value); + // String[] values = value.split(""); + // value = values[0]; + // } + // } + // if("Ʒ".equals(value)) { + // value = ""; + // }else if("".equals(value)) { + // value = "C"; + // }else if("ȴ".equals(value)) { + // value = "R"; + // }else if("".equals(value)) { + // value = "L"; + // }else if("ͼ".equals(value)) { + // value = "D"; + // } + // attrValue = value; + // }else { + // attrValue = ((JTextField) objList.get(i)).getText(); + // } + // String mark = markList.get(i); + // sb.append(mark.trim()); + // sb.append(attrValue); + // } + // productNumber = sb.toString(); + // System.out.println("productNumber============"+productNumber); + // StringBuilder sb2 = new StringBuilder(); + // for (int i = 0; i < objList2.size(); i++) { + // String attrValue = ""; + // String lov = lovList2.get(i); + // System.out.println("lov============="+lov); + // if("yes".equals(lovList2.get(i))) { + // String value = (String) ((JComboBox) objList2.get(i)).getSelectedItem(); + // if(asList.contains(value) || esList.contains(value)) { + // value = ""; + // }else { + // if(value.contains(":")) { + // String[] values = value.split(":"); + // value = values[0]; + // }else if(value.contains("")) { + // String[] values = value.split(""); + // value = values[0]; + // } + // } + // if("Ʒ".equals(value)) { + // value = ""; + // }else if("".equals(value)) { + // value = "C"; + // }else if("ȴ".equals(value)) { + // value = "R"; + // }else if("".equals(value)) { + // value = "L"; + // }else if("ͼ".equals(value)) { + // value = "D"; + // } + // attrValue = value; + // }else { + // attrValue = ((JTextField) objList2.get(i)).getText(); + // } + // System.out.println("attrValue=================="+attrValue); + // String mark = markList2.get(i); + // sb2.append(mark.trim()); + // sb2.append(attrValue); + // } + if(classFlag) { + productNumber = splicValue(attrList,esAttrList,objMap,markList,isNList,lovMap); + drawingNumber = splicValue(attrList2,esAttrList2,objMap2,markList2,isNList2,lovMap2); + + System.out.println("productNumber============"+productNumber); + System.out.println("drawingNumber============"+drawingNumber); + if(productNumber == null || drawingNumber == null) { + return; + } + } + TCComponentItemRevision newRev = null; + String newID = ""; + try { + TCComponentItemType typeComponent = (TCComponentItemType) session + .getTypeComponent(targetType); + if(flag) { + StringBuilder idSb = new StringBuilder(idField.getText()); + String id = ""; + if(idList != null && idList.size() > 0) { + JTextField idField = (JTextField) idList.get(0); + JComboBox idbox = (JComboBox) idList.get(1); + id = idField.getText(); + String boxID = (String) idbox.getSelectedItem(); +// if("".equals(id.trim()) && "".equals(boxID.trim())) { +// MessageBox.post("δд", "ʾ", MessageBox.INFORMATION); +// return; +// } + if("".equals(id.trim())) { + id = boxID; + + } + + jhID = id; + idSb.append(id); + } + String typeID = ""; + if(typeList != null && typeList.size() > 0) { + JComboBox idComb = typeList.get(0); + typeID = (String) idComb.getSelectedItem(); + if(typeID.contains(":")) { + typeID = typeID.split(":")[1]; + }else if(typeID.contains("")) { + typeID = typeID.split("")[1]; + } + if("Ʒ".equals(typeID) || "Finished product".equals(typeID)) { + typeID = ""; + }else if("".equals(typeID) || "Turning workpiece".equals(typeID)) { + typeID = "C"; + }else if("ȴ".equals(typeID) || "Heat treatment parts".equals(typeID)) { + typeID = "R"; + }else if("շ伷".equals(typeID) || "Cold rolled parts or cold extrusion parts".equals(typeID)) { + typeID = "D"; + }else if("ͼ".equals(typeID) || "Forge piece".equals(typeID)) { + typeID = "D"; + } + idSb.append(typeID); + } + + newID = idSb.toString(); + String[] keys = new String[]{" ID"}; + String[] values = new String[]{idField.getText()}; + zcList = queryObject(" ID", keys, values); + if(zcList != null) { + if(zcList.size() > 0) { + if(zcList.get(0) instanceof TCComponentItem) { + TCComponentItem zcItem = (TCComponentItem) zcList.get(0); + TCComponentItemRevision zcRev = zcItem.getLatestItemRevision(); + TCProperty tcProperty = zcRev.getTCProperty("release_status_list"); + TCComponent[] targets = tcProperty.getReferenceValueArray(); + if(targets != null && targets.length >0) { + MessageBox.post("ûйеܳɰ汾󴴽!!","ʾ", MessageBox.WARNING); + return; + } + if(!classFlag) { + productNumber = zcRev.getStringProperty("rb3_th") + id; + drawingNumber = zcRev.getStringProperty("rb3_th") + id; + System.out.println("productNumber============"+productNumber); + System.out.println("drawingNumber============"+drawingNumber); + } + if("RB3_ZC".equals(targetType)) { + List compList = queryObject("RBSearchZCCPH", + new String[] {"Ʒ"}, new String[] {productNumber}); + if(compList != null ) { + if( compList.size() > 0) { + //Ż + String nID=newID.substring(0,2); + + + + for(int j=0;j compList = queryObject("RBSearchLBJCPH", + new String[] {"Ʒ"}, new String[] {productNumber}); + if(compList != null ) { + if(compList.size() > 0) { + //Ż + String nID=newID.substring(0,2); + + + + for(int j=0;j compList = queryObject(" ID", keys, values); + if(compList != null) { + if(compList.size() > 0) { + MessageBox.post("ϵͳѴidΪ"+newID+"ϣ룡", + "", MessageBox.INFORMATION); + return; + } + } + + String revID = (String) revComb.getSelectedItem(); + String name = nameField.getText(); + TCComponentItem newItem = typeComponent.create(newID,revID, targetType, + name, "", null); + if (newItem != null) { + session.getUser().getHomeFolder() + .add("contents", newItem); + session.getUser().getHomeFolder().refresh(); + } + String statu = ""; + if ("A1".equals(revID)) { + statu = ":Conceptual design"; + } else if ("B1".equals(revID)) { + statu = ":Product design"; + } else if ("R1".equals(revID)) { + statu = ":Process design/Sample delivery"; + } else if ("P1".equals(revID)) { + statu = "P:Pilot production/small batch"; + } else if ("M1".equals(revID)) { + statu = "M:Mass production"; + } + newRev = newItem.getLatestItemRevision(); + newRev.setStringProperty("rb3_th", drawingNumber); + newRev.setStringProperty("rb3_cph", productNumber); + newRev.setStringProperty("rb3_smzqzt", statu); + if(!("".equals(jhID))) { + newRev.setStringProperty("rb3_jh", jhID); + } + if(!("".equals(bsNumber))) { + newRev.setStringProperty("rb3_bsh", bsNumber); + newRev.setStringProperty("rb3_sm2", smNumber); + } + + + + + + //Ż + for(int k=0;k proList=new ArrayList<>(); + String[] split = text.split(","); + TCProperty tclov = ((TCComponentItemRevision) targetComp).getTCProperty(key); + TCComponentListOfValues lov = tclov.getLOV(); + for(int p=0;p revList = new ArrayList(); + //öbomline + TCComponentBOMLine line = view.setWindowTopLine(targetRev.getItem(), + targetRev, null, null); + //BOMLINEµbomline + AIFComponentContext[] contexts = line.getChildren(); + for(AIFComponentContext context : contexts){ + InterfaceAIFComponent child = context.getComponent(); + if(child instanceof TCComponentBOMLine){ + TCComponentBOMLine childLine = (TCComponentBOMLine) child; + TCComponentItemRevision itemRevision = childLine.getItemRevision(); + revList.add(itemRevision); + } + } + //ر + view.close(); + view = winType.create(null); + // + view.lock(); + //öbomline + TCComponentBOMLine line1 = view.setWindowTopLine(newRev.getItem(), + newRev, null, null); + for(TCComponentItemRevision revComp : revList){ + //bomline + TCComponentBOMLine childBomline = + line1.add(revComp.getItem(), revComp, null, false, ""); + } + + // + view.save(); + // + view.unlock(); + //ر + view.close(); + newRev.setStringProperty("rb3_zclx", type); + } + TCComponent[] references = targetRev.getReferenceListProperty("TC_Is_Represented_By"); + for (int i = 0; i < references.length; i++) { + if(references[i] instanceof TCComponentItemRevision) { + TCComponentItemRevision pic = (TCComponentItemRevision) references[i]; + newRev.add("TC_Is_Represented_By", pic); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + MessageBox.post("ʧ!!!!", "ʾ", MessageBox.INFORMATION); + e.printStackTrace(); + return; + } + List vals = new ArrayList(); + for (Map value : values) { + for (Map.Entry entry : value.entrySet()) { + String type = entry.getKey(); + if(type.equals("JComboBox")){ + JComboBox comb1 = (JComboBox) entry.getValue(); + String val = (String) comb1.getSelectedItem(); + vals.add(val); + }else{ + JTextField field1 = (JTextField) entry.getValue(); + String val = field1.getText(); + vals.add(val); + } + } + } + Integer[] classKeys = new Integer[classList.size()]; + String[] classVals = new String[classList.size()]; + System.out.println("size============================"+classList.size()); + for(int i=0;i box = boxMap.get(attrName); + val2 = (String) box.getSelectedItem(); + } + } + classVals[i] = val2; + } + sendObjToClassficationByWebService(className,newRev, classKeys, classVals);//ͷ + disposeDialog(); + MessageBox.post("ɹ!!!!", "", MessageBox.INFORMATION); + + } + /** + * ͷ + */ + public void sendObjToClassficationByWebService(String class_id, + TCComponentItemRevision rev, Integer[] keys, String[] vals) { + try { + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList(); + + for (int i = 0; i < keys.length; i++) { + + if(keys[i] != null && vals[i] != null) { + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * ͨѯѯĿ + * + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + return null; + } + } + + public String splicValue(List attrList,List esAttrList, + Map map,List markList,List isNList,Map lovMap) { + // List asList = Arrays.asList(lovVal); + // List esList = Arrays.asList(esLovVal); + List objList = new ArrayList(); + List lovList = new ArrayList(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < attrList.size(); i++) { + String attr = attrList.get(i); + System.out.println("attr======112"+attr); + String esAttr = esAttrList.get(i); + if(map.get(attr) == null && map.get(esAttr) == null) { + if((PlmLocaleUtil.getString("PartNumber")).equals(attr) || + (PlmLocaleUtil.getString("PartNumber")).equals(esAttr)) { + JComboBox idbox = boxMap.get(PlmLocaleUtil.getString("PartNumber")); + JTextField idfield = (JTextField) idList.get(0); + String fieldText = idfield.getText(); + String boxText = (String) idbox.getSelectedItem(); + if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(PlmLocaleUtil.getString("PartNumber")+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } +// if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { +// MessageBox.post(PlmLocaleUtil.getString("PartNumber")+"дһֵ", "ʾ", MessageBox.INFORMATION); +// return null; +// } + if(!("".equals(fieldText.trim()))) { + objList.add(idfield); + lovList.add("no"); + }else { + objList.add(idbox); + lovList.add("yes"); + } + continue; + } + objList.add(defaultValueList.get(i)); + lovList.add("string"); + continue; + } + if(!("".equals(attr.trim()))) { + Object obj = map.get(attr); + JComboBox box = null; + if((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attr)) { + box = boxMap.get(attr); + } + if((PlmLocaleUtil.getString("RadialInternalClearance")).equals(esAttr)) { + box = boxMap.get(esAttr); + } + if(obj == null) { + obj = map.get(esAttr); + if(box != null) { + JTextField field = (JTextField)obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(esAttr+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(esAttr+"дһֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if(!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + }else { + objList.add(box); + lovList.add("yes"); + } + }else { + objList.add(obj); + lovList.add(lovMap.get(esAttr)); + } + }else { + if(box != null) { + JTextField field = (JTextField)obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(attr+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(attr+"дһֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if(!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + }else { + objList.add(box); + lovList.add("yes"); + } + }else { + objList.add(obj); + lovList.add(lovMap.get(attr)); + } + } + } + } + for (int i = 0; i < objList.size(); i++) { + String attrValue = ""; + Object obj = objList.get(i); + if(obj != null ) { + if("yes".equals(lovList.get(i))) { + String value = (String) ((JComboBox) obj).getSelectedItem(); + if(asList.contains(value) || esList.contains(value)) { + if(isNList.get(i).trim().contains(value)) { + if(value.contains(":")) { + System.out.println("value============"+value); + String[] values = value.split(":"); + value = values[0]; + }else if(value.contains("")) { + System.out.println("value============"+value); + String[] values = value.split(""); + value = values[0]; + } + }else { + value = ""; + } + }else { + if(value.contains(":")) { + System.out.println("value============"+value); + String[] values = value.split(":"); + value = values[0]; + }else if(value.contains("")) { + System.out.println("value============"+value); + String[] values = value.split(""); + value = values[0]; + } + } + if("Ʒ".equals(value) || "Finished product".equals(value)) { + value = ""; + }else if("".equals(value) || "Turning workpiece".equals(value)) { + value = "C"; + }else if("ȴ".equals(value) || "Heat treatment parts".equals(value)) { + value = "R"; + }else if("շ伷".equals(value) || "Cold rolled parts or cold extrusion parts".equals(value)) { + value = "D"; + }else if("ͼ".equals(value) || "Forge piece".equals(value)) { + value = "D"; + } + attrValue = value; + }else if("no".equals(lovList.get(i))){ + attrValue = ((JTextField) obj).getText(); + + }else { + attrValue = (String) obj; + } + if(asList.contains(attrValue) || esList.contains(attrValue)) { + attrValue = ""; + }else { + if(attrValue.contains(":")) { + System.out.println("attrValue============"+attrValue); + String[] values = attrValue.split(":"); + attrValue = values[0]; + }else if(attrValue.contains("")) { + System.out.println("attrValue============"+attrValue); + String[] values = attrValue.split(""); + attrValue = values[0]; + } + } + + String mark = markList.get(i); + System.out.println("mark============"+mark); + if(!("".equals(attrValue.trim())) && mark != null) { + sb.append(mark.trim()); + sb.append(attrValue); + } + } + } + return sb.toString(); + } +} diff --git a/src/另存2 b/src/另存2 new file mode 100644 index 0000000..5c3d2de --- /dev/null +++ b/src/另存2 @@ -0,0 +1,1757 @@ +package com.connor.rb.plm.rb011; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Text; + +import com.connor.rb.plm.entity.ZC_LBJ_list; +import com.connor.rb.plm.newcombox.RwJComboBox; +import com.connor.rb.plm.rb012.SearchJComItem; +import com.connor.rb.plm.util.ClassAttributeBean; +import com.connor.rb.plm.util.ClassProperty; +import com.connor.rb.plm.util.ParseXML; +import com.connor.rb.plm.util.PlmLocaleUtil; +import com.connor.rb.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + + +public class CreatDialog extends AbstractAIFDialog { + private AbstractAIFApplication app; + private TCSession session; + private TCPreferenceService service; + private List classList = new ArrayList(); + private JLabel[] labels1 = null; + private JComboBox comb = null; + private String className = ""; + private Map map2; + private List> values = new ArrayList>(); + private String type = ""; + private String targetType = ""; + private JScrollPane scr2; + private boolean flag = true; + private String url = ""; + private TCComponentItemRevision targetRev = null; + private boolean classFlag = true; + private JTextField idField = null; + private JTextField nameField = null; + private JComboBox revComb = null; + private List idList = new ArrayList(); + private List typeList = new ArrayList(); + private String productNumber = ""; + private String drawingNumber = ""; + private Map> attrMap; + private Map> attrMap2; + private Map> attrMap3; + private Map> attrMap4; + private Map> boxMap = new HashMap>(); + private Map objMap = new HashMap(); + private Map objMap2 = new HashMap(); + private Map objMap3 = new HashMap(); + private Map objMap4 = new HashMap(); + private Map lovMap = new HashMap(); + private Map lovMap2 = new HashMap(); + private Map lovMap3 = new HashMap(); + private Map lovMap4 = new HashMap(); + private List defaultValueList = new ArrayList(); + private List isNList = new ArrayList(); + private List isNList2 = new ArrayList(); + private List isNList3 = new ArrayList(); + private List isNList4 = new ArrayList(); + private List markList = new ArrayList(); + private List markList2 = new ArrayList(); + private List markList3 = new ArrayList(); + private List markList4 = new ArrayList(); + private List attrList = new ArrayList(); + private List esAttrList = new ArrayList(); + // private List objList = new ArrayList(); + // private List lovList = new ArrayList(); + private List attrList2 = new ArrayList(); + private List attrList3 = new ArrayList(); + private List attrList4 = new ArrayList(); + private List esAttrList2 = new ArrayList(); + private List esAttrList3 = new ArrayList(); + private List esAttrList4 = new ArrayList(); + private String bsNumber = ""; + private String smNumber = ""; + private List asList = new ArrayList(); + private List esList = new ArrayList(); + private InterfaceAIFComponent targetComp; + //Ż + private Map zc_lbj_map=new HashMap<>(); + private List fieldList=new ArrayList<>(); + private List comboxList=new ArrayList(); + private List yylyList=new ArrayList(); + //private int h=4; + private boolean boflag=false; + private Map fieldmap=new HashMap<>(); + private Map comboxmap=new HashMap<>(); + //endŻ + // private List objList2 = new ArrayList(); + // private List lovList2 = new ArrayList(); + // private String[] lovVal = new String[] { "ǰ", "׼", "޽Ӵ", "ʽ", "ͨ", "A:NBR", "0:", "", "", + // "SN:1805ػ", "ȴ", "", "S:(25% to 35%)", "C0","V0","Z0","׼","PC:ﵽC&UƷƾҪ" + // ,"P0:ﵽC&UƷƾҪ","ṹҪƹ","0:˫нǽӴ",":SECC൱",":벿Ŷȷ","BC:35"}; + // private String[] esLovVal = new String[] { "Non", "Standard ball", "Non", "Open", "Without vent hole", "A:NBR", + // "0:Black", "Non", "Ball", "SN:1805 temper","Conventional monolithic martensite quenching heat treatment", + // "Single", "S:(25% to 35%)", "C0","V0","Z0","Standard","PC:Meet the group C&U brand accuracy requirements" + // ,"P0:Meet the group C&U brand accuracy requirements","Other structures need to formulate rules","0:Double row angular contact ball bearing" + // ,"Not marked: SECC or equivalent","Other materials: confirm with department team for approval","BC:35"}; + + public CreatDialog (AbstractAIFApplication app) { + super(false); + this.app = app; + this.targetComp = app.getTargetComponent(); + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + } + + @Override + public void run() { + String lovVal = service.getStringValue("RB3_lovVal_default"); + String esLovVal = service.getStringValue("RB3_esLovVal_default"); + if(lovVal.contains(";")) { + String[] vals = lovVal.split(";"); + String[] esVals = esLovVal.split(";"); + for (int i = 0; i < vals.length; i++) { + asList.add(vals[i]); + esList.add(esVals[i]); + } + } + ParseXML xml=new ParseXML(); + File file=xml.getSXX("RB3_CPHPJFS", session); + + attrMap =xml.parseXMLAttr(file); + if(attrMap == null || attrMap.size() <= 0) { + MessageBox.post("ѡRB3_CPHPJFSδã飡", "WARNING", + MessageBox.WARNING); + return; + } + File file2=xml.getSXX("RB3_THPJFS", session); + attrMap2 =xml.parseXMLAttr(file2); + if(attrMap2 == null || attrMap2.size() <= 0) { + MessageBox.post("ѡRB3_THPJFSδã飡", "WARNING", + MessageBox.WARNING); + return; + } + this.initUI(); + + } + + public void initUI(){ + setTitle("Ϊ"); + int i = 1; + Dimension dimension = new Dimension(); + this.setLayout(new PropertyLayout()); + dimension.setSize(650,800); + this.setMinimumSize(dimension); + this.setPreferredSize(dimension); + JPanel parentPanel = new JPanel(new PropertyLayout()); + scr2 = new JScrollPane(parentPanel); + scr2.setPreferredSize(new Dimension(640, 700)); + JPanel classJpanel = new JPanel(new PropertyLayout());// Խ + classJpanel.add("1.1.center.top", scr2); + //Żڼ + this.addComponentListener(new ComponentListener() { + + + @Override + public void componentResized(ComponentEvent e) { + // TODO Auto-generated method stub + Component component2=e.getComponent(); + int h=component2.getHeight(); + if(h>800) { + scr2.setPreferredSize(new Dimension(component2.getWidth()-10,h-100)); + scr2.revalidate(); + scr2.repaint(); + classJpanel.setPreferredSize(new Dimension(component2.getWidth(),h-100)); + classJpanel.revalidate(); + classJpanel.repaint(); + } + } + + @Override + public void componentMoved(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void componentShown(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void componentHidden(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + }); + + + //endŻ + + + + + + + if(targetComp instanceof TCComponentItemRevision) { + targetRev = (TCComponentItemRevision) targetComp; + String revType = targetRev.getType(); + try { + targetType = targetRev.getItem().getType(); + System.out.println("revType============"+revType); + nameField = new JTextField(18); + parentPanel.add(i+".1.center.top", new JLabel("")); + i += 1; + if("RB3_ZCRevision".equals(revType)) { + type = targetRev.getStringProperty("rb3_zclx"); + flag = false; + }else if("RB3_LBJRevision".equals(revType)){ + idField = new JTextField(18); + + parentPanel.add(i+".1.center.top", new JLabel("ܳϱ")); + parentPanel.add(i+".2.center.top", idField); + i += 1; + type = targetRev.getStringProperty("rb3_lbjlx"); + } + parentPanel.add(i+".1.center.top", new JLabel("")); + parentPanel.add(i+".2.center.top", nameField); + i += 1; + String name = targetRev.getStringProperty("object_name"); + nameField.setText(name); + className = targetRev.getClassificationClass(); + String xmlClassName = ""; + if(flag) { + xmlClassName = className; + JTextField idfield = new JTextField(18); + idList.add(idfield); + JComboBox idbox = new JComboBox(); + idList.add(idbox); + idbox.addItem(" "); + String[] idstrs = new String[99]; + for (int K = 0; K < 99; K++) { + if(K < 9) { + idstrs[K] = "0"+(K+1); + }else { + idstrs[K] = (K+1)+""; + } + } + for (int K = 0; K < idstrs.length; K++) { + idbox.addItem(idstrs[K]); + } + boxMap.put(PlmLocaleUtil.getString("PartNumber"), idbox); + parentPanel.add((i)+".1.center.top", new JLabel(PlmLocaleUtil.getString("PartNumber"))); + parentPanel.add((i)+".2.center.top", idfield); + parentPanel.add((i)+".3.center.top", idbox); + i += 1; + }else { + xmlClassName = className.substring(0, 6); + ParseXML xml=new ParseXML(); + File file3=xml.getSXX("RB3_BSHPJFS", session); + attrMap3 =xml.parseXMLAttr(file3); + if(attrMap3 == null || attrMap3.size() <= 0) { + MessageBox.post("ѡRB3_BSHPJFSδã飡", "WARNING", + MessageBox.WARNING); + return; + } + File file4=xml.getSXX("RB3_SMPJFS", session); + attrMap4 =xml.parseXMLAttr(file4); + if(attrMap4 == null || attrMap4.size() <= 0) { + MessageBox.post("ѡRB3_SMPJFSδã飡", "WARNING", + MessageBox.WARNING); + return; + } + } + System.out.println("className==========="+className); + System.out.println("xmlClassName==========="+xmlClassName); + saveCOM2(xmlClassName,attrMap,attrList,esAttrList,markList,defaultValueList,isNList); + saveCOM(xmlClassName,attrMap2,attrList2,esAttrList2,markList2,isNList2); + if(attrMap3 != null) { + saveCOM(xmlClassName,attrMap3,attrList3,esAttrList3,markList3,isNList3); + saveCOM(xmlClassName,attrMap4,attrList4,esAttrList4,markList4,isNList4); + } + TCComponentICO[] icos = targetRev.getClassificationObjects(); + if(icos == null || icos.length <= 0){ + MessageBox.post("ѡеûз͵࣬뷢ͣ","ʾ",MessageBox.INFORMATION); + return; + } + Map claMap = new HashMap(); + if(icos != null && icos.length>0){ + ICSProperty[] icss = icos[0].getICSProperties(true); + for (ICSProperty ics : icss) { + claMap.put(ics.getId(), ics.getValue()); + } + } + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(xmlClassName); + String cName = c.getName(); + System.out.println("cName==="+cName); + if(PlmLocaleUtil.getString("BearingAccessories").equals(cName)) { + classFlag = false; + } + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + if (icsAttrS != null) { + for (ICSAdminClassAttribute attr : icsAttrS) { + ClassAttributeBean bean = new ClassAttributeBean(); + if (attr.isReferenceAttribute()) {// + continue; + } + if (attr.isReference()) { + continue; + } + int propID = attr.getAttributeId(); + bean.setId(propID); + String propDisName = attr.getName(); + bean.setName(propDisName); + System.out.print("propDisName:"+propDisName); + int attrType = attr.getFormat1().getType(); + bean.setType(attrType); + + if (claMap != null + && claMap.containsKey(propID)) { + bean.setVal(claMap.get(propID)); + } else { + bean.setVal(""); + } + + ICSKeyLov lov1 = attr.getFormat1().getKeyLov(); + lov1 = (lov1 == null ? attr.getFormat2().getKeyLov() : lov1); + if (lov1 != null) { + bean.setIslov(true); + String[] keys = lov1.getKeys(); + Map map1 = new HashMap(); + for (String key : keys) { + String value = lov1.getValueOfKey(key); + map1.put(value, key);// <ʾֵ,ʵֵ> + if(key.equals(bean.getVal())&&(!bean.getVal().equals(""))){ + bean.setVal(value); + } + } + bean.setLov(map1); + } else { + bean.setIslov(false); + } + + classList.add(bean); + + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + + + + + } + + String[] revs = service.getStringValues("RB_Revision_id"); + if(revs == null || revs.length <= 0) { + MessageBox.post("ѡRB_Revision_idδ,ϵԱ!!", + "", MessageBox.ERROR); + return; + } + + revComb = new JComboBox(); + revComb.addItem("B1"); + //Ż + revComb.setEditable(false); + //end + for (int j = 0; j < revs.length; j++) { + revComb.addItem(revs[j]); + } + + parentPanel.add(i+".1.center.top", new JLabel("汾")); + parentPanel.add(i+".2.center.top", revComb); + i += 1; + + labels1 = new JLabel[classList.size()]; + + for (int j = 0; j comb = new JComboBox(); + //Ż + JTextField jt=new JTextField(9); + JButton bu=new JButton(""); + //end + comb.setEditable(false); + comb.setSize(new Dimension(60,40)); + comb.addItem(bean.getVal()); + for (Entry entry : bean.getLov().entrySet()) { + if(!(bean.getVal().equals(entry.getKey()))) { + comb.addItem(entry.getKey()); + } + } + //Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip=jt.getText(); + System.out.println(""+tip); + if(tip.length()>0) { + SearchJComItem.changeBox(comb, tip); + } + } + + }); + //end + map2 = new HashMap(); + map2.put("JComboBox", comb); + values.add(map2); + parentPanel.add(i+".2.center.top", comb); + parentPanel.add(i+".3.center.top", jt); + parentPanel.add(i+".4.center.top", bu); + + + if(attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, comb); + lovMap.put(attrName, "yes"); + } + if(attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, comb); + lovMap2.put(attrName, "yes"); + } + if(attrMap3 != null) { + if(attrList3.contains(attrName) || esAttrList3.contains(attrName)) { + objMap3.put(attrName, comb); + lovMap3.put(attrName, "yes"); + } + if(attrList4.contains(attrName) || esAttrList4.contains(attrName)) { + objMap4.put(attrName, comb); + lovMap4.put(attrName, "yes"); + } + } + if((PlmLocaleUtil.getString("Category")).equals(attrName)) { + typeList.add(comb); + } + }else{ + JTextField field = new JTextField(18); + + map2 = new HashMap(); + map2.put("JTextField", field); + values.add(map2); + parentPanel.add(i+".2.center.top", field); + if(bean.getVal() != null && bean.getVal()!=""){ + field.setText(bean.getVal()); + } + if((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName)) { + JComboBox box = new JComboBox(); + //Ż + JTextField jt=new JTextField(9); + JButton bu=new JButton(""); + //end + box.addItem(" "); + String[] strs = new String[] {"C0","C2","C3","C4","C5"}; + for (int K = 0; K < strs.length; K++) { + box.addItem(strs[K]); + } + //Ż + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip=jt.getText(); + System.out.println(""+tip); + if(tip.length()>0) { + SearchJComItem.changeBox(comb, tip); + } + } + + }); + //end + boxMap.put(attrName, box); + parentPanel.add((i)+".3.center.top", box); + parentPanel.add((i)+".3.center.top", jt); + parentPanel.add((i)+".3.center.top", bu); + } + if(attrList.contains(attrName) || esAttrList.contains(attrName)) { + objMap.put(attrName, field); + lovMap.put(attrName, "no"); + } + if(attrList2.contains(attrName) || esAttrList2.contains(attrName)) { + objMap2.put(attrName, field); + lovMap2.put(attrName, "no"); + } + if(attrMap3 != null) { + if(attrList3.contains(attrName) || esAttrList3.contains(attrName)) { + objMap3.put(attrName, field); + lovMap3.put(attrName, "no"); + } + if(attrList4.contains(attrName) || esAttrList4.contains(attrName)) { + objMap4.put(attrName, field); + lovMap4.put(attrName, "no"); + } + } + + } + + } + + + + //Ż + if(targetComp instanceof TCComponentItemRevision) { + targetRev = (TCComponentItemRevision) targetComp; + String revType = targetRev.getType(); + try { + zc_lbj_map = targetRev.getProperties(); + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + + System.out.println("汾:"+revType); + if(revType.equals("RB3_ZCRevision")) { + System.out.println(revType); + boflag=true; + + }else { + System.out.println(revType); + + } + parentPanel.add(i+".1.center.top",new JLabel(" ")); + parentPanel.add(i+".2.center.top",new JLabel("**********************")); + i+=1; + if(boflag) { + // System.out.println("ӵԸ:"+h); + for(int n=0;n disVal=new ArrayList(); + for(int a=0;a0) { + StringBuilder sb=new StringBuilder(); + for(int t=0;t disVal=new ArrayList(); + if(vals.length>0) { + for(int e=0;e0) { + comboxitems=new String[yylyList.size()]; + for(int g=0;g0) { + StringBuilder sb=new StringBuilder(); + for(int t=0;t(); + zcBox.setSize(new Dimension(60,40)); + zcBox.setName(ZC_LBJ_list.ZCPros.get(n)); + TCProperty zclov = ((TCComponentItemRevision) targetComp).getTCProperty(ZC_LBJ_list.ZCPros.get(n)); + TCComponentListOfValues zcprolov = zclov.getLOV(); + String[] comboxitems; + JTextField jt=new JTextField(9); + JButton bu=new JButton(""); + if(zcprolov!=null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + zcBox.setModel(model); + + + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip=jt.getText(); + System.out.println(""+tip); + if(tip.length()>0) { + SearchJComItem.changeBox(zcBox, tip); + } + } + + }); + + comboxList.add(zcBox); + } + + zcBox.setSelectedItem(zc_lbj_map.get(ZC_LBJ_list.ZCPros.get(n))); + if((ZC_LBJ_list.ZCDisPros.get(n)).equals("ʱϱʶ")) { + zcBox.setSelectedIndex(-1); + } + parentPanel.add((n+i)+".2.center.top",zcBox); + parentPanel.add((n+i)+".3.center.top",jt); + parentPanel.add((n+i)+".4.center.top",bu); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + }else { + JTextField field=new JTextField(18); + field.setName(ZC_LBJ_list.ZCPros.get(n)); + field.setText(zc_lbj_map.get(ZC_LBJ_list.ZCPros.get(n))); + parentPanel.add((n+i)+".2.center.top",field); + fieldList.add(field); + } + } + }else { + for(int n=0;n disVal=new ArrayList(); + for(int a=0;a0) { + StringBuilder sb=new StringBuilder(); + for(int t=0;t(); + zcBox.setSize(new Dimension(60,40)); + zcBox.setName(ZC_LBJ_list.LBJPros.get(n)); + TCProperty zclov = ((TCComponentItemRevision) targetComp).getTCProperty(ZC_LBJ_list.LBJPros.get(n)); + TCComponentListOfValues zcprolov = zclov.getLOV(); + String[] comboxitems; + JTextField jt=new JTextField(9); + JButton bu=new JButton(""); + if(zcprolov!=null) { + comboxitems = zcprolov.getListOfValues().getLOVDisplayValues(); + ComboBoxModel model = new DefaultComboBoxModel(comboxitems); + zcBox.setModel(model); + + + bu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String tip=jt.getText(); + System.out.println(""+tip); + if(tip.length()>0) { + SearchJComItem.changeBox(zcBox, tip); + } + } + + }); + + comboxList.add(zcBox); + } + + zcBox.setSelectedItem(zc_lbj_map.get(ZC_LBJ_list.LBJPros.get(n))); + if((ZC_LBJ_list.LBJDisPros.get(n)).equals("ʱϱʶ")) { + zcBox.setSelectedIndex(-1); + } + parentPanel.add((n+i)+".2.center.top",zcBox); + parentPanel.add((n+i)+".3.center.top",jt); + parentPanel.add((n+i)+".4.center.top",bu); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }else { + JTextField field=new JTextField(18); + field.setName(ZC_LBJ_list.LBJPros.get(n)); + field.setText(zc_lbj_map.get(ZC_LBJ_list.LBJPros.get(n))); + parentPanel.add((n+i)+".2.center.top",field); + fieldList.add(field); + } + } + } + + } + + + + + + //end Ż + + + + JPanel southPanel = new JPanel(new FlowLayout()); + southPanel.setPreferredSize(new Dimension(250, 80)); + JButton button = new JButton(""); + JButton button1 = new JButton("ȡ"); + button.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // objList.clear(); + // objList2.clear(); + // lovList.clear(); + // lovList2.clear(); + createItem(); + //disposeDialog(); + } + + }); + button1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + + }); + southPanel.add(button); + southPanel.add(button1); + this.add("1.1.center.top",new JLabel(" ")); + this.add("2.1.center.top",classJpanel); + this.add("3.1.center.top",southPanel); + pack(); + centerToScreen(1.0D, 0.75D); + this.showDialog(); + } + private void saveCOM2(String xmlClassName, Map> attrMap, List attrList, + List esAttrList, List markList,List defaultValueList,List isNList) { + if(attrMap.containsKey(xmlClassName)) { + List nameMarkList = attrMap.get(xmlClassName); + String attrNames = nameMarkList.get(0); + String marks = nameMarkList.get(1); + String values = nameMarkList.get(2); + String isN = nameMarkList.get(3); + if(attrNames.contains(";")) { + String[] attrs = attrNames.split(";"); + String[] markss = marks.split(";"); + String[] valuess = values.split(";"); + String[] isNs = isN.split(";"); + for (int i = 0; i < attrs.length; i++) { + if(attrs[i].contains("+")) { + String[] attrss = attrs[i].split("\\+"); + attrList.add(attrss[0]); + esAttrList.add(attrss[1]); + markList.add(markss[i]); + defaultValueList.add(valuess[i]); + isNList.add(isNs[i]); + } + } + } + } + } + private void saveCOM(String xmlClassName, Map> attrMap, List attrList, + List esAttrList, List markList,List isNList) { + if(attrMap.containsKey(xmlClassName)) { + List nameMarkList = attrMap.get(xmlClassName); + String attrNames = nameMarkList.get(0); + String marks = nameMarkList.get(1); + String isN = nameMarkList.get(3); + if(attrNames.contains(";")) { + String[] attrs = attrNames.split(";"); + String[] markss = marks.split(";"); + String[] isNs = isN.split(";"); + for (int i = 0; i < attrs.length; i++) { + if(attrs[i].contains("+")) { + String[] attrss = attrs[i].split("\\+"); + attrList.add(attrss[0]); + esAttrList.add(attrss[1]); + markList.add(markss[i]); + isNList.add(isNs[i]); + } + } + } + } + } + + protected void createItem() { + + // TODO Auto-generated method stub + List zcList = null; + String jhID = ""; + // List asList = Arrays.asList(lovVal); + // List esList = Arrays.asList(esLovVal); + // StringBuilder sb = new StringBuilder(); + // for (int i = 0; i < attrList.size(); i++) { + // String attr = attrList.get(i); + // String esAttr = esAttrList.get(i); + // if(!("".equals(attr.trim()))) { + // JComboBox box = null; + // if((PlmLocale.getString("RadialInternalClearance")).equals(attr) + // || (PlmLocale.getString("PartNumber")).equals(attr)) { + // box = boxMap.get(attr); + // } + // Object obj = objMap.get(attr); + // if(obj == null) { + // JTextField field = (JTextField)objMap.get(esAttr); + // if(box != null) { + // String fieldText = field.getText(); + // String boxText = (String) box.getSelectedItem(); + // if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + // MessageBox.post(esAttr+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + // MessageBox.post(esAttr+"дһֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if(!("".equals(fieldText.trim()))) { + // objList.add(field); + // lovList.add("no"); + // }else { + // objList.add(box); + // lovList.add("yes"); + // } + // }else { + // objList.add(field); + // lovList.add(lovMap.get(esAttr)); + // } + // }else { + // if(box != null) { + // JTextField field = (JTextField)obj; + // String fieldText = field.getText(); + // String boxText = (String) box.getSelectedItem(); + // if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + // MessageBox.post(attr+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + // MessageBox.post(attr+"дһֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if(!("".equals(fieldText.trim()))) { + // objList.add(field); + // lovList.add("no"); + // }else { + // objList.add(box); + // lovList.add("yes"); + // } + // }else { + // objList.add(obj); + // lovList.add(lovMap.get(attr)); + // } + // } + // } + // } + // for (int i = 0; i < attrList2.size(); i++) { + // String attr = attrList2.get(i); + // String esAttr = esAttrList2.get(i); + // if(!("".equals(attr.trim()))) { + // JComboBox box = null; + // if((PlmLocale.getString("RadialInternalClearance")).equals(attr) + // || (PlmLocale.getString("PartNumber")).equals(attr)) { + // box = boxMap.get(attr); + // } + // Object obj = objMap2.get(attr); + // if(obj == null) { + // JTextField field = (JTextField)objMap.get(esAttr); + // if(box != null) { + // String fieldText = field.getText(); + // String boxText = (String) box.getSelectedItem(); + // if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + // MessageBox.post(esAttr+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + // MessageBox.post(esAttr+"дһֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if(!("".equals(fieldText.trim()))) { + // objList2.add(field); + // lovList2.add("no"); + // }else { + // objList2.add(box); + // lovList2.add("yes"); + // } + // }else { + // objList2.add(field); + // lovList2.add(lovMap2.get(esAttr)); + // } + // }else { + // if(box != null) { + // JTextField field = (JTextField)obj; + // String fieldText = field.getText(); + // String boxText = (String) box.getSelectedItem(); + // if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + // MessageBox.post(attr+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + // MessageBox.post(attr+"дһֵ", "ʾ", MessageBox.INFORMATION); + // return; + // } + // if(!("".equals(fieldText.trim()))) { + // objList2.add(field); + // lovList2.add("no"); + // }else { + // objList2.add(box); + // lovList2.add("yes"); + // } + // }else { + // objList2.add(obj); + // lovList2.add(lovMap2.get(attr)); + // } + // } + // } + // } + // for (int i = 0; i < objList.size(); i++) { + // String attrValue = ""; + // if("yes".equals(lovList.get(i))) { + // String value = (String) ((JComboBox) objList.get(i)).getSelectedItem(); + // if(asList.contains(value) || esList.contains(value)) { + // value = ""; + // }else { + // if(value.contains(":")) { + // System.out.println("value============"+value); + // String[] values = value.split(":"); + // value = values[0]; + // }else if(value.contains("")) { + // System.out.println("value============"+value); + // String[] values = value.split(""); + // value = values[0]; + // } + // } + // if("Ʒ".equals(value)) { + // value = ""; + // }else if("".equals(value)) { + // value = "C"; + // }else if("ȴ".equals(value)) { + // value = "R"; + // }else if("".equals(value)) { + // value = "L"; + // }else if("ͼ".equals(value)) { + // value = "D"; + // } + // attrValue = value; + // }else { + // attrValue = ((JTextField) objList.get(i)).getText(); + // } + // String mark = markList.get(i); + // sb.append(mark.trim()); + // sb.append(attrValue); + // } + // productNumber = sb.toString(); + // System.out.println("productNumber============"+productNumber); + // StringBuilder sb2 = new StringBuilder(); + // for (int i = 0; i < objList2.size(); i++) { + // String attrValue = ""; + // String lov = lovList2.get(i); + // System.out.println("lov============="+lov); + // if("yes".equals(lovList2.get(i))) { + // String value = (String) ((JComboBox) objList2.get(i)).getSelectedItem(); + // if(asList.contains(value) || esList.contains(value)) { + // value = ""; + // }else { + // if(value.contains(":")) { + // String[] values = value.split(":"); + // value = values[0]; + // }else if(value.contains("")) { + // String[] values = value.split(""); + // value = values[0]; + // } + // } + // if("Ʒ".equals(value)) { + // value = ""; + // }else if("".equals(value)) { + // value = "C"; + // }else if("ȴ".equals(value)) { + // value = "R"; + // }else if("".equals(value)) { + // value = "L"; + // }else if("ͼ".equals(value)) { + // value = "D"; + // } + // attrValue = value; + // }else { + // attrValue = ((JTextField) objList2.get(i)).getText(); + // } + // System.out.println("attrValue=================="+attrValue); + // String mark = markList2.get(i); + // sb2.append(mark.trim()); + // sb2.append(attrValue); + // } + if(classFlag) { + productNumber = splicValue(attrList,esAttrList,objMap,markList,isNList,lovMap); + drawingNumber = splicValue(attrList2,esAttrList2,objMap2,markList2,isNList2,lovMap2); + + System.out.println("productNumber============"+productNumber); + System.out.println("drawingNumber============"+drawingNumber); + if(productNumber == null || drawingNumber == null) { + return; + } + } + TCComponentItemRevision newRev = null; + String newID = ""; + try { + TCComponentItemType typeComponent = (TCComponentItemType) session + .getTypeComponent(targetType); + if(flag) { + StringBuilder idSb = new StringBuilder(idField.getText()); + String id = ""; + if(idList != null && idList.size() > 0) { + JTextField idField = (JTextField) idList.get(0); + JComboBox idbox = (JComboBox) idList.get(1); + id = idField.getText(); + String boxID = (String) idbox.getSelectedItem(); +// if("".equals(id.trim()) && "".equals(boxID.trim())) { +// MessageBox.post("δд", "ʾ", MessageBox.INFORMATION); +// return; +// } + if("".equals(id.trim())) { + id = boxID; + + } + + jhID = id; + idSb.append(id); + } + String typeID = ""; + if(typeList != null && typeList.size() > 0) { + JComboBox idComb = typeList.get(0); + typeID = (String) idComb.getSelectedItem(); + if(typeID.contains(":")) { + typeID = typeID.split(":")[1]; + }else if(typeID.contains("")) { + typeID = typeID.split("")[1]; + } + if("Ʒ".equals(typeID) || "Finished product".equals(typeID)) { + typeID = ""; + }else if("".equals(typeID) || "Turning workpiece".equals(typeID)) { + typeID = "C"; + }else if("ȴ".equals(typeID) || "Heat treatment parts".equals(typeID)) { + typeID = "R"; + }else if("շ伷".equals(typeID) || "Cold rolled parts or cold extrusion parts".equals(typeID)) { + typeID = "D"; + }else if("ͼ".equals(typeID) || "Forge piece".equals(typeID)) { + typeID = "D"; + } + idSb.append(typeID); + } + + newID = idSb.toString(); + String[] keys = new String[]{" ID"}; + String[] values = new String[]{idField.getText()}; + zcList = queryObject(" ID", keys, values); + if(zcList != null) { + if(zcList.size() > 0) { + if(zcList.get(0) instanceof TCComponentItem) { + TCComponentItem zcItem = (TCComponentItem) zcList.get(0); + TCComponentItemRevision zcRev = zcItem.getLatestItemRevision(); + TCProperty tcProperty = zcRev.getTCProperty("release_status_list"); + TCComponent[] targets = tcProperty.getReferenceValueArray(); + if(targets != null && targets.length >0) { + MessageBox.post("ûйеܳɰ汾󴴽!!","ʾ", MessageBox.WARNING); + return; + } + if(!classFlag) { + productNumber = zcRev.getStringProperty("rb3_th") + id; + drawingNumber = zcRev.getStringProperty("rb3_th") + id; + System.out.println("productNumber============"+productNumber); + System.out.println("drawingNumber============"+drawingNumber); + } + if("RB3_ZC".equals(targetType)) { + List compList = queryObject("RBSearchZCCPH", + new String[] {"Ʒ"}, new String[] {productNumber}); + if(compList != null ) { + if( compList.size() > 0) { + //Ż + String nID=newID.substring(0,2); + + + + for(int j=0;j compList = queryObject("RBSearchLBJCPH", + new String[] {"Ʒ"}, new String[] {productNumber}); + if(compList != null ) { + if(compList.size() > 0) { + //Ż + String nID=newID.substring(0,2); + + + + for(int j=0;j compList = queryObject(" ID", keys, values); + if(compList != null) { + if(compList.size() > 0) { + MessageBox.post("ϵͳѴidΪ"+newID+"ϣ룡", + "", MessageBox.INFORMATION); + return; + } + } + + String revID = (String) revComb.getSelectedItem(); + String name = nameField.getText(); + TCComponentItem newItem = typeComponent.create(newID,revID, targetType, + name, "", null); + if (newItem != null) { + session.getUser().getHomeFolder() + .add("contents", newItem); + session.getUser().getHomeFolder().refresh(); + } + String statu = ""; + if ("A1".equals(revID)) { + statu = ":Conceptual design"; + } else if ("B1".equals(revID)) { + statu = ":Product design"; + } else if ("R1".equals(revID)) { + statu = ":Process design/Sample delivery"; + } else if ("P1".equals(revID)) { + statu = "P:Pilot production/small batch"; + } else if ("M1".equals(revID)) { + statu = "M:Mass production"; + } + newRev = newItem.getLatestItemRevision(); + newRev.setStringProperty("rb3_th", drawingNumber); + newRev.setStringProperty("rb3_cph", productNumber); + newRev.setStringProperty("rb3_smzqzt", statu); + if(!("".equals(jhID))) { + newRev.setStringProperty("rb3_jh", jhID); + } + if(!("".equals(bsNumber))) { + newRev.setStringProperty("rb3_bsh", bsNumber); + newRev.setStringProperty("rb3_sm2", smNumber); + } + + + + + + //Ż + for(int k=0;k proList=new ArrayList<>(); + String[] split = text.split(","); + TCProperty tclov = ((TCComponentItemRevision) targetComp).getTCProperty(key); + TCComponentListOfValues lov = tclov.getLOV(); + for(int p=0;p revList = new ArrayList(); + //öbomline + TCComponentBOMLine line = view.setWindowTopLine(targetRev.getItem(), + targetRev, null, null); + //BOMLINEµbomline + AIFComponentContext[] contexts = line.getChildren(); + for(AIFComponentContext context : contexts){ + InterfaceAIFComponent child = context.getComponent(); + if(child instanceof TCComponentBOMLine){ + TCComponentBOMLine childLine = (TCComponentBOMLine) child; + TCComponentItemRevision itemRevision = childLine.getItemRevision(); + revList.add(itemRevision); + } + } + //ر + view.close(); + view = winType.create(null); + // + view.lock(); + //öbomline + TCComponentBOMLine line1 = view.setWindowTopLine(newRev.getItem(), + newRev, null, null); + for(TCComponentItemRevision revComp : revList){ + //bomline + TCComponentBOMLine childBomline = + line1.add(revComp.getItem(), revComp, null, false, ""); + } + + // + view.save(); + // + view.unlock(); + //ر + view.close(); + newRev.setStringProperty("rb3_zclx", type); + } + TCComponent[] references = targetRev.getReferenceListProperty("TC_Is_Represented_By"); + for (int i = 0; i < references.length; i++) { + if(references[i] instanceof TCComponentItemRevision) { + TCComponentItemRevision pic = (TCComponentItemRevision) references[i]; + newRev.add("TC_Is_Represented_By", pic); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + MessageBox.post("ʧ!!!!", "ʾ", MessageBox.INFORMATION); + e.printStackTrace(); + return; + } + List vals = new ArrayList(); + for (Map value : values) { + for (Map.Entry entry : value.entrySet()) { + String type = entry.getKey(); + if(type.equals("JComboBox")){ + JComboBox comb1 = (JComboBox) entry.getValue(); + String val = (String) comb1.getSelectedItem(); + vals.add(val); + }else{ + JTextField field1 = (JTextField) entry.getValue(); + String val = field1.getText(); + vals.add(val); + } + } + } + Integer[] classKeys = new Integer[classList.size()]; + String[] classVals = new String[classList.size()]; + System.out.println("size============================"+classList.size()); + for(int i=0;i box = boxMap.get(attrName); + val2 = (String) box.getSelectedItem(); + } + } + classVals[i] = val2; + } + sendObjToClassficationByWebService(className,newRev, classKeys, classVals);//ͷ + disposeDialog(); + MessageBox.post("ɹ!!!!", "", MessageBox.INFORMATION); + + } + /** + * ͷ + */ + public void sendObjToClassficationByWebService(String class_id, + TCComponentItemRevision rev, Integer[] keys, String[] vals) { + try { + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList(); + + for (int i = 0; i < keys.length; i++) { + + if(keys[i] != null && vals[i] != null) { + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * ͨѯѯĿ + * + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + return null; + } + } + + public String splicValue(List attrList,List esAttrList, + Map map,List markList,List isNList,Map lovMap) { + // List asList = Arrays.asList(lovVal); + // List esList = Arrays.asList(esLovVal); + List objList = new ArrayList(); + List lovList = new ArrayList(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < attrList.size(); i++) { + String attr = attrList.get(i); + System.out.println("attr======112"+attr); + String esAttr = esAttrList.get(i); + if(map.get(attr) == null && map.get(esAttr) == null) { + if((PlmLocaleUtil.getString("PartNumber")).equals(attr) || + (PlmLocaleUtil.getString("PartNumber")).equals(esAttr)) { + JComboBox idbox = boxMap.get(PlmLocaleUtil.getString("PartNumber")); + JTextField idfield = (JTextField) idList.get(0); + String fieldText = idfield.getText(); + String boxText = (String) idbox.getSelectedItem(); + if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(PlmLocaleUtil.getString("PartNumber")+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } +// if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { +// MessageBox.post(PlmLocaleUtil.getString("PartNumber")+"дһֵ", "ʾ", MessageBox.INFORMATION); +// return null; +// } + if(!("".equals(fieldText.trim()))) { + objList.add(idfield); + lovList.add("no"); + }else { + objList.add(idbox); + lovList.add("yes"); + } + continue; + } + objList.add(defaultValueList.get(i)); + lovList.add("string"); + continue; + } + if(!("".equals(attr.trim()))) { + Object obj = map.get(attr); + JComboBox box = null; + if((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attr)) { + box = boxMap.get(attr); + } + if((PlmLocaleUtil.getString("RadialInternalClearance")).equals(esAttr)) { + box = boxMap.get(esAttr); + } + if(obj == null) { + obj = map.get(esAttr); + if(box != null) { + JTextField field = (JTextField)obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(esAttr+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(esAttr+"дһֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if(!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + }else { + objList.add(box); + lovList.add("yes"); + } + }else { + objList.add(obj); + lovList.add(lovMap.get(esAttr)); + } + }else { + if(box != null) { + JTextField field = (JTextField)obj; + String fieldText = field.getText(); + String boxText = (String) box.getSelectedItem(); + if(!("".equals(fieldText.trim())) && !("".equals(boxText.trim()))) { + MessageBox.post(attr+"ͬʱдֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if("".equals(fieldText.trim()) && "".equals(boxText.trim())) { + MessageBox.post(attr+"дһֵ", "ʾ", MessageBox.INFORMATION); + return null; + } + if(!("".equals(fieldText.trim()))) { + objList.add(field); + lovList.add("no"); + }else { + objList.add(box); + lovList.add("yes"); + } + }else { + objList.add(obj); + lovList.add(lovMap.get(attr)); + } + } + } + } + for (int i = 0; i < objList.size(); i++) { + String attrValue = ""; + Object obj = objList.get(i); + if(obj != null ) { + if("yes".equals(lovList.get(i))) { + String value = (String) ((JComboBox) obj).getSelectedItem(); + if(asList.contains(value) || esList.contains(value)) { + if(isNList.get(i).trim().contains(value)) { + if(value.contains(":")) { + System.out.println("value============"+value); + String[] values = value.split(":"); + value = values[0]; + }else if(value.contains("")) { + System.out.println("value============"+value); + String[] values = value.split(""); + value = values[0]; + } + }else { + value = ""; + } + }else { + if(value.contains(":")) { + System.out.println("value============"+value); + String[] values = value.split(":"); + value = values[0]; + }else if(value.contains("")) { + System.out.println("value============"+value); + String[] values = value.split(""); + value = values[0]; + } + } + if("Ʒ".equals(value) || "Finished product".equals(value)) { + value = ""; + }else if("".equals(value) || "Turning workpiece".equals(value)) { + value = "C"; + }else if("ȴ".equals(value) || "Heat treatment parts".equals(value)) { + value = "R"; + }else if("շ伷".equals(value) || "Cold rolled parts or cold extrusion parts".equals(value)) { + value = "D"; + }else if("ͼ".equals(value) || "Forge piece".equals(value)) { + value = "D"; + } + attrValue = value; + }else if("no".equals(lovList.get(i))){ + attrValue = ((JTextField) obj).getText(); + + }else { + attrValue = (String) obj; + } + if(asList.contains(attrValue) || esList.contains(attrValue)) { + attrValue = ""; + }else { + if(attrValue.contains(":")) { + System.out.println("attrValue============"+attrValue); + String[] values = attrValue.split(":"); + attrValue = values[0]; + }else if(attrValue.contains("")) { + System.out.println("attrValue============"+attrValue); + String[] values = attrValue.split(""); + attrValue = values[0]; + } + } + + String mark = markList.get(i); + System.out.println("mark============"+mark); + if(!("".equals(attrValue.trim())) && mark != null) { + sb.append(mark.trim()); + sb.append(attrValue); + } + } + } + return sb.toString(); + } +} diff --git a/src/编码器 b/src/编码器 new file mode 100644 index 0000000..e8e73ed --- /dev/null +++ b/src/编码器 @@ -0,0 +1,4954 @@ +/** + * @author tyl + * @Action ini + * 2011-4-4 + */ +package cn.com.origin.autocode.newitem.generatcode; + +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.datatransfer.StringSelection; +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.math.BigInteger; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.JDialog; +import javax.xml.bind.JAXBException; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CTabFolder; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.custom.ScrolledComposite; +import org.eclipse.swt.events.ControlAdapter; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.VerifyEvent; +import org.eclipse.swt.events.VerifyListener; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.DateTime; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.widgets.Widget; + +import cn.com.origin.autocode.jfom.util.ChangTextField; +import cn.com.origin.autocode.jfom.util.ClassProperty; +import cn.com.origin.autocode.jfom.util.JFomMethodUtil; +import cn.com.origin.autocode.jfom.util.JFomUtil; +import cn.com.origin.autocode.jfom.util.SoaServerUtil; +import cn.com.origin.autocode.newitem.origin.ORAfterNewItemCustomization; +import cn.com.origin.autocode.newitem.origin.ORCreateICOObject; +import cn.com.origin.autocode.newitem.origin.ORSaveObjectDescOperation; +import cn.com.origin.autocode.newitem.system.ORItemInfoPanel; +import cn.com.origin.autocode.newitem.system.ORNewItemDialog; +import cn.com.origin.autocode.saveas.ORSaveItemAsDialog; +import cn.com.origin.autocode.views.itemtypeview.NewItemClassificationView; +import cn.com.origin.autocode.xmlutil.CNCompontent; +import cn.com.origin.autocode.xmlutil.CNPart; +import cn.com.origin.autocode.xmlutil.CNPartList; +import cn.com.origin.autocode.xmlutil.CNProperty; +import cn.com.origin.autocode.xmlutil.CNXmlUtil; +import cn.com.origin.autocode.xmlutil.ParseXMLUtil; +import cn.com.origin.autocodemanager.common.AutoCodeManagerPropertyName; +import cn.com.origin.autocodemanager.common.CreateCompositeUtil; +import cn.com.origin.autocodemanager.common.PackCodeDescInfos; +import cn.com.origin.autocodemanager.common.TCLOVUtil; +import cn.com.origin.autocodemanager.common.TCPreferenceUitl; +import cn.com.origin.autocodemanager.common.TCQueryUtil; +import cn.com.origin.autocodemanager.common.operations.GetCodeNumber; +import cn.com.origin.autocodemanager.common.operations.PackCodeNodeInfo; +import cn.com.origin.autocodemanager.common.operations.TreeAndListCodeOperation; +import cn.com.origin.autocodemanager.common.tree.AbstractTreeData; +import cn.com.origin.autocodemanager.common.tree.TreeViewOperation; +import cn.com.origin.autocodemanager.views.listcodeview.NewItemListCodeView; +import cn.com.origin.autocodemanager.views.treecodeview.NewItemTreeCodeView; + +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.SoaUtil; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentProjectType; +import com.teamcenter.rac.kernel.TCComponentPseudoFolder; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentRole; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCExceptionPartial; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSApplicationObject; +import com.teamcenter.rac.kernel.ics.ICSFormat; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSSearchResult; +import com.teamcenter.rac.kernel.ics.ICSView; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PlatformHelper; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; +import com.teamcenter.services.rac.core.DataManagementService; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateInput; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateOut; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse; +import com.teamcenter.soa.client.model.LovValue; +import com.teamcenter.soaictstubs.booleanSeq_tHolder; +import com.teamcenter.soaictstubs.stringSeq_tHolder; + +public class NewCodeItemDialog extends Dialog { + // ӢĶ + private SashForm sashFormCodeView; + private CTabItem codeTreeCTab; + private CTabItem codeListCTab; + private Composite compositCodeTree; + private Composite compositCodeList; + private CTabFolder ctabFolder; + private Text idLengthText; + private Text DescText; + private Text idText; + private Combo revCombo; + private Text nameText; + private Combo unitCombo; + private NewItemClassificationView classificationView; + private NewItemListCodeView listView; + private NewItemTreeCodeView treeView; + private TreeViewer classificationTreeViewer; + private TreeViewOperation treeViewOperation; + public TreeAndListCodeOperation treeAndListCodeOperation; + private TCSession session; + private TCComponentItemType tccomponentitemtype; + private AbstractTreeData selectedSegmentNode = null; + private TCComponent selectedSegmentTCComponent = null; + private AbstractTreeData icoTreeData; + private String pattern = ""; + private String codeDesc = ""; + private String codeStyle = ""; + private String newSeq = ""; + private String counterID = ""; + private String newID = ""; + private String finalPattern = ""; + private String idPattern = ""; + // 20170510 class id + private String codeRemark = ""; + + private int codeLength; + private Map icoPropertyMap; + private String firstListICOName = ""; + private String codeCounterName = ""; + private Map segmentItemType; + private TCComponent newComp; + private String showItemType = ""; + private Boolean isTypeFilter = false; + private String origin_isNewItemMustLastNode = "origin_isNewItemMustLastNode"; + private String origin_idNeddExamineAndApproveTypes = "origin_idNeddExamineAndApproveTypes"; + private String origin_sendToClassification_excludeType = "origin_sendToClassification_excludeType"; + private String origin_sendToPreviousTreeNode = "origin_sendToPreviousTreeNode"; + private String origin_sendToClassification_Automatic = "origin_sendToClassification_Automatic"; + private String origin_isCodePatternCanEditTypes = "origin_isCodePatternCanEditTypes"; + private String unitLOVName = "Unit of Measures"; + private String origin_newItem_isShowUnit = "origin_newItem_isShowUnit"; + private String origin_showUnit_excludeTypes = "origin_showUnit_excludeTypes"; + private JDialog newItemDialog; + private ORItemInfoPanel orNewItemInfoPanel; + private TCComponent[] units = null; + private String origin_isItemNameTextDefaultNull = "origin_isItemNameTextDefaultNull"; + private PackCodeDescInfos packCodeDescInfos = null; + private SashForm container; + private SashForm itemInfoComposite; + private SashForm sashFormClassfication; + private String origin_isMustSelecteUnit = "origin_isMustSelecteUnit"; + private String origin_searchGenerateID = "origin_searchGenerateID"; + private String origin_isNotSaveNewItemToPseudoFolder = "origin_isNotSaveNewItemToPseudoFolder"; + private String origin_isShowPCUnitLast = "origin_isShowPCUnitLast"; + private String origin_newCodeSequenceNumber = "origin_newCodeSequenceNumber"; + private String origin_sequenceExcludeFirstPatternTypes = "origin_sequenceExcludeFirstPatternTypes"; + private String connor_isCanCreateTempMaterial = "connor_isCanCreateTempMaterial"; + + private final String connor_isIdTextEnable = "connor_isIdTextEnable"; + + private Composite cpxCompsite; + private Label cpxLabel; + private Text cpxText; + private Label nfLabel; + private Text nfText; + private Label cpxLabel2; + private Combo cpxText2; + + private final String CPX = "CPDM"; + private final String NF = "NF"; + private final String CPX2 = "CP"; + private final String JY_CPX_Option = "JY_CPX_Option"; + private HashMap jyCPXMap; + + // 2017.05.10 + private Button isCreateTempItemButton = null; + + private Boolean isCreateTempItem = false; + + // 2017.06.02 + // private List<> + private Composite objPropComposite; + private Composite classPropComposite; + private static TCClassificationService classService; + private static ICSAdminClass adminClass; + + // 2017.06.26 + private String LPBIGString; + private String LPSString; + + // 2017.07.02 + private CNPartList cnPartList; + private CNPart currentCNPart; + private List cnpropList; + + + // 2018.09.30 + private String LP_PROJECT_ID; + + //2019.11.07 + private String connor_InsertSequence = "LP_sequenceMapping"; + private HashMap connor_SequenceNameMapping; + private List connor_PatterValueList; + private String connor_CurrentTypeNameString = ""; + + //2020.12.28 + // private Button picCheckbox; + private Button picButton; + private List revList = new ArrayList(); + private String productNumber = ""; + private String drawingNumber = ""; + private String bsNumber = ""; + private String smNumber = ""; + private String cldh = ""; + private String zcType = ""; + private Map> attrMap; + private Map> attrMap2; + private Map> attrMap3; + private Map> attrMap4; + private Map objMap = new HashMap(); + private Map objMap2 = new HashMap(); + private Map objMap3 = new HashMap(); + private Map objMap4 = new HashMap(); + private Map lovMap = new HashMap(); + private Map lovMap2 = new HashMap(); + private Map lovMap3 = new HashMap(); + private Map lovMap4 = new HashMap(); + private List attrList = new ArrayList(); + private List esAttrList = new ArrayList(); + private List defaultValueList = new ArrayList(); + private List markList = new ArrayList(); + private List markList2 = new ArrayList(); + private List markList3 = new ArrayList(); + private List markList4 = new ArrayList(); + private List isNList = new ArrayList(); + private List isNList2 = new ArrayList(); + private List isNList3 = new ArrayList(); + private List isNList4 = new ArrayList(); + private List attrList2 = new ArrayList(); + private List attrList3 = new ArrayList(); + private List attrList4 = new ArrayList(); + private List esAttrList2 = new ArrayList(); + private List esAttrList3 = new ArrayList(); + private List esAttrList4 = new ArrayList(); + private Map boxMap = new HashMap(); + private Map idMap = new HashMap(); + private List asList = new ArrayList(); + private List esList = new ArrayList(); + // private String[] lovVal = new String[] { "ǰ", "׼", "޽Ӵ", "ʽ", "ͨ", "A:NBR", "0:", "", "", + // "SN:1805ػ", "ȴ", "", "S:(25% to 35%)", "C0","V0","Z0","׼","PC:ﵽC&UƷƾҪ" + // ,"P0:ﵽC&UƷƾҪ","ṹҪƹ","0:˫нǽӴ",":SECC൱",":벿Ŷȷ","BC:35"}; + // private String[] esLovVal = new String[] { "Non", "Standard ball", "Non", "Open", "Without vent hole", "A:NBR", + // "0:Black", "Non", "Ball", "SN:1805 temper","Conventional monolithic martensite quenching heat treatment", + // "Single", "S:(25% to 35%)", "C0","V0","Z0","Standard","PC:Meet the group C&U brand accuracy requirements" + // ,"P0:Meet the group C&U brand accuracy requirements","Other structures need to formulate rules","0:Double row angular contact ball bearing" + // ,"Not marked: SECC or equivalent","Other materials: confirm with department team for approval","BC:35"}; + public Text getIdLengthText() { + return idLengthText; + } + + public void setIdLengthText(Text idLengthText) { + this.idLengthText = idLengthText; + } + + public Combo getUnitCombo() { + return unitCombo; + } + + public void setUnitCombo(Combo unitCombo) { + this.unitCombo = unitCombo; + } + + public Text getDescText() { + return DescText; + } + + public void setDescText(Text descText) { + DescText = descText; + } + + public Text getIdText() { + return idText; + } + + public void setIdText(Text idText) { + this.idText = idText; + } + + public Combo getRevCombo() { + return revCombo; + } + + public void setRevCombo(Combo revCombo) { + this.revCombo = revCombo; + } + + public Text getNameText() { + return nameText; + } + + public void setNameText(Text nameText) { + this.nameText = nameText; + } + + public TCComponent getNewComp() { + return newComp; + } + + public void setNewComp(TCComponent newComp) { + this.newComp = newComp; + } + + + // public Button getPicCheckbox() { + // return picCheckbox; + // } + // + // public void setPicCheckbox(Button picCheckbox) { + // this.picCheckbox = picCheckbox; + // } + + public Button getPicButton() { + return picButton; + } + + public void setPicButton(Button picButton) { + this.picButton = picButton; + } + + public NewCodeItemDialog(Shell parentShell) { + super(parentShell); + treeViewOperation = new TreeViewOperation(); + treeAndListCodeOperation = new TreeAndListCodeOperation(); + session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + segmentItemType = new HashMap(); + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("Item")); + } catch (TCException e) { + e.printStackTrace(); + } + } + + + + + public NewCodeItemDialog(Shell parentShell, String showItemType) { + super(parentShell); + treeViewOperation = new TreeViewOperation(); + this.showItemType = showItemType.trim(); + treeAndListCodeOperation = new TreeAndListCodeOperation(); + session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + segmentItemType = new HashMap(); + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("Item")); + } catch (TCException e) { + e.printStackTrace(); + } + } + + public NewCodeItemDialog(Shell parentShell, String showItemType, + Boolean isFilterType) { + super(parentShell); + treeViewOperation = new TreeViewOperation(); + this.showItemType = showItemType.trim(); + this.isTypeFilter = isFilterType; + treeAndListCodeOperation = new TreeAndListCodeOperation(); + session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + segmentItemType = new HashMap(); + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("Item")); + } catch (TCException e) { + e.printStackTrace(); + } + } + + public NewCodeItemDialog(JDialog newItemDialog, Shell parentShell, + String showItemType) { + super(parentShell); + this.newItemDialog = newItemDialog; + treeViewOperation = new TreeViewOperation(); + this.showItemType = showItemType.trim(); + treeAndListCodeOperation = new TreeAndListCodeOperation(); + session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + segmentItemType = new HashMap(); + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("Item")); + } catch (TCException e) { + e.printStackTrace(); + } + } + + public NewCodeItemDialog(Shell parentShell, String showItemType, + PackCodeDescInfos packCodeDescInfos) { + super(parentShell); + treeViewOperation = new TreeViewOperation(); + this.showItemType = showItemType.trim(); + treeAndListCodeOperation = new TreeAndListCodeOperation(); + session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + segmentItemType = new HashMap(); + this.packCodeDescInfos = packCodeDescInfos; + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("Item")); + } catch (TCException e) { + e.printStackTrace(); + } + } + + public NewCodeItemDialog(ORItemInfoPanel newItemInfoPanel, + Shell parentShell, String showItemType) { + super(parentShell); + this.orNewItemInfoPanel = newItemInfoPanel; + treeViewOperation = new TreeViewOperation(); + this.showItemType = showItemType.trim(); + treeAndListCodeOperation = new TreeAndListCodeOperation(); + session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + segmentItemType = new HashMap(); + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("Item")); + } catch (TCException e) { + e.printStackTrace(); + } + } + + /** + * ҳ ӷϤҳ + * + * @param parent + */ + public void createClassTablePannel(Composite parent1) { + + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 3; + GridLayout classGridLayout = new GridLayout(); + classGridLayout.numColumns = 3; + GridData gridData1 = new GridData(); + gridData1.widthHint = 200; + gridData1.heightHint = 680; + gridData1.horizontalAlignment = GridData.FILL; + gridData1.verticalAlignment = GridData.CENTER; + gridData1.grabExcessHorizontalSpace = true; + + CTabFolder ctabFolder = new CTabFolder(parent1, SWT.BORDER); + ctabFolder.setBorderVisible(true); + ctabFolder.setSimple(false); + ctabFolder.setLayoutData(gridData1); + CTabItem objPropTab = new CTabItem(ctabFolder, SWT.NONE); + objPropTab.setText(PlmLocale.getString("ObjectProperties")); + Composite objectCompsite = new Composite(ctabFolder, SWT.BORDER); + objectCompsite.setLayout(new FillLayout()); + final ScrolledComposite objectSrolledComposite = new ScrolledComposite( + objectCompsite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); + objPropComposite = new Composite(objectSrolledComposite, SWT.NONE); + objPropComposite.setLayout(gridLayout); + objectSrolledComposite.setContent(objPropComposite);// ܿ + objectSrolledComposite.setExpandHorizontal(true); + objectSrolledComposite.setExpandVertical(true); + objectSrolledComposite.addControlListener(new ControlAdapter() { + public void controlResized(ControlEvent e) { + Point r = objPropComposite + .computeSize(SWT.DEFAULT, SWT.DEFAULT); + objectSrolledComposite.setMinSize(objectSrolledComposite + .computeSize(r.x, (r.y)+300)); + } + }); + objPropTab.setControl(objectCompsite); + ctabFolder.setSelection(0); + // + CTabItem classPropTab = new CTabItem(ctabFolder, SWT.NONE); + classPropTab.setText(PlmLocale.getString("ClassificationProperties")); + Composite classCompsite = new Composite(ctabFolder, SWT.BORDER); + classCompsite.setLayout(new FillLayout()); + final ScrolledComposite classSrolledComposite = new ScrolledComposite( + classCompsite, SWT.V_SCROLL); + classPropComposite = new Composite(classSrolledComposite, SWT.NONE);// ctabFolder + classPropComposite.setLayout(classGridLayout); + classSrolledComposite.setContent(classPropComposite);// ܿ + classSrolledComposite.setExpandHorizontal(true); + classSrolledComposite.setExpandVertical(true); + classSrolledComposite.addControlListener(new ControlAdapter() { + public void controlResized(ControlEvent e) { + Point r = classPropComposite.computeSize(SWT.DEFAULT, + SWT.DEFAULT); + classSrolledComposite.setMinSize(classSrolledComposite + .computeSize(r.x, (r.y)+300)); + } + }); + classPropTab.setControl(classCompsite); + + } + + public List