commit a500ba7084a16b4c0c57cd6016dbdcc26cd051b2 Author: guoyh Date: Thu Sep 16 19:06:18 2021 +0800 Commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..35f2133 --- /dev/null +++ b/.classpath @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..3ab0b66 --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + com.connor.dfl.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.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..295926d --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/MANIFEST.MF b/MANIFEST.MF new file mode 100644 index 0000000..fb407a1 --- /dev/null +++ b/MANIFEST.MF @@ -0,0 +1,1225 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Plm +Bundle-SymbolicName: com.connor.dfl.plm; singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: com.connor.dfl.plm.Activator +Bundle-Vendor: CONNOR +Require-Bundle: org.eclipse.core.runtime;bundle-version="3.15.100", + com.teamcenter.rac.viewer;bundle-version="12000.2.0", + com.teamcenter.rac.kernel;bundle-version="12000.2.0", + com.teamcenter.rac.vns;bundle-version="12000.2.0", + com.teamcenter.rac.ui;bundle-version="12000.2.0", + org.eclipse.ui;bundle-version="3.111.0", + com.teamcenter.rac.aifrcp;bundle-version="12000.2.0", + com.teamcenter.rac.common;bundle-version="12000.2.0", + org.eclipse.ui.forms;bundle-version="3.7.400", + org.apache.poi.39;bundle-version="3.9.0", + com.teamcenter.rac.external;bundle-version="12000.2.0", + com.teamcenter.rac.project;bundle-version="12000.2.0", + com.teamcenter.rac.ui.commands;bundle-version="12000.2.0", + com.teamcenter.rac.tcapps;bundle-version="12000.2.0", + com.teamcenter.rac.util;bundle-version="12000.2.0", + TcSoaCoreRac;bundle-version="12000.2.0", + TcSoaCoreTypes;bundle-version="12000.2.0", + TcSoaCommon;bundle-version="12000.2.0", + org.eclipse.ui.navigator;bundle-version="3.7.300", + com.teamcenter.rac.ui.views;bundle-version="12000.2.0", + com.teamcenter.rac.cm;bundle-version="12000.2.0", + com.teamcenter.rac.workflow;bundle-version="12000.2.0", + com.teamcenter.rac.workflow.processdesigner;bundle-version="12000.2.0", + com.teamcenter.rac.workflow.processviewer;bundle-version="12000.2.0", + org.eclipse.osgi.services;bundle-version="3.7.100", + org.eclipse.osgi.util;bundle-version="3.5.100" +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Bundle-ActivationPolicy: lazy +Bundle-ClassPath: 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.13.jar, + lib/axiom-dom-1.2.13.jar, + lib/axiom-impl-1.2.13.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/httpcore-4.0.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/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/cn.com.origin.autocodemanager_1.0.0.jar, + lib/jxl.jar, + lib/org.eclipse.osgi.services_3.7.100.v20180827-1536.jar, + lib/Spire.Xls.jar, + lib/cn.com.origin.autocode_1.0.0.jar, + lib/org.eclipse.osgi.services.nl_12000.2.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.com.origin.autocode, + cn.com.origin.autocode.classification, + cn.com.origin.autocode.classification.panels, + cn.com.origin.autocode.common, + cn.com.origin.autocode.common.operations, + cn.com.origin.autocode.handlers, + cn.com.origin.autocode.jfom.util, + cn.com.origin.autocode.newitem.generatcode, + cn.com.origin.autocode.newitem.origin, + cn.com.origin.autocode.newitem.system, + cn.com.origin.autocode.saveas, + cn.com.origin.autocode.views, + cn.com.origin.autocode.views.codeview, + cn.com.origin.autocode.views.groupview, + cn.com.origin.autocode.views.itemtypeview, + cn.com.origin.autocode.xmlutil, + cn.com.origin.autocodemanager, + cn.com.origin.autocodemanager.common, + cn.com.origin.autocodemanager.common.dialog, + cn.com.origin.autocodemanager.common.encrypt, + cn.com.origin.autocodemanager.common.operations, + cn.com.origin.autocodemanager.common.progress, + cn.com.origin.autocodemanager.common.tree, + cn.com.origin.autocodemanager.common.treetable, + cn.com.origin.autocodemanager.export, + cn.com.origin.autocodemanager.handlers, + cn.com.origin.autocodemanager.imports, + cn.com.origin.autocodemanager.views, + cn.com.origin.autocodemanager.views.codestyleview, + cn.com.origin.autocodemanager.views.codeview, + cn.com.origin.autocodemanager.views.listcodeview, + cn.com.origin.autocodemanager.views.testview, + cn.com.origin.autocodemanager.views.treecodeview, + com.connor.dev.imp, + com.connor.dev.imp.bom, + com.connor.dev.imp.ob, + com.connor.dev.imp.solution.handler, + com.connor.dev.imp.toolkit, + com.connor.dfl.plm, + com.connor.dfl.plm.actions, + com.connor.dfl.plm.cadhandler, + com.connor.dfl.plm.dfl001, + com.connor.dfl.plm.dfl002, + com.connor.dfl.plm.dfl003, + com.connor.dfl.plm.dfl004, + com.connor.dfl.plm.dfl005, + com.connor.dfl.plm.dfl006, + com.connor.dfl.plm.dfl007, + com.connor.dfl.plm.dfl008, + com.connor.dfl.plm.dfl009, + com.connor.dfl.plm.dfl010, + com.connor.dfl.plm.dfl011, + com.connor.dfl.plm.dfl012, + com.connor.dfl.plm.dfl013, + com.connor.dfl.plm.dfl014, + com.connor.dfl.plm.dfl015, + com.connor.dfl.plm.dfl016, + com.connor.dfl.plm.dfl017, + com.connor.dfl.plm.dfl018, + com.connor.dfl.plm.dfl019, + com.connor.dfl.plm.dfl020, + com.connor.dfl.plm.dfl021, + com.connor.dfl.plm.dfl023, + com.connor.dfl.plm.dfl024, + com.connor.dfl.plm.dfl025, + com.connor.dfl.plm.dfl026, + com.connor.dfl.plm.dfl027, + com.connor.dfl.plm.dfl028, + com.connor.dfl.plm.dfl029, + com.connor.dfl.plm.dfl030, + com.connor.dfl.plm.dfl031, + com.connor.dfl.plm.dfl032, + com.connor.dfl.plm.dfl033, + com.connor.dfl.plm.dfl034, + com.connor.dfl.plm.dfl035, + com.connor.dfl.plm.dfl036, + com.connor.dfl.plm.dfl037, + com.connor.dfl.plm.dfl038, + com.connor.dfl.plm.dfl039, + com.connor.dfl.plm.exportBOM, + com.connor.dfl.plm.forms, + com.connor.dfl.plm.table, + com.connor.dfl.plm.util, + com.connor.dfl.plm.worklist, + 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.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.spire.data.table, + com.spire.data.table.common, + com.spire.license, + 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.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.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.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.security, + com.spire.pdf.tables, + com.spire.pdf.tables.table, + com.spire.pdf.tables.table.common, + com.spire.pdf.widget, + com.spire.pdf.xmp, + 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.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.spire.xls.packages, + 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, + common, + common.log, + 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, + jxl, + jxl.biff, + jxl.biff.drawing, + jxl.biff.formula, + jxl.demo, + jxl.format, + jxl.read.biff, + jxl.write, + jxl.write.biff, + 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.locator, + org.apache.axiom.locator.loader, + org.apache.axiom.mime, + org.apache.axiom.mime.impl.axiom, + org.apache.axiom.mime.impl.javamail, + org.apache.axiom.om, + org.apache.axiom.om.dom, + 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.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.geronimo.osgi.locator, + org.apache.http, + org.apache.http.entity, + org.apache.http.impl, + org.apache.http.impl.entity, + org.apache.http.impl.io, + org.apache.http.io, + org.apache.http.message, + org.apache.http.params, + org.apache.http.protocol, + org.apache.http.util, + 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.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.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.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.osgi.service.cm, + org.osgi.service.component, + org.osgi.service.component.annotations, + org.osgi.service.component.runtime, + org.osgi.service.component.runtime.dto, + org.osgi.service.device, + org.osgi.service.event, + org.osgi.service.http, + org.osgi.service.http.context, + org.osgi.service.http.runtime, + org.osgi.service.http.runtime.dto, + org.osgi.service.http.whiteboard, + org.osgi.service.log, + org.osgi.service.metatype, + org.osgi.service.provisioning, + org.osgi.service.upnp, + org.osgi.service.useradmin, + org.osgi.service.wireadmin, + 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 +Import-Package: com.teamcenter.rac.kernel diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000..fb407a1 --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,1225 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Plm +Bundle-SymbolicName: com.connor.dfl.plm; singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: com.connor.dfl.plm.Activator +Bundle-Vendor: CONNOR +Require-Bundle: org.eclipse.core.runtime;bundle-version="3.15.100", + com.teamcenter.rac.viewer;bundle-version="12000.2.0", + com.teamcenter.rac.kernel;bundle-version="12000.2.0", + com.teamcenter.rac.vns;bundle-version="12000.2.0", + com.teamcenter.rac.ui;bundle-version="12000.2.0", + org.eclipse.ui;bundle-version="3.111.0", + com.teamcenter.rac.aifrcp;bundle-version="12000.2.0", + com.teamcenter.rac.common;bundle-version="12000.2.0", + org.eclipse.ui.forms;bundle-version="3.7.400", + org.apache.poi.39;bundle-version="3.9.0", + com.teamcenter.rac.external;bundle-version="12000.2.0", + com.teamcenter.rac.project;bundle-version="12000.2.0", + com.teamcenter.rac.ui.commands;bundle-version="12000.2.0", + com.teamcenter.rac.tcapps;bundle-version="12000.2.0", + com.teamcenter.rac.util;bundle-version="12000.2.0", + TcSoaCoreRac;bundle-version="12000.2.0", + TcSoaCoreTypes;bundle-version="12000.2.0", + TcSoaCommon;bundle-version="12000.2.0", + org.eclipse.ui.navigator;bundle-version="3.7.300", + com.teamcenter.rac.ui.views;bundle-version="12000.2.0", + com.teamcenter.rac.cm;bundle-version="12000.2.0", + com.teamcenter.rac.workflow;bundle-version="12000.2.0", + com.teamcenter.rac.workflow.processdesigner;bundle-version="12000.2.0", + com.teamcenter.rac.workflow.processviewer;bundle-version="12000.2.0", + org.eclipse.osgi.services;bundle-version="3.7.100", + org.eclipse.osgi.util;bundle-version="3.5.100" +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Bundle-ActivationPolicy: lazy +Bundle-ClassPath: 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.13.jar, + lib/axiom-dom-1.2.13.jar, + lib/axiom-impl-1.2.13.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/httpcore-4.0.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/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/cn.com.origin.autocodemanager_1.0.0.jar, + lib/jxl.jar, + lib/org.eclipse.osgi.services_3.7.100.v20180827-1536.jar, + lib/Spire.Xls.jar, + lib/cn.com.origin.autocode_1.0.0.jar, + lib/org.eclipse.osgi.services.nl_12000.2.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.com.origin.autocode, + cn.com.origin.autocode.classification, + cn.com.origin.autocode.classification.panels, + cn.com.origin.autocode.common, + cn.com.origin.autocode.common.operations, + cn.com.origin.autocode.handlers, + cn.com.origin.autocode.jfom.util, + cn.com.origin.autocode.newitem.generatcode, + cn.com.origin.autocode.newitem.origin, + cn.com.origin.autocode.newitem.system, + cn.com.origin.autocode.saveas, + cn.com.origin.autocode.views, + cn.com.origin.autocode.views.codeview, + cn.com.origin.autocode.views.groupview, + cn.com.origin.autocode.views.itemtypeview, + cn.com.origin.autocode.xmlutil, + cn.com.origin.autocodemanager, + cn.com.origin.autocodemanager.common, + cn.com.origin.autocodemanager.common.dialog, + cn.com.origin.autocodemanager.common.encrypt, + cn.com.origin.autocodemanager.common.operations, + cn.com.origin.autocodemanager.common.progress, + cn.com.origin.autocodemanager.common.tree, + cn.com.origin.autocodemanager.common.treetable, + cn.com.origin.autocodemanager.export, + cn.com.origin.autocodemanager.handlers, + cn.com.origin.autocodemanager.imports, + cn.com.origin.autocodemanager.views, + cn.com.origin.autocodemanager.views.codestyleview, + cn.com.origin.autocodemanager.views.codeview, + cn.com.origin.autocodemanager.views.listcodeview, + cn.com.origin.autocodemanager.views.testview, + cn.com.origin.autocodemanager.views.treecodeview, + com.connor.dev.imp, + com.connor.dev.imp.bom, + com.connor.dev.imp.ob, + com.connor.dev.imp.solution.handler, + com.connor.dev.imp.toolkit, + com.connor.dfl.plm, + com.connor.dfl.plm.actions, + com.connor.dfl.plm.cadhandler, + com.connor.dfl.plm.dfl001, + com.connor.dfl.plm.dfl002, + com.connor.dfl.plm.dfl003, + com.connor.dfl.plm.dfl004, + com.connor.dfl.plm.dfl005, + com.connor.dfl.plm.dfl006, + com.connor.dfl.plm.dfl007, + com.connor.dfl.plm.dfl008, + com.connor.dfl.plm.dfl009, + com.connor.dfl.plm.dfl010, + com.connor.dfl.plm.dfl011, + com.connor.dfl.plm.dfl012, + com.connor.dfl.plm.dfl013, + com.connor.dfl.plm.dfl014, + com.connor.dfl.plm.dfl015, + com.connor.dfl.plm.dfl016, + com.connor.dfl.plm.dfl017, + com.connor.dfl.plm.dfl018, + com.connor.dfl.plm.dfl019, + com.connor.dfl.plm.dfl020, + com.connor.dfl.plm.dfl021, + com.connor.dfl.plm.dfl023, + com.connor.dfl.plm.dfl024, + com.connor.dfl.plm.dfl025, + com.connor.dfl.plm.dfl026, + com.connor.dfl.plm.dfl027, + com.connor.dfl.plm.dfl028, + com.connor.dfl.plm.dfl029, + com.connor.dfl.plm.dfl030, + com.connor.dfl.plm.dfl031, + com.connor.dfl.plm.dfl032, + com.connor.dfl.plm.dfl033, + com.connor.dfl.plm.dfl034, + com.connor.dfl.plm.dfl035, + com.connor.dfl.plm.dfl036, + com.connor.dfl.plm.dfl037, + com.connor.dfl.plm.dfl038, + com.connor.dfl.plm.dfl039, + com.connor.dfl.plm.exportBOM, + com.connor.dfl.plm.forms, + com.connor.dfl.plm.table, + com.connor.dfl.plm.util, + com.connor.dfl.plm.worklist, + 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.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.spire.data.table, + com.spire.data.table.common, + com.spire.license, + 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.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.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.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.security, + com.spire.pdf.tables, + com.spire.pdf.tables.table, + com.spire.pdf.tables.table.common, + com.spire.pdf.widget, + com.spire.pdf.xmp, + 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.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.spire.xls.packages, + 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, + common, + common.log, + 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, + jxl, + jxl.biff, + jxl.biff.drawing, + jxl.biff.formula, + jxl.demo, + jxl.format, + jxl.read.biff, + jxl.write, + jxl.write.biff, + 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.locator, + org.apache.axiom.locator.loader, + org.apache.axiom.mime, + org.apache.axiom.mime.impl.axiom, + org.apache.axiom.mime.impl.javamail, + org.apache.axiom.om, + org.apache.axiom.om.dom, + 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.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.geronimo.osgi.locator, + org.apache.http, + org.apache.http.entity, + org.apache.http.impl, + org.apache.http.impl.entity, + org.apache.http.impl.io, + org.apache.http.io, + org.apache.http.message, + org.apache.http.params, + org.apache.http.protocol, + org.apache.http.util, + 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.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.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.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.osgi.service.cm, + org.osgi.service.component, + org.osgi.service.component.annotations, + org.osgi.service.component.runtime, + org.osgi.service.component.runtime.dto, + org.osgi.service.device, + org.osgi.service.event, + org.osgi.service.http, + org.osgi.service.http.context, + org.osgi.service.http.runtime, + org.osgi.service.http.runtime.dto, + org.osgi.service.http.whiteboard, + org.osgi.service.log, + org.osgi.service.metatype, + org.osgi.service.provisioning, + org.osgi.service.upnp, + org.osgi.service.useradmin, + org.osgi.service.wireadmin, + 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 +Import-Package: com.teamcenter.rac.kernel diff --git a/SortData.xlsx b/SortData.xlsx new file mode 100644 index 0000000..4df5024 Binary files /dev/null and b/SortData.xlsx differ diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..4286c16 --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1,2 @@ +/com/ +/syn/ diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..bfe5663 --- /dev/null +++ b/build.properties @@ -0,0 +1,93 @@ +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.13.jar,\ + lib/axiom-dom-1.2.13.jar,\ + lib/axiom-impl-1.2.13.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/httpcore-4.0.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/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/jxl.jar,\ + lib/org.eclipse.osgi.services_3.7.100.v20180827-1536.jar,\ + lib/Spire.Xls.jar,\ + lib/org.eclipse.osgi.services.nl_12000.2.0.jar,\ + lib/cn.com.origin.autocode_1.0.0.jar,\ + lib/cn.com.origin.autocodemanager_1.0.0.jar diff --git a/icons/sample.gif b/icons/sample.gif new file mode 100644 index 0000000..34fb3c9 Binary files /dev/null and b/icons/sample.gif differ diff --git a/lib/Spire.Xls.jar b/lib/Spire.Xls.jar new file mode 100644 index 0000000..2d1af62 Binary files /dev/null and b/lib/Spire.Xls.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/axiom-api-1.2.13.jar b/lib/axiom-api-1.2.13.jar new file mode 100644 index 0000000..84cb42c Binary files /dev/null and b/lib/axiom-api-1.2.13.jar differ diff --git a/lib/axiom-dom-1.2.13.jar b/lib/axiom-dom-1.2.13.jar new file mode 100644 index 0000000..4890bb2 Binary files /dev/null and b/lib/axiom-dom-1.2.13.jar differ diff --git a/lib/axiom-impl-1.2.13.jar b/lib/axiom-impl-1.2.13.jar new file mode 100644 index 0000000..a959b28 Binary files /dev/null and b/lib/axiom-impl-1.2.13.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/cn.com.origin.autocode_1.0.0.jar b/lib/cn.com.origin.autocode_1.0.0.jar new file mode 100644 index 0000000..971146d Binary files /dev/null and b/lib/cn.com.origin.autocode_1.0.0.jar differ diff --git a/lib/cn.com.origin.autocodemanager_1.0.0.jar b/lib/cn.com.origin.autocodemanager_1.0.0.jar new file mode 100644 index 0000000..ce5cb3b Binary files /dev/null and b/lib/cn.com.origin.autocodemanager_1.0.0.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/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/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/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/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/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.jar b/lib/jxl.jar new file mode 100644 index 0000000..b210c06 Binary files /dev/null and b/lib/jxl.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/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/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/org.eclipse.osgi.services.nl_12000.2.0.jar b/lib/org.eclipse.osgi.services.nl_12000.2.0.jar new file mode 100644 index 0000000..06bf182 Binary files /dev/null and b/lib/org.eclipse.osgi.services.nl_12000.2.0.jar differ diff --git a/lib/org.eclipse.osgi.services_3.7.100.v20180827-1536.jar b/lib/org.eclipse.osgi.services_3.7.100.v20180827-1536.jar new file mode 100644 index 0000000..1c23d82 Binary files /dev/null and b/lib/org.eclipse.osgi.services_3.7.100.v20180827-1536.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/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/plugin.xml b/plugin.xml new file mode 100644 index 0000000..2a87b0f --- /dev/null +++ b/plugin.xml @@ -0,0 +1,3141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/connor/dev/imp/.svn/all-wcprops b/src/com/connor/dev/imp/.svn/all-wcprops new file mode 100644 index 0000000..8520ca0 --- /dev/null +++ b/src/com/connor/dev/imp/.svn/all-wcprops @@ -0,0 +1,35 @@ +K 25 +svn:wc:ra_dav:version-url +V 92 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp +END +MappingAttribute.java +K 25 +svn:wc:ra_dav:version-url +V 114 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/MappingAttribute.java +END +ImportFlex.java +K 25 +svn:wc:ra_dav:version-url +V 108 +/svn/dongfang/!svn/ver/34/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/ImportFlex.java +END +ImportSettings.java +K 25 +svn:wc:ra_dav:version-url +V 112 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/ImportSettings.java +END +AbstractImportCommand.java +K 25 +svn:wc:ra_dav:version-url +V 119 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/AbstractImportCommand.java +END +AbstractImportDialog.java +K 25 +svn:wc:ra_dav:version-url +V 118 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/AbstractImportDialog.java +END diff --git a/src/com/connor/dev/imp/.svn/entries b/src/com/connor/dev/imp/.svn/entries new file mode 100644 index 0000000..b568acd --- /dev/null +++ b/src/com/connor/dev/imp/.svn/entries @@ -0,0 +1,216 @@ +10 + +dir +13 +http://192.168.0.254:8080/svn/dongfang/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp +http://192.168.0.254:8080/svn/dongfang + + + +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + +d5545a61-9634-c849-9c05-96e4e3e25a21 + +MappingAttribute.java +file + + + + +2011-07-06T04:02:28.125000Z +1618f2675f53fcfc915707ff45a697d7 +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + + + + + + + + +1281 + +ob +dir + +images +dir + +toolkit +dir + +re +dir + +ImportFlex.java +file +34 + + + +2011-11-29T10:16:29.562500Z +2a6c25a0005e02c27cdc87fa23c55541 +2011-12-31T02:38:28.156481Z +34 +liqz + + + + + + + + + + + + + + + + + + + + + +80780 + +ImportSettings.java +file + + + + +2011-07-06T04:02:28.125000Z +b306dc85134af1300dd7ef0bae595a4f +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + + + + + + + + +1909 + +solution +dir + +AbstractImportCommand.java +file + + + + +2011-07-06T04:02:28.109375Z +f5b9128d78bc69ca6ed038332ff5408a +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + + + + + + + + +1828 + +bom +dir + +AbstractImportDialog.java +file + + + + +2011-08-26T06:26:48.187500Z +2230a1f79ce6438ac604d77ae91da590 +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + + + + + + + + +18710 + diff --git a/src/com/connor/dev/imp/.svn/text-base/AbstractImportCommand.java.svn-base b/src/com/connor/dev/imp/.svn/text-base/AbstractImportCommand.java.svn-base new file mode 100644 index 0000000..c489ee9 --- /dev/null +++ b/src/com/connor/dev/imp/.svn/text-base/AbstractImportCommand.java.svn-base @@ -0,0 +1,65 @@ +package com.origin.dev.imp; + +import com.origin.dev.imp.ob.ImportObjectsCommand; +import com.origin.dev.imp.toolkit.ProgressReporter; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public abstract class AbstractImportCommand extends AbstractAIFCommand +{ + protected TCSession session; + + public AbstractImportCommand(AbstractAIFUIApplication application) + { + this.session = (TCSession) application.getSession(); + + processImporting(); + } + + private void processImporting() + { + InterfaceAIFComponent targetCom = AIFUtility.getCurrentApplication().getTargetComponent(); + // 如果在选择导入功能前选中了某个已有文件夹 + if (this instanceof ImportObjectsCommand) + { + if (!(targetCom instanceof TCComponentFolder)) + { + MessageBox msg = new MessageBox("导入失败", "提示:\n请您先选择对象导入的文件夹!然后再执行导入!\n", "执行错误", 1, true); + msg.setVisible(true); + return; + } + } + + final ProgressReporter reporter = new ProgressReporter(); + reporter.reportProgressMessage("正在初始化界面,请稍候..."); + new Thread(reporter).start(); + new Thread(new Runnable() + { + public void run() + { + while (!reporter.isRequestCanceling()) + { + reporter.setProgressPercent(reporter.getProgess() + 5); + + try + { + Thread.sleep(500); + } + catch (InterruptedException e) + { + continue; + } + } + } + }).start(); + importHistoryDatas(); + reporter.requestCanceling(); + } + + protected abstract void importHistoryDatas(); +} diff --git a/src/com/connor/dev/imp/.svn/text-base/AbstractImportDialog.java.svn-base b/src/com/connor/dev/imp/.svn/text-base/AbstractImportDialog.java.svn-base new file mode 100644 index 0000000..fc2f69c --- /dev/null +++ b/src/com/connor/dev/imp/.svn/text-base/AbstractImportDialog.java.svn-base @@ -0,0 +1,574 @@ +package com.origin.dev.imp; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.DefaultComboBoxModel; +import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.event.ChangeListener; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import jxl.Cell; +import jxl.Sheet; +import jxl.Workbook; +import jxl.read.biff.BiffException; + +import com.origin.dev.imp.toolkit.ProgressReporter; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.common.TCUtilities; +import com.teamcenter.rac.common.create.DisplayTypeInfo; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.AIFImageIcon; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public abstract class AbstractImportDialog extends AbstractAIFDialog implements ActionListener, ChangeListener, ListSelectionListener { + private static final long serialVersionUID = 1L; + + private JTextField filePathField; + + private JButton browse; + + // private JTextField logPathField; + + protected JTextField dateFormatField; + + // protected JTextField arraySepField; + + protected JList excelList; + + protected DefaultListModel excelListModel; + + protected JList[] propertiesList; + + protected JList[] mappingList; + + protected DefaultListModel[] propertiesListModels; + + protected DefaultListModel[] mappingListModels; + + protected JTabbedPane rightPane; + + protected JButton add; + + protected JButton remove; + + protected JButton execute; + + protected JButton unlock; + + protected JButton save; + + protected JButton open; + + protected TCSession session; + + protected JFileChooser chooser; + + protected File importFile; + + private ProgressReporter reporter; + + public AbstractImportDialog(TCSession session, String title, boolean modal) { + super(modal); + + this.session = session; + chooser = new JFileChooser(); + chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + chooser.setMultiSelectionEnabled(false); + + setTitle(title); + // setResizable(false); + setLayout(new BorderLayout()); + + initializeUI(); + setComponentsTextProperty(); + addUIComponents(); + registerActionComponents(); + } + + protected void initializeUI() { + filePathField = new JTextField(30); + filePathField.setEditable(false); + + browse = new JButton(); + + // logPathField = new JTextField(30); + + dateFormatField = new JTextField(30); + // arraySepField = new JTextField(5); + + excelListModel = new DefaultListModel(); + excelList = new JList(excelListModel); + excelList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + rightPane = new JTabbedPane(); + + System.out.println("this.getClass().getSimpleName()===" + this.getClass().getSimpleName()); + if (this.getClass().getSimpleName().equals("ImportRelationsDialog")) { + add = new JButton(AIFImageIcon.getImageIcon(this, "images/cancel_16.png")); + add.setEnabled(false); + remove = new JButton(AIFImageIcon.getImageIcon(this, "images/cancel_all_16.png")); + remove.setEnabled(false); + // remove.setVisible(false); + } else { + add = new JButton(AIFImageIcon.getImageIcon(this, "images/add_16.png")); + add.setEnabled(false); + + remove = new JButton(AIFImageIcon.getImageIcon(this, "images/remove_16.png")); + remove.setEnabled(false); + } + execute = new JButton(AIFImageIcon.getImageIcon(this, "images/import_16.png")); + execute.setEnabled(false); + + unlock = new JButton(AIFImageIcon.getImageIcon(this, "images/apply_16.png")); + + save = new JButton(AIFImageIcon.getImageIcon(this, "images/save_16.png")); + + open = new JButton(AIFImageIcon.getImageIcon(this, "images/open_16.png")); + + reporter = new ProgressReporter(); + } + + protected void setComponentsTextProperty() { + browse.setText("..."); + execute.setToolTipText("执行导入操作"); + unlock.setToolTipText("激活更改配置"); + save.setToolTipText("保存配置"); + open.setToolTipText("导入配置"); + + if (this.getClass().getSimpleName().equals("ImportRelationsDialog")) { + add.setToolTipText("清除配置"); + remove.setToolTipText("清除所有配置"); + }else + { + add.setToolTipText("添加映射"); + remove.setToolTipText("移除映射"); + } + + + dateFormatField.setText("yyyy-MM-dd HH:mm:ss"); + dateFormatField.setToolTipText("设置日期格式,区分大小写:
    " + "
  • y代表年
  • " + "
  • M代表月
  • " + "
  • d代表天
  • " + "
  • H代表时
  • " + "
  • m代表分
  • " + "
  • s代表秒
  • " + "
"); + + // doPurgeComponentProperties(""); + } + + protected void registerActionComponents() { + add.addActionListener(this); + remove.addActionListener(this); + rightPane.addChangeListener(this); + + execute.addActionListener(this); + unlock.addActionListener(this); + save.addActionListener(this); + open.addActionListener(this); + browse.addActionListener(this); + + for (int i = 0; i < propertiesList.length; i++) { + propertiesList[i].addListSelectionListener(this); + mappingList[i].addListSelectionListener(this); + } + + excelList.addListSelectionListener(this); + } + + protected void addUIComponents() { + JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + topPanel.add(new JLabel("数据文件")); + topPanel.add(filePathField); + topPanel.add(browse); + // topPanel.add(new JLabel("日志文件")); + // topPanel.add(logPathField); + + JPanel raPanel = new JPanel(new FlowLayout()); + raPanel.add(add); + raPanel.add(remove); + + JPanel rightPanel = new JPanel(new BorderLayout()); + rightPanel.add(rightPane, BorderLayout.CENTER); + rightPanel.add(raPanel, BorderLayout.SOUTH); + + JSplitPane centerPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); + centerPanel.setDividerLocation(120); + centerPanel.setContinuousLayout(true); + centerPanel.setLeftComponent(new JScrollPane(excelList)); + + addTabbedPaneComponents(); + + centerPanel.setRightComponent(rightPanel); + + JPanel bottomPanel = new JPanel(new FlowLayout()); + bottomPanel.add(execute); + bottomPanel.add(unlock); + bottomPanel.add(save); + bottomPanel.add(open); + + add(topPanel, BorderLayout.NORTH); + add(centerPanel, BorderLayout.CENTER); + add(bottomPanel, BorderLayout.SOUTH); + } + + protected abstract void addTabbedPaneComponents(); + + protected JPanel getParameterPanel() { + JPanel p = new JPanel(new PropertyLayout()); + p.add("1.1.right.top.preferred.preferred", new JLabel("日期格式:")); + p.add("1.2.left.top.preferred.preferred", dateFormatField); + // p.add("2.1.right.top.preferred.preferred", new JLabel("数组内容分隔符:")); + // p.add("2.2.left.top.preferred.preferred", arraySepField); + + return p; + } + + protected String[] getTCComponentProperties(String name) { + String[] properties = null; + try { + TCTypeService typeService = session.getTypeService(); + TCComponentType typeComponent = typeService.getTypeComponent(name); + properties = typeComponent.getPropertyNames(); + } catch (TCException e) { + e.printStackTrace(); + } + + return properties; + } + + protected void populateTypeChoices(String name, JComboBox box) { + try { + TCTypeService service = session.getTypeService(); + TCComponentType[] items = service.getTypes(name); + if (items != null) { + for (int i = 0; i < items.length; i++) { + String item = items[i].toString(); + + if ("EngChange".equalsIgnoreCase(item)) { + continue; + } + // System.out.println(items[i].toString()); + box.addItem(items[i].toString()); + + // TCComponentItemType + // TCComponentType[] sub = items[i].isTypeOf(s); + System.out.println("d"); + // AIFComponentContext[] aifcs = items[i].getChildren(); + // for (AIFComponentContext aifc : aifcs) + // { + // InterfaceAIFComponent com = aifc.getComponent(); + // System.out.println(com.getClass()); + // } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + /* + * (non-Javadoc) + * @see + * javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event + * .ListSelectionEvent) + */ + public void valueChanged(ListSelectionEvent listselectionevent) { + checkMappingsEditable(); + } + + protected void checkMappingsEditable() { + int index = rightPane.getSelectedIndex(); + if (index < propertiesList.length) { + add.setEnabled(excelList.getSelectedIndex() != -1 && propertiesList[index].getSelectedIndex() != -1); + remove.setEnabled(mappingList[index].getSelectedIndex() != -1); + } else { + if (this.getClass().getSimpleName().equals("ImportRelationsDialog")) { + add.setEnabled(true); + remove.setEnabled(true); + } else { + add.setEnabled(false); + remove.setEnabled(false); + } + } + } + + protected void doPurgeComponentProperties(String name) { + for (int i = 0; i < propertiesList.length - 1; i++) { + propertiesListModels[i].removeAllElements(); + mappingListModels[i].removeAllElements(); + } + } + + /* + * (non-Javadoc) + * @see + * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) + */ + public void actionPerformed(ActionEvent ae) { + + if (ae.getSource() == add) { + if (!this.getClass().getSimpleName().equals("ImportRelationsDialog")) { + String excel = excelList.getSelectedValue().toString(); + int index = excelList.getSelectedIndex(); + String prop = propertiesList[rightPane.getSelectedIndex()].getSelectedValue().toString(); + + MappingAttribute ma = new MappingAttribute(index, excel, prop); + if (!mappingListModels[rightPane.getSelectedIndex()].contains(ma)) { + mappingListModels[rightPane.getSelectedIndex()].addElement(ma); + } + } + } else if (ae.getSource() == remove) { + if (!this.getClass().getSimpleName().equals("ImportRelationsDialog")) { + mappingListModels[rightPane.getSelectedIndex()].remove(mappingList[rightPane.getSelectedIndex()].getSelectedIndex()); + } + } else if (ae.getSource() == execute) { + executeImport(); + } else if (ae.getSource() == unlock) { + excelList.setEnabled(true); + for (int i = 0; i < propertiesList.length; i++) { + propertiesList[i].setEnabled(true); + mappingList[i].setEnabled(true); + } + } else if (ae.getSource() == open) { + if (filePathField.getText().trim().length() == 0) { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "请先选择要导入的数据文件", "警告", 1); + } else { + openImportSettings(); + } + } else if (ae.getSource() == save) { + saveImportSettings(); + } else if (ae.getSource() == browse) { + selectImportFile(); + } + } + + private void selectImportFile() { + excelListModel.removeAllElements(); + + if (chooser.showOpenDialog(null) == 0) { + importFile = chooser.getSelectedFile(); + if (importFile != null) { + + if(importFile.exists()&&importFile.isFile()){ + if(importFile.getAbsolutePath().endsWith(".xls")){ + try { + Workbook workbook = Workbook.getWorkbook(importFile); + Sheet sheet = workbook.getSheet(0); + Cell[] row = sheet.getRow(0); + for (int i = 0; i < row.length; i++) { + if (row[i].getContents().trim().equals("")) { + excelListModel.addElement("(该列名字为空)"); + } else { + excelListModel.addElement(row[i].getContents()); + } + } + workbook.close(); + filePathField.setText(importFile.getAbsolutePath()); + execute.setEnabled(true); + + return; + } catch (BiffException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + }else if(importFile.getAbsolutePath().endsWith(".xlsx")){ + try { + org.apache.poi.ss.usermodel.Workbook workbook = new XSSFWorkbook(new FileInputStream(importFile)); + org.apache.poi.ss.usermodel.Sheet sheet = workbook.getSheetAt(0); + Row row = sheet.getRow(0); + for (int i = 0; i < row.getPhysicalNumberOfCells(); i++) { + if (!row.getCell(i).getStringCellValue().trim().equals("")) { + excelListModel.addElement(row.getCell(i).getStringCellValue()); + } +// else { +// excelListModel.addElement("(该列名字为空)"); +// } + } + filePathField.setText(importFile.getAbsolutePath()); + execute.setEnabled(true); + + return; + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + } + + execute.setEnabled(false); + } + + private void executeImport() { + if (checkNecessaryCondition()) { + setVisible(false); + + reporter.reportProgressMessage("正在导入数据,请稍候..."); + new Thread(reporter).start(); + + new Thread() { + public void run() { + try { + + ImportFlex flex = new ImportFlex(session, reporter); + flex.runImporting(generateImportSettings(), new File(filePathField.getText())); + + reporter.requestCanceling(); + dispose(); + if( flex.logpath.equals("")){ + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "数据导入完成!\n\n成功条数 : " + flex.success + "\n失败条数 : " + flex.fail , "完成", 0); + }else{ + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "数据导入完成!\n\n成功条数 : " + flex.success + "\n失败条数 : " + flex.fail + "\n日志路径:" + flex.logpath, "完成", 0); + } + + } catch (Throwable e) { + e.printStackTrace(); + + reporter.requestCanceling(); + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "导入失败", "错误", 1); + setVisible(true); + } + } + }.start(); + } + } + + protected boolean checkNecessaryCondition() { + return true; + } + + protected abstract void openImportSettings(); + + protected abstract void saveImportSettings(); + + public abstract ImportSettings generateImportSettings(); + + protected void populateItemTypes(JComboBox box) { + // BaseClassInput[] abaseclassinput = new + // com.teamcenter.services.rac.core._2007_06.DataManagement.BaseClassInput[4]; + // for (int i = 0; i < 4; i++) + // abaseclassinput[i] = new + // com.teamcenter.services.rac.core._2007_06.DataManagement.BaseClassInput(); + // + // abaseclassinput[0].baseClass = "Item"; + // abaseclassinput[0].exclusionTypes = new String[] {}; + // abaseclassinput[1].baseClass = "MEProcess"; + // abaseclassinput[2].baseClass = "MEOP"; + // abaseclassinput[3].baseClass = "MEWorkarea"; + // + // com.teamcenter.services.rac.core._2007_06.DataManagement.GetAvailableTypesResponse + // getavailabletypesresponse + // = TCUtilities + // .getDisplayableTypeNames(session, abaseclassinput); + // Map map = getavailabletypesresponse.inputClassToTypes; + // com.teamcenter.services.rac.core._2007_06.DataManagement.BaseClassInput + // abaseclassinput1[] = abaseclassinput; + // int j = abaseclassinput1.length; + // for (int k = 0; k < j; k++) + // { + // com.teamcenter.services.rac.core._2007_06.DataManagement.BaseClassInput + // baseclassinput = abaseclassinput1[k]; + // com.teamcenter.services.rac.core._2007_06.DataManagement.AvailableTypeInfo + // aavailabletypeinfo[] = + // (com.teamcenter.services.rac.core._2007_06.DataManagement.AvailableTypeInfo[]) + // map + // .get(baseclassinput.baseClass); + // com.teamcenter.services.rac.core._2007_06.DataManagement.AvailableTypeInfo + // aavailabletypeinfo1[] = + // aavailabletypeinfo; + // int l = aavailabletypeinfo1.length; + // for (int i1 = 0; i1 < l; i1++) + // { + // com.teamcenter.services.rac.core._2007_06.DataManagement.AvailableTypeInfo + // availabletypeinfo = + // aavailabletypeinfo1[i1]; + // box.addItem(availabletypeinfo.type); + // } + // + // } + // + // if (getavailabletypesresponse.serviceData.sizeOfPartialErrors() > 0) + // { + // TCException tcexception = + // SoaUtil.checkPartialErrorsNoThrow(getavailabletypesresponse.serviceData); + // MessageBox.post(Utilities.getParentFrame(this), tcexception); + // } + + String[] types = new String[] { "Item", "MEProcess", "MEOP" }; + + List datas = new ArrayList(); + + Map> map = new HashMap>(types.length); + for (String string : types) { + map.put(string, new ArrayList()); + } + if (map != null && map.size() > 0) { + Map> map1 = TCUtilities.getDisplayableTypeNamesWithHierarchyInfo(session, map); + if (map1 != null && !map1.isEmpty()) { + Iterator>> iterator = map1.entrySet().iterator(); + do { + if (!iterator.hasNext()) + break; + Entry> entry = iterator.next(); + List list = entry.getValue(); + if (list != null && !list.isEmpty()) { + Iterator iterator1 = list.iterator(); + while (iterator1.hasNext()) { + DisplayTypeInfo displaytypeinfo = (DisplayTypeInfo) iterator1.next(); + datas.add(displaytypeinfo.getTypeName()); + } + } + } while (true); + } + } + + Collections.sort(datas); + + box.setModel(new DefaultComboBoxModel(datas.toArray(new String[datas.size()]))); + } + + public static void main(String[] args){ + org.apache.poi.ss.usermodel.Workbook workbook; + try { + workbook = new XSSFWorkbook(new FileInputStream("C:\\Users\\Administrator.SD-20101212HAVL\\Desktop\\123.xlsx")); + org.apache.poi.ss.usermodel.Sheet sheet = workbook.getSheetAt(0); + System.out.println(sheet.getPhysicalNumberOfRows()); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/src/com/connor/dev/imp/.svn/text-base/ImportFlex.java.svn-base b/src/com/connor/dev/imp/.svn/text-base/ImportFlex.java.svn-base new file mode 100644 index 0000000..6e4928a --- /dev/null +++ b/src/com/connor/dev/imp/.svn/text-base/ImportFlex.java.svn-base @@ -0,0 +1,2056 @@ +package com.origin.dev.imp; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + +import com.origin.dev.imp.bom.BomsImportSettings; +import com.origin.dev.imp.ob.ObjectsImportSettings; +import com.origin.dev.imp.re.RelationsImportSettings; +import com.origin.dev.imp.toolkit.JXLExcelParser; +import com.origin.dev.imp.toolkit.POIExcelParser; +import com.origin.dev.imp.toolkit.ProgressReporter; +import com.origin.dev.imp.toolkit.SearchUtility; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.commands.delete.DeleteOperation; +import com.teamcenter.rac.kernel.NamedReferenceContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetDefinition; +import com.teamcenter.rac.kernel.TCComponentDatasetDefinitionType; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCComponentType; +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.kernel.TCTypeService; +import com.teamcenter.rac.util.MessageBox; + +public class ImportFlex { + /** + * Logger for this class + */ + private static final Logger logger = Logger.getLogger(ImportFlex.class); + + private TCComponentFolder folder; + + private TCTypeService service; + + private TCComponentType uom; + private TCComponentItemType itemType; + private TCComponentDatasetType datasetType; + + private TCComponentDatasetDefinitionType dsdefType; + private TCComponentBOMWindowType winType; + + public int success = 0; + + public int fail = 0; + + public int k = 1;//控制数据集版本 + + public String logpath = "";//日志路径 + + public String systitem = ""; + + private TCSession session; + private ProgressReporter reporter; + + /** + * Creates a new instance of ImportFlex. + * @param session + * @param reporter + * @throws TCException + */ + public ImportFlex(TCSession session, ProgressReporter reporter) throws TCException { + this.session = session; + this.reporter = reporter; + + logger.debug("开始初始化类ImportFlex"); + service = session.getTypeService(); + + uom = service.getTypeComponent("UnitOfMeasure"); + itemType = (TCComponentItemType) service.getTypeComponent("Item"); + datasetType = (TCComponentDatasetType) service.getTypeComponent("Dataset"); + dsdefType = (TCComponentDatasetDefinitionType) service.getTypeComponent("DatasetType"); + winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + + if (AIFUtility.getCurrentApplication().getTargetComponent() instanceof TCComponentFolder) { + folder = (TCComponentFolder) AIFUtility.getCurrentApplication().getTargetComponent(); + } + + logger.debug("类ImportFlex初始化完毕"); + } + + /** + * runImporting:(实现数据导入 ) + * @param settings 数据导入的配置选项 + * @param input 设定文件 + * @since CodingExample Ver 1.1 + */ + public void runImporting(ImportSettings settings, File input) { + systitem = new SimpleDateFormat("yyyyMMdd-HHmmss").format(new Date()); + success = 0; + fail = 0; + System.out.println("要导入的文件路径为" + input.getAbsolutePath()); + if(input.getAbsolutePath().endsWith(".xls")){ + if (settings instanceof ObjectsImportSettings) { + System.out.println("要导入的类型为对象"); + ObjectsImportSettings ois = (ObjectsImportSettings) settings; + importObjectsByJxl(ois, input); + System.out.println("对象导入结束"); + } else if (settings instanceof BomsImportSettings) { + System.out.println("要导入的类型为BOM"); + BomsImportSettings bis = (BomsImportSettings) settings; + importBomsByJxl(bis, input); + System.out.println("BOM导入结束"); + } else { + System.out.println("要导入的类型为关系"); + RelationsImportSettings ris = (RelationsImportSettings) settings; + importRelationsByJxl(ris, input); + System.out.println("关系导入结束"); + } + }else if(input.getAbsolutePath().endsWith(".xlsx")){ + if (settings instanceof ObjectsImportSettings) { + System.out.println("要导入的类型为对象"); + ObjectsImportSettings ois = (ObjectsImportSettings) settings; + importObjectsByPoi(ois, input); + System.out.println("对象导入结束"); + } else if (settings instanceof BomsImportSettings) { + System.out.println("要导入的类型为BOM"); + BomsImportSettings bis = (BomsImportSettings) settings; + importBomsByPoi(bis, input); + System.out.println("BOM导入结束"); + } else { + System.out.println("要导入的类型为关系"); + RelationsImportSettings ris = (RelationsImportSettings) settings; + importRelationsByPoi(ris, input); + System.out.println("关系导入结束"); + } + } + + } + + private void importRelationsByJxl(RelationsImportSettings ris, File input) { + System.out.println("关系导入开始"); + + if (ris.getCurrentItemID() == null || ris.getRelativeItemID() == null) { + MessageBox.post("请先选择当前零组件与目标零组件的ID对应关系后再执行导入操作", "警告", 1); + return; + } + + int currentIndex = ris.getCurrentItemID().getColumnIndex(); + System.out.println("当前零组件对应的列为" + currentIndex); + int relativeIndex = ris.getRelativeItemID().getColumnIndex(); + System.out.println("目标零组件对应的列为" + relativeIndex); + + String relation = ris.getRelation(); + String propertyName = ""; + if (relation.equals("")) { + // MessageBox.post("所指定的关系为空,请先指定关系", "警告", 1); + // return; + } + int propertyIndex = -2; + if (ris.getProperty() != null) { + propertyIndex = ris.getProperty().getColumnIndex(); + } + try { + System.out.println("开始初始化解析excel文件的类"); + JXLExcelParser parser = new JXLExcelParser(input, 0, ris.getColumns(), 1); + reporter.setTaskRange(0, parser.rows); + List line = null; + System.out.println("开始解析excel文件"); + while ((line = parser.parseLine()) != null) { + reporter.setProgressPercent(parser.startRow); + reporter.reportProgressMessage("正在导入第 " + parser.startRow + " 行数据"); + + String currentID = line.get(currentIndex).trim(); + String relativeID = line.get(relativeIndex).trim(); + if (propertyIndex != -2) { + propertyName = line.get(propertyIndex).trim(); + } + + // if ((propertyName == null) || (propertyName.length() == 0) || + // (relation == null) || (relation.length() == 0)) { + // MessageBox.post("所指定的关系和属性为空,请先指定关系或属性", "警告", 1); + // return; + // } + if (currentID.equals("") || relativeID.equals("")) { + System.out.println("【警告】excel中 第" + parser.startRow + "行零组件ID或者目标零组件ID为空,不进行导入"); + System.out.println("当前零组件ID或者目标零组件ID为空,不进行处理"); + continue; + } + + System.out.println("开始查找当前零组件"); + TCComponentItem currentItem = itemType.find(currentID); + if (currentItem == null) { + System.out.println("【警告】excel中 第" + parser.startRow + "行零组件不存在,不进行导入"); + System.out.println("所指定的当前零组件不存在"); + continue; + } + System.out.println("当前零组件查找完成"); + + System.out.println("开始查找目标零组件"); + TCComponentItem relativeItem = itemType.find(relativeID); + if (relativeItem == null) { + System.out.println("【警告】excel中 第" + parser.startRow + "行目标零组件不存在,不进行导入"); + System.out.println("所指定的目标零组件不存在"); + continue; + } + System.out.println("目标零组件查找完成"); + + String currentRevision = null; + if (ris.getCurrentItemRevision() != null) { + currentRevision = line.get(ris.getCurrentItemRevision().getColumnIndex()); + } + + String relativeRevision = null; + if (ris.getRelativeItemRevision() != null) { + relativeRevision = line.get(ris.getRelativeItemRevision().getColumnIndex()); + } + if (relation.equals("")) { + if(propertyName!=""){ + establishRelation(parser.startRow, currentItem, relativeItem, currentRevision, relativeRevision, propertyName); + } + } else { + establishRelation(parser.startRow, currentItem, relativeItem, currentRevision, relativeRevision, relation); + } + } + } catch (Exception e) { + logger.error("导入关系失败 - " + e.getMessage()); + logger.debug(e.toString()); + } + } + + + private void importRelationsByPoi(RelationsImportSettings ris, File input) { + System.out.println("关系导入开始"); + + if (ris.getCurrentItemID() == null || ris.getRelativeItemID() == null) { + MessageBox.post("请先选择当前零组件与目标零组件的ID对应关系后再执行导入操作", "警告", 1); + return; + } + + int currentIndex = ris.getCurrentItemID().getColumnIndex(); + System.out.println("当前零组件对应的列为" + currentIndex); + int relativeIndex = ris.getRelativeItemID().getColumnIndex(); + System.out.println("目标零组件对应的列为" + relativeIndex); + + String relation = ris.getRelation(); + String propertyName = ""; + if (relation.equals("")) { + // MessageBox.post("所指定的关系为空,请先指定关系", "警告", 1); + // return; + } + int propertyIndex = -2; + if (ris.getProperty() != null) { + propertyIndex = ris.getProperty().getColumnIndex(); + } + try { + System.out.println("开始初始化解析excel文件的类"); + POIExcelParser parser = new POIExcelParser(input, 0, ris.getColumns(), 1); + reporter.setTaskRange(0, parser.rows); + List line = null; + System.out.println("开始解析excel文件"); + while ((line = parser.parseLine()) != null) { + reporter.setProgressPercent(parser.startRow); + reporter.reportProgressMessage("正在导入第 " + parser.startRow + " 行数据"); + + String currentID = line.get(currentIndex).trim(); + String relativeID = line.get(relativeIndex).trim(); + if (propertyIndex != -2) { + propertyName = line.get(propertyIndex).trim(); + } + + // if ((propertyName == null) || (propertyName.length() == 0) || + // (relation == null) || (relation.length() == 0)) { + // MessageBox.post("所指定的关系和属性为空,请先指定关系或属性", "警告", 1); + // return; + // } + if (currentID.equals("") || relativeID.equals("")) { + System.out.println("【警告】excel中 第" + parser.startRow + "行零组件ID或者目标零组件ID为空,不进行导入"); + System.out.println("当前零组件ID或者目标零组件ID为空,不进行处理"); + continue; + } + + System.out.println("开始查找当前零组件"); + TCComponentItem currentItem = itemType.find(currentID); + if (currentItem == null) { + System.out.println("【警告】excel中 第" + parser.startRow + "行零组件不存在,不进行导入"); + System.out.println("所指定的当前零组件不存在"); + continue; + } + System.out.println("当前零组件查找完成"); + + System.out.println("开始查找目标零组件"); + TCComponentItem relativeItem = itemType.find(relativeID); + if (relativeItem == null) { + System.out.println("【警告】excel中 第" + parser.startRow + "行目标零组件不存在,不进行导入"); + System.out.println("所指定的目标零组件不存在"); + continue; + } + System.out.println("目标零组件查找完成"); + + String currentRevision = null; + if (ris.getCurrentItemRevision() != null) { + currentRevision = line.get(ris.getCurrentItemRevision().getColumnIndex()); + } + + String relativeRevision = null; + if (ris.getRelativeItemRevision() != null) { + relativeRevision = line.get(ris.getRelativeItemRevision().getColumnIndex()); + } + if (relation.equals("")) { + if(propertyName!=""){ + establishRelation(parser.startRow, currentItem, relativeItem, currentRevision, relativeRevision, propertyName); + } + } else { + establishRelation(parser.startRow, currentItem, relativeItem, currentRevision, relativeRevision, relation); + } + } + } catch (Exception e) { + logger.error("导入关系失败 - " + e.getMessage()); + logger.debug(e.toString()); + } + } + + private void establishRelation(int row, TCComponentItem currentItem, TCComponentItem relativeItem, String currentRevision, String relativeRevision, String relation) throws Exception { + TCComponent parent = currentItem; + TCComponent child = relativeItem; + System.out.println("relation====" + relation); + TCComponentItemRevision revision = null; + if ((currentRevision == null) || (currentRevision.length() == 0)) { + System.out.println("没有指定当前零组件的版本"); + // revision = currentItem.getLatestItemRevision(); + } else { + System.out.println("开始查找指定的当前零组件版本"); + InterfaceAIFComponent[] coms = SearchUtility.searchComponentsCollection(session, "originSearchItemRevision", new String[] { "ItemID", "Revision" }, new String[] { currentItem.getProperty("item_id"), currentRevision }); + + if (coms != null && coms.length > 0) { + revision = (TCComponentItemRevision) coms[0]; + } + + // TCComponentItemRevision[] revisions = + // currentItem.getWorkingItemRevisions(); + // for (int i = 0; i < revisions.length; i++) + // { + // if + // (currentRevision.equals(revisions[i].getProperty("item_revision_id"))) + // { + // revision = revisions[i]; + // break; + // } + // } + + if (revision == null) { + System.out.println("【失败】excel中 第" + row + "行导入失败,原因是: 所指定的当前零组件的版本不存在"); + StringBufferDemo("ID:"+currentItem.getProperty("item_id")+". 【失败】excel中 第" + row + "行导入失败,原因是: 所指定的当前零组件的版本不存在\r\n","历史数据导入关系"); + fail++; + System.out.println("所指定的当前零组件的版本不存在"); + return; + } + + System.out.println("查找指定的当前零组件版本成功"); + + parent = revision; + } + + TCComponentItemRevision re = null; + if (relativeRevision == null) { + System.out.println("没有指定目标 零组件的版本"); + // re = relativeItem.getLatestItemRevision(); + } else { + System.out.println("开始查找目标零组件版本"); + + InterfaceAIFComponent[] coms = SearchUtility.searchComponentsCollection(session, "originSearchItemRevision", new String[] { "ItemID", "Revision" }, new String[] { relativeItem.getProperty("item_id"), relativeRevision }); + + if (coms != null && coms.length > 0) { + re = (TCComponentItemRevision) coms[0]; + } + + if (re == null) { + System.out.println("【失败】excel中 第" + row + "行导入失败,原因是: 所指定的目标零组件的版本不存在"); + StringBufferDemo("ID:"+relativeItem.getProperty("item_id")+". 【失败】excel中 第" + row + "行导入失败,原因是: 所指定的目标零组件的版本不存在\r\n","历史数据导入关系"); + fail++; + System.out.println("所指定的目标零组件的版本不存在"); + return; + } + + System.out.println("查找指定的目标零组件版本成功"); + + child = re; + } + + boolean find = false; + System.out.println("检查当前对象下是否已经存在指定关系的目标对象"); + AIFComponentContext[] contexts = parent.getRelated(relation); + if (contexts != null) { + System.out.println("contexts != null"); + for (int j = 0; j < contexts.length; j++) { + InterfaceAIFComponent iac = contexts[j].getComponent(); + if (iac.equals(child)) { + find = true; + break; + } + } + } + + if (!find) { + System.out.println("没有找到,将进行添加"); + parent.add(relation, child); + System.out.println("添加完成"); + } else { + System.out.println("【成功】excel中 第" + row + "行导入成功"); + System.out.println("已经存在,不进行处理"); + } + + success++; + } + + private void importBomsByJxl(BomsImportSettings bis, File input) { + System.out.println("BOM导入开始"); + if (bis.getParentMapping() == null || bis.getChildMapping() == null) { + MessageBox.post("请先选择父装配与子装配的ID后再执行导入", "警告", 1); + + return; + } + + int parentIndex = bis.getParentMapping().getColumnIndex(); + System.out.println("父级装配对应的列为" + parentIndex); + int childIndex = bis.getChildMapping().getColumnIndex(); + System.out.println("子级装配对应的列为" + childIndex); + + try { + System.out.println("开始初始化解析excel文件的类"); + JXLExcelParser parser = new JXLExcelParser(input, 0, bis.getColumns(), 1); + + reporter.setTaskRange(0, parser.rows); + List line = null; + System.out.println("开始解析excel文件"); + StringBuffer buffer = new StringBuffer(); + List set = new ArrayList(); + while ((line = parser.parseLine()) != null) { + reporter.setProgressPercent(parser.startRow); + reporter.reportProgressMessage("正在验证第 " + parser.startRow + " 行数据"); + String parentID = line.get(parentIndex); + if (parentID.trim().length() > 0) { + TCComponentItem item = itemType.find(parentID); + if (item == null) { + if (!set.contains(parentID)) { + set.add(parentID); + buffer.append("\n" + parser.startRow + ": " + parentID); + continue; + } + } + } + + String childID = line.get(childIndex); + if (childID.trim().length() > 0) { + TCComponentItem item = itemType.find(childID); + if (item == null) { + if (!set.contains(childID)) { + set.add(parentID); + buffer.append("\n" + parser.startRow + ": " + childID); + continue; + } + } + } + } + + if (buffer.length() > 1) { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "当前BOM中含有新物料,分别是:\n" + buffer.toString() + "\n\n请创建物料后,再进行导入", "错误", 1); + return; + } + + parser = new JXLExcelParser(input, 0, bis.getColumns(), 1); + while ((line = parser.parseLine()) != null) { + try { + reporter.setProgressPercent(parser.startRow); + reporter.reportProgressMessage("正在导入第 " + parser.startRow + " 行数据"); + + String parentID = line.get(parentIndex); + TCComponentItem parentItem = null; + System.out.println("开始查找父级装配所对应的零件 "); + if (parentID.trim().length() > 0) { + InterfaceAIFComponent[] coms = SearchUtility.searchComponentsCollection(session, "originSearchItem", new String[] { "ItemID" }, new String[] { parentID }); + + if (coms != null && coms.length > 0) { + parentItem = (TCComponentItem) coms[0]; + } + // parentItem = itemType.find(parentID); + } + if (parentItem == null) { + System.out.println("【失败】excel中 第" + parser.startRow + "行父装配的零组件不存在,不进行导入"); + StringBufferDemo("ID:"+parentID+". 【失败】excel中 第" + parser.startRow + "行父装配的零组件不存在,不进行导入\r\n","历史数据导入BOM"); + System.out.println("父装配的零组件不存在"); + fail++; + continue; + } + System.out.println("找到父级装配所对应的零件 "); + + String childID = line.get(childIndex); + System.out.println("开始查找子级装配所对应的零件 "); + TCComponentItem childItem = null; + if (childID.trim().length() > 0) { + InterfaceAIFComponent[] coms = SearchUtility.searchComponentsCollection(session, "originSearchItem", new String[] { "ItemID" }, new String[] { childID }); + + if (coms != null && coms.length > 0) { + childItem = (TCComponentItem) coms[0]; + } + // TCComponentItem childItem = itemType.find(childID); + } + if (childItem == null) { + System.out.println("【失败】excel中 第" + parser.startRow + "行子装配的零组件不存在,不进行导入"); + StringBufferDemo("ID:"+childID+". 【失败】excel中 第" + parser.startRow + "行子装配的零组件不存在,不进行导入\r\n","历史数据导入BOM"); + System.out.println("子装配的零组件不存在"); + fail++; + continue; + } + System.out.println("找到子级装配所对应的零件 "); + + String parantRevision = null; + if (bis.getParentRevMapping() != null) { + parantRevision = line.get(bis.getParentRevMapping().getColumnIndex()); + } + + String childRevision = null; + if (bis.getChildRevMapping() != null) { + childRevision = line.get(bis.getChildRevMapping().getColumnIndex()); + } + + MappingAttribute[] atts = bis.getBomLineMapping(); + Map properties = new HashMap(); + for (int i = 0; i < atts.length; i++) { + properties.put(atts[i].getTcAttribute(), line.get(atts[i].getColumnIndex())); + } + + establishBomStructrue(parser.startRow, parentItem, childItem, parantRevision, childRevision, properties); + } catch (Exception e) { + System.out.println("【失败】excel中 第" + parser.startRow + "行BOM导入失败"); + StringBufferDemo("【失败】excel中 第" + parser.startRow + "行BOM导入失败\r\n","历史数据导入BOM"); + fail++; + continue; + } + } + } catch (Exception e) { + e.printStackTrace(); + System.out.println("【失败】导入BOM失败"); + logger.error("导入BOM失败 - " + e.getMessage()); + logger.debug(e.toString()); + } + } + + + private void importBomsByPoi(BomsImportSettings bis, File input) { + System.out.println("BOM导入开始"); + if (bis.getParentMapping() == null || bis.getChildMapping() == null) { + MessageBox.post("请先选择父装配与子装配的ID后再执行导入", "警告", 1); + + return; + } + + int parentIndex = bis.getParentMapping().getColumnIndex(); + System.out.println("父级装配对应的列为" + parentIndex); + int childIndex = bis.getChildMapping().getColumnIndex(); + System.out.println("子级装配对应的列为" + childIndex); + + try { + System.out.println("开始初始化解析excel文件的类"); + POIExcelParser parser = new POIExcelParser(input, 0, bis.getColumns(), 1); + + reporter.setTaskRange(0, parser.rows); + List line = null; + System.out.println("开始解析excel文件"); + StringBuffer buffer = new StringBuffer(); + List set = new ArrayList(); + while ((line = parser.parseLine()) != null) { + reporter.setProgressPercent(parser.startRow); + reporter.reportProgressMessage("正在验证第 " + parser.startRow + " 行数据"); + String parentID = line.get(parentIndex); + if (parentID.trim().length() > 0) { + TCComponentItem item = itemType.find(parentID); + if (item == null) { + if (!set.contains(parentID)) { + set.add(parentID); + buffer.append("\n" + parser.startRow + ": " + parentID); + continue; + } + } + } + + String childID = line.get(childIndex); + if (childID.trim().length() > 0) { + TCComponentItem item = itemType.find(childID); + if (item == null) { + if (!set.contains(childID)) { + set.add(parentID); + buffer.append("\n" + parser.startRow + ": " + childID); + continue; + } + } + } + } + + if (buffer.length() > 1) { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "当前BOM中含有新物料,分别是:\n" + buffer.toString() + "\n\n请创建物料后,再进行导入", "错误", 1); + return; + } + + parser = new POIExcelParser(input, 0, bis.getColumns(), 1); + while ((line = parser.parseLine()) != null) { + try { + reporter.setProgressPercent(parser.startRow); + reporter.reportProgressMessage("正在导入第 " + parser.startRow + " 行数据"); + + String parentID = line.get(parentIndex); + TCComponentItem parentItem = null; + System.out.println("开始查找父级装配所对应的零件 "); + if (parentID.trim().length() > 0) { + InterfaceAIFComponent[] coms = SearchUtility.searchComponentsCollection(session, "originSearchItem", new String[] { "ItemID" }, new String[] { parentID }); + + if (coms != null && coms.length > 0) { + parentItem = (TCComponentItem) coms[0]; + } + // parentItem = itemType.find(parentID); + } + if (parentItem == null) { + System.out.println("【失败】excel中 第" + parser.startRow + "行父装配的零组件不存在,不进行导入"); + System.out.println("父装配的零组件不存在"); + fail++; + continue; + } + System.out.println("找到父级装配所对应的零件 "); + + String childID = line.get(childIndex); + System.out.println("开始查找子级装配所对应的零件 "); + TCComponentItem childItem = null; + if (childID.trim().length() > 0) { + InterfaceAIFComponent[] coms = SearchUtility.searchComponentsCollection(session, "originSearchItem", new String[] { "ItemID" }, new String[] { childID }); + + if (coms != null && coms.length > 0) { + childItem = (TCComponentItem) coms[0]; + } + // TCComponentItem childItem = itemType.find(childID); + } + if (childItem == null) { + System.out.println("【失败】excel中 第" + parser.startRow + "行子装配的零组件不存在,不进行导入"); + System.out.println("子装配的零组件不存在"); + fail++; + continue; + } + System.out.println("找到子级装配所对应的零件 "); + + String parantRevision = null; + if (bis.getParentRevMapping() != null) { + parantRevision = line.get(bis.getParentRevMapping().getColumnIndex()); + } + + String childRevision = null; + if (bis.getChildRevMapping() != null) { + childRevision = line.get(bis.getChildRevMapping().getColumnIndex()); + } + + MappingAttribute[] atts = bis.getBomLineMapping(); + Map properties = new HashMap(); + for (int i = 0; i < atts.length; i++) { + properties.put(atts[i].getTcAttribute(), line.get(atts[i].getColumnIndex())); + } + + establishBomStructrue(parser.startRow, parentItem, childItem, parantRevision, childRevision, properties); + } catch (Exception e) { + System.out.println("【失败】excel中 第" + parser.startRow + "行BOM导入失败"); + fail++; + continue; + } + } + } catch (Exception e) { + e.printStackTrace(); + System.out.println("【失败】导入BOM失败"); + logger.error("导入BOM失败 - " + e.getMessage()); + logger.debug(e.toString()); + } + } + + @SuppressWarnings("static-access") + private void establishBomStructrue(int row, TCComponentItem parentItem, TCComponentItem childItem, String parantRevision, String childRevision, Map properties) throws Exception { + TCComponentItemRevision revision = null; + if (parantRevision == null || parantRevision.trim().equals("")) { + System.out.println("没有指定父级装配的版本,将使用最新版本"); + // revision = parentItem.getLatestItemRevision(); + InterfaceAIFComponent[] coms = SearchUtility.searchComponentsCollection(session, "originSearchItemRevision", new String[] { "ItemID" }, new String[] { parentItem.getProperty("item_id") }); + + if (coms != null && coms.length > 0) { + revision = (TCComponentItemRevision) coms[coms.length - 1]; + } + } else { + System.out.println("将查找指定父级装配的版本"); + + InterfaceAIFComponent[] coms = SearchUtility.searchComponentsCollection(session, "originSearchItemRevision", new String[] { "ItemID", "Revision" }, new String[] { parentItem.getProperty("item_id"), parantRevision }); + + if (coms != null && coms.length > 0) { + revision = (TCComponentItemRevision) coms[0]; + } + } + + if (revision != null) { + TCComponentBOMWindow window = winType.create(null); + window.lock(); + + System.out.println("查找指定父级装配的版本成功"); + TCComponentBOMLine line = window.setWindowTopLine(parentItem, revision, null, null); + + // TCComponentBOMWindow win = winType.create(null); + // win.lock(); + + TCComponentItemRevision re = null; + if (childRevision == null || childRevision.trim().equals("")) { + System.out.println("没有指定子级装配的版本,将使用最新版本"); + // re = childItem.getLatestItemRevision(); + InterfaceAIFComponent[] coms = SearchUtility.searchComponentsCollection(session, "originSearchItemRevision", new String[] { "ItemID" }, new String[] { childItem.getProperty("item_id") }); + + if (coms != null && coms.length > 0) { + re = (TCComponentItemRevision) coms[coms.length - 1]; + } + } else { + System.out.println("将查找指定子级装配的版本"); + + InterfaceAIFComponent[] coms = SearchUtility.searchComponentsCollection(session, "originSearchItemRevision", new String[] { "ItemID", "Revision" }, new String[] { childItem.getProperty("item_id"), childRevision }); + + if (coms != null && coms.length > 0) { + re = (TCComponentItemRevision) coms[0]; + } + } + System.out.println("childRevision = " + childRevision +":: 子件对象re = " + re); + + if (re != null) { + System.out.println("查找指定子级装配的版本成功"); + + System.out.println("判断是不是已经搭建过结构"); + boolean find = false; + TCComponentBOMLine childLine = null; + TCComponent[] tccomponents = re.whereUsed(re.WHERE_USED_ALL); + if(tccomponents!=null&&tccomponents.length>0){ + for (int j = 0; j < tccomponents.length; j++) { + if(tccomponents[j] instanceof TCComponentItemRevision){ + TCComponentItemRevision itemrevision = (TCComponentItemRevision)tccomponents[j]; + if(itemrevision.equals(line.getItemRevision())){ + find = true; + System.out.println("【警告】excel中 第" + row + "行BOM已经搭建过,不进行导入"); + break; + } + } + } + } + + if (!find) { + System.out.println("没有搭建过结构"); + childLine = line.add(childItem, re, null, false, ""); + for (Iterator iterator = properties.keySet().iterator(); iterator.hasNext();) { + String key = iterator.next(); + String value = properties.get(key); + // System.out.println(key + " : " + value); + try { + childLine.setProperty(key, value); + } catch (TCException e) { + System.out.println("【失败】excel中 第" + row + "行导入失败,原因是: 子装配的属性 " + key + " 不正确,请检查后重新搭建该行"); + StringBufferDemo("ID:"+childItem.getProperty("item_id")+". 【失败】excel中 第" + row + "行导入失败,原因是: 子装配的属性 " + key + " 不正确,请检查后重新搭建该行\r\n","历史数据导入BOM"); + fail++; + // win.close(); + window.save(); + window.unlock(); + window.close(); + return; + } + } + + childLine.save(); + System.out.println("搭建结构完成"); + } + + success++; + System.out.println("【成功】excel中 第" + row + "行导入成功"); + } else { + System.out.println("【失败】excel中 第" + row + "行导入失败,原因是: 所指定的子装配的版本不存在"); + StringBufferDemo("ID:"+childItem.getProperty("item_id")+". 【失败】excel中 第" + row + "行导入失败,原因是: 所指定的子装配的版本不存在\r\n","历史数据导入BOM"); + System.out.println("所指定的子装配的版本不存在"); + fail++; + } + + line.save(); + window.save(); + window.unlock(); + window.close(); + } else { + System.out.println("【失败】excel中 第" + row + "行导入失败,原因是: 所指定的父装配的版本不存在"); + StringBufferDemo("ID:"+parentItem.getProperty("item_id")+". 【失败】excel中 第" + row + "行导入失败,原因是: 所指定的父装配的版本不存在\r\n","历史数据导入BOM"); + System.out.println("没有找到指定零组件的指定版本"); + fail++; + } + } + + private void importObjectsByJxl(ObjectsImportSettings ois, File input) { + System.out.println("对象导入开始"); + + try { + TCComponent[] uoms = uom.extent(); + Map uomMap = new HashMap(); + if (uoms != null) { + for (int i = 0; i < uoms.length; i++) { + uomMap.put(uoms[i].toString(), uoms[i]); + } + } + + int uomIndex = -1; + int idIndex = -1; + int nameIndex = -1; + + MappingAttribute[] items = ois.getItemMapping(); + MappingAttribute[] revisions = ois.getRevMapping(); + MappingAttribute[] forms = ois.getRevFormMapping(); + + for (int i = 0; i < items.length; i++) { + if ("item_id".equals(items[i].getTcAttribute())) { + idIndex = items[i].getColumnIndex(); + System.out.println("零组件ID所对应的列" + idIndex); + continue; + } + if ("uom_tag".equals(items[i].getTcAttribute())) { + uomIndex = items[i].getColumnIndex(); + System.out.println("测量单位所对应的列为" + uomIndex); + } + if ("object_name".equals(items[i].getTcAttribute())) { + nameIndex = items[i].getColumnIndex(); + System.out.println("名称所对应的列为" + nameIndex); + } + } + + if (idIndex < 0) { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "【失败】没有选择ID所对应的列,不能完成导入", "错误", 1); + return; + } + + if (nameIndex < 0) { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "【失败】没有选择名称所对应的列,不能完成导入", "错误", 1); + return; + } + + int itemRevIndex = -1; + for (int i = 0; i < revisions.length; i++) { + if ("item_revision_id".equals(revisions[i].getTcAttribute())) { + itemRevIndex = revisions[i].getColumnIndex(); + System.out.println("零组件版本所对应的列为" + itemRevIndex); + } + } + + JXLExcelParser parser = new JXLExcelParser(input, 0, ois.getColumns(), 1); + reporter.setTaskRange(0, parser.rows); + List line = null; + String id = ""; + String rev = ""; + while ((line = parser.parseLine()) != null) { + reporter.setProgressPercent(parser.startRow); + reporter.reportProgressMessage("正在导入第 " + parser.startRow + " 行数据"); + try { + String lastid = id; + id = line.get(idIndex); + if (id.length() > 0) { + TCComponent uomCom = null; + if (uomIndex >= 0) { + String uom = line.get(uomIndex); + if (uom.length() > 0) { + uomCom = uomMap.get(uom); + + if (uomCom == null) { + try { + if(line.get(nameIndex).equals("")){ + StringBufferDemo("ID:"+id+". 【失败】excel中 第"+ parser.startRow + "行导入失败,原因是: 所指定的单位没有在系统中定义\r\n","历史数据导入对象"); + }else{ + StringBufferDemo("ID:"+id+",名称:"+line.get(nameIndex)+". 【失败】excel中 第"+ parser.startRow + "行导入失败,原因是: 所指定的单位没有在系统中定义\r\n","历史数据导入对象"); + } + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println("【失败】excel中 第" + parser.startRow + "行导入失败,原因是: 所指定的单位没有在系统中定义."); + fail++; + continue; + } + } + } + + String lastRev = rev; + if (itemRevIndex > 0) { + rev = line.get(itemRevIndex); + } + //---判断是否是上一次的版本 zyn + if(!lastid.equals("")){ + if(lastid.equals(id)){ + if(!lastRev.equals("")){ + if(!lastRev.equals(rev)){ + k = 1; + } + } + }else{ + k = 1; + } + } + //---zyn + TCComponentItem item = null;// itemType.find(id); + InterfaceAIFComponent[] coms = SearchUtility.searchComponentsCollection(session, "originSearchItem", new String[] { "ItemID" }, new String[] { id }); + + if (coms != null && coms.length > 0) { + item = (TCComponentItem) coms[0]; + } + TCComponentItemRevision revision = null; + + List ps = new ArrayList(); + boolean refresh = false; + if (item == null) { + String name = line.get(nameIndex); + if (name.equals("")) { + try { + StringBufferDemo("ID:"+id+". 【失败】excel中 第" + parser.startRow + "行导入失败,原因是: 零组件的的名字为不允许为空值\r\n","历史数据导入对象"); + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println("【失败】excel中 第" + parser.startRow + "行导入失败,原因是: 零组件的的名字为不允许为空值"); + fail++; + continue; + } + + item = itemType.create(id, rev, ois.getItemType(), name, "", uomCom); + // item = itemType.create("159753", "A", + // "MnfDesign", "Test", "dddd", null); + revision = item.getLatestItemRevision(); + folder.add("contents", item); + System.out.println("零组件被成功创建 "); + } else { + refresh = true; + System.out.println("零组件已经存在于系统当中,不需要创建"); + } + + // if (!rev.equals("")) + // { + if (revision == null) { + System.out.println("查找指定的零组件版本 - " + rev); + coms = SearchUtility.searchComponentsCollection(session, "originSearchItemRevision", new String[] { "ItemID", "Revision" }, new String[] { id, rev }); + System.out.println("coms==="+coms); + if (coms != null && coms.length > 0) { + revision = (TCComponentItemRevision) coms[0]; + } + } + System.out.println("revision=="+revision); + if (revision == null && !rev.equals("")) { + refresh = false; + System.out.println("零组件已经存,但指定的版本不存在,现在将其修订至指定版本"); + revision = item.getLatestItemRevision().saveAs(rev, item.getProperty("object_name"), "", true, null, null); + TCComponent[] datasets = revision.getTCProperty("IMAN_specification").getReferenceValueArray(); + for(int i=0;i 0) { + logger.debug("找到名称为" + line.get(revisions[i].getColumnIndex()) + ",类型为" + relatedItemType + "的对象"); + if (cs[0] instanceof TCComponentItemRevision) { + TCComponentItemRevision tcc = (TCComponentItemRevision) cs[0]; + property.setPropertyData(tcc); + } + } else { + try { + StringBufferDemo("ID:"+id+",名称:"+line.get(nameIndex)+". 【失败】没有找到名称为" + line.get(revisions[i].getColumnIndex()) + ",类型为" + relatedItemType + "的对象\r\n","历史数据导入对象"); + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println("【失败】没有找到名称为" + line.get(revisions[i].getColumnIndex()) + ",类型为" + relatedItemType + "的对象"); + fail++; + continue; + } + } else { + logger.debug("relatedItemType = " + relatedItemType); + setTCProperty(property, line.get(revisions[i].getColumnIndex())); + } + ps.add(property); + } + } + revision.setTCProperties(ps.toArray(new TCProperty[ps.size()])); + System.out.println("更新创建的零组件上的属性成功 "); + + TCComponentForm form = getItemRevisionMasterForm(revision); + if (form != null) { + System.out.println("获取零组件版本Form成功,开始更新其属性"); + ps.clear(); + + // String itemType = ois.getItemType(); + + for (int i = 0; i < forms.length; i++) { + TCProperty property = form.getTCProperty(forms[i].getTcAttribute()); + if (property != null && property.getDescriptor().isModifiable()) { + // descriptor.isArray() + setTCProperty(property, line.get(forms[i].getColumnIndex())); + + ps.add(property); + } + + // Map map = + // form.getProperties(); + // for (Iterator iterator = + // map.keySet().iterator(); + // iterator.hasNext();) + // { + // TCProperty property = + // form.getTCProperty(iterator.next()); + // if (property.isRequired() && + // property.isPropValueNull() && + // !ps.contains(property)) + // { + // setTCProperty(property, ""); + // ps.add(property); + // } + } + form.setTCProperties(ps.toArray(new TCProperty[ps.size()])); + form.save(); + } else { + System.out.println("获取零组件版本Form失败"); + } + System.out.println("77777777777"); + MappingAttribute[] datasets = ois.getDatasetMapping(); + System.out.println("处理版本下面的数据集, 有" + datasets.length + "个需要处理"); + ps.clear(); + for (int i = 0; i < datasets.length; i++) { + try { + System.out.println("k==="+k); + logger.debug("开始处理第" + (i + 1) + "个"); + String filePath = line.get(datasets[i].getColumnIndex()); + if (filePath.trim().length() > 0) { + System.out.println("数据集的路径为" + filePath); + String ds = datasets[i].getTcAttribute(); + System.out.println("ds==" + ds); + // String sep = ois.getArraySeparator(); + //假如filePath以“||”就表示挂成多个数据集,如果以“;”就表示挂一个数据集,添加多个命名引用 + String[] files = filePath.split("\\|\\|"); + List fis = new ArrayList(); + for (int j = 0; j < files.length; j++) { + // File f = new + // File(input.getParent(), + // files[j]); + File f = new File(files[j]); + if (f.exists()) { + System.out.println("f.getAbsolutePath()==" + f.getAbsolutePath()); + fis.add(f.getAbsolutePath()); + } else { + System.out.println("文件" + f.getAbsolutePath() + "不存在,不予以处理"); + } + } + if (fis.size() > 0) { + String did = revision.getProperty("item_id");// datasetType.getNewID(revision); + did = did + "/" + revision.getProperty("item_revision_id"); + + System.out.println("生成的数据集id为" + did); + String[] refs = guessDatasetReferenceNames(ds, files); + System.out.println("refs.length==" + refs.length); + for (int j = 0; j < refs.length; j++) { + if (refs[j] == null) { + //System.out.println("【失败】excel中 第" + parser.startRow + "数据集导入失败,没有为文件" + files[j] + "找到命名的引用,请查看" + ds + "类型数据集的文件模板定义"); + //fail++; + continue; + } + } + + System.out.println("取得系统中指定文件类型所对应的数据集引用的名字成功完成"); + + AIFComponentContext[] cc = revision.getChildren("IMAN_specification"); + boolean find = false; + for (int j = 0; cc != null && j < cc.length; j++) { + InterfaceAIFComponent tcc = cc[j].getComponent(); + if (tcc instanceof TCComponentDataset) { + TCComponentDataset ods = (TCComponentDataset) tcc; +// if (ods.getProperty("object_name").equals(did) && ods.getProperty("object_type").equals(ds)) { + if (ods.getProperty("object_name").equals(did+"/"+k) && ods.getProperty("object_type").equals(ds)) { + find = true; + System.out.println("指定ID与类型的数据集已经存在,要更改其引用"); + if (fis.size() > 0) { + + ods.setFiles(fis.toArray(new String[fis.size()]), refs); + } + System.out.println("更改引用完成"); + break; + } + } + } + + System.out.println("find = " + find); + + if (!find) { + System.out.println("指定ID与类型的数据集已经不存在,将进行新建"); + TCComponentDataset tcd = datasetType.create(did+"/"+k, "", ds); + System.out.println("数据集新建完成"); + int ifail = -1; + for (int j = 0; j < refs.length; j++) { + if (refs[j] == null) { + ifail = j; + break; + } + } + + if (ifail > 0) { + MessageBox.post("没有为文件以下文件找到数据集的引用\n" + files[ifail], "错误", 1); + continue; + } + if (fis.size() > 0) { + for(int l=0;l uomMap = new HashMap(); + if (uoms != null) { + for (int i = 0; i < uoms.length; i++) { + uomMap.put(uoms[i].toString(), uoms[i]); + } + } + + int uomIndex = -1; + int idIndex = -1; + int nameIndex = -1; + + MappingAttribute[] items = ois.getItemMapping(); + MappingAttribute[] revisions = ois.getRevMapping(); + MappingAttribute[] forms = ois.getRevFormMapping(); + + for (int i = 0; i < items.length; i++) { + if ("item_id".equals(items[i].getTcAttribute())) { + idIndex = items[i].getColumnIndex(); + System.out.println("零组件ID所对应的列" + idIndex); + continue; + } + if ("uom_tag".equals(items[i].getTcAttribute())) { + uomIndex = items[i].getColumnIndex(); + System.out.println("测量单位所对应的列为" + uomIndex); + } + if ("object_name".equals(items[i].getTcAttribute())) { + nameIndex = items[i].getColumnIndex(); + System.out.println("名称所对应的列为" + nameIndex); + } + } + + if (idIndex < 0) { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "【失败】没有选择ID所对应的列,不能完成导入", "错误", 1); + return; + } + + if (nameIndex < 0) { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "【失败】没有选择名称所对应的列,不能完成导入", "错误", 1); + return; + } + + int itemRevIndex = -1; + for (int i = 0; i < revisions.length; i++) { + if ("item_revision_id".equals(revisions[i].getTcAttribute())) { + itemRevIndex = revisions[i].getColumnIndex(); + System.out.println("零组件版本所对应的列为" + itemRevIndex); + } + } + + POIExcelParser parser = new POIExcelParser(input, 0, ois.getColumns(), 1); + reporter.setTaskRange(0, parser.rows); + List line = null; + while ((line = parser.parseLine()) != null) { + reporter.setProgressPercent(parser.startRow); + reporter.reportProgressMessage("正在导入第 " + parser.startRow + " 行数据"); + try { + String id = line.get(idIndex); + if (id.length() > 0) { + TCComponent uomCom = null; + if (uomIndex >= 0) { + String uom = line.get(uomIndex); + if (uom.length() > 0) { + uomCom = uomMap.get(uom); + + if (uomCom == null) { + System.out.println("【失败】excel中 第" + parser.startRow + "行导入失败,原因是: 所指定的单位没有在系统中定义."); + fail++; + continue; + } + } + } + + String rev = ""; + if (itemRevIndex > 0) { + rev = line.get(itemRevIndex); + } + + TCComponentItem item = null;// itemType.find(id); + InterfaceAIFComponent[] coms = SearchUtility.searchComponentsCollection(session, "originSearchItem", new String[] { "ItemID" }, new String[] { id }); + + if (coms != null && coms.length > 0) { + item = (TCComponentItem) coms[0]; + } + TCComponentItemRevision revision = null; + List ps = new ArrayList(); + boolean refresh = false; + if (item == null) { + String name = line.get(nameIndex); + if (name.equals("")) { + System.out.println("【失败】excel中 第" + parser.startRow + "行导入失败,原因是: 零组件的的名字为不允许为空值"); + fail++; + continue; + } + + item = itemType.create(id, rev, ois.getItemType(), name, "", uomCom); + // item = itemType.create("159753", "A", + // "MnfDesign", "Test", "dddd", null); + revision = item.getLatestItemRevision(); + folder.add("contents", item); + System.out.println("零组件被成功创建 "); + } else { + refresh = true; + System.out.println("零组件已经存在于系统当中,不需要创建"); + } + + // if (!rev.equals("")) + // { + if (revision == null) { + System.out.println("查找指定的零组件版本 - " + rev); + coms = SearchUtility.searchComponentsCollection(session, "originSearchItemRevision", new String[] { "ItemID", "Revision" }, new String[] { id, rev }); + + if (coms != null && coms.length > 0) { + revision = (TCComponentItemRevision) coms[0]; + } + } + + if (revision == null && !rev.equals("")) { + refresh = false; + System.out.println("零组件已经存,但指定的版本不存在,现在将其修订至指定版本"); + revision = item.getLatestItemRevision().saveAs(rev, item.getProperty("object_name"), "", true, null, null); + System.out.println("修订至指定版本成功"); + } + if (revision == null) { + revision = item.getLatestItemRevision(); + } + // ps.clear(); + // for (int i = 0; i < revisions.length; + // i++) + // { + // if(revisions[i].getTcAttribute().equals("item_revision_id")) + // { + // continue; + // } + // + // TCProperty property = + // revision.getTCProperty(revisions[i].getTcAttribute()); + // if (property != null && + // property.getPropertyDescriptor().isModifiable()) + // { + // setTCProperty(property, + // line.get(revisions[i].getColumnIndex())); + // ps.add(property); + // } + // } + // revision.setTCProperties(ps.toArray(new + // TCProperty[ps.size()])); + // } + // else + // { + // if (revision == null) + // { + // revision = item.getLatestItemRevision(); + // } + // } + if ((refresh && ois.isExistedRefreshed()) || !refresh) { + String name = line.get(nameIndex); + if (name.equals("")) { + System.out.println("【失败】excel中 第" + parser.startRow + "行更新失败,原因是: 零组件的的名字为不允许为空值"); + fail++; + continue; + } + + if (uomCom != null) { + try { + item.setReferenceProperty("uom_tag", uomCom); + } catch (Exception e) { + System.out.println("【失败】excel中 第" + parser.startRow + "行更新失败,原因是: 该行零组件的单位不允许修改,请检查其时事已经搭建过BOM"); + fail++; + continue; + } + } + System.out.println("更新零组件上的属性"); + ps.clear(); + for (int i = 0; i < items.length; i++) { + if (items[i].equals("uom_tag") || items[i].equals("object_name")) { + continue; + } + TCProperty property = item.getTCProperty(items[i].getTcAttribute()); + if (property != null && property.getPropertyDescriptor().isModifiable()) { + // { + setTCProperty(property, line.get(items[i].getColumnIndex())); + ps.add(property); + // } + // catch (TCException e) + // { + // System.out.println("【警告】excel中 第" + + // parser.startRow + "行Form属性 " + // + property.getPropertyName() + + // " 更新失败,请检查后重新导入该行"); + // } + } + } + item.setTCProperties(ps.toArray(new TCProperty[ps.size()])); + System.out.println("更新零组件上的属性成功完成更新 "); + + System.out.println("更新创建的零组件版本上的属性"); + revision.setProperty("object_name", item.getProperty("object_name")); + ps.clear(); + for (int i = 0; i < revisions.length; i++) { + TCProperty property = revision.getTCProperty(revisions[i].getTcAttribute()); + + // revision.setReferenceProperty(s, tccomponent) + // ps.add(property); + + if (property != null && property.getPropertyDescriptor().isModifiable()) { + logger.debug("更新属性 - " + property.getPropertyName()); + + String propertyName = property.getName(); + + String relatedItemType = null; + + // if (itemType.equals("MnfReqRecord") || + // itemType.equals("MnfMaterial") + // || itemType.equals("MnfReqReport") || + // itemType.equals("MnfStandard")) + // { + // if (propertyName.equals("MnfBrandOAttr")) + // { + // relatedItemType = "MnfBrandObj"; + // } + // } + // else if (itemType.equals("MnfPlanning") + // || itemType.equals("MnfResearch") + // || itemType.equals("MnfTesting") || + // itemType.equals("MnfSurStruc")) + // { + // if (propertyName.equals("MnfBrandOAttr")) + // { + // relatedItemType = "MnfBrandObj"; + // } + // else if + // (propertyName.equals("MnfCategoryOAttr")) + // { + // relatedItemType = "MnfCategoryObj"; + // } + // else if + // (propertyName.equals("MnfSeasonOAttr")) + // { + // relatedItemType = "MnfSeasonObj"; + // } + // } + // else if (itemType.equals("MnfProjDoc") || + // itemType.equals("MnfDesignDoc") + // || itemType.equals("MnfTech") || + // itemType.equals("MnfSampProduct") + // || itemType.equals("MnfRequirement") || + // itemType.equals("MnfProduct")) + // { + if (propertyName.equals("MnfBrandOAttr")) { + relatedItemType = "MnfBrandObj"; + } else if (propertyName.equals("MnfCategoryOAttr")) { + relatedItemType = "MnfCategoryObj"; + } else if (propertyName.equals("MnfProdLineOAttr")) { + relatedItemType = "MnfProdLineObj"; + } else if (propertyName.equals("MnfSeasonOAttr")) { + relatedItemType = "MnfSeasonObj"; + } else if (propertyName.equals("MnfSeriesOAttr")) { + relatedItemType = "MnfSeriesObj"; + } else if (propertyName.equals("MnfStyleOAttr")) { + relatedItemType = "MnfStyleObj"; + } + // } + // else if (itemType.equals("MnfFabric")) + // { + else if (propertyName.equals("MnfMaterialBOAttr")) { + relatedItemType = "MnfMaterialBType"; + } else if (propertyName.equals("MnfMaterialSOAttr")) { + relatedItemType = "MnfMaterialSType"; + } + // } + if (relatedItemType != null) { + logger.debug("通过名字和类型查找对应的Item对象"); + InterfaceAIFComponent[] cs = SearchUtility.searchComponentsCollection(session, "originSearchGeneral", new String[] { "Name", "Type" }, new String[] { line.get(revisions[i].getColumnIndex()), relatedItemType + "Revision" }); + if (cs != null && cs.length > 0) { + logger.debug("找到名称为" + line.get(revisions[i].getColumnIndex()) + ",类型为" + relatedItemType + "的对象"); + if (cs[0] instanceof TCComponentItemRevision) { + TCComponentItemRevision tcc = (TCComponentItemRevision) cs[0]; + property.setPropertyData(tcc); + } + } else { + logger.error("【失败】没有找到名称为" + line.get(revisions[i].getColumnIndex()) + ",类型为" + relatedItemType + "的对象"); + fail++; + continue; + } + } else { + logger.debug("relatedItemType = " + relatedItemType); + setTCProperty(property, line.get(revisions[i].getColumnIndex())); + } + ps.add(property); + } + } + revision.setTCProperties(ps.toArray(new TCProperty[ps.size()])); + System.out.println("更新创建的零组件上的属性成功 "); + TCComponentForm form = getItemRevisionMasterForm(revision); + if (form != null) { + System.out.println("获取零组件版本Form成功,开始更新其属性"); + ps.clear(); + for (int i = 0; i < forms.length; i++) { + + TCProperty property = form.getTCProperty(forms[i].getTcAttribute()); + if (property != null && property.getDescriptor().isModifiable()) { + + setTCProperty(property, line.get(forms[i].getColumnIndex())); + ps.add(property); + } + } + form.setTCProperties(ps.toArray(new TCProperty[ps.size()])); + form.save(); + } else { + System.out.println("获取零组件版本Form失败"); + } + MappingAttribute[] datasets = ois.getDatasetMapping(); + System.out.println("处理版本下面的数据集, 有" + datasets.length + "个需要处理"); + ps.clear(); + for (int i = 0; i < datasets.length; i++) { + try { + logger.debug("开始处理第" + (i + 1) + "个"); + String filePath = line.get(datasets[i].getColumnIndex()); + if (filePath.trim().length() > 0) { + System.out.println("数据集的路径为" + filePath); + String ds = datasets[i].getTcAttribute(); + // String sep = ois.getArraySeparator(); + //假如filePath以“||”就表示挂成多个数据集,如果以“;”就表示挂一个数据集,添加多个命名引用 + String[] files = filePath.split("\\|\\|"); + List> fis = new ArrayList>(); + for (int j = 0; j < files.length; j++) { + String filepath = files[j].trim(); + if(filepath.contains(";")){ + String[] filepaths = filepath.split(";"); + List list = new ArrayList(); + for(int k=0;k list = new ArrayList(); + for(int k=0;k 0) { + String did = revision.getProperty("item_id"); + did = did + "/" + revision.getProperty("item_revision_id"); + + System.out.println("生成的数据集id为" + did); + String[] refs = guessDatasetReferenceNames(ds, files); + for (int j = 0; j < refs.length; j++) { + if (refs[j] == null) { + logger.error("【失败】excel中 第" + parser.startRow + "数据集导入失败,没有为文件" + files[j] + "找到命名的引用,请查看" + ds + "类型数据集的文件模板定义"); + fail++; + continue; + } + } + System.out.println("取得系统中指定文件类型所对应的数据集引用的名字成功完成"); + if(fis.size()==1){ + List listString = fis.get(0); + AIFComponentContext[] cc = revision.getChildren("IMAN_specification"); + List listComponent = new ArrayList(); + for (int j = 0; j < cc.length; j++) { + InterfaceAIFComponent tcc = cc[j].getComponent(); + if (tcc instanceof TCComponentDataset) { + TCComponentDataset ods = (TCComponentDataset) tcc; + if (ods.getType().equals(ds)) { + listComponent.add(cc[j]); + } + } + } + if(listComponent.size()>0){ + if(listComponent.size()>1){ + for(int k=0;k 0) { + MessageBox.post("没有为文件以下文件找到数据集的引用\n" + files[ifail], "错误", 1); + continue; + } + removeNRFiles(tcd, refs[0], tcd.getTcFiles()); + for(int l=0;l listComponent = new ArrayList(); + for (int j = 0; j < cc.length; j++) { + InterfaceAIFComponent tcc = cc[j].getComponent(); + if (tcc instanceof TCComponentDataset) { + TCComponentDataset ods = (TCComponentDataset) tcc; + if (ods.getType().equals(ds)) { + listComponent.add(cc[j]); + } + } + } + for(int k=0;k filePathCount = fis.get(count); + TCComponentDataset tcd = null; + String filepath = filePathCount.get(0); + + String datasetName = did; +// String datasetName = did+filepath.substring(filepath.lastIndexOf("-"),filepath.lastIndexOf(".")); + + tcd = datasetType.create(datasetName, "", ds); + System.out.println("数据集新建完成"); + int ifail = -1; + for (int j = 0; j < refs.length; j++) { + if (refs[j] == null) { + ifail = j; + break; + } + } + if (ifail > 0) { + MessageBox.post("没有为文件以下文件找到数据集的引用\n" + files[ifail], "错误", 1); + continue; + } + removeNRFiles(tcd, refs[0], tcd.getTcFiles()); + for(int l=0;l hashtable = new Hashtable(contexts.length); + String all = ""; + for (int i = 0; i < contexts.length; i++) { + String template = contexts[i].getFileTemplate(); + int index = template.lastIndexOf("."); + if (index != -1) { + hashtable.put(template.substring(index + 1).toLowerCase(), contexts[i].getNamedReference()); + } else { + all = template.toLowerCase(); + hashtable.put(all, contexts[i].getNamedReference()); + } + } + + String refers[] = new String[files.length]; + System.out.println("有" + files.length + "个文件需要获取数据集引用"); + for (int i = 0; i < files.length; i++) { + String name = (new File(files[i])).getName(); + refers[i] = hashtable.get(name.substring(name.lastIndexOf(".") + 1).toLowerCase()); + if (refers[i] == null) { + refers[i] = hashtable.get(all); + } + + System.out.println(name.substring(name.lastIndexOf(".") + 1).toLowerCase() + "对应" + refers[i]); + } + + return refers; + } + + private void setTCProperty(TCProperty property, String value) throws TCException { + System.out.println("setTCProperty(TCProperty property 更新属性=" + property.getPropertyName() + ", String value=" + value + ") - start"); +// if (value == null || value.length() == 0) { +// System.out.println("setTCProperty(TCProperty property, String value) - end"); +// return; +// } + TCPropertyDescriptor descriptor = property.getPropertyDescriptor(); + boolean isArray = descriptor.isArray(); + if (!isArray) { + switch (descriptor.getType()){ + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + logger.debug("对应的类型为字符串"); + property.setStringValueData(value); + break; + case TCProperty.PROP_char: + logger.debug("对应的类型为字符"); + if (value.length() > 0) { + property.setCharValueData(value.charAt(0)); + } + break; + case TCProperty.PROP_double: + logger.debug("对应的类型为double"); + property.setDoubleValueData(Double.parseDouble(value)); + break; + case TCProperty.PROP_float: + logger.debug("对应的类型为float"); + property.setFloatValueData(Float.parseFloat(value)); + break; + case TCProperty.PROP_int: + case TCProperty.PROP_short: + logger.debug("对应的类型为int或者short"); + property.setIntValueData(Integer.parseInt(value)); + break; + case TCProperty.PROP_logical: + logger.debug("对应的类型为Boolean"); + property.setLogicalValueData(Boolean.parseBoolean(value)); + break; + case TCProperty.PROP_date: + logger.debug("对应的类型为日期类型"); + try { + property.setDateValueData(new SimpleDateFormat().parse(value)); + } catch (ParseException e) { + logger.error("setTCProperty(TCProperty property, String value)", e); + + e.printStackTrace(); + } + break; + } + } else { + System.out.println("对应的属性为数组类型,不予以处理"); + } + + System.out.println("setTCProperty(TCProperty property, String value) - end"); + } + + private TCComponentForm getItemRevisionMasterForm(TCComponentItemRevision revision) throws TCException { + if (revision != null) { + AIFComponentContext[] contexts = revision.getChildren("IMAN_master_form_rev"); + if (contexts != null && contexts.length > 0) { + InterfaceAIFComponent component = contexts[0].getComponent(); + if (component instanceof TCComponentForm) { + TCComponentForm form = (TCComponentForm) component; + + return form; + } + } + } + + return null; + } + + public void removeNRFiles(TCComponentDataset dataset, String namedReference, TCComponentTcFile files[]) + throws Exception + { + + System.out.println("--------------------开始删除文件操作------------------------"); + + try + { + + TCComponent comps[] = dataset.getNamedRefComponents(namedReference); + if(comps != null && comps.length > 0) + { + + for(int i = 0; i < comps.length; i++) + dataset.removeNamedReference(namedReference); + + } + for(int i = 0; i < files.length; i++) + if(files[i] != null) + { + + try + { + files[i].delete(); + } + catch(Exception e) + { + e.printStackTrace(); + + } + } + + } + catch(Exception e) + { + e.printStackTrace(); + } + + } + + public void importFilesOperation(TCComponentDataset dataset,File file,String fileType,String refType){ + System.out.println("-----------------------------开始进行文件的上传工作---------------------------"); + String as[] = { + file.getPath() + }; + String as1[] = { + fileType + }; + String as2[] = { + "Plain" + }; + String as3[] = { + refType + }; + try { + dataset.setFiles(as, as1, as2, as3); + } catch (TCException e) { + e.printStackTrace(); + } + session.setReadyStatus(); + } + + // 写日志 + public void StringBufferDemo(String strContext, String strFileName) throws IOException { + //logpath = System.getProperty("java.io.tmpdir")+File.separator+ strFileName; + logpath = "C:\\"+strFileName+"_"+systitem+".log"; + File file = new File(logpath); + if (!file.exists()) + file.createNewFile(); + FileOutputStream out = new FileOutputStream(file, true); + StringBuffer sb = new StringBuffer(strContext); + out.write(sb.toString().getBytes("gb2312")); + out.close(); + } + +// //删除日志 +// public void deleteLog(String strFileName) throws IOException { +// File file = new File(System.getProperty("java.io.tmpdir")+File.separator+"OriginTemp" + strFileName); +// if (file.exists()) +// file.delete(); +// } + + public static void main(String[] args) { + String filePath = "C:\\11.txt||C:\\22.txt"; + String[] str = filePath.split("\\|\\|"); + System.out.println(str.length); + System.out.println(str[0]); + System.out.println(str[1]); + } +} diff --git a/src/com/connor/dev/imp/.svn/text-base/ImportSettings.java.svn-base b/src/com/connor/dev/imp/.svn/text-base/ImportSettings.java.svn-base new file mode 100644 index 0000000..dda03a3 --- /dev/null +++ b/src/com/connor/dev/imp/.svn/text-base/ImportSettings.java.svn-base @@ -0,0 +1,110 @@ +package com.origin.dev.imp; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +public abstract class ImportSettings implements Serializable +{ + private static final long serialVersionUID = 1L; + + private boolean saved; + + private int columns; + + private String dateFormat; + + //private String arraySeparator; + + public boolean save(File file) + { + try + { + FileOutputStream fos = new FileOutputStream(file); + ObjectOutputStream oos = new ObjectOutputStream(fos); + oos.writeObject(this); + oos.flush(); + oos.close(); + + saved = true; + + return true; + } + catch (IOException ioe) + { + ioe.printStackTrace(); + } + + return false; + } + + public ImportSettings load(File file) + { + try + { + FileInputStream fis = new FileInputStream(file); + ObjectInputStream ois = new ObjectInputStream(fis); + Object o = ois.readObject(); + + ois.close(); + fis.close(); + + saved = false; + + if (o instanceof ImportSettings) + { + return (ImportSettings) o; + } + } + catch (Exception e) + { + e.printStackTrace(); + } + + return null; + } + + public void setSaved(boolean saved) + { + this.saved = saved; + } + + public boolean isSaved() + { + return saved; + } + + public void setColumns(int columns) + { + this.columns = columns; + } + + public int getColumns() + { + return columns; + } + + public String getDateFormat() + { + return dateFormat; + } + + public void setDateFormat(String dateFormat) + { + this.dateFormat = dateFormat; + } + + // public String getArraySeparator() + // { + // return arraySeparator; + // } + // + // public void setArraySeparator(String arraySeparator) + // { + // this.arraySeparator = arraySeparator; + // } +} diff --git a/src/com/connor/dev/imp/.svn/text-base/MappingAttribute.java.svn-base b/src/com/connor/dev/imp/.svn/text-base/MappingAttribute.java.svn-base new file mode 100644 index 0000000..b4c40cc --- /dev/null +++ b/src/com/connor/dev/imp/.svn/text-base/MappingAttribute.java.svn-base @@ -0,0 +1,69 @@ +package com.origin.dev.imp; + +import java.io.Serializable; + +public class MappingAttribute implements Serializable +{ + private static final long serialVersionUID = 1L; + + private int columnIndex; + + private String columnTitle; + + private String tcAttribute; + + public MappingAttribute(int columnIndex, String columnTitle, String tcAttribute) + { + this.columnIndex = columnIndex; + this.columnTitle = columnTitle; + this.tcAttribute = tcAttribute; + } + + public int getColumnIndex() + { + return columnIndex; + } + + public void setColumnIndex(int columnIndex) + { + this.columnIndex = columnIndex; + } + + public String getColumnTitle() + { + return columnTitle; + } + + public void setColumnTitle(String columnTitle) + { + this.columnTitle = columnTitle; + } + + public String getTcAttribute() + { + return tcAttribute; + } + + public void setTcAttribute(String tcAttribute) + { + this.tcAttribute = tcAttribute; + } + + public boolean equals(Object obj) + { + if (!(obj instanceof MappingAttribute)) + { + return false; + } + else + { + MappingAttribute at = (MappingAttribute) obj; + return tcAttribute.equals(at.tcAttribute); + } + } + + public String toString() + { + return "(" + columnIndex + ")" + columnTitle + " => " + tcAttribute; + } +} diff --git a/src/com/connor/dev/imp/AbstractImportCommand.java b/src/com/connor/dev/imp/AbstractImportCommand.java new file mode 100644 index 0000000..c2ad4db --- /dev/null +++ b/src/com/connor/dev/imp/AbstractImportCommand.java @@ -0,0 +1,77 @@ +package com.connor.dev.imp; + +import com.connor.dev.imp.ob.ImportObjectsCommand; +import com.connor.dev.imp.toolkit.ProgressReporter; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public abstract class AbstractImportCommand extends AbstractAIFCommand { + protected TCSession session; + protected boolean isExec; + + public AbstractImportCommand(AbstractAIFUIApplication application, + boolean isExec) { + this.session = (TCSession) application.getSession(); + this.isExec = isExec; + processImporting(); + } + + public AbstractImportCommand(AbstractAIFUIApplication application) { + this.session = (TCSession) application.getSession(); + + processImporting(); + } + + private void processImporting() { + + InterfaceAIFComponent targetCom = null; + if (isExec) { + try { + targetCom = this.session.getUser().getNewStuffFolder(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + targetCom = AIFUtility.getCurrentApplication() + + .getTargetComponent(); + } + // 如果在选择导入功能前选中了某个已有文件夹 + if (this instanceof ImportObjectsCommand) { + if (!(targetCom instanceof TCComponentFolder)) { + MessageBox msg = new MessageBox("导入失败", + "提示:\n请您先选择对象导入的文件夹!然后再执行导入!\n", "执行错误", 1, true); + msg.setVisible(true); + return; + } + } + + final ProgressReporter reporter = new ProgressReporter(); + reporter.reportProgressMessage("正在初始化界面,请稍候..."); + new Thread(reporter).start(); + new Thread(new Runnable() { + public void run() { + while (!reporter.isRequestCanceling()) { + reporter.setProgressPercent(reporter.getProgess() + 5); + + try { + Thread.sleep(500); + } catch (InterruptedException e) { + continue; + } + } + } + }).start(); + importHistoryDatas(); + reporter.requestCanceling(); + } + + protected abstract void importHistoryDatas(); +} diff --git a/src/com/connor/dev/imp/AbstractImportDialog.java b/src/com/connor/dev/imp/AbstractImportDialog.java new file mode 100644 index 0000000..b15c10c --- /dev/null +++ b/src/com/connor/dev/imp/AbstractImportDialog.java @@ -0,0 +1,891 @@ +package com.connor.dev.imp; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.DefaultComboBoxModel; +import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.event.ChangeListener; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + +import jxl.Cell; +import jxl.Sheet; +import jxl.Workbook; +import jxl.read.biff.BiffException; + +import org.apache.poi.hssf.usermodel.HSSFDataFormatter; +import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.dev.imp.ob.StaticEnum; +import com.connor.dev.imp.toolkit.ProgressReporter; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.common.TCUtilities; +import com.teamcenter.rac.common.create.DisplayTypeInfo; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.AIFImageIcon; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public abstract class AbstractImportDialog extends AbstractAIFDialog implements +ActionListener, ChangeListener, ListSelectionListener { + private static final long serialVersionUID = 1L; + private JTextField filePathField; + private List errList = new ArrayList(); + public JButton browse; + // private JTextField logPathField; + protected JTextField dateFormatField; + // protected JTextField arraySepField; + protected JList excelList; + + protected DefaultListModel excelListModel; + + protected JList[] propertiesList; + + protected JList[] mappingList; + + protected DefaultListModel[] propertiesListModels; + + protected DefaultListModel[] mappingListModels; + + protected JTabbedPane rightPane; + + public JButton add; + + public JButton remove; + + public JButton execute; + public JButton unlock; + public JButton save; + public JButton open; + protected TCSession session; + protected JFileChooser chooser; + protected File importFile; + private ProgressReporter reporter; + + protected int locationTemp = -2;// 特殊路径 + protected int typeIndex = -2;// 特殊类型 + protected int relIndex = -2;// 特殊关系 + + public String exportFilePath; + public String settingFilePath; + public boolean isExec = false; + + public AbstractImportDialog(TCSession session, String title, boolean modal, + String exportFilePath, String settingFilePath, boolean isExec) { + + this(session, title, modal); + this.isExec = isExec; + this.exportFilePath = exportFilePath; + this.settingFilePath = settingFilePath; + StaticEnum.isExec = true; + } + + public AbstractImportDialog(TCSession session, String title, boolean modal) { + super(modal); + this.session = session; + chooser = new JFileChooser(); + chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + chooser.setMultiSelectionEnabled(false); + StaticEnum.isExec = false; + setTitle(title); + // setResizable(false); + setLayout(new BorderLayout()); + initializeUI(); + setComponentsTextProperty(); + addUIComponents(); + registerActionComponents(); + } + + protected void initializeUI() { + filePathField = new JTextField(30); + filePathField.setEditable(false); + + browse = new JButton(); + + // logPathField = new JTextField(30); + + dateFormatField = new JTextField(30); + // arraySepField = new JTextField(5); + + excelListModel = new DefaultListModel(); + excelList = new JList(excelListModel); + excelList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + rightPane = new JTabbedPane(); + + System.out.println("this.getClass().getSimpleName()===" + + this.getClass().getSimpleName()); + if (this.getClass().getSimpleName().equals("ImportRelationsDialog")) { + add = new JButton(AIFImageIcon.getImageIcon(this, + "images/cancel_16.png")); + add.setEnabled(false); + remove = new JButton(AIFImageIcon.getImageIcon(this, + "images/cancel_all_16.png")); + remove.setEnabled(false); + // remove.setVisible(false); + } else { + add = new JButton(AIFImageIcon.getImageIcon(this, + "images/add_16.png")); + add.setEnabled(false); + + remove = new JButton(AIFImageIcon.getImageIcon(this, + "images/remove_16.png")); + remove.setEnabled(false); + } + execute = new JButton(AIFImageIcon.getImageIcon(this, + "images/import_16.png")); + execute.setEnabled(false); + + unlock = new JButton(AIFImageIcon.getImageIcon(this, + "images/apply_16.png")); + + save = new JButton( + AIFImageIcon.getImageIcon(this, "images/save_16.png")); + + open = new JButton( + AIFImageIcon.getImageIcon(this, "images/open_16.png")); + + reporter = new ProgressReporter(); + } + + /** + * browse->open->unlock->execute + */ + protected void setComponentsTextProperty() { + browse.setText("..."); + execute.setToolTipText("执行导入操作"); + unlock.setToolTipText("激活更改配置"); + save.setToolTipText("保存配置"); + open.setToolTipText("导入配置"); + + if (this.getClass().getSimpleName().equals("ImportRelationsDialog")) { + add.setToolTipText("清除配置"); + remove.setToolTipText("清除所有配置"); + } else { + add.setToolTipText("添加映射"); + remove.setToolTipText("移除映射"); + } + + dateFormatField.setText("yyyy-MM-dd HH:mm:ss"); + dateFormatField.setToolTipText("设置日期格式,区分大小写:
    " + + "
  • y代表年
  • " + "
  • M代表月
  • " + "
  • d代表天
  • " + + "
  • H代表时
  • " + "
  • m代表分
  • " + "
  • s代表秒
  • " + + "
"); + + // doPurgeComponentProperties(""); + } + + protected void registerActionComponents() { + add.addActionListener(this); + remove.addActionListener(this); + rightPane.addChangeListener(this); + + execute.addActionListener(this); + unlock.addActionListener(this); + save.addActionListener(this); + open.addActionListener(this); + browse.addActionListener(this); + + for (int i = 0; i < propertiesList.length; i++) { + propertiesList[i].addListSelectionListener(this); + mappingList[i].addListSelectionListener(this); + } + + excelList.addListSelectionListener(this); + } + + protected void addUIComponents() { + JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + topPanel.add(new JLabel("数据文件")); + topPanel.add(filePathField); + topPanel.add(browse); + // topPanel.add(new JLabel("日志文件")); + // topPanel.add(logPathField); + + JPanel raPanel = new JPanel(new FlowLayout()); + raPanel.add(add); + raPanel.add(remove); + + JPanel rightPanel = new JPanel(new BorderLayout()); + rightPanel.add(rightPane, BorderLayout.CENTER); + rightPanel.add(raPanel, BorderLayout.SOUTH); + + JSplitPane centerPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); + centerPanel.setDividerLocation(120); + centerPanel.setContinuousLayout(true); + centerPanel.setLeftComponent(new JScrollPane(excelList)); + + addTabbedPaneComponents(); + + centerPanel.setRightComponent(rightPanel); + + JPanel bottomPanel = new JPanel(new FlowLayout()); + bottomPanel.add(execute); + bottomPanel.add(unlock); + bottomPanel.add(save); + bottomPanel.add(open); + + add(topPanel, BorderLayout.NORTH); + add(centerPanel, BorderLayout.CENTER); + add(bottomPanel, BorderLayout.SOUTH); + } + + protected abstract void addTabbedPaneComponents(); + + protected JPanel getParameterPanel() { + JPanel p = new JPanel(new PropertyLayout()); + p.add("1.1.right.top.preferred.preferred", new JLabel("日期格式:")); + p.add("1.2.left.top.preferred.preferred", dateFormatField); + // p.add("2.1.right.top.preferred.preferred", new JLabel("数组内容分隔符:")); + // p.add("2.2.left.top.preferred.preferred", arraySepField); + + return p; + } + + protected String[] getTCComponentProperties(String name) { + String[] properties = null; + try { + TCTypeService typeService = session.getTypeService(); + TCComponentType typeComponent = typeService.getTypeComponent(name); + properties = typeComponent.getPropertyNames(); + } catch (TCException e) { + e.printStackTrace(); + } + + return properties; + } + + protected void populateTypeChoices(String name, JComboBox box) { + try { + TCTypeService service = session.getTypeService(); + TCComponentType[] items = service.getTypes(name); + if (items != null) { + for (int i = 0; i < items.length; i++) { + String item = items[i].toString(); + + if ("EngChange".equalsIgnoreCase(item)) { + continue; + } + // System.out.println(items[i].toString()); + box.addItem(items[i].toString()); + + // TCComponentItemType + // TCComponentType[] sub = items[i].isTypeOf(s); + System.out.println("d"); + // AIFComponentContext[] aifcs = items[i].getChildren(); + // for (AIFComponentContext aifc : aifcs) + // { + // InterfaceAIFComponent com = aifc.getComponent(); + // System.out.println(com.getClass()); + // } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + /* + * (non-Javadoc) + * + * @see + * javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event + * .ListSelectionEvent) + */ + public void valueChanged(ListSelectionEvent listselectionevent) { + checkMappingsEditable(); + } + + protected void checkMappingsEditable() { + int index = rightPane.getSelectedIndex(); + if (index < propertiesList.length) { + add.setEnabled(excelList.getSelectedIndex() != -1 + && propertiesList[index].getSelectedIndex() != -1); + remove.setEnabled(mappingList[index].getSelectedIndex() != -1); + } else { + if (this.getClass().getSimpleName().equals("ImportRelationsDialog")) { + add.setEnabled(true); + remove.setEnabled(true); + } else { + add.setEnabled(false); + remove.setEnabled(false); + } + } + } + + protected void doPurgeComponentProperties(String name) { + for (int i = 0; i < propertiesList.length - 1; i++) { + propertiesListModels[i].removeAllElements(); + mappingListModels[i].removeAllElements(); + } + } + + protected void doPurgeComponentProperties2(String name) { + for (int i = 0; i < propertiesList.length - 1; i++) { + propertiesListModels[i].removeAllElements(); + mappingListModels[i].removeAllElements(); + } + } + + /* + * (non-Javadoc) + * + * @see + * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) + */ + public void actionPerformed(ActionEvent ae) { + + if (ae.getSource() == add) { + if (!this.getClass().getSimpleName() + .equals("ImportRelationsDialog")) { + String excel = excelList.getSelectedValue().toString(); + int index = excelList.getSelectedIndex(); + String prop = propertiesList[rightPane.getSelectedIndex()] + .getSelectedValue().toString(); + + MappingAttribute ma = new MappingAttribute(index, excel, prop); + if (rightPane.getSelectedIndex() == 3) { + // TODO 添加特殊处理 特殊路径处理 + if (!mappingListModels[rightPane.getSelectedIndex()] + .contains(ma)) { + mappingListModels[rightPane.getSelectedIndex()] + .addElement(ma); + System.out.println("ADD_MSG = >>" + index + "/" + excel + + "/" + prop); + if (prop.equals("路径")) { + locationTemp = index; + } + } else if (!prop.equals("路径")) {// 只允许有一个路径,而别的类型却允许有多个 + mappingListModels[rightPane.getSelectedIndex()] + .addElement(ma); + } + } else if (rightPane.getSelectedIndex() == 0) { + // TODO 添加类型的特殊处理 + if (!mappingListModels[rightPane.getSelectedIndex()] + .contains(ma)) { + mappingListModels[rightPane.getSelectedIndex()] + .addElement(ma); + System.out.println("ADD_MSG = >>" + index + "/" + excel + + "/" + prop); + if (prop.equals("类型")) { + typeIndex = index; + } + } + } else { + // TODO 常规处理 + if (!mappingListModels[rightPane.getSelectedIndex()] + .contains(ma)) { + mappingListModels[rightPane.getSelectedIndex()] + .addElement(ma); + } + } + + } + } else if (ae.getSource() == remove) { + if (!this.getClass().getSimpleName() + .equals("ImportRelationsDialog")) { + // 针对特殊路径 + if (rightPane.getSelectedIndex() == 3) { + int temp_index = ((MappingAttribute) mappingListModels[rightPane + .getSelectedIndex()].get(mappingList[rightPane + .getSelectedIndex()].getSelectedIndex())) + .getColumnIndex(); + if (temp_index == locationTemp) { + locationTemp = -2; + System.out.println("移除路径"); + } + + } else if (rightPane.getSelectedIndex() == 0) { + int temp_index = ((MappingAttribute) mappingListModels[rightPane + .getSelectedIndex()].get(mappingList[rightPane + .getSelectedIndex()].getSelectedIndex())) + .getColumnIndex(); + if (temp_index == typeIndex) { + typeIndex = -2; + System.out.println("移除类型"); + } + } + mappingListModels[rightPane.getSelectedIndex()] + .remove(mappingList[rightPane.getSelectedIndex()] + .getSelectedIndex()); + + } + } else if (ae.getSource() == execute) { + executeImport(); + } else if (ae.getSource() == unlock) { + excelList.setEnabled(true); + for (int i = 0; i < propertiesList.length; i++) { + propertiesList[i].setEnabled(true); + mappingList[i].setEnabled(true); + } + } else if (ae.getSource() == open) { + if (filePathField.getText().trim().length() == 0) { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), + "请先选择要导入的数据文件", "警告", 1); + } else { + openImportSettings(); + } + } else if (ae.getSource() == save) { + saveImportSettings(); + } else if (ae.getSource() == browse) { + selectImportFile(); + if(errList.size() > 0) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < errList.size(); i++) { + sb.append(errList.get(i)); + } + MessageBox.post(sb.toString(),"错误",MessageBox.ERROR); + execute.setEnabled(false); + errList.clear(); + } + } + } + + /** + * 导入选择的文件夹 + * + */ + private void selectImportFile() { + excelListModel.removeAllElements(); + + if (this.isExec) { + importFile = new File(this.exportFilePath);// chooser.getSelectedFile(); + if (importFile != null) { + + if (importFile.exists() && importFile.isFile()) { + if (importFile.getAbsolutePath().endsWith(".xls")) { + try { + Workbook workbook = Workbook + .getWorkbook(importFile); + Sheet sheet = workbook.getSheet(0); + Cell[] row = sheet.getRow(0); + for (int i = 0; i < row.length; i++) { + if (row[i].getContents().trim().equals("")) { + excelListModel.addElement("(该列名字为空)"); + } else { + excelListModel.addElement(row[i] + .getContents()); + } + } + workbook.close(); + filePathField.setText(importFile.getAbsolutePath()); + execute.setEnabled(true); + + return; + } catch (BiffException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } else if (importFile.getAbsolutePath().endsWith(".xlsx")) { + try { + org.apache.poi.ss.usermodel.Workbook workbook = new XSSFWorkbook( + new FileInputStream(importFile)); + org.apache.poi.ss.usermodel.Sheet sheet = workbook + .getSheetAt(0); + Row row = sheet.getRow(0); + for (int i = 0; i < row.getPhysicalNumberOfCells(); i++) { + if (!row.getCell(i).getStringCellValue().trim() + .equals("")) { + String cellValue = getCellValue(row + .getCell(i)); + excelListModel.addElement(cellValue); + } + // else { + // excelListModel.addElement("(该列名字为空)"); + // } + } + Map> maps = new HashMap>(); + int rows = sheet.getLastRowNum(); + for (int i = 1; i < rows; i++) { + Row row2 = sheet.getRow(i); + String fuValue = getCellValue(row2 + .getCell(0)); + if("".equals(fuValue.trim())) { + continue; + } + String ziValue = getCellValue(row2 + .getCell(1)); + if(maps.containsKey(fuValue)) { + List list = maps.get(fuValue); + if(list.contains(ziValue)) { + errList.add("第"+(i+1)+"行存在相同子件,id号为: "+ziValue); + }else { + list.add(ziValue); + } + }else { + List ziIDs = new ArrayList(); + ziIDs.add(ziValue); + maps.put(fuValue, ziIDs); + } + } + filePathField.setText(importFile.getAbsolutePath()); + execute.setEnabled(true); + + return; + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + } else { + + if (chooser.showOpenDialog(null) == 0) { + + importFile = chooser.getSelectedFile(); + if (importFile != null) { + + if (importFile.exists() && importFile.isFile()) { + if (importFile.getAbsolutePath().endsWith(".xls")) { + try { + Workbook workbook = Workbook + .getWorkbook(importFile); + Sheet sheet = workbook.getSheet(0); + Cell[] row = sheet.getRow(0); + for (int i = 0; i < row.length; i++) { + if (row[i].getContents().trim().equals("")) { + excelListModel.addElement("(该列名字为空)"); + } else { + excelListModel.addElement(row[i] + .getContents()); + } + } + workbook.close(); + filePathField.setText(importFile + .getAbsolutePath()); + execute.setEnabled(true); + + return; + } catch (BiffException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } else if (importFile.getAbsolutePath().endsWith( + ".xlsx")) { + try { + org.apache.poi.ss.usermodel.Workbook workbook = new XSSFWorkbook( + new FileInputStream(importFile)); + org.apache.poi.ss.usermodel.Sheet sheet = workbook + .getSheetAt(0); + Row row = sheet.getRow(0); + for (int i = 0; i < row + .getPhysicalNumberOfCells(); i++) { + if (!row.getCell(i).getStringCellValue() + .trim().equals("")) { + String cellValue = getCellValue(row + .getCell(i)); + excelListModel.addElement(cellValue); + System.out.println("cellValue"+i+"==="+cellValue); + } + // else { + // excelListModel.addElement("(该列名字为空)"); + // } + } + Map> maps = new HashMap>(); + int rows = sheet.getLastRowNum(); + for (int i = 1; i < rows; i++) { + Row row2 = sheet.getRow(i); + String fuValue = getCellValue(row2 + .getCell(0)); + if("".equals(fuValue.trim())) { + continue; + } + String ziValue = getCellValue(row2 + .getCell(1)); + if(maps.containsKey(fuValue)) { + List list = maps.get(fuValue); + if(list.contains(ziValue)) { + errList.add("第"+(i+1)+"行存在相同子件,id号为: "+ziValue); + }else { + list.add(ziValue); + } + }else { + List ziIDs = new ArrayList(); + ziIDs.add(ziValue); + maps.put(fuValue, ziIDs); + } + } + filePathField.setText(importFile + .getAbsolutePath()); + execute.setEnabled(true); + + return; + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + } + + } + + execute.setEnabled(false); + } + + private void executeImport() { + if (checkNecessaryCondition()) { + setVisible(false); + + reporter.reportProgressMessage("正在导入数据,请稍候..."); + new Thread(reporter).start(); + + new Thread() { + public void run() { + try { + // callUserServices(session, "1", "ORIGIN_set_bypass"); + ImportFlex flex = new ImportFlex(session, reporter); + // 此处添加对数据集特殊路径的处理 + flex.locationIndex = locationTemp; + // 此处添加对对象的类型的特殊处理 + flex.typeIndex = typeIndex; + + flex.runImporting(generateImportSettings(), new File( + filePathField.getText())); + // callUserServices(session, "1", + // "ORIGIN_close_bypass"); + reporter.requestCanceling(); + dispose(); + if (flex.logpath.equals("")) { + MessageBox.post(AIFDesktop.getActiveDesktop() + .getShell(), "数据导入完成!\n\n成功条数 : " + + flex.success + "\n失败条数 : " + flex.fail, + "完成", MessageBox.INFORMATION); + } else { + MessageBox.post(AIFDesktop.getActiveDesktop() + .getShell(), "数据导入完成!\n\n成功条数 : " + + flex.success + "\n失败条数 : " + flex.fail + + "\n日志路径:" + flex.logpath, "完成", + MessageBox.ERROR); + } + + } catch (Throwable e) { + e.printStackTrace(); + + reporter.requestCanceling(); + MessageBox.post(AIFDesktop.getActiveDesktop() + .getShell(), "导入失败", "错误", 1); + setVisible(true); + } + } + }.start(); + } + } + + protected boolean checkNecessaryCondition() { + return true; + } + + protected abstract void openImportSettings(); + + protected abstract void saveImportSettings(); + + public abstract ImportSettings generateImportSettings(); + + protected void populateItemTypes(JComboBox box) { + // BaseClassInput[] abaseclassinput = new + // com.teamcenter.services.rac.core._2007_06.DataManagement.BaseClassInput[4]; + // for (int i = 0; i < 4; i++) + // abaseclassinput[i] = new + // com.teamcenter.services.rac.core._2007_06.DataManagement.BaseClassInput(); + // + // abaseclassinput[0].baseClass = "Item"; + // abaseclassinput[0].exclusionTypes = new String[] {}; + // abaseclassinput[1].baseClass = "MEProcess"; + // abaseclassinput[2].baseClass = "MEOP"; + // abaseclassinput[3].baseClass = "MEWorkarea"; + // + // com.teamcenter.services.rac.core._2007_06.DataManagement.GetAvailableTypesResponse + // getavailabletypesresponse + // = TCUtilities + // .getDisplayableTypeNames(session, abaseclassinput); + // Map map = getavailabletypesresponse.inputClassToTypes; + // com.teamcenter.services.rac.core._2007_06.DataManagement.BaseClassInput + // abaseclassinput1[] = abaseclassinput; + // int j = abaseclassinput1.length; + // for (int k = 0; k < j; k++) + // { + // com.teamcenter.services.rac.core._2007_06.DataManagement.BaseClassInput + // baseclassinput = abaseclassinput1[k]; + // com.teamcenter.services.rac.core._2007_06.DataManagement.AvailableTypeInfo + // aavailabletypeinfo[] = + // (com.teamcenter.services.rac.core._2007_06.DataManagement.AvailableTypeInfo[]) + // map + // .get(baseclassinput.baseClass); + // com.teamcenter.services.rac.core._2007_06.DataManagement.AvailableTypeInfo + // aavailabletypeinfo1[] = + // aavailabletypeinfo; + // int l = aavailabletypeinfo1.length; + // for (int i1 = 0; i1 < l; i1++) + // { + // com.teamcenter.services.rac.core._2007_06.DataManagement.AvailableTypeInfo + // availabletypeinfo = + // aavailabletypeinfo1[i1]; + // box.addItem(availabletypeinfo.type); + // } + // + // } + // + // if (getavailabletypesresponse.serviceData.sizeOfPartialErrors() > 0) + // { + // TCException tcexception = + // SoaUtil.checkPartialErrorsNoThrow(getavailabletypesresponse.serviceData); + // MessageBox.post(Utilities.getParentFrame(this), tcexception); + // } + + String[] types = new String[] { "Item", "MEProcess", "MEOP", + + "CompanyLocation", "CompanyContact" }; + + List datas = new ArrayList(); + + Map> map = new HashMap>( + types.length); + for (String string : types) { + map.put(string, new ArrayList()); + } + if (map != null && map.size() > 0) { + Map> map1 = TCUtilities + .getDisplayableTypeNamesWithHierarchyInfo(session, map); + if (map1 != null && !map1.isEmpty()) { + Iterator>> iterator = map1 + .entrySet().iterator(); + do { + if (!iterator.hasNext()) + break; + Entry> entry = iterator + .next(); + List list = entry.getValue(); + if (list != null && !list.isEmpty()) { + Iterator iterator1 = list.iterator(); + while (iterator1.hasNext()) { + DisplayTypeInfo displaytypeinfo = (DisplayTypeInfo) iterator1 + .next(); + if (!datas.contains(displaytypeinfo.getTypeName())) + datas.add(displaytypeinfo.getTypeName()); + } + } + } while (true); + } + } + Collections.sort(datas); + + box.setModel(new DefaultComboBoxModel(datas.toArray(new String[datas + .size()]))); + + } + + public static void main(String[] args) { + org.apache.poi.ss.usermodel.Workbook workbook; + try { + workbook = new XSSFWorkbook( + new FileInputStream( + "C:\\Users\\Administrator.SD-20101212HAVL\\Desktop\\123.xlsx")); + org.apache.poi.ss.usermodel.Sheet sheet = workbook.getSheetAt(0); + System.out.println(sheet.getPhysicalNumberOfRows()); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static Object callUserServices(TCSession session, Object target, + String str_userServiceName) { + Object[] obj = new Object[1]; + obj[0] = target; + Object robj = null; + try { + robj = session.getUserService().call(str_userServiceName, obj); + return robj; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + public static String getCellValue(org.apache.poi.ss.usermodel.Cell cell) { + String cellValue = ""; + if (cell == null) { + return cellValue; + } + // 判断数据的类型 + switch (cell.getCellType()) { + case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC: // 数字 + //如果为时间格式的内容 + if (HSSFDateUtil.isCellDateFormatted(cell)) { + //注:format格式 yyyy-MM-dd hh:mm:ss 中小时为12小时制,若要24小时制,则把小h变为H即可,yyyy-MM-dd HH:mm:ss + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + cellValue=sdf.format(HSSFDateUtil.getJavaDate(cell. + getNumericCellValue())).toString(); + break; + } else { + HSSFDataFormatter dataFormatter = new HSSFDataFormatter(); + String cellFormatted = dataFormatter.formatCellValue(cell); + cellValue=cellFormatted; + } + break; + case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_STRING: // 字符串 + // log.info("==字符串类型=="); + cellValue = String.valueOf(cell.getStringCellValue()); + break; + case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BOOLEAN: // Boolean + cellValue = String.valueOf(cell.getBooleanCellValue()); + break; + case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_FORMULA: // 公式 + if (cell.getCellStyle().getDataFormatString().indexOf("%") != -1) { + cellValue=cell.getNumericCellValue()*100+"%"; + } + break; + case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BLANK: // 空值 + cellValue = null; + break; + case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_ERROR: // 故障 + cellValue = "非法字符"; + break; + default: + cellValue = "未知类型"; + break; + } + return cellValue; + } +} diff --git a/src/com/connor/dev/imp/ImportFlex.java b/src/com/connor/dev/imp/ImportFlex.java new file mode 100644 index 0000000..2cacfca --- /dev/null +++ b/src/com/connor/dev/imp/ImportFlex.java @@ -0,0 +1,4040 @@ +package com.connor.dev.imp; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + +import com.connor.dev.imp.bom.BomsImportSettings; +import com.connor.dev.imp.ob.ObjectsImportSettings; +import com.connor.dev.imp.ob.StaticEnum; +import com.connor.dev.imp.toolkit.JXLExcelParser; +import com.connor.dev.imp.toolkit.POIExcelParser; +import com.connor.dev.imp.toolkit.ProgressReporter; +import com.connor.dev.imp.toolkit.SearchUtility; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.commands.delete.DeleteOperation; +import com.teamcenter.rac.kernel.NamedReferenceContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetDefinition; +import com.teamcenter.rac.kernel.TCComponentDatasetDefinitionType; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentIdContext; +import com.teamcenter.rac.kernel.TCComponentIdContextRuleType; +import com.teamcenter.rac.kernel.TCComponentIdentifier; +import com.teamcenter.rac.kernel.TCComponentIdentifierType; +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.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCComponentType; +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.kernel.TCTypeService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; + +public class ImportFlex { + /** + * Logger for this class + */ + private static final Logger logger = Logger.getLogger(ImportFlex.class); + + private TCComponentFolder folder; + + private TCTypeService service; + + private TCComponentType uom; + private TCComponentItemType itemType; + private TCComponentDatasetType datasetType; + + private TCComponentDatasetDefinitionType dsdefType; + private TCComponentBOMWindowType winType; + + public int success = 0; + + public int fail = 0; + + public int k = 1;// 控制数据集版本 + + public String logpath = "";// 日志路径 + + public String systitem = ""; + + private TCSession session; + private ProgressReporter reporter; + private TCUserService userservice; + // 路径的列记录 + public int locationIndex = -2; + // 项目的列记录 + public int projectIndex = -2; + // 类型的列记录 + public int typeIndex = -2; + // 类型首选项的处理缓存 + private static final String typePreference = "Connor_History_Type_Mapping"; + private HashMap typeMapTemp; + + // 增加纪录不需要增加BOM的对象 + private HashMap hasBOMMap; + + /** + * Creates a new instance of ImportFlex. + * + * @param session + * @param reporter + * @throws TCException + */ + public ImportFlex(TCSession session, ProgressReporter reporter) + throws TCException { + this.session = session; + this.reporter = reporter; + this.userservice = session.getUserService(); + this.hasBOMMap = new HashMap(); + logger.debug("开始初始化类ImportFlex"); + service = session.getTypeService(); + uom = service.getTypeComponent("UnitOfMeasure"); + itemType = (TCComponentItemType) service.getTypeComponent("Item"); + datasetType = (TCComponentDatasetType) service + .getTypeComponent("Dataset"); + dsdefType = (TCComponentDatasetDefinitionType) service + .getTypeComponent("DatasetType"); + winType = (TCComponentBOMWindowType) service + .getTypeComponent("BOMWindow"); + if (AIFUtility.getCurrentApplication().getTargetComponent() instanceof TCComponentFolder) { + + folder = (TCComponentFolder) AIFUtility.getCurrentApplication() + .getTargetComponent(); + + } else if (StaticEnum.isExec) { + + folder = session.getUser().getNewStuffFolder(); + + } + // 记录类型的匹配MAP + typeMapTemp = new HashMap(); + getObjTypeTem(); + + logger.debug("类ImportFlex初始化完毕"); + } + + /** + * 通过首选项获取需要自动创建的对象的类型 + */ + public void getObjTypeTem() { + try { + TCPreferenceService prefService = session.getPreferenceService(); + String values[] = prefService.getStringArray( + TCPreferenceService.TC_preference_site, typePreference); + if (values == null) { + return; + } + for (String value : values) { + if (value.contains("=")) { + String tempValues[] = value.split("="); + if (tempValues.length == 2) { + typeMapTemp.put(tempValues[0], tempValues[1]); + } + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * runImporting:(实现数据导入 ) + * + * @param settings + * 数据导入的配置选项 + * @param input + * 设定文件 + * @since CodingExample Ver 1.1 + */ + public void runImporting(ImportSettings settings, File input) { + + System.out.println("I AM 1"); + systitem = new SimpleDateFormat("yyyyMMdd-HHmmss").format(new Date()); + success = 0; + fail = 0; + System.out.println("要导入的文件路径为" + input.getAbsolutePath()); + if (input.getAbsolutePath().endsWith(".xls")) { + if (settings instanceof ObjectsImportSettings) { + System.out.println("要导入的类型为对象"); + ObjectsImportSettings ois = (ObjectsImportSettings) settings; + importObjectsByJxl(ois, input); + System.out.println("对象导入结束"); + } else if (settings instanceof BomsImportSettings) { + System.out.println("要导入的类型为BOM"); + BomsImportSettings bis = (BomsImportSettings) settings; + importBomsByJxl(bis, input); + System.out.println("BOM导入结束"); + } + } else if (input.getAbsolutePath().endsWith(".xlsx")) { + if (settings instanceof ObjectsImportSettings) { + System.out.println("要导入的类型为对象"); + ObjectsImportSettings ois = (ObjectsImportSettings) settings; + importObjectsByPoi(ois, input); + System.out.println("对象导入结束"); + } else if (settings instanceof BomsImportSettings) { + System.out.println("要导入的类型为BOM"); + BomsImportSettings bis = (BomsImportSettings) settings; + importBomsByPoi(bis, input); + System.out.println("BOM导入结束"); + } + } + + System.out.println("I AM 2"); + } + + private void establishRelation(int row, TCComponentItem currentItem, + TCComponentItem relativeItem, String currentRevision, + String relativeRevision, String relation) throws Exception { + TCComponent parent = currentItem; + TCComponent child = relativeItem; + System.out.println("relation====" + relation); + TCComponentItemRevision revision = null; + if ((currentRevision == null) || (currentRevision.trim().isEmpty())) { + + // continue; + // revision = currentItem.getLatestItemRevision(); + } else { + + InterfaceAIFComponent[] coms = SearchUtility + .searchComponentsCollection(session, "ConnorItemRevSearch", + new String[] { "ItemID1", "Revision1" }, + new String[] { currentItem.getProperty("item_id"), + currentRevision }); + if (coms != null && coms.length > 0) { + revision = (TCComponentItemRevision) coms[0]; + } + + if (revision == null) { + System.out.println("ID:" + currentItem.getProperty("item_id") + + ". 【失败】excel中 第" + row + + "行导入失败,原因是: 所指定的当前零组件的版本不存在\r\n"); + StringBufferDemo("ID:" + currentItem.getProperty("item_id") + + ". 【失败】excel中 第" + row + + "行导入失败,原因是: 所指定的当前零组件的版本不存在\r\n", "导入关系"); + fail++; + + return; + } + + System.out.println("查找指定的当前零组件版本成功"); + + parent = revision; + } + + TCComponentItemRevision re = null; + if (relativeRevision == null) { + System.out.println("没有指定目标 零组件的版本"); + // re = relativeItem.getLatestItemRevision(); + } else { + System.out.println("开始查找目标零组件版本"); + + // InterfaceAIFComponent[] coms = + // SearchUtility.searchComponentsCollection(session, + // "originSearchItemRevision", new String[] { "ItemID", "Revision" + // }, new String[] { relativeItem.getProperty("item_id"), + // relativeRevision }); + InterfaceAIFComponent[] coms = SearchUtility + .searchComponentsCollection(session, "ConnorItemRevSearch", + new String[] { "ItemID1", "Revision1" }, + new String[] { relativeItem.getProperty("item_id"), + relativeRevision }); + if (coms != null && coms.length > 0) { + re = (TCComponentItemRevision) coms[0]; + } + + if (re == null) { + System.out.println("【失败】excel中 第" + row + + "行导入失败,原因是: 所指定的目标零组件的版本不存在"); + StringBufferDemo("ID:" + relativeItem.getProperty("item_id") + + ". 【失败】excel中 第" + row + + "行导入失败,原因是: 所指定的目标零组件的版本不存在\r\n", "导入关系"); + fail++; + System.out.println("所指定的目标零组件的版本不存在"); + return; + } + + System.out.println("查找指定的目标零组件版本成功"); + + child = re; + } + + boolean find = false; + System.out.println("检查当前对象下是否已经存在指定关系的目标对象"); + if (parent.getTCProperty(relation) == null) { + System.out.println("ID:" + relativeItem.getProperty("item_id") + + ". 【失败】excel中 第" + row + "没有找到关系属性[" + relation + + "]\r\n"); + StringBufferDemo("ID:" + relativeItem.getProperty("item_id") + + ". 【失败】excel中 第" + row + "没有找到关系属性[" + relation + + "]\r\n", "导入关系"); + fail++; + return; + } + + AIFComponentContext[] contexts = parent.getRelated(relation); + if (contexts != null) { + System.out.println("contexts != null"); + for (int j = 0; j < contexts.length; j++) { + InterfaceAIFComponent iac = contexts[j].getComponent(); + if (iac.equals(child)) { + + find = true; + + break; + + } + } + } + try { + if (!find) { + System.out.println("没有找到,将进行添加"); + parent.add(relation, child); + System.out.println("添加完成"); + } else { + System.out.println("【成功】excel中 第" + row + "行导入成功"); + System.out.println("已经存在,不进行处理"); + } + } catch (Exception e) { + StringBufferDemo("ID:" + relativeItem.getProperty("item_id") + + ". 【失败】excel中 第" + row + "行"+e.getMessage()+"\r\n", "导入关系"); + fail++; + e.printStackTrace(); + + } + success++; + } + + private void importBomsByJxl(BomsImportSettings bis, File input) { + System.out.println("BOM导入开始"); + if (bis.getParentMapping() == null || bis.getChildMapping() == null) { + MessageBox.post("请先选择父装配与子装配的ID后再执行导入", "警告", 1); + + return; + } + + int parentIndex = bis.getParentMapping().getColumnIndex(); + System.out.println("父级装配对应的列为" + parentIndex); + int childIndex = bis.getChildMapping().getColumnIndex(); + System.out.println("子级装配对应的列为" + childIndex); + + try { + System.out.println("开始初始化解析excel文件的类"); + JXLExcelParser parser = new JXLExcelParser(input, 0, + bis.getColumns(), 1); + + reporter.setTaskRange(0, parser.rows); + List line = null; + System.out.println("开始解析excel文件"); + StringBuffer buffer = new StringBuffer(); + // StringBuffer noacl_buffer = new StringBuffer(); + List set = new ArrayList(); + while ((line = parser.parseLine()) != null) { + reporter.setProgressPercent(parser.startRow); + reporter.reportProgressMessage("正在验证第 " + parser.startRow + + " 行数据"); + String parentID = line.get(parentIndex); + if (parentID.trim().length() > 0) { + TCComponentItem item = null; + try { + item = itemType.find(parentID); + } catch (TCException tce) { + tce.printStackTrace(); + System.out.println("【失败】导入BOM失败"); + logger.error("导入BOM失败 - " + tce.getMessage()); + logger.debug(tce.toString()); + MessageBox.post(AIFDesktop.getActiveDesktop() + .getShell(), "对物料:" + parentID + + "无读权限,请确认后再进行导入", "错误", 1); + return; + } + if (item == null) { + if (!set.contains(parentID)) { + set.add(parentID); + buffer.append("\n" + parser.startRow + ": " + + parentID); + continue; + } + } + } + + String childID = line.get(childIndex); + if (childID.trim().length() > 0) { + TCComponentItem item = null; + try { + item = itemType.find(childID); + } catch (TCException tce) { + tce.printStackTrace(); + System.out.println("【失败】导入BOM失败"); + logger.error("导入BOM失败 - " + tce.getMessage()); + logger.debug(tce.toString()); + MessageBox.post(AIFDesktop.getActiveDesktop() + .getShell(), "对物料:" + childID + + "无读权限,请确认后再进行导入", "错误", 1); + return; + } + if (item == null) { + if (!set.contains(childID)) { + set.add(parentID); + buffer.append("\n" + parser.startRow + ": " + + childID); + continue; + } + } + } + } + + if (buffer.length() > 1) { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), + "当前BOM中含有新物料,分别是:\n" + buffer.toString() + + "\n\n请创建物料后,再进行导入", "错误", 1); + return; + } + // if(noacl_buffer.length()>1) + // { + // MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), + // "当前BOM中含有无读权限物料,分别是:\n" + noacl_buffer.toString() + + // "\n\n请创建物料后,再进行导入", "错误", 1); + // return; + // } + + parser = new JXLExcelParser(input, 0, bis.getColumns(), 1); + while ((line = parser.parseLine()) != null) { + try { + reporter.setProgressPercent(parser.startRow); + reporter.reportProgressMessage("正在导入第 " + parser.startRow + + " 行数据"); + + String parentID = line.get(parentIndex); + System.out.println("父级id9.14========"+parentID); + TCComponentItem parentItem = null; + System.out.println("开始查找父级装配所对应的零件 "); + if (parentID.trim().length() > 0) { + parentItem = itemType.find(parentID); + } + if (parentItem == null) { + System.out.println("【失败】excel中 第" + parser.startRow + + "行父装配的零组件不存在,不进行导入"); + StringBufferDemo("ID:" + parentID + ". 【失败】excel中 第" + + parser.startRow + "行父装配的零组件不存在,不进行导入\r\n", + "历史数据导入BOM"); + System.out.println("父装配的零组件不存在"); + fail++; + continue; + } + System.out.println("找到父级装配所对应的零件 "); + + String childID = line.get(childIndex); + System.out.println("开始查找子级装配所对应的零件 "); + TCComponentItem childItem = null; + if (childID.trim().length() > 0) { + childItem = itemType.find(childID); + } + if (childItem == null) { + System.out.println("【失败】excel中 第" + parser.startRow + + "行子装配的零组件不存在,不进行导入"); + StringBufferDemo("ID:" + childID + ". 【失败】excel中 第" + + parser.startRow + "行子装配的零组件不存在,不进行导入\r\n", + "历史数据导入BOM"); + System.out.println("子装配的零组件不存在"); + fail++; + continue; + } + System.out.println("找到子级装配所对应的零件 "); + + String parantRevision = null; + if (bis.getParentRevMapping() != null) { + parantRevision = line.get(bis.getParentRevMapping() + .getColumnIndex()); + } + + String childRevision = null; + if (bis.getChildRevMapping() != null) { + childRevision = line.get(bis.getChildRevMapping() + .getColumnIndex()); + } + + MappingAttribute[] atts = bis.getBomLineMapping(); + Map properties = new HashMap(); + for (int i = 0; i < atts.length; i++) { + properties.put(atts[i].getTcAttribute(), + line.get(atts[i].getColumnIndex())); + } + System.out.println("parentItem:" + parentItem); + System.out.println("childItem:" + childItem); + System.out.println("childRevision:" + childRevision); + System.out.println("parentRevision:" + parantRevision); + establishBomStructrue(parser.startRow, parentItem, + childItem, parantRevision, childRevision, + properties); + } catch (Exception e) { + System.out.println("【失败】excel中 第" + parser.startRow + + "行BOM导入失败"); + StringBufferDemo("【失败】excel中 第" + parser.startRow + + "行BOM导入失败\r\n", "历史数据导入BOM"); + e.printStackTrace(); + fail++; + continue; + } + } + } catch (Exception e) { + e.printStackTrace(); + System.out.println("【失败】导入BOM失败"); + logger.error("导入BOM失败 - " + e.getMessage()); + logger.debug(e.toString()); + } + } + + private void importBomsByPoi(BomsImportSettings bis, File input) { + System.out.println("BOM导入开始"); + if (bis.getParentMapping() == null || bis.getChildMapping() == null) { + MessageBox.post("请先选择父装配与子装配的ID后再执行导入", "警告", 1); + + return; + } + + int parentIndex = bis.getParentMapping().getColumnIndex(); + System.out.println("父级装配对应的列为" + parentIndex); + int childIndex = bis.getChildMapping().getColumnIndex(); + System.out.println("子级装配对应的列为" + childIndex); + + try { + System.out.println("开始初始化解析excel文件的类"); + POIExcelParser parser = new POIExcelParser(input, 0, + bis.getColumns(), 1); + + reporter.setTaskRange(0, parser.rows); + List line = null; + System.out.println("开始解析excel文件"); + StringBuffer buffer = new StringBuffer(); + List set = new ArrayList(); + while ((line = parser.parseLine()) != null) { + reporter.setProgressPercent(parser.startRow); + reporter.reportProgressMessage("正在验证第 " + parser.startRow + + " 行数据"); + String parentID = line.get(parentIndex); + if (parentID.trim().length() > 0) { + TCComponentItem item = null; + try { + item = itemType.find(parentID); + } catch (TCException tce) { + tce.printStackTrace(); + System.out.println("【失败】导入BOM失败"); + logger.error("导入BOM失败 - " + tce.getMessage()); + logger.debug(tce.toString()); + MessageBox.post(AIFDesktop.getActiveDesktop() + .getShell(), "对物料:" + parentID + + "无读权限,请确认后再进行导入", "错误", 1); + return; + } + if (item == null) { + if (!set.contains(parentID)) { + set.add(parentID); + buffer.append("\n" + parser.startRow + ": " + + parentID); + continue; + } + } + } + + String childID = line.get(childIndex); + if (childID.trim().length() > 0) { + TCComponentItem item = null; + try { + item = itemType.find(childID); + } catch (TCException tce) { + tce.printStackTrace(); + System.out.println("【失败】导入BOM失败"); + logger.error("导入BOM失败 - " + tce.getMessage()); + logger.debug(tce.toString()); + MessageBox.post(AIFDesktop.getActiveDesktop() + .getShell(), "对物料:" + childID + + "无读权限,请确认后再进行导入", "错误", 1); + return; + } + if (item == null) { + if (!set.contains(childID)) { + set.add(parentID); + buffer.append("\n" + parser.startRow + ": " + + childID); + continue; + } + } + } + } + + if (buffer.length() > 1) { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), + "当前BOM中含有新物料,分别是:\n" + buffer.toString() + + "\n\n请创建物料后,再进行导入", "错误", 1); + return; + } + + parser = new POIExcelParser(input, 0, bis.getColumns(), 1); + while ((line = parser.parseLine()) != null) { + try { + reporter.setProgressPercent(parser.startRow); + reporter.reportProgressMessage("正在导入第 " + parser.startRow + + " 行数据"); + + String parentID = line.get(parentIndex); + TCComponentItem parentItem = null; + System.out.println("开始查找父级装配所对应的零件 "); + if (parentID.trim().length() > 0) { + parentItem = itemType.find(parentID); + } + if (parentItem == null) { + System.out.println("【失败】excel中 第" + parser.startRow + + "行父装配的零组件不存在,不进行导入"); + System.out.println("父装配的零组件不存在"); + StringBufferDemo("【失败】excel中 第" + parser.startRow + + "行父装配的零组件不存在,不进行导入", "历史数据导入BOM"); + fail++; + continue; + } + System.out.println("找到父级装配所对应的零件 "); + + String childID = line.get(childIndex); + System.out.println("开始查找子级装配所对应的零件 "); + TCComponentItem childItem = null; + if (childID.trim().length() > 0) { + childItem = itemType.find(childID); + } + if (childItem == null) { + System.out.println("【失败】excel中 第" + parser.startRow + + "行子装配的零组件不存在,不进行导入"); + System.out.println("子装配的零组件不存在"); + StringBufferDemo("【失败】excel中 第" + parser.startRow + + "行父装配的零组件不存在,不进行导入", "历史数据导入BOM"); + fail++; + continue; + } + System.out.println("找到子级装配所对应的零件 "); + + String parantRevision = null; + if (bis.getParentRevMapping() != null) { + parantRevision = line.get(bis.getParentRevMapping() + .getColumnIndex()); + } + + String childRevision = null; + if (bis.getChildRevMapping() != null) { + childRevision = line.get(bis.getChildRevMapping() + .getColumnIndex()); + } + + MappingAttribute[] atts = bis.getBomLineMapping(); + Map properties = new HashMap(); + for (int i = 0; i < atts.length; i++) { + properties.put(atts[i].getTcAttribute(), + line.get(atts[i].getColumnIndex())); + } + + establishBomStructrue(parser.startRow, parentItem, + childItem, parantRevision, childRevision, + properties); + } catch (Exception e) { + System.out.println("【失败】excel中 第" + parser.startRow + + "行BOM导入失败"); + StringBufferDemo("【失败】excel中 第" + parser.startRow + + "行BOM导入失败", "历史数据导入BOM"); + e.printStackTrace(); + fail++; + continue; + } + } + } catch (Exception e) { + e.printStackTrace(); + System.out.println("【失败】导入BOM失败"); + logger.error("导入BOM失败 - " + e.getMessage()); + logger.debug(e.toString()); + } + } + + @SuppressWarnings("static-access") + private void establishBomStructrue(int row, TCComponentItem parentItem, + TCComponentItem childItem, String parantRevision, + String childRevision, Map properties) + throws Exception { + TCComponentItemRevision revision = null; + if (parantRevision == null || parantRevision.trim().equals("")) { + System.out.println("没有指定父级装配的版本,将使用最新版本"); + // revision = parentItem.getLatestItemRevision(); + InterfaceAIFComponent[] coms = SearchUtility + .searchComponentsCollection(session, "ConnorItemRevSearch", + new String[] { "ItemID1" }, + new String[] { parentItem.getProperty("item_id") }); + + if (coms != null && coms.length > 0) { + revision = (TCComponentItemRevision) coms[coms.length - 1]; + TCComponentItem item = revision.getItem(); + revision = item.getLatestItemRevision(); + } + } else { + System.out.println("将查找指定父级装配的版本"); + + InterfaceAIFComponent[] coms = SearchUtility + .searchComponentsCollection(session, "ConnorItemRevSearch", + new String[] { "ItemID1", "Revision1" }, + new String[] { parentItem.getProperty("item_id"), + parantRevision }); + System.out.println(parentItem.getProperty("item_id") + " | " + + parantRevision); + System.out.println("222222222222222222222"); + if (coms != null && coms.length > 0) { + revision = (TCComponentItemRevision) coms[0]; + System.out.println("3333333333333333333333"); + } else { + System.out.println("111111111111111111111"); + } + } + if (revision != null) { + + TCComponentBOMWindow window = winType.create(null); + window.lock(); + + System.out.println("查找指定父级装配的版本成功"); + TCComponentBOMLine line = window.setWindowTopLine(parentItem, + revision, null, null); + + // TCComponentBOMWindow win = winType.create(null); + // win.lock(); + + TCComponentItemRevision re = null; + if (childRevision == null || childRevision.trim().equals("")) { + System.out.println("没有指定子级装配的版本,将使用最新版本"); + // re = childItem.getLatestItemRevision(); + InterfaceAIFComponent[] coms = SearchUtility + .searchComponentsCollection( + session, + "ConnorItemRevSearch", + new String[] { "ItemID1" }, + new String[] { childItem.getProperty("item_id") }); + + if (coms != null && coms.length > 0) { + re = (TCComponentItemRevision) coms[coms.length - 1]; + TCComponentItem item = re.getItem(); + re = item.getLatestItemRevision(); + } + } else { + System.out.println("将查找指定子级装配的版本"); + + InterfaceAIFComponent[] coms = SearchUtility + .searchComponentsCollection(session, + "ConnorItemRevSearch", new String[] { + "ItemID1", "Revision1" }, new String[] { + childItem.getProperty("item_id"), + childRevision }); + + if (coms != null && coms.length > 0) { + re = (TCComponentItemRevision) coms[0]; + } + } + System.out.println("childRevision = " + childRevision + + ":: 子件对象re = " + re); + + if (re != null) { + System.out.println("查找指定子级装配的版本成功"); + + System.out.println("判断是不是已经搭建过结构"); + boolean find = false; + TCComponentBOMLine childLine = null; + TCComponent[] tccomponents = re.whereUsed(re.WHERE_USED_ALL); + if (tccomponents != null && tccomponents.length > 0) { + for (int j = 0; j < tccomponents.length; j++) { + if (tccomponents[j] instanceof TCComponentItemRevision) { + TCComponentItemRevision itemrevision = (TCComponentItemRevision) tccomponents[j]; + if (itemrevision.equals(line.getItemRevision())) { + find = true; + System.out.println("【警告】excel中 第" + row + + "行BOM已经搭建过,不进行导入"); + AIFComponentContext[] childs = line.getChildren(); + for (int i = 0; i < childs.length; i++) { + InterfaceAIFComponent child = childs[i].getComponent(); + if(child instanceof TCComponentBOMLine) { + TCComponentBOMLine childBomLine = (TCComponentBOMLine) child; + if(re.equals(childBomLine.getItemRevision())) { + for (Iterator iterator = properties.keySet() + .iterator(); iterator.hasNext();) { + String key = iterator.next(); + String value = properties.get(key); + // System.out.println(key + " : " + value); + try { + // if(key.equals("bl_quantity")) + // { + // quantity_num = Integer.valueOf(value); + // System.out.println("数量属性转为int:"+quantity_num); + // } + // else + // { + // System.out.println("下面开始转换位号"); + if (key.equals("bl_ref_designator") + && (!value.contains("-"))) { + System.out + .println("位号属性进行转换value=" + value); + value = change(value, row); + System.out.println("位号属性转换后value=" + value); + } + System.out.println("key=" + key + " value=" + + value); + if (value.contains("\\.") + && key.equals("bl_quantity")) { + try { + double d = Double.parseDouble(value); + childBomLine.setDoubleProperty(key, d); + } catch (Exception e) { + System.out.println("【失败】excel中 第" + row + + "行导入失败,原因是: 子装配的属性 " + key + + " 不正确,请检查后重新搭建该行"); + StringBufferDemo( + "ID:" + + childItem + .getProperty("item_id") + + ". 【失败】excel中 第" + + row + + "行导入失败,原因是: 子装配的属性 " + + key + + " 不正确,请检查后重新搭建该行\r\n", + "历史数据导入BOM"); + fail++; + // win.close(); + window.save(); + window.unlock(); + window.close(); + return; + } + } else { + childBomLine.setProperty(key, value); + } + + // } + } catch (TCException e) { + System.out.println("【失败】excel中 第" + row + + "行导入失败,原因是: 子装配的属性 " + key + + " 不正确,请检查后重新搭建该行"); + StringBufferDemo( + "ID:" + + childItem.getProperty("item_id") + + ". 【失败】excel中 第" + row + + "行导入失败,原因是: 子装配的属性 " + key + + " 不正确,请检查后重新搭建该行\r\n", + "历史数据导入BOM"); + fail++; + // win.close(); + window.save(); + window.unlock(); + window.close(); + return; + } + } + } + } + break; + } + break; + } + } + } + } + + // 判断是否有子节点 + TCComponent[] b_existBOM = re + .getRelatedComponents("structure_revisions"); + if (b_existBOM.length > 0) { + // 存在BOM,纪录 + System.out.println("存在BOM"); + String tempitemid = re.getProperty("item_id"); + System.out.println("存在BOM:" + tempitemid); + if (!hasBOMMap.containsKey(tempitemid)) + hasBOMMap.put(tempitemid, re); + } + + if (!find) { + System.out.println("没有搭建过结构"); + if (hasBOMMap.containsKey(line.getProperty("bl_item_item_id"))) { + System.out.println("进入不需要搭建内容"); + System.out.println("【警告】excel中第" + row + + "行BOM导入失败,该父BOM已存在BOM结构,不进行导入"); + StringBufferDemo( + "【警告】excel中第" + + row + + "行BOM导入失败,该父BOM已存在BOM结构,不进行导入,如需导入请删除BOM视图后再进行导入", + "历史数据导入BOM"); + fail++; + + } else { + childLine = line.add(childItem, re, null, false, ""); + // String newswquence = + // childLine.getProperty("bl_sequence_no"); + // System.out.println("获得的查找编号为:"+newswquence); + // int quantity_num = -9999; + for (Iterator iterator = properties.keySet() + .iterator(); iterator.hasNext();) { + String key = iterator.next(); + String value = properties.get(key); + // System.out.println(key + " : " + value); + try { + // if(key.equals("bl_quantity")) + // { + // quantity_num = Integer.valueOf(value); + // System.out.println("数量属性转为int:"+quantity_num); + // } + // else + // { + // System.out.println("下面开始转换位号"); + if (key.equals("bl_ref_designator") + && (!value.contains("-"))) { + System.out + .println("位号属性进行转换value=" + value); + value = change(value, row); + System.out.println("位号属性转换后value=" + value); + } + System.out.println("key=" + key + " value=" + + value); + if (value.contains("\\.") + && key.equals("bl_quantity")) { + try { + double d = Double.parseDouble(value); + childLine.setDoubleProperty(key, d); + } catch (Exception e) { + System.out.println("【失败】excel中 第" + row + + "行导入失败,原因是: 子装配的属性 " + key + + " 不正确,请检查后重新搭建该行"); + StringBufferDemo( + "ID:" + + childItem + .getProperty("item_id") + + ". 【失败】excel中 第" + + row + + "行导入失败,原因是: 子装配的属性 " + + key + + " 不正确,请检查后重新搭建该行\r\n", + "历史数据导入BOM"); + fail++; + // win.close(); + window.save(); + window.unlock(); + window.close(); + return; + } + } else { + childLine.setProperty(key, value); + } + + // } + } catch (TCException e) { + System.out.println("【失败】excel中 第" + row + + "行导入失败,原因是: 子装配的属性 " + key + + " 不正确,请检查后重新搭建该行"); + StringBufferDemo( + "ID:" + + childItem.getProperty("item_id") + + ". 【失败】excel中 第" + row + + "行导入失败,原因是: 子装配的属性 " + key + + " 不正确,请检查后重新搭建该行\r\n", + "历史数据导入BOM"); + fail++; + // win.close(); + window.save(); + window.unlock(); + window.close(); + return; + } + } + childLine.pack(); + childLine.save(); + System.out.println("搭建结构完成"); + } + + }else { + System.out.println("搭建过结构,只进行更新属性"); + AIFComponentContext[] childs = line.getChildren(); + for (int i = 0; i < childs.length; i++) { + InterfaceAIFComponent child = childs[i].getComponent(); + if(child instanceof TCComponentBOMLine) { + TCComponentBOMLine childBomLine = (TCComponentBOMLine) child; + String childID = childItem.getStringProperty("item_id"); + String childBOMID = childBomLine.getStringProperty("bl_item_item_id"); + System.out.println("childID==============="+childID); + System.out.println("childBOMID==============="+childBOMID); + if(childID.equals(childBOMID)) { + childLine = childBomLine; + break; + } + } + } + for (Iterator iterator = properties.keySet() + .iterator(); iterator.hasNext();) { + String key = iterator.next(); + String value = properties.get(key); + // System.out.println(key + " : " + value); + try { + // if(key.equals("bl_quantity")) + // { + // quantity_num = Integer.valueOf(value); + // System.out.println("数量属性转为int:"+quantity_num); + // } + // else + // { + // System.out.println("下面开始转换位号"); + if (key.equals("bl_ref_designator") + && (!value.contains("-"))) { + System.out + .println("位号属性进行转换value=" + value); + value = change(value, row); + System.out.println("位号属性转换后value=" + value); + } + System.out.println("key=" + key + " value=" + + value); + if (value.contains("\\.") + && key.equals("bl_quantity")) { + try { + double d = Double.parseDouble(value); + childLine.setDoubleProperty(key, d); + } catch (Exception e) { + System.out.println("【失败】excel中 第" + row + + "行导入失败,原因是: 子装配的属性 " + key + + " 不正确,请检查后重新搭建该行"); + StringBufferDemo( + "ID:" + + childItem + .getProperty("item_id") + + ". 【失败】excel中 第" + + row + + "行导入失败,原因是: 子装配的属性 " + + key + + " 不正确,请检查后重新搭建该行\r\n", + "历史数据导入BOM"); + fail++; + // win.close(); + window.save(); + window.unlock(); + window.close(); + return; + } + } else { + childLine.setProperty(key, value); + } + + // } + } catch (TCException e) { + System.out.println("【失败】excel中 第" + row + + "行导入失败,原因是: 子装配的属性 " + key + + " 不正确,请检查后重新搭建该行"); + StringBufferDemo( + "ID:" + + childItem.getProperty("item_id") + + ". 【失败】excel中 第" + row + + "行导入失败,原因是: 子装配的属性 " + key + + " 不正确,请检查后重新搭建该行\r\n", + "历史数据导入BOM"); + fail++; + // win.close(); + window.save(); + window.unlock(); + window.close(); + return; + } + } + childLine.pack(); + childLine.save(); + } + + success++; + System.out.println("【成功】excel中 第" + row + "行导入成功"); + } else { + System.out.println("【失败】excel中 第" + row + + "行导入失败,原因是: 所指定的子装配的版本不存在"); + StringBufferDemo("ID:" + childItem.getProperty("item_id") + + ". 【失败】excel中 第" + row + + "行导入失败,原因是: 所指定的子装配的版本不存在\r\n", "历史数据导入BOM"); + System.out.println("所指定的子装配的版本不存在"); + fail++; + } + line.save(); + window.save(); + window.unlock(); + window.close(); + } else { + System.out.println("【失败】excel中 第" + row + + "行导入失败,原因是: 所指定的父装配的版本不存在"); + StringBufferDemo("ID:" + parentItem.getProperty("item_id") + + ". 【失败】excel中 第" + row + "行导入失败,原因是: 所指定的父装配的版本不存在\r\n", + "历史数据导入BOM"); + System.out.println("没有找到指定零组件的指定版本"); + fail++; + } + } + + public boolean isStrNum(String str) { + + try { + Integer.parseInt(str); + return true; + } catch (NumberFormatException e) { + return false; + } + + } + + // 将连续位号转换成带-的 + public String change(String ss, int row) { + // TODO Auto-generated method stub + String newstr = ""; + List keylist = new ArrayList(); + Map> map = new HashMap>(); + + String left = ""; + + ss = ss.replaceAll(",", ","); + ss = ss.replaceAll(" ", ""); + + String[] strs = ss.split(","); + if (strs != null && strs.length > 0) { + + for (String str : strs) { + try { + str = str.trim(); + if (str.length() > 0) + for (int i = 1; i < str.length(); i++) { + if (isStrNum(str.substring(i, str.length()))) { + left = str.substring(0, i); + if (!keylist.contains(left)) { + keylist.add(left); + } + break; + } + } + } catch (NumberFormatException e) { + System.out.println(str + "数据异常无法转化" + e.getMessage()); + System.out.println("【失败】excel中 第" + row + + "行位号可能导入失败,原因是:位号异常"); + try { + StringBufferDemo("【失败】excel中 第" + row + + "行位号可能导入失败,原因是:位号异常", "历史数据导入BOM"); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + System.out.println("所指定的子装配的版本不存在"); + fail++; + } + + } + for (String keystr : keylist) { + List list = new ArrayList(); + for (String str : strs) { + try { + str = str.trim(); + if (str.length() > 0) + for (int i = 1; i < str.length(); i++) { + if (isStrNum(str.substring(i, str.length()))) { + left = str.substring(0, i); + if (keystr.equals(left)) { + int in = Integer.parseInt(str + .substring(i, str.length())); + list.add(in); + } + break; + } + } + } catch (NumberFormatException e) { + System.out.println(str + "数据异常无法转化" + e.getMessage()); + System.out.println("【失败】excel中 第" + row + + "行位号可能导入失败,原因是:位号异常"); + try { + StringBufferDemo("【失败】excel中 第" + row + + "行位号可能导入失败,原因是:位号异常", "历史数据导入BOM"); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + System.out.println("所指定的子装配的版本不存在"); + fail++; + } + + } + + Collections.sort(list);// 排序 + + map.put(keystr, list); + + } + + } + if (map != null) { + for (String keystr : keylist) { + if (!newstr.equals("")) { + newstr = newstr + ","; + } + List list = map.get(keystr); + if (list != null && list.size() > 0) + for (int i = 0; i < list.size(); i++) { + if (i == list.size() - 1) { + newstr = newstr + keystr + list.get(i); + break; + } + if (list.get(i) + 1 == list.get(i + 1)) { + if (!newstr.endsWith("-") || newstr.equals("")) { + newstr = newstr + keystr + list.get(i) + "-"; + } + + } else { + if (newstr.endsWith("-")) { + newstr = newstr + keystr + list.get(i) + ","; + } else { + newstr = newstr + keystr + list.get(i) + ","; + } + } + + } + } + + } + System.out.println(ss); + System.out.println(newstr); + if (newstr.equals("")) { + System.out.println("内容[" + ss + "]不符合转换,直接赋值"); + return ss; + } + return newstr; + + } + + private void importObjectsByJxl(ObjectsImportSettings ois, File input) { + + System.out.println("对象导入开始"); + + try { + TCComponent[] uoms = uom.extent(); + Map uomMap = new HashMap(); + if (uoms != null) { + for (int i = 0; i < uoms.length; i++) { + uomMap.put(uoms[i].toString(), uoms[i]); + } + } + + int uomIndex = -1; + int idIndex = -1; + int nameIndex = -1; + boolean isthroughParent = ois.isSelectParent(); + + MappingAttribute[] items = ois.getItemMapping(); + MappingAttribute[] revisions = ois.getRevMapping(); + MappingAttribute[] forms = ois.getRevFormMapping(); + MappingAttribute[] datasetMap = ois.getDatasetMapping(); + + for (int i = 0; i < datasetMap.length; i++) { + if ("路径".equals(datasetMap[i].getTcAttribute()) + && "路径".equals(datasetMap[i].getColumnTitle())) { + this.locationIndex = datasetMap[i].getColumnIndex(); + System.out.println(">>路径所对应的列" + locationIndex); + } else { + System.out.println(">>没有找到路径" + locationIndex); + } + + } + + for (int i = 0; i < items.length; i++) { + if ("项目".equals(items[i].getTcAttribute())) { + this.projectIndex = items[i].getColumnIndex(); + System.out.println(">>项目所对应的列" + projectIndex); + } else { + System.out.println(">>没有找到项目" + projectIndex); + } + + } + + for (int i = 0; i < items.length; i++) { + if ("item_id".equals(items[i].getTcAttribute())) { + idIndex = items[i].getColumnIndex(); + System.out.println("零组件ID所对应的列" + idIndex); + continue; + } + if ("uom_tag".equals(items[i].getTcAttribute())) { + uomIndex = items[i].getColumnIndex(); + System.out.println("测量单位所对应的列为" + uomIndex); + } + if ("object_name".equals(items[i].getTcAttribute())) { + nameIndex = items[i].getColumnIndex(); + System.out.println("名称所对应的列为" + nameIndex); + } + + if ("类型".equals(items[i].getTcAttribute()) + && "类型".equals(items[i].getColumnTitle())) { + this.typeIndex = items[i].getColumnIndex(); + System.out.println(">>类型所对应的列" + typeIndex); + } else { + System.out.println(">>没有找到类型" + typeIndex); + } + + } + + if (idIndex < 0) { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), + "【失败】没有选择ID所对应的列,不能完成导入", "错误", 1); + return; + } + + if (nameIndex < 0) { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), + "【失败】没有选择名称所对应的列,不能完成导入", "错误", 1); + return; + } + + int itemRevIndex = -1; + for (int i = 0; i < revisions.length; i++) { + if ("item_revision_id".equals(revisions[i].getTcAttribute())) { + itemRevIndex = revisions[i].getColumnIndex(); + System.out.println("零组件版本所对应的列为" + itemRevIndex); + } + } + + JXLExcelParser parser = new JXLExcelParser(input, 0, + ois.getColumns(), 1); + reporter.setTaskRange(0, parser.rows); + List line = null; + String id = ""; + String rev = ""; + while ((line = parser.parseLine()) != null) { + reporter.setProgressPercent(parser.startRow); + reporter.reportProgressMessage("正在导入第 " + parser.startRow + + " 行数据"); + try { + String lastid = id; + id = line.get(idIndex); + if (id.length() > 0) { + TCComponent uomCom = null; + if (uomIndex >= 0) { + String uom = line.get(uomIndex); + if (uom.length() > 0) { + uomCom = uomMap.get(uom); + + if (uomCom == null) { + try { + if (line.get(nameIndex).equals("")) { + StringBufferDemo( + "ID:" + + id + + ". 【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是: 所指定的单位没有在系统中定义\r\n", + "历史数据导入对象"); + } else { + StringBufferDemo( + "ID:" + + id + + ",名称:" + + line.get(nameIndex) + + ". 【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是: 所指定的单位没有在系统中定义\r\n", + "历史数据导入对象"); + } + } catch (IOException e) { + e.printStackTrace(); + } + + System.out.println("【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是: 所指定的单位没有在系统中定义."); + fail++; + continue; + } + } + } + + String lastRev = rev; + if (itemRevIndex > 0) { + rev = line.get(itemRevIndex); + } + // ---判断是否是上一次的版本 zyn + if (!lastid.equals("")) { + if (lastid.equals(id)) { + if (!lastRev.equals("")) { + if (!lastRev.equals(rev)) { + k = 1; + } + } + } else { + k = 1; + } + } + TCComponentItem item = null; + item = itemType.find(id); + TCComponentItemRevision revision = null; + + List ps = new ArrayList(); + boolean refresh = false; + if (item == null) { + String name = line.get(nameIndex); + if (name.equals("")) { + try { + StringBufferDemo("ID:" + id + + ". 【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是: 零组件的的名字为不允许为空值\r\n", + "历史数据导入对象"); + } catch (IOException e) { + e.printStackTrace(); + } + + System.out.println("【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是: 零组件的的名字为不允许为空值"); + fail++; + continue; + } + // 判断是否通过选定父类,自动创建子类 + if (typeIndex == -2) { + item = itemType.create(id, rev, + ois.getItemType(), name, "", uomCom); + } else { + String typeTemp1 = line.get(typeIndex); + String typeTemp = typeMapTemp.get(typeTemp1); + if (typeTemp != null && typeTemp.length() > 0) { + TCTypeService typeService = session + .getTypeService(); + TCComponentType type = typeService + .getTypeComponent(typeTemp); + if (type == null) { + try { + StringBufferDemo("ID:" + id + + ". 【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是: 找不到该类型\r\n", + "历史数据导入对象"); + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println("【失败】excel中 第" + + parser.startRow + + "行新建失败,原因是: 找不到该类型"); + continue; + } + item = itemType.create(id, rev, typeTemp, + name, "", uomCom); + } else { + try { + StringBufferDemo("ID:" + id + + ". 【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是: 找不到该类型\r\n", + "历史数据导入对象"); + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println("【失败】excel中 第" + + parser.startRow + + "行新建失败,原因是: 找不到该类型"); + continue; + } + } + // item = itemType.create(id, rev, + // ois.getItemType(), name, "", uomCom); + + revision = item.getLatestItemRevision(); + folder.add("contents", item); + System.out.println("零组件被成功创建 "); + } else { + refresh = true; + System.out.println("零组件已经存在于系统当中,不需要创建"); + StringBufferDemo("ID:" + id + ". 【错误】excel中 第" + + parser.startRow + + "行导入失败,原因是: 零组件已经存在\r\n", "历史数据导入对象"); + // continue; + } + + if (revision == null) { + InterfaceAIFComponent[] coms = null; + System.out.println("查找指定的零组件版本 - " + rev); + coms = SearchUtility.searchComponentsCollection( + session, "ConnorItemRevSearch", + new String[] { "ItemID1", "Revision1" }, + new String[] { id, rev }); + System.out.println("coms===" + coms); + if (coms != null && coms.length > 0) { + revision = (TCComponentItemRevision) coms[0]; + } + } + System.out.println("revision==" + revision); + if (revision == null && !rev.equals("")) { + refresh = false; + System.out.println("零组件已经存,但指定的版本不存在,现在将其修订至指定版本"); + revision = item.getLatestItemRevision().saveAs(rev, + item.getProperty("object_name"), "", true, + null, null); + TCComponent[] datasets = revision.getTCProperty( + "IMAN_specification").getReferenceValueArray(); + for (int i = 0; i < datasets.length; i++) { + if (datasets[i] instanceof TCComponentDataset) { + revision.remove("IMAN_specification", datasets[i]);// 移除升版前的数据集--dfhm + // by + // zyn + // 2011/08/11 + } + } + System.out.println("修订至指定版本成功"); + } + if (revision == null) { + revision = item.getLatestItemRevision(); + } + if ((refresh && ois.isExistedRefreshed()) || !refresh) { + String name = line.get(nameIndex); + if (name.equals("")) { + try { + StringBufferDemo("ID:" + id + + ". 【失败】excel中 第" + + parser.startRow + + "行更新失败,原因是: 零组件的的名字为不允许为空值\r\n", + "历史数据导入对象"); + } catch (IOException e) { + e.printStackTrace(); + } + StringBufferDemo("【失败】excel中 第" + + parser.startRow + + "行更新失败,原因是: 零组件的的名字为不允许为空值", + "历史数据导入对象"); + System.out.println("【失败】excel中 第" + + parser.startRow + + "行更新失败,原因是: 零组件的的名字为不允许为空值"); + fail++; + continue; + } + if (uomCom != null) { + try { + item.setReferenceProperty("uom_tag", uomCom); + } catch (Exception e) { + StringBufferDemo( + "ID:" + + id + + ",名称:" + + line.get(nameIndex) + + ". 【失败】excel中 第" + + parser.startRow + + "行更新失败,原因是: 该行零组件的单位不允许修改,请检查其是否已经搭建过BOM\r\n", + "历史数据导入对象"); + System.out + .println("【失败】excel中 第" + + parser.startRow + + "行更新失败,原因是: 该行零组件的单位不允许修改,请检查其是否已经搭建过BOM"); + fail++; + continue; + } + } + System.out.println("更新零组件上的属性"); + ps.clear(); + TCComponentIdentifierType altype = (TCComponentIdentifierType) session + .getTypeService().getTypeComponent( + "Identifier"); + TCComponentIdContextRuleType tccomponentidcontextruletype = (TCComponentIdContextRuleType) session + .getTypeComponent("IdContextRule"); + TCComponentIdContext[] context; + context = tccomponentidcontextruletype + .getAliasContexts(); + for (int i = 0; i < items.length; i++) { + if (items[i].equals("uom_tag") + || items[i].equals("object_name")) { + continue; + } + if (items[i].getTcAttribute().equals( + "IMAN_aliasid")) { + TCComponentIdentifier alid = altype + .createAliasIdentifier("WX3_AAA"); + alid.setReferenceProperty("idcontext", + context[0]); + alid.setProperty("idfr_id", + line.get(items[i].getColumnIndex())); + alid.setProperty("object_name", "wx"); + alid.setProperty("object_desc", ""); + alid.save(); + item.add("IMAN_aliasid", alid); + continue; + } + TCProperty property = item + .getTCProperty(items[i] + .getTcAttribute()); + if (property != null + && property.getPropertyDescriptor() + .isModifiable()) { + if (property.getPropertyName().equals( + "item_id")) { + continue; + } + setTCProperty(property, + line.get(items[i].getColumnIndex())); + ps.add(property); + } + } + item.setTCProperties(ps.toArray(new TCProperty[ps + .size()])); + System.out.println("更新零组件上的属性成功完成更新 "); + System.out.println("更新创建的零组件版本上的属性"); + revision.setProperty("object_name", + item.getProperty("object_name")); + ps.clear(); + for (int i = 0; i < revisions.length; i++) { + TCProperty property = revision + .getTCProperty(revisions[i] + .getTcAttribute()); + if (property != null + && property.getPropertyDescriptor() + .isModifiable()) { + logger.debug("更新属性 - " + + property.getPropertyName()); + String propertyName = property.getName(); + String relatedItemType = null; + if (propertyName.equals("MnfBrandOAttr")) { + relatedItemType = "MnfBrandObj"; + } else if (propertyName + .equals("MnfCategoryOAttr")) { + relatedItemType = "MnfCategoryObj"; + } else if (propertyName + .equals("MnfProdLineOAttr")) { + relatedItemType = "MnfProdLineObj"; + } else if (propertyName + .equals("MnfSeasonOAttr")) { + relatedItemType = "MnfSeasonObj"; + } else if (propertyName + .equals("MnfSeriesOAttr")) { + relatedItemType = "MnfSeriesObj"; + } else if (propertyName + .equals("MnfStyleOAttr")) { + relatedItemType = "MnfStyleObj"; + } else if (propertyName + .equals("MnfMaterialBOAttr")) { + relatedItemType = "MnfMaterialBType"; + } else if (propertyName + .equals("MnfMaterialSOAttr")) { + relatedItemType = "MnfMaterialSType"; + } + if (relatedItemType != null) { + logger.debug("通过名字和类型查找对应的Item对象"); + InterfaceAIFComponent[] cs = SearchUtility + .searchComponentsCollection( + session, + "ConnorItemSearch", + new String[] { "Name1", + "Type1" }, + new String[] { + line.get(revisions[i] + .getColumnIndex()), + relatedItemType + + "Revision" }); + if (cs != null && cs.length > 0) { + System.out.println("DDD " + + revisions[i] + .getColumnIndex()); + logger.debug("找到名称为" + + line.get(revisions[i] + .getColumnIndex()) + + ",类型为" + relatedItemType + + "的对象"); + if (cs[0] instanceof TCComponentItemRevision) { + TCComponentItemRevision tcc = (TCComponentItemRevision) cs[0]; + property.setPropertyData(tcc); + } + } else { + try { + StringBufferDemo( + "ID:" + + id + + ",名称:" + + line.get(nameIndex) + + ". 【失败】没有找到名称为" + + line.get(revisions[i] + .getColumnIndex()) + + ",类型为" + + relatedItemType + + "的对象\r\n", + "历史数据导入对象"); + } catch (IOException e) { + e.printStackTrace(); + } + + System.out.println("【失败】没有找到名称为" + + line.get(revisions[i] + .getColumnIndex()) + + ",类型为" + relatedItemType + + "的对象"); + fail++; + continue; + } + } else { + logger.debug("relatedItemType = " + + relatedItemType); + setTCProperty(property, + line.get(revisions[i] + .getColumnIndex())); + } + ps.add(property); + } + } + revision.setTCProperties(ps + .toArray(new TCProperty[ps.size()])); + System.out.println("更新创建的零组件上的属性成功 "); + + TCComponentForm form = getItemRevisionMasterForm(revision); + if (form != null) { + System.out.println("获取零组件版本Form成功,开始更新其属性"); + ps.clear(); + for (int i = 0; i < forms.length; i++) { + TCProperty property = form + .getTCProperty(forms[i] + .getTcAttribute()); + if (property != null + && property.getDescriptor() + .isModifiable()) { + setTCProperty(property, + line.get(forms[i] + .getColumnIndex())); + ps.add(property); + } + } + form.setTCProperties(ps + .toArray(new TCProperty[ps.size()])); + form.save(); + } else { + System.out.println("获取零组件版本Form失败"); + } + MappingAttribute[] datasets = ois + .getDatasetMapping(); + System.out.println("处理版本下面的数据集, 有" + + datasets.length + "个需要处理"); + ps.clear(); + + // 开始处理数据集2017.11.8改 + String allFilePath = ""; + String allFilePaths[] = null; + if (locationIndex != -2) { + allFilePath = line.get(locationIndex); + if (allFilePath.contains(";")) { + allFilePaths = allFilePath.split(";"); + } else if (allFilePath.contains(";")) { + allFilePaths = allFilePath.split(";"); + } else { + allFilePaths = new String[] { allFilePath }; + } + System.out.println("特殊处理【文件个数" + + allFilePaths.length + "】"); + } else { + System.out.println("不是特殊处理"); + } + int filePathIndex = 0; + for (int i = 0; i < datasets.length; i++) { + System.out.println("dataset:" + + datasets[i].getColumnIndex()); + System.out.println("dataset2:" + + datasets[i].getColumnTitle()); + try { + String filePath = null; + if (locationIndex != -2) { + if (datasets[i].getColumnIndex() == locationIndex) { + continue; + } + String fileName = line.get(datasets[i] + .getColumnIndex()); + if (fileName.trim().equals("")) { + System.out.println("特殊处理,数据集名称为空"); + continue; + } + + if (filePathIndex < allFilePaths.length) { + filePath = allFilePaths[filePathIndex]; + } else { + System.out + .println("特殊处理,非空文件超出文件个数,请检查!"); + continue; + } + filePathIndex++; + logger.debug("开始处理第" + (filePathIndex) + + "个"); + } else { + filePath = line.get(datasets[i] + .getColumnIndex()); + logger.debug("开始处理第" + (i + 1) + "个"); + } + if (filePath.trim().length() > 0) { + System.out + .println("数据集的路径为" + filePath); + String ds = datasets[i] + .getTcAttribute(); + // String sep = ois.getArraySeparator(); + // 假如filePath以“||”就表示挂成多个数据集,如果以“;”就表示挂一个数据集,添加多个命名引用 + String[] files = filePath + .split("\\|\\|"); + List> fis = new ArrayList>(); + for (int j = 0; j < files.length; j++) { + String filepath = files[j].trim(); + if (filepath.contains(";")) { + String[] filepaths = filepath + .split(";"); + List list = new ArrayList(); + for (int k = 0; k < filepaths.length; k++) { + File file = new File( + filepaths[k].trim()); + if (file.exists()) { + list.add(file + .getAbsolutePath()); + } else { + // 需要报错 + StringBufferDemo( + "【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是:表格中填写数据集路径有误\r\n", + "历史数据导入对象"); + System.out + .println("文件" + + file.getAbsolutePath() + + "不存在,不予以处理"); + logger.error("【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是:表格中填写数据集路径有误"); + fail++; + continue; + } + } + fis.add(list); + } else if (filepath.contains(";")) { + String[] filepaths = filepath + .split(";"); + List list = new ArrayList(); + for (int k = 0; k < filepaths.length; k++) { + File file = new File( + filepaths[k].trim()); + System.out.println("文件路径为:" + + file); + if (file.exists()) { + list.add(file + .getAbsolutePath()); + } else { + // 需要报错 + StringBufferDemo( + "【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是:表格中填写数据集路径有误\n\r", + "历史数据导入对象"); + System.out + .println("文件" + + file.getAbsolutePath() + + "不存在,不予以处理"); + logger.error("【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是:表格中填写数据集路径有误"); + fail++; + continue; + } + } + fis.add(list); + } else { + System.out.println("files[" + j + + "] = " + files[j]); + File file = new File( + files[j].trim()); + if (file.exists()) { + List list = new ArrayList(); + list.add(file + .getAbsolutePath()); + fis.add(list); + } else { + // 需要报错 + StringBufferDemo( + "【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是:表格中填写数据集路径有误\n\r", + "历史数据导入对象"); + System.out + .println("【错误】文件" + + file.getAbsolutePath() + + "不存在,不予以处理"); + logger.error("【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是:表格中填写数据集路径有误"); + fail++; + continue; + } + } + } + + if (fis.size() > 0) { + String did = line.get(datasets[i] + .getColumnIndex()); + String[] dids = null; + if(did.contains(";")){ + dids = did.split(";"); + }else if(did.contains(";")){ + dids = did.split(";"); + }else{ + dids = new String[1]; + dids[0] = did; + } + for(int n=0;n listString = fis + .get(0); + AIFComponentContext[] cc = revision + .getChildren("IMAN_specification"); + List listComponent = new ArrayList(); + for (int j = 0; j < cc.length; j++) { + InterfaceAIFComponent tcc = cc[j] + .getComponent(); + if (tcc instanceof TCComponentDataset) { + TCComponentDataset ods = (TCComponentDataset) tcc; + if (ods.getStringProperty( + "object_name") + .equals(did)) { + listComponent + .add(cc[j]); + } + } + } + if (listComponent.size() > 0) { + if (listComponent.size() > 1) { + for (int k = 0; k < listComponent + .size() - 1; k++) { + DeleteOperation deleteOperation = new DeleteOperation( + listComponent + .get(k)); + session.queueOperation(deleteOperation); + listComponent + .remove(k); + k--; + } + if (listComponent + .get(0) + .getComponent() instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) listComponent + .get(0) + .getComponent(); + if (dataset + .getProperty( + "object_name") + .equals(did)) { + removeNRFiles( + dataset, + refs[0], + dataset.getTcFiles()); + for (int l = 0; l < listString + .size(); l++) { + importFilesOperation( + dataset, + new File( + listString + .get(l)), + dataset.getType(), + refs[0]); + + } + } else { + dataset.setProperty( + "object_name", + did); + removeNRFiles( + dataset, + refs[0], + dataset.getTcFiles()); + for (int l = 0; l < listString + .size(); l++) { + importFilesOperation( + dataset, + new File( + listString + .get(l)), + dataset.getType(), + refs[0]); + + } + } + } + } else { + if (listComponent + .get(0) + .getComponent() instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) listComponent + .get(0) + .getComponent(); + if (dataset + .getProperty( + "object_name") + .equals(did)) { + removeNRFiles( + dataset, + refs[0], + dataset.getTcFiles()); + for (int l = 0; l < listString + .size(); l++) { + importFilesOperation( + dataset, + new File( + listString + .get(l)), + dataset.getType(), + refs[0]); + + } + } else { + dataset.setProperty( + "object_name", + did); + removeNRFiles( + dataset, + refs[0], + dataset.getTcFiles()); + for (int l = 0; l < listString + .size(); l++) { + importFilesOperation( + dataset, + new File( + listString + .get(l)), + dataset.getType(), + refs[0]); + + } + } + } + } + } else { + System.out + .println("指定ID与类型的数据集已经不存在,将进行新建"); + System.out + .println("ds &&&&&&&&&&&&&&&&&& " + + ds); + TCComponentDataset tcd = datasetType + .create(did, "", ds); + System.out + .println("数据集新建完成"); + int ifail = -1; + for (int j = 0; j < refs.length; j++) { + if (refs[j] == null) { + ifail = j; + break; + } + } + if (ifail > 0) { + MessageBox + .post("没有为文件以下文件找到数据集的引用\n" + + files[ifail], + "错误", 1); + continue; + } + removeNRFiles(tcd, refs[0], + tcd.getTcFiles()); + for (int l = 0; l < listString + .size(); l++) { + importFilesOperation( + tcd, + new File( + listString + .get(l)), + tcd.getType(), + refs[0]); + + } + System.out + .println("设置其命名的引用完成 "); + + revision.add("IMAN_specification", + tcd); + System.out + .println("将其挂到零组件版本对象下完成"); + } + } else { + AIFComponentContext[] cc = revision + .getChildren("IMAN_specification"); + List listComponent = new ArrayList(); + for (int j = 0; j < cc.length; j++) { + InterfaceAIFComponent tcc = cc[j] + .getComponent(); + if (tcc instanceof TCComponentDataset) { + TCComponentDataset ods = (TCComponentDataset) tcc; + if (ods.getType() + .equals(ds)) { + listComponent + .add(cc[j]); + } + } + } + for (int k = 0; k < listComponent + .size(); k++) { + DeleteOperation deleteOperation = new DeleteOperation( + listComponent + .get(k)); + session.queueOperation(deleteOperation); + } + System.out + .println("fis.size()================= " + + fis.size()); + for (int count = 0,n=0; count < fis + .size(); count++,n++) { + TCComponentDataset tcd = null; + List filePathCount = fis + .get(count); + did = dids[n]; + String datasetName = did; + System.out + .println("============="+did); + // String datasetName = + // did+filepath.substring(filepath.lastIndexOf("-"),filepath.lastIndexOf(".")); + tcd = datasetType + .create(datasetName, + "", ds); + + System.out + .println("数据集新建完成"); + int ifail = -1; + for (int j = 0; j < refs.length; j++) { + if (refs[j] == null) { + ifail = j; + break; + } + } + if (ifail > 0) { + MessageBox + .post("没有为文件以下文件找到数据集的引用\n" + + files[ifail], + "错误", 1); + continue; + } + removeNRFiles(tcd, refs[0], + tcd.getTcFiles()); + for (int l = 0; l < filePathCount + .size(); l++) { + importFilesOperation( + tcd, + new File( + filePathCount + .get(l)), + tcd.getType(), + refs[0]); + + } + + System.out + .println("设置其命名的引用完成 "); + revision.add("IMAN_specification", + tcd); + System.out + .println("将其挂到零组件版本对象下完成"); + } + } + } else { + System.out.println("该零件没有数据集要处理"); + } + } + } catch (Exception e) { + System.out.println("【警告】excel中 第" + + parser.startRow + "行挂载数据集" + + datasets[i].getTcAttribute() + + "失败"); + continue; + } + } + + // 项目指派 + if (item != null) { + String projectname = ""; + if (projectIndex != -2) { + projectname = line.get(projectIndex); + System.out.println("项目所在列=" + projectIndex); + if (projectname != null + && !"".equals(projectname.trim())) { + System.out.println("项目ID=" + + projectname); + TCComponentProject pro = qeary(projectname); + if (pro != null) { + pro.assignToProject(new TCComponent[] { item }); + System.out.println("指派成功"); + } else { + StringBufferDemo( + "【失败】查询项目发生错误:未查到项目ID[" + + projectname + + "]\n\r", + "历史数据导入对象"); + fail++; + System.out.println("没有查到项目"); + } + + } + System.out.println("指派项目名称【" + projectname + + "】"); + + } else { + System.out.println("不需要指派项目"); + } + } + + // putDataset(parser, line, datasets, revision); + if (refresh) { + System.out.println("【成功】excel中 第" + + parser.startRow + "行更新完成"); + } else { + System.out.println("【成功】excel中 第" + + parser.startRow + "行创建完成"); + } + } + success++; + } else { + System.out.println("【警告】excel中 第" + parser.startRow + + "行ID为空,不进行导入处理"); + } + } catch (Exception e) { + e.printStackTrace(); + StringBufferDemo("ID:" + id + ",名称:" + line.get(nameIndex) + + ". 【失败】excel中 第" + parser.startRow + + "行导入失败,原因是: " + e.toString() + "\r\n", "历史数据导入对象"); + System.out.println("【失败】excel中 第" + parser.startRow + + "行导入失败,原因是: " + e.toString()); + fail++; + continue; + } + } + } catch (Exception e) { + logger.error("导入对象失败 - " + e.toString()); + logger.debug(e.toString()); + } + } + + /** + * cavalier added on 2013-08-15 + */ + public void putDataset(JXLExcelParser parser, List line, + MappingAttribute[] datasets, TCComponentItemRevision revision) { + // TODO 特殊处理 + String allFilePath = ""; + String allFilePaths[] = null; + if (locationIndex != -2) { + allFilePath = line.get(locationIndex); + if (allFilePath.contains(";")) { + allFilePaths = allFilePath.split(";"); + } else if (allFilePath.contains(";")) { + allFilePaths = allFilePath.split(";"); + } else { + allFilePaths = new String[] { allFilePath }; + } + System.out.println("特殊处理【文件个数" + allFilePaths.length + "】"); + } else { + System.out.println("不是特殊处理"); + } + int filePathIndex = 0; + + for (int i = 0; i < datasets.length; i++) { + try { + // logger.debug("开始处理第" + (i + 1) + "个"); + // String filePath = line.get(datasets[i].getColumnIndex()); + String filePath = null; + if (locationIndex != -2) { + if (datasets[i].getColumnIndex() == locationIndex) { + continue; + } + String fileName = line.get(datasets[i].getColumnIndex()); + if (fileName.trim().equals("")) { + System.out.println("特殊处理,数据集名称为空"); + continue; + } + + if (filePathIndex < allFilePaths.length) { + filePath = allFilePaths[filePathIndex]; + } else { + System.out.println("特殊处理,非空文件超出文件个数,请检查!"); + continue; + } + filePathIndex++; + logger.debug("开始处理第" + (filePathIndex) + "个"); + } else { + filePath = line.get(datasets[i].getColumnIndex()); + logger.debug("开始处理第" + (i + 1) + "个"); + } + + if (filePath.trim().length() > 0) { + + // ----------------------------------------- + AIFComponentContext[] cc22 = revision + .getChildren("IMAN_specification"); + List listComponent22 = new ArrayList(); + System.out.println(">>>>>>>删除数据集count=" + cc22.length); + for (int j = 0; j < cc22.length; j++) { + InterfaceAIFComponent tcc = cc22[j].getComponent(); + if (tcc instanceof TCComponentDataset) { + TCComponentDataset ods = (TCComponentDataset) tcc; + // if (ods.getType().equals(ds)) { + listComponent22.add(cc22[j]); + // } + } + } + for (int k = 0; k < listComponent22.size(); k++) { + DeleteOperation deleteOperation = new DeleteOperation( + listComponent22.get(k)); + session.queueOperation(deleteOperation); + } + System.out.println(">>>>>>>删除数据集完成 "); + // ---------------------------------------- + System.out.println("数据集的路径为" + filePath); + String ds = datasets[i].getTcAttribute(); + // String sep = ois.getArraySeparator(); + // 假如filePath以“||”就表示挂成多个数据集,如果以“;”就表示挂一个数据集,添加多个命名引用 + String[] files = filePath.split("\\|\\|"); + List> fis = new ArrayList>(); + for (int j = 0; j < files.length; j++) { + String filepath = files[j].trim(); + if (filepath.contains(";")) { + String[] filepaths = filepath.split(";"); + List list = new ArrayList(); + for (int k = 0; k < filepaths.length; k++) { + File file = new File(filepaths[k].trim()); + if (file.exists()) { + list.add(file.getAbsolutePath()); + } else { + // 需要报错 + try { + StringBufferDemo( + "ID: " + + ". 【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是: 表格中填写的路径" + + file.getAbsolutePath() + + "有误\r\n", "历史数据导入对象"); + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println("【失败】文件" + + file.getAbsolutePath() + + "不存在,不予以处理"); + logger.error("【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是:表格中填写数据集路径有误"); + fail++; + continue; + } + } + fis.add(list); + } else if (filepath.contains(";")) { + String[] filepaths = filepath.split(";"); + List list = new ArrayList(); + for (int k = 0; k < filepaths.length; k++) { + File file = new File(filepaths[k].trim()); + System.out.println("文件路径为:" + file); + if (file.exists()) { + list.add(file.getAbsolutePath()); + } else { + // 需要报错 + try { + StringBufferDemo("ID:" + " " + + ". 【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是: 表格中填写的数据集路径" + + file.getAbsolutePath() + + "有误\r\n", "历史数据导入对象"); + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println("【失败】文件" + + file.getAbsolutePath() + + "不存在,不予以处理"); + logger.error("【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是:表格中填写数据集路径" + + file.getAbsolutePath() + "有误"); + fail++; + continue; + } + } + fis.add(list); + } else { + System.out + .println("files[" + j + "] = " + files[j]); + File file = new File(files[j].trim()); + if (file.exists()) { + List list = new ArrayList(); + list.add(file.getAbsolutePath()); + fis.add(list); + } else { + // 需要报错 + try { + StringBufferDemo( + "ID:" + " " + ". 【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是: 表格中填写的路径" + + file.getAbsolutePath() + + "有误\r\n", "历史数据导入对象"); + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println("【失败】文件" + + file.getAbsolutePath() + "不存在,不予以处理"); + logger.error("【失败】excel中 第" + parser.startRow + + "行导入失败,原因是:表格中填写数据集路径有误"); + fail++; + continue; + } + } + } + + if (fis.size() > 0) { + String did = line.get(datasets[i].getColumnIndex()); + if (did.contains(".") && did.contains("\\")) { + did = did.substring(did.lastIndexOf("\\") + 1, + did.lastIndexOf(".")); + } + // String did = revision.getProperty("item_id"); + // did = did + "/" + + // revision.getProperty("item_revision_id"); + + System.out.println("生成的数据集id为" + did); + String[] refs = guessDatasetReferenceNames(ds, files); + for (int j = 0; j < refs.length; j++) { + if (refs[j] == null) { + try { + StringBufferDemo("ID:" + " " + + ". 【失败】excel中 第" + + parser.startRow + "行导入失败,原因是: " + + "没有为文件" + files[j] + + "找到命名的引用,请查看" + ds + + "类型数据集的文件模板定义" + "\r\n", + "历史数据导入对象"); + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println("【失败】excel中 第" + + parser.startRow + "数据集导入失败,没有为文件" + + files[j] + "找到命名的引用,请查看" + ds + + "类型数据集的文件模板定义"); + logger.error("【失败】excel中 第" + parser.startRow + + "数据集导入失败,没有为文件" + files[j] + + "找到命名的引用,请查看" + ds + "类型数据集的文件模板定义"); + fail++; + continue; + } + } + System.out.println("取得系统中指定文件类型所对应的数据集引用的名字成功完成"); + if (fis.size() == 1) { + AIFComponentContext[] cc2 = revision + .getChildren("IMAN_specification"); + List listComponent2 = new ArrayList(); + System.out.println(">>删除数据集count=" + cc2.length); + for (int j = 0; j < cc2.length; j++) { + InterfaceAIFComponent tcc = cc2[j] + .getComponent(); + if (tcc instanceof TCComponentDataset) { + TCComponentDataset ods = (TCComponentDataset) tcc; + if (ods.getType().equals(ds)) { + listComponent2.add(cc2[j]); + } + } + } + for (int k = 0; k < listComponent2.size(); k++) { + DeleteOperation deleteOperation = new DeleteOperation( + listComponent2.get(k)); + session.queueOperation(deleteOperation); + } + System.out.println(">>删除数据集完成 "); + + // ---------------------------------- + List listString = fis.get(0); + AIFComponentContext[] cc = revision + .getChildren("IMAN_specification"); + List listComponent = new ArrayList(); + for (int j = 0; j < cc.length; j++) { + InterfaceAIFComponent tcc = cc[j] + .getComponent(); + if (tcc instanceof TCComponentDataset) { + TCComponentDataset ods = (TCComponentDataset) tcc; + if (ods.getStringProperty("object_name") + .equals(did)) { + listComponent.add(cc[j]); + } + } + } + if (listComponent.size() > 0) { + if (listComponent.size() > 1) { + for (int k = 0; k < listComponent.size() - 1; k++) { + DeleteOperation deleteOperation = new DeleteOperation( + listComponent.get(k)); + session.queueOperation(deleteOperation); + listComponent.remove(k); + k--; + } + if (listComponent.get(0).getComponent() instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) listComponent + .get(0).getComponent(); + if (dataset.getProperty("object_name") + .equals(did)) { + removeNRFiles(dataset, refs[0], + dataset.getTcFiles()); + for (int l = 0; l < listString + .size(); l++) { + importFilesOperation( + dataset, + new File(listString + .get(l)), + dataset.getType(), + refs[0]); + + } + } else { + dataset.setProperty("object_name", + did); + removeNRFiles(dataset, refs[0], + dataset.getTcFiles()); + for (int l = 0; l < listString + .size(); l++) { + importFilesOperation( + dataset, + new File(listString + .get(l)), + dataset.getType(), + refs[0]); + + } + } + } + } else { + if (listComponent.get(0).getComponent() instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) listComponent + .get(0).getComponent(); + if (dataset.getProperty("object_name") + .equals(did)) { + removeNRFiles(dataset, refs[0], + dataset.getTcFiles()); + for (int l = 0; l < listString + .size(); l++) { + importFilesOperation( + dataset, + new File(listString + .get(l)), + dataset.getType(), + refs[0]); + + } + } else { + dataset.setProperty("object_name", + did); + removeNRFiles(dataset, refs[0], + dataset.getTcFiles()); + for (int l = 0; l < listString + .size(); l++) { + importFilesOperation( + dataset, + new File(listString + .get(l)), + dataset.getType(), + refs[0]); + + } + } + } + } + } else { + System.out.println("指定ID与类型的数据集已经不存在,将进行新建"); + System.out.println("ds &&&&&&&&&&&&&&&&&& " + + ds); + TCComponentDataset tcd = datasetType.create( + did, "", ds); + System.out.println("数据集新建完成"); + int ifail = -1; + for (int j = 0; j < refs.length; j++) { + if (refs[j] == null) { + ifail = j; + break; + } + } + if (ifail > 0) { + MessageBox.post("没有为文件以下文件找到数据集的引用\n" + + files[ifail], "错误", 1); + continue; + } + removeNRFiles(tcd, refs[0], tcd.getTcFiles()); + for (int l = 0; l < listString.size(); l++) { + importFilesOperation(tcd, new File( + listString.get(l)), tcd.getType(), + refs[0]); + + } + System.out.println("设置其命名的引用完成 "); + + revision.add("IMAN_specification", tcd); + System.out.println("将其挂到零组件版本对象下完成"); + } + } else { + AIFComponentContext[] cc2 = revision + .getChildren("IMAN_specification"); + List listComponent2 = new ArrayList(); + System.out.println("删除数据集count=" + cc2.length); + for (int j = 0; j < cc2.length; j++) { + InterfaceAIFComponent tcc = cc2[j] + .getComponent(); + if (tcc instanceof TCComponentDataset) { + TCComponentDataset ods = (TCComponentDataset) tcc; + if (ods.getType().equals(ds)) { + listComponent2.add(cc2[j]); + } + } + } + for (int k = 0; k < listComponent2.size(); k++) { + DeleteOperation deleteOperation = new DeleteOperation( + listComponent2.get(k)); + session.queueOperation(deleteOperation); + } + System.out.println("删除数据集完成 "); + + AIFComponentContext[] cc = revision + .getChildren("IMAN_specification"); + List listComponent = new ArrayList(); + for (int j = 0; j < cc.length; j++) { + InterfaceAIFComponent tcc = cc[j] + .getComponent(); + if (tcc instanceof TCComponentDataset) { + TCComponentDataset ods = (TCComponentDataset) tcc; + if (ods.getType().equals(ds)) { + listComponent.add(cc[j]); + } + } + } + for (int k = 0; k < listComponent.size(); k++) { + DeleteOperation deleteOperation = new DeleteOperation( + listComponent.get(k)); + session.queueOperation(deleteOperation); + } + System.out.println("fis.size()================= " + + fis.size()); + for (int count = 0; count < fis.size(); count++) { + List filePathCount = fis.get(count); + TCComponentDataset tcd = null; + String filepath = filePathCount.get(0); + + String datasetName = did; + // String datasetName = + // did+filepath.substring(filepath.lastIndexOf("-"),filepath.lastIndexOf(".")); + + tcd = datasetType.create(datasetName, "", ds); + System.out.println("数据集新建完成"); + int ifail = -1; + for (int j = 0; j < refs.length; j++) { + if (refs[j] == null) { + ifail = j; + break; + } + } + if (ifail > 0) { + MessageBox.post("没有为文件以下文件找到数据集的引用\n" + + files[ifail], "错误", 1); + continue; + } + removeNRFiles(tcd, refs[0], tcd.getTcFiles()); + for (int l = 0; l < filePathCount.size(); l++) { + importFilesOperation(tcd, new File( + filePathCount.get(l)), + tcd.getType(), refs[0]); + + } + System.out.println("设置其命名的引用完成 "); + revision.add("IMAN_specification", tcd); + System.out.println("将其挂到零组件版本对象下完成"); + } + } + } else { + System.out.println("该零件没有数据集要处理"); + } + } + } catch (Exception e) { + try { + StringBufferDemo("ID:" + " " + ". 【失败】excel中 第" + + parser.startRow + "行导入失败,原因是:行挂载数据集" + + datasets[i].getTcAttribute() + "失败\r\n", + "历史数据导入对象"); + } catch (IOException e1) { + e1.printStackTrace(); + } + System.out.println("【警告】excel中 第" + parser.startRow + "行挂载数据集" + + datasets[i].getTcAttribute() + "失败"); + continue; + } + } + } + + private void importObjectsByPoi(ObjectsImportSettings ois, File input) { + System.out.println("对象导入开始"); + + try { + TCComponent[] uoms = uom.extent(); + Map uomMap = new HashMap(); + if (uoms != null) { + for (int i = 0; i < uoms.length; i++) { + uomMap.put(uoms[i].toString(), uoms[i]); + } + } + int uomIndex = -1; + int idIndex = -1; + int nameIndex = -1; + + boolean isthroughParent = ois.isSelectParent(); + MappingAttribute[] items = ois.getItemMapping(); + MappingAttribute[] revisions = ois.getRevMapping(); + MappingAttribute[] forms = ois.getRevFormMapping(); + MappingAttribute[] datasetMap = ois.getDatasetMapping();// 2017/10/24 + + for (int i = 0; i < datasetMap.length; i++) { + if ("路径".equals(datasetMap[i].getTcAttribute()) + && "路径".equals(datasetMap[i].getColumnTitle())) { + this.locationIndex = datasetMap[i].getColumnIndex(); + System.out.println(">>路径所对应的列" + locationIndex); + } else { + System.out.println(">>没有找到路径" + locationIndex); + } + + } + + for (int i = 0; i < items.length; i++) { + if ("项目".equals(items[i].getTcAttribute())) { + this.projectIndex = items[i].getColumnIndex(); + System.out.println(">>项目所对应的列" + projectIndex); + } else { + System.out.println(">>没有找到项目" + projectIndex); + } + + } + + for (int i = 0; i < items.length; i++) { + if ("item_id".equals(items[i].getTcAttribute())) { + idIndex = items[i].getColumnIndex(); + System.out.println("零组件ID所对应的列" + idIndex); + continue; + } + if ("uom_tag".equals(items[i].getTcAttribute())) { + uomIndex = items[i].getColumnIndex(); + System.out.println("测量单位所对应的列为" + uomIndex); + } + if ("object_name".equals(items[i].getTcAttribute())) { + nameIndex = items[i].getColumnIndex(); + System.out.println("名称所对应的列为" + nameIndex); + } + } + + if (idIndex < 0) { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), + "【失败】没有选择ID所对应的列,不能完成导入", "错误", 1); + return; + } + + if (nameIndex < 0) { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), + "【失败】没有选择名称所对应的列,不能完成导入", "错误", 1); + return; + } + + int itemRevIndex = -1; + for (int i = 0; i < revisions.length; i++) { + if ("item_revision_id".equals(revisions[i].getTcAttribute())) { + itemRevIndex = revisions[i].getColumnIndex(); + System.out.println("零组件版本所对应的列为" + itemRevIndex); + } + } + + POIExcelParser parser = new POIExcelParser(input, 0, + ois.getColumns(), 1); + reporter.setTaskRange(0, parser.rows); + List line = null; + while ((line = parser.parseLine()) != null) { + reporter.setProgressPercent(parser.startRow); + reporter.reportProgressMessage("正在导入第 " + parser.startRow + + " 行数据"); + try { + String id = line.get(idIndex); + if (id.length() > 0) { + TCComponent uomCom = null; + if (uomIndex >= 0) { + String uom = line.get(uomIndex); + if (uom.length() > 0) { + uomCom = uomMap.get(uom); + + if (uomCom == null) { + StringBufferDemo("【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是: 所指定的单位没有在系统中定义\n\r", + "历史数据导入对象"); + System.out.println("【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是: 所指定的单位没有在系统中定义."); + fail++; + continue; + } + } + } + + String rev = ""; + if (itemRevIndex > 0) { + rev = line.get(itemRevIndex); + } + TCComponentItem item = null; + item = itemType.find(id); + TCComponentItemRevision revision = null; + List ps = new ArrayList(); + boolean refresh = false; + if (item == null) { + String name = line.get(nameIndex); + if (name.equals("")) { + StringBufferDemo("【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是: 零组件的的名字为不允许为空值\n\r", + "历史数据导入对象"); + System.out.println("【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是: 零组件的的名字为不允许为空值"); + fail++; + continue; + } + // TODO 添加对类型的特殊处理 + if (typeIndex == -2) { + item = itemType.create(id, rev, + ois.getItemType(), name, "", uomCom); + } else { + String typeTemp1 = line.get(typeIndex); + String typeTemp = typeMapTemp.get(typeTemp1); + if (typeTemp != null && typeTemp.length() > 0) { + TCTypeService typeService = session + .getTypeService(); + TCComponentType type = typeService + .getTypeComponent(typeTemp); + if (type == null) { + System.out.println("【失败】excel中 第" + + parser.startRow + + "行新建失败,原因是: 找不到该类型"); + continue; + } + item = itemType.create(id, rev, typeTemp, + name, "", uomCom); + } else { + System.out.println("【失败】excel中 第" + + parser.startRow + + "行新建失败,原因是: 找不到该类型"); + continue; + } + } + revision = item.getLatestItemRevision(); + folder.add("contents", item); + System.out.println("零组件被成功创建 "); + } else { + refresh = true; + System.out.println("零组件已经存在于系统当中,不需要创建"); + } + + if (revision == null) { + System.out.println("查找指定的零组件版本 - " + rev); + InterfaceAIFComponent[] coms = null; + coms = SearchUtility.searchComponentsCollection( + session, "ConnorItemRevSearch", + new String[] { "ItemID1", "Revision1" }, + new String[] { id, rev }); + + if (coms != null && coms.length > 0) { + revision = (TCComponentItemRevision) coms[0]; + } + } + + if (revision == null && !rev.equals("")) { + refresh = false; + System.out.println("零组件已经存,但指定的版本不存在,现在将其修订至指定版本"); + revision = item.getLatestItemRevision().saveAs(rev, + item.getProperty("object_name"), "", true, + null, null); + System.out.println("修订至指定版本成功"); + } + if (revision == null) { + revision = item.getLatestItemRevision(); + } + if ((refresh && ois.isExistedRefreshed()) || !refresh) { + String name = line.get(nameIndex); + if (name.equals("")) { + StringBufferDemo("【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是: 零组件的的名字为不允许为空值\n\r", + "历史数据导入对象"); + System.out.println("【失败】excel中 第" + + parser.startRow + + "行更新失败,原因是: 零组件的的名字为不允许为空值"); + fail++; + continue; + } + + if (uomCom != null) { + try { + item.setReferenceProperty("uom_tag", uomCom); + } catch (Exception e) { + StringBufferDemo( + "【失败】excel中 第" + + parser.startRow + + "行更新失败,原因是: 该行零组件的单位不允许修改,请检查其时事已经搭建过BOM\n\r", + "历史数据导入对象"); + System.out + .println("【失败】excel中 第" + + parser.startRow + + "行更新失败,原因是: 该行零组件的单位不允许修改,请检查其时事已经搭建过BOM"); + fail++; + continue; + } + } + System.out.println("更新零组件上的属性"); + ps.clear(); + TCComponentIdentifierType altype = (TCComponentIdentifierType) session + .getTypeService().getTypeComponent( + "Identifier"); + TCComponentIdContextRuleType tccomponentidcontextruletype = (TCComponentIdContextRuleType) session + .getTypeComponent("IdContextRule"); + TCComponentIdContext[] context; + context = tccomponentidcontextruletype + .getAliasContexts(); + for (int i = 0; i < items.length; i++) { + if (items[i].equals("uom_tag") + || items[i].equals("object_name")) { + continue; + } + if (items[i].getTcAttribute().equals( + "IMAN_aliasid")) { + TCComponentIdentifier alid = altype + .createAliasIdentifier("WX3_AAA"); + alid.setReferenceProperty("idcontext", + context[0]); + alid.setProperty("idfr_id", + line.get(items[i].getColumnIndex())); + alid.setProperty("object_name", "wx"); + alid.setProperty("object_desc", ""); + alid.save(); + item.add("IMAN_aliasid", alid); + continue; + } + TCProperty property = item + .getTCProperty(items[i] + .getTcAttribute()); + if (property != null + && property.getPropertyDescriptor() + .isModifiable()) { + if (property.getPropertyName().equals( + "item_id")) { + continue; + } + setTCProperty(property, + line.get(items[i].getColumnIndex())); + ps.add(property); + } + } + item.setTCProperties(ps.toArray(new TCProperty[ps + .size()])); + System.out.println("更新零组件上的属性成功完成更新 "); + + System.out.println("更新创建的零组件版本上的属性"); + revision.setProperty("object_name", + item.getProperty("object_name")); + ps.clear(); + for (int i = 0; i < revisions.length; i++) { + TCProperty property = revision + .getTCProperty(revisions[i] + .getTcAttribute()); + + System.out.println("property:" + + revisions[i].getTcAttribute()); + System.out.println("type:" + + property.getPropertyType()); + if (property != null + && property.getPropertyDescriptor() + .isModifiable()) { + logger.debug("更新属性 - " + + property.getPropertyName()); + String propertyName = property.getName(); + String relatedItemType = null; + if (propertyName.equals("MnfBrandOAttr")) { + relatedItemType = "MnfBrandObj"; + } else if (propertyName + .equals("MnfCategoryOAttr")) { + relatedItemType = "MnfCategoryObj"; + } else if (propertyName + .equals("MnfProdLineOAttr")) { + relatedItemType = "MnfProdLineObj"; + } else if (propertyName + .equals("MnfSeasonOAttr")) { + relatedItemType = "MnfSeasonObj"; + } else if (propertyName + .equals("MnfSeriesOAttr")) { + relatedItemType = "MnfSeriesObj"; + } else if (propertyName + .equals("MnfStyleOAttr")) { + relatedItemType = "MnfStyleObj"; + } else if (propertyName + .equals("MnfMaterialBOAttr")) { + relatedItemType = "MnfMaterialBType"; + } else if (propertyName + .equals("MnfMaterialSOAttr")) { + relatedItemType = "MnfMaterialSType"; + } + if (relatedItemType != null) { + logger.debug("通过名字和类型查找对应的Item对象"); + InterfaceAIFComponent[] cs = SearchUtility + .searchComponentsCollection( + session, + "ConnorItemSearch", + new String[] { "Name1", + "Type1" }, + new String[] { + line.get(revisions[i] + .getColumnIndex()), + relatedItemType + + "Revision" }); + if (cs != null && cs.length > 0) { + logger.debug("找到名称为" + + line.get(revisions[i] + .getColumnIndex()) + + ",类型为" + relatedItemType + + "的对象"); + if (cs[0] instanceof TCComponentItemRevision) { + TCComponentItemRevision tcc = (TCComponentItemRevision) cs[0]; + property.setPropertyData(tcc); + } + } else { + StringBufferDemo( + "【失败】没有找到名称为" + + line.get(revisions[i] + .getColumnIndex()) + + ",类型为" + + relatedItemType + + "的对象\n\r", + "历史数据导入对象"); + logger.error("【失败】没有找到名称为" + + line.get(revisions[i] + .getColumnIndex()) + + ",类型为" + relatedItemType + + "的对象"); + System.out.println("【失败】没有找到名称为" + + line.get(revisions[i] + .getColumnIndex()) + + ",类型为" + relatedItemType + + "的对象"); + fail++; + continue; + } + } else { + + setTCProperty(property, + line.get(revisions[i] + .getColumnIndex())); + } + ps.add(property); + } + } + revision.setTCProperties(ps + .toArray(new TCProperty[ps.size()])); + System.out.println("更新创建的零组件上的属性成功 "); + TCComponentForm form = getItemRevisionMasterForm(revision); + if (form != null) { + System.out.println("获取零组件版本Form成功,开始更新其属性"); + ps.clear(); + for (int i = 0; i < forms.length; i++) { + + TCProperty property = form + .getTCProperty(forms[i] + .getTcAttribute()); + if (property != null + && property.getDescriptor() + .isModifiable()) { + + setTCProperty(property, + line.get(forms[i] + .getColumnIndex())); + ps.add(property); + } + } + form.setTCProperties(ps + .toArray(new TCProperty[ps.size()])); + form.save(); + } else { + System.out.println("获取零组件版本Form失败"); + } + + + + + + + // TODO 添加数据集处理 + MappingAttribute[] datasets = ois + .getDatasetMapping(); + System.out.println("处理版本下面的数据集, 有" + + datasets.length + "个需要处理"); + ps.clear(); + // TODO 特殊处理 + String allFilePath = ""; + String allFilePaths[] = null; + if (locationIndex != -2) { + allFilePath = line.get(locationIndex); + if (allFilePath.contains(";")) { + allFilePaths = allFilePath.split(";"); + } else if (allFilePath.contains(";")) { + allFilePaths = allFilePath.split(";"); + } else { + allFilePaths = new String[] { allFilePath }; + } + System.out.println("特殊处理【文件个数" + + allFilePaths.length + "】"); + } else { + System.out.println("不是特殊处理"); + } + int filePathIndex = 0; + for (int i = 0; i < datasets.length; i++) { + System.out.println("dataset:" + + datasets[i].getColumnIndex()); + System.out.println("dataset2:" + + datasets[i].getColumnTitle()); + try { + String filePath = null; + if (locationIndex != -2) { + if (datasets[i].getColumnIndex() == locationIndex) { + continue; + } + String fileName = line.get(datasets[i] + .getColumnIndex()); + if (fileName.trim().equals("")) { + System.out.println("特殊处理,数据集名称为空"); + continue; + } + + if (filePathIndex < allFilePaths.length) { + filePath = allFilePaths[filePathIndex]; + } else { + System.out + .println("特殊处理,非空文件超出文件个数,请检查!"); + continue; + } + filePathIndex++; + logger.debug("开始处理第" + (filePathIndex) + + "个"); + } else { + filePath = line.get(datasets[i] + .getColumnIndex()); + logger.debug("开始处理第" + (i + 1) + "个"); + } + if (filePath.trim().length() > 0) { + System.out + .println("数据集的路径为" + filePath); + String ds = datasets[i] + .getTcAttribute(); + // String sep = ois.getArraySeparator(); + // 假如filePath以“||”就表示挂成多个数据集,如果以“;”就表示挂一个数据集,添加多个命名引用 + String[] files = filePath + .split("\\|\\|"); + List> fis = new ArrayList>(); + for (int j = 0; j < files.length; j++) { + String filepath = files[j].trim(); + if (filepath.contains(";")) { + String[] filepaths = filepath + .split(";"); + List list = new ArrayList(); + for (int k = 0; k < filepaths.length; k++) { + File file = new File( + filepaths[k].trim()); + if (file.exists()) { + list.add(file + .getAbsolutePath()); + } else { + // 需要报错 + StringBufferDemo( + "【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是:表格中填写数据集路径有误\r\n", + "历史数据导入对象"); + System.out + .println("文件" + + file.getAbsolutePath() + + "不存在,不予以处理"); + logger.error("【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是:表格中填写数据集路径有误"); + fail++; + continue; + } + } + fis.add(list); + } else if (filepath.contains(";")) { + String[] filepaths = filepath + .split(";"); + List list = new ArrayList(); + for (int k = 0; k < filepaths.length; k++) { + File file = new File( + filepaths[k].trim()); + System.out.println("文件路径为:" + + file); + if (file.exists()) { + list.add(file + .getAbsolutePath()); + } else { + // 需要报错 + StringBufferDemo( + "【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是:表格中填写数据集路径有误\n\r", + "历史数据导入对象"); + System.out + .println("文件" + + file.getAbsolutePath() + + "不存在,不予以处理"); + logger.error("【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是:表格中填写数据集路径有误"); + fail++; + continue; + } + } + fis.add(list); + } else { + System.out.println("files[" + j + + "] = " + files[j]); + File file = new File( + files[j].trim()); + if (file.exists()) { + List list = new ArrayList(); + list.add(file + .getAbsolutePath()); + fis.add(list); + } else { + // 需要报错 + StringBufferDemo( + "【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是:表格中填写数据集路径有误\n\r", + "历史数据导入对象"); + System.out + .println("【错误】文件" + + file.getAbsolutePath() + + "不存在,不予以处理"); + logger.error("【失败】excel中 第" + + parser.startRow + + "行导入失败,原因是:表格中填写数据集路径有误"); + fail++; + continue; + } + } + } + + if (fis.size() > 0) { + String did = line.get(datasets[i] + .getColumnIndex()); + String[] dids = null; + if(did.contains(";")){ + dids = did.split(";"); + }else if(did.contains(";")){ + dids = did.split(";"); + }else{ + dids = new String[1]; + dids[0] = did; + } + for(int n=0;n listString = fis + .get(0); + AIFComponentContext[] cc = revision + .getChildren("IMAN_specification"); + List listComponent = new ArrayList(); + for (int j = 0; j < cc.length; j++) { + InterfaceAIFComponent tcc = cc[j] + .getComponent(); + if (tcc instanceof TCComponentDataset) { + TCComponentDataset ods = (TCComponentDataset) tcc; + if (ods.getStringProperty( + "object_name") + .equals(did)) { + listComponent + .add(cc[j]); + } + } + } + if (listComponent.size() > 0) { + if (listComponent.size() > 1) { + for (int k = 0; k < listComponent + .size() - 1; k++) { + DeleteOperation deleteOperation = new DeleteOperation( + listComponent + .get(k)); + session.queueOperation(deleteOperation); + listComponent + .remove(k); + k--; + } + if (listComponent + .get(0) + .getComponent() instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) listComponent + .get(0) + .getComponent(); + if (dataset + .getProperty( + "object_name") + .equals(did)) { + removeNRFiles( + dataset, + refs[0], + dataset.getTcFiles()); + for (int l = 0; l < listString + .size(); l++) { + importFilesOperation( + dataset, + new File( + listString + .get(l)), + dataset.getType(), + refs[0]); + + } + } else { + dataset.setProperty( + "object_name", + did); + removeNRFiles( + dataset, + refs[0], + dataset.getTcFiles()); + for (int l = 0; l < listString + .size(); l++) { + importFilesOperation( + dataset, + new File( + listString + .get(l)), + dataset.getType(), + refs[0]); + + } + } + } + } else { + if (listComponent + .get(0) + .getComponent() instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) listComponent + .get(0) + .getComponent(); + if (dataset + .getProperty( + "object_name") + .equals(did)) { + removeNRFiles( + dataset, + refs[0], + dataset.getTcFiles()); + for (int l = 0; l < listString + .size(); l++) { + importFilesOperation( + dataset, + new File( + listString + .get(l)), + dataset.getType(), + refs[0]); + + } + } else { + dataset.setProperty( + "object_name", + did); + removeNRFiles( + dataset, + refs[0], + dataset.getTcFiles()); + for (int l = 0; l < listString + .size(); l++) { + importFilesOperation( + dataset, + new File( + listString + .get(l)), + dataset.getType(), + refs[0]); + + } + } + } + } + } else { + System.out + .println("指定ID与类型的数据集已经不存在,将进行新建"); + System.out + .println("ds &&&&&&&&&&&&&&&&&& " + + ds); + TCComponentDataset tcd = datasetType + .create(did, "", ds); + System.out + .println("数据集新建完成"); + int ifail = -1; + for (int j = 0; j < refs.length; j++) { + if (refs[j] == null) { + ifail = j; + break; + } + } + if (ifail > 0) { + MessageBox + .post("没有为文件以下文件找到数据集的引用\n" + + files[ifail], + "错误", 1); + continue; + } + removeNRFiles(tcd, refs[0], + tcd.getTcFiles()); + for (int l = 0; l < listString + .size(); l++) { + importFilesOperation( + tcd, + new File( + listString + .get(l)), + tcd.getType(), + refs[0]); + + } + System.out + .println("设置其命名的引用完成 "); + + revision.add("IMAN_specification", + tcd); + System.out + .println("将其挂到零组件版本对象下完成"); + } + } + } else { + AIFComponentContext[] cc = revision + .getChildren("IMAN_specification"); + List listComponent = new ArrayList(); + for (int j = 0; j < cc.length; j++) { + InterfaceAIFComponent tcc = cc[j] + .getComponent(); + if (tcc instanceof TCComponentDataset) { + TCComponentDataset ods = (TCComponentDataset) tcc; + if (ods.getType() + .equals(ds)) { + listComponent + .add(cc[j]); + } + } + } + for (int k = 0; k < listComponent + .size(); k++) { + DeleteOperation deleteOperation = new DeleteOperation( + listComponent + .get(k)); + session.queueOperation(deleteOperation); + } + System.out + .println("fis.size()================= " + + fis.size()); + for (int count = 0,n=0; count < fis + .size(); count++,n++) { + TCComponentDataset tcd = null; + List filePathCount = fis + .get(count); + did = dids[n]; + String datasetName = did; + System.out + .println("==============="+did); + + // String datasetName = + // did+filepath.substring(filepath.lastIndexOf("-"),filepath.lastIndexOf(".")); + tcd = datasetType + .create(datasetName, + "", ds); + System.out + .println("数据集新建完成"); + int ifail = -1; + for (int j = 0; j < refs.length; j++) { + if (refs[j] == null) { + ifail = j; + break; + } + } + if (ifail > 0) { + MessageBox + .post("没有为文件以下文件找到数据集的引用\n" + + files[ifail], + "错误", 1); + continue; + } + removeNRFiles(tcd, refs[0], + tcd.getTcFiles()); + for (int l = 0; l < filePathCount + .size(); l++) { + importFilesOperation( + tcd, + new File( + filePathCount + .get(l)), + tcd.getType(), + refs[0]); + + + + System.out + .println("设置其命名的引用完成 "); + revision.add("IMAN_specification", + tcd); + System.out + .println("将其挂到零组件版本对象下完成"); + } + } + } + + } else { + System.out.println("该零件没有数据集要处理"); + } + } + } catch (Exception e) { + System.out.println("【警告】excel中 第" + + parser.startRow + "行挂载数据集" + + datasets[i].getTcAttribute() + + "失败"); + continue; + } + } + + + + + + + // 创建 + + // 项目指派 + if (item != null) { + String projectname = ""; + if (projectIndex != -2) { + projectname = line.get(projectIndex); + if (projectname != null + && !"".equals(projectname.trim())) { + TCComponentProject pro = qeary(projectname); + if (pro != null) { + pro.assignToProject(new TCComponent[] { item }); + System.out.println("指派成功"); + } else { + StringBufferDemo( + "【失败】查询项目发生错误:未查到项目名称[" + + projectname + + "]\n\r", + "历史数据导入对象"); + fail++; + System.out.println("没有查到项目"); + } + + } + System.out.println("指派项目名称【" + projectname + + "】"); + + } else { + System.out.println("不需要指派项目"); + } + } + + if (refresh) { + System.out.println("【成功】excel中 第" + + parser.startRow + "行更新完成"); + } else { + System.out.println("【成功】excel中 第" + + parser.startRow + "行创建完成"); + } + } + success++; + } else { + System.out.println("【警告】excel中 第" + parser.startRow + + "行ID为空,不进行导入处理"); + } + } catch (Exception e) { + e.printStackTrace(); + StringBufferDemo("【失败】excel中 第" + parser.startRow + + "行导入失败,原因是: " + e.toString() + "\n\r", "历史数据导入对象"); + System.out.println("【失败】excel中 第" + parser.startRow + + "行导入失败,原因是: " + e.toString()); + fail++; + continue; + } + } + } catch (Exception e) { + logger.error("导入对象失败 - " + e.toString()); + logger.debug(e.toString()); + } + } + + private TCComponentProject qeary(String str) { + // TODO Auto-generated method stub + TCComponent[] projects = null; + try { + projects = session.search("项目...", new String[] { "项目 ID" }, + new String[] { str }); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + try { + StringBufferDemo("【失败】查询项目发生错误:" + e.getMessage() + "\n\r", + "历史数据导入对象"); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + fail++; + } + if (projects != null && projects.length > 0) { + return (TCComponentProject) projects[0]; + } + return null; + } + + private String[] guessDatasetReferenceNames(String ds, String[] files) + throws TCException { + System.out.println("开始取得系统中指定文件类型所对应的数据集引用的名字"); + System.out.println("ds==" + ds); + System.out.println("files.length==" + files.length); + System.out.println("files[0]==" + files[0]); + TCComponentDatasetDefinition definition = dsdefType.find(ds); + System.out.println("definition==" + definition); + NamedReferenceContext[] contexts = definition + .getNamedReferenceContexts(); + System.out.println("contexts.length==" + contexts.length); + Hashtable hashtable = new Hashtable( + contexts.length); + String all = ""; + for (int i = 0; i < contexts.length; i++) { + String template = contexts[i].getFileTemplate(); + int index = template.lastIndexOf("."); + if (index != -1) { + hashtable.put(template.substring(index + 1).toLowerCase(), + contexts[i].getNamedReference()); + } else { + all = template.toLowerCase(); + hashtable.put(all, contexts[i].getNamedReference()); + } + } + + String refers[] = new String[files.length]; + System.out.println("有" + files.length + "个文件需要获取数据集引用"); + for (int i = 0; i < files.length; i++) { + String name = (new File(files[i])).getName(); + refers[i] = hashtable.get(name.substring(name.lastIndexOf(".") + 1) + .toLowerCase()); + if (refers[i] == null) { + refers[i] = hashtable.get(all); + } + + System.out.println(name.substring(name.lastIndexOf(".") + 1) + .toLowerCase() + "对应" + refers[i]); + } + + return refers; + } + + private void setTCProperty(TCProperty property, String value) + throws TCException { + System.out.println("setTCProperty(TCProperty property 更新属性=" + + property.getPropertyName() + ", String value=" + value + + ") - start"); + // if (value == null || value.length() == 0) { + // System.out.println("setTCProperty(TCProperty property, String value) + // - end"); + // return; + // } + if (value == null || value.length() == 0) + return; + + //lov转换成真实值2017.11.8 + TCPropertyDescriptor descriptor = property.getPropertyDescriptor(); + TCComponentListOfValues lov=property.getLOV(); + String[] realValues = null; + if(lov!=null){//判断是否lov + String[] strs=lov.getListOfValues().getStringListOfValues();//所有真实值 + Boolean flag = true; + if(descriptor.isArray()) { + String[] values = null; + if(value.contains(",")) { + values = value.split(","); + }else if(value.contains(",")) { + values = value.split(","); + }else { + values = new String[] {value}; + } + for (int i = 0; i < values.length; i++) { + System.out.println("values【"+i+"】============"+values[i]); + } + realValues = new String[values.length]; + for (int i = 0; i < values.length; i++) { + for(String s1:strs){ + String a1 = lov.getListOfValues().getDisplayableValue(s1);//真实值对应的显示值 + System.out.println("真实值为==================="+s1); + System.out.println("显示值为==================="+a1); + if(a1.equals(values[i])){ + realValues[i] = s1; + flag = false; + break; + } + } + } + }else { + for(String s1:strs){ + String a1 = lov.getListOfValues().getDisplayableValue(s1);//真实值对应的显示值 + System.out.println("真实值为==================="+s1); + System.out.println("显示值为==================="+a1); + if(a1.equals(value)){ + value=s1; //显示值改为真实值 + flag = false; + break; + } + } + } + if(flag){ + try { + StringBufferDemo("【失败】该显示值 +"+value+"没有对应的真实值"+"\n\r", + "历史数据导入对象"); + fail++; + + } catch (IOException e) { + e.printStackTrace(); + } + } + + } + + + boolean isArray = descriptor.isArray(); + if (!isArray) { + System.out.println("descriptor.getType()="+descriptor.getType()); + switch (descriptor.getType()) { + + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + System.out.println("对应的类型为字符串"); + logger.debug("对应的类型为字符串"); + property.setStringValue(value); + System.out.println("设置完成"); + break; + case TCProperty.PROP_char: + System.out.println("对应的类型为字符"); + logger.debug("对应的类型为字符"); + if (value.length() > 0) { + property.setCharValue(value.charAt(0)); + } + break; + case TCProperty.PROP_double: + System.out.println("对应的类型为double"); + logger.debug("对应的类型为double"); + if (value == null || value.trim().length() == 0) + property.setDoubleValue((Integer) null); + else + property.setDoubleValue(Double.parseDouble(value)); + break; + case TCProperty.PROP_float: + System.out.println("对应的类型为float"); + logger.debug("对应的类型为float"); + if (value == null || value.trim().length() == 0) + property.setFloatValueData((Integer) null); + else + property.setFloatValueData(Float.parseFloat(value)); + break; + case TCProperty.PROP_int: + case TCProperty.PROP_short: + System.out.println("对应的类型为int或者short"); + logger.debug("对应的类型为int或者short"); + if (value == null || value.trim().length() == 0) + property.setIntValue((Integer) null); + else + property.setIntValue(Integer.parseInt(value)); + break; + case TCProperty.PROP_logical: + System.out.println("对应的类型为Boolean"); + logger.debug("对应的类型为Boolean"); + property.setLogicalValue(Boolean.parseBoolean(value)); + break; + case TCProperty.PROP_date: + System.out.println("对应的类型为日期类型"); + logger.debug("对应的类型为日期类型"); + try { + property.setDateValue(new SimpleDateFormat() + .parse(value)); + } catch (ParseException e) { + logger.error( + "setTCProperty(TCProperty property, String value)", + e); + + e.printStackTrace(); + } + break; + } + } else { + property.setStringValueArray(realValues); + + //System.out.println("对应的属性为数组类型,不予以处理"); + } + + System.out + .println("setTCProperty(TCProperty property, String value) - end"); + } + + private TCComponentForm getItemRevisionMasterForm( + TCComponentItemRevision revision) throws TCException { + if (revision != null) { + AIFComponentContext[] contexts = revision + .getChildren("IMAN_master_form_rev"); + if (contexts != null && contexts.length > 0) { + InterfaceAIFComponent component = contexts[0].getComponent(); + if (component instanceof TCComponentForm) { + TCComponentForm form = (TCComponentForm) component; + + return form; + } + } + } + + return null; + } + + public void removeNRFiles(TCComponentDataset dataset, + String namedReference, TCComponentTcFile files[]) throws Exception { + + System.out + .println("--------------------开始删除文件操作------------------------"); + + try { + + TCComponent comps[] = dataset.getNamedRefComponents(namedReference); + if (comps != null && comps.length > 0) { + + for (int i = 0; i < comps.length; i++) + dataset.removeNamedReference(namedReference); + + } + for (int i = 0; i < files.length; i++) + if (files[i] != null) { + + try { + System.out.println("delete file " + files[i].getPath()); + files[i].delete(); + } catch (Exception e) { + e.printStackTrace(); + + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + + } + + public void importFilesOperation(TCComponentDataset dataset, File file, + String fileType, String refType) { + System.out + .println("-----------------------------开始进行文件的上传工作---------------------------"); + + String as[] = { file.getPath() }; + String as1[] = { fileType }; + String as2[] = { "Plain" }; + String as3[] = { refType }; + System.out.println("fileType:" + fileType); + System.out.println("file.getPath()&&&&&&&&&&&&&&&&&&& " + + file.getPath()); + try { + dataset.setFiles(as, as1, as2, as3); + } catch (TCException e) { + + e.printStackTrace(); + } + session.setReadyStatus(); + + } + + // 写日志 + public void StringBufferDemo(String strContext, String strFileName) + throws IOException { + // logpath = System.getProperty("java.io.tmpdir")+File.separator+ + // strFileName; + + logpath = System.getenv("TEMP") + "\\" + strFileName + "_" + systitem + + ".log"; + File file = new File(logpath); + if (!file.exists()) + file.createNewFile(); + FileOutputStream out = new FileOutputStream(file, true); + StringBuffer sb = new StringBuffer(strContext); + // System.out.println("日志:"+sb.toString()); + out.write(sb.toString().getBytes("gb2312")); + out.close(); + } + + // //删除日志 + // public void deleteLog(String strFileName) throws IOException { + // File file = new + // File(System.getProperty("java.io.tmpdir")+File.separator+"OriginTemp" + + // strFileName); + // if (file.exists()) + // file.delete(); + // } + + // java调C 开关bypass + public void setByPass(boolean val) throws TCException { + // if (userservice == null) { + // userservice = this.session.getUserService(); + // } + // Object[] obj = new Object[1]; + // obj[0] = "origin"; + // if (val) { + // userservice.call("ORIGIN_set_bypass", obj); + // } else { + // userservice.call("ORIGIN_close_bypass", obj); + // } + } + + public void sendItem() { + TCUserService service = this.session.getUserService(); + + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent comp = app.getTargetComponent(); + + try { + + if (StaticEnum.isExec) { + + comp = session.getUser().getNewStuffFolder(); + } + Object returnObj = service.call("SendItem", new Object[] { comp }); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public static void main(String[] args) { + String filePath = "C:\\11.txt||C:\\22.txt"; + String[] str = filePath.split("\\|\\|"); + System.out.println(str.length); + System.out.println(str[0]); + System.out.println(str[1]); + } +} diff --git a/src/com/connor/dev/imp/ImportSettings.java b/src/com/connor/dev/imp/ImportSettings.java new file mode 100644 index 0000000..1fd11ad --- /dev/null +++ b/src/com/connor/dev/imp/ImportSettings.java @@ -0,0 +1,110 @@ +package com.connor.dev.imp; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +public abstract class ImportSettings implements Serializable +{ + private static final long serialVersionUID = 1L; + + private boolean saved; + + private int columns; + + private String dateFormat; + + //private String arraySeparator; + + public boolean save(File file) + { + try + { + FileOutputStream fos = new FileOutputStream(file); + ObjectOutputStream oos = new ObjectOutputStream(fos); + oos.writeObject(this); + oos.flush(); + oos.close(); + + saved = true; + + return true; + } + catch (IOException ioe) + { + ioe.printStackTrace(); + } + + return false; + } + + public ImportSettings load(File file) + { + try + { + FileInputStream fis = new FileInputStream(file); + ObjectInputStream ois = new ObjectInputStream(fis); + Object o = ois.readObject(); + + ois.close(); + fis.close(); + + saved = false; + + if (o instanceof ImportSettings) + { + return (ImportSettings) o; + } + } + catch (Exception e) + { + e.printStackTrace(); + } + + return null; + } + + public void setSaved(boolean saved) + { + this.saved = saved; + } + + public boolean isSaved() + { + return saved; + } + + public void setColumns(int columns) + { + this.columns = columns; + } + + public int getColumns() + { + return columns; + } + + public String getDateFormat() + { + return dateFormat; + } + + public void setDateFormat(String dateFormat) + { + this.dateFormat = dateFormat; + } + + // public String getArraySeparator() + // { + // return arraySeparator; + // } + // + // public void setArraySeparator(String arraySeparator) + // { + // this.arraySeparator = arraySeparator; + // } +} diff --git a/src/com/connor/dev/imp/MappingAttribute.java b/src/com/connor/dev/imp/MappingAttribute.java new file mode 100644 index 0000000..31167f7 --- /dev/null +++ b/src/com/connor/dev/imp/MappingAttribute.java @@ -0,0 +1,69 @@ +package com.connor.dev.imp; + +import java.io.Serializable; + +public class MappingAttribute implements Serializable +{ + private static final long serialVersionUID = 1L; + + private int columnIndex; + + private String columnTitle; + + private String tcAttribute; + + public MappingAttribute(int columnIndex, String columnTitle, String tcAttribute) + { + this.columnIndex = columnIndex; + this.columnTitle = columnTitle; + this.tcAttribute = tcAttribute; + } + + public int getColumnIndex() + { + return columnIndex; + } + + public void setColumnIndex(int columnIndex) + { + this.columnIndex = columnIndex; + } + + public String getColumnTitle() + { + return columnTitle; + } + + public void setColumnTitle(String columnTitle) + { + this.columnTitle = columnTitle; + } + + public String getTcAttribute() + { + return tcAttribute; + } + + public void setTcAttribute(String tcAttribute) + { + this.tcAttribute = tcAttribute; + } + + public boolean equals(Object obj) + { + if (!(obj instanceof MappingAttribute)) + { + return false; + } + else + { + MappingAttribute at = (MappingAttribute) obj; + return tcAttribute.equals(at.tcAttribute); + } + } + + public String toString() + { + return "(" + columnIndex + ")" + columnTitle + " => " + tcAttribute; + } +} diff --git a/src/com/connor/dev/imp/bom/.svn/all-wcprops b/src/com/connor/dev/imp/bom/.svn/all-wcprops new file mode 100644 index 0000000..e9f3a1a --- /dev/null +++ b/src/com/connor/dev/imp/bom/.svn/all-wcprops @@ -0,0 +1,23 @@ +K 25 +svn:wc:ra_dav:version-url +V 96 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/bom +END +ImportBomsCommand.java +K 25 +svn:wc:ra_dav:version-url +V 119 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/bom/ImportBomsCommand.java +END +ImportBomsDialog.java +K 25 +svn:wc:ra_dav:version-url +V 118 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/bom/ImportBomsDialog.java +END +BomsImportSettings.java +K 25 +svn:wc:ra_dav:version-url +V 120 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/bom/BomsImportSettings.java +END diff --git a/src/com/connor/dev/imp/bom/.svn/entries b/src/com/connor/dev/imp/bom/.svn/entries new file mode 100644 index 0000000..6a79161 --- /dev/null +++ b/src/com/connor/dev/imp/bom/.svn/entries @@ -0,0 +1,130 @@ +10 + +dir +13 +http://192.168.0.254:8080/svn/dongfang/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/bom +http://192.168.0.254:8080/svn/dongfang + + + +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + +d5545a61-9634-c849-9c05-96e4e3e25a21 + +ImportBomsCommand.java +file + + + + +2011-07-06T04:02:28.578125Z +d5a2a8f2a4efc33cd7c051c0cdb2b42c +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + + + + + + + + +453 + +ImportBomsDialog.java +file + + + + +2011-07-06T04:02:28.578125Z +0a5081c13e06795672c60f9f994d8de6 +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + + + + + + + + +9344 + +BomsImportSettings.java +file + + + + +2011-07-06T04:02:28.578125Z +27ac2321957134d89a169ad2dc202072 +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + + + + + + + + +1527 + diff --git a/src/com/connor/dev/imp/bom/.svn/text-base/BomsImportSettings.java.svn-base b/src/com/connor/dev/imp/bom/.svn/text-base/BomsImportSettings.java.svn-base new file mode 100644 index 0000000..5a2e59f --- /dev/null +++ b/src/com/connor/dev/imp/bom/.svn/text-base/BomsImportSettings.java.svn-base @@ -0,0 +1,71 @@ +package com.origin.dev.imp.bom; + +import java.io.Serializable; + +import com.origin.dev.imp.ImportSettings; +import com.origin.dev.imp.MappingAttribute; + +public class BomsImportSettings extends ImportSettings implements Serializable +{ + private static final long serialVersionUID = 1L; + + private MappingAttribute parentMapping; + + private MappingAttribute parentRevMapping; + + private MappingAttribute childMapping; + + private MappingAttribute childRevMapping; + + private MappingAttribute[] bomLineMapping; + + public MappingAttribute getParentMapping() + { + return parentMapping; + } + + public void setParentMapping(MappingAttribute parentMapping) + { + this.parentMapping = parentMapping; + } + + public MappingAttribute getParentRevMapping() + { + return parentRevMapping; + } + + public void setParentRevMapping(MappingAttribute parentRevMapping) + { + this.parentRevMapping = parentRevMapping; + } + + public MappingAttribute getChildMapping() + { + return childMapping; + } + + public void setChildMapping(MappingAttribute childMapping) + { + this.childMapping = childMapping; + } + + public MappingAttribute getChildRevMapping() + { + return childRevMapping; + } + + public void setChildRevMapping(MappingAttribute childRevMapping) + { + this.childRevMapping = childRevMapping; + } + + public void setBomLineMapping(MappingAttribute[] bomLineMapping) + { + this.bomLineMapping = bomLineMapping; + } + + public MappingAttribute[] getBomLineMapping() + { + return bomLineMapping; + } +} diff --git a/src/com/connor/dev/imp/bom/.svn/text-base/ImportBomsCommand.java.svn-base b/src/com/connor/dev/imp/bom/.svn/text-base/ImportBomsCommand.java.svn-base new file mode 100644 index 0000000..4b427e3 --- /dev/null +++ b/src/com/connor/dev/imp/bom/.svn/text-base/ImportBomsCommand.java.svn-base @@ -0,0 +1,19 @@ +package com.origin.dev.imp.bom; + + +import com.origin.dev.imp.AbstractImportCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; + +public class ImportBomsCommand extends AbstractImportCommand +{ + public ImportBomsCommand(AbstractAIFUIApplication application) + { + super(application); + } + + protected void importHistoryDatas() + { + ImportBomsDialog dialog = new ImportBomsDialog(session, "导入BOM"); + setRunnable(dialog); + } +} diff --git a/src/com/connor/dev/imp/bom/.svn/text-base/ImportBomsDialog.java.svn-base b/src/com/connor/dev/imp/bom/.svn/text-base/ImportBomsDialog.java.svn-base new file mode 100644 index 0000000..0dffe23 --- /dev/null +++ b/src/com/connor/dev/imp/bom/.svn/text-base/ImportBomsDialog.java.svn-base @@ -0,0 +1,339 @@ +package com.origin.dev.imp.bom; + +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.swing.DefaultListModel; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; +import javax.swing.event.ChangeEvent; + +import com.origin.dev.imp.AbstractImportDialog; +import com.origin.dev.imp.ImportSettings; +import com.origin.dev.imp.MappingAttribute; +import com.origin.dev.imp.ob.MappingButton; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.MessageBox; + +public class ImportBomsDialog extends AbstractImportDialog +{ + private static final long serialVersionUID = 1L; + + private MappingButton parent; + + private MappingButton child; + + private MappingButton parentRev; + + private MappingButton childRev; + + public ImportBomsDialog(TCSession session, String title) + { + super(session, title, true); + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#initializeUI() + */ + protected void initializeUI() + { + super.initializeUI(); + + propertiesList = new JList[1]; + propertiesListModels = new DefaultListModel[1]; + mappingListModels = new DefaultListModel[1]; + mappingList = new JList[1]; + + for (int i = 0; i < propertiesList.length; i++) + { + propertiesListModels[i] = new DefaultListModel(); + propertiesList[i] = new JList(propertiesListModels[i]); + propertiesList[i].setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + propertiesList[i].setVisibleRowCount(20); + mappingListModels[i] = new DefaultListModel(); + mappingList[i] = new JList(mappingListModels[i]); + mappingList[i].setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + } + + parent = new MappingButton("Parent ID"); + child = new MappingButton("Child ID"); + parentRev = new MappingButton("Parent Revision ID"); + childRev = new MappingButton("Child Revision ID"); + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#registerActionComponents() + */ + protected void registerActionComponents() + { + super.registerActionComponents(); + + parent.addActionListener(this); + child.addActionListener(this); + parentRev.addActionListener(this); + childRev.addActionListener(this); + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#setComponentsTextProperty() + */ + protected void setComponentsTextProperty() + { + super.setComponentsTextProperty(); + + try + { + TCTypeService service = session.getTypeService(); + TCComponentType type = service.getTypeComponent("BOMLine"); + TCPropertyDescriptor descriptor[] = type.getPropertyDescriptors(); + List list = new ArrayList(); + for (int i = 0; i < descriptor.length; i++) + { + if (descriptor[i].isModifiable() && !descriptor[i].toString().equals("bl_pack_count")) + { + list.add(descriptor[i].getName()); + } + } + Collections.sort(list); + for (String str : list) + { + propertiesListModels[0].addElement(str); + } + } + catch (TCException te) + { + te.printStackTrace(); + } + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#addTabbedPaneComponents() + */ + protected void addTabbedPaneComponents() + { + String[] titles = new String[] { "BOMLine" }; + for (int i = 0; i < propertiesList.length; i++) + { + JPanel panel = new JPanel(new GridLayout()); + panel.add(new JScrollPane(propertiesList[i])); + panel.add(new JScrollPane(mappingList[i])); + rightPane.addTab(titles[i], panel); + } + + rightPane.addTab("参数", getParameterPanel()); + } + + /* + * (non-Javadoc) + * + * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) + */ + public void actionPerformed(ActionEvent ae) + { + if (ae.getSource() instanceof MappingButton) + { + assignMappingAttribute((MappingButton) ae.getSource()); + } + else if (ae.getSource() == unlock) + { + parent.setEnabled(true); + child.setEnabled(true); + parentRev.setEnabled(true); + childRev.setEnabled(true); + + super.actionPerformed(ae); + } + else + { + super.actionPerformed(ae); + } + } + + private void assignMappingAttribute(MappingButton button) + { + if (excelList.getSelectedIndex() == -1) + { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "请先在左边选择对应的一行数据再指定关系", "警告", 1); + + return; + } + + String excel = excelList.getSelectedValue().toString(); + int index = excelList.getSelectedIndex(); + + MappingAttribute ma = new MappingAttribute(index, excel, button.getPropertyName()); + button.setMappingAttribute(ma); + } + + /* + * (non-Javadoc) + * + * @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent) + */ + public void stateChanged(ChangeEvent changeevent) + { + int index = rightPane.getSelectedIndex(); + if (index > 0) + { + add.setEnabled(false); + remove.setEnabled(false); + } + else + { + checkMappingsEditable(); + } + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#openImportSettings() + */ + protected void openImportSettings() + { + if (chooser.showOpenDialog(null) == 0) + { + BomsImportSettings bis = new BomsImportSettings(); + ImportSettings is = bis.load(chooser.getSelectedFile()); + + if (is == null) + { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "从文件中加载配置失败.", "错误", 1); + return; + } + + if (is instanceof BomsImportSettings) + { + bis = (BomsImportSettings) is; + + // arraySepField.setText(bis.getArraySeparator()); + + for (int i = 0; i < mappingListModels.length; i++) + { + mappingListModels[i].removeAllElements(); + } + + for (int i = 0; i < bis.getBomLineMapping().length; i++) + { + mappingListModels[0].addElement(bis.getBomLineMapping()[i]); + } + + parent.setMappingAttribute(bis.getParentMapping()); + child.setMappingAttribute(bis.getChildMapping()); + parentRev.setMappingAttribute(bis.getParentRevMapping()); + childRev.setMappingAttribute(bis.getChildRevMapping()); + + excelList.setEnabled(false); + for (int i = 0; i < propertiesList.length; i++) + { + propertiesList[i].setEnabled(false); + mappingList[i].setEnabled(false); + } + + parent.setEnabled(false); + child.setEnabled(false); + parentRev.setEnabled(false); + childRev.setEnabled(false); + } + } + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#saveImportSettings() + */ + protected void saveImportSettings() + { + BomsImportSettings bis = generateImportSettings(); + + if (chooser.showSaveDialog(null) == 0) + { + try + { + FileOutputStream fileoutputstream = new FileOutputStream(chooser.getSelectedFile()); + ObjectOutputStream objectoutputstream = new ObjectOutputStream(fileoutputstream); + objectoutputstream.writeObject(bis); + objectoutputstream.flush(); + objectoutputstream.close(); + } + catch (IOException ioe) + { + ioe.printStackTrace(); + } + + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "配置已经被成功保存在\n" + + chooser.getSelectedFile().getAbsolutePath(), "成功", 0); + } + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#generateImportSettings() + */ + public BomsImportSettings generateImportSettings() + { + BomsImportSettings bis = new BomsImportSettings(); + + MappingAttribute[] itemMapping = new MappingAttribute[mappingListModels[0].size()]; + System.arraycopy(mappingListModels[0].toArray(), 0, itemMapping, 0, itemMapping.length); + bis.setBomLineMapping(itemMapping); + + bis.setChildMapping(child.getMappingAttribute()); + bis.setChildRevMapping(childRev.getMappingAttribute()); + bis.setParentMapping(parent.getMappingAttribute()); + bis.setParentRevMapping(parentRev.getMappingAttribute()); + + bis.setColumns(excelList.getModel().getSize()); + + // bis.setArraySeparator(arraySepField.getText().trim()); + bis.setDateFormat(dateFormatField.getText().trim()); + + return bis; + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#getParameterPanel() + */ + protected JPanel getParameterPanel() + { + JPanel p = super.getParameterPanel(); + + p.add("2.1.right.top.preferred.preferred", new JLabel("Parent ID :")); + p.add("2.2.left.top.preferred.preferred", parent); + p.add("3.1.right.top.preferred.preferred", new JLabel("Parent Revision ID :")); + p.add("3.2.left.top.preferred.preferred", parentRev); + + p.add("4.1.right.top.preferred.preferred", new JLabel("Child ID :")); + p.add("4.2.left.top.preferred.preferred", child); + p.add("5.1.right.top.preferred.preferred", new JLabel("Child Revision ID :")); + p.add("5.2.left.top.preferred.preferred", childRev); + + return p; + } +} diff --git a/src/com/connor/dev/imp/bom/BomsImportSettings.java b/src/com/connor/dev/imp/bom/BomsImportSettings.java new file mode 100644 index 0000000..782cd02 --- /dev/null +++ b/src/com/connor/dev/imp/bom/BomsImportSettings.java @@ -0,0 +1,71 @@ +package com.connor.dev.imp.bom; + +import java.io.Serializable; + +import com.connor.dev.imp.ImportSettings; +import com.connor.dev.imp.MappingAttribute; + +public class BomsImportSettings extends ImportSettings implements Serializable +{ + private static final long serialVersionUID = 1L; + + private MappingAttribute parentMapping; + + private MappingAttribute parentRevMapping; + + private MappingAttribute childMapping; + + private MappingAttribute childRevMapping; + + private MappingAttribute[] bomLineMapping; + + public MappingAttribute getParentMapping() + { + return parentMapping; + } + + public void setParentMapping(MappingAttribute parentMapping) + { + this.parentMapping = parentMapping; + } + + public MappingAttribute getParentRevMapping() + { + return parentRevMapping; + } + + public void setParentRevMapping(MappingAttribute parentRevMapping) + { + this.parentRevMapping = parentRevMapping; + } + + public MappingAttribute getChildMapping() + { + return childMapping; + } + + public void setChildMapping(MappingAttribute childMapping) + { + this.childMapping = childMapping; + } + + public MappingAttribute getChildRevMapping() + { + return childRevMapping; + } + + public void setChildRevMapping(MappingAttribute childRevMapping) + { + this.childRevMapping = childRevMapping; + } + + public void setBomLineMapping(MappingAttribute[] bomLineMapping) + { + this.bomLineMapping = bomLineMapping; + } + + public MappingAttribute[] getBomLineMapping() + { + return bomLineMapping; + } +} diff --git a/src/com/connor/dev/imp/bom/ImportBomsCommand.java b/src/com/connor/dev/imp/bom/ImportBomsCommand.java new file mode 100644 index 0000000..dc832a3 --- /dev/null +++ b/src/com/connor/dev/imp/bom/ImportBomsCommand.java @@ -0,0 +1,20 @@ +package com.connor.dev.imp.bom; + + +import com.connor.dev.imp.AbstractImportCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; + +public class ImportBomsCommand extends AbstractImportCommand +{ + public ImportBomsCommand(AbstractAIFUIApplication application) + { + super(application); + } + + + protected void importHistoryDatas() + { + ImportBomsDialog dialog = new ImportBomsDialog(session, "导入BOM"); + setRunnable(dialog); + } +} diff --git a/src/com/connor/dev/imp/bom/ImportBomsDialog.java b/src/com/connor/dev/imp/bom/ImportBomsDialog.java new file mode 100644 index 0000000..a9f4537 --- /dev/null +++ b/src/com/connor/dev/imp/bom/ImportBomsDialog.java @@ -0,0 +1,339 @@ +package com.connor.dev.imp.bom; + +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.swing.DefaultListModel; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; +import javax.swing.event.ChangeEvent; + +import com.connor.dev.imp.AbstractImportDialog; +import com.connor.dev.imp.ImportSettings; +import com.connor.dev.imp.MappingAttribute; +import com.connor.dev.imp.ob.MappingButton; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.MessageBox; + +public class ImportBomsDialog extends AbstractImportDialog +{ + private static final long serialVersionUID = 1L; + + private MappingButton parent; + + private MappingButton child; + + private MappingButton parentRev; + + private MappingButton childRev; + + public ImportBomsDialog(TCSession session, String title) + { + super(session, title, true); + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#initializeUI() + */ + protected void initializeUI() + { + super.initializeUI(); + + propertiesList = new JList[1]; + propertiesListModels = new DefaultListModel[1]; + mappingListModels = new DefaultListModel[1]; + mappingList = new JList[1]; + + for (int i = 0; i < propertiesList.length; i++) + { + propertiesListModels[i] = new DefaultListModel(); + propertiesList[i] = new JList(propertiesListModels[i]); + propertiesList[i].setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + propertiesList[i].setVisibleRowCount(20); + mappingListModels[i] = new DefaultListModel(); + mappingList[i] = new JList(mappingListModels[i]); + mappingList[i].setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + } + + parent = new MappingButton("Parent ID"); + child = new MappingButton("Child ID"); + parentRev = new MappingButton("Parent Revision ID"); + childRev = new MappingButton("Child Revision ID"); + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#registerActionComponents() + */ + protected void registerActionComponents() + { + super.registerActionComponents(); + + parent.addActionListener(this); + child.addActionListener(this); + parentRev.addActionListener(this); + childRev.addActionListener(this); + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#setComponentsTextProperty() + */ + protected void setComponentsTextProperty() + { + super.setComponentsTextProperty(); + + try + { + TCTypeService service = session.getTypeService(); + TCComponentType type = service.getTypeComponent("BOMLine"); + TCPropertyDescriptor descriptor[] = type.getPropertyDescriptors(); + List list = new ArrayList(); + for (int i = 0; i < descriptor.length; i++) + { + if (descriptor[i].isModifiable() && !descriptor[i].toString().equals("bl_pack_count")) + { + list.add(descriptor[i].getName()); + } + } + Collections.sort(list); + for (String str : list) + { + propertiesListModels[0].addElement(str); + } + } + catch (TCException te) + { + te.printStackTrace(); + } + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#addTabbedPaneComponents() + */ + protected void addTabbedPaneComponents() + { + String[] titles = new String[] { "BOMLine" }; + for (int i = 0; i < propertiesList.length; i++) + { + JPanel panel = new JPanel(new GridLayout()); + panel.add(new JScrollPane(propertiesList[i])); + panel.add(new JScrollPane(mappingList[i])); + rightPane.addTab(titles[i], panel); + } + + rightPane.addTab("参数", getParameterPanel()); + } + + /* + * (non-Javadoc) + * + * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) + */ + public void actionPerformed(ActionEvent ae) + { + if (ae.getSource() instanceof MappingButton) + { + assignMappingAttribute((MappingButton) ae.getSource()); + } + else if (ae.getSource() == unlock) + { + parent.setEnabled(true); + child.setEnabled(true); + parentRev.setEnabled(true); + childRev.setEnabled(true); + + super.actionPerformed(ae); + } + else + { + super.actionPerformed(ae); + } + } + + private void assignMappingAttribute(MappingButton button) + { + if (excelList.getSelectedIndex() == -1) + { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "请先在左边选择对应的一行数据再指定关系", "警告", 1); + + return; + } + + String excel = excelList.getSelectedValue().toString(); + int index = excelList.getSelectedIndex(); + + MappingAttribute ma = new MappingAttribute(index, excel, button.getPropertyName()); + button.setMappingAttribute(ma); + } + + /* + * (non-Javadoc) + * + * @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent) + */ + public void stateChanged(ChangeEvent changeevent) + { + int index = rightPane.getSelectedIndex(); + if (index > 0) + { + add.setEnabled(false); + remove.setEnabled(false); + } + else + { + checkMappingsEditable(); + } + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#openImportSettings() + */ + protected void openImportSettings() + { + if (chooser.showOpenDialog(null) == 0) + { + BomsImportSettings bis = new BomsImportSettings(); + ImportSettings is = bis.load(chooser.getSelectedFile()); + + if (is == null) + { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "从文件中加载配置失败.", "错误", 1); + return; + } + + if (is instanceof BomsImportSettings) + { + bis = (BomsImportSettings) is; + + // arraySepField.setText(bis.getArraySeparator()); + + for (int i = 0; i < mappingListModels.length; i++) + { + mappingListModels[i].removeAllElements(); + } + + for (int i = 0; i < bis.getBomLineMapping().length; i++) + { + mappingListModels[0].addElement(bis.getBomLineMapping()[i]); + } + + parent.setMappingAttribute(bis.getParentMapping()); + child.setMappingAttribute(bis.getChildMapping()); + parentRev.setMappingAttribute(bis.getParentRevMapping()); + childRev.setMappingAttribute(bis.getChildRevMapping()); + + excelList.setEnabled(false); + for (int i = 0; i < propertiesList.length; i++) + { + propertiesList[i].setEnabled(false); + mappingList[i].setEnabled(false); + } + + parent.setEnabled(false); + child.setEnabled(false); + parentRev.setEnabled(false); + childRev.setEnabled(false); + } + } + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#saveImportSettings() + */ + protected void saveImportSettings() + { + BomsImportSettings bis = generateImportSettings(); + + if (chooser.showSaveDialog(null) == 0) + { + try + { + FileOutputStream fileoutputstream = new FileOutputStream(chooser.getSelectedFile()); + ObjectOutputStream objectoutputstream = new ObjectOutputStream(fileoutputstream); + objectoutputstream.writeObject(bis); + objectoutputstream.flush(); + objectoutputstream.close(); + } + catch (IOException ioe) + { + ioe.printStackTrace(); + } + + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "配置已经被成功保存在\n" + + chooser.getSelectedFile().getAbsolutePath(), "成功", 2); + } + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#generateImportSettings() + */ + public BomsImportSettings generateImportSettings() + { + BomsImportSettings bis = new BomsImportSettings(); + + MappingAttribute[] itemMapping = new MappingAttribute[mappingListModels[0].size()]; + System.arraycopy(mappingListModels[0].toArray(), 0, itemMapping, 0, itemMapping.length); + bis.setBomLineMapping(itemMapping); + + bis.setChildMapping(child.getMappingAttribute()); + bis.setChildRevMapping(childRev.getMappingAttribute()); + bis.setParentMapping(parent.getMappingAttribute()); + bis.setParentRevMapping(parentRev.getMappingAttribute()); + + bis.setColumns(excelList.getModel().getSize()); + + // bis.setArraySeparator(arraySepField.getText().trim()); + bis.setDateFormat(dateFormatField.getText().trim()); + + return bis; + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#getParameterPanel() + */ + protected JPanel getParameterPanel() + { + JPanel p = super.getParameterPanel(); + + p.add("2.1.right.top.preferred.preferred", new JLabel("Parent ID :")); + p.add("2.2.left.top.preferred.preferred", parent); + p.add("3.1.right.top.preferred.preferred", new JLabel("Parent Revision ID :")); + p.add("3.2.left.top.preferred.preferred", parentRev); + + p.add("4.1.right.top.preferred.preferred", new JLabel("Child ID :")); + p.add("4.2.left.top.preferred.preferred", child); + p.add("5.1.right.top.preferred.preferred", new JLabel("Child Revision ID :")); + p.add("5.2.left.top.preferred.preferred", childRev); + + return p; + } +} diff --git a/src/com/connor/dev/imp/images/.svn/all-wcprops b/src/com/connor/dev/imp/images/.svn/all-wcprops new file mode 100644 index 0000000..844de27 --- /dev/null +++ b/src/com/connor/dev/imp/images/.svn/all-wcprops @@ -0,0 +1,101 @@ +K 25 +svn:wc:ra_dav:version-url +V 99 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/images +END +add_16.png +K 25 +svn:wc:ra_dav:version-url +V 110 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/images/add_16.png +END +remove_16.png +K 25 +svn:wc:ra_dav:version-url +V 113 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/images/remove_16.png +END +save_16.png +K 25 +svn:wc:ra_dav:version-url +V 111 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/images/save_16.png +END +refresh_16.png +K 25 +svn:wc:ra_dav:version-url +V 114 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/images/refresh_16.png +END +excel_16.png +K 25 +svn:wc:ra_dav:version-url +V 112 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/images/excel_16.png +END +open_16.png +K 25 +svn:wc:ra_dav:version-url +V 111 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/images/open_16.png +END +add.gif +K 25 +svn:wc:ra_dav:version-url +V 107 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/images/add.gif +END +remove.gif +K 25 +svn:wc:ra_dav:version-url +V 110 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/images/remove.gif +END +save.gif +K 25 +svn:wc:ra_dav:version-url +V 108 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/images/save.gif +END +refresh.GIF +K 25 +svn:wc:ra_dav:version-url +V 111 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/images/refresh.GIF +END +import_16.png +K 25 +svn:wc:ra_dav:version-url +V 113 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/images/import_16.png +END +yes.gif +K 25 +svn:wc:ra_dav:version-url +V 107 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/images/yes.gif +END +open.gif +K 25 +svn:wc:ra_dav:version-url +V 108 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/images/open.gif +END +cancel_all_16.png +K 25 +svn:wc:ra_dav:version-url +V 117 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/images/cancel_all_16.png +END +cancel_16.png +K 25 +svn:wc:ra_dav:version-url +V 113 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/images/cancel_16.png +END +apply_16.png +K 25 +svn:wc:ra_dav:version-url +V 112 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/images/apply_16.png +END diff --git a/src/com/connor/dev/imp/images/.svn/entries b/src/com/connor/dev/imp/images/.svn/entries new file mode 100644 index 0000000..47d19d9 --- /dev/null +++ b/src/com/connor/dev/imp/images/.svn/entries @@ -0,0 +1,572 @@ +10 + +dir +13 +http://192.168.0.254:8080/svn/dongfang/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/images +http://192.168.0.254:8080/svn/dongfang + + + +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + +d5545a61-9634-c849-9c05-96e4e3e25a21 + +add_16.png +file + + + + +2011-07-06T04:02:28.546875Z +cd48f1d4419e794055506ef2a4bc6cfc +2011-11-09T09:34:29.065079Z +13 +liqz +has-props + + + + + + + + + + + + + + + + + + + + +332 + +remove_16.png +file + + + + +2011-07-06T04:02:28.562500Z +19fae2151c45e42d555a1a5b4c8b1ee4 +2011-11-09T09:34:29.065079Z +13 +liqz +has-props + + + + + + + + + + + + + + + + + + + + +230 + +save_16.png +file + + + + +2011-07-06T04:02:28.562500Z +2ee52fc43f55cb4b3792217b87af5728 +2011-11-09T09:34:29.065079Z +13 +liqz +has-props + + + + + + + + + + + + + + + + + + + + +769 + +refresh_16.png +file + + + + +2011-07-06T04:02:28.562500Z +b6de699fdb05d0ec803665fb52515b03 +2011-11-09T09:34:29.065079Z +13 +liqz +has-props + + + + + + + + + + + + + + + + + + + + +759 + +excel_16.png +file + + + + +2011-07-06T04:02:28.546875Z +fbccecb1c8c961af0855305a6b9c4400 +2011-11-09T09:34:29.065079Z +13 +liqz +has-props + + + + + + + + + + + + + + + + + + + + +703 + +open_16.png +file + + + + +2011-07-06T04:02:28.546875Z +ee660cae1a2b9020fc5213636c0fcf89 +2011-11-09T09:34:29.065079Z +13 +liqz +has-props + + + + + + + + + + + + + + + + + + + + +969 + +add.gif +file + + + + +2011-07-06T04:02:28.546875Z +0a0759b7ca726a2be41a1fc1f57ef34a +2011-11-09T09:34:29.065079Z +13 +liqz +has-props + + + + + + + + + + + + + + + + + + + + +866 + +remove.gif +file + + + + +2011-07-06T04:02:28.562500Z +8a00b2ec135b0d1facc313883f1616d6 +2011-11-09T09:34:29.065079Z +13 +liqz +has-props + + + + + + + + + + + + + + + + + + + + +848 + +save.gif +file + + + + +2011-07-06T04:02:28.562500Z +2f82dcb4c8976ba0f9f22efd64aa2345 +2011-11-09T09:34:29.065079Z +13 +liqz +has-props + + + + + + + + + + + + + + + + + + + + +138 + +refresh.GIF +file + + + + +2011-07-06T04:02:28.562500Z +a5b39da41f80d2be562bdc764d148fc5 +2011-11-09T09:34:29.065079Z +13 +liqz +has-props + + + + + + + + + + + + + + + + + + + + +142 + +import_16.png +file + + + + +2011-07-06T04:02:28.546875Z +c5ba3ebd1bec98d0199405b7febd4012 +2011-11-09T09:34:29.065079Z +13 +liqz +has-props + + + + + + + + + + + + + + + + + + + + +762 + +yes.gif +file + + + + +2011-07-06T04:02:28.562500Z +f954adcb3dec79f7f226f9ee1464ea29 +2011-11-09T09:34:29.065079Z +13 +liqz +has-props + + + + + + + + + + + + + + + + + + + + +849 + +open.gif +file + + + + +2011-07-06T04:02:28.546875Z +ca92d56bd82033ea1e80cdd46bc5dd7a +2011-11-09T09:34:29.065079Z +13 +liqz +has-props + + + + + + + + + + + + + + + + + + + + +138 + +cancel_all_16.png +file + + + + +2011-07-06T04:02:28.546875Z +4e0de730d44f6f580912a98aa30d8f0c +2011-11-09T09:34:29.065079Z +13 +liqz +has-props + + + + + + + + + + + + + + + + + + + + +3084 + +apply_16.png +file + + + + +2011-07-06T04:02:28.546875Z +560bffa047a3eec78879a4522c72fd1f +2011-11-09T09:34:29.065079Z +13 +liqz +has-props + + + + + + + + + + + + + + + + + + + + +587 + +cancel_16.png +file + + + + +2011-07-06T04:02:28.546875Z +213b061640b4c4919943b35e7c8d1a11 +2011-11-09T09:34:29.065079Z +13 +liqz +has-props + + + + + + + + + + + + + + + + + + + + +396 + diff --git a/src/com/connor/dev/imp/images/.svn/prop-base/add.gif.svn-base b/src/com/connor/dev/imp/images/.svn/prop-base/add.gif.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/com/connor/dev/imp/images/.svn/prop-base/add.gif.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/com/connor/dev/imp/images/.svn/prop-base/add_16.png.svn-base b/src/com/connor/dev/imp/images/.svn/prop-base/add_16.png.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/com/connor/dev/imp/images/.svn/prop-base/add_16.png.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/com/connor/dev/imp/images/.svn/prop-base/apply_16.png.svn-base b/src/com/connor/dev/imp/images/.svn/prop-base/apply_16.png.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/com/connor/dev/imp/images/.svn/prop-base/apply_16.png.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/com/connor/dev/imp/images/.svn/prop-base/cancel_16.png.svn-base b/src/com/connor/dev/imp/images/.svn/prop-base/cancel_16.png.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/com/connor/dev/imp/images/.svn/prop-base/cancel_16.png.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/com/connor/dev/imp/images/.svn/prop-base/cancel_all_16.png.svn-base b/src/com/connor/dev/imp/images/.svn/prop-base/cancel_all_16.png.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/com/connor/dev/imp/images/.svn/prop-base/cancel_all_16.png.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/com/connor/dev/imp/images/.svn/prop-base/excel_16.png.svn-base b/src/com/connor/dev/imp/images/.svn/prop-base/excel_16.png.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/com/connor/dev/imp/images/.svn/prop-base/excel_16.png.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/com/connor/dev/imp/images/.svn/prop-base/import_16.png.svn-base b/src/com/connor/dev/imp/images/.svn/prop-base/import_16.png.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/com/connor/dev/imp/images/.svn/prop-base/import_16.png.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/com/connor/dev/imp/images/.svn/prop-base/open.gif.svn-base b/src/com/connor/dev/imp/images/.svn/prop-base/open.gif.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/com/connor/dev/imp/images/.svn/prop-base/open.gif.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/com/connor/dev/imp/images/.svn/prop-base/open_16.png.svn-base b/src/com/connor/dev/imp/images/.svn/prop-base/open_16.png.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/com/connor/dev/imp/images/.svn/prop-base/open_16.png.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/com/connor/dev/imp/images/.svn/prop-base/refresh.GIF.svn-base b/src/com/connor/dev/imp/images/.svn/prop-base/refresh.GIF.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/com/connor/dev/imp/images/.svn/prop-base/refresh.GIF.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/com/connor/dev/imp/images/.svn/prop-base/refresh_16.png.svn-base b/src/com/connor/dev/imp/images/.svn/prop-base/refresh_16.png.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/com/connor/dev/imp/images/.svn/prop-base/refresh_16.png.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/com/connor/dev/imp/images/.svn/prop-base/remove.gif.svn-base b/src/com/connor/dev/imp/images/.svn/prop-base/remove.gif.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/com/connor/dev/imp/images/.svn/prop-base/remove.gif.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/com/connor/dev/imp/images/.svn/prop-base/remove_16.png.svn-base b/src/com/connor/dev/imp/images/.svn/prop-base/remove_16.png.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/com/connor/dev/imp/images/.svn/prop-base/remove_16.png.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/com/connor/dev/imp/images/.svn/prop-base/save.gif.svn-base b/src/com/connor/dev/imp/images/.svn/prop-base/save.gif.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/com/connor/dev/imp/images/.svn/prop-base/save.gif.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/com/connor/dev/imp/images/.svn/prop-base/save_16.png.svn-base b/src/com/connor/dev/imp/images/.svn/prop-base/save_16.png.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/com/connor/dev/imp/images/.svn/prop-base/save_16.png.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/com/connor/dev/imp/images/.svn/prop-base/yes.gif.svn-base b/src/com/connor/dev/imp/images/.svn/prop-base/yes.gif.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/com/connor/dev/imp/images/.svn/prop-base/yes.gif.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/com/connor/dev/imp/images/.svn/text-base/add.gif.svn-base b/src/com/connor/dev/imp/images/.svn/text-base/add.gif.svn-base new file mode 100644 index 0000000..d66053c Binary files /dev/null and b/src/com/connor/dev/imp/images/.svn/text-base/add.gif.svn-base differ diff --git a/src/com/connor/dev/imp/images/.svn/text-base/add_16.png.svn-base b/src/com/connor/dev/imp/images/.svn/text-base/add_16.png.svn-base new file mode 100644 index 0000000..bc58bd7 Binary files /dev/null and b/src/com/connor/dev/imp/images/.svn/text-base/add_16.png.svn-base differ diff --git a/src/com/connor/dev/imp/images/.svn/text-base/apply_16.png.svn-base b/src/com/connor/dev/imp/images/.svn/text-base/apply_16.png.svn-base new file mode 100644 index 0000000..19f71f8 Binary files /dev/null and b/src/com/connor/dev/imp/images/.svn/text-base/apply_16.png.svn-base differ diff --git a/src/com/connor/dev/imp/images/.svn/text-base/cancel_16.png.svn-base b/src/com/connor/dev/imp/images/.svn/text-base/cancel_16.png.svn-base new file mode 100644 index 0000000..7186b3d Binary files /dev/null and b/src/com/connor/dev/imp/images/.svn/text-base/cancel_16.png.svn-base differ diff --git a/src/com/connor/dev/imp/images/.svn/text-base/cancel_all_16.png.svn-base b/src/com/connor/dev/imp/images/.svn/text-base/cancel_all_16.png.svn-base new file mode 100644 index 0000000..b43470e Binary files /dev/null and b/src/com/connor/dev/imp/images/.svn/text-base/cancel_all_16.png.svn-base differ diff --git a/src/com/connor/dev/imp/images/.svn/text-base/excel_16.png.svn-base b/src/com/connor/dev/imp/images/.svn/text-base/excel_16.png.svn-base new file mode 100644 index 0000000..f2d45cc Binary files /dev/null and b/src/com/connor/dev/imp/images/.svn/text-base/excel_16.png.svn-base differ diff --git a/src/com/connor/dev/imp/images/.svn/text-base/import_16.png.svn-base b/src/com/connor/dev/imp/images/.svn/text-base/import_16.png.svn-base new file mode 100644 index 0000000..9bc3b90 Binary files /dev/null and b/src/com/connor/dev/imp/images/.svn/text-base/import_16.png.svn-base differ diff --git a/src/com/connor/dev/imp/images/.svn/text-base/open.gif.svn-base b/src/com/connor/dev/imp/images/.svn/text-base/open.gif.svn-base new file mode 100644 index 0000000..7a1658c Binary files /dev/null and b/src/com/connor/dev/imp/images/.svn/text-base/open.gif.svn-base differ diff --git a/src/com/connor/dev/imp/images/.svn/text-base/open_16.png.svn-base b/src/com/connor/dev/imp/images/.svn/text-base/open_16.png.svn-base new file mode 100644 index 0000000..79f8d61 Binary files /dev/null and b/src/com/connor/dev/imp/images/.svn/text-base/open_16.png.svn-base differ diff --git a/src/com/connor/dev/imp/images/.svn/text-base/refresh.GIF.svn-base b/src/com/connor/dev/imp/images/.svn/text-base/refresh.GIF.svn-base new file mode 100644 index 0000000..7df56bb Binary files /dev/null and b/src/com/connor/dev/imp/images/.svn/text-base/refresh.GIF.svn-base differ diff --git a/src/com/connor/dev/imp/images/.svn/text-base/refresh_16.png.svn-base b/src/com/connor/dev/imp/images/.svn/text-base/refresh_16.png.svn-base new file mode 100644 index 0000000..e2798c0 Binary files /dev/null and b/src/com/connor/dev/imp/images/.svn/text-base/refresh_16.png.svn-base differ diff --git a/src/com/connor/dev/imp/images/.svn/text-base/remove.gif.svn-base b/src/com/connor/dev/imp/images/.svn/text-base/remove.gif.svn-base new file mode 100644 index 0000000..e0ced49 Binary files /dev/null and b/src/com/connor/dev/imp/images/.svn/text-base/remove.gif.svn-base differ diff --git a/src/com/connor/dev/imp/images/.svn/text-base/remove_16.png.svn-base b/src/com/connor/dev/imp/images/.svn/text-base/remove_16.png.svn-base new file mode 100644 index 0000000..4ff8845 Binary files /dev/null and b/src/com/connor/dev/imp/images/.svn/text-base/remove_16.png.svn-base differ diff --git a/src/com/connor/dev/imp/images/.svn/text-base/save.gif.svn-base b/src/com/connor/dev/imp/images/.svn/text-base/save.gif.svn-base new file mode 100644 index 0000000..e6ff1c4 Binary files /dev/null and b/src/com/connor/dev/imp/images/.svn/text-base/save.gif.svn-base differ diff --git a/src/com/connor/dev/imp/images/.svn/text-base/save_16.png.svn-base b/src/com/connor/dev/imp/images/.svn/text-base/save_16.png.svn-base new file mode 100644 index 0000000..57e15d9 Binary files /dev/null and b/src/com/connor/dev/imp/images/.svn/text-base/save_16.png.svn-base differ diff --git a/src/com/connor/dev/imp/images/.svn/text-base/yes.gif.svn-base b/src/com/connor/dev/imp/images/.svn/text-base/yes.gif.svn-base new file mode 100644 index 0000000..e6ee93d Binary files /dev/null and b/src/com/connor/dev/imp/images/.svn/text-base/yes.gif.svn-base differ diff --git a/src/com/connor/dev/imp/images/add.gif b/src/com/connor/dev/imp/images/add.gif new file mode 100644 index 0000000..d66053c Binary files /dev/null and b/src/com/connor/dev/imp/images/add.gif differ diff --git a/src/com/connor/dev/imp/images/add_16.png b/src/com/connor/dev/imp/images/add_16.png new file mode 100644 index 0000000..bc58bd7 Binary files /dev/null and b/src/com/connor/dev/imp/images/add_16.png differ diff --git a/src/com/connor/dev/imp/images/apply_16.png b/src/com/connor/dev/imp/images/apply_16.png new file mode 100644 index 0000000..19f71f8 Binary files /dev/null and b/src/com/connor/dev/imp/images/apply_16.png differ diff --git a/src/com/connor/dev/imp/images/cancel_16.png b/src/com/connor/dev/imp/images/cancel_16.png new file mode 100644 index 0000000..7186b3d Binary files /dev/null and b/src/com/connor/dev/imp/images/cancel_16.png differ diff --git a/src/com/connor/dev/imp/images/cancel_all_16.png b/src/com/connor/dev/imp/images/cancel_all_16.png new file mode 100644 index 0000000..b43470e Binary files /dev/null and b/src/com/connor/dev/imp/images/cancel_all_16.png differ diff --git a/src/com/connor/dev/imp/images/excel_16.png b/src/com/connor/dev/imp/images/excel_16.png new file mode 100644 index 0000000..f2d45cc Binary files /dev/null and b/src/com/connor/dev/imp/images/excel_16.png differ diff --git a/src/com/connor/dev/imp/images/import_16.png b/src/com/connor/dev/imp/images/import_16.png new file mode 100644 index 0000000..9bc3b90 Binary files /dev/null and b/src/com/connor/dev/imp/images/import_16.png differ diff --git a/src/com/connor/dev/imp/images/open.gif b/src/com/connor/dev/imp/images/open.gif new file mode 100644 index 0000000..7a1658c Binary files /dev/null and b/src/com/connor/dev/imp/images/open.gif differ diff --git a/src/com/connor/dev/imp/images/open_16.png b/src/com/connor/dev/imp/images/open_16.png new file mode 100644 index 0000000..79f8d61 Binary files /dev/null and b/src/com/connor/dev/imp/images/open_16.png differ diff --git a/src/com/connor/dev/imp/images/refresh.GIF b/src/com/connor/dev/imp/images/refresh.GIF new file mode 100644 index 0000000..7df56bb Binary files /dev/null and b/src/com/connor/dev/imp/images/refresh.GIF differ diff --git a/src/com/connor/dev/imp/images/refresh_16.png b/src/com/connor/dev/imp/images/refresh_16.png new file mode 100644 index 0000000..e2798c0 Binary files /dev/null and b/src/com/connor/dev/imp/images/refresh_16.png differ diff --git a/src/com/connor/dev/imp/images/remove.gif b/src/com/connor/dev/imp/images/remove.gif new file mode 100644 index 0000000..e0ced49 Binary files /dev/null and b/src/com/connor/dev/imp/images/remove.gif differ diff --git a/src/com/connor/dev/imp/images/remove_16.png b/src/com/connor/dev/imp/images/remove_16.png new file mode 100644 index 0000000..4ff8845 Binary files /dev/null and b/src/com/connor/dev/imp/images/remove_16.png differ diff --git a/src/com/connor/dev/imp/images/save.gif b/src/com/connor/dev/imp/images/save.gif new file mode 100644 index 0000000..e6ff1c4 Binary files /dev/null and b/src/com/connor/dev/imp/images/save.gif differ diff --git a/src/com/connor/dev/imp/images/save_16.png b/src/com/connor/dev/imp/images/save_16.png new file mode 100644 index 0000000..57e15d9 Binary files /dev/null and b/src/com/connor/dev/imp/images/save_16.png differ diff --git a/src/com/connor/dev/imp/images/yes.gif b/src/com/connor/dev/imp/images/yes.gif new file mode 100644 index 0000000..e6ee93d Binary files /dev/null and b/src/com/connor/dev/imp/images/yes.gif differ diff --git a/src/com/connor/dev/imp/ob/.svn/all-wcprops b/src/com/connor/dev/imp/ob/.svn/all-wcprops new file mode 100644 index 0000000..cd0ddb5 --- /dev/null +++ b/src/com/connor/dev/imp/ob/.svn/all-wcprops @@ -0,0 +1,29 @@ +K 25 +svn:wc:ra_dav:version-url +V 95 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/ob +END +ImportObjectsCommand.java +K 25 +svn:wc:ra_dav:version-url +V 121 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/ob/ImportObjectsCommand.java +END +ImportObjectsDialog.java +K 25 +svn:wc:ra_dav:version-url +V 120 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/ob/ImportObjectsDialog.java +END +ObjectsImportSettings.java +K 25 +svn:wc:ra_dav:version-url +V 122 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/ob/ObjectsImportSettings.java +END +MappingButton.java +K 25 +svn:wc:ra_dav:version-url +V 114 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/ob/MappingButton.java +END diff --git a/src/com/connor/dev/imp/ob/.svn/entries b/src/com/connor/dev/imp/ob/.svn/entries new file mode 100644 index 0000000..08173c4 --- /dev/null +++ b/src/com/connor/dev/imp/ob/.svn/entries @@ -0,0 +1,164 @@ +10 + +dir +13 +http://192.168.0.254:8080/svn/dongfang/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/ob +http://192.168.0.254:8080/svn/dongfang + + + +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + +d5545a61-9634-c849-9c05-96e4e3e25a21 + +ImportObjectsCommand.java +file + + + + +2011-07-06T04:02:28.468750Z +fd40ea24a60ace9b2146248dc590f926 +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + + + + + + + + +1202 + +ImportObjectsDialog.java +file + + + + +2011-07-06T04:02:28.468750Z +6157db23620ca4f65e60171b93850023 +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + + + + + + + + +11426 + +ObjectsImportSettings.java +file + + + + +2011-07-06T04:02:28.546875Z +c98f60b21558b12babf2033ad0e387c6 +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + + + + + + + + +1651 + +MappingButton.java +file + + + + +2011-07-06T04:02:28.546875Z +6077f6fcad8699e95e81fff0d5743a50 +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + + + + + + + + +831 + diff --git a/src/com/connor/dev/imp/ob/.svn/text-base/ImportObjectsCommand.java.svn-base b/src/com/connor/dev/imp/ob/.svn/text-base/ImportObjectsCommand.java.svn-base new file mode 100644 index 0000000..acea1b1 --- /dev/null +++ b/src/com/connor/dev/imp/ob/.svn/text-base/ImportObjectsCommand.java.svn-base @@ -0,0 +1,47 @@ +package com.origin.dev.imp.ob; + +import com.origin.dev.imp.AbstractImportCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; + +public class ImportObjectsCommand extends AbstractImportCommand { + public ImportObjectsCommand(AbstractAIFUIApplication application) { + super(application); + } + + public void importHistoryDatas() { + try { + ImportObjectsDialog dialog = new ImportObjectsDialog(session, "导入对象"); + if (dialog != null) { + setRunnable(dialog); + } + } + catch (Exception e) { + e.printStackTrace(); + } + // try + // { + // TCTypeService service = session.getTypeService(); + // TCComponentType[] items = service.getTypes("UnitOfMeasure"); + // if (items != null) + // { + // for (int i = 0; i < items.length; i++) + // { + // System.out.println(items[i].toString()); + // } + // } + // else + // { + // TCComponentType uom = service.getTypeComponent("UnitOfMeasure"); + // TCComponent[] coms = uom.extent(); + // for (int i = 0; i < coms.length; i++) + // { + // System.out.println(coms[i].toString()); + // System.out.println(coms[i].getClass().getName()); + // } + // } + // } + // catch (TCException e) + // { + // } + } +} diff --git a/src/com/connor/dev/imp/ob/.svn/text-base/ImportObjectsDialog.java.svn-base b/src/com/connor/dev/imp/ob/.svn/text-base/ImportObjectsDialog.java.svn-base new file mode 100644 index 0000000..3b29bfc --- /dev/null +++ b/src/com/connor/dev/imp/ob/.svn/text-base/ImportObjectsDialog.java.svn-base @@ -0,0 +1,413 @@ +package com.origin.dev.imp.ob; + +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.swing.DefaultListModel; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; +import javax.swing.event.ChangeEvent; + +import com.origin.dev.imp.AbstractImportDialog; +import com.origin.dev.imp.ImportSettings; +import com.origin.dev.imp.MappingAttribute; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.MessageBox; + +/** + * @author Administrator + * + */ +public class ImportObjectsDialog extends AbstractImportDialog +{ + private static final long serialVersionUID = 1L; + + private JComboBox itemTypeCombo; + + private JCheckBox replace; + + public ImportObjectsDialog(TCSession session, String title) + { + super(session, title, false); + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#initializeUI() + */ + protected void initializeUI() + { + super.initializeUI(); + + propertiesList = new JList[4]; + propertiesListModels = new DefaultListModel[4]; + mappingListModels = new DefaultListModel[4]; + mappingList = new JList[4]; + + for (int i = 0; i < propertiesList.length; i++) + { + propertiesListModels[i] = new DefaultListModel(); + propertiesList[i] = new JList(propertiesListModels[i]); + propertiesList[i].setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + propertiesList[i].setVisibleRowCount(20); + mappingListModels[i] = new DefaultListModel(); + mappingList[i] = new JList(mappingListModels[i]); + mappingList[i].setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + } + + itemTypeCombo = new JComboBox(); + + replace = new JCheckBox(); + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#registerActionComponents() + */ + protected void registerActionComponents() + { + super.registerActionComponents(); + + itemTypeCombo.addActionListener(this); + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#setComponentsTextProperty() + */ + protected void setComponentsTextProperty() + { + super.setComponentsTextProperty(); + + // populateTypeChoices("Item", itemTypeCombo); + // populateTypeChoices("MEProcess", itemTypeCombo); + // populateTypeChoices("MEOP", itemTypeCombo); + populateItemTypes(itemTypeCombo); + itemTypeCombo.insertItemAt("", 0); + itemTypeCombo.setSelectedIndex(0); + // populateTypeChoices("MENCMachining", itemTypeCombo); + + // arraySepField.setText("||"); + + try + { + TCTypeService service = session.getTypeService(); + TCComponentType[] type = service.getTypes("Dataset"); + propertiesListModels[3].removeAllElements(); + List list = new ArrayList(); + for (int i = 0; i < type.length; i++) + { + list.add(type[i].toString()); + } + Collections.sort(list); + for (String str : list) + { + propertiesListModels[3].addElement(str); + } + } + catch (TCException tce) + { + tce.printStackTrace(); + } + + replace.setText("更新已存在的零组件属性"); + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#addTabbedPaneComponents() + */ + public void addTabbedPaneComponents() + { + String[] titles = new String[] { "零件", "零件版本", "零件版本Form", "数据集" }; + for (int i = 0; i < 4; i++) + { + JPanel panel = new JPanel(new GridLayout()); + panel.add(new JScrollPane(propertiesList[i])); + panel.add(new JScrollPane(mappingList[i])); + rightPane.addTab(titles[i], panel); + } + + rightPane.addTab("参数", getParameterPanel()); + } + + protected void doPurgeComponentProperties(String name) + { + super.doPurgeComponentProperties(name); + + if (itemTypeCombo.getSelectedIndex() == 0) + { + return; + } + + // 得到零组件上的所有属性名 + try + { + TCTypeService service = session.getTypeService(); + TCComponentType type = service.getTypeComponent(name); + TCPropertyDescriptor[] descriptor = type.getPropertyDescriptors(); + List list = new ArrayList(); + for (int i = 0; i < descriptor.length; i++) + { + if (descriptor[i].isModifiable()) + { + list.add(descriptor[i].getName()); + } + } + + propertiesListModels[0].removeAllElements(); + Collections.sort(list); + for (String str : list) + { + propertiesListModels[0].addElement(str); + } + + // 得到版本上的所有属性名 + // if ("Design".equals(name) || "Drawing".equals(name) || "EngChange".equals(name) + // || "CommercialPart".equals(name) || "Part".equals(name) || "ManufacturerPart".equals(name) + // || "Message".equals(name) || "Paragraph".equals(name) || "Requirement".equals(name) + // || "GCS_CP_Plug".equals(name) || "GCS_CP_Socket".equals(name) || "GCS_CP".equals(name) + // || "MEWEDM".equals(name) || "Specification".equals(name) || "RequirementSpec".equals(name)) + // { + // name = String.valueOf(String.valueOf(name)).concat(" "); + // } + + try + { + type = service.getTypeComponent(String.valueOf(name + "Revision")); + name = name + "Revision"; + } + catch (Exception e) + { + type = service.getTypeComponent(String.valueOf(name.concat(" Revision"))); + name = name + " Revision"; + } + descriptor = type.getPropertyDescriptors(); + list.clear(); + for (int i = 0; i < descriptor.length; i++) + { + if (descriptor[i].isModifiable()) + { + list.add(descriptor[i].getName()); + } + } + propertiesListModels[1].removeAllElements(); + Collections.sort(list); + for (String str : list) + { + propertiesListModels[1].addElement(str); + } + try + { + type = service.getTypeComponent(name + "Master"); + } + catch (Exception e) + { + type = service.getTypeComponent(name + " Master"); + } + String[] properties = type.getPropertyNames(); + list.clear(); + for (int i = 0; i < properties.length; i++) + { + list.add(properties[i]); + } + propertiesListModels[2].removeAllElements(); + Collections.sort(list); + for (String str : list) + { + propertiesListModels[2].addElement(str); + } + } + catch (TCException tce) + { + tce.printStackTrace(); + } + } + + /* + * (non-Javadoc) + * + * @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent) + */ + public void stateChanged(ChangeEvent e) + { + int index = rightPane.getSelectedIndex(); + if (index > 3) + { + add.setEnabled(false); + remove.setEnabled(false); + } + else + { + checkMappingsEditable(); + } + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#openImportSettings() + */ + protected void openImportSettings() + { + if (chooser.showOpenDialog(null) == 0) + { + ObjectsImportSettings ois = new ObjectsImportSettings(); + ImportSettings is = ois.load(chooser.getSelectedFile()); + + if (is == null) + { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "从文件中加载配置失败.", "错误", 1); + return; + } + + if (is instanceof ObjectsImportSettings) + { + ois = (ObjectsImportSettings) is; + + replace.setSelected(ois.isExistedRefreshed()); + itemTypeCombo.setSelectedItem(ois.getItemType()); + + // arraySepField.setText(ois.getArraySeparator()); + + for (int i = 0; i < 4; i++) + { + mappingListModels[i].removeAllElements(); + } + + for (int i = 0; i < ois.getItemMapping().length; i++) + { + mappingListModels[0].addElement(ois.getItemMapping()[i]); + } + + for (int i = 0; i < ois.getRevMapping().length; i++) + { + mappingListModels[1].addElement(ois.getRevMapping()[i]); + } + + for (int i = 0; i < ois.getRevFormMapping().length; i++) + { + mappingListModels[2].addElement(ois.getRevFormMapping()[i]); + } + + for (int i = 0; i < ois.getDatasetMapping().length; i++) + { + mappingListModels[3].addElement(ois.getDatasetMapping()[i]); + } + + excelList.setEnabled(false); + for (int i = 0; i < 4; i++) + { + propertiesList[i].setEnabled(false); + mappingList[i].setEnabled(false); + } + } + } + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#saveImportSettings() + */ + protected void saveImportSettings() + { + ObjectsImportSettings ois = generateImportSettings(); + + if (chooser.showSaveDialog(null) == 0) + { + if (ois.save(chooser.getSelectedFile())) + { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "配置已经被成功保存在\n" + + chooser.getSelectedFile().getAbsolutePath(), "成功", 0); + } + else + { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "保存配置文件失败", "失败", 1); + } + } + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#generateImportSettings() + */ + public ObjectsImportSettings generateImportSettings() + { + ObjectsImportSettings ois = new ObjectsImportSettings(); + + MappingAttribute[] itemMapping = new MappingAttribute[mappingListModels[0].size()]; + System.arraycopy(mappingListModels[0].toArray(), 0, itemMapping, 0, itemMapping.length); + ois.setItemMapping(itemMapping); + + MappingAttribute[] revMapping = new MappingAttribute[mappingListModels[1].size()]; + System.arraycopy(mappingListModels[1].toArray(), 0, revMapping, 0, revMapping.length); + ois.setRevMapping(revMapping); + + MappingAttribute[] revFormMapping = new MappingAttribute[mappingListModels[2].size()]; + System.arraycopy(mappingListModels[2].toArray(), 0, revFormMapping, 0, revFormMapping.length); + ois.setRevFormMapping(revFormMapping); + + MappingAttribute[] datasetMapping = new MappingAttribute[mappingListModels[3].size()]; + System.arraycopy(mappingListModels[3].toArray(), 0, datasetMapping, 0, datasetMapping.length); + ois.setDatasetMapping(datasetMapping); + + ois.setItemType(itemTypeCombo.getSelectedItem().toString()); + ois.setColumns(excelList.getModel().getSize()); + ois.setExistedRefreshed(replace.isSelected()); + + // ois.setArraySeparator(arraySepField.getText().trim()); + ois.setDateFormat(dateFormatField.getText().trim()); + + return ois; + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#getParameterPanel() + */ + protected JPanel getParameterPanel() + { + JPanel p = super.getParameterPanel(); + + // p.add("3.1.right.top.preferred.preferred", new JLabel("文件名分隔符:")); + // p.add("3.2.left.top.preferred.preferred", new JTextField(20)); + p.add("2.1.right.top.preferred.preferred", new JLabel("零组件类型:")); + p.add("2.2.left.top.preferred.preferred", itemTypeCombo); + p.add("3.1.right.top.preferred.preferred", new JLabel(" ")); + p.add("3.2.left.top.preferred.preferred", replace); + + return p; + } + + public void actionPerformed(ActionEvent ae) + { + if (ae.getSource() == itemTypeCombo) + { + doPurgeComponentProperties(itemTypeCombo.getSelectedItem().toString()); + } + else + { + super.actionPerformed(ae); + } + } +} diff --git a/src/com/connor/dev/imp/ob/.svn/text-base/MappingButton.java.svn-base b/src/com/connor/dev/imp/ob/.svn/text-base/MappingButton.java.svn-base new file mode 100644 index 0000000..4c6ab6f --- /dev/null +++ b/src/com/connor/dev/imp/ob/.svn/text-base/MappingButton.java.svn-base @@ -0,0 +1,46 @@ +package com.origin.dev.imp.ob; + +import javax.swing.JButton; + +import com.origin.dev.imp.MappingAttribute; + + +public class MappingButton extends JButton +{ + private static final long serialVersionUID = 1L; + + private MappingAttribute mappingAttribute; + + private String propertyName; + + public MappingButton(String propertyName) + { + super(propertyName); + + this.propertyName = propertyName; + } + + public void setMappingAttribute(MappingAttribute mappingAttribute) + { + this.mappingAttribute = mappingAttribute; + + if(mappingAttribute != null) + { + setText(mappingAttribute.toString()); + } + else + { + setText(propertyName); + } + } + + public MappingAttribute getMappingAttribute() + { + return mappingAttribute; + } + + public String getPropertyName() + { + return propertyName; + } +} diff --git a/src/com/connor/dev/imp/ob/.svn/text-base/ObjectsImportSettings.java.svn-base b/src/com/connor/dev/imp/ob/.svn/text-base/ObjectsImportSettings.java.svn-base new file mode 100644 index 0000000..c9ebbfd --- /dev/null +++ b/src/com/connor/dev/imp/ob/.svn/text-base/ObjectsImportSettings.java.svn-base @@ -0,0 +1,80 @@ +package com.origin.dev.imp.ob; + +import java.io.Serializable; + +import com.origin.dev.imp.ImportSettings; +import com.origin.dev.imp.MappingAttribute; + +public class ObjectsImportSettings extends ImportSettings implements Serializable +{ + private static final long serialVersionUID = 1L; + + private MappingAttribute[] itemMapping; + + private MappingAttribute[] revMapping; + + private MappingAttribute[] revFormMapping; + + private MappingAttribute[] datasetMapping; + + private String itemType; + + private boolean existedRefreshed; + + public MappingAttribute[] getItemMapping() + { + return itemMapping; + } + public void setItemMapping(MappingAttribute[] itemMapping) + { + this.itemMapping = itemMapping; + } + + public MappingAttribute[] getRevMapping() + { + return revMapping; + } + + public void setRevMapping(MappingAttribute[] revMapping) + { + this.revMapping = revMapping; + } + + public MappingAttribute[] getRevFormMapping() + { + return revFormMapping; + } + + public void setRevFormMapping(MappingAttribute[] revFormMapping) + { + this.revFormMapping = revFormMapping; + } + + public MappingAttribute[] getDatasetMapping() + { + return datasetMapping; + } + + public void setDatasetMapping(MappingAttribute[] datasetMapping) + { + this.datasetMapping = datasetMapping; + } + + public void setItemType(String itemType) + { + this.itemType = itemType; + } + + public String getItemType() + { + return itemType; + } + public void setExistedRefreshed(boolean existedRefreshed) + { + this.existedRefreshed = existedRefreshed; + } + public boolean isExistedRefreshed() + { + return existedRefreshed; + } +} diff --git a/src/com/connor/dev/imp/ob/ImportObjectsCommand.java b/src/com/connor/dev/imp/ob/ImportObjectsCommand.java new file mode 100644 index 0000000..a113b17 --- /dev/null +++ b/src/com/connor/dev/imp/ob/ImportObjectsCommand.java @@ -0,0 +1,47 @@ +package com.connor.dev.imp.ob; + +import com.connor.dev.imp.AbstractImportCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; + +public class ImportObjectsCommand extends AbstractImportCommand { + public ImportObjectsCommand(AbstractAIFUIApplication application) { + super(application); + } + + public void importHistoryDatas() { + try { + ImportObjectsDialog dialog = new ImportObjectsDialog(session, "导入对象"); + if (dialog != null) { + setRunnable(dialog); + } + } + catch (Exception e) { + e.printStackTrace(); + } + // try + // { + // TCTypeService service = session.getTypeService(); + // TCComponentType[] items = service.getTypes("UnitOfMeasure"); + // if (items != null) + // { + // for (int i = 0; i < items.length; i++) + // { + // System.out.println(items[i].toString()); + // } + // } + // else + // { + // TCComponentType uom = service.getTypeComponent("UnitOfMeasure"); + // TCComponent[] coms = uom.extent(); + // for (int i = 0; i < coms.length; i++) + // { + // System.out.println(coms[i].toString()); + // System.out.println(coms[i].getClass().getName()); + // } + // } + // } + // catch (TCException e) + // { + // } + } +} diff --git a/src/com/connor/dev/imp/ob/ImportObjectsDialog.java b/src/com/connor/dev/imp/ob/ImportObjectsDialog.java new file mode 100644 index 0000000..861d62d --- /dev/null +++ b/src/com/connor/dev/imp/ob/ImportObjectsDialog.java @@ -0,0 +1,611 @@ +package com.connor.dev.imp.ob; + +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; +import javax.swing.event.ChangeEvent; + +import com.connor.dev.imp.AbstractImportDialog; +import com.connor.dev.imp.ImportSettings; +import com.connor.dev.imp.MappingAttribute; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.kernel.TCComponentAliasList; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.AIFImageIcon; +import com.teamcenter.rac.util.MessageBox; + +/** + * @author Administrator + * + */ +public class ImportObjectsDialog extends AbstractImportDialog { + private static final long serialVersionUID = 1L; + + private JComboBox itemTypeCombo; + + private JCheckBox replace; + private JCheckBox throughParent; + private JButton addType; + private boolean isCanValues = false; + + public ImportObjectsDialog(TCSession session, String title, String exportFilePath, String settingFilePath, + boolean isCanValues) { + + super(session, title, false, exportFilePath, settingFilePath, isCanValues); + + } + + public ImportObjectsDialog(TCSession session, String title) { + super(session, title, false); + } + + public void init() { + initializeUI(); + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#initializeUI() + */ + protected void initializeUI() { + super.initializeUI(); + + propertiesList = new JList[4]; + propertiesListModels = new DefaultListModel[4]; + mappingListModels = new DefaultListModel[4]; + mappingList = new JList[4]; + + for (int i = 0; i < propertiesList.length; i++) { + propertiesListModels[i] = new DefaultListModel(); + propertiesList[i] = new JList(propertiesListModels[i]); + propertiesList[i].setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + propertiesList[i].setVisibleRowCount(20); + mappingListModels[i] = new DefaultListModel(); + mappingList[i] = new JList(mappingListModels[i]); + mappingList[i].setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + } + + itemTypeCombo = new JComboBox(); + + replace = new JCheckBox(); + addType = new JButton(AIFImageIcon.getImageIcon(this, "images/add_16.png")); + addType.setEnabled(false); + throughParent = new JCheckBox(); + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#registerActionComponents() + */ + protected void registerActionComponents() { + super.registerActionComponents(); + + itemTypeCombo.addActionListener(this); + throughParent.addActionListener(this); + addType.addActionListener(this); + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#setComponentsTextProperty() + */ + protected void setComponentsTextProperty() { + super.setComponentsTextProperty(); + + // populateTypeChoices("Item", itemTypeCombo); + // populateTypeChoices("MEProcess", itemTypeCombo); + // populateTypeChoices("MEOP", itemTypeCombo); + populateItemTypes(itemTypeCombo); + itemTypeCombo.insertItemAt("", 0); + itemTypeCombo.setSelectedIndex(0); + // populateTypeChoices("MENCMachining", itemTypeCombo); + + // arraySepField.setText("||"); + + try { + TCTypeService service = session.getTypeService(); + TCComponentType[] type = service.getTypes("Dataset"); + propertiesListModels[3].removeAllElements(); + List list = new ArrayList(); + if (type != null) + for (int i = 0; i < type.length; i++) { + list.add(type[i] == null ? "" : type[i].toString()); + } + Collections.sort(list); + propertiesListModels[3].addElement("路径"); + + for (String str : list) { + propertiesListModels[3].addElement(str); + } + } catch (TCException tce) { + tce.printStackTrace(); + } + + replace.setText("更新已存在的零组件属性"); + + throughParent.setText("多值"); + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#addTabbedPaneComponents() + */ + public void addTabbedPaneComponents() { + String[] titles = new String[] { "零件", "零件版本", "零件版本Form", "数据集" }; + for (int i = 0; i < 4; i++) { + JPanel panel = new JPanel(new GridLayout()); + panel.add(new JScrollPane(propertiesList[i])); + panel.add(new JScrollPane(mappingList[i])); + rightPane.addTab(titles[i], panel); + } + + rightPane.addTab("参数", getParameterPanel()); + } + + /** + * 只允许单值的情况 + */ + protected void doPurgeComponentProperties(String name) { + super.doPurgeComponentProperties(name); + + if (itemTypeCombo.getSelectedIndex() == 0) { + return; + } + + // 得到零组件上的所有属性名 + try { + TCTypeService service = session.getTypeService(); + TCComponentType type = service.getTypeComponent(name); + TCPropertyDescriptor[] descriptor = type.getPropertyDescriptors(); + List list = new ArrayList(); + + for (int i = 0; i < descriptor.length; i++) { + list.add(descriptor[i].getName()); + } + + propertiesListModels[0].removeAllElements(); + Collections.sort(list); + propertiesListModels[0].addElement("类型"); + propertiesListModels[0].addElement("项目");//2017/10/25改 + for (String str : list) { + propertiesListModels[0].addElement(str); + } + + // 得到版本上的所有属性名 + // if ("Design".equals(name) || "Drawing".equals(name) || + // "EngChange".equals(name) + // || "CommercialPart".equals(name) || "Part".equals(name) || + // "ManufacturerPart".equals(name) + // || "Message".equals(name) || "Paragraph".equals(name) || + // "Requirement".equals(name) + // || "GCS_CP_Plug".equals(name) || "GCS_CP_Socket".equals(name) || + // "GCS_CP".equals(name) + // || "MEWEDM".equals(name) || "Specification".equals(name) || + // "RequirementSpec".equals(name)) + // { + // name = String.valueOf(String.valueOf(name)).concat(" "); + // } + // *** + String temp1 = ""; + String temp2 = ""; + String temp3 = name; + + /* + * try { type = service.getTypeComponent(String.valueOf(name + + * "Revision")); name = name + "Revision"; } catch (Exception e) { + * type = service.getTypeComponent(String.valueOf(name.concat( + * " Revision" ))); name = name + " Revision"; } + */ + type = service.getTypeComponent(String.valueOf(name + " Revision")); + // type.getReferenceListProperty(arg0) + if (type == null) { + type = service.getTypeComponent(String.valueOf(name + "Revision")); + name = name + "Revision"; + temp1 = name; + } else { + name = name + " Revision"; + temp2 = name; + } // ***** + TCComponentFolder folder = null; + descriptor = type.getPropertyDescriptors(); + list.clear(); + for (int i = 0; i < descriptor.length; i++) { + if (descriptor[i].isModifiable()) { + list.add(descriptor[i].getName()); + } + } + propertiesListModels[1].removeAllElements(); + Collections.sort(list); + for (String str : list) { + propertiesListModels[1].addElement(str); + } + // **** + /* + * try { type = service.getTypeComponent(name + "Master"); } catch + * (Exception e) { type = service.getTypeComponent(name + " Master" + * ); } + */ + + type = service.getTypeComponent(name + " Master"); + if (type == null) { + type = service.getTypeComponent(name + "Master"); + + } + if (type == null) { + type = service.getTypeComponent(temp1 + "Master"); + } + if (type == null) { + type = service.getTypeComponent(temp2 + "Master"); + } + if (type == null) { + type = service.getTypeComponent(temp1 + " Master"); + } + if (type == null) { + type = service.getTypeComponent(temp2 + " Master"); + } + if (type == null) { + type = service.getTypeComponent(temp3 + "Rev" + " Master"); + } + if (type == null) { + type = service.getTypeComponent(temp3 + "Rev" + "Master"); + } + // **** + String[] properties = type.getPropertyNames(); + list.clear(); + for (int i = 0; i < properties.length; i++) { + list.add(properties[i]); + } + propertiesListModels[2].removeAllElements(); + Collections.sort(list); + for (String str : list) { + propertiesListModels[2].addElement(str); + } + } catch (TCException tce) { + tce.printStackTrace(); + } + } + + /** + * 允许多值的情况 + * + * @param name + */ + protected void doPurgeComponentProperties2(String name) { + // super.doPurgeComponentProperties(name); + + if (itemTypeCombo.getSelectedIndex() == 0) { + return; + } + + // 得到零组件上的所有属性名 + try { + TCTypeService service = session.getTypeService(); + TCComponentType type = service.getTypeComponent(name); + TCPropertyDescriptor[] descriptor = type.getPropertyDescriptors(); + List list = new ArrayList(); + + for (int i = 0; i < descriptor.length; i++) { + if (descriptor[i].isModifiable()) { + list.add(descriptor[i].getName()); + } + } + for (int i = 0; i < propertiesListModels[0].size(); i++) { + Object obj = propertiesListModels[0].get(i); + list.add((String) obj); + } + + propertiesListModels[0].removeAllElements(); + Collections.sort(list); + if (!propertiesListModels[0].contains("类型")) { + propertiesListModels[0].addElement("类型"); + System.out.println("没有添加类型"); + } else { + System.out.println("存在类型"); + } + for (String str : list) { + if (!propertiesListModels[0].contains(str)) + propertiesListModels[0].addElement(str); + } + + // 得到版本上的所有属性名 + // if ("Design".equals(name) || "Drawing".equals(name) || + // "EngChange".equals(name) + // || "CommercialPart".equals(name) || "Part".equals(name) || + // "ManufacturerPart".equals(name) + // || "Message".equals(name) || "Paragraph".equals(name) || + // "Requirement".equals(name) + // || "GCS_CP_Plug".equals(name) || "GCS_CP_Socket".equals(name) || + // "GCS_CP".equals(name) + // || "MEWEDM".equals(name) || "Specification".equals(name) || + // "RequirementSpec".equals(name)) + // { + // name = String.valueOf(String.valueOf(name)).concat(" "); + // } + // *** + String temp1 = ""; + String temp2 = ""; + String temp3 = name; + + /* + * try { type = service.getTypeComponent(String.valueOf(name + + * "Revision")); name = name + "Revision"; } catch (Exception e) { + * type = service.getTypeComponent(String.valueOf(name.concat( + * " Revision" ))); name = name + " Revision"; } + */ + type = service.getTypeComponent(String.valueOf(name + " Revision")); + if (type == null) { + type = service.getTypeComponent(String.valueOf(name + "Revision")); + name = name + "Revision"; + temp1 = name; + } else { + name = name + " Revision"; + temp2 = name; + } // ***** + + descriptor = type.getPropertyDescriptors(); + list.clear(); + for (int i = 0; i < descriptor.length; i++) { + if (descriptor[i].isModifiable()) { + list.add(descriptor[i].getName()); + } + } + for (int i = 0; i < propertiesListModels[1].size(); i++) { + Object obj = propertiesListModels[1].get(i); + list.add((String) obj); + } + propertiesListModels[1].removeAllElements(); + Collections.sort(list); + for (String str : list) { + if (!propertiesListModels[1].contains(str)) + propertiesListModels[1].addElement(str); + } + // **** + /* + * try { type = service.getTypeComponent(name + "Master"); } catch + * (Exception e) { type = service.getTypeComponent(name + " Master" + * ); } + */ + + type = service.getTypeComponent(name + " Master"); + if (type == null) { + type = service.getTypeComponent(name + "Master"); + + } + if (type == null) { + type = service.getTypeComponent(temp1 + "Master"); + } + if (type == null) { + type = service.getTypeComponent(temp2 + "Master"); + } + if (type == null) { + type = service.getTypeComponent(temp1 + " Master"); + } + if (type == null) { + type = service.getTypeComponent(temp2 + " Master"); + } + if (type == null) { + type = service.getTypeComponent(temp3 + "Rev" + " Master"); + } + if (type == null) { + type = service.getTypeComponent(temp3 + "Rev" + "Master"); + } + // **** + String[] properties = type.getPropertyNames(); + list.clear(); + for (int i = 0; i < properties.length; i++) { + list.add(properties[i]); + } + for (int i = 0; i < propertiesListModels[2].size(); i++) { + Object obj = propertiesListModels[2].get(i); + list.add((String) obj); + } + propertiesListModels[2].removeAllElements(); + Collections.sort(list); + for (String str : list) { + if (!propertiesListModels[2].contains(str)) + propertiesListModels[2].addElement(str); + } + } catch (TCException tce) { + tce.printStackTrace(); + } + } + + /* + * (non-Javadoc) + * + * @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event. + * ChangeEvent ) + */ + public void stateChanged(ChangeEvent e) { + int index = rightPane.getSelectedIndex(); + if (index > 3) { + add.setEnabled(false); + remove.setEnabled(false); + } else { + checkMappingsEditable(); + } + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#openImportSettings() + */ + protected void openImportSettings() { + + if (this.isExec) { + openImportSettings2(isExec); + } else if (chooser.showOpenDialog(null) == 0) { + openImportSettings2(false); + } + } + + public void openImportSettings2(boolean c) { + + ObjectsImportSettings ois = new ObjectsImportSettings(); + ImportSettings is = null; + if (!isExec) { + is = ois.load(chooser.getSelectedFile()); + } else { + + is = ois.load(new File(this.settingFilePath)); + } + + if (is == null) { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "从文件中加载配置失败.", "错误", 1); + return; + } + + if (is instanceof ObjectsImportSettings) { + ois = (ObjectsImportSettings) is; + + replace.setSelected(ois.isExistedRefreshed()); + throughParent.setSelected(ois.isSelectParent()); + itemTypeCombo.setSelectedItem(ois.getItemType()); + // arraySepField.setText(ois.getArraySeparator()); + for (int i = 0; i < 4; i++) { + mappingListModels[i].removeAllElements(); + } + + for (int i = 0; i < ois.getItemMapping().length; i++) { + mappingListModels[0].addElement(ois.getItemMapping()[i]); + } + + for (int i = 0; i < ois.getRevMapping().length; i++) { + mappingListModels[1].addElement(ois.getRevMapping()[i]); + } + + for (int i = 0; i < ois.getRevFormMapping().length; i++) { + mappingListModels[2].addElement(ois.getRevFormMapping()[i]); + } + + for (int i = 0; i < ois.getDatasetMapping().length; i++) { + mappingListModels[3].addElement(ois.getDatasetMapping()[i]); + } + + excelList.setEnabled(false); + for (int i = 0; i < 4; i++) { + propertiesList[i].setEnabled(false); + mappingList[i].setEnabled(false); + } + } + + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#saveImportSettings() + */ + protected void saveImportSettings() { + ObjectsImportSettings ois = generateImportSettings(); + + if (chooser.showSaveDialog(null) == 0) { + if (ois.save(chooser.getSelectedFile())) { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), + "配置已经被成功保存在\n" + chooser.getSelectedFile().getAbsolutePath(), "成功", 2); + } else { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "保存配置文件失败", "失败", 1); + } + } + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#generateImportSettings() + */ + public ObjectsImportSettings generateImportSettings() { + ObjectsImportSettings ois = new ObjectsImportSettings(); + + MappingAttribute[] itemMapping = new MappingAttribute[mappingListModels[0].size()]; + System.arraycopy(mappingListModels[0].toArray(), 0, itemMapping, 0, itemMapping.length); + ois.setItemMapping(itemMapping); + + MappingAttribute[] revMapping = new MappingAttribute[mappingListModels[1].size()]; + System.arraycopy(mappingListModels[1].toArray(), 0, revMapping, 0, revMapping.length); + ois.setRevMapping(revMapping); + + MappingAttribute[] revFormMapping = new MappingAttribute[mappingListModels[2].size()]; + System.arraycopy(mappingListModels[2].toArray(), 0, revFormMapping, 0, revFormMapping.length); + ois.setRevFormMapping(revFormMapping); + + MappingAttribute[] datasetMapping = new MappingAttribute[mappingListModels[3].size()]; + System.arraycopy(mappingListModels[3].toArray(), 0, datasetMapping, 0, datasetMapping.length); + ois.setDatasetMapping(datasetMapping); + + ois.setItemType(itemTypeCombo.getSelectedItem().toString()); + ois.setColumns(excelList.getModel().getSize()); + ois.setExistedRefreshed(replace.isSelected()); + ois.setSelectParent(throughParent.isSelected()); + + // ois.setArraySeparator(arraySepField.getText().trim()); + ois.setDateFormat(dateFormatField.getText().trim()); + + return ois; + } + + /* + * (non-Javadoc) + * + * @see cn.com.origin.imp.AbstractImportDialog#getParameterPanel() + */ + protected JPanel getParameterPanel() { + JPanel p = super.getParameterPanel(); + + // p.add("3.1.right.top.preferred.preferred", new JLabel("文件名分隔符:")); + // p.add("3.2.left.top.preferred.preferred", new JTextField(20)); + p.add("2.1.right.top.preferred.preferred", new JLabel("零组件类型:")); + p.add("2.2.left.top.preferred.preferred", itemTypeCombo); + p.add("2.3.left.top.preferred.preferred", addType); + p.add("2.4.left.top.preferred.preferred", throughParent); + p.add("3.1.right.top.preferred.preferred", new JLabel(" ")); + p.add("3.2.left.top.preferred.preferred", replace); + // p.add("4.1.right.top.preferred.preferred", new JLabel(" ")); + // p.add("4.2.left.top.preferred.preferred", throughParent); + return p; + } + + public void actionPerformed(ActionEvent ae) { + if (ae.getSource() == throughParent) { + if (throughParent.isSelected()) { + isCanValues = true; + addType.setEnabled(true); + } else { + isCanValues = false; + addType.setEnabled(false); + doPurgeComponentProperties(itemTypeCombo.getSelectedItem().toString()); + } + } else if (ae.getSource() == itemTypeCombo) { + if (!isCanValues) + doPurgeComponentProperties(itemTypeCombo.getSelectedItem().toString()); + + } else if (ae.getSource() == addType) { + doPurgeComponentProperties2(itemTypeCombo.getSelectedItem().toString()); + } else { + super.actionPerformed(ae); + } + } +} diff --git a/src/com/connor/dev/imp/ob/MappingButton.java b/src/com/connor/dev/imp/ob/MappingButton.java new file mode 100644 index 0000000..e3b65a9 --- /dev/null +++ b/src/com/connor/dev/imp/ob/MappingButton.java @@ -0,0 +1,46 @@ +package com.connor.dev.imp.ob; + +import javax.swing.JButton; + +import com.connor.dev.imp.MappingAttribute; + + +public class MappingButton extends JButton +{ + private static final long serialVersionUID = 1L; + + private MappingAttribute mappingAttribute; + + private String propertyName; + + public MappingButton(String propertyName) + { + super(propertyName); + + this.propertyName = propertyName; + } + + public void setMappingAttribute(MappingAttribute mappingAttribute) + { + this.mappingAttribute = mappingAttribute; + + if(mappingAttribute != null) + { + setText(mappingAttribute.toString()); + } + else + { + setText(propertyName); + } + } + + public MappingAttribute getMappingAttribute() + { + return mappingAttribute; + } + + public String getPropertyName() + { + return propertyName; + } +} diff --git a/src/com/connor/dev/imp/ob/ObjectsImportSettings.java b/src/com/connor/dev/imp/ob/ObjectsImportSettings.java new file mode 100644 index 0000000..ea36287 --- /dev/null +++ b/src/com/connor/dev/imp/ob/ObjectsImportSettings.java @@ -0,0 +1,91 @@ +package com.connor.dev.imp.ob; + +import java.io.Serializable; + +import com.connor.dev.imp.ImportSettings; +import com.connor.dev.imp.MappingAttribute; + +public class ObjectsImportSettings extends ImportSettings implements Serializable +{ + private static final long serialVersionUID = 1L; + + private MappingAttribute[] itemMapping; + + private MappingAttribute[] revMapping; + + private MappingAttribute[] revFormMapping; + + private MappingAttribute[] datasetMapping; + + private String itemType; + + private boolean existedRefreshed; + //添加选择父类,自动创建子类的功能 + private boolean selectParent; + + + + public boolean isSelectParent() { + return selectParent; + } + public void setSelectParent(boolean selectParent) { + this.selectParent = selectParent; + } + + public MappingAttribute[] getItemMapping() + { + return itemMapping; + } + public void setItemMapping(MappingAttribute[] itemMapping) + { + this.itemMapping = itemMapping; + } + + public MappingAttribute[] getRevMapping() + { + return revMapping; + } + + public void setRevMapping(MappingAttribute[] revMapping) + { + this.revMapping = revMapping; + } + + public MappingAttribute[] getRevFormMapping() + { + return revFormMapping; + } + + public void setRevFormMapping(MappingAttribute[] revFormMapping) + { + this.revFormMapping = revFormMapping; + } + + public MappingAttribute[] getDatasetMapping() + { + return datasetMapping; + } + + public void setDatasetMapping(MappingAttribute[] datasetMapping) + { + this.datasetMapping = datasetMapping; + } + + public void setItemType(String itemType) + { + this.itemType = itemType; + } + + public String getItemType() + { + return itemType; + } + public void setExistedRefreshed(boolean existedRefreshed) + { + this.existedRefreshed = existedRefreshed; + } + public boolean isExistedRefreshed() + { + return existedRefreshed; + } +} diff --git a/src/com/connor/dev/imp/ob/StaticEnum.java b/src/com/connor/dev/imp/ob/StaticEnum.java new file mode 100644 index 0000000..d8b6b1c --- /dev/null +++ b/src/com/connor/dev/imp/ob/StaticEnum.java @@ -0,0 +1,7 @@ +package com.connor.dev.imp.ob; + +public class StaticEnum { + public static final String Connor_Create_Item_Operation = "Connor_Create_Item_Operation"; + public static boolean isExec = false; + +} diff --git a/src/com/connor/dev/imp/solution/handler/.svn/all-wcprops b/src/com/connor/dev/imp/solution/handler/.svn/all-wcprops new file mode 100644 index 0000000..cd15f0a --- /dev/null +++ b/src/com/connor/dev/imp/solution/handler/.svn/all-wcprops @@ -0,0 +1,23 @@ +K 25 +svn:wc:ra_dav:version-url +V 109 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/solution/handler +END +ImportObjectsHandler.java +K 25 +svn:wc:ra_dav:version-url +V 135 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/solution/handler/ImportObjectsHandler.java +END +ImportRelationHandler.java +K 25 +svn:wc:ra_dav:version-url +V 136 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/solution/handler/ImportRelationHandler.java +END +ImportBOMsHandler.java +K 25 +svn:wc:ra_dav:version-url +V 132 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/solution/handler/ImportBOMsHandler.java +END diff --git a/src/com/connor/dev/imp/solution/handler/.svn/entries b/src/com/connor/dev/imp/solution/handler/.svn/entries new file mode 100644 index 0000000..82e9c84 --- /dev/null +++ b/src/com/connor/dev/imp/solution/handler/.svn/entries @@ -0,0 +1,130 @@ +10 + +dir +13 +http://192.168.0.254:8080/svn/dongfang/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/solution/handler +http://192.168.0.254:8080/svn/dongfang + + + +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + +d5545a61-9634-c849-9c05-96e4e3e25a21 + +ImportObjectsHandler.java +file + + + + +2011-07-06T04:02:28.125000Z +e3091fe948a614e03f0431c91eee466e +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + + + + + + + + +982 + +ImportRelationHandler.java +file + + + + +2011-07-06T04:02:28.125000Z +52558d1fb1b4dd21f89848dcb4d07483 +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + + + + + + + + +989 + +ImportBOMsHandler.java +file + + + + +2011-07-06T04:02:28.125000Z +e240503785397b2f74390795adf3be12 +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + + + + + + + + +971 + diff --git a/src/com/connor/dev/imp/solution/handler/.svn/text-base/ImportBOMsHandler.java.svn-base b/src/com/connor/dev/imp/solution/handler/.svn/text-base/ImportBOMsHandler.java.svn-base new file mode 100644 index 0000000..a1f6bd5 --- /dev/null +++ b/src/com/connor/dev/imp/solution/handler/.svn/text-base/ImportBOMsHandler.java.svn-base @@ -0,0 +1,34 @@ +package com.origin.dev.imp.solution.handler; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.origin.dev.imp.bom.ImportBomsCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.util.MessageBox; + +public class ImportBOMsHandler extends AbstractHandler +{ + /* + * (non-Javadoc) + * + * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + public Object execute(ExecutionEvent arg0) throws ExecutionException + { + AbstractAIFUIApplication application = AIFUtility.getCurrentApplication(); + try + { + ImportBomsCommand command = new ImportBomsCommand(application); + command.executeModal(); + } + catch (Exception exception) + { + MessageBox.post(exception, true); + } + + return null; + } +} diff --git a/src/com/connor/dev/imp/solution/handler/.svn/text-base/ImportObjectsHandler.java.svn-base b/src/com/connor/dev/imp/solution/handler/.svn/text-base/ImportObjectsHandler.java.svn-base new file mode 100644 index 0000000..9990233 --- /dev/null +++ b/src/com/connor/dev/imp/solution/handler/.svn/text-base/ImportObjectsHandler.java.svn-base @@ -0,0 +1,34 @@ +package com.origin.dev.imp.solution.handler; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.origin.dev.imp.ob.ImportObjectsCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.util.MessageBox; + +public class ImportObjectsHandler extends AbstractHandler +{ + /* + * (non-Javadoc) + * + * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + public Object execute(ExecutionEvent arg0) throws ExecutionException + { + AbstractAIFUIApplication application = AIFUtility.getCurrentApplication(); + try + { + ImportObjectsCommand command = new ImportObjectsCommand(application); + command.executeModal(); + } + catch (Exception exception) + { + MessageBox.post(exception, true); + } + + return null; + } +} diff --git a/src/com/connor/dev/imp/solution/handler/.svn/text-base/ImportRelationHandler.java.svn-base b/src/com/connor/dev/imp/solution/handler/.svn/text-base/ImportRelationHandler.java.svn-base new file mode 100644 index 0000000..874431e --- /dev/null +++ b/src/com/connor/dev/imp/solution/handler/.svn/text-base/ImportRelationHandler.java.svn-base @@ -0,0 +1,34 @@ +package com.origin.dev.imp.solution.handler; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.origin.dev.imp.re.ImportRelationsCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.util.MessageBox; + +public class ImportRelationHandler extends AbstractHandler +{ + /* + * (non-Javadoc) + * + * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + public Object execute(ExecutionEvent arg0) throws ExecutionException + { + AbstractAIFUIApplication application = AIFUtility.getCurrentApplication(); + try + { + ImportRelationsCommand command = new ImportRelationsCommand(application); + command.executeModal(); + } + catch (Exception exception) + { + MessageBox.post(exception, true); + } + + return null; + } +} diff --git a/src/com/connor/dev/imp/solution/handler/ImportBOMsHandler.java b/src/com/connor/dev/imp/solution/handler/ImportBOMsHandler.java new file mode 100644 index 0000000..ce9da99 --- /dev/null +++ b/src/com/connor/dev/imp/solution/handler/ImportBOMsHandler.java @@ -0,0 +1,35 @@ +package com.connor.dev.imp.solution.handler; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.dev.imp.bom.ImportBomsCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.util.MessageBox; + +public class ImportBOMsHandler extends AbstractHandler +{ + /* + * (non-Javadoc) + * + * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + public Object execute(ExecutionEvent arg0) throws ExecutionException + { + AbstractAIFUIApplication application = AIFUtility.getCurrentApplication(); + try + { + + ImportBomsCommand command = new ImportBomsCommand(application); + command.executeModal(); + } + catch (Exception exception) + { + MessageBox.post(exception, true); + } + + return null; + } +} diff --git a/src/com/connor/dev/imp/toolkit/.svn/all-wcprops b/src/com/connor/dev/imp/toolkit/.svn/all-wcprops new file mode 100644 index 0000000..7cf3e69 --- /dev/null +++ b/src/com/connor/dev/imp/toolkit/.svn/all-wcprops @@ -0,0 +1,41 @@ +K 25 +svn:wc:ra_dav:version-url +V 100 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/toolkit +END +Logger.java +K 25 +svn:wc:ra_dav:version-url +V 112 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/toolkit/Logger.java +END +POIExcelParser.java +K 25 +svn:wc:ra_dav:version-url +V 120 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/toolkit/POIExcelParser.java +END +POIExcelUtil.java +K 25 +svn:wc:ra_dav:version-url +V 118 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/toolkit/POIExcelUtil.java +END +ProgressReporter.java +K 25 +svn:wc:ra_dav:version-url +V 122 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/toolkit/ProgressReporter.java +END +SearchUtility.java +K 25 +svn:wc:ra_dav:version-url +V 119 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/toolkit/SearchUtility.java +END +JXLExcelParser.java +K 25 +svn:wc:ra_dav:version-url +V 120 +/svn/dongfang/!svn/ver/13/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/toolkit/JXLExcelParser.java +END diff --git a/src/com/connor/dev/imp/toolkit/.svn/entries b/src/com/connor/dev/imp/toolkit/.svn/entries new file mode 100644 index 0000000..b8ec84a --- /dev/null +++ b/src/com/connor/dev/imp/toolkit/.svn/entries @@ -0,0 +1,232 @@ +10 + +dir +13 +http://192.168.0.254:8080/svn/dongfang/Java%E4%BB%A3%E7%A0%81/TCImportHistoryDatas/src/com/origin/dev/imp/toolkit +http://192.168.0.254:8080/svn/dongfang + + + +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + +d5545a61-9634-c849-9c05-96e4e3e25a21 + +Logger.java +file + + + + +2011-07-06T04:02:28.125000Z +5ed3ab02ba83e31076ffb05f3cbeaded +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + + + + + + + + +428 + +POIExcelParser.java +file + + + + +2011-07-06T04:02:28.125000Z +81dcea016788ccb950c8f19846874dfa +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + + + + + + + + +8522 + +POIExcelUtil.java +file + + + + +2011-07-06T04:02:28.125000Z +031adc73623418cec7bc81f69eb3f922 +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + + + + + + + + +10062 + +ProgressReporter.java +file + + + + +2011-07-06T04:02:28.125000Z +77a58002d2e1e60e0ea474e6e35e8388 +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + + + + + + + + +2317 + +SearchUtility.java +file + + + + +2011-07-06T04:02:28.125000Z +7465b8ca69014bdf22a0a243b6d28905 +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + + + + + + + + +1829 + +JXLExcelParser.java +file + + + + +2011-07-06T04:02:28.125000Z +f7314359f584acd23310e81f9d070cc9 +2011-11-09T09:34:29.065079Z +13 +liqz + + + + + + + + + + + + + + + + + + + + + +1686 + diff --git a/src/com/connor/dev/imp/toolkit/.svn/text-base/JXLExcelParser.java.svn-base b/src/com/connor/dev/imp/toolkit/.svn/text-base/JXLExcelParser.java.svn-base new file mode 100644 index 0000000..6973f01 --- /dev/null +++ b/src/com/connor/dev/imp/toolkit/.svn/text-base/JXLExcelParser.java.svn-base @@ -0,0 +1,94 @@ +package com.origin.dev.imp.toolkit; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import jxl.Cell; +import jxl.Sheet; +import jxl.Workbook; +import jxl.WorkbookSettings; +import jxl.read.biff.BiffException; + +public class JXLExcelParser +{ + private Workbook workbook; + + private Sheet sheet; + + public int rows; + + public int startRow; + + private int columns; + + public JXLExcelParser(File input, int sheetIndex, int columns, int startRow) throws BiffException, IOException + { + this.startRow = startRow; + this.columns = columns; + + WorkbookSettings ws = new WorkbookSettings(); + ws.setEncoding("ISO-8859-1"); + workbook = Workbook.getWorkbook(input, ws); + sheet = workbook.getSheet(sheetIndex); + rows = sheet.getRows(); + + System.out.println("excel文件一共要读取" + rows + "行数据"); + } + + public List parseLine() + { + List l = getLine(); + while (isEmpty(l)) + { + l = getLine(); + } + + return l; + } + + private boolean isEmpty(List l) + { + if (l == null) + { + return false; + } + + for (String string : l) + { + if (!string.trim().equals("")) + { + return false; + } + } + + return true; + } + + public List getLine() + { + if (startRow > rows - 1) + { + workbook.close(); + return null; + } + + List line = new ArrayList(); + + Cell[] cells = sheet.getRow(startRow++); + + int cos = Math.min(columns, cells.length); + for (int j = 0; j < cos; j++) + { + line.add(cells[j].getContents().trim()); + } + + for (int j = 0; j < columns - cos + 1; j++) + { + line.add(""); + } + + return line; + } +} diff --git a/src/com/connor/dev/imp/toolkit/.svn/text-base/Logger.java.svn-base b/src/com/connor/dev/imp/toolkit/.svn/text-base/Logger.java.svn-base new file mode 100644 index 0000000..1b42f27 --- /dev/null +++ b/src/com/connor/dev/imp/toolkit/.svn/text-base/Logger.java.svn-base @@ -0,0 +1,24 @@ +package com.origin.dev.imp.toolkit; + +public class Logger +{ + public void debug(String message) + { + System.out.println("【debug】" + message); + } + + public void error(String message) + { + System.out.println("【error】" + message); + } + + public void info(String message) + { + System.out.println("【info】" + message); + } + + public void warn(String message) + { + System.out.println("【warn】" + message); + } +} diff --git a/src/com/connor/dev/imp/toolkit/.svn/text-base/POIExcelParser.java.svn-base b/src/com/connor/dev/imp/toolkit/.svn/text-base/POIExcelParser.java.svn-base new file mode 100644 index 0000000..33a8d27 --- /dev/null +++ b/src/com/connor/dev/imp/toolkit/.svn/text-base/POIExcelParser.java.svn-base @@ -0,0 +1,291 @@ +package com.origin.dev.imp.toolkit; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.List; + +import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.DateUtil; +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; + +/** *//** +*
    +*
  • Title:[POI基础上的Excel数据读取工具]
  • +*
  • Description: [支持Excell2003,Excell2007,自动格式化数值型数据,自动格式化日期型数据]
  • +*
  • Copyright 2010 RoadWay Co., Ltd.
  • +*
  • All right reserved.
  • +*
  • Created by [刘剑鸣] [Dec 5, 2010]
  • +*
  • Midified by [modifier] [modified time]
  • +* +*
  • 所需Jar包列表
  • +*
  • poi-3.7-20101029.jar
  • +*
  • poi-examples-3.7-20101029.jar
  • +*
  • poi-ooxml-3.7-2010102.jar
  • +*
  • poi-ooxml-schemas-3.7-2010102.jar
  • +*
  • xmlbeans-2.3.0.jar
  • +*
      +* +* @version 1.0 +*/ +public class POIExcelParser +{ + private Workbook workbook; + + private Sheet sheet; + + public int rows; + + public int startRow; + + private int columns; + + public POIExcelParser(File input, int sheetIndex, int columns, int startRow) throws FileNotFoundException, IOException + { + this.startRow = startRow; + this.columns = columns; + + workbook = new XSSFWorkbook(new FileInputStream(input)); + sheet = workbook.getSheetAt(sheetIndex); + rows = sheet.getPhysicalNumberOfRows(); + + System.out.println("excel文件一共要读取" + rows + "行数据"); + } + + public List parseLine() + { + List l = getLine(); + while (isEmpty(l)) + { + l = getLine(); + } + + return l; + } + + private boolean isEmpty(List l) + { + if (l == null) + { + return false; + } + + for (String string : l) + { + if (!string.trim().equals("")) + { + return false; + } + } + + return true; + } + + public List getLine() + { + if (startRow > rows - 1) + { + return null; + } + + List line = new ArrayList(); + + Row rows = sheet.getRow(startRow++); + if(rows!=null){ +// int cos = Math.min(columns, rows.getPhysicalNumberOfCells()); + int cos = sheet.getRow(0).getPhysicalNumberOfCells(); + for (int j = 0; j < cos; j++) + { + Cell cell = rows.getCell(j); + String cellValue = ""; + if(cell!=null){ + /** *//** 处理数字型的,自动去零 */ + if (Cell.CELL_TYPE_NUMERIC == cell.getCellType()) + { + /** *//** 在excel里,日期也是数字,在此要进行判断 */ + if (HSSFDateUtil.isCellDateFormatted(cell)) + { + cellValue = String.valueOf(DateUtil.getExcelDate(cell.getDateCellValue())); + } + else + { +// cellValue = getRightStr(cell.getNumericCellValue() + ""); + cellValue = cutZero(cell.getNumericCellValue()+""); + } + } + /** *//** 处理字符串型 */ + else if (Cell.CELL_TYPE_STRING == cell.getCellType()) + { + cellValue = cell.getStringCellValue(); + } + /** *//** 处理布尔型 */ + else if (Cell.CELL_TYPE_BOOLEAN == cell.getCellType()) + { + cellValue = cell.getBooleanCellValue() + ""; + } + /** *//** 其它的,非以上几种数据类型 */ + else + { + cellValue = cell.toString() + ""; + } + line.add(cellValue); + }else{ + line.add(cellValue); + } + } + + for (int j = 0; j < columns - cos + 1; j++) + { + line.add(""); + } + } + + + return line; + } + + /** *//** + *
        + *
      • Description:[正确地处理整数后自动加零的情况]
      • + *
      • Created by [Huyvanpull] [Jan 20, 2010]
      • + *
      • Midified by [modifier] [modified time]
      • + *
          + * + * @param sNum + * @return + */ + private String getRightStr(String sNum) + { + DecimalFormat decimalFormat = new DecimalFormat("#.000000"); + String resultStr = decimalFormat.format(new Double(sNum)); + if (resultStr.matches("^[-+]?\\d+\\.[0]+$")) + { + resultStr = resultStr.substring(0, resultStr.indexOf(".")); + } + return resultStr; + } + + /** + * 去掉小数点后面多余的零 + * + * @param v + * @return + */ + public String cutZero(String v) { + if (v.indexOf(".") > -1) { + while (true) { + if (v.lastIndexOf("0") == (v.length() - 1)) { + v = v.substring(0, v.lastIndexOf("0")); + } else { + break; + } + } + if (v.lastIndexOf(".") == (v.length() - 1)) { + v = v.substring(0, v.lastIndexOf(".")); + } + } + return v; + } + + public POIExcelParser(){ + + org.apache.poi.ss.usermodel.Workbook workbook; + try { + workbook = new XSSFWorkbook(new FileInputStream("D:\\reprot.xlsx")); +// workbook = new XSSFWorkbook(new FileInputStream("C:\\Users\\Administrator.SD-20101212HAVL\\Desktop\\material.xlsx")); + org.apache.poi.ss.usermodel.Sheet sheet = workbook.getSheetAt(0); + + for (int i = 0; i < 44; i++) + { + int cellCount = sheet.getRow(0).getPhysicalNumberOfCells(); + Row row = sheet.getRow(i); + if(row!=null){ + System.out.println("第"+i+"行有列数:"+cellCount); + for(int j=0;j1900){ + if(month.length()==2){ + if(Integer.parseInt(month)>0&&Integer.parseInt(month)<13){ + return true; + }else{ + System.out.println("月份不在1月和12月之间"); + } + }else{ + System.out.println("月中字符不等于2位"); + } + }else{ + System.out.println("年中字符不等于4位"); + } + } catch (NumberFormatException e) { + System.out.println("年或者月中含有非数字的字符"); + e.printStackTrace(); + } + } + return false; + } + + public static void main(String[] args){ + new POIExcelParser(); + } +} + diff --git a/src/com/connor/dev/imp/toolkit/.svn/text-base/POIExcelUtil.java.svn-base b/src/com/connor/dev/imp/toolkit/.svn/text-base/POIExcelUtil.java.svn-base new file mode 100644 index 0000000..c93afaf --- /dev/null +++ b/src/com/connor/dev/imp/toolkit/.svn/text-base/POIExcelUtil.java.svn-base @@ -0,0 +1,323 @@ +package com.origin.dev.imp.toolkit; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.List; + +import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.DateUtil; +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; + +/** *//** +*
            +*
          • Title:[POI基础上的Excel数据读取工具]
          • +*
          • Description: [支持Excell2003,Excell2007,自动格式化数值型数据,自动格式化日期型数据]
          • +*
          • Copyright 2010 RoadWay Co., Ltd.
          • +*
          • All right reserved.
          • +*
          • Created by [刘剑鸣] [Dec 5, 2010]
          • +*
          • Midified by [modifier] [modified time]
          • +* +*
          • 所需Jar包列表
          • +*
          • poi-3.7-20101029.jar
          • +*
          • poi-examples-3.7-20101029.jar
          • +*
          • poi-ooxml-3.7-2010102.jar
          • +*
          • poi-ooxml-schemas-3.7-2010102.jar
          • +*
          • xmlbeans-2.3.0.jar
          • +*
              +* +* @version 1.0 +*/ +public class POIExcelUtil +{ + /** *//** 总行数 */ + private int totalRows = 0; + + /** *//** 总列数 */ + private int totalCells = 0; + + /** *//** sheet页 */ + private Sheet sheet; + + /** *//** 构造方法 */ + public POIExcelUtil() + {} + + /** *//** + *
                + *
              • Description:[根据文件名读取excel文件]
              • + *
              • Created by [Huyvanpull] [Jan 20, 2010]
              • + *
              • Midified by [modifier] [modified time]
              • + *
                  + * + * @param fileName + * @return + * @throws Exception + */ + public List> read(String fileName) + { + List> dataLst = new ArrayList>(); + + /** *//** 检查文件名是否为空或者是否是Excel格式的文件 */ + if (fileName == null || !fileName.matches("^.+\\.(?i)((xls)|(xlsx))$")) + { + return dataLst; + } + + boolean isExcel2003 = true; + /** *//** 对文件的合法性进行验证 */ + if (fileName.matches("^.+\\.(?i)(xlsx)$")) + { + isExcel2003 = false; + } + + /** *//** 检查文件是否存在 */ + File file = new File(fileName); + if (file == null || !file.exists()) + { + return dataLst; + } + + try + { + /** *//** 调用本类提供的根据流读取的方法 */ + dataLst = read(new FileInputStream(file), isExcel2003); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + /** *//** 返回最后读取的结果 */ + return dataLst; + } + + /** *//** + *
                    + *
                  • Description:[根据流读取Excel文件]
                  • + *
                  • Created by [Huyvanpull] [Jan 20, 2010]
                  • + *
                  • Midified by [modifier] [modified time]
                  • + *
                      + * + * @param inputStream + * @param isExcel2003 + * @return + */ + public List> read(InputStream inputStream, + boolean isExcel2003) + { + List> dataLst = null; + try + { + /** *//** 根据版本选择创建Workbook的方式 */ + Workbook wb = isExcel2003 ? new HSSFWorkbook(inputStream) + : new XSSFWorkbook(inputStream); + dataLst = read(wb); + } + catch (IOException e) + { + e.printStackTrace(); + } + return dataLst; + } + + /** *//** + *
                        + *
                      • Description:[得到总行数]
                      • + *
                      • Created by [Huyvanpull] [Jan 20, 2010]
                      • + *
                      • Midified by [modifier] [modified time]
                      • + *
                          + * + * @return + */ + public int getTotalRows() + { + return totalRows; + } + + /** *//** + *
                            + *
                          • Description:[得到总列数]
                          • + *
                          • Created by [Huyvanpull] [Jan 20, 2010]
                          • + *
                          • Midified by [modifier] [modified time]
                          • + *
                              + * + * @return + */ + public int getTotalCells() + { + return totalCells; + } + + + public Sheet getSheet(){ + return sheet; + } + + /** *//** + *
                                + *
                              • Description:[读取数据]
                              • + *
                              • Created by [Huyvanpull] [Jan 20, 2010]
                              • + *
                              • Midified by [modifier] [modified time]
                              • + *
                                  + * + * @param wb + * @return + */ + private List> read(Workbook wb) + { + List> dataLst = new ArrayList>(); + + /** *//** 得到第一个shell */ + sheet = wb.getSheetAt(0); + this.totalRows = sheet.getPhysicalNumberOfRows(); + if (this.totalRows >= 1 && sheet.getRow(0) != null) + { + this.totalCells = sheet.getRow(0).getPhysicalNumberOfCells(); + } + + /** *//** 循环Excel的行 */ + for (int r = 0; r < this.totalRows; r++) + { + Row row = sheet.getRow(r); + if (row == null) + { + continue; + } + + ArrayList rowLst = new ArrayList(); + /** *//** 循环Excel的列 */ + for (short c = 0; c < this.getTotalCells(); c++) + { + Cell cell = row.getCell(c); + String cellValue = ""; + if (cell == null) + { + rowLst.add(cellValue); + continue; + } + + /** *//** 处理数字型的,自动去零 */ + if (Cell.CELL_TYPE_NUMERIC == cell.getCellType()) + { + /** *//** 在excel里,日期也是数字,在此要进行判断 */ + if (HSSFDateUtil.isCellDateFormatted(cell)) + { + cellValue = String.valueOf(DateUtil.getExcelDate(cell.getDateCellValue())); + } + else + { + cellValue = getRightStr(cell.getNumericCellValue() + ""); + } + } + /** *//** 处理字符串型 */ + else if (Cell.CELL_TYPE_STRING == cell.getCellType()) + { + cellValue = cell.getStringCellValue(); + } + /** *//** 处理布尔型 */ + else if (Cell.CELL_TYPE_BOOLEAN == cell.getCellType()) + { + cellValue = cell.getBooleanCellValue() + ""; + } + /** *//** 其它的,非以上几种数据类型 */ + else + { + cellValue = cell.toString() + ""; + } + + rowLst.add(cellValue); + } + dataLst.add(rowLst); + } + return dataLst; + } + + /** *//** + *
                                    + *
                                  • Description:[正确地处理整数后自动加零的情况]
                                  • + *
                                  • Created by [Huyvanpull] [Jan 20, 2010]
                                  • + *
                                  • Midified by [modifier] [modified time]
                                  • + *
                                      + * + * @param sNum + * @return + */ + private String getRightStr(String sNum) + { + DecimalFormat decimalFormat = new DecimalFormat("#.000000"); + String resultStr = decimalFormat.format(new Double(sNum)); + if (resultStr.matches("^[-+]?\\d+\\.[0]+$")) + { + resultStr = resultStr.substring(0, resultStr.indexOf(".")); + } + return resultStr; + } + + + /** *//** + *
                                        + *
                                      • Description:[测试main方法]
                                      • + *
                                      • Created by [Huyvanpull] [Dec 5, 2010]
                                      • + *
                                      • Midified by [modifier] [modified time]
                                      • + *
                                          + * + * @param args + * @throws Exception + */ + public static void main(String[] args) + { + System.out.println("123"); + List> dataLst = new POIExcelUtil() + .read("D:\\reprot.xlsx"); +// for (ArrayList innerLst : dataLst) +// { +// StringBuffer rowData = new StringBuffer(); +// for (String dataStr : innerLst) +// { +// rowData.append(",").append(dataStr); +// } +// if (rowData.length() > 0) +// { +// System.out.println(rowData.deleteCharAt(0).toString()); +// } +// } + for(int rowCount=0;rowCount rowDataList = dataLst.get(rowCount); + for(int i = 0;i 0) { + System.out.println("数据集的路径为" + filePath); + // String sep = ois.getArraySeparator(); + String[] files = filePath.split("\\|\\|"); + List fis = new ArrayList(); + for (int j = 0; j < files.length; j++) { + // File f = new + // File(input.getParent(), + // files[j]); + File f = new File(files[j]); + if (f.exists()) { + fis.add(f.getAbsolutePath()); + System.out.println("文件" + f.getAbsolutePath() + "存在"); + } else { + System.out.println("文件" + f.getAbsolutePath() + "不存在,不予以处理"); + } + } + } + } + } + } + + } +} + diff --git a/src/com/connor/dev/imp/toolkit/.svn/text-base/ProgressReporter.java.svn-base b/src/com/connor/dev/imp/toolkit/.svn/text-base/ProgressReporter.java.svn-base new file mode 100644 index 0000000..640b2d2 --- /dev/null +++ b/src/com/connor/dev/imp/toolkit/.svn/text-base/ProgressReporter.java.svn-base @@ -0,0 +1,127 @@ +package com.origin.dev.imp.toolkit; + +import java.awt.BorderLayout; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Toolkit; + +import javax.swing.JLabel; +import javax.swing.JProgressBar; +import javax.swing.JWindow; + +public class ProgressReporter extends JWindow implements Runnable +{ + private static final long serialVersionUID = 1L; + + private JLabel messageLabel; + + private JProgressBar progressBar; + + private boolean requestCanceling; + + private int percent; + + public ProgressReporter() + { + // setAlwaysOnTop(true); + setLayout(new BorderLayout()); + + initializeComponents(); + setTextPropertyForComponents(); + registerComponentsListeners(); + addComponents(); + + setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + } + + private void initializeComponents() + { + messageLabel = new JLabel(" ", JLabel.LEFT); + progressBar = new JProgressBar(); + } + + private void setTextPropertyForComponents() + { + // setTitle("处理进度"); + } + + private void registerComponentsListeners() + { + } + + private void addComponents() + { + add(messageLabel, BorderLayout.NORTH); + add(progressBar, BorderLayout.SOUTH); + } + + private void centerToClientScreen() + { + Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); + + int x = screen.width - getWidth(); + int y = screen.height - getHeight(); + + setLocation(x / 2, y / 2); + } + + public void reportProgressMessage(String message) + { + messageLabel.setText(message); + } + + public void setProgressPercent(int percent) + { + this.percent = percent; + } + + public void requestCanceling() + { + requestCanceling = true; + } + + public void setTaskRange(int min, int max) + { + progressBar.setMinimum(min); + progressBar.setMaximum(max); + } + + public void run() + { + pack(); + setSize(500, getHeight()); + centerToClientScreen(); + setVisible(true); + + while (!requestCanceling) + { + if (percent > progressBar.getMaximum()) + { + percent = 0; + } + + progressBar.setValue(percent); + + try + { + Thread.sleep(500); + } + catch (InterruptedException e) + { + continue; + } + } + + dispose(); + } + + public int getProgess() + { + return progressBar.getValue(); + } + + public boolean isRequestCanceling() + { + return requestCanceling; + } +} diff --git a/src/com/connor/dev/imp/toolkit/.svn/text-base/SearchUtility.java.svn-base b/src/com/connor/dev/imp/toolkit/.svn/text-base/SearchUtility.java.svn-base new file mode 100644 index 0000000..b317fa4 --- /dev/null +++ b/src/com/connor/dev/imp/toolkit/.svn/text-base/SearchUtility.java.svn-base @@ -0,0 +1,54 @@ +package com.origin.dev.imp.toolkit; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentContextList; +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.TCTextService; +import com.teamcenter.rac.util.MessageBox; + +public class SearchUtility { + + public static InterfaceAIFComponent[] searchComponentsCollection( + TCSession session, String searchName, String[] keys, String[] values) { + // 信息输出 + InterfaceAIFComponent[] result = new InterfaceAIFComponent[0]; + + try { + TCTextService textService = session.getTextService(); + TCComponentQueryType querytype = (TCComponentQueryType) session + .getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) querytype + .find(searchName); + querytype.clearCache(); + String[] as = new String[keys.length]; + for (int i = 0; i < keys.length; i++) { + as[i] = textService.getTextValue(keys[i]); + } + + String[] as1 = new String[values.length]; + for (int i = 0; i < values.length; i++) { + as1[i] = textService.getTextValue(values[i]); + } + + query.clearCache(); + TCComponentContextList list = query.getExecuteResultsList(as, as1); + if (list != null) { + int count = list.getListCount(); + result = new InterfaceAIFComponent[count]; + + for (int i = 0; i < count; i++) { + result[i] = list.get(i).getComponent(); + } + } + } catch (TCException e) { + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "通过查询构建器" + + searchName + "查询发生错误.", "错误", 1); + } + + return result; + } +} diff --git a/src/com/connor/dev/imp/toolkit/JXLExcelParser.java b/src/com/connor/dev/imp/toolkit/JXLExcelParser.java new file mode 100644 index 0000000..82c2e1e --- /dev/null +++ b/src/com/connor/dev/imp/toolkit/JXLExcelParser.java @@ -0,0 +1,114 @@ +package com.connor.dev.imp.toolkit; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import jxl.Cell; +import jxl.CellType; +import jxl.NumberCell; +import jxl.Sheet; +import jxl.Workbook; +import jxl.WorkbookSettings; +import jxl.read.biff.BiffException; + +public class JXLExcelParser +{ + private Workbook workbook; + + private Sheet sheet; + + public int rows; + + public int startRow; + + private int columns; + + public JXLExcelParser(File input, int sheetIndex, int columns, int startRow) throws BiffException, IOException + { + this.startRow = startRow; + this.columns = columns; + + WorkbookSettings ws = new WorkbookSettings(); + ws.setEncoding("ISO-8859-1"); + workbook = Workbook.getWorkbook(input, ws); + sheet = workbook.getSheet(sheetIndex); + rows = sheet.getRows(); + + System.out.println("excel文件一共要读取" + rows + "行数据"); + } + + public List parseLine() + { + List l = getLine(); + while (isEmpty(l)) + { + l = getLine(); + } + + return l; + } + + private boolean isEmpty(List l) + { + if (l == null) + { + return false; + } + + for (String string : l) + { + if (!string.trim().equals("")) + { + return false; + } + } + + return true; + } + + public List getLine() + { + if (startRow > rows - 1) + { + workbook.close(); + return null; + } + + List line = new ArrayList(); + + Cell[] cells = sheet.getRow(startRow++); + + int cos = Math.min(columns, cells.length); + for (int j = 0; j < cos; j++) + { + if(cells[j].getType()==CellType.NUMBER){ + NumberCell nc = (NumberCell) cells[j]; + double value = nc.getValue(); + String valstr=value+""; + for(int m=0;m<8;m++){ + if(valstr.endsWith("0")&&valstr.length()>1){ + valstr=valstr.substring(0,valstr.length()-1); + }else if(valstr.endsWith(".")&&valstr.length()>1){ + valstr=valstr.substring(0,valstr.length()-1); + }else{ + break; + } + } + line.add(valstr); + }else{ + line.add(cells[j].getContents().trim()); + } + + + } + + for (int j = 0; j < columns - cos + 1; j++) + { + line.add(""); + } + + return line; + } +} diff --git a/src/com/connor/dev/imp/toolkit/Logger.java b/src/com/connor/dev/imp/toolkit/Logger.java new file mode 100644 index 0000000..64292b9 --- /dev/null +++ b/src/com/connor/dev/imp/toolkit/Logger.java @@ -0,0 +1,24 @@ +package com.connor.dev.imp.toolkit; + +public class Logger +{ + public void debug(String message) + { + System.out.println("【debug】" + message); + } + + public void error(String message) + { + System.out.println("【error】" + message); + } + + public void info(String message) + { + System.out.println("【info】" + message); + } + + public void warn(String message) + { + System.out.println("【warn】" + message); + } +} diff --git a/src/com/connor/dev/imp/toolkit/POIExcelParser.java b/src/com/connor/dev/imp/toolkit/POIExcelParser.java new file mode 100644 index 0000000..16bb658 --- /dev/null +++ b/src/com/connor/dev/imp/toolkit/POIExcelParser.java @@ -0,0 +1,311 @@ +package com.connor.dev.imp.toolkit; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.List; + +import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.DateUtil; +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; + +/** */ +/** + *
                                            + *
                                          • Title:[POI基础上的Excel数据读取工具]
                                          • + *
                                          • Description: [支持Excell2003,Excell2007,自动格式化数值型数据,自动格式化日期型数据]
                                          • + *
                                          • Copyright 2010 RoadWay Co., Ltd.
                                          • + *
                                          • All right reserved.
                                          • + *
                                          • Created by [刘剑鸣] [Dec 5, 2010]
                                          • + *
                                          • Midified by [modifier] [modified time]
                                          • + * + *
                                          • 所需Jar包列表
                                          • + *
                                          • poi-3.7-20101029.jar
                                          • + *
                                          • poi-examples-3.7-20101029.jar
                                          • + *
                                          • poi-ooxml-3.7-2010102.jar
                                          • + *
                                          • poi-ooxml-schemas-3.7-2010102.jar
                                          • + *
                                          • xmlbeans-2.3.0.jar
                                          • + *
                                              + * + * @version 1.0 + */ +public class POIExcelParser { + private Workbook workbook; + + private Sheet sheet; + + public int rows; + + public int startRow; + + private int columns; + + public POIExcelParser(File input, int sheetIndex, int columns, int startRow) + throws FileNotFoundException, IOException { + this.startRow = startRow; + this.columns = columns; + + workbook = new XSSFWorkbook(new FileInputStream(input)); + sheet = workbook.getSheetAt(sheetIndex); + rows = sheet.getPhysicalNumberOfRows(); + + System.out.println("excel文件一共要读取" + rows + "行数据"); + } + + public List parseLine() { + List l = getLine(); + while (isEmpty(l)) { + l = getLine(); + } + + return l; + } + + private boolean isEmpty(List l) { + if (l == null) { + return false; + } + + for (String string : l) { + if (!string.equals("")) { + //if (!string.trim().equals("")) { + return false; + } + } + + return true; + } + + public List getLine() { + if (startRow > rows - 1) { + return null; + } + + List line = new ArrayList(); + // FormulaEvaluator + // FormulaEvaluator evaluator = + Row rows = sheet.getRow(startRow++); + if (rows != null) { + // int cos = Math.min(columns, rows.getPhysicalNumberOfCells()); + int cos = sheet.getRow(0).getPhysicalNumberOfCells(); + for (int j = 0; j < cos; j++) { + Cell cell = rows.getCell(j); + String cellValue = ""; + if (cell != null) { + /** */ + /** 处理数字型的,自动去零 */ +// if(Cell.CELL_TYPE_NUMERIC == cell.getCellType()){ +// cell.setCellType(Cell.CELL_TYPE_STRING);//将数值型转换成字符型 +// } + + if (Cell.CELL_TYPE_NUMERIC == cell.getCellType()) { + /** */ + /** 在excel里,日期也是数字,在此要进行判断 */ + if (HSSFDateUtil.isCellDateFormatted(cell)) { + cellValue = String.valueOf(DateUtil + .getExcelDate(cell.getDateCellValue())); + } else { + // cellValue = + // getRightStr(cell.getNumericCellValue() + ""); + DecimalFormat df = new DecimalFormat("0.00000000"); + //df.format(cell.getNumericCellValue()); + cellValue = cutZero(df.format(cell.getNumericCellValue())); + //cellValue = cutZero(cell.getNumericCellValue() + ""); + } + } + /** */ + /** 处理字符串型 */ + else if (Cell.CELL_TYPE_STRING == cell.getCellType()) { + cellValue = cell.getStringCellValue(); + } + /** */ + /** 处理布尔型 */ + else if (Cell.CELL_TYPE_BOOLEAN == cell.getCellType()) { + cellValue = cell.getBooleanCellValue() + ""; + }// 处理公式的 + else if (Cell.CELL_TYPE_FORMULA == cell.getCellType()) { + // + cell.setCellType(Cell.CELL_TYPE_STRING); + cellValue = cell.getStringCellValue(); + if (cellValue != null) { + cellValue = cellValue.replaceAll("#N/A", "").trim(); + } + } + /** */ + /** 其它的,非以上几种数据类型 */ + else { + cellValue = cell.toString() + ""; + } + line.add(cellValue); + } else { + line.add(cellValue); + } + } + + for (int j = 0; j < columns - cos + 1; j++) { + line.add(""); + } + } + + return line; + } + + /** */ + /** + *
                                                + *
                                              • Description:[正确地处理整数后自动加零的情况]
                                              • + *
                                              • Created by [Huyvanpull] [Jan 20, 2010]
                                              • + *
                                              • Midified by [modifier] [modified time]
                                              • + *
                                                  + * + * @param sNum + * @return + */ + private String getRightStr(String sNum) { + DecimalFormat decimalFormat = new DecimalFormat("#.000000"); + String resultStr = decimalFormat.format(new Double(sNum)); + if (resultStr.matches("^[-+]?\\d+\\.[0]+$")) { + resultStr = resultStr.substring(0, resultStr.indexOf(".")); + } + return resultStr; + } + + /** + * 去掉小数点后面多余的零 + * + * @param v + * @return + */ + public String cutZero(String v) { + if (v.indexOf(".") > -1) { + while (true) { + if (v.lastIndexOf("0") == (v.length() - 1)) { + v = v.substring(0, v.lastIndexOf("0")); + } else { + break; + } + } + if (v.lastIndexOf(".") == (v.length() - 1)) { + v = v.substring(0, v.lastIndexOf(".")); + } + } + return v; + } + + public POIExcelParser() { + + org.apache.poi.ss.usermodel.Workbook workbook; + try { + workbook = new XSSFWorkbook(new FileInputStream( + "C:\\Users\\hub\\Desktop\\A877图纸导入.xlsx")); + // workbook = new XSSFWorkbook(new + // FileInputStream("C:\\Users\\Administrator.SD-20101212HAVL\\Desktop\\material.xlsx")); + org.apache.poi.ss.usermodel.Sheet sheet = workbook.getSheetAt(0); + + for (int i = 0; i < 44; i++) { + int cellCount = sheet.getRow(0).getPhysicalNumberOfCells(); + Row row = sheet.getRow(i); + if (row != null) { + System.out.println("第" + i + "行有列数:" + cellCount); + for (int j = 0; j < cellCount; j++) { + System.out.println(i + "行" + j + "列"); + + Cell cell = row.getCell(j); + String cellValue = ""; + if (cell != null) { + /** */ + /** 处理数字型的,自动去零 */ + if (Cell.CELL_TYPE_NUMERIC == cell.getCellType()) { + /** */ + /** 在excel里,日期也是数字,在此要进行判断 */ + if (HSSFDateUtil.isCellDateFormatted(cell)) { + cellValue = String.valueOf(DateUtil + .getExcelDate(cell + .getDateCellValue())); + } else { + cellValue = getRightStr(cell + .getNumericCellValue() + ""); + System.out.println(cutZero(cell + .getNumericCellValue() + "")); + } + } + /** */ + /** 处理字符串型 */ + else if (Cell.CELL_TYPE_STRING == cell + .getCellType()) { + cellValue = cell.getStringCellValue(); + System.out.println(cellValue); + } + /** */ + /** 处理布尔型 */ + else if (Cell.CELL_TYPE_BOOLEAN == cell + .getCellType()) { + cellValue = cell.getBooleanCellValue() + ""; + System.out.println(cellValue); + } else if (Cell.CELL_TYPE_FORMULA == cell + .getCellType()) { + // + cell.setCellType(Cell.CELL_TYPE_STRING); + cellValue = cell.getStringCellValue(); + if (cellValue != null) { + cellValue = cellValue + .replaceAll("#N/A", "").trim(); + } + System.out.println(cellValue); + } + /** */ + /** 其它的,非以上几种数据类型 */ + else { + cellValue = cell.toString() + ""; + System.out.println(cellValue); + } + } + } + } + } + + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static boolean isDateFormat(String dataStr) { + if (dataStr.contains("-")) { + String year = dataStr.split("-")[0]; + String month = dataStr.split("-")[1]; + try { + if (year.length() == 4 && Integer.parseInt(year) > 1900) { + if (month.length() == 2) { + if (Integer.parseInt(month) > 0 + && Integer.parseInt(month) < 13) { + return true; + } else { + System.out.println("月份不在1月和12月之间"); + } + } else { + System.out.println("月中字符不等于2位"); + } + } else { + System.out.println("年中字符不等于4位"); + } + } catch (NumberFormatException e) { + System.out.println("年或者月中含有非数字的字符"); + e.printStackTrace(); + } + } + return false; + } + + public static void main(String[] args) { + new POIExcelParser(); + } +} diff --git a/src/com/connor/dev/imp/toolkit/POIExcelUtil.java b/src/com/connor/dev/imp/toolkit/POIExcelUtil.java new file mode 100644 index 0000000..c25fce6 --- /dev/null +++ b/src/com/connor/dev/imp/toolkit/POIExcelUtil.java @@ -0,0 +1,323 @@ +package com.connor.dev.imp.toolkit; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.List; + +import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.DateUtil; +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; + +/** *//** +*
                                                    +*
                                                  • Title:[POI基础上的Excel数据读取工具]
                                                  • +*
                                                  • Description: [支持Excell2003,Excell2007,自动格式化数值型数据,自动格式化日期型数据]
                                                  • +*
                                                  • Copyright 2010 RoadWay Co., Ltd.
                                                  • +*
                                                  • All right reserved.
                                                  • +*
                                                  • Created by [刘剑鸣] [Dec 5, 2010]
                                                  • +*
                                                  • Midified by [modifier] [modified time]
                                                  • +* +*
                                                  • 所需Jar包列表
                                                  • +*
                                                  • poi-3.7-20101029.jar
                                                  • +*
                                                  • poi-examples-3.7-20101029.jar
                                                  • +*
                                                  • poi-ooxml-3.7-2010102.jar
                                                  • +*
                                                  • poi-ooxml-schemas-3.7-2010102.jar
                                                  • +*
                                                  • xmlbeans-2.3.0.jar
                                                  • +*
                                                      +* +* @version 1.0 +*/ +public class POIExcelUtil +{ + /** *//** 总行数 */ + private int totalRows = 0; + + /** *//** 总列数 */ + private int totalCells = 0; + + /** *//** sheet页 */ + private Sheet sheet; + + /** *//** 构造方法 */ + public POIExcelUtil() + {} + + /** *//** + *
                                                        + *
                                                      • Description:[根据文件名读取excel文件]
                                                      • + *
                                                      • Created by [Huyvanpull] [Jan 20, 2010]
                                                      • + *
                                                      • Midified by [modifier] [modified time]
                                                      • + *
                                                          + * + * @param fileName + * @return + * @throws Exception + */ + public List> read(String fileName) + { + List> dataLst = new ArrayList>(); + + /** *//** 检查文件名是否为空或者是否是Excel格式的文件 */ + if (fileName == null || !fileName.matches("^.+\\.(?i)((xls)|(xlsx))$")) + { + return dataLst; + } + + boolean isExcel2003 = true; + /** *//** 对文件的合法性进行验证 */ + if (fileName.matches("^.+\\.(?i)(xlsx)$")) + { + isExcel2003 = false; + } + + /** *//** 检查文件是否存在 */ + File file = new File(fileName); + if (file == null || !file.exists()) + { + return dataLst; + } + + try + { + /** *//** 调用本类提供的根据流读取的方法 */ + dataLst = read(new FileInputStream(file), isExcel2003); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + /** *//** 返回最后读取的结果 */ + return dataLst; + } + + /** *//** + *
                                                            + *
                                                          • Description:[根据流读取Excel文件]
                                                          • + *
                                                          • Created by [Huyvanpull] [Jan 20, 2010]
                                                          • + *
                                                          • Midified by [modifier] [modified time]
                                                          • + *
                                                              + * + * @param inputStream + * @param isExcel2003 + * @return + */ + public List> read(InputStream inputStream, + boolean isExcel2003) + { + List> dataLst = null; + try + { + /** *//** 根据版本选择创建Workbook的方式 */ + Workbook wb = isExcel2003 ? new HSSFWorkbook(inputStream) + : new XSSFWorkbook(inputStream); + dataLst = read(wb); + } + catch (IOException e) + { + e.printStackTrace(); + } + return dataLst; + } + + /** *//** + *
                                                                + *
                                                              • Description:[得到总行数]
                                                              • + *
                                                              • Created by [Huyvanpull] [Jan 20, 2010]
                                                              • + *
                                                              • Midified by [modifier] [modified time]
                                                              • + *
                                                                  + * + * @return + */ + public int getTotalRows() + { + return totalRows; + } + + /** *//** + *
                                                                    + *
                                                                  • Description:[得到总列数]
                                                                  • + *
                                                                  • Created by [Huyvanpull] [Jan 20, 2010]
                                                                  • + *
                                                                  • Midified by [modifier] [modified time]
                                                                  • + *
                                                                      + * + * @return + */ + public int getTotalCells() + { + return totalCells; + } + + + public Sheet getSheet(){ + return sheet; + } + + /** *//** + *
                                                                        + *
                                                                      • Description:[读取数据]
                                                                      • + *
                                                                      • Created by [Huyvanpull] [Jan 20, 2010]
                                                                      • + *
                                                                      • Midified by [modifier] [modified time]
                                                                      • + *
                                                                          + * + * @param wb + * @return + */ + private List> read(Workbook wb) + { + List> dataLst = new ArrayList>(); + + /** *//** 得到第一个shell */ + sheet = wb.getSheetAt(0); + this.totalRows = sheet.getPhysicalNumberOfRows(); + if (this.totalRows >= 1 && sheet.getRow(0) != null) + { + this.totalCells = sheet.getRow(0).getPhysicalNumberOfCells(); + } + + /** *//** 循环Excel的行 */ + for (int r = 0; r < this.totalRows; r++) + { + Row row = sheet.getRow(r); + if (row == null) + { + continue; + } + + ArrayList rowLst = new ArrayList(); + /** *//** 循环Excel的列 */ + for (short c = 0; c < this.getTotalCells(); c++) + { + Cell cell = row.getCell(c); + String cellValue = ""; + if (cell == null) + { + rowLst.add(cellValue); + continue; + } + + /** *//** 处理数字型的,自动去零 */ + if (Cell.CELL_TYPE_NUMERIC == cell.getCellType()) + { + /** *//** 在excel里,日期也是数字,在此要进行判断 */ + if (HSSFDateUtil.isCellDateFormatted(cell)) + { + cellValue = String.valueOf(DateUtil.getExcelDate(cell.getDateCellValue())); + } + else + { + cellValue = getRightStr(cell.getNumericCellValue() + ""); + } + } + /** *//** 处理字符串型 */ + else if (Cell.CELL_TYPE_STRING == cell.getCellType()) + { + cellValue = cell.getStringCellValue(); + } + /** *//** 处理布尔型 */ + else if (Cell.CELL_TYPE_BOOLEAN == cell.getCellType()) + { + cellValue = cell.getBooleanCellValue() + ""; + } + /** *//** 其它的,非以上几种数据类型 */ + else + { + cellValue = cell.toString() + ""; + } + + rowLst.add(cellValue); + } + dataLst.add(rowLst); + } + return dataLst; + } + + /** *//** + *
                                                                            + *
                                                                          • Description:[正确地处理整数后自动加零的情况]
                                                                          • + *
                                                                          • Created by [Huyvanpull] [Jan 20, 2010]
                                                                          • + *
                                                                          • Midified by [modifier] [modified time]
                                                                          • + *
                                                                              + * + * @param sNum + * @return + */ + private String getRightStr(String sNum) + { + DecimalFormat decimalFormat = new DecimalFormat("#.000000"); + String resultStr = decimalFormat.format(new Double(sNum)); + if (resultStr.matches("^[-+]?\\d+\\.[0]+$")) + { + resultStr = resultStr.substring(0, resultStr.indexOf(".")); + } + return resultStr; + } + + + /** *//** + *
                                                                                + *
                                                                              • Description:[测试main方法]
                                                                              • + *
                                                                              • Created by [Huyvanpull] [Dec 5, 2010]
                                                                              • + *
                                                                              • Midified by [modifier] [modified time]
                                                                              • + *
                                                                                  + * + * @param args + * @throws Exception + */ + public static void main(String[] args) + { + System.out.println("123"); + List> dataLst = new POIExcelUtil() + .read("D:\\reprot.xlsx"); +// for (ArrayList innerLst : dataLst) +// { +// StringBuffer rowData = new StringBuffer(); +// for (String dataStr : innerLst) +// { +// rowData.append(",").append(dataStr); +// } +// if (rowData.length() > 0) +// { +// System.out.println(rowData.deleteCharAt(0).toString()); +// } +// } + for(int rowCount=0;rowCount rowDataList = dataLst.get(rowCount); + for(int i = 0;i 0) { + System.out.println("数据集的路径为" + filePath); + // String sep = ois.getArraySeparator(); + String[] files = filePath.split("\\|\\|"); + List fis = new ArrayList(); + for (int j = 0; j < files.length; j++) { + // File f = new + // File(input.getParent(), + // files[j]); + File f = new File(files[j]); + if (f.exists()) { + fis.add(f.getAbsolutePath()); + System.out.println("文件" + f.getAbsolutePath() + "存在"); + } else { + System.out.println("文件" + f.getAbsolutePath() + "不存在,不予以处理"); + } + } + } + } + } + } + + } +} + diff --git a/src/com/connor/dev/imp/toolkit/ProgressReporter.java b/src/com/connor/dev/imp/toolkit/ProgressReporter.java new file mode 100644 index 0000000..248d686 --- /dev/null +++ b/src/com/connor/dev/imp/toolkit/ProgressReporter.java @@ -0,0 +1,127 @@ +package com.connor.dev.imp.toolkit; + +import java.awt.BorderLayout; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Toolkit; + +import javax.swing.JLabel; +import javax.swing.JProgressBar; +import javax.swing.JWindow; + +public class ProgressReporter extends JWindow implements Runnable +{ + private static final long serialVersionUID = 1L; + + private JLabel messageLabel; + + private JProgressBar progressBar; + + private boolean requestCanceling; + + private int percent; + + public ProgressReporter() + { + // setAlwaysOnTop(true); + setLayout(new BorderLayout()); + + initializeComponents(); + setTextPropertyForComponents(); + registerComponentsListeners(); + addComponents(); + + setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + } + + private void initializeComponents() + { + messageLabel = new JLabel(" ", JLabel.LEFT); + progressBar = new JProgressBar(); + } + + private void setTextPropertyForComponents() + { + // setTitle("处理进度"); + } + + private void registerComponentsListeners() + { + } + + private void addComponents() + { + add(messageLabel, BorderLayout.NORTH); + add(progressBar, BorderLayout.SOUTH); + } + + private void centerToClientScreen() + { + Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); + + int x = screen.width - getWidth(); + int y = screen.height - getHeight(); + + setLocation(x / 2, y / 2); + } + + public void reportProgressMessage(String message) + { + messageLabel.setText(message); + } + + public void setProgressPercent(int percent) + { + this.percent = percent; + } + + public void requestCanceling() + { + requestCanceling = true; + } + + public void setTaskRange(int min, int max) + { + progressBar.setMinimum(min); + progressBar.setMaximum(max); + } + + public void run() + { + pack(); + setSize(500, getHeight()); + centerToClientScreen(); + setVisible(true); + + while (!requestCanceling) + { + if (percent > progressBar.getMaximum()) + { + percent = 0; + } + + progressBar.setValue(percent); + + try + { + Thread.sleep(500); + } + catch (InterruptedException e) + { + continue; + } + } + + dispose(); + } + + public int getProgess() + { + return progressBar.getValue(); + } + + public boolean isRequestCanceling() + { + return requestCanceling; + } +} diff --git a/src/com/connor/dev/imp/toolkit/SearchUtility.java b/src/com/connor/dev/imp/toolkit/SearchUtility.java new file mode 100644 index 0000000..72efe0a --- /dev/null +++ b/src/com/connor/dev/imp/toolkit/SearchUtility.java @@ -0,0 +1,63 @@ +package com.connor.dev.imp.toolkit; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentContextList; +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.TCTextService; +import com.teamcenter.rac.util.MessageBox; + +public class SearchUtility { + + public static InterfaceAIFComponent[] searchComponentsCollection(TCSession session, String searchName, + String[] keys, String[] values) { + // 信息输出 + InterfaceAIFComponent[] result = new InterfaceAIFComponent[0]; + + try { + TCTextService textService = session.getTextService(); + TCComponentQueryType querytype = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) querytype.find(searchName); + querytype.clearCache(); +// String[] as = new String[keys.length]; +// for (int i = 0; i < keys.length; i++) { +// as[i] = textService.getTextValue(keys[i]); +// } +// +// String[] as1 = new String[values.length]; +// for (int i = 0; i < values.length; i++) { +// as1[i] = textService.getTextValue(values[i]); +// } +// if (query == null) { +// MessageBox.post("没有查找到:" + searchName + "查询", "错误", 0); +// return null; +// } + try { + System.out.println("comp length:"+session.search(searchName, keys, values).length); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + query.clearCache(); + TCComponentContextList list = query.getExecuteResultsList(keys, values); + if (list != null) { + int count = list.getListCount(); + result = new InterfaceAIFComponent[count]; + + for (int i = 0; i < count; i++) { + result[i] = list.get(i).getComponent(); + } + } + } catch (TCException e) { + + e.printStackTrace(); + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), "通过查询构建器" + searchName + "查询发生错误.", "错误", 1); + + } + + return result; + } +} diff --git a/src/com/connor/dfl/plm/Activator.java b/src/com/connor/dfl/plm/Activator.java new file mode 100644 index 0000000..08f60ff --- /dev/null +++ b/src/com/connor/dfl/plm/Activator.java @@ -0,0 +1,61 @@ +package com.connor.dfl.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.dfl.plm"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + 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/dfl/plm/actions/SampleAction.java b/src/com/connor/dfl/plm/actions/SampleAction.java new file mode 100644 index 0000000..567d41b --- /dev/null +++ b/src/com/connor/dfl/plm/actions/SampleAction.java @@ -0,0 +1,64 @@ +package com.connor.dfl.plm.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.jface.dialogs.MessageDialog; + +/** + * Our sample action implements workbench action delegate. + * The action proxy will be created by the workbench and + * shown in the UI. When the user tries to use the action, + * this delegate will be created and execution will be + * delegated to it. + * @see IWorkbenchWindowActionDelegate + */ +public class SampleAction implements IWorkbenchWindowActionDelegate { + private IWorkbenchWindow window; + /** + * The constructor. + */ + public SampleAction() { + } + + /** + * The action has been activated. The argument of the + * method represents the 'real' action sitting + * in the workbench UI. + * @see IWorkbenchWindowActionDelegate#run + */ + public void run(IAction action) { + MessageDialog.openInformation( + window.getShell(), + "Plm", + "Hello, Eclipse world"); + } + + /** + * Selection in the workbench has been changed. We + * can change the state of the 'real' action here + * if we want, but this can only happen after + * the delegate has been created. + * @see IWorkbenchWindowActionDelegate#selectionChanged + */ + public void selectionChanged(IAction action, ISelection selection) { + } + + /** + * We can use this method to dispose of any system + * resources we previously allocated. + * @see IWorkbenchWindowActionDelegate#dispose + */ + public void dispose() { + } + + /** + * We will cache window object in order to + * be able to provide parent shell for the message dialog. + * @see IWorkbenchWindowActionDelegate#init + */ + public void init(IWorkbenchWindow window) { + this.window = window; + } +} \ No newline at end of file diff --git a/src/com/connor/dfl/plm/cadhandler/CreateCADModelHandler.java b/src/com/connor/dfl/plm/cadhandler/CreateCADModelHandler.java new file mode 100644 index 0000000..4185f31 --- /dev/null +++ b/src/com/connor/dfl/plm/cadhandler/CreateCADModelHandler.java @@ -0,0 +1,27 @@ +package com.connor.dfl.plm.cadhandler; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + + +public class CreateCADModelHandler extends AbstractHandler { + private AbstractAIFUIApplication app; + private TCSession session; + String opType = ""; + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + this.session = (TCSession) app.getSession(); + opType = arg0.getCommand().getId(); + CreateCADOperation operation = new CreateCADOperation(app,session,opType); + System.out.println("CAD模板"); + session.queueOperation(operation); + return null; + } +} + diff --git a/src/com/connor/dfl/plm/cadhandler/CreateCADOperation.java b/src/com/connor/dfl/plm/cadhandler/CreateCADOperation.java new file mode 100644 index 0000000..18db011 --- /dev/null +++ b/src/com/connor/dfl/plm/cadhandler/CreateCADOperation.java @@ -0,0 +1,122 @@ +package com.connor.dfl.plm.cadhandler; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +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.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +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.kernel.ics.ICSSearchResult; +import com.teamcenter.rac.util.MessageBox; + +public class CreateCADOperation extends AbstractAIFOperation{ + private AbstractAIFUIApplication app; + private TCSession session; + String opType = ""; + TCComponentDataset dateset ; + + public CreateCADOperation(AbstractAIFUIApplication app, TCSession session, String opType) { + this.app = app; + this.session = session; + this.opType = opType; + } + + @Override + public void executeOperation() throws Exception { + + System.out.println("====================" + opType); + InterfaceAIFComponent targetComp = app.getTargetComponent(); + // TODO Auto-generated method stub + String[] stringArray = session.getPreferenceService().getStringValues( + "DFL2_CAD"); + if (stringArray == null || stringArray.length <= 0 ) { + + MessageBox.post("首选项DFL2_CAD未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + } + + + //总部-A0-中文:数据集PUID + String uid = ""; + for(int i = 0 ;i 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/dfl/plm/dfl001/Dfl001Handler.java b/src/com/connor/dfl/plm/dfl001/Dfl001Handler.java new file mode 100644 index 0000000..b91f267 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl001/Dfl001Handler.java @@ -0,0 +1,25 @@ +package com.connor.dfl.plm.dfl001; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + + +public class Dfl001Handler extends AbstractHandler { + private AbstractAIFUIApplication app; + private TCSession session; + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + this.session = (TCSession) app.getSession(); + Dfl001Operation operation = new Dfl001Operation(app,session); + System.out.println("开始获取分类属性======================"); + session.queueOperation(operation); + return null; + } +} + diff --git a/src/com/connor/dfl/plm/dfl001/Dfl001Operation.java b/src/com/connor/dfl/plm/dfl001/Dfl001Operation.java new file mode 100644 index 0000000..73c7864 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl001/Dfl001Operation.java @@ -0,0 +1,235 @@ +package com.connor.dfl.plm.dfl001; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +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.TCComponentICO; +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.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; + + + +public class Dfl001Operation extends AbstractAIFOperation{ + private AbstractAIFUIApplication app; + private TCSession session; + private List attrList; + public Dfl001Operation(AbstractAIFUIApplication app, TCSession session) { + this.app = app; + this.session = session; + + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + ParseXMLUtil xml=new ParseXMLUtil(); + File file=xml.getSXX("DFL_CLASS_Xml", session); + attrList =xml.parseXMLCode(file); + if(attrList == null || attrList.size() <= 0) { + MessageBox.post("首选项DFL_CLASS_Xml未配置,请检查!", "WARNING", + MessageBox.WARNING); + return; + } + InterfaceAIFComponent[] comps = app.getTargetComponents(); + List beanList = getItemValue(comps); + for (int i = 0; i < beanList.size(); i++) { + ItemBean bean = beanList.get(i); + System.out.println("品号====="+bean.getItem_id()+ + "品名============"+bean.getItem_name()+ + "品牌============"+bean.getItem_brand()+ + "分群码============"+bean.getItem_groupCode()+ + "版本============"+bean.getItem_rev()+ + "来源码============"+bean.getItem_sourceCode()+ + "规格============"+bean.getItem_spec()+ + "单位============"+bean.getItem_unit()); + + } + } + public List getItemValue(InterfaceAIFComponent[] comps) { + List beanList = new ArrayList(); + + for (int i = 0; i < comps.length; i++) { + InterfaceAIFComponent comp = comps[i]; + if(comp instanceof TCComponentItemRevision ) { + ItemBean bean = new ItemBean(); + String spec = ""; + String unit = ""; + String brand =""; + TCComponentItemRevision rev = (TCComponentItemRevision) comp; + try { + bean.setItem_id(rev.getStringProperty("item_id")); + bean.setItem_name(rev.getStringProperty("object_name")); + TCProperty groupCodeProp = rev.getTCProperty("t2_groupCode"); + TCComponentListOfValues groupCodeLov = groupCodeProp.getLOV(); + String[] groupCodeVals = groupCodeLov.getListOfValues().getStringListOfValues(); + String groupCode = rev.getStringProperty("t2_groupCode"); + for (String val : groupCodeVals) { + String al = groupCodeLov.getListOfValues().getDisplayableValue(val); + if(al.equals(groupCode)) { + bean.setItem_groupCode(val); + break; + } + } + TCProperty sourceCodeProp = rev.getTCProperty("t2_sourceCode"); + TCComponentListOfValues sourceCodeLov = sourceCodeProp.getLOV(); + String[] sourceCodeVals = sourceCodeLov.getListOfValues().getStringListOfValues(); + String sourceCode = rev.getStringProperty("t2_sourceCode"); + for (String val : sourceCodeVals) { + String al = sourceCodeLov.getListOfValues().getDisplayableValue(val); + if(al.equals(sourceCode)) { + bean.setItem_sourceCode(val); + break; + } + } + bean.setItem_rev(rev.getStringProperty("item_revision_id")); + String type = rev.getStringProperty("object_type"); + if("T2_outsourceRevision".equals(type)) { + spec = getOutsourceValue(rev); + unit = rev.getStringProperty("t2_unit"); + }else if("T2_OutBuyPartRevision".equals(type)) { + List vals= getOutBuyPartValue(rev); + brand = vals.get(0); + unit = vals.get(1); + spec = vals.get(2); + } + // else if("T2_VirtualRevision".equals(type) || + // "T2_EquipmentRevision".equals(type) || + // "T2_SystemSchemeRevision".equals(type)) { + // + // } + bean.setItem_spec(spec); + bean.setItem_unit(unit); + bean.setItem_brand(brand); + beanList.add(bean); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + return beanList; + } + + private List getOutBuyPartValue(TCComponentItemRevision rev) { + // TODO Auto-generated method stub + List vals = new ArrayList(); + StringBuilder sb = new StringBuilder(); + List classPropList = new ArrayList(); + TCClassificationService classificationService = session.getClassificationService(); + try { + String className = rev.getClassificationClass(); + TCComponentICO[] icos = rev.getClassificationObjects(); + 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); + System.out.println("classValue=================="+classValue); + if(classValue.contains(";")) { + String[] classValues = classValue.split(";"); + if(className.equals(classValues[0])) { + for (int k = 1; k < classValues.length; k++) { + String attrName = classValues[k]; + System.out.println("attrName=================="+attrName); + for (int i = 0; i < classPropList.size(); i++) { + ClassPropBean bean = classPropList.get(i); + System.out.println("bean.propDisName=================="+bean.propDisName); + if(attrName.equals(bean.propDisName)) { + String value = claMap.get(bean.propID); + System.out.println("bean.propID=================="+bean.propID); + if(bean.isLov) { + String lovValue = bean.lovMapping.get(value); + System.out.println("lovValue===================="+lovValue); + if("品牌".equals(attrName) || "单位".equals(attrName)) { + vals.add(lovValue); + }else { + sb.append(lovValue); + if(k < classValues.length-1) { + sb.append(";"); + } + } + }else { + if("品牌".equals(attrName) || "单位".equals(attrName)) { + vals.add(value); + }else { + System.out.println("value===================="+value); + sb.append(value); + if(k < classValues.length-1) { + sb.append(";"); + } + } + } + break; + } + } + } + break; + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + String spec = sb.toString(); + vals.add(spec); + return vals; + } + + private String getOutsourceValue(TCComponentItemRevision rev) { + // TODO Auto-generated method stub + StringBuilder sb = new StringBuilder(); + try { + sb.append(rev.getStringProperty("t2_Importance")); + sb.append(";"); + sb.append(rev.getStringProperty("t2_material")); + sb.append(";"); + sb.append(rev.getStringProperty("t2_MASS")); + sb.append(";"); + sb.append(rev.getStringProperty("t2_Specifications")); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + String spec = sb.toString(); + return spec; + } +} + diff --git a/src/com/connor/dfl/plm/dfl001/ItemBean.java b/src/com/connor/dfl/plm/dfl001/ItemBean.java new file mode 100644 index 0000000..b729d18 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl001/ItemBean.java @@ -0,0 +1,62 @@ +package com.connor.dfl.plm.dfl001; + +public class ItemBean { + + private String item_id; //品号 item_id + private String item_name; //品名 object_name + private String item_spec; //规格 + private String item_groupCode; //分群码 t2_groupCode + private String item_unit; //单位 t2_unit + private String item_sourceCode; //来源码 t2_sourceCode + private String item_brand; //品牌 + private String item_rev; //版本 item_revision_id + public String getItem_id() { + return item_id; + } + public void setItem_id(String item_id) { + this.item_id = item_id; + } + public String getItem_name() { + return item_name; + } + public void setItem_name(String item_name) { + this.item_name = item_name; + } + public String getItem_spec() { + return item_spec; + } + public void setItem_spec(String item_spec) { + this.item_spec = item_spec; + } + public String getItem_groupCode() { + return item_groupCode; + } + public void setItem_groupCode(String item_groupCode) { + this.item_groupCode = item_groupCode; + } + public String getItem_unit() { + return item_unit; + } + public void setItem_unit(String item_unit) { + this.item_unit = item_unit; + } + public String getItem_sourceCode() { + return item_sourceCode; + } + public void setItem_sourceCode(String item_sourceCode) { + this.item_sourceCode = item_sourceCode; + } + public String getItem_brand() { + return item_brand; + } + public void setItem_brand(String item_brand) { + this.item_brand = item_brand; + } + public String getItem_rev() { + return item_rev; + } + public void setItem_rev(String item_rev) { + this.item_rev = item_rev; + } + +} diff --git a/src/com/connor/dfl/plm/dfl001/ParseXMLUtil.java b/src/com/connor/dfl/plm/dfl001/ParseXMLUtil.java new file mode 100644 index 0000000..e9e1e4a --- /dev/null +++ b/src/com/connor/dfl/plm/dfl001/ParseXMLUtil.java @@ -0,0 +1,123 @@ +package com.connor.dfl.plm.dfl001; + +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +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"); + System.out.println("classID===================="+classID); + 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"); + System.out.println("name===================="+name); + 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; + } + + /** + * 通过首选项里的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) { + MessageBox.post("数据集没有命名引用的文件或文件过多,请检查!", "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:\\2.xml"); +// ParseXML t = new ParseXML(); +// // t.parseXML(file); +// t.parseXMLCode(file2); +// } +} diff --git a/src/com/connor/dfl/plm/dfl002/Dfl002Handler.java b/src/com/connor/dfl/plm/dfl002/Dfl002Handler.java new file mode 100644 index 0000000..bad5e50 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl002/Dfl002Handler.java @@ -0,0 +1,26 @@ +package com.connor.dfl.plm.dfl002; + +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.TCSession; + + +public class Dfl002Handler extends AbstractHandler { + private AbstractAIFUIApplication app; + private TCSession session; + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + this.session = (TCSession) app.getSession(); + InterfaceAIFComponent target = app.getTargetComponent(); + Dfl002Operation operation = new Dfl002Operation(app,session,target); + session.queueOperation(operation); + return null; + } +} + diff --git a/src/com/connor/dfl/plm/dfl002/Dfl002Operation.java b/src/com/connor/dfl/plm/dfl002/Dfl002Operation.java new file mode 100644 index 0000000..681a12b --- /dev/null +++ b/src/com/connor/dfl/plm/dfl002/Dfl002Operation.java @@ -0,0 +1,57 @@ +package com.connor.dfl.plm.dfl002; + + +import com.connor.dfl.plm.exportBOM.ChangeDbomUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + + +public class Dfl002Operation extends AbstractAIFOperation{ + private AbstractAIFUIApplication app; + private TCSession session; + private InterfaceAIFComponent target; + public Dfl002Operation(AbstractAIFUIApplication app, TCSession session, InterfaceAIFComponent target) { + this.app = app; + this.session = session; + this.target = target; + } + + @Override + public void executeOperation() throws Exception { + try { + System.out.println("开旁路"); + ChangeDbomUtil.setByPass(true); + } catch (TCException e2) { + e2.printStackTrace(); + } + // TODO Auto-generated method stub + try { + if(target instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) target; + TCComponentItem item = rev.getItem(); + String class_id = rev.getStringProperty("t2_classifyID"); + String id = item.getStringProperty("item_id"); + StringBuffer sb = new StringBuffer(id); + sb.append(class_id); + String item_id = sb.toString(); + item.setStringProperty("item_id", item_id); + System.out.println("item_id================="+item_id); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + try { + ChangeDbomUtil.setByPass(false); + System.out.println("关旁路"); + } catch (TCException e2) { + e2.printStackTrace(); + } + } +} + diff --git a/src/com/connor/dfl/plm/dfl003/Dfl003AIFDialog.java b/src/com/connor/dfl/plm/dfl003/Dfl003AIFDialog.java new file mode 100644 index 0000000..7315745 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl003/Dfl003AIFDialog.java @@ -0,0 +1,850 @@ +package com.connor.dfl.plm.dfl003; + +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.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JComboBox; +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.border.LineBorder; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; + +import com.connor.dfl.plm.util.CodeBean; +import com.connor.dfl.plm.util.CopyPropsBean; +import com.connor.dfl.plm.util.DataBaseControl; +import com.connor.dfl.plm.util.GetCodeBean; +import com.connor.dfl.plm.util.MenuBean; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.ServiceData; +import com.teamcenter.rac.kernel.SoaUtil; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemRevisionType; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Utilities; + +public class Dfl003AIFDialog extends AbstractAIFDialog { + private TCSession session; + private TCPreferenceService service; + private InterfaceAIFComponent targetComp; + private String name; + private MenuBean menuBean; + private JPanel jp1; + private JPanel jp2; + private JTextField jtext1; + private JTextField jtext2; + private JTextField jtext3; + private JTextField jtext4; + private JTextField jtext5; + private JTextField jtext6; + private JTextArea jtext8; + private JTextField jtext10; + + // private List codeBeanList; + private CodeBean selCodeBean; + private JButton okBut = new JButton("确定"); + private JButton celBut = new JButton("取消"); + private GetCodeBean getcode; + private String selnodename = ""; + private JComboBox jcomname=new JComboBox(); + private Map nameMap=new HashMap(); + private Map unitMap=new HashMap(); + private JComboBox jcomproject=new JComboBox(); + private JComboBox jcomunit=new JComboBox(); + private boolean islov=false; + + private Map groupMap=new HashMap(); + private Map sourceMap=new HashMap(); + private Map ImportanceMap=new HashMap(); + + + + private JComboBox groupCode_combobox; + private JComboBox sourceCode_combobox; + private JComboBox Importantce_combobox; + + + + public Dfl003AIFDialog(TCSession session, InterfaceAIFComponent targetComp, + String name) { + this.session = session; + this.service = session.getPreferenceService(); + this.targetComp = targetComp; + this.name = name; + } + + + @Override + public void run() { + // TODO Auto-generated method stub + getcode = new GetCodeBean(session); + menuBean = getcode.getMenuBean(name); + // codeBeanList = bean.getCodeBeanList(); + + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + + /** + * 判断名称是否lov + */ + private void getNameLov(String type) { + // TODO Auto-generated method stub + try { + TCComponentItemType tctype = (TCComponentItemType) session + .getTypeComponent(type); + TCPropertyDescriptor propertyDescriptor = tctype.getPropertyDescriptor("object_name"); + TCComponentListOfValues lov = propertyDescriptor.getLOV(); + if (lov!=null) { + islov=true; + String[] strs=lov.getListOfValues().getStringListOfValues();//所有真实值 + for(String s1:strs){ + String a1 = lov.getListOfValues().getDisplayableValue(s1);//该真实值对应的显示值 + jcomname.addItem(a1); + System.out.println(s1+"-----"+a1); + nameMap.put(a1, s1);//显示:真实 + } + }else{ + islov=false; + } + if (islov) { + jcomname.setBounds(60, 100, 120, 30); + jp2.add(jcomname); + }else{ + jtext3.setBounds(60, 100, 120, 30); + jp2.add(jtext3); + } + String[] values = new String[]{}; + + String lovname=service.getStringValue("T2_unitsLOV");//"T2_unitsLOV" + System.out.println("lovname="+lovname); + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lov1 = lovType.find(lovname); + System.out.println("lov1="+lov1.length); + if(lov1.length > 0){ + ListOfValuesInfo value = lov1[0].getListOfValues(); + values = value.getStringListOfValues(); + for (int i = 0; i < values.length; i++) { + String disval = value.getDisplayableValue(values[i]); + jcomunit.addItem(disval); + unitMap.put(disval, values[i]); + } + + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + /** + * 主页面 + * @throws TCException + */ + private void init() throws TCException { + // TODO Auto-generated method stub + this.setTitle("创建" + name); + this.setAlwaysOnTop(true); + this.setPreferredSize(new Dimension(550, 630)); + this.setLayout(new PropertyLayout()); + jp1 = new JPanel(new BorderLayout()); + jp2 = new JPanel(new PropertyLayout()); + jp1.setPreferredSize(new Dimension(250, 450)); + jp2.setPreferredSize(new Dimension(390, 570)); + JTree tree = getTree(menuBean); + tree.addTreeSelectionListener(new TreeSelectionListener() { + public void valueChanged(TreeSelectionEvent e) { + DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) e + .getPath().getLastPathComponent(); + int childCount = treeNode.getChildCount(); + System.out.println("当前被选中的节点: " + treeNode + " 子节点数量:" + + childCount); + selnodename = ""; + if (childCount > 0) { + jp2.setVisible(false); + } else { + jp2.setVisible(true); + setTextStr(treeNode); + } + + } + }); + JScrollPane scrollPane = new JScrollPane(tree); + scrollPane.setPreferredSize(new Dimension(250, 250)); + ; + // 添加滚动面板到那内容面板 + jp1.add(scrollPane, BorderLayout.CENTER); + + JLabel jl1 = new JLabel("ID:"); + JLabel jl2 = new JLabel("版本:"); + JLabel jl3 = new JLabel("名称:"); + JLabel jl5 = new JLabel("材质:"); + JLabel jl6 = new JLabel("重量:"); + JLabel jl7 = new JLabel("单位:"); + JLabel jl8 = new JLabel("规格:"); + JLabel jl9 = new JLabel("项目:"); + JLabel jl10 = new JLabel("旧品号:"); + + JLabel groupCode_lable = new JLabel("分群码:"); + JLabel sourceCode_lable = new JLabel("来源码:"); + JLabel Important_lable = new JLabel("关键件:"); + + groupCode_combobox = new JComboBox();groupCode_combobox.addItem(name); + sourceCode_combobox = new JComboBox();sourceCode_combobox.addItem("自制件"); + Importantce_combobox = new JComboBox();Importantce_combobox.addItem("A"); + + jtext1 = new JTextField(); + jtext2 = new JTextField(); + jtext3 = new JTextField(); + jtext4 = new JTextField(); + jtext5 = new JTextField(); + jtext6 = new JTextField(); + jtext8 = new JTextArea(); + jtext8.setLineWrap(true); + jtext8.setWrapStyleWord(true); + jtext8.setBorder(new LineBorder(new java.awt.Color(127,157,185), 1, false)); + jtext10 = new JTextField(); + jcomproject.addItem(" "); + TCComponentUser user = session.getUser(); + try { + String user_id = user.getStringProperty("user_id"); + System.out.println("user_id=============="+user_id); + String[] keys = new String[]{"ID"}; + String[] values = new String[]{user_id}; + List compList = queryObject("基于用户的项目", keys, values); + if(compList != null && compList.size() > 0) { + for (int i = 0; i < compList.size(); i++) { + TCComponent comp = compList.get(i); + if(comp instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) comp; + try { + String id = project.getStringProperty("project_id"); + jcomproject.addItem(id); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + } + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + jtext1.setEnabled(false); + jtext2.setEnabled(false); + jcomname.setEnabled(false); + jp2.setLayout(null); + jl1.setBounds(20, 20, 30, 30); + jtext1.setBounds(60, 20, 70, 30); + jl2.setBounds(20, 60, 40, 30); + jtext2.setBounds(60, 60, 30, 30); + jl3.setBounds(20, 100, 40, 30); + jl5.setBounds(20, 140, 40, 30); + jtext5.setBounds(60, 140, 120, 30); + jl6.setBounds(20, 180, 40, 30); + jtext6.setBounds(60, 180, 120, 30); + jl7.setBounds(20, 220, 40, 30); + jcomunit.setBounds(60, 220, 120, 30); + jl8.setBounds(20, 260, 40, 30); + jtext8.setBounds(60, 260, 200, 100); + jl9.setBounds(20, 370, 40, 30); + jcomproject.setBounds(60, 370, 120, 30); + jl10.setBounds(20, 410, 40, 30); + jtext10.setBounds(60, 410, 120, 30); + + groupCode_lable.setBounds(20, 450, 40, 30); + groupCode_combobox.setBounds(60, 450, 120, 30); + + + + sourceCode_lable.setBounds(20, 490, 40, 30); + sourceCode_combobox.setBounds(60, 490, 120, 30); + + + Important_lable.setBounds(20, 530, 40, 30); + Importantce_combobox.setBounds(60, 530, 120, 30); + jp2.add(groupCode_lable);jp2.add(groupCode_combobox);jp2.add(sourceCode_lable); + jp2.add(sourceCode_combobox);jp2.add(Important_lable);jp2.add(Importantce_combobox); + + + + jp2.add(jl1); + jp2.add(jtext1); + jp2.add(jl2); + jp2.add(jtext2); + jp2.add(jl3); + //jp2.add(jtext3); + jp2.add(jl5); + jp2.add(jtext5); + jp2.add(jl6); + jp2.add(jtext6); + jp2.add(jl7); + jp2.add(jcomunit); + jp2.add(jl8); + jp2.add(jtext8); + jp2.add(jl9); + jp2.add(jcomproject); + jp2.add(jl10); + jp2.add(jtext10); + + // jp2.add("1.1.left.center", new JLabel("")); + // jp2.add("2.1.center.center", jl1); + // jp2.add("2.2.left.center", jtext1); + // jp2.add("3.1.left.center", new JLabel("")); + // jp2.add("4.1.center.center", jl2); + // jp2.add("4.2.left.center", jtext2); + // jp2.add("5.1.left.center", new JLabel("")); + // jp2.add("6.1.center.center", jl3); + // jp2.add("7.1.left.center", new JLabel("")); + // jp2.add("8.1.center.center", jl4); + // jp2.add("8.2.left.center", jtext4); + // jp2.add("9.1.left.center", new JLabel("")); + // jp2.add("10.1.center.center", jl5); + // jp2.add("10.2.left.center", jtext5); + // jp2.add("11.1.left.center", new JLabel("")); + // jp2.add("12.1.center.center", jl6); + // jp2.add("12.2.left.center", jtext6); + // jp2.add("13.1.left.center", new JLabel("")); + // jp2.add("14.1.center.center", jl7); + // jp2.add("14.2.left.center", jtext7); + // jp2.add("15.1.left.center", new JLabel("")); + // jp2.add("16.1.center.center", jl8); + // jp2.add("16.2.left.center", jtext8); + // jp2.add("17.1.left.center", new JLabel("")); + // jp2.add("18.1.center.center", jl9); + // jp2.add("18.2.left.center", jcomproject); + + jp2.setVisible(false); + + add("1.1.center.center", jp1); + add("1.2.center.center", jp2); + add("2.1.center.center", okBut); + add("2.2.center.center", celBut); + + String oldId = jtext10.getText(); + // + String[] groupvalues = new String[]{}; + String lovgroupname=service.getStringValue("T2_waixiejianlov");//首选项控制外协件分群码下拉值 + System.out.println("lovname="+lovgroupname); + TCComponentListOfValuesType lovType0 = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lov1 = lovType0.find(lovgroupname); + System.out.println("lov1="+lov1.length); + if(lov1.length > 0){ + ListOfValuesInfo value = lov1[0].getListOfValues(); + groupvalues = value.getStringListOfValues(); + for (int i = 0; i < groupvalues.length; i++) { + String disval = value.getDisplayableValue(groupvalues[i]); + groupCode_combobox.addItem(disval); + groupMap.put(disval, groupvalues[i]); + + } + + } + + // + String[] sourcevalues = new String[]{}; + String lovsourcename=service.getStringValue("T2_sourceCode");//"T2_unitsLOV" + System.out.println("lovname="+lovsourcename); + TCComponentListOfValuesType lovType1 = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lov2 = lovType1.find(lovsourcename); + System.out.println("lov2="+lov2.length); + if(lov2.length > 0){ + ListOfValuesInfo value = lov2[0].getListOfValues(); + sourcevalues = value.getStringListOfValues(); + for (int i = 0; i < sourcevalues.length; i++) { + String disval = value.getDisplayableValue(sourcevalues[i]); + sourceCode_combobox.addItem(disval); + sourceMap.put(disval, sourcevalues[i]); + + + } + + } + + + + // + + + // + String[] importancevalues = new String[]{}; + String lovimportancename=service.getStringValue("T2_Importance"); + System.out.println("lovname="+lovimportancename); + TCComponentListOfValuesType lovType2 = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lov3 = lovType2.find(lovimportancename); + System.out.println("lov3="+lov3.length); + if(lov3.length > 0){ + ListOfValuesInfo value = lov3[0].getListOfValues(); + importancevalues = value.getStringListOfValues(); + for (int i = 0; i < importancevalues.length; i++) { + String disval = value.getDisplayableValue(importancevalues[i]); + Importantce_combobox.addItem(disval); + ImportanceMap.put(disval, importancevalues[i]); + } + + } + + + okBut.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("确定"); + if (jp2.isVisible()) { + String itemName=""; + if (islov) { + itemName=(String) jcomname.getSelectedItem(); + if (!nameMap.containsKey(itemName)) { + MessageBox.post("名称错误,请在下拉框范围内选择!", "提示", MessageBox.INFORMATION); + } + }else{ + StringBuilder sb = new StringBuilder(name); + sb.append("-"); + sb.append(jtext3.getText()); + itemName=sb.toString(); + } + + String groupCode = (String) groupCode_combobox.getSelectedItem(); + String souceCode = (String) sourceCode_combobox.getSelectedItem(); + + System.out.println("=========group" + groupCode); + System.out.println("=========source" + souceCode); + + + + if ( !(" ".equals(itemName)) && !( " ".equals(groupCode)) && !(" ".equals(souceCode))) { + createItem(); + } else { + MessageBox.post("名称、来源码、分群码不能为空!", "提示", MessageBox.INFORMATION); + } + + + + + + + } else { + MessageBox.post("请选择创建类型!", "提示", MessageBox.INFORMATION); + } + + } + }); + celBut.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("取消"); + setVisible(false); + } + }); + this.setVisible(true); + this.centerToScreen(); + // this.pack(); + } + + /** + * 创建对象事件 + */ + protected void createItem() { + // TODO Auto-generated method stub + try { + String type = selCodeBean.getType(); + DataBaseControl data = new DataBaseControl(session); + TCComponentItemType tctype = (TCComponentItemType) session + .getTypeComponent(type); + try { + String newID = data.getNewCode("PLMCODE", selCodeBean); + System.out.println("newID1==============="+newID); + TCComponentItem find = tctype.find(newID); + if (find != null) { + newID = data.getMaxCode("PLMCODE", selCodeBean); + System.out.println("newID2==============="+newID); + find = tctype.find(newID); + } + if (find != null) { + MessageBox.post("当前流水ID:" + newID + "已存在对象,无法创建!", "错误", + MessageBox.ERROR); + } else { + this.setVisible(false); + String itemName=""; + if (islov) { + itemName=(String) jcomname.getSelectedItem(); + itemName=nameMap.get(itemName); + }else{ + itemName=jtext3.getText(); + } + TCComponentItem item = tctype.create(newID, + jtext2.getText(), type, itemName, "", null); +// String oldId = jtext4.getText(); + String material = jtext5.getText(); + String weight = jtext6.getText(); + String key = (String) jcomunit.getSelectedItem(); + String oldId = jtext10.getText(); + String group = groupMap.get(groupCode_combobox.getSelectedItem()); + String source = sourceMap.get( sourceCode_combobox.getSelectedItem()); + String impotance =ImportanceMap.get(Importantce_combobox.getSelectedItem()); + + //查重旧品号 + String[] keys2 = new String[]{"CNwaixie"}; + String[] values2 = new String[]{oldId}; + List compList2 = queryObject("根据旧品号查物料", keys2, values2); + System.out.println("查询结果------"+compList2); + System.out.println("旧品号--------"+oldId); + if(compList2!=null) { + MessageBox.post("旧品号["+oldId+ "]已经存在,不允许创建!", "错误",MessageBox.ERROR); + return ; + } + + String unit = ""; + if(unitMap.containsKey(key)) { + unit = unitMap.get(key); + } + String Specifications = jtext8.getText(); + TCComponentItemRevision rev = item.getLatestItemRevision(); + // + + + if(group != null && group != "" && group != " " ) { + rev.setStringProperty("t2_groupCode", group); + } + + if(source != null && source != "" && source != "") { + rev.setStringProperty("t2_sourceCode", source); + } + if(impotance != null && impotance != "" && impotance != " " ) { + rev.setStringProperty("t2_Importance", impotance); + } + if(itemName != null && itemName != "" && itemName != " " ) { + item.setStringProperty("object_desc", itemName); + rev.setStringProperty("object_desc", itemName); + } + + +// if(oldId != null && oldId != "" && oldId != " " ) { +// rev.setStringProperty("t2_OLDMerchandiseID", oldId); +// } + if(oldId != null && oldId != "" && oldId != " " ) { + String oldId2 = oldId.trim(); + System.out.println("输入的旧品号-----"+oldId2); + rev.setStringProperty("t2_OldId", oldId2); + } + if(material != null && material != "" && material != " " ) { + rev.setStringProperty("t2_material", material); + } + if(weight != null && weight != "" && oldId != " " ) { + rev.setStringProperty("t2_MASS", weight); + } + if(unit != null && unit != "" && unit != " " ) { + rev.setStringProperty("t2_unit", unit); + } + if(Specifications != null && Specifications != "" && Specifications != " ") { + rev.setStringProperty("t2_Specifications", Specifications); + } + String classid = selCodeBean.getClassID(); + if(classid != null && classid != "" && classid != " ") { + rev.setStringProperty("t2_ClassID", classid); + } + if(targetComp instanceof TCComponent) { + TCComponent comp = (TCComponent) targetComp; + String targetType = comp.getType(); + System.out.println("targetType================="+targetType); + if("T2_outsourceRevision".equals(targetType)) { + String id = comp.getStringProperty("item_id"); + rev.setStringProperty("t2_ReferenceOldId", id); + rev.add("T2_RelationPart", comp); + }else if("Fnd0HomeFolder".equals(targetType) || + "Folder".equals(targetType) || + "Newstuff Folder".equals(targetType) ){ + + }else + { + MessageBox.post("选中的对象不是外协件版本对象!!!" ,"提示", + MessageBox.INFORMATION); + } + } + String proID = (String) jcomproject.getSelectedItem(); + if(proID != null & proID !=" ") { + String[] keys = new String[]{"项目 ID"}; + String[] values = new String[]{proID}; + List compList = queryObject("基于项目ID查找项目", keys, values); + if(compList != null && compList.size() > 0) { + TCComponent comp = compList.get(0); + if(comp instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) comp; + TCComponentUser atccomponentuser[] = new TCComponentUser[1]; + com.teamcenter.services.internal.rac.core.DataManagementService datamanagementservice = com.teamcenter.services.internal.rac.core.DataManagementService.getService(session); + ServiceData servicedata = datamanagementservice.setDefaultProjectForProjectMembers(project,atccomponentuser); + // if (servicedata != null && servicedata.sizeOfPartialErrors() > 0) { + // com.teamcenter.rac.kernel.TCExceptionPartial tcexceptionpartial = SoaUtil + // .checkPartialErrorsNoThrow(servicedata); + // MessageBox.post(Utilities.getCurrentFrame(), + // tcexceptionpartial); + // } + project.assignToProject(new TCComponent[] {item}); + } + } + } + System.out.println("开始同步选中属性到创建对象"); + CopyPropsBean copyPropBean = selCodeBean.getCopyPropBean(); + if (copyPropBean!=null) { + String type2 = copyPropBean.getType(); + List props = copyPropBean.getProps(); + if (targetComp!=null&&targetComp.getType().equals(type2)) { + boolean isok=true; + TCComponentItemRevision furev=null; + if (targetComp instanceof TCComponentItemRevision) { + furev=(TCComponentItemRevision) targetComp; + }else if (targetComp instanceof TCComponentItem) { + furev=((TCComponentItem)targetComp).getLatestItemRevision(); + }else{ + isok=false; + System.out.println("只支持版本和对象"); + } + if (props!=null&&props.size()>0&&isok) { + for (int i = 0; i < props.size(); i++) { + String[] split = props.get(i).split("="); + if (split != null && split.length == 2) { + String propstr = ""; + if (split[0].startsWith("ITEM.")) { + TCComponentItem com = furev.getItem(); + propstr = com.getTCProperty(split[0].substring(5)).getStringValue(); + } else if (split[0].startsWith("REV.")) { + TCComponentItemRevision com = furev; + propstr = com.getTCProperty(split[0].substring(4)).getStringValue(); + } else if (split[0].startsWith("FORM.")) { + TCComponentForm com = (TCComponentForm) furev.getReferenceListProperty("IMAN_master_form_rev")[0]; + propstr = com.getTCProperty(split[0].substring(5)).getStringValue(); + } + if (propstr != null&& !propstr.equals("")) { + if (split[1].startsWith("ITEM.")) { + TCComponentItem com = item; + com.getTCProperty(split[1].substring(5)).setStringValue(propstr); + } else if (split[1].startsWith("REV.")) { + TCComponentItemRevision com = rev; + com.getTCProperty(split[1].substring(4)).setStringValue(propstr); + } else if (split[1].startsWith("FORM.")) { + TCComponentForm com = (TCComponentForm) rev + .getReferenceListProperty("IMAN_master_form_rev")[0]; + com.getTCProperty(split[1].substring(5)).setStringValue(propstr); + } + } + + } + } + } + } + }else{ + System.out.println("未配置同步,不进行属性同步"); + } + + if (targetComp == null) { + session.getUser().getNewStuffFolder().add("contents", item); + MessageBox.post("对象" + item + "创建成功,请在NewStuff文件夹下查看!", + "成功", MessageBox.INFORMATION); + } else if (targetComp instanceof TCComponentFolder) { + ((TCComponentFolder) targetComp).add("contents", item); + MessageBox.post("对象" + item + "创建成功,请在当前文件夹下查看!", "成功", + MessageBox.INFORMATION); + }else { + session.getUser().getNewStuffFolder().add("contents", item); + MessageBox.post("对象" + item + "创建成功,请在NewStuff文件夹下查看!", + "成功", MessageBox.INFORMATION); + } + //if (classid != null && !classid.equals("")) { + //Dfl003Operation op=new Dfl003Operation(session, classid, rev, new Integer[] {}, new String[] {}); + //session.queueOperation(op); + //} else { + //System.out.println("未找到该类型的分类id,不发生分类"); + //} + + + + + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("错误:" + e.getMessage(), "错误", + MessageBox.INFORMATION); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + + /** + * 选中底层事件 + * + */ + protected void setTextStr(DefaultMutableTreeNode treeNode) { + // TODO Auto-generated method stub + selnodename = treeNode.toString(); + if (islov) { + if (nameMap.containsKey(selnodename)) { + jcomname.setSelectedItem(selnodename); + } + }else{ + jtext3.setText(""); + } + String names = getNode(treeNode, ""); + selCodeBean = getcode.getCodebean(names); + if (selCodeBean != null) { + String type = selCodeBean.getType(); + String code = selCodeBean.getCode(); + code = code + " [L]"; + getNameLov(type); + try { + TCComponentItemType tctype = (TCComponentItemType) session + .getTypeComponent(type); + jtext1.setText(code); + jtext2.setText(tctype.getNewRev(null)); + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * 遍历获得当前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; + } + } + +} diff --git a/src/com/connor/dfl/plm/dfl003/Dfl003Action.java b/src/com/connor/dfl/plm/dfl003/Dfl003Action.java new file mode 100644 index 0000000..776cf1e --- /dev/null +++ b/src/com/connor/dfl/plm/dfl003/Dfl003Action.java @@ -0,0 +1,30 @@ +package com.connor.dfl.plm.dfl003; + +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.TCSession; + +public class Dfl003Action extends AbstractAIFAction { + private AbstractAIFApplication app; + private InterfaceAIFComponent tar; + private TCSession session; + private String name; + + public Dfl003Action(AbstractAIFApplication arg0, String arg1, String name) { + super(arg0, arg1); + // TODO Auto-generated constructor stub + this.app = arg0; + this.tar = app.getTargetComponent(); + this.session = (TCSession) app.getSession(); + this.name = name; + } + + public void run() { + // TODO Auto-generated method stub + Dfl003AIFDialog dia = new Dfl003AIFDialog(session, tar, name); + new Thread(dia).start(); + + } + +} diff --git a/src/com/connor/dfl/plm/dfl003/Dfl003Handler.java b/src/com/connor/dfl/plm/dfl003/Dfl003Handler.java new file mode 100644 index 0000000..f92c03c --- /dev/null +++ b/src/com/connor/dfl/plm/dfl003/Dfl003Handler.java @@ -0,0 +1,37 @@ +package com.connor.dfl.plm.dfl003; + +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.aifrcp.AIFUtility; + +/** + * 程序名:Dfl003Handler + * 程序描述:创建外协件 + * 创建日期:2020-06-09 + * 程序员 wangc + * + */ +public class Dfl003Handler extends AbstractHandler { + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + try { + String name = arg0.getCommand().getName(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + //TCSession session = (TCSession) app.getSession(); + //InterfaceAIFComponent com = app.getTargetComponent(); + Dfl003Action dia = new Dfl003Action(app, null,name); + new Thread(dia).start(); + } catch (NotDefinedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + +} diff --git a/src/com/connor/dfl/plm/dfl003/Dfl003Operation.java b/src/com/connor/dfl/plm/dfl003/Dfl003Operation.java new file mode 100644 index 0000000..6711fee --- /dev/null +++ b/src/com/connor/dfl/plm/dfl003/Dfl003Operation.java @@ -0,0 +1,80 @@ +package com.connor.dfl.plm.dfl003; + +import java.util.ArrayList; +import java.util.List; + +import com.connor.dfl.plm.util.ClassProperty; +import com.connor.dfl.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; + +public class Dfl003Operation extends AbstractAIFOperation { + + private TCSession session; + private String classid; + private TCComponentItemRevision rev; + private Integer[] keys; + private String[] vels; + + public Dfl003Operation(TCSession session, String classid, + TCComponentItemRevision rev, Integer[] keys, String[] vels) { + // TODO Auto-generated constructor stub + this.session = session; + this.classid = classid; + this.rev = rev; + this.keys = keys; + this.vels = vels; + + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + sendObjToClassficationByWebService(classid, rev, keys, vels); + + } + + /** + * 发送分类 + * + * @param class_id + * 分类id + * @param rev + * 版本对象 + * @param keys + * 分类属性id集合 + * @param vals + * 分类属性值集合 + */ + public void sendObjToClassficationByWebService(String class_id, + TCComponentItemRevision rev, Integer[] keys, String[] vals) { + try { + String url = session.getPreferenceService().getStringValue( + "Autocode_SendClassServer_URL"); + 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++) { + + + 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(); + } + } + +} diff --git a/src/com/connor/dfl/plm/dfl004/Dfl004Handler.java b/src/com/connor/dfl/plm/dfl004/Dfl004Handler.java new file mode 100644 index 0000000..9c48eb9 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl004/Dfl004Handler.java @@ -0,0 +1,32 @@ +package com.connor.dfl.plm.dfl004; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AIFDesktop; + +import cn.com.origin.autocode.newitem.generatcode.NewCodeItemDialog; +import cn.com.origin.autocode.xmlutil.ProgressBarThread; + + + +public class Dfl004Handler extends AbstractHandler { + private ProgressBarThread wait; + public Object execute(ExecutionEvent arg0) throws ExecutionException { + System.out.println("调用编码器======================"); +// new Thread() { +// public void run() { +// wait = new ProgressBarThread("编码器", +// "编码器界面加载中,请稍等..."); +// wait.start();// 开启进度条 +// +// }; +// }.start(); + new NewCodeItemDialog(AIFDesktop.getActiveDesktop().getShell()).open(); +// wait.setBool(true);// 关闭进度条 +// wait.interrupt(); + return null; + } +} + diff --git a/src/com/connor/dfl/plm/dfl005/Dfl005Handler.java b/src/com/connor/dfl/plm/dfl005/Dfl005Handler.java new file mode 100644 index 0000000..dda7562 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl005/Dfl005Handler.java @@ -0,0 +1,314 @@ +package com.connor.dfl.plm.dfl005; + +import java.util.ArrayList; +import java.util.List; + + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExecutableExtension; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.handlers.HandlerUtil; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.aifrcp.SelectionHelper; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.services.ISessionService; +import com.teamcenter.rac.ui.commands.Messages; +import com.teamcenter.rac.ui.commands.RACUICommandsActivator; +import com.teamcenter.rac.ui.commands.create.bo.NewBOModel; +import com.teamcenter.rac.ui.commands.create.bo.NewBOWizard; +import com.teamcenter.rac.util.OSGIUtil; +import com.teamcenter.rac.util.SWTUIUtilities; +import com.teamcenter.rac.util.UIUtilities; +import com.teamcenter.rac.util.wizard.extension.BaseExternalWizardDialog; +import com.teamcenter.rac.util.wizard.extension.WizardExtensionHelper; + +/** + * TC9及其以上版本的新建对象(包括零组件、文件夹、表单)的新的swt的界面 com.teamcenter.rac.ui.commands.handlers + * + * + * @author hub + * + */ +public class Dfl005Handler extends AbstractHandler implements + IExecutableExtension { + private String opType = ""; + + private class CreateNewBOSWTDialog implements Runnable { + + public void run() { + NewBOWizard newbowizard = (NewBOWizard) getWizard(); + if (newbowizard == null) + newbowizard = new NewBOWizard(wizardId); + newbowizard.setBOModel(m_boModel); + newbowizard.setWindowTitle(getWizardTitle()); + newbowizard.setRevisionFlag(m_boModel.getRevisionFlag()); + newbowizard.setDefaultType(m_type); + Shell shell = UIUtilities.getCurrentModalShell(); + dialog = new BaseExternalWizardDialog(m_shell, newbowizard); + dialog.create(); + newbowizard.retrievePersistedDialogSettings(dialog); + newbowizard.setWizardDialog(dialog); + UIUtilities.setCurrentModalShell(dialog.getShell()); + dialog.open(); + dialog = null; + + InterfaceAIFComponent[] compS = m_boModel.getTargetArray(); + + if (compS != null && compS.length != 0) { + System.out.println(" length =" + compS.length); + if (compS[0] instanceof TCComponentItem) { + + System.out.println("ITEM"); + } else if (compS[0] instanceof TCComponentFolder) { + + System.out.println("FOLDER"); + } + TCComponent compT = (TCComponent) compS[0]; + try { + System.out.println("object_name =>" + + compT.getStringProperty("object_name")); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } else { + System.out.println(" null "); + } + + System.out.println("=====>"); + List contextList = m_boModel.getCompContext(); + if (contextList != null) { + for (AIFComponentContext context : contextList) { + InterfaceAIFComponent comp = context.getComponent(); + try { + System.out.println(">" + + ((TCComponent) comp) + .getStringProperty("object_name")); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + } + System.out.println("=====>"); + m_boModel = null; + + UIUtilities.setCurrentModalShell(shell); + + System.out.println("dialog ==> " + opType + " | " + m_type); + } + + private final Shell m_shell; + private final String m_type; + final Dfl005Handler this$0; + + private CreateNewBOSWTDialog(Shell shell, String s) { + super(); + this$0 = Dfl005Handler.this; + + m_shell = shell; + m_type = s; + } + + CreateNewBOSWTDialog(Shell shell, String s, + CreateNewBOSWTDialog createnewboswtdialog) { + this(shell, s); + } + + } + + public Object execute(ExecutionEvent executionevent) + throws ExecutionException { + + opType = executionevent.getCommand().getId(); + if("WF2_phsRvwForm1".equals(opType)){ + opType = "WF2_phsRvwForm"; + } + if("WF2_procFlow1".equals(opType)){ + opType = "WF2_procFlow"; + } + if("WF2_machDimCP1".equals(opType)){ + opType = "WF2_machDimCP"; + } + + if (executionevent == null) + throw new IllegalArgumentException("Event can't be null"); + + boolean flag = false; + if (executionevent.getParameters() != null + && executionevent.getParameters().containsKey("selection")) { + Object obj = executionevent.getParameters().get("selection"); + if (obj instanceof InterfaceAIFComponent[]) { + selectedCmps = (InterfaceAIFComponent[]) obj; + m_currentSelection = new StructuredSelection(selectedCmps); + flag = true; + } + } + if (!flag) { + m_currentSelection = HandlerUtil + .getCurrentSelection(executionevent); + selectedCmps = SelectionHelper + .getTargetComponents(m_currentSelection); + } + m_boModel = getBOModel(); + launchWizard(executionevent); + return null; + } + + public void setInitializationData( + IConfigurationElement iconfigurationelement, String s, Object obj) + throws CoreException { + } + + protected NewBOModel getBOModel() { + if (m_boModel == null) + m_boModel = new NewBOModel(this); + return m_boModel; + } + + public Wizard getWizard() { + if (wizardId == null || wizardId.length() == 0) + wizardId = "com.teamcenter.rac.ui.commands.create.bo.NewBOWizard"; + return WizardExtensionHelper.getWizard(wizardId); + } + + public String getWizardTitle() { + return Messages.getString("wizard.TITLE"); + } + + public void launchWizard() { + launchWizard(null); + } + + public void launchWizard(ExecutionEvent executionevent) { + String s = this.opType; + initWizardModel(executionevent); + // if (executionevent != null) + // s = (String) executionevent.getParameters().get("objectType"); + AIFDesktop aifdesktop = AIFUtility.getActiveDesktop(); + Shell shell = aifdesktop.getShell(); + if (shell != null) + SWTUIUtilities.asyncExec(new CreateNewBOSWTDialog(shell, s, null)); + } + + protected void initWizardModel(ExecutionEvent executionevent) { + boolean flag = false; + Object obj = null; + ISessionService isessionservice = (ISessionService) OSGIUtil + .getService(RACUICommandsActivator.getDefault(), + com.teamcenter.rac.services.ISessionService.class); + try { + session = (TCSession) isessionservice + .getSession(com.teamcenter.rac.kernel.TCSession.class + .getName()); + } catch (Exception _ex) { + session = (TCSession) AIFUtility.getDefaultSession(); + } + m_boModel.setSession(session); + m_boModel.reInitializeTransientData(); + m_boModel.setFrame(AIFUtility.getActiveDesktop()); + if (executionevent != null) { + if (executionevent.getParameters().containsKey("revisionFlag")) + flag = ((Boolean) executionevent.getParameters().get( + "revisionFlag")).booleanValue(); + if (executionevent.getParameters().containsKey("pasteRelation")) { + String s = (String) executionevent.getParameters().get( + "pasteRelation"); + if (s != null) { + String as[] = null; + as = s.split(","); + m_boModel.setRelType(as[0]); + m_boModel.setPreAssignedRelType(as); + } + } + if (executionevent.getParameters().containsKey("parentComponents")) { + InterfaceAIFComponent ainterfaceaifcomponent[] = (InterfaceAIFComponent[]) executionevent + .getParameters().get("parentComponents"); + m_boModel.setTargetArray(ainterfaceaifcomponent); + } else { + m_boModel.setTargetArray(selectedCmps); + } + if(executionevent.getParameters().containsKey("relOtherTypeInfo")) + { + String s1 = (String)executionevent.getParameters().get("relOtherTypeInfo"); + if(s1 != null) + { + String as1[] = s1.split(","); + ArrayList arraylist = new ArrayList(); + ArrayList arraylist1 = new ArrayList(); + String as2[]; + int j = (as2 = as1).length; + for(int i = 0; i < j; i++) + { + String s2 = as2[i]; + s2 = s2.trim(); + int k = s2.indexOf("."); + arraylist.add(s2.substring(0, k)); + arraylist1.add(s2.substring(k + 1, s2.length())); + } + + m_boModel.setPreAssignedRelTypesForAllSubTypes(arraylist, arraylist1); + } + } else + { + m_boModel.setAllowUserToSelectRelation(useDefaultRelations()); + } + } else { + m_boModel.setTargetArray(selectedCmps); + } + m_boModel.setRevisionFlag(flag); + AIFDesktop aifdesktop = AIFUtility.getActiveDesktop(); + Shell shell = aifdesktop.getShell(); + m_boModel.setShell(shell); + m_boModel.setCurrentSelection(m_currentSelection); + } + + protected boolean useDefaultRelations() + { + return true; + } + + protected void readDisplayParameters(NewBOWizard newbowizard, + WizardDialog wizarddialog) { + newbowizard.retrievePersistedDialogSettings(wizarddialog); + } + + protected InterfaceAIFComponent selectedCmps[]; + protected ISelection m_currentSelection; + protected String wizardId; + protected WizardDialog dialog; + /** + * @deprecated Field session is deprecated + */ + @Deprecated + protected TCSession session; + protected NewBOModel m_boModel; +} + +/* + * DECOMPILATION REPORT + * + * Decompiled from: + * F:\Teamcenter11ENV\JAVA\rac\plugins\com.teamcenter.rac.ui.commands_11000 + * .2.0.jar Total time: 72 ms Jad reported messages/errors: Exit status: 0 + * Caught exceptions: + */ \ No newline at end of file diff --git a/src/com/connor/dfl/plm/dfl006/CreateChangeOrderDialog.java b/src/com/connor/dfl/plm/dfl006/CreateChangeOrderDialog.java new file mode 100644 index 0000000..00352f6 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl006/CreateChangeOrderDialog.java @@ -0,0 +1,194 @@ +package com.connor.dfl.plm.dfl006; + +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.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.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.iTextField; +/** + * 程序名:CreateChangeOrderDialog + * 程序描述:变更通知单创建 + * 创建日期:2020-06-11 + * 程序员 wangc + * + * 修改日期 修改人 修改描述 + * + */ +public class CreateChangeOrderDialog extends AbstractAIFDialog{ + private static final long serialVersionUID = 1L; + private InterfaceAIFComponent[] targetComponents = null; + private AbstractAIFApplication app; + private TCSession session; + public CreateChangeOrderDialog(AbstractAIFApplication arg0) { + + this.app=arg0; + this.session=(TCSession) app.getSession(); + targetComponents = app.getTargetComponents(); + init(); + } + private void init() { + //判断是否为变更申请单 + final TCComponent itemR = (TCComponent)targetComponents[0]; + if(!itemR.getTypeComponent().toString().equals("T2_ECRRevision")) { + System.out.println(itemR.getTypeComponent()); + MessageBox.post("创建失败,请选择变更申请单版本进行创建!", "提示信息",MessageBox.INFORMATION); + }else { + + //调用创建变更通知单的程序 + + this.setTitle("变更通知单创建"); + this.setLayout(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //设置JPanel的大小 + this.setPreferredSize(new Dimension(380, 330)); + + + //创建输入的panel + JPanel panel = new JPanel(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //创建按钮的panel + JPanel buttonPanel = new JPanel(new ButtonLayout( + ButtonLayout.HORIZONTAL, ButtonLayout.CENTER, 30)); + + //创建模芯输入对象 + final iTextField id_TextField = new iTextField(); + final iTextField name_TextField = new iTextField(); + //final iTextField re_TextField = new iTextField(); //度量单位 + final iTextField desc_TextField = new iTextField();//描述 + + final JLabel jText = new JLabel(); + final JLabel jid = new JLabel(); + final JLabel jname= new JLabel(); + //final JLabel jre = new JLabel(); + final JLabel jdesc = new JLabel(); + jText.setText(" ID值必须参照\"ECN\"nnnnnnn进行编辑"); + jid.setText("ID:"); + jname.setText("名称:"); + //jre.setText("度量单位:"); + jdesc.setText("描述:"); + id_TextField.setPreferredSize(new Dimension(180, 20)); + name_TextField.setPreferredSize(new Dimension(180, 20)); + // re_TextField.setPreferredSize(new Dimension(180, 20)); + desc_TextField.setPreferredSize(new Dimension(180, 20)); + JButton give_button = new JButton("指派"); + + + //panel.add("1.1.center.center.preferred.preferred",jText); + panel.add("1.1.left.center",new JLabel(" ")); + panel.add("2.1.left.center",new JLabel(" ")); + panel.add("3.1.left.center",new JLabel(" ")); + panel.add("3.2.center.center",jText); + panel.add("4.1.left.center",new JLabel(" ")); + panel.add("5.1.left.center",jid); + panel.add("5.2.center.center",id_TextField); + panel.add("5.3.right.center",give_button); + panel.add("6.1.left.center",jname); + panel.add("6.2.center.center",name_TextField); + + // panel.add("3.2.left.center.perferred.perferred",re_TextField); + + panel.add("7.1.left.center",jdesc); + panel.add("7.2.center.center",desc_TextField); + + + + //创建按钮 并放入到指定的区域 + + + JButton ok_Button = new JButton("确定"); + JButton cancel_Button = new JButton("取消"); + + buttonPanel.add(ok_Button); + buttonPanel.add(cancel_Button); + + this.add("1.1.center.center", panel); + this.add("2.1.center.center", buttonPanel); + + + this.centerToScreen(); + this.setVisible(true); + + + give_button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + + TCComponentItemType ccomponentitemtype; + + + try { + ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("T2_ECN"); + id_TextField.setText(ccomponentitemtype.getNewID()); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + }); + + ok_Button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + //创建变更通知单 + + String itemId=id_TextField.getText().trim(); + String itemName=name_TextField.getText().trim(); + String itemDescription = desc_TextField.getText().trim(); + + if(itemName.equals("")|itemName=="null") { + MessageBox.post("名称为必填项", "提示信息",MessageBox.INFORMATION); + }else { + + TCComponentItemType ccomponentitemtype; + try { + ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("T2_ECN"); + TCComponentItem item = ccomponentitemtype.create(itemId,"01","T2_ECN",itemName,itemDescription,null); + + + //将item与变更通知单文件夹添加附加关系 + + + itemR.add("T2_ECNRe", item); + + MessageBox.post("变更通知单添加成功", "提示信息",MessageBox.INFORMATION); + closeDialog(); + + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + }); + + cancel_Button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + closeDialog(); + } + }); + + + + } + } + private void closeDialog() { + disposeDialog(); + setVisible(false); +} +} diff --git a/src/com/connor/dfl/plm/dfl006/Dfl006Handler.java b/src/com/connor/dfl/plm/dfl006/Dfl006Handler.java new file mode 100644 index 0000000..9813084 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl006/Dfl006Handler.java @@ -0,0 +1,29 @@ +package com.connor.dfl.plm.dfl006; + +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; +/** + * 程序名:变更通知单创建 + * 程序描述:变更通知单创建 + * 创建日期:2020-06-10 + * 程序员 wangc + * + * 修改日期 修改人 修改描述 + * + */ +public class Dfl006Handler extends AbstractHandler { + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + AbstractAIFApplication app=AIFUtility.getCurrentApplication(); + CreateChangeOrderDialog createChangeOrderDialog = new CreateChangeOrderDialog(app); + + return null; + } + +} diff --git a/src/com/connor/dfl/plm/dfl007/ChildFolderPart.java b/src/com/connor/dfl/plm/dfl007/ChildFolderPart.java new file mode 100644 index 0000000..c5255e4 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl007/ChildFolderPart.java @@ -0,0 +1,24 @@ +package com.connor.dfl.plm.dfl007; + +import java.util.List; + +public class ChildFolderPart { + private String name; + private List childName; + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public List getChildName() { + return childName; + } + public void setChildName(List childName) { + this.childName = childName; + } + @Override + public String toString() { + return "FolderPart [name=" + name + ", childName=" + childName + "]"; + } +} diff --git a/src/com/connor/dfl/plm/dfl007/CreateProjectDialog.java b/src/com/connor/dfl/plm/dfl007/CreateProjectDialog.java new file mode 100644 index 0000000..2ccaaa3 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl007/CreateProjectDialog.java @@ -0,0 +1,329 @@ + +package com.connor.dfl.plm.dfl007; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.Label; +import java.awt.LayoutManager; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.event.AncestorEvent; +import javax.swing.event.AncestorListener; + +import org.eclipse.swt.events.KeyEvent; + +import com.itextpdf.text.Jpeg; +import com.sun.codemodel.JCase; +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.KernelConstants; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFolderType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentProjectType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.VerticalLayout; + +/** + * + * 程序名:CreateProjectDialog + * 程序描述:选择完任务节点后,点击确定,可提供创建项目和添加项目组成员 + * 创建日期:2020-06-28 + * 程序员 suny + * + */ + + + + +public class CreateProjectDialog extends AbstractAIFDialog { + private AbstractAIFApplication app ; + //= AIFUtility.getCurrentApplication(); + TCSession session ; + //= (TCSession) app.getSession(); + InterfaceAIFComponent targetComp; + + + //存放第一层选中的值 + private List list1 = new ArrayList(); + //存放第二层第一阶段选中的值 + private List list21 = new ArrayList(); + //存放第二层第二阶段选中的值 + private List list22 = new ArrayList(); + //存放第二层第三阶段选中的值 + private List list23 = new ArrayList(); + //存放第二层第四阶段选中的值 + private List list24 = new ArrayList(); + //存放第二层第五阶段选中的值 + private List list25 = new ArrayList(); + + + + //存放第三层段选中的值 + private List list30 = new ArrayList(); + private List list31 = new ArrayList(); + private List list32 = new ArrayList(); + private List list33 = new ArrayList(); + + + + + public CreateProjectDialog(AbstractAIFApplication app,InterfaceAIFComponent targetComp) { + super(); + this.app = app; + this.targetComp = targetComp; + this.session = (TCSession) app.getSession(); + } + @Override + public void run() { + createProject(); + } + + + + + + + + + protected void createProject() { + + //第一层 + + + + list1.add("计划和确定项目"); list1.add("产品设计开发");list1.add("产品生产、检验");list1.add("FAT阶段");list1.add("SAT阶段"); + list1.add("单机设备图"); + //第三层 + // "Mockup设计下发下的三层 + + list30.add("三维模型"); list30.add("图纸"); list30.add("BOM表"); + + + + //第三层 + //产品设计(机械) + + + + list31.add("压力容器计算书及资料"); list31.add("设计计算书"); list31.add("DS文件"); + + list31.add("FDS文件"); list31.add("设计确认文件"); list31.add("设计校审表"); + + list31.add("P&ID图纸"); list31.add("容器图纸"); list31.add("罐体备料图"); + + list31.add("机械图纸"); list31.add("规格件图纸"); list31.add("机械BOM表"); + + //第三层 + //产品设计(电器硬件) + list32.add("状态迁移图"); list32.add("仪器仪表校验清单"); list32.add("HDS文件"); list32.add("设计校审表"); + + list32.add("电器原理图"); list32.add("电器硬件BOM表"); list32.add("电器标签清单"); list32.add("机械BOM表"); + // + //第三层 + //产品设计(软件) + list33.add("FS文件"); list33.add("SDS文件"); list33.add("软件控制程序"); list33.add("电器软件校核报告"); + //第二层 + //第一阶段 + list21.add("产品任务书"); list21.add("项目进度计划表"); list21.add("项目启动会议纪要"); + + //第二层 + //第二阶段 + list22.add("部件关键性评估(CCA)"); list22.add("风险评估(RA)"); list22.add("系统风险评估"); list22.add("功能风险评估"); + + list22.add("设计输入评审报告"); list22.add("Mockup确认清单"); list22.add("Mockup会议纪要"); list22.add("长周期物料采购清单"); + + list22.add("Mockup设计下发"); list22.add("产品设计(机械)"); list22.add("产品设计(电器硬件)"); list22.add("产品设计(软件设计)"); + + //第二层 + //第三阶段 + + list23.add("来料检验记录") ; list23.add("产品生产交付确认单") ; list23.add("装配自检表") ; + list23.add("调试试运行报告") ; list23.add("过程检验报告") ; list23.add("工序流转跟踪卡") ; + //第二层 + //第四阶段 + list24.add("最终检验报告"); list24.add("预验收记录"); list24.add("FAT验收报告"); + list24.add("单机设备确认放行单"); list24.add("FAT竣工会议纪要"); + + //第二层 + //第五阶段 + + + + list25.add("包装检验报告"); list25.add("装箱清单"); list25.add("SAT报告"); list25.add("项目总结报告"); + + + + + //创建文件夹 + + if(targetComp instanceof TCComponent) { + TCComponent comp = (TCComponent) targetComp; + + + String targetType = comp.getType(); + if( "Folder".equals(targetType) ) { + + if(list1.size()>0) { + for(int i = 0 ;i0) { + for(int j = 0 ;j0) { + for(int j = 0 ;j0) { + for(int k = 0;k0) { + for(int k = 0;k0) { + for(int k = 0;k0) { + for(int k = 0;k0) { + for(int j = 0 ;j0) { + for(int j = 0 ;j0) { + for(int j = 0 ;j folderList = new ArrayList(); + + + public CreateProjectDialog2(AbstractAIFApplication app,InterfaceAIFComponent targetComp) { + super(); + this.app = app; + this.targetComp = targetComp; + this.session = (TCSession) app.getSession(); + } + @Override + public void run() { + ParseFolderXML xml=new ParseFolderXML(); + File file=xml.getSXX("DFL_Folder_Xml", session); + System.out.println("获取配置文件"); + FolderPart bean = xml.parseXMLCode(file); + if(bean == null ) { + MessageBox.post("首选项DFL_Folder_Xml未配置,请检查!", "WARNING", + MessageBox.WARNING); + return; + } + if(targetComp instanceof TCComponent) { + TCComponent comp = (TCComponent) targetComp; + try { + TCComponent[] comps = comp.getReferenceListProperty("contents"); + for (int i = 0; i < comps.length; i++) { + String name = comps[i].getStringProperty("object_name"); + if("产品设计开发".equals(name)) { + MessageBox.post("【已存在文件夹结构,不进行创建】!!!" ,"提示", + MessageBox.INFORMATION); + return; + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + String targetType = comp.getType(); + if( "Folder".equals(targetType) ) { + try { + List list = bean.getChildName(); + for (int i = 0; i < list.size(); i++) { + int num = 1; + ChildFolderPart childBean = list.get(i); + createProject(comp,childBean,num); + } + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post("文件夹对象创建失败!!!" ,"提示", + MessageBox.INFORMATION); + e.printStackTrace(); + return; + } + try { + String name = ((TCComponentFolder) targetComp).getStringProperty("object_name"); + System.out.println("======name" + name); + TCComponentUser atccomponentuser[] = new TCComponentUser[1]; + atccomponentuser[0] = session.getUser(); + System.out.println("======UserId" + session.getUser().getUid()); + if(name != null && !("".equals(name.trim()))) { + String[] keys = new String[]{"项目 ID"}; + String[] values = new String[]{name}; + List compList = queryObject("基于项目ID查找项目", keys, values); + if(compList != null && compList.size() > 0) { + TCComponent[] folders =new TCComponent[folderList.size()]; + for (int i = 0; i < folders.length; i++) { + folders[i] = folderList.get(i); + } + for (int i = 0; i < compList.size(); i++) { + TCComponent target = compList.get(i); + if(target instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) target; + project.assignToProject(folders); + break; + } + } + +// MessageBox.post("【已存在相同ID的项目,不进行创建】!!!" ,"提示", +// MessageBox.INFORMATION); + }else { + TCComponentProjectType projectType = (TCComponentProjectType) session.getTypeComponent("TC_Project"); + TCComponentProject project = projectType.create(name, name, name, new TCComponent[] { atccomponentuser[0] }, atccomponentuser[0], new TCComponentUser[] {}); + TCComponent[] folders =new TCComponent[folderList.size()+1]; + for (int i = 0; i < folders.length-1; i++) { + folders[i] = folderList.get(i); + } + folders[folders.length-1] = (TCComponentFolder) targetComp; + project.assignToProject(folders); + } + } + } catch (TCException e) { + setVisible(false); + MessageBox.post("项目创建 失败!!!" ,"提示", + MessageBox.INFORMATION); + e.printStackTrace(); + } + setVisible(false); + MessageBox.post("文件夹结构创建成功,请在当前文件夹下查看!!!" ,"提示", + MessageBox.INFORMATION); + }else { + setVisible(false); + MessageBox.post("选中的不是文件夹对象,请选择一个文件夹!!!" ,"提示", + MessageBox.INFORMATION); + } + }else { + setVisible(false); + MessageBox.post("没有选中对象,请选择!!!" ,"提示", + MessageBox.INFORMATION); + } + + } + + public void createProject(TCComponent comp,ChildFolderPart bean,int num) throws TCException { + //创建文件夹 + String name = bean.getName(); + TCComponentFolderType t= (TCComponentFolderType)session.getTypeComponent("Folder"); + TCComponentFolder folder =t.create(name, "My Folder Description","Folder"); + comp.add("contents", folder); + if(num == 1) { + folderList.add(folder); + System.out.println("name==========="+name); + } + List childList = bean.getChildName(); + if(childList != null && childList.size() > 0) { + num++; + for (int i = 0; i < childList.size(); i++) { + ChildFolderPart childBean = childList.get(i); + createProject(folder,childBean,num); + } + } + } + + /** + * 通过查询构建器查询项目对象 + * @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/dfl/plm/dfl007/Dfl007Handler.java b/src/com/connor/dfl/plm/dfl007/Dfl007Handler.java new file mode 100644 index 0000000..ea379bd --- /dev/null +++ b/src/com/connor/dfl/plm/dfl007/Dfl007Handler.java @@ -0,0 +1,33 @@ +package com.connor.dfl.plm.dfl007; + +import org.eclipse.core.commands.AbstractHandler; +/** + * 程序名:通过菜单创建出项目任务结构 + * 程序描述:通过菜单创建出项目任务结构 + * 创建日期:2020-06-28 + * 程序员:suny + * + * + * 修改日期 修改人 修改描述 + * + * + */ +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; + +public class Dfl007Handler extends AbstractHandler { + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent comp = app.getTargetComponent(); + CreateProjectDialog2 createProjectDialog2 = new CreateProjectDialog2(app,comp); + new Thread(createProjectDialog2).start(); + return null; + } + +} diff --git a/src/com/connor/dfl/plm/dfl007/FolderPart.java b/src/com/connor/dfl/plm/dfl007/FolderPart.java new file mode 100644 index 0000000..0e3aab8 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl007/FolderPart.java @@ -0,0 +1,17 @@ +package com.connor.dfl.plm.dfl007; + +import java.util.List; + +public class FolderPart { + private List childName; + public List getChildName() { + return childName; + } + public void setChildName(List childName) { + this.childName = childName; + } + @Override + public String toString() { + return "FolderPart [childName=" + childName + "]"; + } +} diff --git a/src/com/connor/dfl/plm/dfl007/ParseFolderXML.java b/src/com/connor/dfl/plm/dfl007/ParseFolderXML.java new file mode 100644 index 0000000..d937a6d --- /dev/null +++ b/src/com/connor/dfl/plm/dfl007/ParseFolderXML.java @@ -0,0 +1,127 @@ +package com.connor.dfl.plm.dfl007; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +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 ParseFolderXML { + /** + * 解析编码规则XML + * @param file + */ + public FolderPart parseXMLCode(File file) { + FolderPart bean =new FolderPart(); + List fuList = new ArrayList(); + try { + SAXReader saxReader = new SAXReader(); + Document document = saxReader.read(file); + Element root = document.getRootElement(); + Iterator iter = root.elementIterator("largeclass");// part标签 + while (iter.hasNext()) { + Element recordEle = (Element) iter.next(); + Iterator iter2 = recordEle.elementIterator("subclass");// subclass标签 + getCode(iter2, fuList); + } + } catch (Exception e) { + e.printStackTrace(); + } + bean.setChildName(fuList); + return bean; + } + + /** + * 递归遍历编码xml + * + * @param iter2 + * @param codeList + */ + private void getCode(Iterator iter2, List list) { + while (iter2.hasNext()) { + ChildFolderPart zimenuBean=new ChildFolderPart(); + Element recordEle2 = (Element) iter2.next(); + String type = recordEle2.attributeValue("type"); + String name = recordEle2.attributeValue("name"); + zimenuBean.setName(name); + List codeList = new ArrayList(); + zimenuBean.setChildName(codeList); + list.add(zimenuBean); + if (type != null && type.toUpperCase().equals("S")) { + + } else { + Iterator iter3 = recordEle2.elementIterator("subclass"); + if (iter3.hasNext()) { + getCode(iter3, codeList); + } + } + + } + } + /** + * 通过首选项里的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) { + MessageBox.post("数据集没有命名引用的文件或文件过多,请检查!", "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:\\2.xml"); +// ParseXML t = new ParseXML(); +// // t.parseXML(file); +// t.parseXMLCode(file2); +// } +} diff --git a/src/com/connor/dfl/plm/dfl008/CreateEquipmentDialogs.java b/src/com/connor/dfl/plm/dfl008/CreateEquipmentDialogs.java new file mode 100644 index 0000000..89cbd8b --- /dev/null +++ b/src/com/connor/dfl/plm/dfl008/CreateEquipmentDialogs.java @@ -0,0 +1,626 @@ +package com.connor.dfl.plm.dfl008; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GridBagLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.connor.dfl.plm.util.CopyPropsBean; +import com.connor.dfl.plm.util.DataBaseControl; +import com.itextpdf.text.Jpeg; +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.aifrcp.AIFUtility; +import com.teamcenter.rac.commands.userpreferences.ProductContextPreferencesPanel; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.ServiceData; +import com.teamcenter.rac.kernel.SoaUtil; +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.TCComponentForm; +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.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +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.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Utilities; +import com.teamcenter.soaictstubs.stringSeq_tHolder; + +public class CreateEquipmentDialogs extends AbstractAIFDialog { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + private InterfaceAIFComponent targetComp; + private TCPreferenceService service; + + TCSession session = (TCSession) app.getSession(); + + private JPanel panel1; + + private JPanel buttonPanel; + + + + private JLabel id_lable; + // private JLabel name_lable; + private JLabel client_name_lable; + private JLabel department_lable; + + + + private JLabel groupCode_lable; + private JLabel sourceCode_lable; + private JComboBox groupCode_combobox; + private JComboBox sourceCode_combobox; + + + + private JLabel product_model_lable; + private JLabel product_name_lable; + private JLabel unit_lable; + private JLabel project_number_lable; + + private JLabel BI_lABLE1; + private JLabel BI_lABLE2; + + private JTextField id_field; + // private JTextField name_field; + private JTextField client_name_field; + private JTextField department_field; + private JTextField product_model_field; + private JTextField product_name_field; + private JTextField unit_field; + private JComboBox project_number_combobox; + + private JButton certain_btn; + private JButton cancel_btn; + private Map groupMap=new HashMap(); + private Map sourceMap=new HashMap(); + private String[] boms; + private String customerName; + private String Productmodel; + + public CreateEquipmentDialogs(AbstractAIFApplication app,InterfaceAIFComponent targetComp) { + super(); + this.app = app; + this.session = session; + this.service = session.getPreferenceService(); + this.targetComp = targetComp; + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + boms = service.getStringValues("DFL2_Standard_BOM"); + if(boms == null || boms.length <= 0) { + MessageBox.post("首选项DFL2_Standard_BOM未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + } + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + private void init() throws TCException { + this.setTitle("创建设备"); + this.setPreferredSize(new Dimension(450, 450)); + this.setAlwaysOnTop(true); + + this.setLayout(null); + // buttonPanel = new JPanel(); + // buttonPanel.setLayout(new ButtonLayout(ButtonLayout.HORIZONTAL)); + + id_lable = new JLabel(" 品号 (必填): "); + // name_lable = new JLabel(" 品名 (必填): "); + client_name_lable = new JLabel("客户名称 (必填) :"); + department_lable = new JLabel("所属事业部 (必填) :"); + product_model_lable = new JLabel("产品型号 (必填) :"); + product_name_lable = new JLabel("产品名称 (必填) :"); + unit_lable = new JLabel("单位 (必填) :"); + groupCode_lable = new JLabel(" 分群码 :"); + sourceCode_lable = new JLabel(" 来源码 :"); + groupCode_combobox = new JComboBox();groupCode_combobox.addItem(" "); + sourceCode_combobox = new JComboBox();sourceCode_combobox.addItem(" "); + + project_number_lable = new JLabel(" 项目编号 :"); + + + + BI_lABLE1 = new JLabel("*"); + BI_lABLE1.setFont(new Font("微软雅黑", Font.BOLD, 13)); + BI_lABLE1.setForeground(Color.RED); + + + BI_lABLE2 = new JLabel("*"); + BI_lABLE2.setFont(new Font("微软雅黑", Font.BOLD, 13)); + BI_lABLE2.setForeground(Color.RED); + + + id_field = new JTextField(35); + // name_field = new JTextField(35); + client_name_field = new JTextField(35); + department_field = new JTextField(35); + product_model_field = new JTextField(35); + product_name_field = new JTextField(35); + unit_field = new JTextField(35); + project_number_combobox = new JComboBox(); + project_number_combobox.addItem(" "); + project_number_combobox.setEditable(true); + project_number_combobox.setPreferredSize(new Dimension(10, 35)); + + + + String[] keys = new String[] { "ID" }; + TCComponentUser user = session.getUser(); + String user_id = user.getStringProperty("user_id"); + String[] values = new String[] { user_id }; + List compList = queryObject("基于用户的项目", keys, values); + if (compList != null && compList.size() > 0) { + for (int i = 0; i < compList.size(); i++) { + TCComponent comp = compList.get(i); + if (comp instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) comp; + try { + String id = project.getStringProperty("project_id"); + project_number_combobox.addItem(id); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + } + + + + + // + String[] groupvalues = new String[]{}; + String lovgroupname=service.getStringValue("T2_groupCode"); + System.out.println("lovname="+lovgroupname); + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lov1 = lovType.find(lovgroupname); + System.out.println("lov1="+lov1.length); + if(lov1.length > 0){ + ListOfValuesInfo value = lov1[0].getListOfValues(); + groupvalues = value.getStringListOfValues(); + for (int i = 0; i < groupvalues.length; i++) { + String disval = value.getDisplayableValue(groupvalues[i]); + groupCode_combobox.addItem(disval); + groupMap.put(disval, groupvalues[i]); + + } + + } + + + // + String[] sourcevalues = new String[]{}; + String lovsourcename=service.getStringValue("T2_sourceCode");//"T2_unitsLOV" + System.out.println("lovname="+lovsourcename); + TCComponentListOfValuesType lovType1 = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lov2 = lovType1.find(lovsourcename); + System.out.println("lov2="+lov2.length); + if(lov2.length > 0){ + ListOfValuesInfo value = lov2[0].getListOfValues(); + sourcevalues = value.getStringListOfValues(); + for (int i = 0; i < sourcevalues.length; i++) { + String disval = value.getDisplayableValue(sourcevalues[i]); + sourceCode_combobox.addItem(disval); + sourceMap.put(disval, sourcevalues[i]); + } + } + + id_lable.setBounds(50, 30, 130, 30); + id_field.setBounds(170, 30, 200, 30); + BI_lABLE1.setBounds(305, 30, 15, 15); + this.add(id_lable); + this.add(id_field); + this.add(BI_lABLE1); + + + // name_lable.setBounds(50, 70, 130, 30); + // name_field.setBounds(170, 70, 200, 30); + // BI_lABLE2.setBounds(305, 70, 15, 15); + // this.add(name_lable); + // this.add(name_field); + // this.add(BI_lABLE2); + + + client_name_lable.setBounds(50, 70, 130, 30); + client_name_field.setBounds(170, 70, 200, 30); + this.add(client_name_lable); + this.add(client_name_field); + + + department_lable.setBounds(50, 110, 130, 30); + department_field.setBounds(170, 110, 200, 30); + this.add(department_lable); + this.add(department_field); + + product_model_lable.setBounds(50, 150, 130, 30); + product_model_field.setBounds(170, 150, 200, 30); + this.add(product_model_lable); + this.add(product_model_field); + + product_name_lable.setBounds(50, 190, 130, 30); + product_name_field.setBounds(170, 190, 200, 30); + this.add(product_name_lable); + this.add(product_name_field); + + unit_lable.setBounds(50, 230, 130, 30); + unit_field.setBounds(170,230, 200, 30); + this.add(unit_lable); + this.add(unit_field); + + groupCode_lable.setBounds(50, 270, 130, 30); + groupCode_combobox.setBounds(170,270, 200, 30); + this.add(groupCode_lable); + this.add(groupCode_combobox); + + + sourceCode_lable.setBounds(50, 310, 130, 30); + sourceCode_combobox.setBounds(170,310, 200, 30); + this.add(sourceCode_lable); + this.add(sourceCode_combobox); + + TCComponent comp = (TCComponent) targetComp; + + + //String groupname= session.getGroup().getGroupName(); + TCComponentGroup group = session.getGroup(); + + + String groupnames = session.getGroup().getStringProperty("display_name"); + String [] buisnisDivisions= groupnames.split("\\."); + String groupname =""; + + if(buisnisDivisions.length>=2) { + groupname = buisnisDivisions[buisnisDivisions.length-2]; + + } + + String fordername = comp.getStringProperty("object_name"); + + System.out.println("============"+groupname); + //设置id + id_field.setText(fordername); + + //分解t2_OA1的值 + String t2_OA1 = comp.getStringProperty("t2_OA1"); + if (t2_OA1!="") { + String[] t2oastrings = t2_OA1.split("_"); + + //设置客户名称 + customerName = t2oastrings[0]; + client_name_field.setText(customerName); + //设置产品型号 + Productmodel = t2oastrings[2]; + product_model_field.setText(Productmodel); + } + + //所属事业部=登录账户组织 + // + // if(applynames.length > 0) { + // department_field.setText(applynames[0]); + // } + // else { + // department_field.setText(applyname); + // } + // + + department_field.setText(groupname); + + certain_btn = new JButton("确定"); + + cancel_btn = new JButton("取消"); + + certain_btn.setBounds(80, 350, 70, 35); + + cancel_btn.setBounds(320, 350, 70, 35); + this.add(certain_btn); + this.add(cancel_btn); + + + + cancel_btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + setVisible(false); + } + }); + + certain_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + + // String[] keys = new String[]{"零组件 ID"}; + // String[] values = new String[]{"*"}; + // List compList = queryObject("零组件 ID", keys, values); + // if(compList != null && compList.size() > 0) { + // for (int i = 0; i < compList.size(); i++) { + // TCComponent comp = compList.get(i); + // if(comp instanceof TCComponentProject) { + // + // TCComponentProject project = (TCComponentProject) comp; + // try { + // String id = project.getStringProperty("item_id"); + // System.out.println(id_field.getText()); + // if(id_field.getText().equals(id)) { + // MessageBox.post("系统中已有该id,请重新输入","错误",MessageBox.ERROR); + // }else if(id_field.getText()==null) { + // MessageBox.post("id不能为空","错误",MessageBox.ERROR); + // }else { + + + + String s = id_field.getText(); + // String n= name_field.getText(); + String customerName = client_name_field.getText(); + String bu = department_field.getText(); + String productModel = product_model_field.getText(); + String productName = product_name_field.getText(); + String unit = unit_field.getText(); + // private JTextField client_name_field; + // private JTextField department_field; + // private JTextField product_model_field; + if(!("".equals(s.trim())) + // && !("".equals(n.trim())) + && !("".equals(customerName.trim())) && !("".equals(bu.trim())) + && !("".equals(productModel.trim())) && !("".equals(productName.trim())) + && !("".equals(unit.trim()))) { + createItem(); + }else { + MessageBox.post("必填属性不能为空!", "提示", MessageBox.INFORMATION); + return; + //System.out.println(); + } + + + // + // } + // } catch (TCException e1) { + // // TODO Auto-generated catch block + // e1.printStackTrace(); + // } + // } + } + // } + + // } + + }); + + this.pack(); + this.setResizable(false); + this.centerToScreen(); + this.showDialog(); + + } + + + + /** + * 通过查询构建器查询项目对象 + * + * @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; + } + } + + protected void createItem() { + // TODO Auto-generated method stub + try { + + TCComponentItemType tctype = (TCComponentItemType) session.getTypeComponent("T2_Equipment"); + String itemid = id_field.getText(); + // String itemName = name_field.getText(); + + String clientname = client_name_field.getText(); + String department = department_field.getText(); + String product = product_model_field.getText(); + String productName = product_name_field.getText(); + String unit = unit_field.getText(); + if("".equals(itemid.trim()) + // || "".equals(itemName.trim()) + || "".equals(clientname.trim()) || + "".equals(department.trim()) || "".equals(product.trim()) || "".equals(productName.trim()) + || "".equals(unit.trim())) { + MessageBox.post("请填写完成所有的必填属性!!!", "错误", + MessageBox.ERROR); + return; + } + String group =groupMap.get( groupCode_combobox.getSelectedItem()); + String source = sourceMap.get( sourceCode_combobox.getSelectedItem()); + + TCComponentItem find = tctype.find(itemid); + + if (find != null) { + setVisible(false); + MessageBox.post("当前流水ID:" + itemid + "已存在对象,无法创建!", "错误", + MessageBox.ERROR); + + } else { + + TCComponentItem item = tctype.create(itemid, "01", "T2_Equipment", productName, "", null); + + TCComponentItemRevision rev = item.getLatestItemRevision(); + + if (clientname != null && clientname != "") { + rev.setStringProperty("t2_CustomerName", clientname); + } + if (department != null && department != "") { + rev.setStringProperty("t2_BU", department); + } + if (product != null && product != "") { + rev.setStringProperty("t2_ProductModel", product); + } + if (productName != null && productName != "") { + rev.setStringProperty("t2_ProductName", productName); + rev.setStringProperty("object_name", productName); + } + if (unit != null && unit != "") { + rev.setStringProperty("t2_unit", unit); + } + if (group != null && group != "") { + rev.setStringProperty("t2_groupCode", group); + } + if (source != null && source != "") { + rev.setStringProperty("t2_sourceCode", source); + } + + this.setVisible(false); + boolean isNewStuff = true; + if (targetComp == null) { + session.getUser().getNewStuffFolder().add("contents", item); + } else if (targetComp instanceof TCComponentFolder) { + ((TCComponentFolder) targetComp).add("contents", item); + System.out.println("111111111111111111111111111111111"); + isNewStuff = false; + } else { + session.getUser().getNewStuffFolder().add("contents", item); + } + if (isNewStuff) { + MessageBox.post("对象" + item + "创建成功,请在NewStuff文件夹下查看!", + "成功", MessageBox.INFORMATION); + } else { + MessageBox.post("对象" + item + "创建成功,请在当前文件夹下查看!", "成功", + MessageBox.INFORMATION); + } + // String proID = (String) project_number_combobox.getSelectedItem(); + // if(proID != null & proID !=" ") { + // String[] keys = new String[]{"项目 ID"}; + // String[] values = new String[]{proID}; + // List compList = queryObject("基于项目ID查找项目", keys, values); + // if(compList != null && compList.size() > 0) { + // TCComponent comp = compList.get(0); + // if(comp instanceof TCComponentProject) { + // TCComponentProject project = (TCComponentProject) comp; + // // project.getStringProperty(""); + // + // TCComponentUser atccomponentuser[] = new TCComponentUser[1]; + // com.teamcenter.services.internal.rac.core.DataManagementService datamanagementservice = com.teamcenter.services.internal.rac.core.DataManagementService.getService(session); + // ServiceData servicedata = datamanagementservice.setDefaultProjectForProjectMembers(project,atccomponentuser); + // // if (servicedata != null && servicedata.sizeOfPartialErrors() > 0) { + // // com.teamcenter.rac.kernel.TCExceptionPartial tcexceptionpartial = SoaUtil + // // .checkPartialErrorsNoThrow(servicedata); + // // MessageBox.post(Utilities.getCurrentFrame(), + // // tcexceptionpartial); + // // } + // project.assignToProject(new TCComponent[] {item}); + // + // } + // } + // } +// boolean flag = true; +// String[] vals = null; +// for (int i = 0; i < boms.length; i++) { +// String bom = boms[i]; +// vals = bom.split("="); +// if(groupCode_combobox.getSelectedItem().equals(vals[0])) { +// flag = false; +// break; +// } +// } +// if(vals != null) { +// if(flag) { +// MessageBox.post("没有配置对应的标准BOM结构,需手动创建虚拟系统层级!!!", "提示", +// MessageBox.INFORMATION); +// }else { +// TCTypeService service = session.getTypeService(); +// //获取BOMWindowType +// TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service +// .getTypeComponent("BOMWindow"); +// //创建一个新的window +// TCComponentBOMWindow view = winType.create(null); +// +// view.lock(); +// //设置顶层的bomline +// TCComponentBOMLine line = view.setWindowTopLine(item, +// rev, null, null); +// TCComponentItemType type = (TCComponentItemType) session.getTypeComponent("T2_Virtual"); +// String[] values = vals[1].split(";"); +// for (int j = 0; j < values.length; j++) { +// String[] nameID = values[j].split("\\|"); +// String item_id = itemid + "" + nameID[0]; +// System.out.println(item_id); +// TCComponentItem newItem = type.create(item_id, "01", "T2_Virtual", nameID[1], "", null); +// if (targetComp == null) { +// session.getUser().getNewStuffFolder().add("contents", newItem); +// } else if (targetComp instanceof TCComponentFolder) { +// ((TCComponentFolder) targetComp).add("contents", newItem); +// } else { +// session.getUser().getNewStuffFolder().add("contents", newItem); +// } +// //添加子bomline +// TCComponentBOMLine childBomline = +// line.add(newItem, newItem.getLatestItemRevision(), null, false, ""); +// } +// view.save(); +// view.unlock(); +// view.close(); +// } +// } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("错误:" + e.getMessage(), "错误", MessageBox.INFORMATION); + } + } +} diff --git a/src/com/connor/dfl/plm/dfl008/Dfl008Handler.java b/src/com/connor/dfl/plm/dfl008/Dfl008Handler.java new file mode 100644 index 0000000..575ade2 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl008/Dfl008Handler.java @@ -0,0 +1,21 @@ +package com.connor.dfl.plm.dfl008; + +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; + +public class Dfl008Handler extends AbstractHandler { + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent com = app.getTargetComponent(); + CreateEquipmentDialogs createEquipment = new CreateEquipmentDialogs(app ,com); + new Thread(createEquipment).start(); + return null; + } + +} diff --git a/src/com/connor/dfl/plm/dfl009/CreateSystemSchemeDialog.java b/src/com/connor/dfl/plm/dfl009/CreateSystemSchemeDialog.java new file mode 100644 index 0000000..016a810 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl009/CreateSystemSchemeDialog.java @@ -0,0 +1,457 @@ +package com.connor.dfl.plm.dfl009; +/*创建系统方案 + * + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.sun.xml.bind.v2.runtime.unmarshaller.LocatorEx.Snapshot; +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.ServiceData; +import com.teamcenter.rac.kernel.SoaUtil; +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.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Utilities; + +public class CreateSystemSchemeDialog extends AbstractAIFDialog { + private AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + private InterfaceAIFComponent targetComp; + private TCPreferenceService service; + + TCSession session = (TCSession) app.getSession(); + + private String foldername ="" ; + private JLabel id_lable; + private JLabel name_lable; + private JLabel project_lable; + + private JLabel BI_lABLE1; + private JLabel BI_lABLE2; + + private JTextField id_field; + private JTextField name_field; + private JComboBox project_comboBox; + + private JButton certain_btn; + private JButton cancel_btn; + + + + private JLabel groupCode_lable; + private JLabel sourceCode_lable; + private JComboBox groupCode_combobox; + private JComboBox sourceCode_combobox; + + + private Map groupMap=new HashMap(); + private Map sourceMap=new HashMap(); + + public CreateSystemSchemeDialog(AbstractAIFApplication app ,InterfaceAIFComponent targetComp ) { + super(); + this.app = app; + this.session = session; + this.service = session.getPreferenceService(); + this.targetComp = targetComp; + } + + @Override + public void run() { + // TODO Auto-generated method stub + super.run(); + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void init() throws TCException { + // TODO Auto-generated method stub + + this.setTitle("创建系统方案"); + + this.setPreferredSize(new Dimension(450, 360)); + this.setAlwaysOnTop(true); + this.setLayout(null); + + TCComponent mycomp = (TCComponent) targetComp; + + AIFComponentContext[] contex = mycomp.whereReferenced(); + if(contex.length>0) { + TCComponentFolder folder = (TCComponentFolder) contex[0].getComponent(); + foldername = folder.getStringProperty("object_name"); + } + + + id_lable = new JLabel(" 品号 :"); + id_field = new JTextField(20); + // id_field.setEditable(false); + id_field.setText(foldername); + + + name_lable = new JLabel(" 品名 :"); + name_field = new JTextField(20); + project_lable = new JLabel(" 项 目 :"); + project_comboBox = new JComboBox(); + project_comboBox.addItem(" "); + + + groupCode_lable = new JLabel(" 分群码 :"); + sourceCode_lable = new JLabel(" 来源码 :"); + groupCode_combobox = new JComboBox();groupCode_combobox.addItem(" "); + sourceCode_combobox = new JComboBox();sourceCode_combobox.addItem(" "); + + + + BI_lABLE1 = new JLabel("*"); + BI_lABLE1.setFont(new Font("微软雅黑", Font.BOLD, 16)); + BI_lABLE1.setForeground(Color.RED); + + + BI_lABLE2 = new JLabel("*"); + BI_lABLE2.setFont(new Font("微软雅黑", Font.BOLD, 16)); + BI_lABLE2.setForeground(Color.RED); + + + boolean flag =false; + String[] keys = new String[] { "ID" }; + TCComponentUser user = session.getUser(); + String user_id = user.getStringProperty("user_id"); + String[] values = new String[] { user_id }; + List compList = queryObject("基于用户的项目", keys, values); + if (compList != null && compList.size() > 0) { + for (int i = 0; i < compList.size(); i++) { + TCComponent comp = compList.get(i); + if (comp instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) comp; + try { + String id = project.getStringProperty("project_id"); + if(foldername.equals(id)) { + flag = true; + } + project_comboBox.addItem(id); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + + if(flag) { + project_comboBox.setSelectedItem(foldername); + } + + + + } + + + + + project_comboBox.setEditable(true); + project_comboBox.setSize(10, 25); + certain_btn = new JButton("确定"); + cancel_btn = new JButton("取消"); + + id_lable.setBounds(60,40,100,30); + id_field.setBounds(160,40,200,30); + + BI_lABLE1.setBounds(365, 40, 15, 15); + + + this.add(id_lable); + this.add(id_field); + this.add(BI_lABLE1); + + + name_lable.setBounds(60,80 , 80, 30); + name_field.setBounds(160,80 , 200, 30); + BI_lABLE2.setBounds(365, 80, 15, 15); + this.add(name_lable); + this.add(name_field); + this.add(BI_lABLE2); + + + + + + + + project_lable.setBounds(60, 120,100, 30); + project_comboBox.setBounds(160, 120, 200, 30); + + + + + + this.add(project_lable); + this.add(project_comboBox); + + + +// groupCode_lable.setBounds(60, 160,100, 30); +// groupCode_combobox.setBounds(160, 160,200, 30); +// this.add(groupCode_lable); +// this.add(groupCode_combobox); + +// sourceCode_lable.setBounds(60, 200,100, 30); +// sourceCode_combobox.setBounds(160, 200,200, 30); +// this.add(sourceCode_lable); +// this.add(sourceCode_combobox); + + // + String[] groupvalues = new String[]{}; + String lovgroupname=service.getStringValue("T2_groupCode"); + System.out.println("lovname="+lovgroupname); + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lov1 = lovType.find(lovgroupname); + System.out.println("lov1="+lov1.length); + if(lov1.length > 0){ + ListOfValuesInfo value = lov1[0].getListOfValues(); + groupvalues = value.getStringListOfValues(); + for (int i = 0; i < groupvalues.length; i++) { + String disval = value.getDisplayableValue(groupvalues[i]); + groupCode_combobox.addItem(disval); + groupMap.put(disval, groupvalues[i]); + + } + + } + + // + String[] sourcevalues = new String[]{}; + String lovsourcename=service.getStringValue("T2_sourceCode");//"T2_unitsLOV" + System.out.println("lovname="+lovsourcename); + TCComponentListOfValuesType lovType1 = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lov2 = lovType1.find(lovsourcename); + System.out.println("lov2="+lov2.length); + if(lov2.length > 0){ + ListOfValuesInfo value = lov2[0].getListOfValues(); + sourcevalues = value.getStringListOfValues(); + for (int i = 0; i < sourcevalues.length; i++) { + String disval = value.getDisplayableValue(sourcevalues[i]); + sourceCode_combobox.addItem(disval); + sourceMap.put(disval, sourcevalues[i]); + + } + + } + + + + + + certain_btn.setBounds(70, 280,70, 35); + cancel_btn.setBounds(300, 280, 70, 35); + this.add(certain_btn); + this.add(cancel_btn); + + + this.setResizable(false); +// this.setAlwaysOnTop(true); + //this.add(new JLabel(" ")); + this.setVisible(true); + this.centerToScreen(); + + cancel_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + setVisible(false); + } + }); + + certain_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + + String s = id_field.getText(); + String n= name_field.getText(); + if(s.length()>0 && n.length() >0) { + createItem(); + + }else { + setVisible(false); + MessageBox.post("品号和品名不能为空!", "提示", MessageBox.INFORMATION); + //System.out.println(); + } + } + }); + } + + protected void createItem() { + // TODO Auto-generated method stub + try { + + TCComponentItemType tctype = (TCComponentItemType) session.getTypeComponent("T2_SystemScheme"); + String itemid = id_field.getText(); + String itemName = name_field.getText(); + + String group =groupMap.get(groupCode_combobox.getSelectedItem()); + String source=sourceMap.get(sourceCode_combobox.getSelectedItem()); + + + + TCComponentItem find = tctype.find(itemid); + + if (find != null) { + setVisible(false); + MessageBox.post("当前流水ID:" + itemid + "已存在对象,无法创建!", "错误", + MessageBox.ERROR); + + + + } else { + + + + TCComponentItem item = tctype.create(itemid, "01", "T2_SystemScheme", itemName, "", null); + + TCComponentItemRevision rev = item.getLatestItemRevision(); + + if (group != null && group != "") { + rev.setStringProperty("t2_groupCode", group); + } + if (source != null && source != "") { + rev.setStringProperty("t2_sourceCode", source); + } + + + // + // if (clientname != null && clientname != "") { + // rev.setStringProperty("t2_CustomerName", clientname); + // } + + // if (department != null && department != "") { + // rev.setStringProperty("t2_BusinessDepartment", department); + // } + // if (product != null && product != "") { + // rev.setStringProperty("t2_model", product); + // } + + + this.setVisible(false); + + boolean isNewStuff = true; + if (targetComp == null) { + session.getUser().getNewStuffFolder().add("contents", item); + } else if (targetComp instanceof TCComponentFolder) { + ((TCComponentFolder) targetComp).add("contents", item); + System.out.println("111111111111111111111111111111111"); + isNewStuff = false; + } else { + session.getUser().getNewStuffFolder().add("contents", item); + } + if (isNewStuff) { + MessageBox.post("对象" + item + "创建成功,请在NewStuff文件夹下查看!", + "成功", MessageBox.INFORMATION); + } else { + MessageBox.post("对象" + item + "创建成功,请在当前文件夹下查看!", "成功", + MessageBox.INFORMATION); + } + + + + + String proID = (String) project_comboBox.getSelectedItem(); + if(proID != null & proID !=" ") { + String[] keys = new String[]{"项目 ID"}; + String[] values = new String[]{proID}; + List compList = queryObject("基于项目ID查找项目", keys, values); + if(compList != null && compList.size() > 0) { + TCComponent comp = compList.get(0); + if(comp instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) comp; + TCComponentUser atccomponentuser[] = new TCComponentUser[1]; + com.teamcenter.services.internal.rac.core.DataManagementService datamanagementservice = com.teamcenter.services.internal.rac.core.DataManagementService.getService(session); + ServiceData servicedata = datamanagementservice.setDefaultProjectForProjectMembers(project,atccomponentuser); + // if (servicedata != null && servicedata.sizeOfPartialErrors() > 0) { + // com.teamcenter.rac.kernel.TCExceptionPartial tcexceptionpartial = SoaUtil + // .checkPartialErrorsNoThrow(servicedata); + // MessageBox.post(Utilities.getCurrentFrame(), + // tcexceptionpartial); + // } + project.assignToProject(new TCComponent[] {item}); + + + + } + } + } + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("错误:" + e.getMessage(), "错误", MessageBox.INFORMATION); + } + } + + /** + * 通过查询构建器查询项目对象 + * + * @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/dfl/plm/dfl009/Dfl009Handler.java b/src/com/connor/dfl/plm/dfl009/Dfl009Handler.java new file mode 100644 index 0000000..95804b6 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl009/Dfl009Handler.java @@ -0,0 +1,23 @@ +package com.connor.dfl.plm.dfl009; + +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.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class Dfl009Handler extends AbstractHandler{ + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComp =app.getTargetComponent(); + CreateSystemSchemeDialog createSystemScheme = new CreateSystemSchemeDialog(app , targetComp); + new Thread(createSystemScheme).start(); + return null; + } + + +} diff --git a/src/com/connor/dfl/plm/dfl010/CreateProblemSpotDialog.java b/src/com/connor/dfl/plm/dfl010/CreateProblemSpotDialog.java new file mode 100644 index 0000000..b70a3c7 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl010/CreateProblemSpotDialog.java @@ -0,0 +1,602 @@ +package com.connor.dfl.plm.dfl010; + + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.border.LineBorder; + +import com.connor.dfl.plm.util.CodeBean; +import com.connor.dfl.plm.util.DataBaseControl; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.ServiceData; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFormType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemRevisionType; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class CreateProblemSpotDialog extends AbstractAIFDialog { + private AbstractAIFApplication app ; + private InterfaceAIFComponent targetComp; + private TCSession session; + private TCPreferenceService service; + private CodeBean selCodeBean ; + + private JPanel jp2; + + private JLabel id_lable; + private JLabel name_lable; + private JLabel equip_lable; + private JLabel project_lable; + + + private JLabel CustomerName_lable; + private JLabel PD_lable; + private JLabel ProductName_lable; + private JLabel ProductModel_lable; + private JLabel ProductType_lable; + private JLabel Department_lable; + private JLabel duty_lable; + private JLabel ProjectPhase_lable; + private JLabel ProType_lable; + private JLabel importance_lable; + private JLabel cause_lable; + // private JLabel ProcessState_lable; + //private JLabel anticipated_lable; + + + + // private JLabel BI_lABLE1; + + + private JTextField id_field; + private JTextField name_field; + private JTextArea equip_field; + private JTextField CustomerName_field; + private JTextField PD_field; + private JTextField ProductName_field; + private JTextField ProductModel_field; + private JTextField duty_field; + private JTextField cause_field; + private JTextArea project_field; + //private JTextField anticipated_field; + + + private JComboBox ProductTypeComboBox; + private JComboBox DepartmentComboBox; + private JComboBox ProjectPhaseComboBox; + private JComboBox ProTypeComboBox; + private JComboBox importanceComboBox; + // private JComboBox ProcessStateComboBox; + + private Map ProductTypeMap; + private Map DepartmentMap; + private Map ProjectPhaseMap; + private Map ProTypeMap; + private Map importanceMap; + // private Map ProcessStateMap; + + + private JButton assign_btn; + + private JButton equip_btn; + + + private JButton certain_btn; + private JButton cancel_btn; + + + + + public CreateProblemSpotDialog(AbstractAIFApplication app ,InterfaceAIFComponent targetComp ) { + super(); + this.app = app; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.targetComp = targetComp; + } + + @Override + public void run() { + // TODO Auto-generated method stub + super.run(); + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void init() throws TCException { + // TODO Auto-generated method stub + this.setLayout(new PropertyLayout()); + this.setTitle("创建问题点"); + this.setPreferredSize(new Dimension(500, 750)); + this.setResizable(false);// 不可变动窗口大小 + TCComponentUser user = session.getUser(); + String userName = user.getStringProperty("user_name"); + jp2 = new JPanel(new PropertyLayout()); + jp2.setPreferredSize(new Dimension(450, 650)); + String attrType =""; + id_lable = new JLabel(" 问题点编号 (必填):"); + id_field = new JTextField(15); + id_field.setEditable(false); + name_lable = new JLabel(" 名称 (必填) :"); + name_field = new JTextField(15); + name_field.setText("问题点"); + equip_lable = new JLabel(" 设备号 (必填) :"); + equip_field = new JTextArea(5,15); + equip_field.setLineWrap(true); + equip_field.setWrapStyleWord(true); + equip_field.setBorder(new LineBorder(new java.awt.Color(127,157,185), 1, false)); + CustomerName_lable = new JLabel(" 客户名称 (必填) :"); + CustomerName_field = new JTextField(20); + PD_lable = new JLabel(" 所属产品部 (必填) :"); + PD_field = new JTextField(15); + ProductName_lable = new JLabel(" 产品名称 (必填):"); + ProductName_field = new JTextField(15); + ProductModel_lable = new JLabel(" 产品型号 (必填) :"); + ProductModel_field = new JTextField(15); + ProductType_lable = new JLabel(" 产品类型 (必填):"); + ProductTypeComboBox = new JComboBox(); + attrType = "t2_ProductType"; + ProductTypeMap = setLovValue(ProductTypeComboBox,attrType); + Department_lable = new JLabel(" 责任部门 (必填) :"); + DepartmentComboBox = new JComboBox(); + attrType = "t2_Department"; + DepartmentMap = setLovValue(DepartmentComboBox,attrType); + + duty_lable = new JLabel(" 责任人 (必填) :"); + duty_field = new JTextField(15); + duty_field.setText(userName); + ProjectPhase_lable = new JLabel(" 项目阶段 (必填):"); + ProjectPhaseComboBox = new JComboBox(); + attrType = "t2_ProjectPhase"; + ProjectPhaseMap = setLovValue(ProjectPhaseComboBox,attrType); + + ProType_lable = new JLabel(" 问题点类型 (必填) :"); + ProTypeComboBox = new JComboBox(); + attrType = "t2_ProType"; + ProTypeMap = setLovValue(ProTypeComboBox,attrType); + + importance_lable = new JLabel(" 重要度 (必填):"); + importanceComboBox = new JComboBox(); + attrType = "t2_importance"; + importanceMap = setLovValue(importanceComboBox,attrType); + + cause_lable = new JLabel(" 原因分析 (必填) :"); + cause_field = new JTextField(15); + // ProcessState_lable = new JLabel(" 处理状态 (必填) :"); + // ProcessStateComboBox = new JComboBox(); + // attrType = "t2_ProcessState"; + // ProcessStateMap = setLovValue(ProcessStateComboBox,attrType); + + // anticipated_lable = new JLabel("预计完成时间 :"); + // anticipated_field = new JTextField(20); + + project_lable = new JLabel(" 项 目 :"); + project_field = new JTextArea(5,15); + project_field.setLineWrap(true); + project_field.setWrapStyleWord(true); + project_field.setBorder(new LineBorder(new java.awt.Color(127,157,185), 1, false)); + + certain_btn = new JButton("确定"); + cancel_btn = new JButton("取消"); + assign_btn = new JButton("指派"); + equip_btn = new JButton("查询"); + JPanel jbutJpanel = new JPanel(new PropertyLayout());// 按钮界面 + jbutJpanel.add("1.1.center.top", certain_btn); + jbutJpanel.add("1.2.center.top", cancel_btn); + // + // BI_lABLE1 = new JLabel("*"); + // BI_lABLE1.setFont(new Font("微软雅黑", Font.BOLD, 16)); + // BI_lABLE1.setForeground(Color.RED); + + jp2.add("1.1.left.center", new JLabel("")); + jp2.add("2.1.center.center", id_lable); + jp2.add("2.2.left.center", id_field); + jp2.add("2.3.left.center", assign_btn); + jp2.add("3.1.left.center", new JLabel("")); + jp2.add("4.1.center.center", name_lable); + jp2.add("4.2.left.center", name_field); + jp2.add("5.1.left.center", new JLabel("")); + jp2.add("6.1.center.center", equip_lable); + jp2.add("6.2.left.center", equip_field); + jp2.add("6.3.left.center", equip_btn); + jp2.add("7.1.left.center", new JLabel("")); + jp2.add("8.1.center.center", CustomerName_lable); + jp2.add("8.2.left.center", CustomerName_field); + jp2.add("9.1.left.center", new JLabel("")); + jp2.add("10.1.center.center", PD_lable); + jp2.add("10.2.left.center", PD_field); + jp2.add("11.1.left.center", new JLabel("")); + jp2.add("12.1.center.center", ProductName_lable); + jp2.add("12.2.left.center", ProductName_field); + jp2.add("13.1.left.center", new JLabel("")); + jp2.add("14.1.center.center", ProductModel_lable); + jp2.add("14.2.left.center", ProductModel_field); + jp2.add("15.1.left.center", new JLabel("")); + jp2.add("16.1.center.center", ProductType_lable); + jp2.add("16.2.left.center", ProductTypeComboBox); + jp2.add("17.1.left.center", new JLabel("")); + jp2.add("18.1.center.center", Department_lable); + jp2.add("18.2.left.center", DepartmentComboBox); + jp2.add("19.1.left.center", new JLabel("")); + jp2.add("20.1.center.center", duty_lable); + jp2.add("20.2.left.center", duty_field); + jp2.add("21.1.left.center", new JLabel("")); + jp2.add("22.1.center.center", ProjectPhase_lable); + jp2.add("22.2.left.center", ProjectPhaseComboBox); + jp2.add("23.1.left.center", new JLabel("")); + jp2.add("24.1.center.center", ProType_lable); + jp2.add("24.2.left.center", ProTypeComboBox); + jp2.add("25.1.left.center", new JLabel("")); + jp2.add("26.1.center.center", importance_lable); + jp2.add("26.2.left.center", importanceComboBox); + jp2.add("27.1.left.center", new JLabel("")); + jp2.add("28.1.center.center", cause_lable); + jp2.add("28.2.left.center", cause_field); + jp2.add("29.1.left.center", new JLabel("")); + jp2.add("30.1.center.center", project_lable); + jp2.add("30.2.left.center", project_field); + + this.add("1.1.center.center", jp2); + this.add("2.1.center.top", jbutJpanel); + this.setResizable(false); + //this.add(new JLabel(" ")); + //this.setAlwaysOnTop(true); + this.setVisible(true); + this.centerToScreen(); + + + cancel_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + setVisible(false); + } + }); + + certain_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + String s = id_field.getText(); + String n = name_field.getText(); + + // private JLabel anticipated_lable; + String CustomerName = CustomerName_field.getText(); + String equip = equip_field.getText(); + String PD = PD_field.getText(); + String ProductName = ProductName_field.getText(); + String ProductModel = ProductModel_field.getText(); + String Department = (String) DepartmentComboBox.getSelectedItem(); + String ProductType = (String) ProductTypeComboBox.getSelectedItem(); + String duty = duty_field.getText(); + String cause = cause_field.getText(); + String ProjectPhase = (String) ProjectPhaseComboBox.getSelectedItem(); + String ProType = (String) ProTypeComboBox.getSelectedItem(); + String importance = (String) importanceComboBox.getSelectedItem(); + // String ProcessState = (String) ProcessStateComboBox.getSelectedItem(); + if(!("".equals(s.trim())) && !("".equals(n.trim())) && !("".equals(n.trim())) + && !("".equals(CustomerName.trim()))&& !("".equals(PD.trim())) + && !("".equals(ProductName.trim()))&& !("".equals(ProductModel.trim())) + && !("".equals(Department.trim()))&& !("".equals(duty.trim())) + && !("".equals(cause.trim()))&& !("".equals(ProjectPhase.trim())) + && !("".equals(ProType.trim())) && !("".equals(importance.trim())) + && !("".equals(ProductType.trim()))) { + createItem(); + setVisible(false); + }else { + MessageBox.post("必填属性值不能为空,请填写完毕后创建!!!", "提示", MessageBox.INFORMATION); + //System.out.println(); + return; + } + } + }); + + + assign_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + try { + if(id_field.getText().length()==0) { + assignID(); + } + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + } + }); + equip_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + String equip = equip_field.getText(); + System.out.println("equip============="+equip); + String CustomerName = ""; + String PD = ""; + String ProductName = ""; + String ProductModel = ""; + StringBuilder sb1 = new StringBuilder(); + StringBuilder sb2 = new StringBuilder(); + StringBuilder sb3 = new StringBuilder(); + StringBuilder sb4 = new StringBuilder(); + if("".equals(equip.trim())) { + MessageBox.post("请先填写设备号!!", "错误", + MessageBox.ERROR); + return; + }else { + try { + if(equip.contains(";")) { + String[] equips = equip.split("\\;"); + for (int i = 0; i < equips.length; i++) { + String[] keys = new String[] {"零组件 ID"}; + System.out.println("equips["+i+"]============="+equips[i].trim()); + String[] values = new String[] {equips[i].trim()}; + List compList = queryObject("零组件 ID", keys, values); + if(compList == null || compList.size() <= 0) { + MessageBox.post("填写的设备号有误,请重新填写!!", "错误", + MessageBox.ERROR); + return; + } + for (int j = 0; j < compList.size(); j++) { + TCComponentItem equipItem = (TCComponentItem) compList.get(j); + TCComponentItemRevision rev = equipItem.getLatestItemRevision(); + System.out.println("CustomerName========="+rev.getStringProperty("t2_CustomerName")); + sb1.append(rev.getStringProperty("t2_CustomerName")); + sb2.append(rev.getStringProperty("t2_BU")); + sb3.append(rev.getStringProperty("t2_ProductName")); + sb4.append(rev.getStringProperty("t2_ProductModel")); + if(i < equips.length-1) { + sb1.append(";"); + sb2.append(";"); + sb3.append(";"); + sb4.append(";"); + } + } + } + CustomerName = sb1.toString(); + PD = sb2.toString(); + ProductName = sb3.toString(); + ProductModel = sb4.toString(); + }else { + String[] keys = new String[] {"零组件 ID"}; + String[] values = new String[] {equip.trim()}; + List compList = queryObject("零组件 ID", keys, values); + TCComponentItem equipItem = (TCComponentItem) compList.get(0); + TCComponentItemRevision rev = equipItem.getLatestItemRevision(); + CustomerName = rev.getStringProperty("t2_CustomerName"); + PD = rev.getStringProperty("t2_BU"); + ProductName = rev.getStringProperty("t2_ProductModel"); + ProductModel = rev.getStringProperty("t2_ProductName"); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + CustomerName_field.setText(CustomerName); + PD_field.setText(PD); + ProductName_field.setText(ProductName); + ProductModel_field.setText(ProductModel); + } + } + }); + } + + + private Map setLovValue(JComboBox comboBox, String attrType) { + Map map = new HashMap(); + try { + TCComponentItemRevisionType tccFormType = (TCComponentItemRevisionType)session.getTypeComponent("T2_problemRevision"); + TCComponentListOfValues lov1 = tccFormType.getPropertyDescriptor(attrType).getLOV(); + if(lov1!=null){ + map=new HashMap<>(); + String[] strs1=lov1.getListOfValues().getStringListOfValues();//所有真实值 + comboBox.addItem(" "); + for(String s1:strs1){ + String a1 = lov1.getListOfValues().getDisplayableValue(s1);//该真实值对应的显示值 + comboBox.addItem(a1);//该真实值对应的显示值 + map.put(a1, s1);//真实k:显示v + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return map; + + } + + protected void assignID() throws Exception { + selCodeBean = new CodeBean(); + selCodeBean.setCode("PR"); + selCodeBean.setType("T2_problem"); + selCodeBean.setNum("000000000"); + selCodeBean.setMin("000000001"); + selCodeBean.setMax("999999999"); + DataBaseControl data = new DataBaseControl(session); + String newID = data.getNewCode("PLMCODE", selCodeBean); + id_field.setText(newID); + } + + + protected void createItem() { + // TODO Auto-generated method stub + try { + String type = selCodeBean.getType(); + TCComponentItemType tctype = (TCComponentItemType) session.getTypeComponent(type); + String newsid=id_field.getText(); + System.out.println(tctype); + TCComponentItem find = tctype.find(newsid); + if (find != null) { + MessageBox.post("当前流水ID:" + newsid + "已存在对象,无法创建!", "错误", + MessageBox.ERROR); + } else { + String proID = project_field.getText(); + //String itemid = id_field.getText(); + String equip = equip_field.getText(); + String itemName = name_field.getText(); + String CustomerName = CustomerName_field.getText(); + String PD = PD_field.getText(); + String ProductName = ProductName_field.getText(); + String ProductModel = ProductModel_field.getText(); + String duty = duty_field.getText(); + String cause = cause_field.getText(); + String Department = (String) DepartmentComboBox.getSelectedItem(); + String ProductType = (String) ProductTypeComboBox.getSelectedItem(); + String ProjectPhase = (String) ProjectPhaseComboBox.getSelectedItem(); + String ProType = (String) ProTypeComboBox.getSelectedItem(); + String importance = (String) importanceComboBox.getSelectedItem(); + // String ProcessState = (String) ProcessStateComboBox.getSelectedItem(); + TCComponentItem item = tctype.create(newsid, "01", "T2_problem", itemName, "", null); + + TCComponentItemRevision rev = item.getLatestItemRevision(); + rev.setProperty("t2_CustomerName", CustomerName); + rev.setProperty("t2_PD", PD); + rev.setProperty("t2_ProductName", ProductName); + rev.setProperty("t2_ProductModel", ProductModel); + rev.setProperty("t2_duty", duty); + rev.setProperty("t2_cause", cause); + String value22 = DepartmentMap.get(Department); + System.out.println("Department================"+Department); + System.out.println("value22================"+value22); + rev.setProperty("t2_Department", DepartmentMap.get(Department)); + rev.setProperty("t2_ProductType", ProductTypeMap.get(ProductType)); + rev.setProperty("t2_ProjectPhase", ProjectPhaseMap.get(ProjectPhase)); + rev.setProperty("t2_ProType", ProTypeMap.get(ProType)); + rev.setProperty("t2_importance", importanceMap.get(importance)); + rev.setProperty("t2_ProjectID", proID); + rev.setProperty("t2_AffectEquipment", equip); + // rev.setProperty("t2_ProcessState", ProcessStateMap.get(ProcessState)); + + + boolean isNewStuff = true; + if (targetComp == null) { + session.getUser().getNewStuffFolder().add("contents", item); + } else if (targetComp instanceof TCComponentFolder) { + ((TCComponentFolder) targetComp).add("contents", item); + + isNewStuff = false; + } else { + session.getUser().getNewStuffFolder().add("contents", item); + } + if (isNewStuff) { + MessageBox.post("对象" + item + "创建成功,请在NewStuff文件夹下查看!", + "成功", MessageBox.INFORMATION); + } else { + MessageBox.post("对象" + item + "创建成功,请在当前文件夹下查看!", "成功", + MessageBox.INFORMATION); + } + if(!("".equals(proID.trim()))) { + StringBuilder salse = new StringBuilder(); + if(proID.contains(";")) { + String[] pros = proID.split("\\;"); + for (int i = 0; i < pros.length; i++) { + sendToProj(pros[i],item,salse); + if(i < pros.length-1) { + salse.append(";"); + } + } + }else { + sendToProj(proID,item,salse); + } + rev.setProperty("t2_type", salse.toString()); + } + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("错误:" + e.getMessage(), "错误", MessageBox.INFORMATION); + } + } + + /** + * 通过查询构建器查询项目对象 + * + * @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 sendToProj(String proID,TCComponentItem item,StringBuilder salse) throws TCException { + String[] keys = new String[]{"项目 ID"}; + String[] values = new String[]{proID.trim()}; + List compList = queryObject("基于项目ID查找项目", keys, values); + if(compList != null && compList.size() > 0) { + TCComponent comp = compList.get(0); + if(comp instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) comp; + TCComponentUser atccomponentuser[] = new TCComponentUser[1]; + com.teamcenter.services.internal.rac.core.DataManagementService datamanagementservice = com.teamcenter.services.internal.rac.core.DataManagementService.getService(session); + ServiceData servicedata = datamanagementservice.setDefaultProjectForProjectMembers(project,atccomponentuser); + // if (servicedata != null && servicedata.sizeOfPartialErrors() > 0) { + // com.teamcenter.rac.kernel.TCExceptionPartial tcexceptionpartial = SoaUtil + // .checkPartialErrorsNoThrow(servicedata); + // MessageBox.post(Utilities.getCurrentFrame(), + // tcexceptionpartial); + // } + project.assignToProject(new TCComponent[] {item}); + String salseClassify=project.getStringProperty("t2_market"); + salse.append(salseClassify); + + } + } + } + +} diff --git a/src/com/connor/dfl/plm/dfl010/Dfl010Handler.java b/src/com/connor/dfl/plm/dfl010/Dfl010Handler.java new file mode 100644 index 0000000..16b328c --- /dev/null +++ b/src/com/connor/dfl/plm/dfl010/Dfl010Handler.java @@ -0,0 +1,23 @@ +package com.connor.dfl.plm.dfl010; + +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.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class Dfl010Handler extends AbstractHandler{ + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComp =app.getTargetComponent(); + CreateProblemSpotDialog createProblemSpotDialog = new CreateProblemSpotDialog(app , targetComp); + new Thread(createProblemSpotDialog).start(); + return null; + } + + +} diff --git a/src/com/connor/dfl/plm/dfl011/ChangeApplyDialog.java b/src/com/connor/dfl/plm/dfl011/ChangeApplyDialog.java new file mode 100644 index 0000000..1390cc3 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl011/ChangeApplyDialog.java @@ -0,0 +1,391 @@ +package com.connor.dfl.plm.dfl011; +/*创建系统方案 + * + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Arrays; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.border.LineBorder; + +import com.connor.dfl.plm.util.CodeBean; +import com.connor.dfl.plm.util.DataBaseControl; +import com.connor.dfl.plm.util.GetCodeBean; +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.ServiceData; +import com.teamcenter.rac.kernel.SoaUtil; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFormType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemRevisionType; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Utilities; + +public class ChangeApplyDialog extends AbstractAIFDialog { + private AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + private InterfaceAIFComponent targetComp; + TCSession session = (TCSession) app.getSession(); + + private CodeBean selCodeBean ; + + private JLabel id_lable; + private JLabel name_lable; + private JLabel project_lable; + private JLabel BI_lABLE1; + //private JLabel BI_lABLE2; + + private JTextField id_field; + private JTextField name_field; + private JTextArea project_field; +// private JComboBox project_comboBox; + + private JButton assign_btn; + + private JButton certain_btn; + private JButton cancel_btn; + + + + + + public ChangeApplyDialog(AbstractAIFApplication app ,InterfaceAIFComponent targetComp ) { + super(); + this.app = app; + this.session = session; + this.targetComp = targetComp; + } + + @Override + public void run() { + // TODO Auto-generated method stub + super.run(); + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void init() throws TCException { + // TODO Auto-generated method stub + + this.setTitle("变更申请单创建"); + this.setPreferredSize(new Dimension(430, 330)); + this.setLayout(new PropertyLayout()); + + id_lable = new JLabel(" 单号 : "); + id_field = new JTextField(20); + id_field.setEditable(false); + name_lable = new JLabel(" 名称 : "); + name_field = new JTextField(20); + project_lable = new JLabel(" 项 目 :"); + + project_field = new JTextArea(5,15); + project_field.setLineWrap(true); + project_field.setWrapStyleWord(true); + project_field.setBorder(new LineBorder(new java.awt.Color(127,157,185), 1, false)); + + assign_btn = new JButton("指派"); + JPanel jp2 = new JPanel(new PropertyLayout()); + jp2.setPreferredSize(new Dimension(350, 250)); + jp2.add("1.1.center.center", new JLabel(" ")); + jp2.add("2.1.center.center", new JLabel(" ")); + jp2.add("3.1.center.center", id_lable); + jp2.add("3.2.center.center", id_field); + jp2.add("3.3.center.center", assign_btn); + jp2.add("4.1.center.center", new JLabel(" ")); + jp2.add("5.1.center.center", name_lable); + jp2.add("5.2.center.center", name_field); + jp2.add("6.1.center.center", new JLabel(" ")); + jp2.add("7.1.center.center", project_lable); + jp2.add("7.2.center.center", project_field); + + certain_btn = new JButton("确定"); + cancel_btn = new JButton("取消"); + + + JPanel jbutJpanel = new JPanel(new PropertyLayout());// 按钮界面 + jbutJpanel.add("1.1.center.top", certain_btn); + jbutJpanel.add("1.2.center.top", cancel_btn); + + + if(targetComp instanceof TCComponent) { + TCComponent comp = (TCComponent) targetComp; + String targetType = comp.getType(); + if( "T2_problemRevision".equals(targetType) ) { + String projID=comp.getStringProperty("t2_ProjectID"); + project_field.setText(projID); + } + } + // + this.add("1.1.center.top",jp2); + this.add("2.1.center.top",jbutJpanel); + + this.setResizable(false); + //this.add(new JLabel(" ")); + this.setBounds(5, 5, 5, 5); + this.centerToScreen(); + this.showDialog(); + + + cancel_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + setVisible(false); + } + }); + + certain_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + String s = id_field.getText(); + String n = name_field.getText(); + if(s.length()>0 && n.length() > 0) { + createItem(); + setVisible(false); + }else { + MessageBox.post("单号和名称不能为空!", "提示", MessageBox.INFORMATION); + //System.out.println(); + return; + } + } + }); + + + assign_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + try { + + + if(id_field.getText().length() ==0) { + assignID(); + } + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + } + }); + } + + + protected void assignID() throws Exception { + selCodeBean = new CodeBean(); + selCodeBean.setCode("ECR"); + selCodeBean.setType("T2_ECR"); + selCodeBean.setNum("00000000"); + selCodeBean.setMin("00000001"); + selCodeBean.setMax("99999999"); + DataBaseControl data = new DataBaseControl(session); + String newID = data.getNewCode("PLMCODE", selCodeBean); + id_field.setText(newID); + } + + + protected void createItem() { + // TODO Auto-generated method stub + try { + + String type = selCodeBean.getType(); + TCComponentItemType tctype = (TCComponentItemType) session.getTypeComponent(type); + String newsid=id_field.getText(); + System.out.println(tctype); + TCComponentItem find = tctype.find(newsid); + if (find != null) { + MessageBox.post("当前流水ID:" + newsid + "已存在对象,无法创建!", "错误", + MessageBox.ERROR); + } else { + if(targetComp instanceof TCComponent) { + TCComponent comp = (TCComponent) targetComp; + String targetType = comp.getType(); + TCComponentItem item = null; + String proID = project_field.getText(); + if( "T2_problemRevision".equals(targetType) ) { + String clientname=comp.getStringProperty("t2_CustomerName"); + String productDepartment = comp.getStringProperty("t2_PD"); + String productName = comp.getStringProperty("t2_ProductName"); + String procuctXH = comp.getStringProperty("t2_ProductModel"); + String dutyMan = comp.getStringProperty("t2_duty"); + String producttypeRE = comp.getStringProperty("t2_ProductType"); + String producttype = getLovValue("t2_ProductType",producttypeRE,comp); + String DepartmentLovRE = comp.getStringProperty("t2_Department"); + String Department = getLovValue("t2_Department",DepartmentLovRE,comp); + String typeLovRE = comp.getStringProperty("t2_type"); + String ProjectPhaseLovRE = comp.getStringProperty("t2_ProjectPhase"); + String ProjectPhase = getLovValue("t2_ProjectPhase",ProjectPhaseLovRE,comp); + String itemid = id_field.getText(); + String itemName = name_field.getText(); + item = tctype.create(newsid, "01", "T2_ECR", itemName, "", null); + TCComponentItemRevision rev = item.getLatestItemRevision(); + rev.setProperty("t2_CustomerName", clientname); + rev.setProperty("t2_PD", productDepartment); + rev.setProperty("t2_ProductName", productName); + rev.setProperty("t2_ProductModel", procuctXH); + rev.setProperty("t2_ProductType", producttype); + rev.setProperty("t2_Department", Department); + rev.setProperty("t2_duty", dutyMan); + rev.setProperty("t2_type", typeLovRE); + rev.setProperty("t2_ProjectPhase", ProjectPhase); + rev.setProperty("t2_ProjectID", proID); + TCComponentItemRevision comprev = (TCComponentItemRevision) comp ; + TCComponentItem compItem = comprev.getItem(); + rev.add("T2_Pro", compItem); + + comprev.add("T2_Change", item); + MessageBox.post("对象" + item + "创建成功,请在当前对象版本关系文件夹下查看!", + "成功", MessageBox.INFORMATION); + }else { + String itemid = id_field.getText(); + String itemName = name_field.getText(); + item = tctype.create(newsid, "01", "T2_ECR", itemName, "", null); + + boolean isNewStuff = true; + if (targetComp == null) { + session.getUser().getNewStuffFolder().add("contents", item); + } else if (targetComp instanceof TCComponentFolder) { + ((TCComponentFolder) targetComp).add("contents", item); + isNewStuff = false; + } else { + session.getUser().getNewStuffFolder().add("contents", item); + } + + if (isNewStuff) { + MessageBox.post("对象" + item + "创建成功,请在NewStuff文件夹下查看!", + "成功", MessageBox.INFORMATION); + } else { + MessageBox.post("对象" + item + "创建成功,请在当前文件夹下查看!", "成功", + MessageBox.INFORMATION); + } + } + + if(!("".equals(proID.trim()))) { + if(proID.contains(";")) { + String[] pros = proID.split("\\;"); + for (int i = 0; i < pros.length; i++) { + sendToProj(pros[i],item); + } + }else { + sendToProj(proID,item); + } + } + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("错误:" + e.getMessage(), "错误", MessageBox.INFORMATION); + } + } + + /** + * 通过查询构建器查询项目对象 + * + * @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 sendToProj(String proID,TCComponentItem item) throws TCException { + String[] keys = new String[]{"项目 ID"}; + String[] values = new String[]{proID.trim()}; + List compList = queryObject("基于项目ID查找项目", keys, values); + if(compList != null && compList.size() > 0) { + TCComponent comp = compList.get(0); + if(comp instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) comp; + TCComponentUser atccomponentuser[] = new TCComponentUser[1]; + com.teamcenter.services.internal.rac.core.DataManagementService datamanagementservice = com.teamcenter.services.internal.rac.core.DataManagementService.getService(session); + ServiceData servicedata = datamanagementservice.setDefaultProjectForProjectMembers(project,atccomponentuser); + // if (servicedata != null && servicedata.sizeOfPartialErrors() > 0) { + // com.teamcenter.rac.kernel.TCExceptionPartial tcexceptionpartial = SoaUtil + // .checkPartialErrorsNoThrow(servicedata); + // MessageBox.post(Utilities.getCurrentFrame(), + // tcexceptionpartial); + // } + project.assignToProject(new TCComponent[] {item}); + } + } + } + private String getLovValue(String attrType,String realValue,TCComponent comp) { + String value = ""; + System.out.println("attrType================="+attrType); + System.out.println("realValue================="+realValue); + if(realValue != null) { + try { + TCProperty tcProperty = comp.getTCProperty(attrType); + TCComponentListOfValues lov1 = tcProperty.getLOV(); + if(lov1!=null){ + String[] strs1=lov1.getListOfValues().getStringListOfValues();//所有真实值 + for(String s1:strs1){ + if(realValue.equals(s1)) { + value = lov1.getListOfValues().getDisplayableValue(s1);//该真实值对应的显示值 + break; + } + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }else { + return value; + } + + return value; + } +} diff --git a/src/com/connor/dfl/plm/dfl011/Dfl011Handler.java b/src/com/connor/dfl/plm/dfl011/Dfl011Handler.java new file mode 100644 index 0000000..f0fec94 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl011/Dfl011Handler.java @@ -0,0 +1,23 @@ +package com.connor.dfl.plm.dfl011; + +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.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class Dfl011Handler extends AbstractHandler{ + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComp =app.getTargetComponent(); + ChangeApplyDialog createProblemSpotDialog = new ChangeApplyDialog(app , targetComp); + new Thread(createProblemSpotDialog).start(); + return null; + } + + +} diff --git a/src/com/connor/dfl/plm/dfl012/ChangeNoticeDialog.java b/src/com/connor/dfl/plm/dfl012/ChangeNoticeDialog.java new file mode 100644 index 0000000..b3c9766 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl012/ChangeNoticeDialog.java @@ -0,0 +1,425 @@ +package com.connor.dfl.plm.dfl012; +/*创建系统方案 + * + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Arrays; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.border.LineBorder; + +import com.connor.dfl.plm.util.CodeBean; +import com.connor.dfl.plm.util.DataBaseControl; +import com.connor.dfl.plm.util.GetCodeBean; +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.ServiceData; +import com.teamcenter.rac.kernel.SoaUtil; +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.TCComponentItemRevisionType; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Utilities; + +public class ChangeNoticeDialog extends AbstractAIFDialog { + private AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + private InterfaceAIFComponent targetComp; + TCSession session = (TCSession) app.getSession(); + + private CodeBean selCodeBean ; + + private JLabel id_lable; + private JLabel name_lable; + private JLabel project_lable; + + private JLabel BI_lABLE1; + + + private JTextField id_field; + private JTextField name_field; + private JTextArea project_field; +// private JComboBox project_comboBox; + + private JButton assign_btn; + + private JButton certain_btn; + private JButton cancel_btn; + + + + + public ChangeNoticeDialog(AbstractAIFApplication app ,InterfaceAIFComponent targetComp ) { + super(); + this.app = app; + this.session = session; + this.targetComp = targetComp; + } + + @Override + public void run() { + // TODO Auto-generated method stub + super.run(); + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void init() throws TCException { + // TODO Auto-generated method stub + + this.setTitle("变更通知单创建"); + this.setPreferredSize(new Dimension(430, 330)); + this.setLayout(new PropertyLayout()); + + + id_lable =new JLabel(" 单号 : "); + id_field = new JTextField(20); + id_field.setEditable(false); + name_lable = new JLabel(" 名称 :"); + name_field = new JTextField(20); + project_lable = new JLabel(" 项 目 :"); +// project_comboBox = new JComboBox(); +// project_comboBox.addItem(" "); + project_field = new JTextArea(5,15); + project_field.setLineWrap(true); + project_field.setWrapStyleWord(true); + project_field.setBorder(new LineBorder(new java.awt.Color(127,157,185), 1, false)); + + certain_btn = new JButton("确定"); + cancel_btn = new JButton("取消"); + assign_btn = new JButton("指派"); + + if(targetComp instanceof TCComponent) { + TCComponent comp = (TCComponent) targetComp; + String targetType = comp.getType(); + if( "T2_ECRRevision".equals(targetType) ) { + String projID=comp.getStringProperty("t2_ProjectID"); + project_field.setText(projID); + } + } + + JPanel jp2 = new JPanel(new PropertyLayout()); + jp2.setPreferredSize(new Dimension(350, 250)); + jp2.add("1.1.center.center", new JLabel(" ")); + jp2.add("2.1.center.center", new JLabel(" ")); + jp2.add("3.1.center.center", id_lable); + jp2.add("3.2.center.center", id_field); + jp2.add("3.3.center.center", assign_btn); + jp2.add("4.1.center.center", new JLabel(" ")); + jp2.add("5.1.center.center", name_lable); + jp2.add("5.2.center.center", name_field); + jp2.add("6.1.center.center", new JLabel(" ")); + jp2.add("7.1.center.center", project_lable); + jp2.add("7.2.center.center", project_field); + + JPanel jbutJpanel = new JPanel(new PropertyLayout());// 按钮界面 + jbutJpanel.add("1.1.center.top", certain_btn); + jbutJpanel.add("1.2.center.top", cancel_btn); + this.add("1.1.center.top",jp2); + this.add("2.1.center.top",jbutJpanel); + + + //this.add(new JLabel(" ")); + this.setVisible(true); + this.centerToScreen(); + + + + cancel_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + setVisible(false); + } + }); + + certain_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + String s = id_field.getText(); + String n = name_field.getText(); + + if(s.length()>0 && n.length() >0) { + createItem(); + setVisible(false); + }else { + MessageBox.post("单号和名称不能为空!", "提示", MessageBox.INFORMATION); + return; + //System.out.println(); + } + } + }); + + + assign_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + try { + if(id_field.getText().length() ==0) { + assignID(); + } + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + } + }); + } + + + protected void assignID() throws Exception { + selCodeBean = new CodeBean(); + selCodeBean.setCode("ECN"); + selCodeBean.setType("T2_ECN"); + selCodeBean.setNum("00000000"); + selCodeBean.setMin("00000001"); + selCodeBean.setMax("99999999"); + DataBaseControl data = new DataBaseControl(session); + String newID = data.getNewCode("PLMCODE", selCodeBean); + id_field.setText(newID); + } + + + protected void createItem() { + // TODO Auto-generated method stub + try { + String type = selCodeBean.getType(); + TCComponentItemType tctype = (TCComponentItemType) session.getTypeComponent(type); + String newsid=id_field.getText(); + System.out.println(tctype); + TCComponentItem find = tctype.find(newsid); + if (find != null) { + MessageBox.post("当前流水ID:" + newsid + "已存在对象,无法创建!", "错误", + MessageBox.ERROR); + } else { + String proID = project_field.getText(); + if(targetComp instanceof TCComponent) { + TCComponent comp = (TCComponent) targetComp; + String targetType = comp.getType(); + + String idnames = comp.getStringProperty("object_string"); + String [] namesarry = idnames.split(";"); + + String names = namesarry[0]; + + TCComponentItem item = null; + if( "T2_ECRRevision".equals(targetType) ) { + String itemid = id_field.getText(); + String itemName = name_field.getText(); + item = tctype.create(newsid, "01", "T2_ECN", itemName, "", null); + TCComponentItemRevision rev = item.getLatestItemRevision(); + rev.setProperty("t2_CustomerName", names); + rev.setProperty("t2_ProjectID", proID); + TCComponentItemRevision comprev = (TCComponentItemRevision) comp ; + TCComponentItem compItem = comprev.getItem(); + rev.add("T2_Change", compItem); + comprev.add("T2_GECN", item); + + }else if("T2_problemRevision".equals(targetType) ) { + String clientname=comp.getStringProperty("t2_CustomerName"); + String productDepartment = comp.getStringProperty("t2_PD"); + String productName = comp.getStringProperty("t2_ProductName"); + String procuctXH = comp.getStringProperty("t2_ProductModel"); + String dutyMan = comp.getStringProperty("t2_duty"); + String producttypeRE = comp.getStringProperty("t2_ProductType"); + String producttype = getLovValue("t2_ProductType",producttypeRE,comp); + String DepartmentLovRE = comp.getStringProperty("t2_Department"); + String Department = getLovValue("t2_Department",DepartmentLovRE,comp); + String typeLovRE = comp.getStringProperty("t2_type"); + String ProjectPhaseLovRE = comp.getStringProperty("t2_ProjectPhase"); + String ProjectPhase = getLovValue("t2_ProjectPhase",ProjectPhaseLovRE,comp); + String itemid = id_field.getText(); + String itemName = name_field.getText(); + item = tctype.create(newsid, "01", "T2_ECN", itemName, "", null); + TCComponentItemRevision rev = item.getLatestItemRevision(); + rev.setProperty("t2_CustomerName", clientname); + rev.setProperty("t2_PD", productDepartment); + rev.setProperty("t2_ProductName", productName); + rev.setProperty("t2_ProductModel", procuctXH); + rev.setProperty("t2_ProductType", producttype); + rev.setProperty("t2_Department", Department); + rev.setProperty("t2_duty", dutyMan); + rev.setProperty("t2_type", typeLovRE); + rev.setProperty("t2_ProjectPhase", ProjectPhase); + rev.setProperty("t2_ProjectID", proID); + TCComponentItemRevision comprev = (TCComponentItemRevision) comp ; + TCComponentItem compItem = comprev.getItem(); + rev.add("T2_Pro", compItem); + comprev.add("T2_Change", item); + MessageBox.post("对象" + item + "创建成功,请在当前对象版本关系文件夹下查看!", + "成功", MessageBox.INFORMATION); + }else { + String itemid = id_field.getText(); + String itemName = name_field.getText(); + item = tctype.create(newsid, "01", "T2_ECN", itemName, "", null); + + boolean isNewStuff = true; + if (targetComp == null) { + session.getUser().getNewStuffFolder().add("contents", item); + } else if (targetComp instanceof TCComponentFolder) { + ((TCComponentFolder) targetComp).add("contents", item); + isNewStuff = false; + } else { + session.getUser().getNewStuffFolder().add("contents", item); + } + + if (isNewStuff) { + MessageBox.post("对象" + item + "创建成功,请在NewStuff文件夹下查看!", + "成功", MessageBox.INFORMATION); + } else { + MessageBox.post("对象" + item + "创建成功,请在当前文件夹下查看!", "成功", + MessageBox.INFORMATION); + } + +// +// MessageBox.post("选中的对象不是变更申请单对象!!!" ,"提示", +// MessageBox.INFORMATION); + } + + if(!("".equals(proID.trim()))) { + if(proID.contains(";")) { + String[] pros = proID.split("\\;"); + for (int i = 0; i < pros.length; i++) { + sendToProj(pros[i],item); + } + }else { + sendToProj(proID,item); + } + } + } +// else { +// MessageBox.post("选中的不是对象!!!" ,"提示", +// MessageBox.INFORMATION); +// } + +// +// if (clientname != null && clientname != "") { +// rev.setStringProperty("t2_CustomerName", clientname); +// } +// if (department != null && department != "") { +// rev.setStringProperty("t2_BusinessDepartment", department); +// } +// if (product != null && product != "") { +// rev.setStringProperty("t2_model", product); +// } + + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("错误:" + e.getMessage(), "错误", MessageBox.INFORMATION); + } + } + + /** + * 通过查询构建器查询项目对象 + * + * @param queryName 查询名称 + * @param keys 查询条件 + * @param values 查询值 + * @returns + */ + 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 sendToProj(String proID,TCComponentItem item) throws TCException { + String[] keys = new String[]{"项目 ID"}; + String[] values = new String[]{proID.trim()}; + List compList = queryObject("基于项目ID查找项目", keys, values); + if(compList != null && compList.size() > 0) { + TCComponent comp = compList.get(0); + if(comp instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) comp; + TCComponentUser atccomponentuser[] = new TCComponentUser[1]; + com.teamcenter.services.internal.rac.core.DataManagementService datamanagementservice = com.teamcenter.services.internal.rac.core.DataManagementService.getService(session); + ServiceData servicedata = datamanagementservice.setDefaultProjectForProjectMembers(project,atccomponentuser); + // if (servicedata != null && servicedata.sizeOfPartialErrors() > 0) { + // com.teamcenter.rac.kernel.TCExceptionPartial tcexceptionpartial = SoaUtil + // .checkPartialErrorsNoThrow(servicedata); + // MessageBox.post(Utilities.getCurrentFrame(), + // tcexceptionpartial); + // } + project.assignToProject(new TCComponent[] {item}); + } + } + } + private String getLovValue(String attrType,String realValue,TCComponent comp) { + String value = ""; + System.out.println("attrType================="+attrType); + System.out.println("realValue================="+realValue); + if(realValue != null) { + try { + TCProperty tcProperty = comp.getTCProperty(attrType); + TCComponentListOfValues lov1 = tcProperty.getLOV(); + if(lov1!=null){ + String[] strs1=lov1.getListOfValues().getStringListOfValues();//所有真实值 + for(String s1:strs1){ + if(realValue.equals(s1)) { + value = lov1.getListOfValues().getDisplayableValue(s1);//该真实值对应的显示值 + break; + } + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }else { + return value; + } + + return value; + } +} diff --git a/src/com/connor/dfl/plm/dfl012/Dfl012Handler.java b/src/com/connor/dfl/plm/dfl012/Dfl012Handler.java new file mode 100644 index 0000000..ac2cd5e --- /dev/null +++ b/src/com/connor/dfl/plm/dfl012/Dfl012Handler.java @@ -0,0 +1,23 @@ +package com.connor.dfl.plm.dfl012; + +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.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class Dfl012Handler extends AbstractHandler{ + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComp =app.getTargetComponent(); + ChangeNoticeDialog createProblemSpotDialog = new ChangeNoticeDialog(app , targetComp); + new Thread(createProblemSpotDialog).start(); + return null; + } + + +} diff --git a/src/com/connor/dfl/plm/dfl013/Dfl013Handler.java b/src/com/connor/dfl/plm/dfl013/Dfl013Handler.java new file mode 100644 index 0000000..563eccc --- /dev/null +++ b/src/com/connor/dfl/plm/dfl013/Dfl013Handler.java @@ -0,0 +1,23 @@ +package com.connor.dfl.plm.dfl013; + +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.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class Dfl013Handler extends AbstractHandler{ + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComp =app.getTargetComponent(); + QuickChangeDialog createProblemSpotDialog = new QuickChangeDialog(app , targetComp); + new Thread(createProblemSpotDialog).start(); + return null; + } + + +} diff --git a/src/com/connor/dfl/plm/dfl013/QuickChangeDialog.java b/src/com/connor/dfl/plm/dfl013/QuickChangeDialog.java new file mode 100644 index 0000000..f7d9f15 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl013/QuickChangeDialog.java @@ -0,0 +1,475 @@ +package com.connor.dfl.plm.dfl013; +/*创建系统方案 + * + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Arrays; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.connor.dfl.plm.util.CodeBean; +import com.connor.dfl.plm.util.DataBaseControl; +import com.connor.dfl.plm.util.GetCodeBean; +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.ServiceData; +import com.teamcenter.rac.kernel.SoaUtil; +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.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Utilities; + +public class QuickChangeDialog extends AbstractAIFDialog { + private AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + private InterfaceAIFComponent targetComp; + TCSession session = (TCSession) app.getSession(); + + private CodeBean selCodeBean ; + + private JLabel id_lable; + private JLabel name_lable; + private JLabel project_lable; + + private JTextField id_field; + private JTextField name_field; + private JComboBox project_comboBox; + private JLabel BI_lABLE1; + + private JButton assign_btn; + + private JButton certain_btn; + private JButton cancel_btn; + + + + + public QuickChangeDialog(AbstractAIFApplication app ,InterfaceAIFComponent targetComp ) { + super(); + this.app = app; + this.session = session; + this.targetComp = targetComp; + } + + @Override + public void run() { + // TODO Auto-generated method stub + super.run(); + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void init() throws TCException { + // TODO Auto-generated method stub + + this.setTitle("快速变更单创建"); + this.setPreferredSize(new Dimension(430, 330)); + this.setLayout(null); + + + + + + id_lable =new JLabel(" 单号 : "); + id_field = new JTextField(20); + id_field.setEditable(false); + name_lable = new JLabel(" 名称 :"); + name_field = new JTextField(20); + project_lable = new JLabel(" 项 目 :"); + project_comboBox = new JComboBox(); + project_comboBox.addItem(" "); + + + BI_lABLE1 = new JLabel("*"); + BI_lABLE1.setFont(new Font("微软雅黑", Font.BOLD, 13)); + BI_lABLE1.setForeground(Color.RED); + + + + + String[] keys = new String[] { "ID" }; + TCComponentUser user = session.getUser(); + String user_id = user.getStringProperty("user_id"); + String[] values = new String[] { user_id }; + List compList = queryObject("基于用户的项目", keys, values); + if (compList != null && compList.size() > 0) { + for (int i = 0; i < compList.size(); i++) { + TCComponent comp = compList.get(i); + if (comp instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) comp; + try { + String id = project.getStringProperty("project_id"); + project_comboBox.addItem(id); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + } + + + + + + project_comboBox.setEditable(true); + project_comboBox.setSize(10, 25); + certain_btn = new JButton("确定"); + cancel_btn = new JButton("取消"); + assign_btn = new JButton("指派"); + id_lable.setBounds(20,45,100,30); + + id_field.setBounds(120,45,200,30); + assign_btn.setBounds(330,45, 70, 30); + this.add(id_lable); + this.add(id_field); + this.add(assign_btn); + + + name_lable.setBounds(20,85 , 100, 30); + name_field.setBounds(120,85 , 200, 30); + BI_lABLE1.setBounds(325,85, 15, 15); + this.add(name_lable); + this.add(name_field); + this.add(BI_lABLE1); + + + + + +// + + + + + project_lable.setBounds(20, 125, 100, 30); + project_comboBox.setBounds(120,125, 200, 30); + this.add(project_lable); + this.add(project_comboBox); + + + certain_btn.setBounds(50, 225,70, 35); + cancel_btn.setBounds(280, 225, 70, 35); + this.add(certain_btn); + this.add(cancel_btn); + + + //this.add(new JLabel(" ")); + this.setAlwaysOnTop(true); + this.setVisible(true); + this.centerToScreen(); + + + cancel_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + setVisible(false); + } + }); + + certain_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + String s = id_field.getText(); + String n = name_field.getText(); + if(s.length()>0 && n.length()>0) { + createItem(); + + }else { + setVisible(false); + MessageBox.post("单号和名称不能为空!", "提示", MessageBox.INFORMATION); + //System.out.println(); + } + } + }); + + + assign_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + try { + if(id_field.getText().length() ==0) { + assignID(); + } + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + } + }); + } + + + protected void assignID() throws Exception { + selCodeBean = new CodeBean(); + selCodeBean.setCode("QECN"); + selCodeBean.setType("T2_QECN"); + selCodeBean.setNum("0000000"); + selCodeBean.setMin("0000001"); + selCodeBean.setMax("9999999"); + DataBaseControl data = new DataBaseControl(session); + String newID = data.getNewCode("PLMCODE", selCodeBean); + id_field.setText(newID); + } + + + protected void createItem() { + // TODO Auto-generated method stub + try { + + + String type = selCodeBean.getType(); + TCComponentItemType tctype = (TCComponentItemType) session.getTypeComponent(type); + String newsid=id_field.getText(); + System.out.println(tctype); + TCComponentItem find = tctype.find(newsid); + if (find != null) { + MessageBox.post("当前流水ID:" + newsid + "已存在对象,无法创建!", "错误", + MessageBox.ERROR); + } else { + this.setVisible(false); + if(targetComp instanceof TCComponent) { + TCComponent comp = (TCComponent) targetComp; + String clientname=comp.getStringProperty("t2_CustomerName"); + String productDepartment = comp.getStringProperty("t2_PD"); + String productName = comp.getStringProperty("t2_ProductName"); + String procuctXH = comp.getStringProperty("t2_ProductModel"); + String productType = comp.getStringProperty("t2_ProductType"); + String dutyDepartment = comp.getStringProperty("t2_Department"); + String dutyMan = comp.getStringProperty("t2_duty"); + String salseType = comp.getStringProperty("t2_type"); + String projectState = comp.getStringProperty("t2_ProjectPhase"); + + + + String targetType = comp.getType(); + + if( "T2_problemRevision".equals(targetType) ) { + + + String itemid = id_field.getText(); + String itemName = name_field.getText(); + TCComponentItem item = tctype.create(newsid, "01", "T2_QECN", itemName, "", null); + TCComponentItemRevision rev = item.getLatestItemRevision(); + rev.setProperty("t2_CustomerName", clientname); + rev.setProperty("t2_PD", productDepartment); + rev.setProperty("t2_ProductName", productName); + rev.setProperty("t2_ProductModel", procuctXH); + rev.setProperty("t2_ProductType", productType); + rev.setProperty("t2_Department", dutyDepartment); + rev.setProperty("t2_duty", dutyMan); + rev.setProperty("t2_type", salseType); + rev.setProperty("t2_ProjectPhase", projectState); + + + + TCComponentItemRevision comprev = (TCComponentItemRevision) comp ; + TCComponentItem compItem = comprev.getItem(); + rev.add("T2_Pro", compItem); + + comprev.add("T2_Change", item); + + boolean isNewStuff = true; + if (targetComp == null) { + session.getUser().getNewStuffFolder().add("contents", item); + } else if (targetComp instanceof TCComponentFolder) { + ((TCComponentFolder) targetComp).add("contents", item); + isNewStuff = false; + } else { + session.getUser().getNewStuffFolder().add("contents", item); + } + //if (classid != null && !classid.equals("")) { + //Dfl003Operation op=new Dfl003Operation(session, classid, rev, new Integer[] {}, new String[] {}); + //session.queueOperation(op); + //} else { + //System.out.println("未找到该类型的分类id,不发生分类"); + //} + if (isNewStuff) { + MessageBox.post("对象" + item + "创建成功,请在NewStuff文件夹下查看!", + "成功", MessageBox.INFORMATION); + } else { + MessageBox.post("对象" + item + "创建成功,请在当前文件夹下查看!", "成功", + MessageBox.INFORMATION); + } + + String proID = (String) project_comboBox.getSelectedItem(); + if(proID != null & proID !=" ") { + String[] keys = new String[]{"项目 ID"}; + String[] values = new String[]{proID}; + List compList = queryObject("基于项目ID查找项目", keys, values); + if(compList != null && compList.size() > 0) { + TCComponent compss = compList.get(0); + if(compss instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) compss; + TCComponentUser atccomponentuser[] = new TCComponentUser[1]; + com.teamcenter.services.internal.rac.core.DataManagementService datamanagementservice = com.teamcenter.services.internal.rac.core.DataManagementService.getService(session); + ServiceData servicedata = datamanagementservice.setDefaultProjectForProjectMembers(project,atccomponentuser); +// if (servicedata != null && servicedata.sizeOfPartialErrors() > 0) { +// com.teamcenter.rac.kernel.TCExceptionPartial tcexceptionpartial = SoaUtil +// .checkPartialErrorsNoThrow(servicedata); +// MessageBox.post(Utilities.getCurrentFrame(), +// tcexceptionpartial); +// } + project.assignToProject(new TCComponent[] {item}); + + + + } + } + + } + + }else { + + String itemid = id_field.getText(); + String itemName = name_field.getText(); + TCComponentItem item = tctype.create(newsid, "01", "T2_QECN", itemName, "", null); + boolean isNewStuff = true; + if (targetComp == null) { + session.getUser().getNewStuffFolder().add("contents", item); + } else if (targetComp instanceof TCComponentFolder) { + ((TCComponentFolder) targetComp).add("contents", item); + isNewStuff = false; + } else { + session.getUser().getNewStuffFolder().add("contents", item); + } + + if (isNewStuff) { + MessageBox.post("对象" + item + "创建成功,请在NewStuff文件夹下查看!", + "成功", MessageBox.INFORMATION); + } else { + MessageBox.post("对象" + item + "创建成功,请在当前文件夹下查看!", "成功", + MessageBox.INFORMATION); + } + + String proID = (String) project_comboBox.getSelectedItem(); + if(proID != null & proID !=" ") { + String[] keys = new String[]{"项目 ID"}; + String[] values = new String[]{proID}; + List compList = queryObject("基于项目ID查找项目", keys, values); + if(compList != null && compList.size() > 0) { + TCComponent compss = compList.get(0); + if(compss instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) compss; + TCComponentUser atccomponentuser[] = new TCComponentUser[1]; + com.teamcenter.services.internal.rac.core.DataManagementService datamanagementservice = com.teamcenter.services.internal.rac.core.DataManagementService.getService(session); + ServiceData servicedata = datamanagementservice.setDefaultProjectForProjectMembers(project,atccomponentuser); +// if (servicedata != null && servicedata.sizeOfPartialErrors() > 0) { +// com.teamcenter.rac.kernel.TCExceptionPartial tcexceptionpartial = SoaUtil +// .checkPartialErrorsNoThrow(servicedata); +// MessageBox.post(Utilities.getCurrentFrame(), +// tcexceptionpartial); +// } + project.assignToProject(new TCComponent[] {item}); + + + + } + } + + } +// + +// MessageBox.post("选中的对象不是问题点版本对象!!!" ,"提示", +// MessageBox.INFORMATION); + } + } +// else { +// MessageBox.post("选中的不是对象!!!" ,"提示", +// MessageBox.INFORMATION); +// } + + + this.setVisible(false); + + + + + + + + +// +// if (clientname != null && clientname != "") { +// rev.setStringProperty("t2_CustomerName", clientname); +// } +// if (department != null && department != "") { +// rev.setStringProperty("t2_BusinessDepartment", department); +// } +// if (product != null && product != "") { +// rev.setStringProperty("t2_model", product); +// } + + + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("错误:" + e.getMessage(), "错误", MessageBox.INFORMATION); + } + } + + /** + * 通过查询构建器查询项目对象 + * + * @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/dfl/plm/dfl014/Dfl014Handler.java b/src/com/connor/dfl/plm/dfl014/Dfl014Handler.java new file mode 100644 index 0000000..da6f308 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl014/Dfl014Handler.java @@ -0,0 +1,23 @@ +package com.connor.dfl.plm.dfl014; + +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.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class Dfl014Handler extends AbstractHandler{ + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComp =app.getTargetComponent(); + PressureVesselConstructionDialog createProblemSpotDialog = new PressureVesselConstructionDialog(app , targetComp); + new Thread(createProblemSpotDialog).start(); + return null; + } + + +} diff --git a/src/com/connor/dfl/plm/dfl014/PressureVesselConstructionDialog.java b/src/com/connor/dfl/plm/dfl014/PressureVesselConstructionDialog.java new file mode 100644 index 0000000..f0eeede --- /dev/null +++ b/src/com/connor/dfl/plm/dfl014/PressureVesselConstructionDialog.java @@ -0,0 +1,444 @@ +package com.connor.dfl.plm.dfl014; +/*创建系统方案 + * + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Arrays; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.connor.dfl.plm.util.CodeBean; +import com.connor.dfl.plm.util.DataBaseControl; +import com.connor.dfl.plm.util.GetCodeBean; +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.ServiceData; +import com.teamcenter.rac.kernel.SoaUtil; +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.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Utilities; + +public class PressureVesselConstructionDialog extends AbstractAIFDialog { + private AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + private InterfaceAIFComponent targetComp; + TCSession session = (TCSession) app.getSession(); + + private CodeBean selCodeBean ; + + private JLabel id_lable; + private JLabel name_lable; + private JLabel project_lable; + private JLabel BI_lABLE1; + + private JTextField id_field; + private JTextField name_field; + private JComboBox project_comboBox; + + private JButton assign_btn; + + private JButton certain_btn; + private JButton cancel_btn; + + + + + public PressureVesselConstructionDialog(AbstractAIFApplication app ,InterfaceAIFComponent targetComp ) { + super(); + this.app = app; + this.session = session; + this.targetComp = targetComp; + } + + @Override + public void run() { + // TODO Auto-generated method stub + super.run(); + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void init() throws TCException { + // TODO Auto-generated method stub + + this.setTitle("压力容器施工图变更通知单创建"); + this.setPreferredSize(new Dimension(430, 330)); + this.setLayout(null); + + + + + + id_lable =new JLabel(" 单号 : "); + id_field = new JTextField(20); + id_field.setEditable(false); + name_lable = new JLabel(" 名称 :"); + name_field = new JTextField(20); + project_lable = new JLabel(" 项 目 :"); + project_comboBox = new JComboBox(); + project_comboBox.addItem(" "); + + + BI_lABLE1 = new JLabel("*"); + BI_lABLE1.setFont(new Font("微软雅黑", Font.BOLD, 13)); + BI_lABLE1.setForeground(Color.RED); + + String[] keys = new String[] { "ID" }; + TCComponentUser user = session.getUser(); + String user_id = user.getStringProperty("user_id"); + String[] values = new String[] { user_id }; + List compList = queryObject("基于用户的项目", keys, values); + if (compList != null && compList.size() > 0) { + for (int i = 0; i < compList.size(); i++) { + TCComponent comp = compList.get(i); + if (comp instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) comp; + try { + String id = project.getStringProperty("project_id"); + project_comboBox.addItem(id); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + } + + + + + project_comboBox.setEditable(true); + project_comboBox.setSize(10, 25); + certain_btn = new JButton("确定"); + cancel_btn = new JButton("取消"); + assign_btn = new JButton("指派"); + + id_lable.setBounds(20,45,100,30); + + id_field.setBounds(120,45,200,30); + assign_btn.setBounds(330,45, 70, 30); + this.add(id_lable); + this.add(id_field); + this.add(assign_btn); + + + name_lable.setBounds(20,85 , 100, 30); + name_field.setBounds(120,85 , 200, 30); + BI_lABLE1.setBounds(325,85, 15, 15); + this.add(name_lable); + this.add(name_field); + this.add(BI_lABLE1); + + + + + +// + + + + + project_lable.setBounds(20, 125, 100, 30); + project_comboBox.setBounds(120,125, 200, 30); + this.add(project_lable); + this.add(project_comboBox); + + + certain_btn.setBounds(50, 225,70, 35); + cancel_btn.setBounds(280, 225, 70, 35); + this.add(certain_btn); + this.add(cancel_btn); + + + //this.add(new JLabel(" ")); + this.setAlwaysOnTop(true); + this.setVisible(true); + this.centerToScreen(); + + + cancel_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + setVisible(false); + } + }); + + certain_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + String s = id_field.getText(); + String n = name_field.getText(); + if(s.length()>0 && n.length() > 0) { + createItem(); + + }else { + setVisible(false); + MessageBox.post("单号和名称不能为空!", "提示", MessageBox.INFORMATION); + //System.out.println(); + } + } + }); + + + assign_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + try { + if(id_field.getText().length() ==0) { + assignID(); + } + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + } + }); + } + + + protected void assignID() throws Exception { + selCodeBean = new CodeBean(); + selCodeBean.setCode("TFL-2020-SJGG"); + selCodeBean.setType("T2_PVECN"); + selCodeBean.setNum("0000"); + selCodeBean.setMin("0001"); + selCodeBean.setMax("9999"); + DataBaseControl data = new DataBaseControl(session); + String newID = data.getNewCode("PLMCODE", selCodeBean); + id_field.setText(newID); + } + + + protected void createItem() { + // TODO Auto-generated method stub + try { + + + String type = selCodeBean.getType(); + TCComponentItemType tctype = (TCComponentItemType) session.getTypeComponent(type); + String newsid=id_field.getText(); + System.out.println(tctype); + TCComponentItem find = tctype.find(newsid); + if (find != null) { + MessageBox.post("当前流水ID:" + newsid + "已存在对象,无法创建!", "错误", + MessageBox.ERROR); + } else { + this.setVisible(false); + + + + if(targetComp instanceof TCComponent) { + TCComponent comp = (TCComponent) targetComp; + String idnames = comp.getStringProperty("object_string"); + String [] namesarry = idnames.split(";"); + + String names = namesarry[0]; + String targetType = comp.getType(); + + if( "T2_ECRRevision".equals(targetType) ) { + + String itemid = id_field.getText(); + String itemName = name_field.getText(); + TCComponentItem item = tctype.create(newsid, "01", "T2_PVECN", itemName, "", null); + TCComponentItemRevision rev = item.getLatestItemRevision(); + rev.setProperty("t2_CustomerName", names); + + + TCComponentItemRevision comprev = (TCComponentItemRevision) comp ; + TCComponentItem compItem = comprev.getItem(); + + + + rev.add("T2_Change", compItem); + comprev.add("T2_GECN", item); + boolean isNewStuff = true; + if (targetComp == null) { + session.getUser().getNewStuffFolder().add("contents", item); + } else if (targetComp instanceof TCComponentFolder) { + ((TCComponentFolder) targetComp).add("contents", item); + isNewStuff = false; + } else { + session.getUser().getNewStuffFolder().add("contents", item); + } + //if (classid != null && !classid.equals("")) { + //Dfl003Operation op=new Dfl003Operation(session, classid, rev, new Integer[] {}, new String[] {}); + //session.queueOperation(op); + //} else { + //System.out.println("未找到该类型的分类id,不发生分类"); + //} + if (isNewStuff) { + MessageBox.post("对象" + item + "创建成功,请在NewStuff文件夹下查看!", + "成功", MessageBox.INFORMATION); + } else { + MessageBox.post("对象" + item + "创建成功,请在当前文件夹下查看!", "成功", + MessageBox.INFORMATION); + } + + String proID = (String) project_comboBox.getSelectedItem(); + if(proID != null & proID !=" ") { + String[] keys = new String[]{"项目 ID"}; + String[] values = new String[]{proID}; + List compList = queryObject("基于项目ID查找项目", keys, values); + if(compList != null && compList.size() > 0) { + TCComponent compss = compList.get(0); + if(compss instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) compss; + TCComponentUser atccomponentuser[] = new TCComponentUser[1]; + com.teamcenter.services.internal.rac.core.DataManagementService datamanagementservice = com.teamcenter.services.internal.rac.core.DataManagementService.getService(session); + ServiceData servicedata = datamanagementservice.setDefaultProjectForProjectMembers(project,atccomponentuser); +// if (servicedata != null && servicedata.sizeOfPartialErrors() > 0) { +// com.teamcenter.rac.kernel.TCExceptionPartial tcexceptionpartial = SoaUtil +// .checkPartialErrorsNoThrow(servicedata); +// MessageBox.post(Utilities.getCurrentFrame(), +// tcexceptionpartial); +// } + project.assignToProject(new TCComponent[] {item}); + + + + } + } + + } + + }else { + + String itemid = id_field.getText(); + String itemName = name_field.getText(); + TCComponentItem item = tctype.create(newsid, "01", "T2_PVECN", itemName, "", null); boolean isNewStuff = true; + if (targetComp == null) { + session.getUser().getNewStuffFolder().add("contents", item); + } else if (targetComp instanceof TCComponentFolder) { + ((TCComponentFolder) targetComp).add("contents", item); + isNewStuff = false; + } else { + session.getUser().getNewStuffFolder().add("contents", item); + } + + if (isNewStuff) { + MessageBox.post("对象" + item + "创建成功,请在NewStuff文件夹下查看!", + "成功", MessageBox.INFORMATION); + } else { + MessageBox.post("对象" + item + "创建成功,请在当前文件夹下查看!", "成功", + MessageBox.INFORMATION); + } + + String proID = (String) project_comboBox.getSelectedItem(); + if(proID != null & proID !=" ") { + String[] keys = new String[]{"项目 ID"}; + String[] values = new String[]{proID}; + List compList = queryObject("基于项目ID查找项目", keys, values); + if(compList != null && compList.size() > 0) { + TCComponent compss = compList.get(0); + if(compss instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) compss; + TCComponentUser atccomponentuser[] = new TCComponentUser[1]; + com.teamcenter.services.internal.rac.core.DataManagementService datamanagementservice = com.teamcenter.services.internal.rac.core.DataManagementService.getService(session); + ServiceData servicedata = datamanagementservice.setDefaultProjectForProjectMembers(project,atccomponentuser); +// if (servicedata != null && servicedata.sizeOfPartialErrors() > 0) { +// com.teamcenter.rac.kernel.TCExceptionPartial tcexceptionpartial = SoaUtil +// .checkPartialErrorsNoThrow(servicedata); +// MessageBox.post(Utilities.getCurrentFrame(), +// tcexceptionpartial); +// } + project.assignToProject(new TCComponent[] {item}); + + + + } + } + + } + // + + + + // MessageBox.post("选中的对象不是变更申请单对象!!!" ,"提示", + // MessageBox.INFORMATION); + } + } +// else { +// MessageBox.post("选中的不是对象!!!" ,"提示", +// MessageBox.INFORMATION); +// } + + + this.setVisible(false); + + + + + + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("错误:" + e.getMessage(), "错误", MessageBox.INFORMATION); + } + } + + /** + * 通过查询构建器查询项目对象 + * + * @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/dfl/plm/dfl015/CreateSoftwareDocument.java b/src/com/connor/dfl/plm/dfl015/CreateSoftwareDocument.java new file mode 100644 index 0000000..2b2affc --- /dev/null +++ b/src/com/connor/dfl/plm/dfl015/CreateSoftwareDocument.java @@ -0,0 +1,379 @@ +package com.connor.dfl.plm.dfl015; +/*创建系统方案 + * + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Arrays; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.connor.dfl.plm.util.CodeBean; +import com.connor.dfl.plm.util.DataBaseControl; +import com.connor.dfl.plm.util.GetCodeBean; +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.ServiceData; +import com.teamcenter.rac.kernel.SoaUtil; +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.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Utilities; + +public class CreateSoftwareDocument extends AbstractAIFDialog { + private AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + private InterfaceAIFComponent targetComp; + TCSession session = (TCSession) app.getSession(); + + private CodeBean selCodeBean ; + + private JLabel id_lable; + private JLabel name_lable; + private JLabel project_lable; + private JLabel BI_lABLE1; + private JLabel BI_lABLE2; + + private JLabel softLable ; + + + private JTextField id_field; + private JTextField name_field; + private JComboBox project_comboBox; + private JTextField soft_field; + + + private JButton assign_btn; + + private JButton certain_btn; + private JButton cancel_btn; + + + + + public CreateSoftwareDocument(AbstractAIFApplication app ,InterfaceAIFComponent targetComp ) { + super(); + this.app = app; + this.session = session; + this.targetComp = targetComp; + } + + @Override + public void run() { + // TODO Auto-generated method stub + super.run(); + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void init() throws TCException { + // TODO Auto-generated method stub + + this.setTitle("软件文档创建"); + this.setPreferredSize(new Dimension(430, 330)); + this.setLayout(null); + + + + + + id_lable = new JLabel(" 软件文档编号:"); + id_field = new JTextField(20); + id_field.setEditable(false); + name_lable = new JLabel(" 名 称(必填):"); + name_field = new JTextField(20); + project_lable = new JLabel(" 项 目 :"); + project_comboBox = new JComboBox(); + project_comboBox.addItem(" "); + BI_lABLE1 = new JLabel("*"); + BI_lABLE1.setFont(new Font("微软雅黑", Font.BOLD, 13)); + BI_lABLE1.setForeground(Color.RED); + BI_lABLE2 = new JLabel("*"); + BI_lABLE2.setFont(new Font("微软雅黑", Font.BOLD, 13)); + BI_lABLE2.setForeground(Color.RED); + softLable = new JLabel(" 软件版本(必填):"); + soft_field = new JTextField(20); + + + String[] keys = new String[] { "ID" }; + TCComponentUser user = session.getUser(); + String user_id = user.getStringProperty("user_id"); + String[] values = new String[] { user_id }; + List compList = queryObject("基于用户的项目", keys, values); + if (compList != null && compList.size() > 0) { + for (int i = 0; i < compList.size(); i++) { + TCComponent comp = compList.get(i); + if (comp instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) comp; + try { + String id = project.getStringProperty("project_id"); + project_comboBox.addItem(id); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + } + + + + + project_comboBox.setEditable(true); + project_comboBox.setSize(10, 25); + certain_btn = new JButton("确定"); + cancel_btn = new JButton("取消"); + assign_btn = new JButton("指派"); + + id_lable.setBounds(20,45,100,30); + + id_field.setBounds(120,45,200,30); + assign_btn.setBounds(330,45, 70, 30); + this.add(id_lable); + this.add(id_field); + this.add(assign_btn); + + + name_lable.setBounds(20,85 , 100, 30); + name_field.setBounds(120,85 , 200, 30); + BI_lABLE1.setBounds(325,85, 15, 15); + this.add(name_lable); + this.add(name_field); + this.add(BI_lABLE1); + + + + + + // + + + + + project_lable.setBounds(20, 165, 100, 30); + project_comboBox.setBounds(120,165, 200, 30); + this.add(project_lable); + this.add(project_comboBox); + + + softLable.setBounds(20, 125, 100, 30); + soft_field.setBounds(120, 125, 200, 30); + BI_lABLE2.setBounds(325,125, 15, 15); + this.add(softLable); + this.add(soft_field); + this.add(BI_lABLE2); + + + + + + certain_btn.setBounds(50, 225,70, 35); + cancel_btn.setBounds(280, 225, 70, 35); + this.add(certain_btn); + this.add(cancel_btn); + + + //this.add(new JLabel(" ")); + this.setAlwaysOnTop(true); + this.setVisible(true); + this.centerToScreen(); + + + cancel_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + setVisible(false); + } + }); + + certain_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + String itemid = id_field.getText(); + String itemName = name_field.getText(); + String soft = soft_field.getText(); + if(!("".equals(itemid.trim())) && !("".equals(itemName.trim())) + && !("".equals(soft.trim()))) { + createItem(); + + }else { + setVisible(false); + MessageBox.post("软件文档编号、软件版本和名称不能为空!", "提示", MessageBox.INFORMATION); + //System.out.println(); + } + } + }); + + + assign_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + try { + if(id_field.getText().length() ==0) { + assignID(); + } + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + } + }); + } + + + protected void assignID() throws Exception { + selCodeBean = new CodeBean(); + selCodeBean.setCode("RJ"); + selCodeBean.setType("T2_SoftwareDoc"); + selCodeBean.setNum("000000000"); + selCodeBean.setMin("000000001"); + selCodeBean.setMax("999999999"); + DataBaseControl data = new DataBaseControl(session); + String newID = data.getNewCode("PLMCODE", selCodeBean); + id_field.setText(newID); + } + + + protected void createItem() { + // TODO Auto-generated method stub + try { + + + String type = selCodeBean.getType(); + TCComponentItemType tctype = (TCComponentItemType) session.getTypeComponent(type); + String newsid=id_field.getText(); + System.out.println(tctype); + TCComponentItem find = tctype.find(newsid); + if (find != null) { + MessageBox.post("当前流水ID:" + newsid + "已存在对象,无法创建!", "错误", + MessageBox.ERROR); + } else { + this.setVisible(false); + + String itemid = id_field.getText(); + String itemName = name_field.getText(); + String soft = soft_field.getText(); + TCComponentItem item = tctype.create(newsid, "01", "T2_SoftwareDoc", itemName, "", null); + TCComponentItemRevision rev = item.getLatestItemRevision(); + rev.setProperty("t2_softRev", soft); + + + boolean isNewStuff = true; + if (targetComp == null) { + session.getUser().getNewStuffFolder().add("contents", item); + } else if (targetComp instanceof TCComponentFolder) { + ((TCComponentFolder) targetComp).add("contents", item); + isNewStuff = false; + } else { + session.getUser().getNewStuffFolder().add("contents", item); + } + //if (classid != null && !classid.equals("")) { + //Dfl003Operation op=new Dfl003Operation(session, classid, rev, new Integer[] {}, new String[] {}); + //session.queueOperation(op); + //} else { + //System.out.println("未找到该类型的分类id,不发生分类"); + //} + if (isNewStuff) { + MessageBox.post("对象" + item + "创建成功,请在NewStuff文件夹下查看!", + "成功", MessageBox.INFORMATION); + } else { + MessageBox.post("对象" + item + "创建成功,请在当前文件夹下查看!", "成功", + MessageBox.INFORMATION); + } + + String proID = (String) project_comboBox.getSelectedItem(); + if(proID != null && proID !=" ") { + String[] keys = new String[]{"项目 ID"}; + String[] values = new String[]{proID}; + List compList = queryObject("基于项目ID查找项目", keys, values); + if(compList != null && compList.size() > 0) { + TCComponent compss = compList.get(0); + if(compss instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) compss; + TCComponentUser atccomponentuser[] = new TCComponentUser[1]; + com.teamcenter.services.internal.rac.core.DataManagementService datamanagementservice = com.teamcenter.services.internal.rac.core.DataManagementService.getService(session); + ServiceData servicedata = datamanagementservice.setDefaultProjectForProjectMembers(project,atccomponentuser); + // if (servicedata != null && servicedata.sizeOfPartialErrors() > 0) { + // com.teamcenter.rac.kernel.TCExceptionPartial tcexceptionpartial = SoaUtil + // .checkPartialErrorsNoThrow(servicedata); + // MessageBox.post(Utilities.getCurrentFrame(), + // tcexceptionpartial); + // } + project.assignToProject(new TCComponent[] {item}); + + } + } + + } + this.setVisible(false); + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("错误:" + e.getMessage(), "错误", MessageBox.INFORMATION); + } + } + + /** + * 通过查询构建器查询项目对象 + * + * @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/dfl/plm/dfl015/Dfl015Handler.java b/src/com/connor/dfl/plm/dfl015/Dfl015Handler.java new file mode 100644 index 0000000..7078202 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl015/Dfl015Handler.java @@ -0,0 +1,23 @@ +package com.connor.dfl.plm.dfl015; + +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.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class Dfl015Handler extends AbstractHandler{ + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComp =app.getTargetComponent(); + CreateSoftwareDocument createProblemSpotDialog = new CreateSoftwareDocument(app , targetComp); + new Thread(createProblemSpotDialog).start(); + return null; + } + + +} diff --git a/src/com/connor/dfl/plm/dfl016/CreateCertificationDocument.java b/src/com/connor/dfl/plm/dfl016/CreateCertificationDocument.java new file mode 100644 index 0000000..49ffe99 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl016/CreateCertificationDocument.java @@ -0,0 +1,371 @@ +package com.connor.dfl.plm.dfl016; +/*创建系统方案 + * + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Arrays; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.connor.dfl.plm.util.CodeBean; +import com.connor.dfl.plm.util.DataBaseControl; +import com.connor.dfl.plm.util.GetCodeBean; +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.ServiceData; +import com.teamcenter.rac.kernel.SoaUtil; +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.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Utilities; + +public class CreateCertificationDocument extends AbstractAIFDialog { + private AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + private InterfaceAIFComponent targetComp; + TCSession session = (TCSession) app.getSession(); + + private CodeBean selCodeBean ; + + private JLabel id_lable; + private JLabel name_lable; + private JLabel project_lable; + private JLabel BI_lABLE1; + + private JTextField id_field; + private JTextField name_field; + private JComboBox project_comboBox; + + private JButton assign_btn; + + private JButton certain_btn; + private JButton cancel_btn; + + + + + public CreateCertificationDocument(AbstractAIFApplication app ,InterfaceAIFComponent targetComp ) { + super(); + this.app = app; + this.session = session; + this.targetComp = targetComp; + } + + @Override + public void run() { + // TODO Auto-generated method stub + super.run(); + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void init() throws TCException { + // TODO Auto-generated method stub + + this.setTitle("认证文档创建"); + this.setPreferredSize(new Dimension(430, 330)); + this.setLayout(null); + + + + + + id_lable = new JLabel("认证文档编号:"); + id_field = new JTextField(20); + id_field.setEditable(false); + name_lable = new JLabel(" 名称:"); + name_field = new JTextField(20); + project_lable = new JLabel(" 项 目:"); + project_comboBox = new JComboBox(); + project_comboBox.addItem(" "); + + + BI_lABLE1 = new JLabel("*"); + BI_lABLE1.setFont(new Font("微软雅黑", Font.BOLD, 13)); + BI_lABLE1.setForeground(Color.RED); + + + + String[] keys = new String[] { "ID" }; + TCComponentUser user = session.getUser(); + String user_id = user.getStringProperty("user_id"); + String[] values = new String[] { user_id }; + List compList = queryObject("基于用户的项目", keys, values); + if (compList != null && compList.size() > 0) { + for (int i = 0; i < compList.size(); i++) { + TCComponent comp = compList.get(i); + if (comp instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) comp; + try { + String id = project.getStringProperty("project_id"); + project_comboBox.addItem(id); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + } + + + + + project_comboBox.setEditable(true); + project_comboBox.setSize(10, 25); + certain_btn = new JButton("确定"); + cancel_btn = new JButton("取消"); + assign_btn = new JButton("指派"); + + id_lable.setBounds(20,45,100,30); + + id_field.setBounds(120,45,200,30); + assign_btn.setBounds(330,45, 70, 30); + this.add(id_lable); + this.add(id_field); + this.add(assign_btn); + + + name_lable.setBounds(20,85 , 100, 30); + name_field.setBounds(120,85 , 200, 30); + BI_lABLE1.setBounds(325,85, 15, 15); + this.add(name_lable); + this.add(name_field); + this.add(BI_lABLE1); + + + + + +// + + + + + project_lable.setBounds(20, 125, 100, 30); + project_comboBox.setBounds(120,125, 200, 30); + this.add(project_lable); + this.add(project_comboBox); + + + certain_btn.setBounds(50, 225,70, 35); + cancel_btn.setBounds(280, 225, 70, 35); + this.add(certain_btn); + this.add(cancel_btn); + + + //this.add(new JLabel(" ")); + this.setAlwaysOnTop(true); + this.setVisible(true); + this.centerToScreen(); + + + + cancel_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + setVisible(false); + } + }); + + certain_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + String s = id_field.getText(); + String n =name_field.getText(); + if(s.length()>0 && n.length()>0) { + createItem(); + + }else { + setVisible(false); + MessageBox.post("认证文档编号和名称不能为空!", "提示", MessageBox.INFORMATION); + //System.out.println(); + } + } + }); + + + assign_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + try { + if(id_field.getText().length() ==0) { + assignID(); + } + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + } + }); + } + + + protected void assignID() throws Exception { + selCodeBean = new CodeBean(); + selCodeBean.setCode("RZ"); + selCodeBean.setType("T2_SoftwareDoc"); + selCodeBean.setNum("000000000"); + selCodeBean.setMin("000000001"); + selCodeBean.setMax("999999999"); + DataBaseControl data = new DataBaseControl(session); + String newID = data.getNewCode("PLMCODE", selCodeBean); + id_field.setText(newID); + } + + + protected void createItem() { + // TODO Auto-generated method stub + try { + + + String type = selCodeBean.getType(); + TCComponentItemType tctype = (TCComponentItemType) session.getTypeComponent(type); + String newsid=id_field.getText(); + System.out.println(tctype); + TCComponentItem find = tctype.find(newsid); + if (find != null) { + MessageBox.post("当前流水ID:" + newsid + "已存在对象,无法创建!", "错误", + MessageBox.ERROR); + } else { + this.setVisible(false); + + + + + String itemid = id_field.getText(); + String itemName = name_field.getText(); + TCComponentItem item = tctype.create(newsid, "01", "T2_RZ", itemName, "", null); + TCComponentItemRevision rev = item.getLatestItemRevision(); + + + + + boolean isNewStuff = true; + if (targetComp == null) { + session.getUser().getNewStuffFolder().add("contents", item); + } else if (targetComp instanceof TCComponentFolder) { + ((TCComponentFolder) targetComp).add("contents", item); + isNewStuff = false; + } else { + session.getUser().getNewStuffFolder().add("contents", item); + } + //if (classid != null && !classid.equals("")) { + //Dfl003Operation op=new Dfl003Operation(session, classid, rev, new Integer[] {}, new String[] {}); + //session.queueOperation(op); + //} else { + //System.out.println("未找到该类型的分类id,不发生分类"); + //} + if (isNewStuff) { + MessageBox.post("对象" + item + "创建成功,请在NewStuff文件夹下查看!", + "成功", MessageBox.INFORMATION); + } else { + MessageBox.post("对象" + item + "创建成功,请在当前文件夹下查看!", "成功", + MessageBox.INFORMATION); + } + + String proID = (String) project_comboBox.getSelectedItem(); + if(proID != null & proID !=" ") { + String[] keys = new String[]{"项目 ID"}; + String[] values = new String[]{proID}; + List compList = queryObject("基于项目ID查找项目", keys, values); + if(compList != null && compList.size() > 0) { + TCComponent compss = compList.get(0); + if(compss instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) compss; + TCComponentUser atccomponentuser[] = new TCComponentUser[1]; + com.teamcenter.services.internal.rac.core.DataManagementService datamanagementservice = com.teamcenter.services.internal.rac.core.DataManagementService.getService(session); + ServiceData servicedata = datamanagementservice.setDefaultProjectForProjectMembers(project,atccomponentuser); +// if (servicedata != null && servicedata.sizeOfPartialErrors() > 0) { +// com.teamcenter.rac.kernel.TCExceptionPartial tcexceptionpartial = SoaUtil +// .checkPartialErrorsNoThrow(servicedata); +// MessageBox.post(Utilities.getCurrentFrame(), +// tcexceptionpartial); +// } + project.assignToProject(new TCComponent[] {item}); + + } + } + + } + + + + + this.setVisible(false); + + + + + + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("错误:" + e.getMessage(), "错误", MessageBox.INFORMATION); + } + } + + /** + * 通过查询构建器查询项目对象 + * + * @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/dfl/plm/dfl016/Dfl016Handler.java b/src/com/connor/dfl/plm/dfl016/Dfl016Handler.java new file mode 100644 index 0000000..0429c6a --- /dev/null +++ b/src/com/connor/dfl/plm/dfl016/Dfl016Handler.java @@ -0,0 +1,23 @@ +package com.connor.dfl.plm.dfl016; + +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.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class Dfl016Handler extends AbstractHandler{ + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComp =app.getTargetComponent(); + CreateCertificationDocument createProblemSpotDialog = new CreateCertificationDocument(app , targetComp); + new Thread(createProblemSpotDialog).start(); + return null; + } + + +} diff --git a/src/com/connor/dfl/plm/dfl017/CreateSealConstructionDraw.java b/src/com/connor/dfl/plm/dfl017/CreateSealConstructionDraw.java new file mode 100644 index 0000000..d33dca3 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl017/CreateSealConstructionDraw.java @@ -0,0 +1,359 @@ +package com.connor.dfl.plm.dfl017; +/*创建系统方案 + * + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Arrays; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.connor.dfl.plm.util.CodeBean; +import com.connor.dfl.plm.util.DataBaseControl; +import com.connor.dfl.plm.util.GetCodeBean; +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.ServiceData; +import com.teamcenter.rac.kernel.SoaUtil; +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.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Utilities; + +public class CreateSealConstructionDraw extends AbstractAIFDialog { + private AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + private InterfaceAIFComponent targetComp; + TCSession session = (TCSession) app.getSession(); + + private CodeBean selCodeBean ; + + private JLabel id_lable; + private JLabel name_lable; + private JLabel project_lable; + private JLabel BI_lABLE1; + + private JTextField id_field; + private JTextField name_field; + private JComboBox project_comboBox; + + private JButton assign_btn; + + private JButton certain_btn; + private JButton cancel_btn; + + + + + public CreateSealConstructionDraw(AbstractAIFApplication app ,InterfaceAIFComponent targetComp ) { + super(); + this.app = app; + this.session = session; + this.targetComp = targetComp; + } + + @Override + public void run() { + // TODO Auto-generated method stub + super.run(); + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void init() throws TCException { + // TODO Auto-generated method stub + + this.setTitle("压力容器施工图盖章对象创建"); + this.setPreferredSize(new Dimension(430, 330)); + this.setLayout(null); + + + + + + id_lable = new JLabel(" 品号 "); + id_field = new JTextField(20); + id_field.setEditable(false); + name_lable = new JLabel(" 品名 :"); + name_field = new JTextField(20); + project_lable = new JLabel(" 项 目 :"); + project_comboBox = new JComboBox(); + project_comboBox.addItem(" "); + + + BI_lABLE1 = new JLabel("*"); + BI_lABLE1.setFont(new Font("微软雅黑", Font.BOLD, 13)); + BI_lABLE1.setForeground(Color.RED); + + + + + + + String[] keys = new String[] { "ID" }; + TCComponentUser user = session.getUser(); + String user_id = user.getStringProperty("user_id"); + String[] values = new String[] { user_id }; + List compList = queryObject("基于用户的项目", keys, values); + if (compList != null && compList.size() > 0) { + for (int i = 0; i < compList.size(); i++) { + TCComponent comp = compList.get(i); + if (comp instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) comp; + try { + String id = project.getStringProperty("project_id"); + project_comboBox.addItem(id); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + } + + + + + project_comboBox.setEditable(true); + project_comboBox.setSize(10, 25); + certain_btn = new JButton("确定"); + cancel_btn = new JButton("取消"); + assign_btn = new JButton("指派"); + + id_lable.setBounds(20,45,100,30); + + id_field.setBounds(120,45,200,30); + assign_btn.setBounds(330,45, 70, 30); + this.add(id_lable); + this.add(id_field); + this.add(assign_btn); + + + name_lable.setBounds(20,85 , 100, 30); + name_field.setBounds(120,85 , 200, 30); + BI_lABLE1.setBounds(325,85, 15, 15); + this.add(name_lable); + this.add(name_field); + this.add(BI_lABLE1); + + + + + +// + + + + + project_lable.setBounds(20, 125, 100, 30); + project_comboBox.setBounds(120,125, 200, 30); + this.add(project_lable); + this.add(project_comboBox); + + + certain_btn.setBounds(50, 225,70, 35); + cancel_btn.setBounds(280, 225, 70, 35); + this.add(certain_btn); + this.add(cancel_btn); + + + //this.add(new JLabel(" ")); + this.setAlwaysOnTop(true); + this.setVisible(true); + this.centerToScreen(); + + + cancel_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + setVisible(false); + } + }); + + certain_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + String s = id_field.getText(); + String n = name_field.getText(); + if(s.length()>0 && n.length()>0) { + createItem(); + + }else { + setVisible(false); + MessageBox.post("品号和品名不能为空!", "提示", MessageBox.INFORMATION); + //System.out.println(); + } + } + }); + + + assign_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + try { + if(id_field.getText().length() ==0) { + assignID(); + } + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + } + }); + } + + + protected void assignID() throws Exception { + selCodeBean = new CodeBean(); + selCodeBean.setCode("GZ"); + selCodeBean.setType("T2_GZ"); + selCodeBean.setNum("000000000"); + selCodeBean.setMin("000000001"); + selCodeBean.setMax("999999999"); + DataBaseControl data = new DataBaseControl(session); + String newID = data.getNewCode("PLMCODE", selCodeBean); + id_field.setText(newID); + } + + + protected void createItem() { + // TODO Auto-generated method stub + try { + + + String type = selCodeBean.getType(); + TCComponentItemType tctype = (TCComponentItemType) session.getTypeComponent(type); + String newsid=id_field.getText(); + System.out.println(tctype); + TCComponentItem find = tctype.find(newsid); + if (find != null) { + MessageBox.post("当前流水ID:" + newsid + "已存在对象,无法创建!", "错误", + MessageBox.ERROR); + } else { + this.setVisible(false); + + + String itemid = id_field.getText(); + String itemName = name_field.getText(); + TCComponentItem item = tctype.create(newsid, "01", "T2_GZ", itemName, "", null); + TCComponentItemRevision rev = item.getLatestItemRevision(); + + + boolean isNewStuff = true; + if (targetComp == null) { + session.getUser().getNewStuffFolder().add("contents", item); + } else if (targetComp instanceof TCComponentFolder) { + ((TCComponentFolder) targetComp).add("contents", item); + isNewStuff = false; + } else { + session.getUser().getNewStuffFolder().add("contents", item); + } + //if (classid != null && !classid.equals("")) { + //Dfl003Operation op=new Dfl003Operation(session, classid, rev, new Integer[] {}, new String[] {}); + //session.queueOperation(op); + //} else { + //System.out.println("未找到该类型的分类id,不发生分类"); + //} + if (isNewStuff) { + MessageBox.post("对象" + item + "创建成功,请在NewStuff文件夹下查看!", + "成功", MessageBox.INFORMATION); + } else { + MessageBox.post("对象" + item + "创建成功,请在当前文件夹下查看!", "成功", + MessageBox.INFORMATION); + } + + String proID = (String) project_comboBox.getSelectedItem(); + if(proID != null & proID !=" ") { + String[] keys = new String[]{"项目 ID"}; + String[] values = new String[]{proID}; + List compList = queryObject("基于项目ID查找项目", keys, values); + if(compList != null && compList.size() > 0) { + TCComponent compss = compList.get(0); + if(compss instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) compss; + TCComponentUser atccomponentuser[] = new TCComponentUser[1]; + com.teamcenter.services.internal.rac.core.DataManagementService datamanagementservice = com.teamcenter.services.internal.rac.core.DataManagementService.getService(session); + ServiceData servicedata = datamanagementservice.setDefaultProjectForProjectMembers(project,atccomponentuser); +// if (servicedata != null && servicedata.sizeOfPartialErrors() > 0) { +// com.teamcenter.rac.kernel.TCExceptionPartial tcexceptionpartial = SoaUtil +// .checkPartialErrorsNoThrow(servicedata); +// MessageBox.post(Utilities.getCurrentFrame(), +// tcexceptionpartial); +// } + project.assignToProject(new TCComponent[] {item}); + } + } + + } + this.setVisible(false); + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("错误:" + e.getMessage(), "错误", MessageBox.INFORMATION); + } + } + + /** + * 通过查询构建器查询项目对象 + * + * @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/dfl/plm/dfl017/Dfl017Handler.java b/src/com/connor/dfl/plm/dfl017/Dfl017Handler.java new file mode 100644 index 0000000..0007429 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl017/Dfl017Handler.java @@ -0,0 +1,23 @@ +package com.connor.dfl.plm.dfl017; + +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.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class Dfl017Handler extends AbstractHandler{ + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComp =app.getTargetComponent(); + CreateSealConstructionDraw createProblemSpotDialog = new CreateSealConstructionDraw(app , targetComp); + new Thread(createProblemSpotDialog).start(); + return null; + } + + +} diff --git a/src/com/connor/dfl/plm/dfl018/Dfl018Handler.java b/src/com/connor/dfl/plm/dfl018/Dfl018Handler.java new file mode 100644 index 0000000..0e07be0 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl018/Dfl018Handler.java @@ -0,0 +1,23 @@ +package com.connor.dfl.plm.dfl018; + +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.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class Dfl018Handler extends AbstractHandler{ + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComp =app.getTargetComponent(); + SupplementCreate createProblemSpotDialog = new SupplementCreate(app , targetComp); + new Thread(createProblemSpotDialog).start(); + return null; + } + + +} diff --git a/src/com/connor/dfl/plm/dfl018/SupplementCreate.java b/src/com/connor/dfl/plm/dfl018/SupplementCreate.java new file mode 100644 index 0000000..38ddf87 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl018/SupplementCreate.java @@ -0,0 +1,202 @@ +package com.connor.dfl.plm.dfl018; +/*创建系统方案 + * + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Arrays; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.connor.dfl.plm.util.CodeBean; +import com.connor.dfl.plm.util.DataBaseControl; +import com.connor.dfl.plm.util.GetCodeBean; +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.ServiceData; +import com.teamcenter.rac.kernel.SoaUtil; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFolderType; +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.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Utilities; + +public class SupplementCreate extends AbstractAIFDialog { + private AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + private InterfaceAIFComponent targetComp; + TCSession session = (TCSession) app.getSession(); + + + + private JLabel name_lable; + private JTextField name_field; + + + + private JButton certain_btn; + private JButton cancel_btn; + private JLabel BI_lABLE1; + + + + + public SupplementCreate(AbstractAIFApplication app ,InterfaceAIFComponent targetComp ) { + super(); + this.app = app; + this.session = session; + this.targetComp = targetComp; + } + + @Override + public void run() { + super.run(); + try { + init(); + } catch (TCException e) { + e.printStackTrace(); + } + } + + private void init() throws TCException { + // TODO Auto-generated method stub + + this.setTitle("补充创建"); + this.setPreferredSize(new Dimension(335, 250)); + this.setLayout(null); + + + + BI_lABLE1 = new JLabel("*"); + BI_lABLE1.setFont(new Font("微软雅黑", Font.BOLD, 16)); + BI_lABLE1.setForeground(Color.RED); + + name_lable = new JLabel(" 名称 "); + name_field = new JTextField(20); + + + + + + + + + + + + certain_btn = new JButton("确定"); + cancel_btn = new JButton("取消"); + + + this.add(name_lable); + this.add(name_field); + + + + + + + + + + + + name_lable.setBounds(20,45,60,30); + name_field.setBounds(100,45,200,30); + BI_lABLE1.setBounds(300,45, 15, 15); + + this.add(BI_lABLE1); + certain_btn.setBounds(50, 150,70, 35); + cancel_btn.setBounds(200, 150, 70, 35); + + + this.add(certain_btn); + this.add(cancel_btn); + + + this.setAlwaysOnTop(true); + this.setVisible(true); + this.centerToScreen(); + + + cancel_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + setVisible(false); + } + }); + + certain_btn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + String s = name_field.getText(); + + if(s.length()>0) { + createFolder(); + + }else { + setVisible(false); + MessageBox.post("名称不能为空!", "提示", MessageBox.INFORMATION); + //System.out.println(); + } + } + }); + } + + protected void createFolder() { + try { + TCComponentFolderType t= (TCComponentFolderType)session.getTypeComponent("Folder"); + TCComponentFolder f1 =t.create( name_field.getText(), "My Folder Description","Folder"); + setVisible(false); + boolean isNewStuff = true; + if (targetComp == null) { + session.getUser().getNewStuffFolder().add("contents", f1); + } else if (targetComp instanceof TCComponentFolder) { + ((TCComponentFolder) targetComp).add("contents", f1); + isNewStuff = false; + } else { + session.getUser().getNewStuffFolder().add("contents", f1); + } + + if (isNewStuff) { + MessageBox.post("对象" + f1 + "创建成功,请在NewStuff文件夹下查看!", + "成功", MessageBox.INFORMATION); + } else { + MessageBox.post("对象" + f1 + "创建成功,请在当前文件夹下查看!", "成功", + MessageBox.INFORMATION); + } + + + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("错误:" + e.getMessage(), "错误", MessageBox.INFORMATION); + } + } + + +} diff --git a/src/com/connor/dfl/plm/dfl019/ClassPropBean.java b/src/com/connor/dfl/plm/dfl019/ClassPropBean.java new file mode 100644 index 0000000..440c9ce --- /dev/null +++ b/src/com/connor/dfl/plm/dfl019/ClassPropBean.java @@ -0,0 +1,64 @@ +package com.connor.dfl.plm.dfl019; + +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/dfl/plm/dfl019/Dfl019Handler.java b/src/com/connor/dfl/plm/dfl019/Dfl019Handler.java new file mode 100644 index 0000000..cc4e59b --- /dev/null +++ b/src/com/connor/dfl/plm/dfl019/Dfl019Handler.java @@ -0,0 +1,27 @@ +package com.connor.dfl.plm.dfl019; + +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.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + + +public class Dfl019Handler extends AbstractHandler { + private AbstractAIFApplication app; + private TCSession session; + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + this.session = (TCSession) app.getSession(); + Dfl019Operation operation = new Dfl019Operation(app, session); + session.queueOperation(operation); +// WuLiaoERP wl = new WuLiaoERP(app); +// new Thread(wl).start(); + return null; + } +} + diff --git a/src/com/connor/dfl/plm/dfl019/Dfl019Operation.java b/src/com/connor/dfl/plm/dfl019/Dfl019Operation.java new file mode 100644 index 0000000..ab03901 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl019/Dfl019Operation.java @@ -0,0 +1,1066 @@ +package com.connor.dfl.plm.dfl019; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +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.List; +import java.util.Map; +import java.util.UUID; + +import com.connor.dfl.plm.util.AutoSign; +import com.connor.dfl.plm.util.ClassValueBean; +import com.connor.dfl.plm.util.ClassValueUtil; +import com.connor.dfl.plm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFApplication; +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.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +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.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; + +import oracle.sql.BLOB; + + + + +public class Dfl019Operation extends AbstractAIFOperation{ + private AbstractAIFApplication app; + private TCSession session; + private List attrList; + private List errList1 = new ArrayList(); + private String url ; + private String user; + private String password ; + private Connection conn = null;// + private PreparedStatement pre = null;// + private ResultSet result = null;// + + private String tops; + private String ns=""; + private String accountSet; + private String zhangtao; + private AutoSign as = null; + private ProgressBarThread wait; + + public Dfl019Operation(AbstractAIFApplication app, TCSession session ,String accountSet,String zhangtao) { + this.app = app; + this.session = session; + this.accountSet = accountSet; + this.as=new AutoSign(); + this.zhangtao = zhangtao; + } + public Dfl019Operation(AbstractAIFApplication app, TCSession session ) { + this.app = app; + this.session = session; + this.as=new AutoSign(); + String[] stringArrays = session.getPreferenceService().getStringValues("DFL_zhangtao"); + Map account_set = new HashMap(); + if (stringArrays == null || stringArrays.length <= 0 ) { + MessageBox.post("首选项DFL_zhangtao未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + }else { + for(int i = 0 ;i0) { + // MessageBox.post("您选中的版本对象没有在流程中","提示",MessageBox.INFORMATION); + // return; + for(int i = 0;i errList = new ArrayList(); + List beanList = getItemValue(comp,errList); + if(beanList == null ) { + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + return; + } + if(beanList.size() <=0) { + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + MessageBox.post("您传递的物料都已经传递到ERP,请检查!", "提示", + MessageBox.INFORMATION); + return; + } + if(errList.size() > 0) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < errList.size(); i++) { + sb.append(errList.get(i)); + if(i < errList.size()-1) { + sb.append(";"); + } + } + String errs = sb.toString(); + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + MessageBox.post(errs+"物料单位属性值未填写,请检查!", "提示", + MessageBox.INFORMATION); + return; + } + if(beanList == null || beanList.size() <= 0) { + return; + } + for (int i = 0; i < beanList.size(); i++) { + ItemBean bean = beanList.get(i); + System.out.println("品号====="+bean.getItem_id()+ + "品名============"+bean.getItem_name()+ + "品牌============"+bean.getItem_brand()+ + "分群码============"+bean.getItem_groupCode()+ + "版本============"+bean.getItem_rev()+ + "来源码============"+bean.getItem_sourceCode()+ + "规格============"+bean.getItem_spec()+ + "单位============"+bean.getItem_unit()+"旧物料号============"+bean.getOldMateriel()); + + } + + + + + // for (int i = 0; i < beanList.size(); i++) { + // ItemBean bean = beanList.get(i); + // System.out.println("品号====="+bean.getItem_id()); + // + // if(ifcountdetial(bean.getItem_id())>0) { + // updateMes(bean,zhangtao); + // }else { + // insertMes(bean,zhangtao); + // } + // + // } + + try { + createXMLFile(beanList,zhangtao); + if(!("".equals(uid))&& !(" ".equals(uid))) { + as.AutoSignServer(uid,session); + } + MessageBox.post("物料数据存储成功,准备传递ERP!!!", + "提示", MessageBox.WARNING); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + MessageBox.post("物料数据存储失败!!!", + "提示", MessageBox.WARNING); + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + return; + + } + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + } + + + public List getItemValue(InterfaceAIFComponent[] comps,List errList) throws TCException { + List beanList = new ArrayList(); + boolean flag = false; + if(comps[0] instanceof TCComponentTask){ + TCComponentTask task = (TCComponentTask) comps[0]; + TCComponent[] targets = task.getReferenceListProperty("root_target_attachments"); + for (int i = 0; i < targets.length; i++) { + flag = setvalues(beanList,targets[i],errList); + if(flag) { + return null; + } + } + }else { + for (int i = 0; i < comps.length; i++) { + InterfaceAIFComponent comp = comps[i]; + if(comp instanceof TCComponent) { + + TCComponent tccomp = (TCComponent) comp; + flag = setvalues(beanList,tccomp,errList); + if(flag) { + return null; + } + + + } + } + } + return beanList; + } + public boolean setvalues(List beanList, TCComponent comp, List errList) throws TCException { + // TODO Auto-generated method stub + boolean flag2 = false; + if(comp instanceof TCComponentItemRevision || comp instanceof TCComponentBOMLine) { + ItemBean bean = new ItemBean(); + TCComponentItemRevision rev = null; + String spec = ""; + String unit = ""; + String brand =""; + String id =""; + String oldMateriel =""; + if(comp instanceof TCComponentItemRevision ) { + rev = (TCComponentItemRevision) comp; + } + if(comp instanceof TCComponentBOMLine ) { + TCComponentBOMLine get_bom_line = (TCComponentBOMLine) comp; + rev = get_bom_line.getItemRevision(); + } + String statu = rev.getStringProperty("t2_ERPStatus"); +// if("已传".equals(statu)) { +// return flag2; +// } + try { + String type = rev.getStringProperty("object_type"); + id = rev.getStringProperty("item_id"); + if(id.contains("-Y")) { + id = id.replace("-Y", ""); + //判断这个版本是否为虚拟件版本 + if("T2_VirtualRevision".equals(type)){ + String[] keys = new String[]{"零组件 ID"}; + String[] values = new String[]{id}; + //查询零组件版本的item_id为id的 + List compList = queryObject("零组件版本...", keys, values); + //判断是否为不为空的 + if(compList!=null) { + for(int i = 0; i < compList.size(); i++){ + TCComponentItemRevision rev1 = null; + rev1 = (TCComponentItemRevision) compList.get(i); + String type1 = rev1.getStringProperty("object_type"); + System.out.println("9.10===type==="+type1); + //如果查询出来的版本为设备版本,则不传递erp + if("T2_EquipmentRevision".equals(type1)) { + return true; + } + } + } + } + } + String groupCode = rev.getStringProperty("t2_groupCode"); + System.out.println("t2_groupCode============"+groupCode); + String sourceCode = rev.getStringProperty("t2_sourceCode"); + System.out.println("t2_sourceCode============"+sourceCode); + if("T2_outsourceRevision".equals(type) || "T2_OutBuyPartRevision".equals(type) + ||"T2_VirtualRevision".equals(type) ||"T2_EquipmentRevision".equals(type) + ||"T2_SystemSchemeRevision".equals(type)) { + if("T2_outsourceRevision".equals(type)||"T2_OutBuyPartRevision".equals(type) ) { + TCProperty tcProperty = rev.getTCProperty("release_status_list"); + TCComponent[] targets = tcProperty.getReferenceValueArray(); + String groupcode1 = rev.getStringProperty("t2_groupCode"); + String sourceCode1 = rev.getStringProperty("t2_sourceCode"); + + // String status = rev.getStringProperty("release_status_list"); + if(targets==null || targets.length<=0) { + MessageBox.post(rev.getStringProperty("item_id")+"该物料没有发布状态!!", + "提示", MessageBox.WARNING); + return true; + } + if(groupcode1.equals("")){ + MessageBox.post(rev.getStringProperty("item_id")+"该物料没有分群码!!", + "提示", MessageBox.WARNING); + return true; + } + if(sourceCode1.equals("")){ + MessageBox.post(rev.getStringProperty("item_id")+"该物料没有来源码!!", + "提示", MessageBox.WARNING); + return true; + } + } + }else { + MessageBox.post("该物料不允许传递ERP!!", + "提示", MessageBox.WARNING); + return true; + } + boolean flag = false; + if("T2_outsourceRevision".equals(type)) { + StringBuilder sb = new StringBuilder(id); + sb.append(rev.getStringProperty("item_revision_id")); + id = sb.toString(); + String classID = id.substring(0, 2); + System.out.println("classID==============="+classID); + if("51".equals(classID) || "72".equals(classID) || "76".equals(classID)) { +// flag = true; +// List vals= getOutBuyPartValue(rev,flag); +// +// if(vals != null) { +// spec = vals.get(0); +// }else { +// return true; +// } + ClassValueBean valueBean = ClassValueUtil.getOutBuyPartValue(rev,errList1); + if(valueBean != null) { + spec = valueBean.getSpecs(); + }else { + return true; + } + }else { + spec = getOutsourceValue(rev); + } + oldMateriel = rev.getStringProperty("t2_OldId"); + unit = rev.getStringProperty("t2_unit"); + //setValue(rev,bean); + if("S".equals(sourceCode)) { + sourceCode = "M"; + System.out.println("t2_sourceCode2============"+sourceCode); + } + }else if("T2_OutBuyPartRevision".equals(type)) { + oldMateriel = rev.getStringProperty("t2_OldID"); +// List vals= getOutBuyPartValue(rev,flag); +// if(vals != null) { +// spec = vals.get(0); +// }else { +// return true; +// } +// for (int j = 0; j < vals.size(); j++) { +// String value = vals.get(j); +// System.out.println("value11111====="+value); +// if(value.contains("=")) { +// if(value.contains("单位")) { +// String[] units = value.split("="); +// if(units.length >= 2) { +// unit = units[1]; +// } +// }else if(value.contains("品牌")) { +// String[] brands = value.split("="); +// if(brands.length >= 2) { +// brand = brands[1]; +// brand = brand.replace("&", "&"); +// } +// }else { +// spec = value; +// } +// }else { +// spec = value; +// } +// } + ClassValueBean valueBean = ClassValueUtil.getOutBuyPartValue(rev,errList1); + if(valueBean != null) { + spec = valueBean.getSpecs(); + if(spec == null) { + spec = ""; + } + unit = valueBean.getUnit(); + if(unit == null) { + unit = ""; + } + + brand = valueBean.getBrand(); + if(brand == null) { + brand = ""; + } + if(brand.contains("&")) { + brand = brand.replace("&", "&"); + } + + }else { + return true; + } + + //setValue(rev,bean); + } + else if("T2_SystemSchemeRevision".equals(type)) { + if(groupCode == null || "".equals(groupCode.trim())) { + groupCode = "00Z"; + } + if(sourceCode == null || "".equals(sourceCode.trim())) { + sourceCode = "M"; + } + + unit = "套"; + + } + else if("T2_EquipmentRevision".equals(type)) { + if(groupCode == null || "".equals(groupCode.trim())) { + groupCode = "00Z"; + } + if(sourceCode == null || "".equals(sourceCode.trim())) { + sourceCode = "M"; + } + unit = rev.getStringProperty("t2_unit"); + //unit = "套"; + } + else if("T2_VirtualRevision".equals(type)) { + if(groupCode == null || "".equals(groupCode.trim())) { + groupCode = "00Z"; + } + if(sourceCode == null || "".equals(sourceCode.trim())) { + sourceCode = "X"; + } + unit = "pcs"; + } + if(spec.contains("&")) { + spec = spec.replace("&", "&"); + } + if(spec.contains("<")) { + spec = spec.replace("<", "<"); + } + if(spec.contains(">")) { + spec = spec.replace(">", ">"); + } + if(spec.contains("\"")) { + System.out.println("spec==============="+spec); + spec = spec.replace("\"", """); + System.out.println("11111spec = = = " + spec); + // String[] str = spec.split("\""); + // StringBuilder sb = new StringBuilder(str[0]); + // for (int j = 1; j < str.length; j++) { + // sb.append(str[j]); + // if(j < str.length - 1) { + // sb.append("""); + // } + // } + } + if("".equals(unit.trim()) || unit == null) { + errList.add(id); + } + bean.setItem_spec(spec); + bean.setItem_unit(unit); + bean.setItem_brand(brand); + bean.setItem_id(id); + String item_name = rev.getStringProperty("object_name"); + if(item_name.contains("&")) { + item_name = item_name.replace("&", "&"); + } + if(item_name.contains("\"")) { + item_name = item_name.replace("\"", """); + } + if("".equals(oldMateriel)) { + bean.setItem_name(item_name); + }else { + bean.setItem_name(item_name+"-"+oldMateriel); + } + + bean.setItem_rev(rev.getStringProperty("item_revision_id")); + bean.setOldMateriel(oldMateriel); + bean.setItem_groupCode(groupCode); + bean.setItem_sourceCode(sourceCode); + bean.setItem_uid(rev.getUid()); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + beanList.add(bean); + } + return flag2; + } + + public void setValue(TCComponentItemRevision rev,ItemBean bean) { + try { + // TCProperty groupCodeProp = rev.getTCProperty("t2_groupCode"); + // TCComponentListOfValues groupCodeLov = groupCodeProp.getLOV(); + // String[] groupCodeVals = groupCodeLov.getListOfValues().getStringListOfValues(); + String groupCode = rev.getStringProperty("t2_groupCode"); + System.out.println("t2_groupCode============"+groupCode); + bean.setItem_groupCode(groupCode); + // for (String val : groupCodeVals) { + // String al = groupCodeLov.getListOfValues().getDisplayableValue(val); + // System.out.println("al============"+al); + // + // System.out.println("val============"+val); + // + // if(al.equals(groupCode)) { + // + // bean.setItem_groupCode(val); + // + // + // break; + // } + // } + // TCProperty sourceCodeProp = rev.getTCProperty("t2_sourceCode"); + // TCComponentListOfValues sourceCodeLov = sourceCodeProp.getLOV(); + // String[] sourceCodeVals = sourceCodeLov.getListOfValues().getStringListOfValues(); + String sourceCode = rev.getStringProperty("t2_sourceCode"); + System.out.println("t2_sourceCode============"+sourceCode); + String type = rev.getStringProperty("object_type"); + System.out.println("object_type=============="+type); + if("T2_outsourceRevision".equals(type)) { + if("S".equals(sourceCode)) { + sourceCode = "M"; + System.out.println("t2_sourceCode2============"+sourceCode); + } + } + bean.setItem_sourceCode(sourceCode); + // for (String val : sourceCodeVals) { + // String al = sourceCodeLov.getListOfValues().getDisplayableValue(val); + // if(al.equals(sourceCode)) { + // bean.setItem_sourceCode(val); + // break; + // } + // } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + public List getOutBuyPartValue(TCComponentItemRevision rev,boolean flag) { + // TODO Auto-generated method stub + List vals = new ArrayList(); + StringBuilder sb = new StringBuilder(); + List classPropList = new ArrayList(); + TCClassificationService classificationService = session.getClassificationService(); + try { + String className = rev.getClassificationClass(); + if("".equals(className.trim())) { + MessageBox.post(rev.getStringProperty("item_id")+"该物料没有发送至分类,请先发送分类!!", + "提示", MessageBox.WARNING); + return null; + } + TCComponentICO[] icos = rev.getClassificationObjects(); + 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); + } + } + boolean have = true; + for (int j = 0; j < attrList.size(); j++) { + String classValue = attrList.get(j); + if(classValue.contains(";")) { + String[] classValues = classValue.split(";"); + if(className.equals(classValues[0])) { + for (int k = 1; k < classValues.length; k++) { + String attrName = classValues[k]; + for (int i = 0; i < classPropList.size(); i++) { + ClassPropBean bean = classPropList.get(i); + if(attrName.equals(bean.propDisName)) { + String value = claMap.get(bean.propID); + if(bean.isLov) { + String lovValue = bean.lovMapping.get(value); + if("品牌".equals(attrName) || "单位".equals(attrName)) { + if(flag) { + if("/".equals(lovValue)) { + System.out.println("不进行拼接"); + continue; + } + sb.append(lovValue); + if(k < classValues.length-1) { + sb.append(";"); + } + }else{ + StringBuilder sb1 = new StringBuilder(attrName); + sb1.append("="); + sb1.append(lovValue); + vals.add(sb1.toString()); + if("/".equals(lovValue)) { + System.out.println("不进行拼接"); + continue; + } + sb.append(lovValue); + if(k < classValues.length-1) { + sb.append(";"); + } + } + }else { + if("/".equals(lovValue)) { + System.out.println("不进行拼接"); + continue; + } + sb.append(lovValue); + if(k < classValues.length-1) { + sb.append(";"); + } + } + }else { + if("品牌".equals(attrName) || "单位".equals(attrName)) { + if(flag) { + if("/".equals(value)) { + System.out.println("不进行拼接"); + continue; + } + sb.append(value); + if(k < classValues.length-1) { + sb.append(";"); + } + }else { + StringBuilder sb1 = new StringBuilder(attrName); + sb1.append("="); + sb1.append(value); + vals.add(sb1.toString()); + if("/".equals(value)) { + System.out.println("不进行拼接"); + continue; + } + sb.append(value); + if(k < classValues.length-1) { + sb.append(";"); + } + } + }else { + if("/".equals(value)) { + System.out.println("不进行拼接"); + continue; + } + sb.append(value); + if(k < classValues.length-1) { + sb.append(";"); + } + } + } + break; + } + } + } + have = false; + break; + } + } + } + if(have) { + MessageBox.post("配置文件中未找到该物料的分类"+className+",请联系管理员!!", + "提示", MessageBox.WARNING); + return null; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + String spec = sb.toString(); + vals.add(spec); + return vals; + } + + private String getOutsourceValue(TCComponentItemRevision rev) { + // TODO Auto-generated method stub + StringBuilder sb = new StringBuilder(); + try { + String importance = rev.getStringProperty("t2_Importance"); + if(!("".equals(importance.trim()))) { + sb.append(importance); + sb.append(";"); + } + String material = rev.getStringProperty("t2_material"); + if(!("".equals(material.trim()))) { + sb.append(material); + sb.append(";"); + } + String mass = rev.getStringProperty("t2_MASS"); + if(!("".equals(mass.trim()))) { + sb.append(mass); + sb.append(";"); + } + String specifications = rev.getStringProperty("t2_Specifications"); + if(!("".equals(specifications.trim()))) { + sb.append(specifications); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + String spec = sb.toString(); + return spec; + } + + + protected void createXMLFile(List beanList ,String zhangtao) throws TCException, IOException { + String weiyi_id = ""; + Date date = new Date(); + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmm"); + StringBuilder uidSB = new StringBuilder(); + String fileName = session.getUser().getUserName()+ "-" +df.format(date); + + // String s1 = ""; + // String s2 =""; + // String s3 = ""; + // String s4 = ""; + + + + String sss1 = ""; + String sss2 =""; + tops = sss1 + sss2; + String bottom =""; + int j = 1; + int o = 1; + StringBuilder sss3SB = new StringBuilder(); + StringBuilder xmlSB = new StringBuilder(); + for (int i = 0; i < beanList.size(); i++) { + ItemBean bean = beanList.get(i); + uidSB.append(bean.getItem_uid()); + String n1 =""; + String n2 = ""; + String n3 = ""; + String n = n1 + n2 + n3; + xmlSB.append(n); + j++; + if(i > 0 && i%60 == 0) { + sss3SB.append(fileName); + sss3SB.append("-"+o++); + sss3SB.append(sss3); + sss3SB.append(xmlSB.toString()); + String zong= tops + sss3SB.toString()+bottom; + System.out.println(zong); + String tempPath = System.getProperty("java.io.tmpdir"); + String path = tempPath + fileName + ".txt"; + File file = new File(path); + if (!file.exists()) { + //file.getParentFile().mkdirs(); + file.createNewFile(); + } + try { + FileOutputStream fos = new FileOutputStream(file); + fos.write(zong.getBytes()); + fos.flush(); + fos.close(); + + weiyi_id = getId(); + + System.out.println("=======================唯一识别码" +weiyi_id); + + as.insertNewTxtFile(fileName,file,weiyi_id,session.getUser().getUid(), url, user, password ,"CreateItemMasterDataRequest",beanList.get(0).getItem_id(),zhangtao,session.getUser().getUserId(),uidSB.toString()); + file.delete(); + weiyi_id = ""; + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + j = 1; + uidSB = new StringBuilder(); + xmlSB = new StringBuilder(); + sss3SB = new StringBuilder(); + continue; + } + if(i < beanList.size()-1) { + uidSB.append(";"); + } + + } + if(!("".equals(uidSB.toString()))) { + sss3SB.append(fileName); + sss3SB.append("-"+o++); + sss3SB.append(sss3); + sss3SB.append(xmlSB.toString()); + String zong= tops + sss3SB.toString()+bottom; + System.out.println(zong); + String tempPath = System.getProperty("java.io.tmpdir"); + String path = tempPath + fileName + ".txt"; + File file = new File(path); + if (!file.exists()) { + //file.getParentFile().mkdirs(); + file.createNewFile(); + } + try { + FileOutputStream fos = new FileOutputStream(file); + fos.write(zong.getBytes()); + fos.flush(); + fos.close(); + + weiyi_id = getId(); + + System.out.println("=======================唯一识别码" +weiyi_id); + + as.insertNewTxtFile(fileName,file,weiyi_id,session.getUser().getUid(), url, user, password ,"CreateItemMasterDataRequest",beanList.get(0).getItem_id(),zhangtao,session.getUser().getUserId(),uidSB.toString()); + file.delete(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + + + + // InputStream in = new FileInputStream("c:/fugang.jpg"); + // + // byte[] fileContent = new byte[in.available()]; + // + // in.read(fileContent); + // + // in.close(); + } + public void insertMes(ItemBean bean ,String zhangtao) { + Connection con = null; + PreparedStatement stmt=null; + String sql = "insert into DFL_SEND_WULIAO_TO_ERP values(?,?,?,?,?,?,?,?,?)"; + try { + con = ConnectionFun( ); + stmt = con.prepareStatement(sql); + stmt.setString(1,bean.getItem_id()); + stmt.setString(2,bean.getItem_name()); + stmt.setString(3,bean.getItem_brand()); + stmt.setString(4,bean.getItem_groupCode()); + stmt.setString(5,bean.getItem_rev()); + stmt.setString(6,bean.getItem_sourceCode()); + stmt.setString(7,bean.getItem_spec()); + stmt.setString(8,bean.getItem_unit()); + stmt.setString(9,zhangtao); + stmt.executeUpdate() ; + System.out.println("数据插入数据库完成"); + + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + + public int ifcountdetial(String id) { + int i = 0; + Connection con = null; + PreparedStatement stmt=null; + String sql = "select * from DFL_SEND_WULIAO_TO_ERP where id=?"; + try { + con = ConnectionFun(); + stmt = con.prepareStatement(sql); + ResultSet rs=null; + stmt.setString(1,id); + rs=stmt.executeQuery(); + while(rs.next()) { + i=i+1; + + } + + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + return i; + } + + + + public void updateMes(ItemBean bean ,String zhangtao) { + Connection con = null; + PreparedStatement stmt=null; + + + String sql ="UPDATE DFL_SEND_WULIAO_TO_ERP SET NAME = ?, BRAND = ? , GROUPCODE=?, REV =? , SOURCECODE =? ,SPEC =?, UNIT =?, ACCOUNTSET =? WHERE ID =?"; + try { + con = ConnectionFun( ); + stmt = con.prepareStatement(sql); + + stmt.setString(1,bean.getItem_name()); + stmt.setString(2,bean.getItem_brand()); + stmt.setString(3,bean.getItem_groupCode()); + stmt.setString(4,bean.getItem_rev()); + stmt.setString(5,bean.getItem_sourceCode()); + stmt.setString(6,bean.getItem_spec()); + stmt.setString(7,bean.getItem_unit()); + stmt.setString(8,(String) zhangtao); + stmt.setString(9,bean.getItem_id()); + stmt.executeUpdate(); + + stmt.setString(1,bean.getItem_id()); + + stmt.setString(9,zhangtao); + + System.out.println("数据更新完成"); + + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + + + public Connection ConnectionFun() throws SQLException { + Connection conn = null;// + + try { + // System.out.println(url); + // System.out.println(user); + // System.out.println(password); + Class.forName("oracle.jdbc.driver.OracleDriver"); + System.out.println("驱动加载成功"); + } catch (ClassNotFoundException e) { + System.out.println("驱动加载失败"); + } + conn=DriverManager.getConnection(url,user,password); + System.out.println("数据库连接成功"); + return conn; + + + } + + public static String getId(){ + String id=UUID.randomUUID().toString();//生成的id942cd30b-16c8-449e-8dc5-028f38495bb5中间含有横杠,用来生成数据库的主键id是很实用的。 + id=id.replace("-", "");//替换掉中间的那个斜杠 + return id; + } + + + /** + * 通过查询构建器查询项目对象 + * @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/dfl/plm/dfl019/ItemBean.java b/src/com/connor/dfl/plm/dfl019/ItemBean.java new file mode 100644 index 0000000..4b5ca9f --- /dev/null +++ b/src/com/connor/dfl/plm/dfl019/ItemBean.java @@ -0,0 +1,76 @@ +package com.connor.dfl.plm.dfl019; + +public class ItemBean { + + private String item_id; //品号 item_id ima01 + private String item_name; //品名 object_name ima02 + private String item_spec; //规格 ima021 + private String item_groupCode; //分群码 t2_groupCode ima06 + private String item_unit; //单位 t2_unit ima25 + private String item_sourceCode; //来源码 t2_sourceCode ima08 + private String item_brand; //品牌 imaud03 + private String item_rev; //版本 item_revision_id ima05 + private String oldMateriel; //旧物料号 t2_OldID ima138 + private String item_uid; //uid + public String getItem_id() { + return item_id; + } + public void setItem_id(String item_id) { + this.item_id = item_id; + } + public String getItem_name() { + return item_name; + } + public void setItem_name(String item_name) { + this.item_name = item_name; + } + public String getItem_spec() { + return item_spec; + } + public void setItem_spec(String item_spec) { + this.item_spec = item_spec; + } + public String getItem_groupCode() { + return item_groupCode; + } + public void setItem_groupCode(String item_groupCode) { + this.item_groupCode = item_groupCode; + } + public String getItem_unit() { + return item_unit; + } + public void setItem_unit(String item_unit) { + this.item_unit = item_unit; + } + public String getItem_sourceCode() { + return item_sourceCode; + } + public void setItem_sourceCode(String item_sourceCode) { + this.item_sourceCode = item_sourceCode; + } + public String getItem_brand() { + return item_brand; + } + public void setItem_brand(String item_brand) { + this.item_brand = item_brand; + } + public String getItem_rev() { + return item_rev; + } + public void setItem_rev(String item_rev) { + this.item_rev = item_rev; + } + public String getOldMateriel() { + return oldMateriel; + } + public void setOldMateriel(String oldMateriel) { + this.oldMateriel = oldMateriel; + } + public String getItem_uid() { + return item_uid; + } + public void setItem_uid(String item_uid) { + this.item_uid = item_uid; + } + +} diff --git a/src/com/connor/dfl/plm/dfl019/ParseXMLUtil.java b/src/com/connor/dfl/plm/dfl019/ParseXMLUtil.java new file mode 100644 index 0000000..e9a6ceb --- /dev/null +++ b/src/com/connor/dfl/plm/dfl019/ParseXMLUtil.java @@ -0,0 +1,121 @@ +package com.connor.dfl.plm.dfl019; + +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +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; + } + + /** + * 通过首选项里的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) { + MessageBox.post("数据集没有命名引用的文件或文件过多,请检查!", "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:\\2.xml"); +// ParseXML t = new ParseXML(); +// // t.parseXML(file); +// t.parseXMLCode(file2); +// } +} diff --git a/src/com/connor/dfl/plm/dfl019/WuLiaoERP.java b/src/com/connor/dfl/plm/dfl019/WuLiaoERP.java new file mode 100644 index 0000000..65258b9 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl019/WuLiaoERP.java @@ -0,0 +1,253 @@ +package com.connor.dfl.plm.dfl019; +/*创建系统方案 + * + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +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.io.InputStream; +import java.sql.Blob; +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.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.UUID; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import org.omg.CORBA_2_3.portable.OutputStream; + +import com.connor.dfl.plm.forms.ChangeOrderBean; +import com.connor.dfl.plm.util.CodeBean; +import com.connor.dfl.plm.util.DataBaseControl; +import com.connor.dfl.plm.util.GetCodeBean; +import com.sun.xml.xsom.impl.scd.Iterators.Map; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.ServiceData; +import com.teamcenter.rac.kernel.SoaUtil; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFolderType; +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.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Utilities; + +import oracle.sql.BLOB; + +public class WuLiaoERP extends AbstractAIFDialog { + private AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + private InterfaceAIFComponent targetComp; + TCSession session = (TCSession) app.getSession(); + + List beanList ; + + private JLabel name_lable; + //private JTextField name_field; + private JComboBox combbox; + + private HashMap map=new HashMap(); + String[] arrays; + + private JButton certain_btn; + private JButton cancel_btn; + private JLabel BI_lABLE1; + + + private HashMap account_set = new HashMap(); + + + + + + public WuLiaoERP(AbstractAIFApplication app) { + super(); + this.app = app; + this.session = (TCSession) app.getSession(); + this.beanList =beanList; + + } + + @Override + public void run() { + super.run(); + try { + init(); + } catch (TCException e) { + e.printStackTrace(); + } + } + + private void init() throws TCException { + + + this.setTitle("物料传递ERP"); + this.setPreferredSize(new Dimension(335, 250)); + this.setLayout(null); + + + combbox = new JComboBox(); + BI_lABLE1 = new JLabel("*"); + BI_lABLE1.setFont(new Font("微软雅黑", Font.BOLD, 16)); + BI_lABLE1.setForeground(Color.RED); + + + name_lable = new JLabel(" 公司账套: "); + combbox.addItem(" "); + + + certain_btn = new JButton("确定"); + cancel_btn = new JButton("取消"); + + + this.add(name_lable); + this.add(combbox); + + + String[] stringArrays = session.getPreferenceService().getStringValues("DFL_zhangtao"); + + if (stringArrays == null || stringArrays.length <= 0 ) { + MessageBox.post("首选项DFL_zhangtao未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + }else { + for(int i = 0 ;i0) { +// updateMes(bean); +// }else { +// insertMes(bean); +// } +// +// } +// +// +// +// +// try { +// createXMLFile(beanList,(String)combbox.getSelectedItem()); +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } catch (IOException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// setVisible(false); +// +// MessageBox.post( "传递成功!","成功", MessageBox.INFORMATION); +// + } + }); + } + + + + + + + + + + + + + + + +} diff --git a/src/com/connor/dfl/plm/dfl020/BOMERP.java b/src/com/connor/dfl/plm/dfl020/BOMERP.java new file mode 100644 index 0000000..1cc6a3b --- /dev/null +++ b/src/com/connor/dfl/plm/dfl020/BOMERP.java @@ -0,0 +1,395 @@ +package com.connor.dfl.plm.dfl020; +/*创建系统方案 + * + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedInputStream; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStreamWriter; +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.List; +import java.util.UUID; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.connor.dfl.plm.dfl019.Dfl019Operation; +import com.connor.dfl.plm.util.AutoSign; +import com.connor.dfl.plm.util.CodeBean; +import com.connor.dfl.plm.util.DataBaseControl; +import com.connor.dfl.plm.util.GetCodeBean; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.ServiceData; +import com.teamcenter.rac.kernel.SoaUtil; +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.TCComponentFolderType; +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.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +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.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Utilities; + +import oracle.sql.BLOB; + +public class BOMERP extends AbstractAIFDialog { + private AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + private InterfaceAIFComponent targetComp; + TCSession session = (TCSession) app.getSession(); + + String outPutInfo= ""; + + private JLabel name_lable; + //private JTextField name_field; + private JComboBox combbox; + private HashMap map=new HashMap(); + private List list1= new ArrayList(); + private AutoSign as = null; + + String zong; + String peizhi; + String peizhi_bottom; + String z_peizhi = ""; + + String outString = ""; + + private JButton certain_btn; + private JButton cancel_btn; + private JLabel BI_lABLE1; + + int j = 0; + + + private String url ; + + private String user; + + private String password ; + private Connection conn = null;// + + private PreparedStatement pre = null;// + + private ResultSet result = null;// + + private HashMap account_set = new HashMap(); + + + public BOMERP(AbstractAIFApplication app ,InterfaceAIFComponent targetComp ) { + super(); + this.app = app; + this.session = session; + this.targetComp = targetComp; + this.as=new AutoSign(); + } + + @Override + public void run() { + super.run(); + try { + init(); + } catch (TCException e) { + e.printStackTrace(); + } + } + + private void init() throws TCException { + // TODO Auto-generated method stub + + this.setTitle("BOM传递ERP"); + this.setPreferredSize(new Dimension(335, 250)); + this.setLayout(null); + + + + String[] stringArray = ((TCSession) app.getSession()).getPreferenceService().getStringValues("DFL2_SQL_Connect"); + + url = "jdbc:oracle:thin:@//"+stringArray[0];// + + user = stringArray[1];// + + password = stringArray[2];// + + conn = null;// + + pre = null;// + + result = null;// + + + combbox = new JComboBox(); + BI_lABLE1 = new JLabel("*"); + BI_lABLE1.setFont(new Font("微软雅黑", Font.BOLD, 16)); + BI_lABLE1.setForeground(Color.RED); + + + + name_lable = new JLabel(" 公司账套: "); + combbox.addItem(" "); + + String[] stringArrays = session.getPreferenceService().getStringValues("DFL_zhangtao"); + + if (stringArrays == null || stringArrays.length <= 0 ) { + MessageBox.post("首选项DFL_zhangtao未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + }else { + for(int i = 0 ;i fatherList,ArrayList childList) throws TCException { + // if (childLine == null) { + // return; + // } + // + // + // FatherBomLineBean fb = new FatherBomLineBean(); + // ChirldBomBean cb = new ChirldBomBean(); + // + // TCComponentItem item= childLine.getItem(); + // //父 + // fb.setPinhao(item.getStringProperty("item_id")); + // + // AIFComponentContext aifs[] = childLine.getChildren(); + // if(aifs.length>0) { + // fatherList.add(fb); + // for (int i = 0; i < aifs.length; i++) { + // TCComponentBOMLine z_line = (TCComponentBOMLine) aifs[i].getComponent(); + // + // AIFComponentContext aif[] = z_line.getChildren(); + // for(int ai = 0 ;ai0) { + // z_line.lock(); + // z_line.remove("", (TCComponent) aif[ai].getComponent()); + // z_line.save(); + // z_line.unlock(); + // } + // } + // //获取系统当前日期 + // SimpleDateFormat sdf =new SimpleDateFormat("YYYYMMdd"); + // String daatatext = sdf.format(new Date()); + // int j = 0; + // cb.setNumber(i+1);//序号 + // cb.setPinhao(z_line.getItem().getStringProperty("item_id") );//元件。也就是品号 + // cb.setDate(daatatext);//生效日期 + // cb.setYonglian( z_line.getStringProperty( "T2_DesignQuantity"));//用量 + // cb.setWork_id(z_line.getStringProperty("T2_JobNumber"));//作业编号 + // cb.setChajian_id(" ");//插件位置 + // cb.setPlmkey("");//PLMkey + // childList.add(cb); + // fb.setList(childList); + // traverseBom(z_line, fatherList,childList); + // } + // + // + // } + // + // for (int i = 0; i < aifs.length; i++) { + // TCComponentBOMLine z_line = (TCComponentBOMLine) aifs[i].getComponent(); + // traverseBom(z_line, fatherList,childList); + // } + // + // } + // + // + + + + + + + // public void bianliBOMLine(TCComponentBOMLine line) throws TCException { + // + // FatherBomLineBean fb = new FatherBomLineBean(); + // fb.setDesignQuantity(line.getStringProperty("T2_DesignQuantity")); + // fb.setJobNumber(line.getStringProperty("T2_JobNumber")); + // //fb.setRemark(line.getStringProperty("T2_remark")); + // fb.setRemark(line.getStringProperty("T2_weihao")); + // System.out.println(fb.getDesignQuantity()); + // System.out.println(fb.getJobNumber()); + // //System.out.println(fb.getRemark()); + // //System.out.println(fb.getWeihao()); + // + // //子BOm ,line + // AIFComponentContext[] aifs = line.getChildren(); + // //遍历 + // if(aifs.length>0) { + // + // j++; + // int f = j; + // + // System.out.println("第"+j+ "层级======================================"); + // for(AIFComponentContext aif:aifs) { + // TCComponentBOMLine child = (TCComponentBOMLine) aif.getComponent(); + //// ChirldBomBean cb = new ChirldBomBean(); + //// cb + // if(child.getChildren().length<=0) { + // System.out.println("第"+f+ "层级======================================"); + // } + // + // bianliBOMLine(child); + // } + // + // } + // + // + // + // } + + + + +} diff --git a/src/com/connor/dfl/plm/dfl020/ChirldBomBean.java b/src/com/connor/dfl/plm/dfl020/ChirldBomBean.java new file mode 100644 index 0000000..f73d9ab --- /dev/null +++ b/src/com/connor/dfl/plm/dfl020/ChirldBomBean.java @@ -0,0 +1,85 @@ +package com.connor.dfl.plm.dfl020; + +public class ChirldBomBean { + + private int number;//序号 + private String pinhao ;//元件 + private String date ;//生效日期 + private String yonglian;//用量 + private String work_id;//作业编号 + private String chajian_id ;//插件位置 + private String plmkey;//PLM Key; + private String beizhu;//备注 + + + + + public ChirldBomBean() { + } + public ChirldBomBean(int number, String pinhao, String date, String yonglian, String work_id, String chajian_id, + String plmkey , String beizhu) { + this.number = number; + this.pinhao = pinhao; + this.date = date; + this.yonglian = yonglian; + this.work_id = work_id; + this.chajian_id = chajian_id; + this.plmkey = plmkey; + this.beizhu = beizhu; + } + public int getNumber() { + return number; + } + public void setNumber(int number) { + this.number = number; + } + public String getPinhao() { + return pinhao; + } + public void setPinhao(String pinhao) { + this.pinhao = pinhao; + } + public String getDate() { + return date; + } + public void setDate(String date) { + this.date = date; + } + public String getYonglian() { + return yonglian; + } + public void setYonglian(String yonglian) { + this.yonglian = yonglian; + } + public String getWork_id() { + return work_id; + } + public void setWork_id(String work_id) { + this.work_id = work_id; + } + public String getChajian_id() { + return chajian_id; + } + public void setChajian_id(String chajian_id) { + this.chajian_id = chajian_id; + } + public String getPlmkey() { + return plmkey; + } + public void setPlmkey(String plmkey) { + this.plmkey = plmkey; + } + public String getBeizhu() { + return beizhu; + } + public void setBeizhu(String beizhu) { + this.beizhu = beizhu; + } + + + + + + + +} diff --git a/src/com/connor/dfl/plm/dfl020/Dfl020Handler.java b/src/com/connor/dfl/plm/dfl020/Dfl020Handler.java new file mode 100644 index 0000000..d24056b --- /dev/null +++ b/src/com/connor/dfl/plm/dfl020/Dfl020Handler.java @@ -0,0 +1,27 @@ +package com.connor.dfl.plm.dfl020; + +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.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class Dfl020Handler extends AbstractHandler{ + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComp =app.getTargetComponent(); + TCSession session = (TCSession) app.getSession(); + Dfl020Operation operation = new Dfl020Operation(app, session); + session.queueOperation(operation); +// BOMERP createProblemSpotDialog = new BOMERP(app , targetComp); +// new Thread(createProblemSpotDialog).start(); + return null; + } + + +} diff --git a/src/com/connor/dfl/plm/dfl020/Dfl020Operation.java b/src/com/connor/dfl/plm/dfl020/Dfl020Operation.java new file mode 100644 index 0000000..fd4fc13 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl020/Dfl020Operation.java @@ -0,0 +1,642 @@ +package com.connor.dfl.plm.dfl020; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.jacorb.idl.runtime.int_token; + +import com.connor.dfl.plm.util.AutoSign; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.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.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentProject; +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.kernel.TCTypeService; +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; +import com.teamcenter.schemas.core._2012_09.projectlevelsecurity.ProjectTeamsResponse; +import com.teamcenter.soaictstubs.stringSeq_tHolder; + +import oracle.sql.BLOB; + + + + +public class Dfl020Operation extends AbstractAIFOperation{ + private AbstractAIFApplication app; + private TCSession session; + private List attrList; + + private String url ; + + private String user; + + private String password ; + private Connection conn = null;// + + private PreparedStatement pre = null;// + + private ResultSet result = null;// + private String outPutInfo= ""; + private String tops; + private String ns ; + + private String weiyi_id; + String accountSet; + private String zhangtao; + private AutoSign as = null; + String zong; + + + String z_peizhi = ""; + + String outString = ""; + + private String txt_pinhao; + + + public Dfl020Operation(AbstractAIFApplication app, TCSession session ,String accountSet,String zhangtao) { + this.app = app; + this.session = session; + this.accountSet = accountSet; + this.as=new AutoSign(); + this.zhangtao = zhangtao; + } + public Dfl020Operation(AbstractAIFApplication app, TCSession session) { + this.app = app; + this.session = session; + this.as=new AutoSign(); + String[] stringArrays = session.getPreferenceService().getStringValues("DFL_zhangtao"); + String[] BOMZT = session.getPreferenceService().getStringValues("DFL_ERPBom_zhangtao"); + if (BOMZT == null || BOMZT.length <= 0 ) { + MessageBox.post("首选项DFL_ERPBom_zhangtao未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + } + Map account_set = new HashMap(); + if (stringArrays == null || stringArrays.length <= 0 ) { + MessageBox.post("首选项DFL_zhangtao未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + }else { + for(int i = 0 ;i=2) { + for (int i = 0; i < BOMZT.length; i++) { + if(BOMZT[i].contains("=")) { + String[] zts = BOMZT[i].split("="); + if(names[names.length-2].equals(zts[0])) { + this.zhangtao = zts[1]; + this.accountSet = account_set.get(zhangtao); + break; + } + } + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + public void executeOperation(){ + new Runnable() { + public void run() { + sendBOMTOERP(); + } + }.run(); + } + + public void sendBOMTOERP() { + InterfaceAIFComponent[] comp = app.getTargetComponents(); + String uid =""; + + + String[] stringArray = ((TCSession) app.getSession()).getPreferenceService().getStringValues("DFL2_SQL_Connect"); + + url = "jdbc:oracle:thin:@//"+stringArray[0];// + + user = stringArray[1];// + + password = stringArray[2];// + + conn = null;// + + pre = null;// + + result = null;// + + + + TCComponentItemRevision rev = null; + + try { + if(comp[0] instanceof TCComponentItemRevision || comp[0] instanceof TCComponentBOMLine ) { + + if(comp[0] instanceof TCComponentItemRevision ) { + rev = (TCComponentItemRevision) comp[0]; + } + if(comp[0] instanceof TCComponentBOMLine ) { + TCComponentBOMLine get_bom_line = (TCComponentBOMLine) comp[0]; + rev = get_bom_line.getItemRevision(); + } + TCProperty tcProperty1 = rev.getTCProperty("release_status_list"); + TCComponent[] targets1 = tcProperty1.getReferenceValueArray(); + String item_type = rev.getType(); + //限制没有发布状态的非虚拟件版本发起bom传递erp命令 +// if(!("T2_VirtualRevision".equals(item_type))) { +// if(targets1 == null || targets1.length <= 0) { +// MessageBox.post("您选中的版本对象没有发布状态","提示",MessageBox.INFORMATION); +// return; +// } +// } + //限制外购件版本发起bom传递erp命令 + if("T2_OutBuyPartRevision".equals(item_type)) { + MessageBox.post("您选中的版本对象是外购件版本,不能进行bom传递erp","提示",MessageBox.INFORMATION); + return; + } + //限制外协件版本发起bom传递erp命令 + if ("T2_outsourceRevision".equals(item_type)) { + MessageBox.post("您选中的版本对象是外协件版本,不能进行bom传递erp","提示",MessageBox.INFORMATION); + return; + } + //限制系统方案版本发起bom传递erp命令 + if ("T2_SystemSchemeRevision".equals(item_type)) { + MessageBox.post("您选中的版本对象是系统方案版本,不能进行bom传递erp","提示",MessageBox.INFORMATION); + return; + } + //TCProperty tcProperty = rev.getTCProperty("fnd0MyWorkflowTasks"); + TCProperty tcProperty = rev.getTCProperty("fnd0MyWorkflowTasks"); + TCComponent[] targets = tcProperty.getReferenceValueArray(); + if(targets != null && targets.length>0) { + // MessageBox.post("您选中的版本对象没有在流程中","提示",MessageBox.INFORMATION); + // return; + for(int i = 0;i 0) { + createXMLFile(line,zhangtao); + }else { + MessageBox.post("不允许单个物料进行BOM传递ERP","提示",MessageBox.INFORMATION); + return; + } + view.close(); + if(!("".equals(uid))&& !(" ".equals(uid))) { + + as.AutoSignServer(uid,session); + + } + MessageBox.post("BOM数据存储成功,准备传递ERP!!!", + "提示", MessageBox.WARNING); + } catch (Exception e) { + // TODO Auto-generated catch block + MessageBox.post("BOM数据存储失败,请检查后重新传递!!!", + "提示", MessageBox.WARNING); + e.printStackTrace(); + } + } + + //生产xml文件 + + protected void createXMLFile(TCComponentBOMLine line ,String zhangtao) throws TCException, IOException { + + List list = new ArrayList(); + StringBuilder uidSB = new StringBuilder(); + try { + getBOMValue(line,list); + if(list.size() <=0) { + MessageBox.post("您传递的BOM都已经传递到ERP,请检查!", "提示", + MessageBox.INFORMATION); + return; + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post("BOM 传递失败,请检查BOM行是否正确!!!" ,"提示",MessageBox.INFORMATION); + return; + } + //获取父 属性 + StringBuilder sb2 = new StringBuilder(); + Date date = new Date(); + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmm"); + String plmls = df.format(date); + String userName = session.getUser().getUserName(); + + String s1 =""; + String s3 = ""; + String s4 = ""; + String s5 = ""; + String s6 = ""; + + sb2.append(s1); + sb2.append(s3); + sb2.append(s4); + sb2.append(s5); + sb2.append(s6); + for(int f_index = 0;f_index< list.size();f_index++) { + uidSB.append(list.get(f_index).getItem_uid()); + if(f_index< list.size()-1) { + uidSB.append(";"); + } + int iii = f_index+1; + System.out.println("==== 第"+ iii+"个配置"); + System.out.println("******品号"+list.get(f_index).getPinhao()+"*****"); + + String peizhi1 =""; + //String peizhi2 = "第"+iii +"个配置 "; + String peizhi3 = ""; + + sb2.append(peizhi1); + sb2.append(peizhi3); + sb2.append(peizhi4); + //z_peizhi+=peizhi; + List l = (List) list.get(f_index).getList(); + for(int z = 0 ;z"; + String yj = ""; + String sxrq = ""; + String yl = ""; + String zybh = ""; + String xjwz = ""; + String bz = ""; + String plmkey =""; + sb2.append(xh);//序号 + sb2.append(yj);//id + sb2.append(sxrq);//生效日期 + sb2.append(yl);// + sb2.append(zybh);//作业编号 + sb2.append(xjwz);// + sb2.append(bz); + sb2.append(plmkey); + + } + sb2.append(""); + } + + + String bottomS =""; + sb2.append(bottomS); + outPutInfo = sb2.toString(); + System.out.println("================"+outPutInfo); + + String fileName ="BOM"+ plmls; + String tempPath = System.getProperty("java.io.tmpdir"); + String path = tempPath + fileName + ".txt"; + File file = new File(path); + + if (!file.exists()) { + //file.getParentFile().mkdirs(); + file.createNewFile(); + } + try { + FileOutputStream fos = new FileOutputStream(file); + fos.write(outPutInfo.getBytes()); + fos.flush(); + fos.close(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // + // InputStream in = new FileInputStream("c:/fugang.jpg"); + // + // byte[] fileContent = new byte[in.available()]; + // + // in.read(fileContent); + // + // in.close(); + // // + + //将txt文件 保存到数据库 + + weiyi_id = getId(); + + System.out.println("=======================唯一识别码" +weiyi_id); + + + as.insertNewTxtFile(fileName,file, weiyi_id,session.getUser().getUid() , url, user, password,"CreatePLMBOMDataRequest",list.get(0).getPinhao(),zhangtao,session.getUser().getUserId(),uidSB.toString()); + + + // as.insertNewTxtFile(fileName,file,weiyi_id,session.getUser().getUid(), url, user, password ,"CreateItemMasterData"); + + file.delete(); + } + + + private void getBOMValue(TCComponentBOMLine line, List list) + { + FatherBomLineBean fatherBean = new FatherBomLineBean(); + try + { + TCComponentItemRevision rev = line.getItemRevision(); + AIFComponentContext[] childrens = line.getChildren(); + if (childrens.length > 0) { + rev.getStringProperty("t2_ERPBomStatus"); + } else { + return; + } + List z_list = new ArrayList(); + String fuID = rev.getStringProperty("item_id"); + fuID = fuID.replace("-Y", ""); + String fuType = rev.getStringProperty("object_type"); + if ("T2_outsourceRevision".equals(fuType)) + { + String revId = rev.getStringProperty("item_revision_id"); + fuID = fuID + revId; + } + fatherBean.setPinhao(fuID); + fatherBean.setItem_uid(rev.getUid()); + int childLineNum = 0; + boolean ispack = false; + for (int i = 0; i < childrens.length; i++) + { + InterfaceAIFComponent childComp = childrens[i].getComponent(); + if ((childComp instanceof TCComponentBOMLine)) + { + TCComponentBOMLine childLine = (TCComponentBOMLine)childComp; + String num = childLine.getStringProperty( "T2_ActualConsumption");//实际用量 + if(num==null||"".equals(num.trim())) { + num = childLine.getStringProperty( "T2_DesignQuantity");//设计用量 + if(num==null||"".equals(num.trim())) { + num = childLine.getStringProperty( "bl_quantity");//用量 +// if(num==null||"".equals(num.trim())) { +// int num1=1; +// num =String.valueOf(num1);//默认为1 +// } + } + } + System.out.println("num=============="+num); + //如果是数量为“已打包的注释”则解包 + if(childLine.isPacked() && "已打包的注释".equals(num)) + { + childLine.unpack(); + ispack = true; + childLine.refresh(); + } + } + } + if (ispack) { + line.refresh(); + } + childrens = line.getChildren(); + List idList = new ArrayList(); + for (int i = 0; i < childrens.length; i++) + { + InterfaceAIFComponent childComp = childrens[i].getComponent(); + if ((childComp instanceof TCComponentBOMLine)) + { + TCComponentBOMLine childLine = (TCComponentBOMLine)childComp; + String occType = childLine.getStringProperty("TCAI_OCC_TYPE"); + if (!"Reference".equals(occType)) + { + getChildValue(childLine, z_list, childLineNum,idList); + childLineNum++; + } + } + } + + fatherBean.setList(z_list); + list.add(fatherBean); + for (int i = 0; i < childrens.length; i++) + { + TCComponentBOMLine z_line = (TCComponentBOMLine)childrens[i].getComponent(); + TCComponentItem item = z_line.getItem(); + String type = item.getType(); + System.out.println("type=============" + type); + if (!("T2_OutBuyPart".equals(type)) && !("T2_outsource".equals(type))) + { + String occType = z_line.getStringProperty("TCAI_OCC_TYPE"); + if (!"Reference".equals(occType)) + { + AIFComponentContext[] childrenAifs = z_line.getChildren(); + if (childrenAifs.length > 0) { + getBOMValue(z_line, list); + } + } + } + } + } + catch (TCException e) + { + e.printStackTrace(); + } + } + private String toString(int num1) { + // TODO Auto-generated method stub + return null; + } + public void getChildValue(TCComponentBOMLine childLine, List z_list,int childLineNum,List idList) { + try { + String occType = childLine.getStringProperty("TCAI_OCC_TYPE"); + if("Reference".equals(occType)) { + return; + } + String childID = childLine.getItem().getStringProperty("item_id"); + String Quantity = childLine.getStringProperty( "T2_ActualConsumption");//实际用量 + if(Quantity==null||"".equals(Quantity.trim())) { + Quantity = childLine.getStringProperty( "T2_DesignQuantity");//设计用量 + if(Quantity==null||"".equals(Quantity.trim())) { + Quantity = childLine.getStringProperty( "bl_quantity");//用量 + if(Quantity==null||"".equals(Quantity.trim())) { + + Quantity =1+"";//默认为1 + } + } + } + System.out.println("Quantity=============="+Quantity); + if(idList.contains(childID)) { + int index = idList.indexOf(childID); + ChirldBomBean child = z_list.get(index); + String yl = child.getYonglian(); + double d1 = Double.parseDouble(yl); + double d2 = 0; + if(Quantity != null && !("".equals(Quantity.trim()))) { + try { + d2 = Double.parseDouble(Quantity); + } catch (Exception e) { + // TODO: handle exception + d2 = 1; + } + }else { + d2 = 1; + } + double d3 = d1 + d2; + child.setYonglian(d3+""); + return; + }else { + idList.add(childID); + } + ChirldBomBean childBean = new ChirldBomBean(); + //获取系统当前日期 + SimpleDateFormat sdf =new SimpleDateFormat("YYYYMMdd"); + String daatatext = sdf.format(new Date()); + int j = 0; + childBean.setNumber(childLineNum+1);//序号 + childBean.setYonglian(Quantity); + String childRev = childLine.getItemRevision().getStringProperty("item_revision_id"); + String childType = childLine.getItem().getStringProperty("object_type"); + childID = childID.replace("-Y", ""); + System.out.println("childID============"+childID); + System.out.println("childRev============"+childRev); + System.out.println("childType============"+childType); + if("T2_outsource".equals(childType)) { + StringBuilder sb = new StringBuilder(childID); + sb.append(childRev); + childID = sb.toString(); + } + System.out.println("childID2============"+childID); + childBean.setPinhao(childID);//元件。也就是品号 + //将获取到的date类型转换为String类型 + java.text.SimpleDateFormat formatter = new SimpleDateFormat( "yyyy/MM/dd"); + + Date released_time = childLine.getItemRevision().getDateProperty("last_mod_date"); + String date = formatter.format(released_time);//获取创建时间 + + childBean.setDate(date);//生效日期 + //外购 外协 要判断是否发布 + + + + childBean.setWork_id(childLine.getStringProperty("T2_JobNumber"));//作业编号 + childBean.setBeizhu(childLine.getStringProperty("T2_remark"));//备注 + childBean.setChajian_id(childLine.getStringProperty("T2_weihao"));//插件位置 + + + // T2_DesignQuantity 设计用量 + // T2_JobNumber 作业编号 + // T2_remark 备注 + // T2_weihao 位号 + + childBean.setPlmkey(childID+"-"+childLine.getItemRevision().getStringProperty("item_revision_id") );//PLMkey + z_list.add(childBean); + + } catch (Exception e) { + // TODO: handle exception + } + } + + public static String getId(){ + String id=UUID.randomUUID().toString();//生成的id942cd30b-16c8-449e-8dc5-028f38495bb5中间含有横杠,用来生成数据库的主键id是很实用的。 + id=id.replace("-", "");//替换掉中间的那个斜杠 + return id; + } + +} + diff --git a/src/com/connor/dfl/plm/dfl020/FatherBomLineBean.java b/src/com/connor/dfl/plm/dfl020/FatherBomLineBean.java new file mode 100644 index 0000000..d73e2d6 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl020/FatherBomLineBean.java @@ -0,0 +1,41 @@ +package com.connor.dfl.plm.dfl020; + +import java.util.List; + +/** + * + * @author 孙毅 + * + + */ +public class FatherBomLineBean { + + private List list;//存放子键对象 + private String pinhao ; //品号 + private String item_uid; //物料uid + public List getList() { + return list; + } + public void setList(List list) { + this.list = list; + } + public String getPinhao() { + return pinhao; + } + public void setPinhao(String pinhao) { + this.pinhao = pinhao; + } + public String getItem_uid() { + return item_uid; + } + public void setItem_uid(String item_uid) { + this.item_uid = item_uid; + } + + + + + + + +} diff --git a/src/com/connor/dfl/plm/dfl021/ChangeOwnerbean.java b/src/com/connor/dfl/plm/dfl021/ChangeOwnerbean.java new file mode 100644 index 0000000..c48f886 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl021/ChangeOwnerbean.java @@ -0,0 +1,35 @@ +package com.connor.dfl.plm.dfl021; + +public class ChangeOwnerbean { + + private String name; + private String handleTime; + private String handleIdea; + private String uid; + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getHandleTime() { + return handleTime; + } + public void setHandleTime(String handleTime) { + this.handleTime = handleTime; + } + public String getHandleIdea() { + return handleIdea; + } + public void setHandleIdea(String handleIdea) { + this.handleIdea = handleIdea; + } + public String getUid() { + return uid; + } + public void setUid(String uid) { + this.uid = uid; + } + + +} diff --git a/src/com/connor/dfl/plm/dfl021/ComparatorDate.java b/src/com/connor/dfl/plm/dfl021/ComparatorDate.java new file mode 100644 index 0000000..9f7dedb --- /dev/null +++ b/src/com/connor/dfl/plm/dfl021/ComparatorDate.java @@ -0,0 +1,17 @@ +package com.connor.dfl.plm.dfl021; + +import java.util.Comparator; +import java.util.Date; + +class ComparatorDate implements Comparator { + + public int compare(Object obj1, Object obj2) { + Date begin = (Date) obj1; + Date end = (Date) obj2; + if (begin.after(end)) { + return 1; + } else { + return -1; + } + } +} \ No newline at end of file diff --git a/src/com/connor/dfl/plm/dfl021/Dfl021Handler.java b/src/com/connor/dfl/plm/dfl021/Dfl021Handler.java new file mode 100644 index 0000000..8c25c6e --- /dev/null +++ b/src/com/connor/dfl/plm/dfl021/Dfl021Handler.java @@ -0,0 +1,27 @@ +package com.connor.dfl.plm.dfl021; + +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.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class Dfl021Handler extends AbstractHandler{ + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + + InterfaceAIFComponent targetComp =app.getTargetComponent(); + + SearchHasSignWorkDialog createProblemSpotDialog = new SearchHasSignWorkDialog(app , targetComp); + + new Thread(createProblemSpotDialog).start(); + + return null; + } + + +} diff --git a/src/com/connor/dfl/plm/dfl021/SearchHasSignWorkDialog.java b/src/com/connor/dfl/plm/dfl021/SearchHasSignWorkDialog.java new file mode 100644 index 0000000..337351c --- /dev/null +++ b/src/com/connor/dfl/plm/dfl021/SearchHasSignWorkDialog.java @@ -0,0 +1,458 @@ +package com.connor.dfl.plm.dfl021; +/*创建系统方案 + * + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +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.JTextArea; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.LineBorder; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; +import javax.swing.table.TableRowSorter; + + +import com.connor.dfl.plm.util.DateChooser; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +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.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.project.plugin.Activator; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class SearchHasSignWorkDialog extends AbstractAIFDialog { + private AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + private InterfaceAIFComponent targetComp; + TCSession session = (TCSession) app.getSession(); + + private JLabel endDateJlable ;//审批时间晚于 + private JTextField endDateFaild; + + private JLabel startDateJlable; //审批时间早于 + private JTextField startDateFaild; + private JButton searchButton; + DefaultTableModel model2; + private JTable table2; + private DefaultTableCellRenderer tcr; + int rows1 = 1; + private JComboBox comBox1; + private JComboBox comBox2; + private String[] columnNames = {"任务名","处理时间","处理意见",""}; + private List compList; + + public SearchHasSignWorkDialog(AbstractAIFApplication app ,InterfaceAIFComponent targetComp ) { + super(); + this.app = app; + this.session = session; + this.targetComp = targetComp; + } + + @Override + public void run() { + + + try { + init(); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + @SuppressWarnings("serial") + private void init() throws ParseException, TCException { + // TODO Auto-generated method stub + + this.setTitle("查找流程审批任务"); + + this.setPreferredSize(new Dimension(600, 450)); + endDateJlable = new JLabel("创建时间晚于:"); + + startDateJlable = new JLabel("修改时间早于:"); + + + DateChooser dateChooser1 = DateChooser.getInstance("yyyy-M-d"); + + DateChooser dateChooser2 = DateChooser.getInstance("yyyy-M-d"); + + Date date = new Date(); + SimpleDateFormat df = new SimpleDateFormat("yyyy-M-d"); + String time = df.format(date); + + endDateFaild = new JTextField(time); + startDateFaild = new JTextField(time); + + dateChooser1.register(endDateFaild); + dateChooser2.register(startDateFaild); + + JPanel panleDate = new JPanel(); + panleDate.setPreferredSize(new Dimension(600, 50)); + + endDateJlable.setBounds(0, 80, 50, 30); + + endDateFaild. setBounds(50, 80, 250, 30); + + startDateJlable.setBounds(300, 80, 50, 30); + startDateFaild.setBounds(350, 80, 250, 30); + + searchButton = new JButton("搜索"); + searchButton.setBounds(450, 20, 100, 30); + + panleDate.add(endDateJlable); + panleDate.add(endDateFaild); + panleDate.add(startDateJlable); + panleDate.add(startDateFaild); + panleDate.add(searchButton); + panleDate.add(searchButton); + + model2 = new DefaultTableModel() { + private static final long serialVersionUID = 6905817304437097181L; + public boolean isCellEditable(int row, int column) { + return false; + } + }; + table2 = new JTable(model2){ + public String getToolTipText(MouseEvent e) { + int row=table2.rowAtPoint(e.getPoint()); + int col=table2.columnAtPoint(e.getPoint()); + String tiptextString=null; + if(row>-1 && col>-1){ + Object value=table2.getValueAt(row, col); + if(null!=value && !"".equals(value)) + tiptextString=value.toString();//悬浮显示单元格内容 + } + return tiptextString; + } + }; + +// model2 = new DefaultTableModel(null, new String[] {"任务名","处理时间","处理意见",""}) { +// public void setValueAt(Object value, int row, int col){ +// Vector rowVector = (Vector) dataVector.elementAt(row); +// rowVector.setElementAt(value, col); +// fireTableCellUpdated(row, col); +// } +// }; + +// table2 = new MyTable() { +// @Override +// public boolean isCellEditable(int row, int column) { +// if(column == 0) { +// return false; +// } +// return true; +// } +// +// }; + TableRowSorter sorter = new TableRowSorter(model2); + table2.setRowSorter(sorter); //为JTable设置排序器 + table2.setDefaultRenderer(Object.class, new TableCellTextAreaRenderer()); + table2.setModel(model2); + + table2.setRowHeight(35); + tcr = new DefaultTableCellRenderer(); + tcr.setHorizontalAlignment(SwingConstants.CENTER); + + table2.setBorder(new LineBorder(Color.BLACK)); + table2.setDefaultRenderer(Object.class, tcr); + + /** + * 查询字段 + * 类型: 执行签发任务 + * 所有权用户 + * 修改时间晚于 + * 修改时间早于 + */ + + + + + searchButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + List list=new ArrayList<>(); + while (table2.getRowCount() > 0) { + ((DefaultTableModel) table2.getModel()).removeRow(0); + } + rows1 = 1; + final String time1 = endDateFaild.getText()+" 00:00"; + final String time2 = startDateFaild.getText()+" 00:00"; + System.out.println("time1============"+time1); + System.out.println("time2============"+time2); + List lists = new ArrayList(); + String[] keys = new String[] {"ID","创建日期","结束日期"}; + TCComponentUser user = session.getUser(); + try { + String user_id = user.getStringProperty("user_id"); + String[] values = new String[] {session.getUser().getUserId(),time1,time2}; + System.out.println("+++++++++++++++++"+ time1); + System.out.println("+++++++++++++++++"+ time2); + + compList = queryObject("任务搜索", keys, values); + if(compList.size()>0) { + for(int j = 0;j< compList.size();j++) { + ChangeOwnerbean project = new ChangeOwnerbean(); + // dateset = (TCComponentDataset) session.stringToComponent(uid); + Date date = compList.get(j).getDateProperty("last_mod_date"); + + SimpleDateFormat df = new SimpleDateFormat("yyyy-M-d"); + + String time = df.format(date); + project.setName(compList.get(j).getStringProperty("job_name")); + project.setHandleTime(time); + project.setHandleIdea(compList.get(j).getStringProperty("fnd0Status")); + project.setUid(compList.get(j).getUid()); + list.add(project); + } + //封装结果集 + Object res[][] = new Object[list.size()][columnNames.length]; + int i=0; + for (ChangeOwnerbean record : list) { + res[i++]=new Object[] {record.getName(),record.getHandleTime(),record.getHandleIdea(),record.getUid()}; + } + model2.setDataVector(res, columnNames); + table2.setColumnModel(getColumn(table2, new int[] { 180, 180, 180 ,0})); + + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }); + + table2.addMouseListener(new MouseAdapter() { + int table2Row = -1; + public void mouseClicked(MouseEvent e){ + if(e.getButton() == MouseEvent.BUTTON3){ + // table2Row = table2.rowAtPoint(e.getPoint()); + table2Row = table2.getSelectedRow(); + table2.setRowSelectionInterval(table2Row, table2Row); + int indexRow = table2.convertRowIndexToModel(table2Row); + System.out.println("indexRow=============="+indexRow); + if(table2Row >= 0){ + System.out.println("1111111111111111111"); + try { + createPopupMenu(indexRow); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + } + } + }); + + + JScrollPane tablePanel = new JScrollPane(table2); + tablePanel.setPreferredSize(new Dimension(600, 300)); + this.setLayout(new PropertyLayout()); + this.add("1.1.center.top",panleDate); + this.add("2.1.center.top",tablePanel); + this.setResizable(false); + this.setAlwaysOnTop(true); + this.centerToScreen(); + this.setVisible(true); + } + + //添加右键菜单 + private void createPopupMenu(final int row) throws TCException { + //m_popupMenu = new JPopupMenu(); + + //JMenuItem delMenItem = new JMenuItem(); + //delMenItem.setText("发送到'我的Teamcenter'"); + //delMenItem.addActionListener(new java.awt.event.ActionListener() { + //public void actionPerformed(java.awt.event.ActionEvent evt) { + //该操作需要做的事 + System.out.println("==发送到item=="+row); + int column = 0; + String uid = (String) table2.getModel().getValueAt(row,3); + System.out.println("=================uid" + uid); + TCComponent comp = session.stringToComponent(uid); + + if ((comp instanceof TCComponent)) { + Activator.getDefault().openPerspective("com.teamcenter.rac.ui.perspectives.navigatorPerspective"); + Activator.getDefault().openComponents("com.teamcenter.rac.ui.perspectives.navigatorPerspective", new InterfaceAIFComponent[]{comp}); + } + } + + public boolean openByApplicationOpenMethod(AbstractAIFUIApplication var1, TCComponent var2) { + boolean var3 = false; + if (var1 != null && var2 != null) { + var3 = var1.reopen(var2); + } + + if (!var3) { + AbstractAIFUIApplication var4 = AIFUtility.getCurrentApplication(); + if (var4 != var1 && var4 != null && var2 != null) { + var3 = var4.open(var2); + } + } + + return var3; + } + + /** + * JTable设置列宽 + */ + public static TableColumnModel getColumn(JTable table, int[] width) { + TableColumnModel columns = table.getColumnModel(); + for (int i = 0; i < width.length; i++) { + TableColumn column = columns.getColumn(i); + column.setPreferredWidth(width[i]); + } + return columns; + } + + + + class MyTable extends JTable { + int myRow = -1, myCol = -1; + TableCellEditor myEditor; + Map map = new HashMap(); + + public void setComboCell(int r, int c, TableCellEditor ce) { + this.myRow = r; + this.myCol = c; + this.myEditor = ce; + map.put(new Point(r, c), ce); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + System.out.println(row + "," + column + ";" + myRow + "," + myCol + "," + myEditor); + + Point point = new Point(row, column); + if (map.containsKey(point)) { + return map.get(point); + } else { + return super.getCellEditor(row, column); + } + } + } + + + /** + * 通过查询构建器查询项目对象 + * + * @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; + } + } + + + + 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/dfl/plm/dfl023/Dfl023Hander.java b/src/com/connor/dfl/plm/dfl023/Dfl023Hander.java new file mode 100644 index 0000000..846dc6c --- /dev/null +++ b/src/com/connor/dfl/plm/dfl023/Dfl023Hander.java @@ -0,0 +1,25 @@ +package com.connor.dfl.plm.dfl023; + +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; +/** + * @author sheng + * @LastModifyDate 2019/6/14 16:01 + * */ +public class Dfl023Hander extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + FczskAction action = new FczskAction(app, null); + new Thread(action).start(); + return null; + } + +} + + diff --git a/src/com/connor/dfl/plm/dfl023/FczskAction.java b/src/com/connor/dfl/plm/dfl023/FczskAction.java new file mode 100644 index 0000000..18be72e --- /dev/null +++ b/src/com/connor/dfl/plm/dfl023/FczskAction.java @@ -0,0 +1,79 @@ +package com.connor.dfl.plm.dfl023; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.IPerspectiveDefService; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.services.IOpenService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.OSGIUtil; +import com.teamcenter.rac.ui.commands.RACUICommandsActivator; +public class FczskAction extends AbstractAIFAction { + private AbstractAIFApplication app; + String preferName = "DFL_FolderUID"; + + public FczskAction(AbstractAIFApplication app,String arg0) { + super(app, arg0); + this.app = app; + } + @Override + public void run() { + TCSession session = (TCSession)app.getSession(); + try { + String puid = TcUtil.getPreferenceVal(preferName); + TCComponent comp = session.stringToComponent(puid); + String type = comp.getType(); + System.out.println("type==>"+type);//folder + if(type==null || !"Folder".equals(type)) { + System.out.println("首选项配置错误,请检查 "+ preferName + "首选项"); + + } + TCComponentFolder folder = (TCComponentFolder)comp; + + IOpenService var4 = AIFUtility.getCurrentOpenService(); + if (var4 != null) { + if (var4 instanceof AbstractAIFUIApplication) { + AbstractAIFUIApplication var5 = (AbstractAIFUIApplication) var4; + this.openByApplicationOpenMethod(var5, folder); + } else { + var4.open(folder); + } + } + } catch (TCException e) { + MessageBox.post("首选项配置错误,请检查 "+ preferName + "首选项", "提示", MessageBox.ERROR); + e.printStackTrace(); + } + } + + public boolean openByApplicationOpenMethod(AbstractAIFUIApplication var1, TCComponent var2) { + boolean var3 = false; + if (var1 != null && var2 != null) { + var3 = var1.reopen(var2); + } + + if (!var3) { + AbstractAIFUIApplication var4 = AIFUtility.getCurrentApplication(); + if (var4 != var1 && var4 != null && var2 != null) { + var3 = var4.open(var2); + } + } + + return var3; + } + + protected static IPerspectiveDefService getPerspectiveDefService() { + return (IPerspectiveDefService) OSGIUtil.getService(RACUICommandsActivator.getDefault(), + IPerspectiveDefService.class); + } + + protected static String getDefaultPerspectiveId() { + return "com.teamcenter.rac.ui.perspectives.navigatorPerspective"; + } + + + +} diff --git a/src/com/connor/dfl/plm/dfl023/TcUtil.java b/src/com/connor/dfl/plm/dfl023/TcUtil.java new file mode 100644 index 0000000..b51b931 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl023/TcUtil.java @@ -0,0 +1,57 @@ +package com.connor.dfl.plm.dfl023; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; + +public class TcUtil { + private static AbstractAIFApplication app; + private static TCSession session; + static{ + app = AIFUtility.getCurrentApplication(); + if(app != null){ + session = (TCSession) app.getSession(); + } + } + public static TCSession getSession(){ + if(session != null) { + return session; + }else { + app = AIFUtility.getCurrentApplication(); + if(app != null){ + session = (TCSession) app.getSession(); + } + return session; + } + + } + public static String getPreferenceVal(String queryName){ + if(session == null){ + System.out.println("session is null"); + return null; + } + TCPreferenceService service = session.getPreferenceService(); + String valuesTemp = service.getStringValue(queryName); + if(valuesTemp == null){ + System.out.println("首选项["+queryName+"]为空"); + return null; + } + return valuesTemp; + } + + public static String[] getPreferenceVals(String queryName){ + if(session == null){ + System.out.println("session is null"); + return null; + } + TCPreferenceService service = session.getPreferenceService(); + String[] valuesTemp = service.getStringValues(queryName); + if(valuesTemp == null){ + System.out.println("首选项["+queryName+"]为空"); + return null; + } + return valuesTemp; + } + +} diff --git a/src/com/connor/dfl/plm/dfl024/Dfl024Dialog.java b/src/com/connor/dfl/plm/dfl024/Dfl024Dialog.java new file mode 100644 index 0000000..78edb30 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl024/Dfl024Dialog.java @@ -0,0 +1,174 @@ +package com.connor.dfl.plm.dfl024; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; + + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class Dfl024Dialog extends AbstractAIFDialog{ + private AbstractAIFUIApplication app; + private TCSession session; + private TCComponentFolder prohectFolder; + private List folder_values; + private List deliverable_values; + private JComboBox comb; + private AIFComponentContext[] childs; + private String pathRoute; + private JTextField pathField ; + private String fielName; + private List projectFolderList ; + private String projextFolderName; + public Dfl024Dialog(AbstractAIFUIApplication app, TCComponentFolder prohectFolder) { + super(); + this.app = app; + this.session = (TCSession) app.getSession(); + this.prohectFolder = prohectFolder; + this.folder_values = new ArrayList(); + this.deliverable_values = new ArrayList(); + this.comb = null; + this.childs = null; + this.pathRoute = null; + this.pathField = null; + this.fielName = null; + } + public void run(){ + initUI(); + } + /** + * 主页面 + */ + private void initUI() { + String puid = session.getPreferenceService().getStringValue( + "DFL_Check_Deliverable_puid"); + if (puid == null||puid.equals("")) { + + MessageBox.post("首选项DFL_Check_Deliverable_puid未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + } + try { + + TCComponentDataset excelData = (TCComponentDataset) session.stringToComponent(puid); + fielName = excelData.getStringProperty("object_name"); + System.out.println("fielName====================="+fielName); + projextFolderName = prohectFolder.getStringProperty("object_name"); + System.out.println("==========" +projextFolderName ); + + + + childs = prohectFolder.getChildren(); + + } catch (TCException e) { + e.printStackTrace(); + } + + + this.setLayout(new BorderLayout()); + this.setTitle("导出项目交付物点检表"); + this.setPreferredSize(new Dimension(320, 130)); + this.setResizable(false); + JPanel mainPanel = new JPanel(new BorderLayout()); + JPanel centerPanel = new JPanel(new PropertyLayout()); + JPanel southPanel = new JPanel(new FlowLayout()); + JLabel name = new JLabel(" 检查阶段"); +// comb = new JComboBox(); +// for (int i = 0; i < values.size(); i++) { +// comb.addItem(values.get(i)); +// } + FileSystemView fsv = FileSystemView.getFileSystemView(); + final String deekPath = fsv.getHomeDirectory().getPath(); + System.out.println("桌面路径为==============="+deekPath); + JLabel path = new JLabel(" 导出路径"); + pathField = new JTextField(16); + pathField.setText(deekPath); + JButton selBtn = new JButton("选择"); + centerPanel.add("1.1.center.top", name); + + centerPanel.add("2.1.center.top", path); + centerPanel.add("2.2.center.top", pathField); + centerPanel.add("2.3.center.top", selBtn); + selBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JFileChooser choose = new JFileChooser(); + //choose.setCurrentDirectory(new File(deekPath)); + choose.setFileSelectionMode(1); + if (choose.showOpenDialog(null) != 1){ + pathField.setText(choose.getSelectedFile() + .getAbsolutePath()); + + + } + } + }); + + JButton okBtn = new JButton("确定"); + okBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + String path = pathField.getText(); + if("".equals(path)){ + disposeDialog(); + MessageBox.post("未选择导出路径!!","提示",MessageBox.INFORMATION); + return; + } + SimpleDateFormat sf = new SimpleDateFormat("yyyyMMDDHHmmss"); + String time = sf.format(new Date()); + pathRoute = pathField.getText()+"\\"+fielName+time+".xlsx"; + + + Dfl024Operation operation = new Dfl024Operation(app, prohectFolder,projextFolderName,pathRoute); + session.queueOperation(operation); + disposeDialog(); + } + }); + JButton celBtn = new JButton("取消"); + celBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + southPanel.add(okBtn); + southPanel.add(celBtn); + mainPanel.add(centerPanel, BorderLayout.CENTER); + mainPanel.add(southPanel,BorderLayout.SOUTH); + this.add(mainPanel,BorderLayout.CENTER); + this.centerToScreen(); + this.showDialog(); + + } + + + + + +} diff --git a/src/com/connor/dfl/plm/dfl024/Dfl024Handler.java b/src/com/connor/dfl/plm/dfl024/Dfl024Handler.java new file mode 100644 index 0000000..0979095 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl024/Dfl024Handler.java @@ -0,0 +1,45 @@ +package com.connor.dfl.plm.dfl024; + +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.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.util.MessageBox; +/** + * 功能名:Wf022Handler + * 功能描述: 项目点检(阶段) + * 创建日期:2019-03-08 + * 程序员 王辰 + * + * 修改日期 修改人 修改描述 + * 2019-01-24 XXXX 创建程序 + */ +public class Dfl024Handler extends AbstractHandler{ + private AbstractAIFUIApplication app; + private InterfaceAIFComponent target; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + this.target = app.getTargetComponent(); + TCComponentFolder projectFolder = null; + if(target != null){ + if(target instanceof TCComponentFolder){ + projectFolder = (TCComponentFolder) target; + Dfl024Dialog dialog = new Dfl024Dialog(app, projectFolder); + new Thread(dialog).start(); + }else{ + MessageBox.post("选中的项目文件夹对象!", "提示", MessageBox.INFORMATION); + } + }else{ + MessageBox.post("没有选中对象!", "提示", MessageBox.INFORMATION); + } + return null; + } + +} diff --git a/src/com/connor/dfl/plm/dfl024/Dfl024Operation.java b/src/com/connor/dfl/plm/dfl024/Dfl024Operation.java new file mode 100644 index 0000000..2bd3fae --- /dev/null +++ b/src/com/connor/dfl/plm/dfl024/Dfl024Operation.java @@ -0,0 +1,317 @@ +package com.connor.dfl.plm.dfl024; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; + + + +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.dfl.plm.util.ProgressBarThread; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.tcservices.TcApplicationService; +import com.teamcenter.rac.util.MessageBox; + +public class Dfl024Operation extends AbstractAIFOperation{ + private AbstractAIFUIApplication app; + private AIFComponentContext[] childs; + private String name; + private TCSession session; + private ProgressBarThread wait; + private String pathRoute; + private XSSFSheet sheet ; + private final static long aDay = 1000 * 60 * 60 * 24; + private String[] setProp; + private SimpleDateFormat format; + private XSSFCellStyle cellStyle; + private short height = 0; + private List compList; + private int col =0; + private int myrol =4; + + private int lastColValue= 0; + + private int lastcol= 0 ; + private int dirs = 5;//定义的变量用于存放统计出来的目录数量和文件数量 + + + private TCComponentFolder folder; + + + public Dfl024Operation(AbstractAIFUIApplication app, + TCComponentFolder folder,String name,String pathRoute) { + super(); + this.app = app; + this.childs = childs; + this.name = name; + this.folder =folder; + //this.wait = null; + this.session = (TCSession) app.getSession(); + this.pathRoute = pathRoute; + this.sheet = null; + this.format = new SimpleDateFormat("yy-MM-dd hh:mm"); + this.cellStyle = null; + this.compList = new ArrayList(); + } + + @Override + public void executeOperation() throws Exception { + wait = new ProgressBarThread("导出点检表", "执行中,请稍等..."); + wait.start(); + writeToExcel(); + } + /** + * 写入到excel报表中 + */ + + private void writeToExcel(){ + FileInputStream fis=null; + FileOutputStream fos=null; + String puid = session.getPreferenceService().getStringValue( + "DFL_Check_Deliverable_puid"); + if (puid == null||puid.equals("")) { + + MessageBox.post("首选项DFL_Check_Deliverable_puid未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + } + try { + TCComponentDataset excelData = (TCComponentDataset) session.stringToComponent(puid); + File file=((TCComponentDataset)excelData).getTcFiles()[0].getFmsFile(); + + fis = new FileInputStream(file); + System.out.println("fis:"+fis); + XSSFWorkbook workbook = new XSSFWorkbook(fis); + + System.out.println("workBook:"+workbook); + sheet = workbook.getSheetAt(0); + XSSFRow targetRow = sheet.getRow(4); + // height = targetRow.getHeight(); + + XSSFCell targetCell = null; + if(targetRow.getCell(0) == null) { + targetRow.createCell(0); + + }else { + targetCell = targetRow.getCell(0); + + cellStyle = targetCell.getCellStyle(); + } + + + if (sheet == null) { + MessageBox.post("sheet不存在", "", 2); + return; + } + System.out.println("sheet:"+sheet); + if(name == null || name == ""){ + MessageBox.post("项目文件夹名称为空!!!","提示",MessageBox.INFORMATION); + }else{ + + XSSFRow firstrow = sheet.getRow(myrol); + + if(firstrow == null){ + firstrow = sheet.createRow(myrol); + } + XSSFCell cell = firstrow.getCell(col); + if(cell == null){ + cell = firstrow.createCell(col); + cell.setCellStyle(cellStyle); + } + + + cell.setCellValue(folder.getStringProperty("object_name")); + + + myrol = 5 ; + col = 1; + + int col2 = 1; + getLastColValue(folder,col2); + lastcol = lastColValue; + + System.out.println("=========lastcol" + lastcol); + compList.add(folder); + tree( folder, col , sheet,firstrow); + //调用方法 + int line = 6; + int row = 4; + System.out.println("compList.size()================"+compList.size()); + for (int i = 0; i < compList.size(); i++) { + TCComponentFolder targetFolder = compList.get(i); + AIFComponentContext[] chlidrens = targetFolder.getChildren(); + if(chlidrens != null && chlidrens.length > 0) { + for (int j = 0; j < chlidrens.length; j++) { + TCComponent comp = (TCComponent) chlidrens[j].getComponent(); + if(!(comp instanceof TCComponentFolder)) { + TCProperty prop = comp.getTCProperty("item_id"); + String id = ""; + if(prop != null) { + id = prop.getStringValue(); + } + + String name = comp.getStringProperty("object_name"); + StringBuilder sb = new StringBuilder(); + if(!("".equals(id))) { + sb.append(id); + sb.append("-"); + } + sb.append(name); + String idName = sb.toString(); + System.out.println("idName==================="+idName); + XSSFRow rowNum = sheet.getRow(row); + if(rowNum == null) { + rowNum = sheet.createRow(row); + } + XSSFCell cellNum = rowNum.getCell(line); + if(cellNum == null) { + cellNum = rowNum.createCell(line); + } + cellNum.setCellStyle(cellStyle); + cellNum.setCellValue(idName); + line++; + + } + } + } + + row++; + } + } + + + wait.setBool(true); + wait.interrupt(); + fos = new FileOutputStream(new File(pathRoute)); + workbook.write(fos); + Runtime.getRuntime().exec((new StringBuilder("cmd /c \"")).append(pathRoute).append("\"").toString()); + + + + + } catch (Exception e1) { + e1.printStackTrace(); + System.out.println("============================导出失败"); + MessageBox.post("导出失败","",2); + return; + }finally{ + try { + + + if(fis!=null) + fis.close(); + if(fos!=null) + fos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + } + + + public void tree(TCComponentFolder folder, int level, XSSFSheet sheet,XSSFRow row_d) throws TCException { + AIFComponentContext[] childs = folder.getChildren(); + for (int i = 0; i < childs.length; i++) { + TCComponent comp = (TCComponent) childs[i].getComponent(); + if(comp instanceof TCComponentFolder) { + TCComponentFolder folders = (TCComponentFolder) comp; + + XSSFRow row = sheet.getRow(dirs); + if(row == null){ + row = sheet.createRow(dirs); + } + XSSFCell cell = row.getCell(level); + if(cell == null){ + cell = row.createCell(level); + cell.setCellStyle(cellStyle); + } + + cell.setCellValue(folders.getStringProperty("object_name")); + + dirs++; + compList.add(folders); + if(getFolderType(folders)) { + tree(folders, level + 1 ,sheet,row); + } + } + // else { + // //XSSFRow row = sheet.getRow(dirs); + // if(row_d == null){ + // row_d = sheet.createRow(dirs); + // } + // XSSFCell cell = row_d.getCell(4+lastColValue++); + // if(cell == null){ + // cell = row_d.createCell(4+lastColValue++); + // cell.setCellStyle(cellStyle); + // } + // + // cell.setCellValue(comp.getStringProperty("item_id")+"-"+comp.getStringProperty("object_name")); + // + // } + } + lastColValue = lastcol; + } + + + + + + + + public void getLastColValue(TCComponentFolder folder, int level) throws TCException { + AIFComponentContext[] childs = folder.getChildren(); + for (int i = 0; i < childs.length; i++) { + TCComponent comp = (TCComponent) childs[i].getComponent(); + if(comp instanceof TCComponentFolder) { + TCComponentFolder folders = (TCComponentFolder) comp; + if(getFolderType(folders)) { + lastColValue = level + 1; + getLastColValue(folders,lastColValue); + } + } + } + + } + + + + public boolean getFolderType(TCComponentFolder folder) throws TCException { + boolean flag = false ; + AIFComponentContext[] contex = folder.getChildren(); + + for(int f = 0 ;f folder_values; + private List deliverable_values; + + + + + + public ProjectFolderBean() { + } + + + + public ProjectFolderBean(String project_folder_name, List folder_values, List deliverable_values) { + this.project_folder_name = project_folder_name; + this.folder_values = folder_values; + this.deliverable_values = deliverable_values; + } + + + + public String getProject_folder_name() { + return project_folder_name; + } + + + + public void setProject_folder_name(String project_folder_name) { + this.project_folder_name = project_folder_name; + } + + + + public List getFolder_values() { + return folder_values; + } + + + + public void setFolder_values(List folder_values) { + this.folder_values = folder_values; + } + + + + public List getDeliverable_values() { + return deliverable_values; + } + + + + public void setDeliverable_values(List deliverable_values) { + this.deliverable_values = deliverable_values; + } + + + + + +} diff --git a/src/com/connor/dfl/plm/dfl025/Dfl025Dialog.java b/src/com/connor/dfl/plm/dfl025/Dfl025Dialog.java new file mode 100644 index 0000000..f98c372 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl025/Dfl025Dialog.java @@ -0,0 +1,162 @@ +package com.connor.dfl.plm.dfl025; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.text.SimpleDateFormat; + +import java.util.Date; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; + +import com.connor.dfl.plm.util.DateChooser; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class Dfl025Dialog extends AbstractAIFDialog{ + private AbstractAIFUIApplication app; + private TCSession session; + private JTextField pathField ; + private JLabel latterTimeLable; + private JLabel EarlyTimeLable; + private JTextField latterTimeField ; + private JTextField EarlyTimeField ; + private JFileChooser jFileChooser; + private String lattertime = ""; + private String earlytime = ""; + public Dfl025Dialog(AbstractAIFUIApplication app) { + super(); + this.app = app; + this.session = (TCSession) app.getSession(); + } + public void run(){ + initUI(); + } + /** + * 主页面 + */ + private void initUI() { + this.setLayout(new BorderLayout()); + this.setTitle("导出系统方案报表"); + this.setPreferredSize(new Dimension(380, 200)); + this.setResizable(false); + FileSystemView fsv = FileSystemView.getFileSystemView(); + final String deskPath = fsv.getHomeDirectory().getPath(); + System.out.println("桌面路径为==============="+deskPath); + JPanel mainPanel = new JPanel(new BorderLayout()); + JPanel centerPanel = new JPanel(new PropertyLayout()); + JPanel southPanel = new JPanel(new FlowLayout()); + JLabel name = new JLabel(" "); + + latterTimeLable = new JLabel(" 创建时间晚于");//创建时间晚于 + EarlyTimeLable = new JLabel(" 创建时间早于");//创建 + + latterTimeField = new JTextField(15); + EarlyTimeField = new JTextField(15); + jFileChooser = new JFileChooser(); + this.jFileChooser.setCurrentDirectory(new File(deskPath));// 文件选择器的初始目录定为当前用户桌面 + this.jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + + + DateChooser dateChooser1 = DateChooser.getInstance("yyyy-M-d"); + + DateChooser dateChooser2 = DateChooser.getInstance("yyyy-M-d"); + + Date date = new Date(); + SimpleDateFormat df = new SimpleDateFormat("yyyy-M-d"); + String time = df.format(date); + + latterTimeField = new JTextField(time); + EarlyTimeField = new JTextField(time); + + dateChooser1.register(latterTimeField); + dateChooser2.register(EarlyTimeField); + + + + + JLabel path = new JLabel(" 导出路径"); + pathField = new JTextField(15); + JButton selBtn = new JButton("选择"); + centerPanel.add("1.1.center.top", name); + centerPanel.add("4.1.center.top", path); + centerPanel.add("4.2.center.top", pathField); + centerPanel.add("4.3.center.top", selBtn); + + centerPanel.add("2.1.center.top", latterTimeLable); + centerPanel.add("2.2.center.top", latterTimeField); + centerPanel.add("3.1.center.top", EarlyTimeLable); + centerPanel.add("3.2.center.top", EarlyTimeField); + + selBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + selectFileButtonEvent(); + } + }); + + JButton okBtn = new JButton("确定"); + okBtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + okEvent(); + } + }); + JButton celBtn = new JButton("取消"); + celBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + southPanel.add(okBtn); + southPanel.add(celBtn); + mainPanel.add(centerPanel, BorderLayout.CENTER); + mainPanel.add(southPanel,BorderLayout.SOUTH); + this.add(mainPanel,BorderLayout.CENTER); + this.centerToScreen(); + this.showDialog(); + + } + public void okEvent() { + try { + String path = pathField.getText(); + if("".equals(path) || " ".equals(path)) { + MessageBox.post("请选择要导出的路径!!", + "提示", MessageBox.INFORMATION); + return; + } + System.out.println("ok"); + lattertime = latterTimeField.getText()+" 00:00"; + earlytime = EarlyTimeField.getText()+" 00:00"; + Dfl025Operation operation = new Dfl025Operation(app,lattertime,earlytime,path); + session.queueOperation(operation); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + this.disposeDialog(); + this.dispose(); + } + public void selectFileButtonEvent() { + int state = jFileChooser.showOpenDialog(null);// 此句是打开文件选择器界面的触发语句 + if (state == 1) { + return; + } else { + File f = jFileChooser.getSelectedFile();// f为选择到的目录 + pathField.setText(f.getAbsolutePath()); + } + } +} diff --git a/src/com/connor/dfl/plm/dfl025/Dfl025Handler.java b/src/com/connor/dfl/plm/dfl025/Dfl025Handler.java new file mode 100644 index 0000000..cc6de7c --- /dev/null +++ b/src/com/connor/dfl/plm/dfl025/Dfl025Handler.java @@ -0,0 +1,45 @@ +package com.connor.dfl.plm.dfl025; + +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.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.util.MessageBox; +/** + * 功能名:Wf022Handler + * 功能描述: 项目点检(阶段) + * 创建日期:2019-03-08 + * 程序员 王辰 + * + * 修改日期 修改人 修改描述 + * 2019-01-24 XXXX 创建程序 + */ +public class Dfl025Handler extends AbstractHandler{ + private AbstractAIFUIApplication app; + private InterfaceAIFComponent target; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); +// this.target = app.getTargetComponent(); +// TCComponentFolder projectFolder = null; +// if(target != null){ +// if(target instanceof TCComponentFolder){ +// projectFolder = (TCComponentFolder) target; + Dfl025Dialog dialog = new Dfl025Dialog(app); + new Thread(dialog).start(); +// }else{ +// MessageBox.post("选中的项目文件夹对象!", "提示", MessageBox.INFORMATION); +// } +// }else{ +// MessageBox.post("没有选中对象!", "提示", MessageBox.INFORMATION); +// } + return null; + } + +} diff --git a/src/com/connor/dfl/plm/dfl025/Dfl025Operation.java b/src/com/connor/dfl/plm/dfl025/Dfl025Operation.java new file mode 100644 index 0000000..6e927e5 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl025/Dfl025Operation.java @@ -0,0 +1,335 @@ +package com.connor.dfl.plm.dfl025; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JComboBox; + +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.dfl.plm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentFormType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemRevisionType; +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.util.MessageBox; +import com.teamcenter.soa.client.model.Property; + +public class Dfl025Operation extends AbstractAIFOperation{ + private AbstractAIFUIApplication app; + private TCSession session; + private ProgressBarThread wait; + private String pathRoute; + private String lattetTime; + private String EarlyTime; + + /** + * + * @param app + * @param lattetTime + * @param EarlyTime + * @param pathRoute + */ + public Dfl025Operation(AbstractAIFUIApplication app,String lattetTime,String EarlyTime,String pathRoute) { + super(); + this.app = app; + this.lattetTime = lattetTime; + this.EarlyTime = EarlyTime; + //this.wait = null; + this.session = (TCSession) app.getSession(); + this.pathRoute = pathRoute; + } + + @Override + public void executeOperation() throws Exception { + System.out.println("开始获取系统方案模板"); + String puid = session.getPreferenceService().getStringValue("DFL_SystemScheme_puid"); + System.out.println("puid======================"+puid); + if (puid == null||"".equals(puid)) { + MessageBox.post("首选项DFL_SystemScheme_puid未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + } + TCComponentDataset excel = (TCComponentDataset) session.stringToComponent(puid); + File file = ((TCComponentDataset)excel).getTcFiles()[0].getFmsFile(); + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");// 设置日期格式 + String time = df.format(new Date()); + String[] keys = new String[] {"创建时间晚于","创建时间早于"}; + String[] values = new String[] {lattetTime,EarlyTime}; + List compList = queryObject("查找系统方案", keys, values); + if(compList == null || compList.size() <= 0) { + MessageBox.post("您选择的时间段没有找到对应的系统方案!!!", + "提醒", MessageBox.INFORMATION); + return; + } + pathRoute = pathRoute + File.separator + "系统方案记录汇总表" + time + ".xlsx"; + wait = new ProgressBarThread("导出汇总表", "执行中,请稍等..."); + wait.start();// 开启进度条 + try { + writeToExcel(compList,file,pathRoute); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + MessageBox.post("生成报表失败"+e.getMessage(),"错误",MessageBox.ERROR); + return; + } + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + MessageBox.post("生成报表完成,请查看","完成",MessageBox.INFORMATION); + Runtime.getRuntime().exec("cmd /c \"" + pathRoute + "\""); + } + /** + * 写入到excel报表中 + * @throws Exception + */ + + private void writeToExcel(List compList,File file,String path) throws Exception{ + FileInputStream fis = new FileInputStream(file); + XSSFWorkbook workbook = new XSSFWorkbook(fis); + System.out.println("workBook:"+workbook); + XSSFSheet sheet = workbook.getSheetAt(0); + XSSFRow targetRow = sheet.getRow(4); + XSSFCell targetCell = targetRow.getCell(0); + XSSFCellStyle cellStyle = targetCell.getCellStyle(); + int o = 4; + for(int c= 0 ;c valueList = new ArrayList(); + //系统项目编号 + String systemProjectID = item.getStringProperty("item_id"); + valueList.add(systemProjectID); + //方案人员 + String schemenMan= form.getStringProperty("t2_Copywriter"); + valueList.add(schemenMan); + //合同号 + String contractNo= form.getStringProperty("t2_ContractNo"); + valueList.add(contractNo); + //用户名称 + String my_object_name = item.getStringProperty("object_name"); + valueList.add(my_object_name); + //项目性质 + String ProjectNature = form.getStringProperty("t2_ProjectNature"); + ProjectNature = getLovValue("t2_ProjectNature",ProjectNature); + valueList.add(ProjectNature); + //项目规模 + String ProjectScale = form.getStringProperty("t2_ProjectScale"); + ProjectScale = getLovValue("t2_ProjectScale",ProjectScale); + valueList.add(ProjectScale); + //供货范围 + String trait = form.getStringProperty("t2_trait"); + valueList.add(trait); + //适用对象 + String ApplicableObjects = form.getStringProperty("t2_ApplicableObjects"); + ApplicableObjects = getLovValue("t2_ApplicableObjects",ApplicableObjects); + valueList.add(ApplicableObjects); + //产品类别 + String ProductClass = form.getStringProperty("t2_ProductClass"); + ProductClass = getLovValue("t2_ProductClass",ProductClass); + valueList.add(ProductClass); + //项目生产药品名称 + String DrugNames = form.getStringProperty("t2_DrugNames"); + valueList.add(DrugNames); + //法规要求 + + TCProperty prop = form.getTCProperty("t2_RequiredByLaw01"); + String RequiredByLaw01 = ""; + String[] values = prop.getStringArrayValue(); + StringBuilder sb = new StringBuilder(); + if(values!= null && values.length > 0) { + for (int i = 0; i < values.length; i++) { + if(values[i] != null) { + sb.append(getLovValue("t2_RequiredByLaw01",values[i])); + if(i < values.length-1) { + sb.append(";"); + } + } + } + } + RequiredByLaw01 = sb.toString(); + valueList.add(RequiredByLaw01); + //国家 + String country = form.getStringProperty("t2_country"); + valueList.add(country); + //地区 + String area = form.getStringProperty("t2_area"); + valueList.add(area); + //"冻干机数量" + String LyophilizerNumber = form.getStringProperty("t2_LyophilizerNumber"); + LyophilizerNumber = getLovValue("t2_LyophilizerNumber",LyophilizerNumber); + valueList.add(LyophilizerNumber); + //冻干机型号 + String LyophilizerType = form.getStringProperty("t2_LyophilizerType"); + valueList.add(LyophilizerType); + //制冷方式 + String RefrigeratingMethod = form.getStringProperty("t2_RefrigeratingMethod"); + valueList.add(RefrigeratingMethod); + //制冷系统特殊点 + String RefrigerationRemark = form.getStringProperty("t2_RefrigerationRemark"); + valueList.add(RefrigerationRemark); + //箱体进料门 + String FeedTheDoor = form.getStringProperty("t2_FeedTheDoor"); + valueList.add(FeedTheDoor); + //箱体侧门 + String SideDoor = form.getStringProperty("t2_SideDoor"); + valueList.add(SideDoor); + //箱体底回风 + String BottomReturnAir = form.getStringProperty("t2_BottomReturnAir"); + BottomReturnAir = getLovValue("t2_BottomReturnAir",BottomReturnAir); + valueList.add(BottomReturnAir); + //箱体特殊点 + String BOXRemark = form.getStringProperty("t2_BOXRemark"); + valueList.add(BOXRemark); + //板层尺寸(D*W*H) + String DWH = form.getStringProperty("t2_DWH"); + valueList.add(DWH); + //板层数量 + String SlashNo = form.getStringProperty("t2_SlashNo"); + valueList.add(SlashNo); + //板层类型 + String SlashType = form.getStringProperty("t2_SlashType"); + SlashType = getLovValue("t2_SlashType",SlashType); + valueList.add(SlashType); + //板层特殊点 + String SlashRemark = form.getStringProperty("t2_SlashRemark"); + valueList.add(SlashRemark); + //进出料模式 + String materials = form.getStringProperty("t2_materials"); + materials = getLovValue("t2_materials",materials); + valueList.add(materials); + //进出料特殊点 + String MaterialsRemark = form.getStringProperty("t2_MaterialsRemark"); + valueList.add(MaterialsRemark); + //隔离方式 + String IsolationMethod = form.getStringProperty("t2_IsolationMethod"); + IsolationMethod = getLovValue("t2_IsolationMethod",IsolationMethod); + valueList.add(IsolationMethod); + //灌装机品牌 + String FillingMachine = form.getStringProperty("t2_FillingMachine"); + valueList.add(FillingMachine); + //轧盖机品牌 + String RollingMachine = form.getStringProperty("t2_RollingMachine"); + valueList.add(RollingMachine); + //西林瓶规格-粉针 + String BoosterInjection = form.getStringProperty("t2_BoosterInjection"); + valueList.add(BoosterInjection); + //西林瓶规格-水针 + String SquirtCut = form.getStringProperty("t2_SquirtCut"); + valueList.add(SquirtCut); + //"西林瓶速度(vpm)(灌装;轧盖) + String VPM = form.getStringProperty("t2_VPM"); + valueList.add(VPM); + //"Tofflon其他设备" + String Other = form.getStringProperty("t2_Other"); + valueList.add(Other); + //项目备注 + String Remark = form.getStringProperty("t2_Remark"); + valueList.add(Remark); + for (int i = 0; i < valueList.size(); i++) { + XSSFRow row = sheet.getRow(o); + if(row == null){ + row = sheet.createRow(o); + } + XSSFCell excelCell = row.getCell(i); + if(excelCell == null){ + excelCell = row.createCell(i); + } + excelCell.setCellStyle(cellStyle); + excelCell.setCellValue(valueList.get(i)); + } + o++; + } + FileOutputStream output = new FileOutputStream(new File(path)); + workbook.write(output); + output.close(); + fis.close(); + + } + + + + + /** + * 通过查询构建器查询项目对象 + * + * @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; + } + } + private String getLovValue(String attrType,String realValue) { + String value = ""; + System.out.println("attrType================="+attrType); + System.out.println("realValue================="+realValue); + if(realValue != null) { + try { + TCComponentFormType tccFormType = (TCComponentFormType)session.getTypeComponent("T2_SystemSchemeRevisionMaster"); + TCComponentListOfValues lov1 = tccFormType.getFormPropertyDescriptor(attrType).getLOV(); + if(lov1!=null){ + String[] strs1=lov1.getListOfValues().getStringListOfValues();//所有真实值 + for(String s1:strs1){ + if(realValue.equals(s1)) { + value = lov1.getListOfValues().getDisplayableValue(s1);//该真实值对应的显示值 + break; + } + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }else { + return value; + } + + return value; + } + +} diff --git a/src/com/connor/dfl/plm/dfl026/Dfl026Handler.java b/src/com/connor/dfl/plm/dfl026/Dfl026Handler.java new file mode 100644 index 0000000..1fcafb1 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl026/Dfl026Handler.java @@ -0,0 +1,38 @@ +package com.connor.dfl.plm.dfl026; + +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.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +/** + * 功能名:Wf022Handler + * 功能描述: 项目点检(阶段) + * 创建日期:2019-03-08 + * 程序员 王辰 + * + * 修改日期 修改人 修改描述 + * 2019-01-24 XXXX 创建程序 + */ +public class Dfl026Handler extends AbstractHandler{ + private AbstractAIFUIApplication app; + private InterfaceAIFComponent target; + private TCSession session; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + this.session = (TCSession) app.getSession(); + this.target = app.getTargetComponent(); + Dfl026Operation operation = new Dfl026Operation(target,session); + session.queueOperation(operation); + return null; + } + +} diff --git a/src/com/connor/dfl/plm/dfl026/Dfl026Operation.java b/src/com/connor/dfl/plm/dfl026/Dfl026Operation.java new file mode 100644 index 0000000..816564c --- /dev/null +++ b/src/com/connor/dfl/plm/dfl026/Dfl026Operation.java @@ -0,0 +1,131 @@ +package com.connor.dfl.plm.dfl026; + +import java.io.File; +import java.io.FileInputStream; +import java.util.Arrays; +import java.util.List; + +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +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.TCUserService; +import com.teamcenter.rac.util.MessageBox; + + +public class Dfl026Operation extends AbstractAIFOperation{ + private InterfaceAIFComponent target; + private TCSession session; + + /** + * + * @param app + * @param lattetTime + * @param EarlyTime + * @param pathRoute + */ + public Dfl026Operation(InterfaceAIFComponent target,TCSession session) { + super(); + this.target = target; + this.session = session; + + } + + @Override + public void executeOperation() throws Exception { + String puid = session.getPreferenceService().getStringValue("DFL_batchReleased_puid"); + System.out.println("puid======================"+puid); + if (puid == null||"".equals(puid)) { + MessageBox.post("首选项DFL_batchReleased_puid未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + } + TCComponentDataset excel = (TCComponentDataset) session.stringToComponent(puid); + File file = ((TCComponentDataset)excel).getTcFiles()[0].getFmsFile(); + FileInputStream fis = new FileInputStream(file); + XSSFWorkbook workbook = new XSSFWorkbook(fis); + System.out.println("workBook:"+workbook); + XSSFSheet sheet = workbook.getSheetAt(0); + int rowNum = sheet.getLastRowNum(); + System.out.println("总行数为=================="+rowNum); + for (int i = 1; i < rowNum+1; i++) { + XSSFRow row = sheet.getRow(i); + XSSFCell cell = row.getCell(1); + String id = cell.getStringCellValue(); + String[] keys = new String[] {"零组件 ID"}; + String[] values = new String[] {id}; + List compList = queryObject("零组件 ID", keys, values); + if(compList == null || compList.size() <= 0) { + MessageBox.post("品号"+id+"未在系统中找到对应的对象!!!", + "提醒", MessageBox.INFORMATION); + return; + }else { + TCComponent comp = compList.get(0); + if(comp instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) comp; + TCComponentItemRevision rev = item.getLatestItemRevision(); + setReleaseStatus(rev,"TCM Released"); + TCComponent[] dataset = rev.getReferenceListProperty("IMAN_specification"); + for (int j = 0; j < dataset.length; j++) { + setReleaseStatus(dataset[j],"TCM Released"); + } + TCComponent[] dataset1 = rev.getReferenceListProperty("IMAN_Rendering"); + for (int j = 0; j < dataset1.length; j++) { + setReleaseStatus(dataset1[j],"TCM Released"); + } + } + } + } + } + public void setReleaseStatus(TCComponent item, String statusName) + throws TCException { + TCUserService userservice = session.getUserService(); + + Object[] obj = new Object[2]; + obj[0] = item; + obj[1] = statusName; + userservice.call("connor_set_release_status", obj); + + } + /** + * 通过查询构建器查询项目对象 + * + * @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/dfl/plm/dfl027/ChangeOwnerbean.java b/src/com/connor/dfl/plm/dfl027/ChangeOwnerbean.java new file mode 100644 index 0000000..6c8c4e2 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl027/ChangeOwnerbean.java @@ -0,0 +1,71 @@ +package com.connor.dfl.plm.dfl027; + +import javax.swing.JTextField; + +public class ChangeOwnerbean { + + private String id;//品号 + private String customerName;//品名 + private String spec;//规格 + private String zhangt;//账套 + private String cangk;//仓库 + private String cangkName; //仓库名称 + private String num;//结余呆滞数量 + private String unit;//库存单位 + private String location;//存储位置 + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getCustomerName() { + return customerName; + } + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + public String getSpec() { + return spec; + } + public void setSpec(String spec) { + this.spec = spec; + } + public String getZhangt() { + return zhangt; + } + public void setZhangt(String zhangt) { + this.zhangt = zhangt; + } + public String getCangk() { + return cangk; + } + public void setCangk(String cangk) { + this.cangk = cangk; + } + public String getNum() { + return num; + } + public void setNum(String num) { + this.num = num; + } + public String getUnit() { + return unit; + } + public void setUnit(String unit) { + this.unit = unit; + } + public String getLocation() { + return location; + } + public void setLocation(String location) { + this.location = location; + } + public String getCangkName() { + return cangkName; + } + public void setCangkName(String cangkName) { + this.cangkName = cangkName; + } + +} diff --git a/src/com/connor/dfl/plm/dfl027/Dfl027Action.java b/src/com/connor/dfl/plm/dfl027/Dfl027Action.java new file mode 100644 index 0000000..97f2050 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl027/Dfl027Action.java @@ -0,0 +1,24 @@ +package com.connor.dfl.plm.dfl027; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +public class Dfl027Action extends AbstractAIFAction { + + private AbstractAIFUIApplication app; + + public Dfl027Action(AbstractAIFUIApplication app, String string) { + super(app,string); + this.app=app; + } + + @Override + public void run() { + try { + new Dfl027Command(app).executeModal(); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/dfl/plm/dfl027/Dfl027Command.java b/src/com/connor/dfl/plm/dfl027/Dfl027Command.java new file mode 100644 index 0000000..07bd8c6 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl027/Dfl027Command.java @@ -0,0 +1,20 @@ +package com.connor.dfl.plm.dfl027; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCSession; + +public class Dfl027Command extends AbstractAIFCommand { + + private TCSession session; + + public Dfl027Command(AbstractAIFUIApplication app) { + this.session=(TCSession)app.getSession(); + } + + @Override + public void executeModal() throws Exception { + new Thread(new Dfl027Dialog(session)).start(); + } + +} diff --git a/src/com/connor/dfl/plm/dfl027/Dfl027Dialog.java b/src/com/connor/dfl/plm/dfl027/Dfl027Dialog.java new file mode 100644 index 0000000..c6cad4d --- /dev/null +++ b/src/com/connor/dfl/plm/dfl027/Dfl027Dialog.java @@ -0,0 +1,534 @@ +package com.connor.dfl.plm.dfl027; + +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.MouseAdapter; +import java.awt.event.MouseEvent; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; +import java.util.MissingResourceException; + +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.JTextArea; +import javax.swing.JTextField; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableRowSorter; + +import com.connor.dfl.plm.util.DataBaseControl; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.commands.open.OpenCommand; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Registry; + +public class Dfl027Dialog extends AbstractAIFDialog { + + private static final long serialVersionUID = 6130114042631785757L; + private static final int width=800; + DefaultTableModel model; + private TCSession session; +// private JButton qryBtn; + private JButton qryBtn2; + private JButton beforeBtn; + private JButton nextBtn; + private int page = 15; + private double pages = 1; + private JTextField idField; + private JTextField page1; + private JTextField page2; + private JTextField nameField; + private JTextField specField; + private JTextField cangKField; +// private JTextField addNumField; +// private JTextField subtractNumField; +// private JComboBox cangKBox; + private StringBuilder sb = new StringBuilder("select CENTER,TC_IMF01,IMA02,IMA021,IMA25,TC_IMF02,IMD02,TC_IMF03,TA_IMF01,rownum AS rowno from allinactive where "); + private StringBuilder numsSb = new StringBuilder("select count(*) from allinactive where "); + private String sql2 = ""; + private JComboBox zhangTBox; + private String[] columnNames = {"账套","品号","品名","规格","库存单位","仓库","仓库名称","呆滞数量","存储位置"}; + private JTable qryTable; + private Object[][] beans; + private TCPreferenceService service; + private DataBaseControl data; + public Dfl027Dialog(TCSession session) { + super(false); + this.session=session; + this.service = session.getPreferenceService(); + this.data = new DataBaseControl(session,"DFL2_ERP_SQL_Connect"); + } + /** + * 刷新table显示和设置宽度 + */ + private void refreshTable() { + qryTable.removeAll(); + model.setDataVector(beans, columnNames); + //qryTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); + qryTable.getColumnModel().getColumn(0).setPreferredWidth(30); + qryTable.getColumnModel().getColumn(1).setPreferredWidth(80); + qryTable.getColumnModel().getColumn(2).setPreferredWidth(80); + qryTable.getColumnModel().getColumn(3).setPreferredWidth(110); + qryTable.getColumnModel().getColumn(4).setPreferredWidth(30); + qryTable.getColumnModel().getColumn(5).setPreferredWidth(30); + qryTable.getColumnModel().getColumn(6).setPreferredWidth(80); + qryTable.getColumnModel().getColumn(7).setPreferredWidth(30); + qryTable.getColumnModel().getColumn(8).setPreferredWidth(60); + + } + + @Override + public void run() { + //显示窗口 + initUI(); + //启用查询按钮 +// qryBtn.setEnabled(true); + } + + + + @SuppressWarnings("serial") + private void initUI() { + this.setTitle("呆滞品库存信息表"); + this.setLayout(new FlowLayout(FlowLayout.CENTER,2,3)); + this.setPreferredSize(new Dimension(width, 550)); + this.setLocation(2, 5); + //Object[][] cellData = getRecords("*"); + model = new DefaultTableModel() { + private static final long serialVersionUID = 6905817304437097181L; + public boolean isCellEditable(int row, int column) { + return true; + } + }; + + 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; + } + }; +// qryTable.addMouseListener(new MouseAdapter() { +// int tableRow = -1; +// +// public void mouseClicked(MouseEvent e){ +// if(e.getButton() == MouseEvent.BUTTON3){ +// // tableRow = qryTable.rowAtPoint(e.getPoint()); +// tableRow = qryTable.getSelectedRow(); +// qryTable.setRowSelectionInterval(tableRow, tableRow); +// int indexRow = qryTable.convertRowIndexToModel(tableRow); +// System.out.println("indexRow=============="+indexRow); +// if(tableRow >= 0){ +// System.out.println("1111111111111111111"); +// createPopupMenu(indexRow); +// +// } +// } +// } +// }); + 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 qryPanel=new JPanel(new PropertyLayout()); + + JLabel idLabel=new JLabel("品号:"); + idField = new JTextField(10); +// qryBtn=new JButton("查询"); + + JLabel cangKLabel=new JLabel(" 仓库编号:"); + cangKField = new JTextField(6); +// cangKBox = new JComboBox(); + JLabel zhangTLabel=new JLabel(" 账套:"); + zhangTBox = new JComboBox(); + //cangKBox.addItem(" "); + zhangTBox.addItem(" "); +// String[] cangks = service.getStringValues("DFL_cangK_Num"); +// if(cangks == null || cangks.length <= 0) { +// MessageBox.post("首选项DFL_cangK_Num未配置,请联系管理员!!!", "错误", +// MessageBox.ERROR); +// return; +// } + page1 = new JTextField(1); + page2 = new JTextField(1); + JLabel nameLabel=new JLabel("品名:"); + nameField = new JTextField(10); + JLabel specLabel=new JLabel("规格:"); + specField = new JTextField(10); + + String[] zhangts = service.getStringValues("DFL_zhangtao"); + if(zhangts == null || zhangts.length <= 0) { + MessageBox.post("首选项DFL_zhangtao未配置,请联系管理员!!!", "错误", + MessageBox.ERROR); + return; + } +// for (int i = 0; i < cangks.length; i++) { +// cangKBox.addItem(cangks[i]); +// } + for (int i = 0; i < zhangts.length; i++) { + zhangTBox.addItem(zhangts[i].split("=")[1]); + } + qryBtn2=new JButton("查询"); + beforeBtn=new JButton("上一页"); + nextBtn=new JButton("下一页"); +// JLabel addNum=new JLabel(" 数量增加:"); +// addNumField = new JTextField(4); +// JLabel subtractNum=new JLabel(" 数量减少:"); +// subtractNumField = new JTextField(4); + qryPanel.add("1.1.center.top",idLabel); + qryPanel.add("1.2.center.top",idField); +// qryPanel.add("1.1.center.top",qryBtn); + qryPanel.add("1.3.center.top",cangKLabel); +// qryPanel.add("1.2.center.top",cangKBox); + qryPanel.add("1.4.center.top",cangKField); + qryPanel.add("1.5.center.top",zhangTLabel); + qryPanel.add("1.6.center.top",zhangTBox); + qryPanel.add("2.1.center.top",nameLabel); + qryPanel.add("2.2.center.top",nameField); + qryPanel.add("2.3.center.top",specLabel); + qryPanel.add("2.4.center.top",specField); + qryPanel.add("2.5.center.top",new JLabel(" ")); + qryPanel.add("2.6.center.top",qryBtn2); +// qryPanel.add("1.7.center.top",qryBtn2); +// qryPanel.add("2.1.center.top",addNum); +// qryPanel.add("2.2.center.top",addNumField); +// qryPanel.add("2.3.center.top",subtractNum); +// qryPanel.add("2.4.center.top",subtractNumField); + JPanel southPanel = new JPanel(new FlowLayout()); + //JButton okBtn = new JButton("确定"); + //okBtn.addActionListener(new ActionListener() { + + //public void actionPerformed(ActionEvent e) { +// int rows = qryTable.getRowCount(); +// if(rows <= 0) { +// MessageBox.post("请先查询相关数据信息再进行修改!!", +// "提示", MessageBox.INFORMATION); +// return ; +// } +// for (int i = 0; i < rows; i++) { +// //String id = idField.getText(); +// String id = (String) qryTable.getModel().getValueAt(i,0); +// String zhangT = (String) qryTable.getModel().getValueAt(i,3); +// String cangK = (String) qryTable.getModel().getValueAt(i,4); +// //String addNum = addNumField.getText(); +// //String subtractNum = subtractNumField.getText(); +// String addNum = (String) qryTable.getModel().getValueAt(i,8); +// String subtractNum = (String) qryTable.getModel().getValueAt(i,9); +// if("".equals(addNum.trim()) && "".equals(subtractNum.trim())) { +// continue; +// } +// Object[] values = new Object[] {id,zhangT,cangK}; +// String newNum = ""; +// try { +// String num = data.getNum(values); +// if("".equals(cangK.trim())) { +// MessageBox.post("请先用仓库编号查询数据!!","提示", MessageBox.INFORMATION); +// return; +// }else { +// if(!("".equals(addNum.trim()))) { +// int num1 = Integer.parseInt(addNum); +// int oldNum = Integer.parseInt(num); +// newNum = (num1+oldNum)+""; +// }else if(!("".equals(subtractNum.trim()))){ +// int num1 = Integer.parseInt(subtractNum); +// int oldNum = Integer.parseInt(num); +// newNum = (oldNum-num1)+""; +// }else { +// MessageBox.post("修改的数量不能为空!!","错误", MessageBox.ERROR); +// return; +// } +// } +// String sql = "update DFL_OLD_ITEM set NUM= ? where ITEM_ID= ? and ZHANGTAO= ? and WAREHOUSE= ?"; +// data.dbModify2(sql, new Object[] { newNum, id, zhangT, cangK}); +// } catch (Exception e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// } +// beans = getRecords(sql2); +// if(beans!=null) { +// refreshTable(); +// } + //disposeDialog(); + // } + //}); + JButton celBtn = new JButton("取消"); + celBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + beforeBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + if(page > 15){ + page = page - 15; + } + page1.setText("" + page/15); + queryResult(); + } + }); + nextBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + //int rowNum = 0; + //if(page < rowNum) { + page = page + 15; + page1.setText("" + page/15); + //} + queryResult(); + } + }); +// southPanel.add(okBtn); + //southPanel.add(qryBtn2); + southPanel.add(celBtn); + JPanel rootPanel=new JPanel(new ButtonLayout()); + rootPanel.add("1.1.center.top",beforeBtn); + rootPanel.add("1.2.left.top",new JLabel(" 第")); + rootPanel.add("1.3.left.top",page1); + rootPanel.add("1.4.left.top",new JLabel("页")); + rootPanel.add("1.5.left.top",new JLabel("共")); + rootPanel.add("1.6.left.top",page2); + rootPanel.add("1.7.left.top",new JLabel("页")); + rootPanel.add("1.8.center.top",nextBtn); +// qryBtn.setEnabled(false); +// qryBtn.addActionListener(new ActionListener() { +// +// public void actionPerformed(ActionEvent e) { +// String id = idField.getText(); +// String sql = "select ITEM_ID,ITEM_NAME,SPEC,ZHANGTAO,WAREHOUSE,NUM,UNIT,LOCATION from DFL_OLD_ITEM where ITEM_ID= ?"; +// beans = getRecords(sql,id); +// if(beans!=null) { +// refreshTable(); +// } +// } +// }); + qryBtn2.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + page = 15; + page1.setText("1"); + queryResult(); + } + }); + this.add(qryPanel); + this.add(scrollPane); + this.add(rootPanel); + this.setResizable(false); + this.setAlwaysOnTop(false); + this.showDialog(); + } + + /** + * 查询项目信息获取记录 + * @return table的dataVector + */ + private Object[][] getRecords(String sql){ + //SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式 + List list = new ArrayList(); + + try { + list = data.getRecord(sql); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if(list == null || list.size() <= 0 ) { + MessageBox.post("数据库中未查找到相应的数据!!", + "错误", MessageBox.ERROR); + return null; + } + //封装结果集 + Object res[][] = new Object[list.size()][this.columnNames.length]; + int i=0; + for (ChangeOwnerbean record : list) { + res[i++]=new Object[] {record.getZhangt(),record.getId(),record.getCustomerName(), + record.getSpec(),record.getUnit(),record.getCangk(),record.getCangkName(),record.getNum(), + record.getLocation()}; + } + return res; + } + +// private Object[][] getRecords2(String sql,String cangK){ +// //SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式 +// List list = new ArrayList(); +// try { +// list = data.getRecord(cangK,sql); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// if(list == null || list.size() <= 0 ) { +// MessageBox.post("数据库中未查找到相应的数据!!", +// "错误", MessageBox.ERROR); +// return null; +// } +// //封装结果集 +// Object res[][] = new Object[list.size()][this.columnNames.length]; +// int i=0; +// for (ChangeOwnerbean record : list) { +// res[i++]=new Object[] {record.getId(),record.getCustomerName(), +// record.getSpec(),record.getZhangt(),record.getCangk(),record.getNum(),record.getUnit()}; +// } +// 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 void queryResult() { + String id = idField.getText(); + String cangK = cangKField.getText(); + String name = nameField.getText(); + String spec = specField.getText(); + String zhangT = (String) zhangTBox.getSelectedItem(); + if(!("".equals(zhangT.trim()))) { + zhangT = zhangT.split("\\.")[0]; + } + if("".equals(id.trim()) && "".equals(cangK.trim()) && "".equals(zhangT.trim()) + && "".equals(name.trim()) && "".equals(spec.trim())) { + MessageBox.post("请选择要查询的条件,至少有一个条件!!", + "提示", MessageBox.INFORMATION); + return ; + }else { + if(!("".equals(id.trim()))) { + sb.append("TC_IMF01 like '" + id + "%'"); + numsSb.append("TC_IMF01 like '" + id + "%'"); + } + if(!("".equals(cangK.trim()))) { + String sql2 = sb.toString(); + if(sql2.contains("like") ) { + sb.append(" and TC_IMF02 = '" + cangK +"'"); + numsSb.append(" and TC_IMF02 = '" + cangK +"'"); + }else { + sb.append(" TC_IMF02 = '" + cangK +"'"); + numsSb.append(" TC_IMF02 = '" + cangK +"'"); + } + } + if(!("".equals(zhangT.trim()))) { + String sql2 = sb.toString(); + if(sql2.contains("like") || sql2.contains("=")) { + sb.append(" and CENTER = '" + zhangT +"'"); + numsSb.append(" and CENTER = '" + zhangT +"'"); + }else { + sb.append(" CENTER = '" + zhangT +"'"); + numsSb.append(" CENTER = '" + zhangT +"'"); + } + } + if(!("".equals(name.trim()))) { + String sql2 = sb.toString(); + if(sql2.contains("like") || sql2.contains("=")) { + sb.append(" and IMA02 like '%" + name +"%'"); + numsSb.append(" and IMA02 like '%" + name +"%'"); + }else { + sb.append(" IMA02 like '%" + name +"%'"); + numsSb.append(" IMA02 like '%" + name +"%'"); + } + } + if(!("".equals(spec.trim()))) { + String sql2 = sb.toString(); + if(sql2.contains("like") || sql2.contains("=")) { + sb.append(" and IMA021 like '%" + spec +"%'"); + numsSb.append(" and IMA021 like '%" + spec +"%'"); + }else { + sb.append(" IMA021 like '%" + spec +"%'"); + numsSb.append(" IMA021 like '%" + spec +"%'"); + } + } + sb.append("and rownum <="+(page-1)); + StringBuilder allSb = new StringBuilder("select CENTER,TC_IMF01,IMA02,IMA021,IMA25,TC_IMF02,IMD02,TC_IMF03,TA_IMF01,rownum from("); + //拼接字符串sb的值 + allSb.append(sb.toString()); + //拼接后面的sql语句 + allSb.append(") table_alias WHERE table_alias.rowno > "+(page - 15)); + //再转化为string格式 + sql2 = allSb.toString(); + System.out.println("sql===================="+sql2); + + beans = getRecords(sql2); + String numsSql = numsSb.toString(); + System.out.println("numsSql===================="+numsSql); + try { + double nums = data.getNums(numsSql); + System.out.println("nums==================="+nums); + pages = nums/15; + pages = Math.ceil(pages); + int allPage = (int) pages; + page2.setText(""+allPage); + System.out.println("allPage==================="+allPage); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if(beans!=null) { + refreshTable(); + } + sb = new StringBuilder("select CENTER,TC_IMF01,IMA02,IMA021,IMA25,TC_IMF02,IMD02,TC_IMF03,TA_IMF01,rownum AS rowno from allinactive where "); + numsSb = new StringBuilder("select count(*) from allinactive where "); + } + //添加右键菜单 +// private void createPopupMenu(final int row) { +// int column = 0; +// String selectedValue = (String) qryTable.getModel().getValueAt(row,column); +//// idField.setText(selectedValue); +// +// } +} diff --git a/src/com/connor/dfl/plm/dfl027/Dfl027Handler.java b/src/com/connor/dfl/plm/dfl027/Dfl027Handler.java new file mode 100644 index 0000000..dd1815c --- /dev/null +++ b/src/com/connor/dfl/plm/dfl027/Dfl027Handler.java @@ -0,0 +1,19 @@ +package com.connor.dfl.plm.dfl027; + +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 Dfl027Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + new Thread(new Dfl027Action(app,"")).start(); + return null; + } + +} diff --git a/src/com/connor/dfl/plm/dfl028/Dfl028AIFDialog.java b/src/com/connor/dfl/plm/dfl028/Dfl028AIFDialog.java new file mode 100644 index 0000000..250e3e7 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl028/Dfl028AIFDialog.java @@ -0,0 +1,367 @@ +package com.connor.dfl.plm.dfl028; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; + +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.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class Dfl028AIFDialog extends AbstractAIFDialog { + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent[] targets; + private JLabel jLabel; + private JTextField jtf = new JTextField(20); + private JButton jButton; + private JFileChooser jFileChooser; + private JButton okBut = new JButton("下载"); + private JButton celBut = new JButton("取消"); + private List fmsFilelist = new ArrayList<>(); + private List hzmlist = new ArrayList<>(); + private List namelist = new ArrayList<>(); + private FileInputStream fis; + private FileOutputStream fos; + private JPanel btnPanel1; + private String hzm; + + public Dfl028AIFDialog(AbstractAIFApplication arg0){ + this.app = arg0; + this.session = (TCSession)app.getSession(); + this.targets = app.getTargetComponents(); + + } + @Override + public void run() { + //显示窗口 + init(); + + + //启用查询按钮 +// qryBtn.setEnabled(true); + } + //获取下载文件列表 + private void getload(TCComponentDataset dataset){ + try { + TCComponentTcFile[] file = dataset.getTcFiles(); + if(file == null || file.length ==0){ + MessageBox.post("数据集没有命名引用的文件,请检查!", + "WARNING",MessageBox.WARNING); + return; + }else{ + for(int i=0;i list = new ArrayList(); + Component[] jcbs = btnPanel1.getComponents();//将勾选的内容存入数组 + for(Component component : jcbs) { + JCheckBox jcb = (JCheckBox) component; + if(jcb.isSelected()) { + list.add(jcb.getText()); + if("DWG".equals(jcb.getText())) { + list.add("DWG"); + list.add("dwg"); + }else if ("STP".equals(jcb.getText())) { + list.add("stp"); + }else if("PDF".equals(jcb.getText())) { + list.add("pdf"); + } + } + } + if(list.size() <= 0) { + list.add("DWG"); + list.add("dwg"); + list.add("pdf"); + list.add("stp"); + } + try { + for (int i = 0; i < targets.length; i++) { + if(targets[i] instanceof TCComponentBOMLine){ + TCComponentBOMLine line = (TCComponentBOMLine) targets[i]; + TCComponentItemRevision rev = line.getItemRevision(); + TCComponent[] datasets = rev.getReferenceListProperty("IMAN_specification"); + TCComponent[] datasets2 = rev.getReferenceListProperty("IMAN_Rendering"); + for (int j = 0; j < datasets.length; j++) { + //获取数据集数组 + TCComponentDataset dataset01 = (TCComponentDataset) datasets[j]; + //执行获取后缀名的方法 + gethzm(dataset01); + + System.out.println("9.07test后缀名"+hzm); + //如果list包含hzm字符串的值 + if(list.contains(hzm)) { + //获取数据集数据 + TCComponentDataset dataset02 = (TCComponentDataset) datasets[j]; + //执行getload方法 + getload(dataset02); + } + } + for (int j = 0; j < datasets2.length; j++) { + //获取数据集数组 + TCComponentDataset dataset02 = (TCComponentDataset) datasets[j]; + //执行获取后缀名的方法 + gethzm(dataset02); + String type2 = datasets2[j].getType(); + if(list.contains(hzm)) { + TCComponentDataset dataset = (TCComponentDataset) datasets2[j]; + getload(dataset); + } + } + } + else if(targets[i] instanceof TCComponentItemRevision){ + TCComponentItemRevision rev = (TCComponentItemRevision) targets[i]; + TCComponent[] datasets = rev.getReferenceListProperty("IMAN_specification"); + TCComponent[] datasets2 = rev.getReferenceListProperty("IMAN_Rendering"); + for (int j = 0; j < datasets.length; j++) { + //获取数据集数组 + TCComponentDataset dataset02 = (TCComponentDataset) datasets[j]; + //执行获取后缀名的方法 + gethzm(dataset02); + if(list.contains(hzm)) { + TCComponentDataset dataset = (TCComponentDataset) datasets[j]; + System.out.println("下载文件"); + getload(dataset); + } + } + for (int j = 0; j < datasets2.length; j++) { + //获取数据集数组 + TCComponentDataset dataset02 = (TCComponentDataset) datasets[j]; + //执行获取后缀名的方法 + gethzm(dataset02); + if(list.contains(hzm)) { + TCComponentDataset dataset = (TCComponentDataset) datasets2[j]; + getload(dataset); + } + } + }else if(targets[i] instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) targets[i]; + getload(dataset); + }else if(targets[i] instanceof TCComponentItem){ + TCComponentItem item = (TCComponentItem) targets[i]; + TCComponentItemRevision rev = item.getLatestItemRevision(); + TCComponent[] datasets = rev.getReferenceListProperty("IMAN_specification"); + TCComponent[] datasets2 = rev.getReferenceListProperty("IMAN_Rendering"); + for (int j = 0; j < datasets.length; j++) { + //获取数据集数组 + TCComponentDataset dataset02 = (TCComponentDataset) datasets[j]; + //执行获取后缀名的方法 + gethzm(dataset02); + if(list.contains(hzm)) { + TCComponentDataset dataset = (TCComponentDataset) datasets[j]; + getload(dataset); + } + } + for (int j = 0; j < datasets2.length; j++) { + //获取数据集数组 + TCComponentDataset dataset02 = (TCComponentDataset) datasets[j]; + //执行获取后缀名的方法 + gethzm(dataset02); + if(list.contains(hzm)) { + TCComponentDataset dataset = (TCComponentDataset) datasets2[j]; + getload(dataset); + } + } + }else { + MessageBox.post("选中的不是版本对象或者BOM行对象或者数据集对象","error",MessageBox.ERROR); + return; + } + } + } catch (Exception e) { + // TODO: handle exception + } + } + +} diff --git a/src/com/connor/dfl/plm/dfl028/Dfl028Handler.java b/src/com/connor/dfl/plm/dfl028/Dfl028Handler.java new file mode 100644 index 0000000..951b7dd --- /dev/null +++ b/src/com/connor/dfl/plm/dfl028/Dfl028Handler.java @@ -0,0 +1,21 @@ +package com.connor.dfl.plm.dfl028; + +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 Dfl028Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app=AIFUtility.getCurrentApplication(); + Dfl028AIFDialog dialog = new Dfl028AIFDialog(app); + new Thread(dialog).start(); + return null; + } + +} diff --git a/src/com/connor/dfl/plm/dfl029/Dfl029Handler.java b/src/com/connor/dfl/plm/dfl029/Dfl029Handler.java new file mode 100644 index 0000000..4e05a6a --- /dev/null +++ b/src/com/connor/dfl/plm/dfl029/Dfl029Handler.java @@ -0,0 +1,38 @@ +package com.connor.dfl.plm.dfl029; + +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.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +/** + * 功能名:Wf022Handler + * 功能描述: 项目点检(阶段) + * 创建日期:2019-03-08 + * 程序员 王辰 + * + * 修改日期 修改人 修改描述 + * 2019-01-24 XXXX 创建程序 + */ +public class Dfl029Handler extends AbstractHandler{ + private AbstractAIFUIApplication app; + private InterfaceAIFComponent target; + private TCSession session; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + this.session = (TCSession) app.getSession(); + this.target = app.getTargetComponent(); + Dfl029Operation operation = new Dfl029Operation(target,session); + session.queueOperation(operation); + return null; + } + +} diff --git a/src/com/connor/dfl/plm/dfl029/Dfl029Operation.java b/src/com/connor/dfl/plm/dfl029/Dfl029Operation.java new file mode 100644 index 0000000..aaf679e --- /dev/null +++ b/src/com/connor/dfl/plm/dfl029/Dfl029Operation.java @@ -0,0 +1,578 @@ +package com.connor.dfl.plm.dfl029; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.filechooser.FileSystemView; + +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.dfl.plm.dfl019.ClassPropBean; +import com.connor.dfl.plm.dfl019.ItemBean; +import com.connor.dfl.plm.dfl019.ParseXMLUtil; +import com.connor.dfl.plm.util.ClassValueBean; +import com.connor.dfl.plm.util.ClassValueUtil; +import com.connor.dfl.plm.util.ProgressBarThread; +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.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +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.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.ICSProperty; +import com.teamcenter.rac.util.MessageBox; + + +public class Dfl029Operation extends AbstractAIFOperation{ + private InterfaceAIFComponent target; + private TCSession session; + private List attrList; + private ProgressBarThread wait; + private String pathRoute; + private List errList = new ArrayList(); + /** + * + * @param app + * @param lattetTime + * @param EarlyTime + * @param pathRoute + */ + public Dfl029Operation(InterfaceAIFComponent target,TCSession session) { + super(); + this.target = target; + this.session = session; + FileSystemView fsv = FileSystemView.getFileSystemView(); + this.pathRoute = fsv.getHomeDirectory().getPath(); + + } + + @Override + public void executeOperation() throws Exception { + String puid = session.getPreferenceService().getStringValue("DFL_batchReleased_puid"); + System.out.println("puid======================"+puid); + if (puid == null||"".equals(puid)) { + MessageBox.post("首选项DFL_batchReleased_puid未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + } + String puid1 = session.getPreferenceService().getStringValue("DFL_SEND_PRO_TO_ERP"); + System.out.println("puid======================"+puid1); + if (puid1 == null||"".equals(puid1)) { + MessageBox.post("首选项DFL_SEND_PRO_TO_ERP未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + } +// ParseXMLUtil xml=new ParseXMLUtil(); +// File xmlFile=xml.getSXX("DFL_CLASS_Xml", session); +// attrList =xml.parseXMLCode(xmlFile); +// if(attrList == null || attrList.size() <= 0) { +// MessageBox.post("首选项DFL_CLASS_Xml未配置,请检查!", "WARNING", +// MessageBox.WARNING); +// return; +// } + TCComponentDataset excel = (TCComponentDataset) session.stringToComponent(puid); + File file = ((TCComponentDataset)excel).getTcFiles()[0].getFmsFile(); + FileInputStream fis = new FileInputStream(file); + XSSFWorkbook workbook = new XSSFWorkbook(fis); + System.out.println("workBook:"+workbook); + XSSFSheet sheet = workbook.getSheetAt(0); + int rowNum = sheet.getLastRowNum(); + System.out.println("总行数为=================="+rowNum); + List beanList = new ArrayList(); + for (int i = 1; i < rowNum+1; i++) { + XSSFRow row = sheet.getRow(i); + XSSFCell cell = row.getCell(1); + String id = cell.getStringCellValue(); + String[] keys = new String[] {"零组件 ID"}; + String[] values = new String[] {id}; + List compList = queryObject("零组件 ID", keys, values); + if(compList == null || compList.size() <= 0) { + MessageBox.post("品号"+id+"未在系统中找到对应的对象!!!", + "提醒", MessageBox.INFORMATION); + return; + }else { + TCComponent comp = compList.get(0); + if(comp instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) comp; + TCComponentItemRevision rev = item.getLatestItemRevision(); + Boolean flag = getItemValue(rev,beanList); + if(flag) { + return; + } + } + } + } + TCComponentDataset excel1 = (TCComponentDataset) session.stringToComponent(puid1); + File file1 = ((TCComponentDataset)excel1).getTcFiles()[0].getFmsFile(); + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");// 设置日期格式 + String time = df.format(new Date()); + pathRoute = pathRoute + File.separator + "传递ERP属性汇总表" + time + ".xlsx"; + wait = new ProgressBarThread("导出汇总表", "执行中,请稍等..."); + wait.start();// 开启进度条 + try { + writeToExcel(beanList,file1,pathRoute); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + MessageBox.post("生成报表失败"+e.getMessage(),"错误",MessageBox.ERROR); + return; + } + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + MessageBox.post("生成报表完成,请在桌面查看","完成",MessageBox.INFORMATION); + Runtime.getRuntime().exec("cmd /c \"" + pathRoute + "\""); + } + /** + * 写入到excel报表中 + * @throws Exception + */ + + private void writeToExcel(List compList,File file,String path) throws Exception{ + FileInputStream fis = new FileInputStream(file); + XSSFWorkbook workbook = new XSSFWorkbook(fis); + System.out.println("workBook:"+workbook); + XSSFSheet sheet = workbook.getSheetAt(0); + XSSFRow targetRow = sheet.getRow(0); + XSSFCell targetCell = targetRow.getCell(0); + XSSFCellStyle cellStyle = targetCell.getCellStyle(); + for (int i = 0; i < compList.size(); i++) { + ItemBean item = compList.get(i); + XSSFRow row = sheet.getRow(i+2); + if(row == null){ + row = sheet.createRow(i+2); + } + XSSFCell excelCell = row.getCell(0); + if(excelCell == null){ + excelCell = row.createCell(0); + } + excelCell.setCellStyle(cellStyle); + excelCell.setCellValue(item.getItem_id()); + + excelCell = row.getCell(1); + if(excelCell == null){ + excelCell = row.createCell(1); + } + excelCell.setCellStyle(cellStyle); + excelCell.setCellValue(item.getItem_name()); + + excelCell = row.getCell(2); + if(excelCell == null){ + excelCell = row.createCell(2); + } + excelCell.setCellStyle(cellStyle); + excelCell.setCellValue(item.getItem_spec()); + + excelCell = row.getCell(3); + if(excelCell == null){ + excelCell = row.createCell(3); + } + excelCell.setCellStyle(cellStyle); + excelCell.setCellValue(item.getItem_groupCode()); + + excelCell = row.getCell(4); + if(excelCell == null){ + excelCell = row.createCell(4); + } + excelCell.setCellStyle(cellStyle); + excelCell.setCellValue(item.getItem_sourceCode()); + + excelCell = row.getCell(5); + if(excelCell == null){ + excelCell = row.createCell(5); + } + excelCell.setCellStyle(cellStyle); + excelCell.setCellValue(item.getItem_unit()); + + excelCell = row.getCell(6); + if(excelCell == null){ + excelCell = row.createCell(6); + } + excelCell.setCellStyle(cellStyle); + excelCell.setCellValue(item.getItem_brand()); + + excelCell = row.getCell(7); + if(excelCell == null){ + excelCell = row.createCell(7); + } + excelCell.setCellStyle(cellStyle); + excelCell.setCellValue(item.getItem_rev()); + + excelCell = row.getCell(8); + if(excelCell == null){ + excelCell = row.createCell(8); + } + excelCell.setCellStyle(cellStyle); + excelCell.setCellValue(item.getOldMateriel()); + } + FileOutputStream output = new FileOutputStream(new File(path)); + workbook.write(output); + output.close(); + fis.close(); + + } + /** + * 通过查询构建器查询项目对象 + * + * @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 boolean getItemValue(TCComponentItemRevision rev,List beanList) throws TCException { + ItemBean bean = new ItemBean(); + String spec = ""; + String unit = ""; + String brand =""; + String id =""; + String oldMateriel =""; + Boolean flag = false; + try { + String type = rev.getStringProperty("object_type"); + id = rev.getStringProperty("item_id"); + if("T2_outsourceRevision".equals(type)) { + String subID = id.substring(0, 2); + if("51".equals(subID) || "72".equals(subID)) { + flag = true; +// List vals= getOutBuyPartValue(rev,flag); +// if(vals != null) { +// spec = vals.get(0); +// }else { +// return true; +// } + ClassValueBean valueBean = ClassValueUtil.getOutBuyPartValue(rev,errList); + if(valueBean != null) { + spec = valueBean.getSpecs(); + }else { + return true; + } + }else { + spec = getOutsourceValue(rev); + } + + unit = rev.getStringProperty("t2_unit"); + setValue(rev,bean); + + }else if("T2_OutBuyPartRevision".equals(type)) { + oldMateriel = rev.getStringProperty("t2_OldID"); +// List vals= getOutBuyPartValue(rev,flag); +// if(vals != null) { +// spec = vals.get(0); +// }else { +// return true; +// } +// for (int j = 0; j < vals.size(); j++) { +// String value = vals.get(j); +// if(value.contains("=")) { +// if(value.contains("单位")) { +// String[] units = value.split("="); +// if(units != null && units.length >= 2) { +// unit = units[1]; +// }else { +// unit = ""; +// } +// +// }else if(value.contains("品牌")) { +// String[] brands = value.split("="); +// if(brands != null && brands.length >= 2) { +// brand = brands[1]; +// }else { +// brand = ""; +// } +// } +// }else { +// spec = value; +// } +// } + ClassValueBean valueBean = ClassValueUtil.getOutBuyPartValue(rev,errList); + if(valueBean != null) { + spec = valueBean.getSpecs(); + unit = valueBean.getUnit(); + brand = valueBean.getBrand(); + if(spec == null) { + spec = ""; + } + if(unit == null) { + unit = ""; + } + if(brand == null) { + brand = ""; + } + }else { + return true; + } + setValue(rev,bean); + } + else if("T2_VirtualRevision".equals(type) || + "T2_EquipmentRevision".equals(type) || + "T2_SystemSchemeRevision".equals(type)) { + bean.setItem_groupCode("00Z"); + bean.setItem_sourceCode("X"); + } +// if(spec.contains("\"")) { +// System.out.println("spec==============="+spec); +// String[] str = spec.split("\""); +// StringBuilder sb = new StringBuilder(str[0]); +// for (int j = 1; j < str.length; j++) { +// sb.append(str[j]); +// if(j < str.length - 1) { +// sb.append("""); +// } +// } +// } + bean.setItem_spec(spec); + bean.setItem_unit(unit); + bean.setItem_brand(brand); + bean.setItem_id(id); + bean.setItem_name(rev.getStringProperty("object_name")); + + bean.setItem_rev(rev.getStringProperty("item_revision_id")); + bean.setOldMateriel(oldMateriel); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + beanList.add(bean); + return false; + } + public void setValue(TCComponentItemRevision rev,ItemBean bean) { + + try { + String groupCode = rev.getStringProperty("t2_groupCode"); + System.out.println("t2_groupCode============"+groupCode); + bean.setItem_groupCode(groupCode); + String sourceCode = rev.getStringProperty("t2_sourceCode"); + System.out.println("t2_sourceCode============"+sourceCode); + bean.setItem_sourceCode(sourceCode); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + public List getOutBuyPartValue(TCComponentItemRevision rev,boolean flag) { + // TODO Auto-generated method stub + List vals = new ArrayList(); + StringBuilder sb = new StringBuilder(); + List classPropList = new ArrayList(); + TCClassificationService classificationService = session.getClassificationService(); + try { + String className = rev.getClassificationClass(); + TCComponentICO[] icos = rev.getClassificationObjects(); + 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); + } + } + boolean have = true; + for (int j = 0; j < attrList.size(); j++) { + String classValue = attrList.get(j); + System.out.println("classValue=================="+classValue); + if(classValue.contains(";")) { + String[] classValues = classValue.split(";"); + if(className.equals(classValues[0])) { + for (int k = 1; k < classValues.length; k++) { + String attrName = classValues[k]; + System.out.println("attrName=================="+attrName); + for (int i = 0; i < classPropList.size(); i++) { + ClassPropBean bean = classPropList.get(i); + System.out.println("bean.propDisName=================="+bean.propDisName); + if(attrName.equals(bean.propDisName)) { + String value = claMap.get(bean.propID); + System.out.println("bean.propID=================="+bean.propID); + if(bean.isLov) { + String lovValue = bean.lovMapping.get(value); + System.out.println("lovValue===================="+lovValue); + if("品牌".equals(attrName) || "单位".equals(attrName)) { + if(flag) { + if("/".equals(lovValue)) { + System.out.println("不进行拼接"); + continue; + } + sb.append(lovValue); + if(k < classValues.length-1) { + sb.append(";"); + } + }else{ + StringBuilder sb1 = new StringBuilder(attrName); + sb1.append("="); + sb1.append(lovValue); + vals.add(sb1.toString()); + if("/".equals(lovValue)) { + System.out.println("不进行拼接"); + continue; + } + sb.append(lovValue); + if(k < classValues.length-1) { + sb.append(";"); + } + } + }else { + if("/".equals(lovValue)) { + System.out.println("不进行拼接"); + continue; + } + sb.append(lovValue); + if(k < classValues.length-1) { + sb.append(";"); + } + } + }else { + if("品牌".equals(attrName) || "单位".equals(attrName)) { + if(flag) { + if("/".equals(value)) { + System.out.println("不进行拼接"); + continue; + } + sb.append(value); + if(k < classValues.length-1) { + sb.append(";"); + } + }else { + StringBuilder sb1 = new StringBuilder(attrName); + sb1.append("="); + sb1.append(value); + vals.add(sb1.toString()); + if("/".equals(value)) { + System.out.println("不进行拼接"); + continue; + } + sb.append(value); + if(k < classValues.length-1) { + sb.append(";"); + } + } + }else { + System.out.println("value===================="+value); + if("/".equals(value)) { + System.out.println("不进行拼接"); + continue; + } + sb.append(value); + if(k < classValues.length-1) { + sb.append(";"); + } + } + } + break; + } + } + } + have = false; + break; + } + } + } + if(have) { + MessageBox.post("配置文件中未找到该物料的分类"+className+",请联系管理员!!", + "提示", MessageBox.WARNING); + return null; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + String spec = sb.toString(); + vals.add(spec); + return vals; + } + + public String getOutsourceValue(TCComponentItemRevision rev) { + // TODO Auto-generated method stub + StringBuilder sb = new StringBuilder(); + try { + String importance = rev.getStringProperty("t2_Importance"); + if(!("".equals(importance.trim()))) { + sb.append(importance); + sb.append(";"); + } + String material = rev.getStringProperty("t2_material"); + if(!("".equals(material.trim()))) { + sb.append(material); + sb.append(";"); + } + String mass = rev.getStringProperty("t2_MASS"); + if(!("".equals(mass.trim()))) { + sb.append(mass); + sb.append(";"); + } + String specifications = rev.getStringProperty("t2_Specifications"); + if(!("".equals(specifications.trim()))) { + sb.append(specifications); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + String spec = sb.toString(); + return spec; + } + + +} diff --git a/src/com/connor/dfl/plm/dfl030/Dfl030Handler.java b/src/com/connor/dfl/plm/dfl030/Dfl030Handler.java new file mode 100644 index 0000000..078ce18 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl030/Dfl030Handler.java @@ -0,0 +1,38 @@ +package com.connor.dfl.plm.dfl030; + +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.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +/** + * 功能名:Wf030Handler + * 功能描述: 测试数据集剪切 + * 创建日期:2019-03-08 + * 程序员 王辰 + * + * 修改日期 修改人 修改描述 + * 2019-01-24 XXXX 创建程序 + */ +public class Dfl030Handler extends AbstractHandler{ + private AbstractAIFUIApplication app; + private InterfaceAIFComponent target; + private TCSession session; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + this.session = (TCSession) app.getSession(); + this.target = app.getTargetComponent(); + Dfl030Operation operation = new Dfl030Operation(target,session); + session.queueOperation(operation); + return null; + } + +} diff --git a/src/com/connor/dfl/plm/dfl030/Dfl030Operation.java b/src/com/connor/dfl/plm/dfl030/Dfl030Operation.java new file mode 100644 index 0000000..f66b3ef --- /dev/null +++ b/src/com/connor/dfl/plm/dfl030/Dfl030Operation.java @@ -0,0 +1,76 @@ +package com.connor.dfl.plm.dfl030; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.filechooser.FileSystemView; + +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.dfl.plm.dfl019.ClassPropBean; +import com.connor.dfl.plm.dfl019.ItemBean; +import com.connor.dfl.plm.dfl019.ParseXMLUtil; +import com.connor.dfl.plm.util.ProgressBarThread; +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.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +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.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.ICSProperty; +import com.teamcenter.rac.util.MessageBox; + + +public class Dfl030Operation extends AbstractAIFOperation{ + private InterfaceAIFComponent target; + private TCSession session; + private List attrList; + private ProgressBarThread wait; + private String pathRoute; + + /** + * + * @param app + * @param lattetTime + * @param EarlyTime + * @param pathRoute + */ + public Dfl030Operation(InterfaceAIFComponent target,TCSession session) { + super(); + this.target = target; + this.session = session; + } + + public void executeOperation() throws Exception { + if(target instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) target; + TCComponent[] comp = rev.getReferenceListProperty("IMAN_specification"); + rev.cutOperation("IMAN_specification", new TCComponent[] {comp[0]}); + comp[0].delete(); + } + } +} diff --git a/src/com/connor/dfl/plm/dfl031/CNClassPropBean.java b/src/com/connor/dfl/plm/dfl031/CNClassPropBean.java new file mode 100644 index 0000000..17877a6 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl031/CNClassPropBean.java @@ -0,0 +1,59 @@ +package com.connor.dfl.plm.dfl031; + +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 CNClassPropBean { + public int propID; + public String propDisName; + public String relValue; + public String displayValue; + public String annotation; + public String defaultValue; + 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 CNClassPropBean(ICSAdminClassAttribute icsAttr) { + 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(); + this.annotation = icsAttr.getAnnotation(); + this.defaultValue = icsAttr.getDefaultValue(); + 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); + } + } else { + this.isLov = false; + } + } + @Override + public String toString() { + return propDisName + ":"; + } + +} diff --git a/src/com/connor/dfl/plm/dfl031/Classbean.java b/src/com/connor/dfl/plm/dfl031/Classbean.java new file mode 100644 index 0000000..a019654 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl031/Classbean.java @@ -0,0 +1,21 @@ +package com.connor.dfl.plm.dfl031; + +public class Classbean { + + private String id; + private String 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; + } + + +} diff --git a/src/com/connor/dfl/plm/dfl031/ExcelBean.java b/src/com/connor/dfl/plm/dfl031/ExcelBean.java new file mode 100644 index 0000000..04db201 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl031/ExcelBean.java @@ -0,0 +1,29 @@ +package com.connor.dfl.plm.dfl031; + +import java.util.List; + +public class ExcelBean { + private int no; + private List list; + private CNClassPropBean cpbean; + public int getNo() { + return no; + } + public void setNo(int no) { + this.no = no; + } + public List getList() { + return list; + } + public void setList(List list) { + this.list = list; + } + public CNClassPropBean getCpbean() { + return cpbean; + } + public void setCpbean(CNClassPropBean cpbean) { + this.cpbean = cpbean; + } + + +} diff --git a/src/com/connor/dfl/plm/dfl031/ExportDialog.java b/src/com/connor/dfl/plm/dfl031/ExportDialog.java new file mode 100644 index 0000000..3effcd1 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl031/ExportDialog.java @@ -0,0 +1,164 @@ +package com.connor.dfl.plm.dfl031; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class ExportDialog extends AbstractAIFDialog{ + private static final long serialVersionUID = -8317156384208344816L; + private AbstractAIFApplication app; + private TCSession session; + private JPanel rootPanel; + private JPanel panel1; + private JPanel panel2; + private JButton okButton; + private JButton celButton; + private JButton fileButton; + private JTextField pathText; + private JFileChooser jfc; + private JTextField projCode; + + public ExportDialog(AbstractAIFApplication app) { + super(false); + this.app = app; + this.session = (TCSession) this.app.getSession(); + } + + @Override + public void run() { + init(); + } + + public void init() { + this.setTitle("导出分类清单"); + String path = FileSystemView.getFileSystemView().getHomeDirectory() + .getAbsolutePath(); + this.setPreferredSize(new Dimension(470, 160)); + jfc = new JFileChooser(); + jfc.setCurrentDirectory(new File(path));// 文件选择器的初始目录定为桌面 + okButton = new JButton("确定"); + celButton = new JButton("取消"); + fileButton = new JButton("..."); + + fileButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + selectFileButtonEvent(e); + } + }); + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + okEvent(e); + } + }); + celButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + celEvent(e); + } + }); + + pathText = new JTextField(30); + pathText.setText(path); + projCode = new JTextField(15); + + panel1 = new JPanel(new PropertyLayout()); + + panel1.add("1.1.right.top.preferred.preferred", new JLabel(" ")); + panel1.add("2.1.right.top.preferred.preferred", new JLabel("分类ID:")); + panel1.add("2.2.left.top.preferred.preferred", projCode); + panel1.add("3.1.right.top.preferred.preferred", new JLabel("选择文件夹:")); + panel1.add("3.2.left.top.preferred.preferred", pathText); + panel1.add("3.3.left.top.preferred.preferred", fileButton); + + panel2 = new JPanel(new FlowLayout()); + panel2.add(okButton); + panel2.add(new JLabel(" ")); + panel2.add(celButton); + + rootPanel = new JPanel(new BorderLayout()); + rootPanel.add(panel1, BorderLayout.CENTER); + rootPanel.add(panel2, BorderLayout.SOUTH); + + this.add(rootPanel, "Center"); + this.centerToScreen(1.0D, 0.75D); + this.pack(); + this.setResizable(false); + this.setVisible(true); + // this.centerToScreen(); + // this.showDialog(); + + } + + /** + * 文件夹选择按钮事件 + * + * @param e + */ + public void selectFileButtonEvent(ActionEvent e) { + jfc.setFileSelectionMode(1);// 设定只能选择到文件夹 + int state = jfc.showOpenDialog(null);// 此句是打开文件选择器界面的触发语句 + if (state == 1) { + return; + } else { + File f = jfc.getSelectedFile();// f为选择到的目录 + pathText.setText(f.getAbsolutePath()); + } + } + + /** + * 添加导出逻辑 + * + * @param e + */ + public void okEvent(ActionEvent e) { + try { + + + File tempFile = new File(pathText.getText()); + if (tempFile.exists() && tempFile.isDirectory()) { + this.dispose(); + ExportOperation operation=new ExportOperation(app, session,pathText.getText(),projCode.getText()); + //operation.executeOperation(); + session.queueOperation(operation); + + } else { + MessageBox.post("请选择导出目录", "Error", MessageBox.ERROR); + } + } catch (Exception e1) { + e1.printStackTrace(); + MessageBox.post("导出清单失败", "Error", MessageBox.ERROR); + } + + } + + /** + * 添加取消逻辑 + * + * @param e + */ + public void celEvent(ActionEvent e) { + this.dispose(); + } + +} diff --git a/src/com/connor/dfl/plm/dfl031/ExportHandler.java b/src/com/connor/dfl/plm/dfl031/ExportHandler.java new file mode 100644 index 0000000..d0f53cb --- /dev/null +++ b/src/com/connor/dfl/plm/dfl031/ExportHandler.java @@ -0,0 +1,35 @@ +package com.connor.dfl.plm.dfl031; + +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; + + +/** + * Our sample handler extends AbstractHandler, an IHandler base class. + * + * @see org.eclipse.core.commands.IHandler + * @see org.eclipse.core.commands.AbstractHandler + */ +public class ExportHandler extends AbstractHandler { + /** + * The constructor. + */ + public ExportHandler() { + } + + /** + * the command has been executed, so extract extract the needed information + * from the application context. + */ + public Object execute(ExecutionEvent event) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + + + new Thread(new ExportDialog(app)).start(); + return null; + } +} diff --git a/src/com/connor/dfl/plm/dfl031/ExportOperation.java b/src/com/connor/dfl/plm/dfl031/ExportOperation.java new file mode 100644 index 0000000..484254d --- /dev/null +++ b/src/com/connor/dfl/plm/dfl031/ExportOperation.java @@ -0,0 +1,287 @@ +package com.connor.dfl.plm.dfl031; + +import java.awt.Desktop; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.swing.JOptionPane; + +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.dfl.plm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCException; +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.ICSHierarchyNodeDescriptor; +import com.teamcenter.rac.util.MessageBox; + +public class ExportOperation extends AbstractAIFOperation { + private TCSession session; + private AbstractAIFApplication app; + + private ProgressBarThread wait; + + private String path; + private String classid; + private File file; + + private int levmax = 1; + + private TCClassificationService classificationService; + + private List excelList = new ArrayList(); + + public ExportOperation(AbstractAIFApplication app, TCSession session, + String path, String classid) { + this.session = session; + this.app = app; + this.path = path; + this.classid = classid; + } + + @Override + public void executeOperation() throws Exception { + wait = new ProgressBarThread("数据导出", "数据导出中,请稍等..."); + wait.start();// 开启进度条 + + getClassPro(); + + try { + //setByPass(session, true); + TCUserService userService = this.session.getUserService(); + + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");// 设置日期格式 + String time = df.format(new Date()); + String outPutFile = path + File.separator + "分类清单" + time + ".xlsx"; + // 写入数据 + System.out.println("outPutFile=" + outPutFile); + File dest = new File(outPutFile); + writeExcel(outPutFile); + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + //setByPass(session, false); + int select = JOptionPane.showConfirmDialog(null, "文件已创建在【" + + outPutFile + "】下,是否打开", "提示", JOptionPane.YES_NO_OPTION); + if (select == JOptionPane.YES_OPTION) { + Desktop.getDesktop().open(dest); + } + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + //setByPass(session, false); + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + MessageBox.post("生成报表失败" + e.getMessage(), "错误", MessageBox.ERROR); + } + + + } + + private void getClassPro() { + // TODO Auto-generated method stub + if (classid.equals("")) { + classid = "ICM"; + } + System.out.println("classid="+classid); + classificationService = session.getClassificationService(); + dgChildClass(classid, 1, new ArrayList()); + + } + + // ,Map map + /** + * 递归分类层级 + * + * @param classid2 + * @param lev + */ + private void dgChildClass(String classid2, int lev, List list) { + // TODO Auto-generated method stub + + try { + if (levmax < lev) { + levmax = lev; + } + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(classid2); + System.out.println("id=" + c.getId()); + System.out.println("name=" + c.getName()); + Classbean classbean = new Classbean(); + classbean.setId(c.getId()); + classbean.setName(c.getName()); + List list2 = new ArrayList(); + for (int i = 0; i < list.size(); i++) { + list2.add(list.get(i)); + } + list2.add(classbean); + ICSHierarchyNodeDescriptor[] dss = classificationService + .getChildren(classid2, true, true, 0, 0); + if (dss != null && dss.length > 0) { + for (int i = 0; i < dss.length; i++) { + System.out.println("name=" + dss[i].getName()); + System.out.println("id=" + dss[i].getId()); + dgChildClass(dss[i].getId(), lev + 1, list2); + + } + } else { + ICSAdminClassAttribute[] attributes = c.getAttributes(); + if (attributes != null && attributes.length > 0) { + for (int i = 0; i < attributes.length; i++) { + CNClassPropBean bean = new CNClassPropBean( + attributes[i]); + System.out.println("bean=" + bean); + ExcelBean excelbean = new ExcelBean(); + excelbean.setCpbean(bean); + excelbean.setList(list2); + excelList.add(excelbean); + } + + } + + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private void writeExcel( String outPutFile) { + // TODO Auto-generated method stub + + try { + + XSSFWorkbook wb = new XSSFWorkbook(); + XSSFSheet sheet = wb.createSheet("分类属性"); + XSSFCellStyle style = wb.createCellStyle(); + style.setAlignment(XSSFCellStyle.ALIGN_CENTER); + XSSFRow rowfist = sheet.getRow(0); + if (rowfist == null) { + rowfist = sheet.createRow(0); + } + for (int j = 0; j < levmax + 7; j++) { + + XSSFCell cell = rowfist.getCell(j); + if (cell == null) { + cell = rowfist.createCell(j); + } + cell.setCellStyle(style); + if (j == 0) { + cell.setCellValue("序号"); + } else if (j == levmax) { + cell.setCellValue("名称"); + } else if (j == levmax + 1) { + cell.setCellValue("属性中文名"); + } else if (j == levmax + 2) { + cell.setCellValue("属性ID"); + } else if (j == levmax + 3) { + cell.setCellValue("属性类型"); + }else if (j == levmax + 4) { + cell.setCellValue("属性LOV"); + } else if (j == levmax + 5) { + cell.setCellValue("属性标识"); + }else if (j == levmax + 6) { + cell.setCellValue("默认值"); + }else { + int li = j; + cell.setCellValue(li + "类"); + } + + } + int no = 1; + for (int i = 0; i < excelList.size(); i++) { + XSSFRow row = sheet.getRow(no); + if (row == null) { + row = sheet.createRow(no); + } + ExcelBean excelbean = excelList.get(i); + CNClassPropBean cpbean = excelbean.getCpbean(); + List list = excelbean.getList(); + + String propDisName = cpbean.propDisName; + int propID = cpbean.propID; + int attrType = cpbean.attrType; + boolean isLov = cpbean.isLov; + String isLovstr = ""; + String annotation = cpbean.annotation; + String defaultValue = cpbean.defaultValue; + if (isLov) { + isLovstr = "是"; + } + if (list.size() > 0) { + for (int j = 0; j < list.size() + 7; j++) { + + XSSFCell cell = row.getCell(j); + if (cell == null) { + cell = row.createCell(j); + } + cell.setCellStyle(style); + if (j == 0) { + cell.setCellValue(no); + } else if (j == levmax + 1) { + cell.setCellValue(propDisName); + } else if (j == levmax + 2) { + cell.setCellValue(propID); + } else if (j == levmax + 3) { + cell.setCellValue(attrType); + } else if (j == levmax + 4) { + cell.setCellValue(isLovstr); + }else if (j == levmax + 5) { + cell.setCellValue(annotation); + }else if (j == levmax + 6) { + cell.setCellValue(defaultValue); + }else if(j<=list.size()){ + String className = list.get(j - 1).getName(); + cell.setCellValue(className); + } + + } + } + + no++; + + } + FileOutputStream output = new FileOutputStream(new File(outPutFile)); + wb.write(output); + output.close(); + + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + // java调C 开关bypass + public void setByPass(TCSession session, boolean val) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = "origin"; + if (val) { + userservice.call("ORIGIN_set_bypass", obj); + } else { + userservice.call("ORIGIN_close_bypass", obj); + } + } + +} diff --git a/src/com/connor/dfl/plm/dfl032/ClassPropBean.java b/src/com/connor/dfl/plm/dfl032/ClassPropBean.java new file mode 100644 index 0000000..24e8a89 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl032/ClassPropBean.java @@ -0,0 +1,64 @@ +package com.connor.dfl.plm.dfl032; + +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/dfl/plm/dfl032/Dfl032Dialog.java b/src/com/connor/dfl/plm/dfl032/Dfl032Dialog.java new file mode 100644 index 0000000..e093039 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl032/Dfl032Dialog.java @@ -0,0 +1,470 @@ +package com.connor.dfl.plm.dfl032; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.GridLayout; +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.lang.reflect.InvocationTargetException; +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.List; +import java.util.Map; +import java.util.MissingResourceException; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.WindowConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableRowSorter; + +import com.connor.dfl.plm.dfl019.ClassPropBean; +import com.connor.dfl.plm.dfl019.ParseXMLUtil; +import com.teamcenter.rac.aif.AIFClipboard; +import com.teamcenter.rac.aif.AIFPortal; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.commands.open.OpenCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentProcess; +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; +import com.teamcenter.rac.util.Registry; + +public class Dfl032Dialog extends AbstractAIFDialog{ + + private static final long serialVersionUID = 6130114042631785757L; + private static final int width=1300; + private TCSession session; + private int tableNum = 0; + private List tableList = new ArrayList(); + //private JTable qryTable; + private List attrList; + private String[] loginProps; + private TCPreferenceService service; + private AbstractAIFUIApplication app; + private Map> revListMap = new HashMap>(); + public Dfl032Dialog(AbstractAIFUIApplication app) { + this.app = app; + this.session=(TCSession) app.getSession(); + this.service = session.getPreferenceService(); + } + + @Override + public void run() { + ParseXMLUtil xml=new ParseXMLUtil(); + File file=xml.getSXX("DFL_CLASS_Xml", session); + attrList =xml.parseXMLCode(file); + if(attrList == null || attrList.size() <= 0) { + MessageBox.post("首选项DFL_CLASS_Xml未配置,请检查!", "WARNING", + MessageBox.WARNING); + return; + } + InterfaceAIFComponent comp = app.getTargetComponent(); + String compType = comp.getType(); + System.out.println("compType=============="+compType); + List idList = new ArrayList(); + StringBuilder sb = new StringBuilder(); + if("EPMPerformSignoffTask".equals(compType)|| "EPMDoTask".equals(compType)) { + if(comp instanceof TCComponent) { + TCComponent tccomp = (TCComponent) comp; + try { + TCComponent[] references = tccomp.getReferenceListProperty("root_target_attachments"); + System.out.println("references====="+references.length); + for (int i = 0; i < references.length; i++) { + String type = references[i].getType(); + System.out.println("type==============="+type); + + if("T2_OutBuyPartRevision".equals(type)) { + TCComponentItemRevision rev = (TCComponentItemRevision) references[i]; + String className = rev.getClassificationClass(); + System.out.println("className=================="+className); + if("".equals(className.trim())) { + String id = rev.getStringProperty("item_id"); + idList.add(id); + continue; + } + if(revListMap.containsKey(className)) { + List revList = revListMap.get(className); + revList.add(rev); + }else { + List revList = new ArrayList(); + revList.add(rev); + revListMap.put(className, revList); + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + }else { + MessageBox.post("请选择审核流程任务!!!","提示",MessageBox.INFORMATION); + return; + } + if(idList.size() > 0) { + for (int i = 0; i < idList.size(); i++) { + sb.append(idList.get(i)); + if(i < idList.size()-1) { + sb.append(";"); + } + } + MessageBox.post(sb.toString()+"物料没有发送到分类,请发送!!!","提示",MessageBox.INFORMATION); + return; + } + //显示窗口 + initUI(); + } + + + + @SuppressWarnings("serial") + private void initUI() { + this.setTitle("流程目标表单"); + this.setLayout(new FlowLayout(FlowLayout.CENTER,2,3)); + this.setPreferredSize(new Dimension(width, 650)); + this.setLocation(2, 5); + final JTabbedPane tabbedPane = new JTabbedPane(); + for(Map.Entry> entry : revListMap.entrySet()){ + List revList = entry.getValue(); + TCComponentItemRevision rev = revList.get(0); + try { + String className = rev.getClassificationClass(); + System.out.println("className=================="+className); + if("".equals(className.trim())) { + MessageBox.post("选中的物料没有发送到分类,请发送!!!","提示",MessageBox.INFORMATION); + return; + } + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(className); + String name = c.getName(); + System.out.println("name=================="+name); + JTable qryTable = new JTable(); + tableList.add(qryTable); + tabbedPane.addTab(name, createTextPanel(revList,c,qryTable)); + // 添加选项卡选中状态改变的监听器 + tabbedPane.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + System.out.println("当前选中的选项卡: " + tabbedPane.getSelectedIndex()); + tableNum = tabbedPane.getSelectedIndex(); + } + }); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + + // 设置默认选中的选项卡 + tabbedPane.setSelectedIndex(0); + this.setContentPane(tabbedPane); + //this.setResizable(false); + this.setAlwaysOnTop(true); + this.showDialog(); + } + + + /** + * 获取分类属性信息 + * @return table的dataVector + */ + private Object[][] getRecords(List revList,String[]columnNames,List classPropList){ + + //封装结果集 + Object res[][] = new Object[revList.size()][columnNames.length]; + int i = 0; + for (TCComponentItemRevision record : revList) { + try { + res[i][0]=(i+1)+""; + res[i][1]=record.getStringProperty("item_id"); + res[i][2]=record.getStringProperty("object_name"); + //获取分类属性 + TCComponentICO[] icos = record.getClassificationObjects(); + if(icos != null && icos.length>0){ + ICSProperty[] icss = icos[0].getICSProperties(true); + for (int j = 0; j < icss.length; j++) { + ClassPropBean bean = classPropList.get(j); + String value = icss[j].getValue(); + if(bean.isLov) { + value = bean.lovMapping.get(value); + } + res[i][j+3] = value; + } + } + i++; + } catch (TCException e) { + e.printStackTrace(); + } + } + return res; + } + + + /** + * 通过查询构建器查询项目对象 + * @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; + } + } + //添加右键菜单 + private void createPopupMenu(final int row,JTable qryTable) { + //m_popupMenu = new JPopupMenu(); + + //JMenuItem delMenItem = new JMenuItem(); + //delMenItem.setText("发送到'我的Teamcenter'"); + //delMenItem.addActionListener(new java.awt.event.ActionListener() { + //public void actionPerformed(java.awt.event.ActionEvent evt) { + //该操作需要做的事 + System.out.println("==发送到item=="+row); + int column = 1; + String selectedValue = (String) qryTable.getModel().getValueAt(row,column); + String proId = selectedValue; + System.out.println("proId=============="+proId); + String[] keys = new String[]{"零组件 ID"}; + String[] values = new String[]{proId}; + List compList = queryObject("零组件 ID", keys, values); + System.out.println("size==========="+compList.size()); + TCComponent comp = compList.get(0); + if ((comp instanceof TCComponent)) { + Registry localRegistry = Registry.getRegistry("com.teamcenter.rac.commands.open.open"); + OpenCommand localOpenCommand; + try { + localOpenCommand = (OpenCommand) localRegistry.newInstanceForEx("openCommand", + new Object[] { AIFUtility.getActiveDesktop(), comp }); + localOpenCommand.executeModeless(); + } catch (MissingResourceException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (NoSuchMethodException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + //} + //}); + //m_popupMenu.add(delMenItem); + } + + 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; + } + } + + /** + * 创建一个面板,面板中心显示一个标签,用于表示某个选项卡需要显示的内容 + */ + private JComponent createTextPanel(List revList,ICSAdminClass c,JTable qryTable) { + System.out.println("进入绘制Jtable"); + String[] attrName = null; + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + List classPropList = new ArrayList(); + 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 i = 0; i < attrList.size(); i++) { + String classValue = attrList.get(i); + if(classValue.contains(";")) { + String[] classValues = classValue.split(";"); + if(c.getId().equals(classValues[0])) { + attrName = new String [classValues.length -1]; + for (int j = 0; j < attrName.length; j++) { + attrName[j] = classValues[j+1]; + } + break; + } + } + } + String[] columnNames = new String[icsAttrS.length + 3]; + columnNames[0] = "序号"; + columnNames[1] = "品号"; + columnNames[2] = "品名"; + for (int j = 0; j < icsAttrS.length; j++) { + columnNames[j + 3] = icsAttrS[j].getName(); + } + + DefaultTableModel model = new DefaultTableModel() { + private static final long serialVersionUID = 6905817304437097181L; + public boolean isCellEditable(int row, int column) { + return true; + } + }; + +// 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; +// } +// }; + qryTable.setModel(model); + qryTable.addMouseListener(new MouseAdapter() { + int tableRow = -1; + public void mouseClicked(MouseEvent e){ + if(e.getButton() == MouseEvent.BUTTON3){ + // tableRow = qryTable.rowAtPoint(e.getPoint()); + JTable qryTable1 =tableList.get(tableNum); + tableRow = qryTable1.getSelectedRow(); + qryTable1.setRowSelectionInterval(tableRow, tableRow); + int indexRow = qryTable1.convertRowIndexToModel(tableRow); + System.out.println("indexRow=============="+indexRow); + if(tableRow >= 0){ + System.out.println("1111111111111111111"); + createPopupMenu(indexRow,qryTable1); + + } + } + } + }); + Object[][] cellData =getRecords(revList,columnNames,classPropList); + + TableRowSorter sorter = new TableRowSorter(model); + qryTable.setRowSorter(sorter); //为JTable设置排序器 + model.setDataVector(cellData, columnNames); + + //DefaultTableCellRenderer类可以绘制单元格的背景、字体颜色等功能 + DefaultTableCellRenderer backGroundColor = new DefaultTableCellRenderer(); + //绘制部门列的背景为黄色 + backGroundColor.setBackground(Color.yellow); + if(attrName != null && attrName.length > 0) { + for (int i = 0; i < attrName.length; i++) { + List colList = Arrays.asList(columnNames); + if(colList.contains(attrName[i])) { + TableColumn tableColumn = qryTable.getColumn(attrName[i]); + tableColumn.setCellRenderer(backGroundColor); + } + } + } + qryTable.getColumnModel().getColumn(0).setPreferredWidth(10); + qryTable.setDefaultRenderer(Object.class, new TableCellTextAreaRenderer()); + JScrollPane scrollPane=new JScrollPane(qryTable); + scrollPane.setPreferredSize(new Dimension(width-5, 620)); + + return scrollPane; + } +} diff --git a/src/com/connor/dfl/plm/dfl032/Dfl032Handler.java b/src/com/connor/dfl/plm/dfl032/Dfl032Handler.java new file mode 100644 index 0000000..682fe4a --- /dev/null +++ b/src/com/connor/dfl/plm/dfl032/Dfl032Handler.java @@ -0,0 +1,21 @@ +package com.connor.dfl.plm.dfl032; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.dfl.plm.dfl031.ExportDialog; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class Dfl032Handler extends AbstractHandler { + private AbstractAIFUIApplication app; + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + new Thread(new Dfl032Dialog(app)).start(); + return null; + } + +} diff --git a/src/com/connor/dfl/plm/dfl033/ClassPropBean.java b/src/com/connor/dfl/plm/dfl033/ClassPropBean.java new file mode 100644 index 0000000..d1e05e0 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl033/ClassPropBean.java @@ -0,0 +1,64 @@ +package com.connor.dfl.plm.dfl033; + +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/dfl/plm/dfl033/Dfl033Dialog.java b/src/com/connor/dfl/plm/dfl033/Dfl033Dialog.java new file mode 100644 index 0000000..39bad2b --- /dev/null +++ b/src/com/connor/dfl/plm/dfl033/Dfl033Dialog.java @@ -0,0 +1,619 @@ +package com.connor.dfl.plm.dfl033; + +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.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.MissingResourceException; + +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.border.LineBorder; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableRowSorter; + +import com.connor.dfl.plm.dfl019.ClassPropBean; +import com.connor.dfl.plm.dfl019.ParseXMLUtil; +import com.connor.dfl.plm.util.ClassValueBean; +import com.connor.dfl.plm.util.ClassValueUtil; +import com.connor.dfl.plm.util.DataBaseControl; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.commands.open.OpenCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentICO; +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.MessageBox; +import com.teamcenter.rac.util.Registry; + +public class Dfl033Dialog extends AbstractAIFDialog{ + + private static final long serialVersionUID = 6130114042631785757L; + private List errList = new ArrayList(); + private static final int width=1300; + private DefaultTableModel model; + private TCSession session; + private JTable qryTable; + private String[] loginProps; + private TCPreferenceService service; + private AbstractAIFUIApplication app; + private List attrList; + private String compType; + private String titleName; + private String comTitle; + private String taskUID; + private JTextArea field; + private InterfaceAIFComponent targetComponent; + private String[] columnNames = new String[] {"序号","品号","品名","规格","分群码","来源码","单位","品牌","版本","旧品号"}; + private List revList = new ArrayList(); + public Dfl033Dialog(AbstractAIFUIApplication app) { + this.app = app; + this.session=(TCSession) app.getSession(); + this.service = session.getPreferenceService(); + } + + @Override + public void run() { +// ParseXMLUtil xml=new ParseXMLUtil(); +// File file=xml.getSXX("DFL_CLASS_Xml", session); +// attrList =xml.parseXMLCode(file); +// if(attrList == null || attrList.size() <= 0) { +// MessageBox.post("首选项DFL_CLASS_Xml未配置,请检查!", "WARNING", +// MessageBox.WARNING); +// return; +// } + InterfaceAIFComponent comp = app.getTargetComponent(); + compType = comp.getType(); + System.out.println("compType=============="+compType); + List idList = new ArrayList(); + StringBuilder sb = new StringBuilder(); + if("EPMPerformSignoffTask".equals(compType) || "EPMDoTask".equals(compType)) { + if(comp instanceof TCComponent) { + TCComponent tccomp = (TCComponent) comp; + try { + TCComponent[] references = tccomp.getReferenceListProperty("root_target_attachments"); + TCComponent rootTask = tccomp.getReferenceProperty("fnd0RootTask"); + taskUID = rootTask.getUid(); + System.out.println("taskUID============"+taskUID); + for (int i = 0; i < references.length; i++) { + String type = references[i].getType(); + System.out.println("type==============="+type); + if("T2_OutBuyPartRevision".equals(type) ) { + TCComponentItemRevision rev = (TCComponentItemRevision) references[i]; + String className = rev.getClassificationClass(); + System.out.println("className=================="+className); + if("".equals(className.trim())) { + String id = rev.getStringProperty("item_id"); + idList.add(id); + continue; + } + revList.add(rev); + }else if("T2_outsourceRevision".equals(type)) { + TCComponentItemRevision rev = (TCComponentItemRevision) references[i]; + String item_id = rev.getStringProperty("item_id"); + String classID = item_id.substring(0, 2); + System.out.println("classID==============="+classID); + if("51".equals(classID) || "72".equals(classID)) { + String className = rev.getClassificationClass(); + System.out.println("className=================="+className); + if("".equals(className.trim())) { + String id = rev.getStringProperty("item_id"); + idList.add(id); + continue; + } + } + revList.add(rev); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + }else { + MessageBox.post("请选择审核流程任务或者编制流程任务!!!","提示",MessageBox.INFORMATION); + return; + } + if(idList.size() > 0) { + for (int i = 0; i < idList.size(); i++) { + sb.append(idList.get(i)); + if(i < idList.size()-1) { + sb.append(";"); + } + } + MessageBox.post(sb.toString()+"物料没有发送到分类,请发送!!!","提示",MessageBox.INFORMATION); + return; + } + //显示窗口 + + initUI(); + + } + + + + @SuppressWarnings("serial") + private void initUI() { + + + targetComponent=app.getTargetComponent(); + try { + titleName = targetComponent.getProperty("fnd0RootTask"); + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + System.out.println("titleName========="+titleName); + + //this.setTitle("传ERP分类属性表单"); + this.setTitle(titleName); + this.setLayout(new FlowLayout(FlowLayout.CENTER,2,3)); + this.setPreferredSize(new Dimension(width, 650)); + this.setLocation(2, 5); + final JTabbedPane tabbedPane = new JTabbedPane(); + tabbedPane.addTab("ERP分类属性", createTextPanel()); + // 添加选项卡选中状态改变的监听器 + tabbedPane.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + System.out.println("当前选中的选项卡: " + tabbedPane.getSelectedIndex()); + } + }); + // 设置默认选中的选项卡 + tabbedPane.setSelectedIndex(0); + JButton okBut = new JButton("确认"); + field = new JTextArea(); + field.setLineWrap(true); + field.setRows(3); + field.setColumns(30); + field.setWrapStyleWord(true); + field.setBorder(new LineBorder(new java.awt.Color(127,157,185), 1, false));; + if("EPMDoTask".equals(compType) || "EPMPerformSignoffTask".equals(compType)) { + DataBaseControl db = new DataBaseControl(session); + try { + String idea = db.getTaskIdea(taskUID); + if(!("".equals(idea))) { + field.setText(idea); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + okBut.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if("EPMPerformSignoffTask".equals(compType)) { + String idea = field.getText(); + System.out.println("idea============="+idea); + if(!("".equals(idea))) { + DataBaseControl db = new DataBaseControl(session); + try { + db.setTaskIdea(taskUID,idea); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + }else { + MessageBox.post("没有权限设置审核意见!!!","提示",MessageBox.INFORMATION); + } + disposeDialog(); + } + }); + this.add("1.1.center.top",new JLabel("审核意见:")); + this.add("1.2.center.top", field); + this.add("1.3.center.top",okBut); + this.add("2.1.center.top",tabbedPane); + //this.setContentPane(tabbedPane); + //this.setResizable(false); + this.setAlwaysOnTop(true); + this.showDialog(); + } + + + /** + * 获取分类属性信息 + * @return table的dataVector + */ + private Object[][] getRecords(){ + //封装结果集 + Object res[][] = new Object[revList.size()][columnNames.length]; + int i = 0; + for (TCComponentItemRevision record : revList) { + + try { + TCClassificationService classificationService = session.getClassificationService(); +// String className = record.getClassificationClass(); +// ICSAdminClass c = classificationService.newICSAdminClass(); +// c.load(className); +// ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); +// List classPropList = new ArrayList(); +// if (icsAttrS != null) { +// for (ICSAdminClassAttribute attr : icsAttrS) { +// if (attr.isReferenceAttribute()) { +// continue; +// } +// if (attr.isReference()) { +// continue; +// } +// ClassPropBean bean = new ClassPropBean(attr); +// classPropList.add(bean); +// } +// } + res[i][0]=(i+1)+""; + String item_id = record.getStringProperty("item_id"); + res[i][1]=item_id; + res[i][2]=record.getStringProperty("object_name"); + //获取分类属性 +// StringBuilder sb = new StringBuilder(); +// TCComponentICO[] icos = record.getClassificationObjects(); +// 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 (int p = 0; p < attrList.size(); p++) { +// String classValue = attrList.get(p); +// if(classValue.contains(";")) { +// String[] classValues = classValue.split(";"); +// if(className.equals(classValues[0])) { +// for (int j = 1; j < classValues.length; j++) { +// String attrName = classValues[j]; +// for (int k = 0; k < classPropList.size(); k++) { +// ClassPropBean bean = classPropList.get(k); +// if(attrName.equals(bean.propDisName)) { +// String value = claMap.get(bean.propID); +// if(bean.isLov) { +// value = bean.lovMapping.get(value); +// } +// if("品牌".equals(attrName) ) { +// res[i][7] = value; +//// if ("/".equals(value)) { +//// System.out.println("不进行拼接"); +//// break; +//// }else { +//// sb.append(value); +//// if(j < classValues.length - 1) { +//// sb.append(";"); +//// } +//// } +// }else if("单位".equals(attrName)){ +// res[i][6] = value; +//// if ("/".equals(value)) { +//// System.out.println("不进行拼接"); +//// break; +//// }else { +//// sb.append(value); +//// if(j < classValues.length - 1) { +//// sb.append(";"); +//// } +//// } +// }else { +// if("/".equals(value)) { +// System.out.println("不进行拼接"); +// break; +// } +// sb.append(value); +// if(j < classValues.length - 1) { +// sb.append(";"); +// } +// } +// break; +// } +// } +// } +// break; +// } +// } +// } +// +// res[i][3] = sb.toString(); + String type = record.getStringProperty("object_type"); + ClassValueBean valueBean = null; + if("T2_OutBuyPartRevision".equals(type)) { + valueBean = ClassValueUtil.getOutBuyPartValue(record,errList); + if(valueBean != null) { + String spec = valueBean.getSpecs(); + String unit = valueBean.getUnit(); + String brand = valueBean.getBrand(); + if(spec == null) { + spec = ""; + } + if(unit == null) { + unit = ""; + } + if(brand == null) { + brand = ""; + } + res[i][3] = spec; + res[i][6] = unit; + res[i][7] = brand; + } + }else if("T2_outsourceRevision".equals(type)){ + String unit = record.getStringProperty("t2_unit"); + String classID = item_id.substring(0, 2); + System.out.println("classID==============="+classID); + if("51".equals(classID) || "72".equals(classID)) { + valueBean = ClassValueUtil.getOutSourcePartValue(record,errList); + if(valueBean != null) { + String spec = valueBean.getSpecs(); + String brand = valueBean.getBrand(); + if(spec == null) { + spec = ""; + } + if(brand == null) { + brand = ""; + } + //String spe = getOutsourceValue(record); + StringBuilder sb = new StringBuilder(spec); + //sb.append(";"); + //sb.append(spe); + res[i][3] = sb.toString(); + res[i][6] = unit; + res[i][7] = brand; + } + }else{ + String spec = getOutsourceValue(record); + res[i][3] = spec; + res[i][6] = unit; + res[i][7] = ""; + } + } + + + res[i][4] = record.getStringProperty("t2_groupCode"); + res[i][5] = record.getStringProperty("t2_sourceCode"); + res[i][8] = record.getStringProperty("item_revision_id"); + res[i][9] = record.getStringProperty("t2_OldID"); + + i++; + } catch (TCException e) { + e.printStackTrace(); + } + } + return res; + } + private String getOutsourceValue(TCComponentItemRevision rev) { + // TODO Auto-generated method stub + StringBuilder sb = new StringBuilder(); + try { + String importance = rev.getStringProperty("t2_Importance"); + if(!("".equals(importance.trim()))) { + sb.append(importance); + sb.append(";"); + } + String material = rev.getStringProperty("t2_material"); + if(!("".equals(material.trim()))) { + sb.append(material); + sb.append(";"); + } + String mass = rev.getStringProperty("t2_MASS"); + if(!("".equals(mass.trim()))) { + sb.append(mass); + sb.append(";"); + } + String specifications = rev.getStringProperty("t2_Specifications"); + if(!("".equals(specifications.trim()))) { + sb.append(specifications); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + String spec = sb.toString(); + return spec; + } + + /** + * 通过查询构建器查询项目对象 + * @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; + } + } + //添加右键菜单 + private void createPopupMenu(final int row) { + //m_popupMenu = new JPopupMenu(); + + //JMenuItem delMenItem = new JMenuItem(); + //delMenItem.setText("发送到'我的Teamcenter'"); + //delMenItem.addActionListener(new java.awt.event.ActionListener() { + //public void actionPerformed(java.awt.event.ActionEvent evt) { + //该操作需要做的事 + System.out.println("==发送到item=="+row); + int column = 1; + String selectedValue = (String) qryTable.getModel().getValueAt(row,column); + String proId = selectedValue; + System.out.println("proId=============="+proId); + String[] keys = new String[]{"零组件 ID"}; + String[] values = new String[]{proId}; + List compList = queryObject("零组件 ID", keys, values); + System.out.println("size==========="+compList.size()); + TCComponent comp = compList.get(0); + if ((comp instanceof TCComponent)) { + Registry localRegistry = Registry.getRegistry("com.teamcenter.rac.commands.open.open"); + OpenCommand localOpenCommand; + try { + localOpenCommand = (OpenCommand) localRegistry.newInstanceForEx("openCommand", + new Object[] { AIFUtility.getActiveDesktop(), comp }); + localOpenCommand.executeModeless(); + } catch (MissingResourceException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (NoSuchMethodException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + //} + //}); + //m_popupMenu.add(delMenItem); + } + + 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; + } + } + + /** + * 创建一个面板,面板中心显示一个标签,用于表示某个选项卡需要显示的内容 + */ + private JComponent createTextPanel() { + System.out.println("进入绘制Jtable"); + + model = new DefaultTableModel() { + private static final long serialVersionUID = 6905817304437097181L; + public boolean isCellEditable(int row, int column) { + return true; + } + }; + + 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; + } + }; + qryTable.addMouseListener(new MouseAdapter() { + int tableRow = -1; + public void mouseClicked(MouseEvent e){ + if(e.getButton() == MouseEvent.BUTTON3){ + // tableRow = qryTable.rowAtPoint(e.getPoint()); + tableRow = qryTable.getSelectedRow(); + qryTable.setRowSelectionInterval(tableRow, tableRow); + int indexRow = qryTable.convertRowIndexToModel(tableRow); + System.out.println("indexRow=============="+indexRow); + if(tableRow >= 0){ + System.out.println("1111111111111111111"); + createPopupMenu(indexRow); + + } + } + } + }); + + Object[][] cellData =getRecords(); + + TableRowSorter sorter = new TableRowSorter(model); + qryTable.setRowSorter(sorter); //为JTable设置排序器 + model.setDataVector(cellData, columnNames); + qryTable.getColumnModel().getColumn(0).setPreferredWidth(10); + qryTable.getColumnModel().getColumn(1).setPreferredWidth(100); + qryTable.getColumnModel().getColumn(2).setPreferredWidth(50); + qryTable.getColumnModel().getColumn(3).setPreferredWidth(200); + qryTable.getColumnModel().getColumn(4).setPreferredWidth(50); + qryTable.getColumnModel().getColumn(5).setPreferredWidth(50); + qryTable.getColumnModel().getColumn(6).setPreferredWidth(50); + qryTable.getColumnModel().getColumn(7).setPreferredWidth(50); + qryTable.getColumnModel().getColumn(8).setPreferredWidth(50); + qryTable.getColumnModel().getColumn(9).setPreferredWidth(100); + qryTable.setDefaultRenderer(Object.class, new TableCellTextAreaRenderer()); + JScrollPane scrollPane=new JScrollPane(qryTable); + scrollPane.setPreferredSize(new Dimension(width-5, 620)); + + return scrollPane; + } +} diff --git a/src/com/connor/dfl/plm/dfl033/Dfl033Handler.java b/src/com/connor/dfl/plm/dfl033/Dfl033Handler.java new file mode 100644 index 0000000..b0604bb --- /dev/null +++ b/src/com/connor/dfl/plm/dfl033/Dfl033Handler.java @@ -0,0 +1,21 @@ +package com.connor.dfl.plm.dfl033; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.dfl.plm.dfl031.ExportDialog; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class Dfl033Handler extends AbstractHandler { + private AbstractAIFUIApplication app; + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + new Thread(new Dfl033Dialog(app)).start(); + return null; + } + +} diff --git a/src/com/connor/dfl/plm/dfl033/TextBorderUtlis.java b/src/com/connor/dfl/plm/dfl033/TextBorderUtlis.java new file mode 100644 index 0000000..641102c --- /dev/null +++ b/src/com/connor/dfl/plm/dfl033/TextBorderUtlis.java @@ -0,0 +1,45 @@ +package com.connor.dfl.plm.dfl033; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import javax.swing.border.LineBorder; + +/** + * @author user + * 边框设置 + */ + +public class TextBorderUtlis extends LineBorder +{ + + private static final long serialVersionUID = 1L; + + public TextBorderUtlis(Color color, int thickness, boolean roundedCorners) + { + super(color, thickness, roundedCorners); + } + + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) + { + + RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + Color oldColor = g.getColor(); + Graphics2D g2 = (Graphics2D) g; + int i; + g2.setRenderingHints(rh); + g2.setColor(lineColor); + for (i = 0; i < thickness; i++) + { + if (!roundedCorners){ + g2.drawRect(x + i, y + i, width - i - i - 1, height - i - i - 1); + }else{ + g2.drawRoundRect(x + i, y + i, width - i - i - 1, height - i - i - 1, 5, 5);} + } + g2.setColor(oldColor); + } + +} + diff --git a/src/com/connor/dfl/plm/dfl034/Dfl034Handler.java b/src/com/connor/dfl/plm/dfl034/Dfl034Handler.java new file mode 100644 index 0000000..9f63e32 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl034/Dfl034Handler.java @@ -0,0 +1,34 @@ +package com.connor.dfl.plm.dfl034; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.dfl.plm.dfl031.ExportDialog; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +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.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.MessageBox; + +public class Dfl034Handler extends AbstractHandler { + private AbstractAIFUIApplication app; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent[] comps = app.getTargetComponents(); + Dfl034Operation operation = new Dfl034Operation(comps,session); + session.queueOperation(operation); + return null; + } + +} diff --git a/src/com/connor/dfl/plm/dfl034/Dfl034Operation.java b/src/com/connor/dfl/plm/dfl034/Dfl034Operation.java new file mode 100644 index 0000000..522c858 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl034/Dfl034Operation.java @@ -0,0 +1,498 @@ +package com.connor.dfl.plm.dfl034; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.filechooser.FileSystemView; + +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.dfl.plm.dfl019.ClassPropBean; +import com.connor.dfl.plm.dfl019.ItemBean; +import com.connor.dfl.plm.dfl019.ParseXMLUtil; +import com.connor.dfl.plm.exportBOM.ChangeDbomUtil; +import com.connor.dfl.plm.util.ClassValueBean; +import com.connor.dfl.plm.util.ClassValueUtil; +import com.connor.dfl.plm.util.ProgressBarThread; +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.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +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.TCComponentUser; +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.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; + + +public class Dfl034Operation extends AbstractAIFOperation{ + private InterfaceAIFComponent[] comps; + private TCSession session; + private List attrList; + private List errList = new ArrayList(); + + /** + * + * @param app + * @param lattetTime + * @param EarlyTime + * @param pathRoute + */ + public Dfl034Operation(InterfaceAIFComponent[] comps,TCSession session) { + super(); + this.comps = comps; + this.session = session; + } + + public void executeOperation() throws Exception { + // TODO Auto-generated method stub +// ParseXMLUtil xml=new ParseXMLUtil(); +// File file=xml.getSXX("DFL_CLASS_Xml", session); +// attrList =xml.parseXMLCode(file); +// if(attrList == null || attrList.size() <= 0) { +// MessageBox.post("首选项DFL_CLASS_Xml未配置,请检查!", "WARNING", +// MessageBox.WARNING); +// return; +// } + + try { + System.out.println("开旁路"); + ChangeDbomUtil.setByPass(true); + for (int i = 0; i < comps.length; i++) { + InterfaceAIFComponent comp = comps[i]; + if(comp instanceof TCComponentBOMLine) { + TCComponentBOMLine line = (TCComponentBOMLine) comp; + setSpecValue(line); + }else if(comp instanceof TCComponentItemRevision){ + try { + TCComponentItemRevision rev = (TCComponentItemRevision) comp; + TCTypeService service = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = winType.create(null); + TCComponentItem item = rev.getItem(); + TCComponentBOMLine line = view.setWindowTopLine(item,rev, null, null); + setSpecValue(line); + } catch (Exception e) { + // TODO: handle exception + } + }else { + MessageBox.post("选中的对象中有非版本对象或BOM行对象,请检查!", "WARNING", + MessageBox.WARNING); + } + } + + ChangeDbomUtil.setByPass(false); + System.out.println("关旁路"); + String err = ""; + StringBuilder sb = new StringBuilder(); + if(errList.size() > 0) { + sb.append(",其中"); + for (int i = 0; i < errList.size(); i++) { + sb.append(errList.get(i)); + if(i < errList.size() -1) { + sb.append(";"); + } + } + sb.append("未发送分类无法同步属性"); + err = sb.toString(); + } + MessageBox.post("同步传ERP属性成功"+err+"!!!", "WARNING", + MessageBox.WARNING); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post("同步传ERP属性失败!!!,请检查!", "WARNING", + MessageBox.WARNING); + } + + + + } + public void setSpecValue(TCComponentBOMLine line) { + + try { + TCComponentItemRevision rev = line.getItemRevision(); + String type = rev.getType(); + String spec = ""; + String unit = ""; + String brand = ""; + Boolean flag = false; + TCComponent[] status = rev.getReferenceListProperty("release_status_list"); + if("T2_outsourceRevision".equals(type)) { + String id = rev.getStringProperty("item_id"); + String subID = id.substring(0, 2); + + if("51".equals(subID) || "72".equals(subID) || "76".equals(subID)) { + flag = true; +// List vals= getSpecValue(rev,flag); +// if(vals != null) { +// spec = vals.get(0); +// } + ClassValueBean valueBean = ClassValueUtil.getOutBuyPartValue(rev,errList); + if(valueBean != null) { + spec = valueBean.getSpecs(); + } + }else { + spec = getOutsourceValue(rev); + } + System.out.println("spec==============="+spec); + if(!("".equals(spec.trim()))) { + //if(status != null && status.length > 0) { + String userName = session.getUserName(); + System.out.println("userName======="+userName); + //if("admin".equals(userName)) { + System.out.println("开始进行同步!!!!"); + rev.setStringProperty("t2_specERP2", spec); + //}else { + String specERP2 = rev.getStringProperty("t2_specERP2"); + if("".equals(specERP2.trim())) { + System.out.println("开始进行同步!!!!"); + rev.setStringProperty("t2_specERP2", spec); + } + //} + + //}else { + System.out.println("开始进行同步!!!!"); + rev.setStringProperty("t2_specERP2", spec); + //} + } + }else if("T2_OutBuyPartRevision".equals(type)) { +// List vals= getSpecValue(rev,flag); +// if(vals != null) { +// for (int j = 0; j < vals.size(); j++) { +// String value = vals.get(j); +// System.out.println("value11111====="+value); +// if(value.contains("=")) { +// if(value.contains("单位")) { +// String[] units = value.split("="); +// if(units.length >= 2) { +// unit = units[1]; +// } +// }else if(value.contains("品牌")) { +// String[] brands = value.split("="); +// if(brands.length >= 2) { +// brand = brands[1]; +// } +// }else { +// spec = value; +// } +// }else { +// spec = value; +// } +// } + ClassValueBean valueBean = ClassValueUtil.getOutBuyPartValue(rev,errList); + if(valueBean != null) { + spec = valueBean.getSpecs(); + unit = valueBean.getUnit(); + brand = valueBean.getBrand(); + if(spec == null) { + spec = ""; + } + if(unit == null) { + unit = ""; + } + if(brand == null) { + brand = ""; + } + System.out.println("spec==============="+spec); + System.out.println("brand==============="+brand); + System.out.println("unit==============="+unit); + //if(status != null && status.length > 0) { + String userName = session.getUserName(); + System.out.println("userName======="+userName); + //if("admin".equals(userName)) { + rev.setStringProperty("t2_specERP1", spec); + rev.setStringProperty("t2_unit", unit); + rev.setStringProperty("t2_brand", brand); + //}else { + String specERP2 = rev.getStringProperty("t2_specERP1"); + if("".equals(specERP2.trim())) { + System.out.println("开始进行同步!!!!"); + rev.setStringProperty("t2_specERP1", spec); + rev.setStringProperty("t2_unit", unit); + rev.setStringProperty("t2_brand", brand); + } + //} + + }else { + System.out.println("开始进行同步!!!!"); + rev.setStringProperty("t2_specERP1", spec); + rev.setStringProperty("t2_unit", unit); + rev.setStringProperty("t2_brand", brand); + } + //} +// } + } + AIFComponentContext[] children = line.getChildren(); + if(children.length > 0) { + for (int i = 0; i < children.length; i++) { + InterfaceAIFComponent comp = children[i].getComponent(); + if(comp instanceof TCComponentBOMLine) { + TCComponentBOMLine childLine = (TCComponentBOMLine) comp; + setSpecValue(childLine); + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public List getSpecValue(TCComponentItemRevision rev,Boolean flag) { + // TODO Auto-generated method stub + List vals = new ArrayList(); + StringBuilder sb = new StringBuilder(); + List classPropList = new ArrayList(); + TCClassificationService classificationService = session.getClassificationService(); + try { + String errID = rev.getStringProperty("item_id"); + String className = rev.getClassificationClass(); + if("".equals(className.trim())) { + errList.add(errID); + return null; + } + TCComponentICO[] icos = rev.getClassificationObjects(); + 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); + String value = claMap.get(bean.propID); + if(bean.isLov) { + String lovValue = bean.lovMapping.get(value); + if(lovValue == null) { + lovValue = ""; + } + if("品牌".equals(bean.propDisName) || "单位".equals(bean.propDisName)) { + if(flag) { + if("/".equals(lovValue)) { + System.out.println("不进行拼接"); + break; + } + + sb.append(lovValue); + sb.append(";"); + }else{ + StringBuilder sb1 = new StringBuilder(bean.propDisName); + sb1.append("="); + sb1.append(lovValue); + vals.add(sb1.toString()); + if("/".equals(lovValue)) { + System.out.println("不进行拼接"); + break; + } + + sb.append(lovValue); + sb.append(";"); + } + }else { + if("/".equals(lovValue)) { + System.out.println("不进行拼接"); + break; + } + sb.append(lovValue); + sb.append(";"); + } + }else { + if(value == null) { + value = ""; + } + if("品牌".equals(bean.propDisName) || "单位".equals(bean.propDisName)) { + if(flag) { + if("/".equals(value)) { + System.out.println("不进行拼接"); + break; + } + sb.append(value); + sb.append(";"); + }else { + StringBuilder sb1 = new StringBuilder(bean.propDisName); + sb1.append("="); + sb1.append(value); + vals.add(sb1.toString()); + if("/".equals(value)) { + System.out.println("不进行拼接"); + break; + } + + sb.append(value); + sb.append(";"); + } + + }else { + if("/".equals(value)) { + System.out.println("不进行拼接"); + break; + } + sb.append(value); + sb.append(";"); + } + } + } + } + // for (int j = 0; j < attrList.size(); j++) { + // String classValue = attrList.get(j); + // if(classValue.contains(";")) { + // String[] classValues = classValue.split(";"); + // if(className.equals(classValues[0])) { + // for (int k = 1; k < classValues.length; k++) { + // String attrName = classValues[k]; + // for (int i = 0; i < classPropList.size(); i++) { + // ClassPropBean bean = classPropList.get(i); + // if(attrName.equals(bean.propDisName)) { + // String value = claMap.get(bean.propID); + // if(bean.isLov) { + // String lovValue = bean.lovMapping.get(value); + // if("品牌".equals(attrName) || "单位".equals(attrName)) { + // if(flag) { + // if("/".equals(lovValue)) { + // System.out.println("不进行拼接"); + // continue; + // } + // sb.append(lovValue); + // if(k < classValues.length-1) { + // sb.append(";"); + // } + // }else{ + // StringBuilder sb1 = new StringBuilder(attrName); + // sb1.append("="); + // sb1.append(lovValue); + // vals.add(sb1.toString()); + // } + // }else { + // if("/".equals(lovValue)) { + // System.out.println("不进行拼接"); + // continue; + // } + // sb.append(lovValue); + // if(k < classValues.length-1) { + // sb.append(";"); + // } + // } + // }else { + // if("品牌".equals(attrName) || "单位".equals(attrName)) { + // if(flag) { + // if("/".equals(value)) { + // System.out.println("不进行拼接"); + // continue; + // } + // sb.append(value); + // if(k < classValues.length-1) { + // sb.append(";"); + // } + // }else { + // StringBuilder sb1 = new StringBuilder(attrName); + // sb1.append("="); + // sb1.append(value); + // vals.add(sb1.toString()); + // } + // + // }else { + // if("/".equals(value)) { + // System.out.println("不进行拼接"); + // continue; + // } + // sb.append(value); + // if(k < classValues.length-1) { + // sb.append(";"); + // } + // } + // } + // break; + // } + // } + // } + // break; + // } + // } + // } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + String spec = sb.toString(); + vals.add(spec); + return vals; + } + + private String getOutsourceValue(TCComponentItemRevision rev) { + // TODO Auto-generated method stub + StringBuilder sb = new StringBuilder(); + try { + String importance = rev.getStringProperty("t2_Importance"); + if(importance != null && !("".equals(importance.trim()))) { + sb.append(importance); + sb.append(";"); + } + String material = rev.getStringProperty("t2_material"); + if(material != null && !("".equals(material.trim()))) { + sb.append(material); + sb.append(";"); + } + String mass = rev.getStringProperty("t2_MASS"); + if(mass != null && !("".equals(mass.trim()))) { + sb.append(mass); + sb.append(";"); + } + String specifications = rev.getStringProperty("t2_Specifications"); + if(specifications != null && !("".equals(specifications.trim()))) { + sb.append(specifications); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + String spec = sb.toString(); + return spec; + } + + +} diff --git a/src/com/connor/dfl/plm/dfl035/ShowMyViewHandler.java b/src/com/connor/dfl/plm/dfl035/ShowMyViewHandler.java new file mode 100644 index 0000000..8816f77 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl035/ShowMyViewHandler.java @@ -0,0 +1,46 @@ +/*jadclipse*/// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. + +package com.connor.dfl.plm.dfl035; + +import org.eclipse.core.commands.*; +import org.eclipse.ui.*; +import org.eclipse.ui.handlers.HandlerUtil; +//显示菜单 +public class ShowMyViewHandler extends AbstractHandler +{ + + public ShowMyViewHandler() + { + } + + @Override + public Object execute(ExecutionEvent executionevent) + throws ExecutionException + { + IWorkbenchPart iworkbenchpart = HandlerUtil.getActivePart(executionevent); + IViewPart iviewpart = (IViewPart)iworkbenchpart; + IWorkbenchPage iworkbenchpage = iviewpart.getSite().getPage(); + String s = "com.connor.dfl.plm.worklist.Workspace"; + try + { + iworkbenchpage.showView(s, null, 1); + } + catch(PartInitException partinitexception) + { + System.out.println("1111"); + //Logger.getLogger(com/teamcenter/rac/classification/icm/ShowClassificationViewHandler).error(partinitexception.getLocalizedMessage(), partinitexception); + } + return null; + } +} + + +/* + DECOMPILATION REPORT + + Decompiled from: D:\Teamcenter_4Sh\OTW11\rac\plugins\com.teamcenter.rac.classification.icm_11000.2.0.jar + Total time: 1022 ms + Jad reported messages/errors: + Exit status: 0 + Caught exceptions: +*/ \ No newline at end of file diff --git a/src/com/connor/dfl/plm/dfl036/AttrBean.java b/src/com/connor/dfl/plm/dfl036/AttrBean.java new file mode 100644 index 0000000..8941ce0 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl036/AttrBean.java @@ -0,0 +1,230 @@ +package com.connor.dfl.plm.dfl036; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; + +public class AttrBean { + private String firstClass; + private String secondClass; + private String thirdClass; + private String className; + private String attrName; + private String attrId; + private String attrType; + private String isLov; + private String isSendToERP; + private String unitDefaultValue; + private String[] tableHeader = new String[] {"1类","2类","3类","名称","属性中文名","属性ID","属性类型","属性LOV","属性标识","默认值"}; + private String[] values; + + public String getFirstClass() { + return firstClass; + } + public void setFirstClass(String firstClass) { + this.firstClass = firstClass; + } + public String getSecondClass() { + return secondClass; + } + public void setSecondClass(String secondClass) { + this.secondClass = secondClass; + } + public String getThirdClass() { + return thirdClass; + } + public void setThirdClass(String thirdClass) { + this.thirdClass = thirdClass; + } + public String getClassName() { + return className; + } + public void setClassName(String className) { + this.className = className; + } + public String getAttrName() { + return attrName; + } + public void setAttrName(String attrName) { + this.attrName = attrName; + } + public String getAttrId() { + return attrId; + } + public void setAttrId(String attrId) { + this.attrId = attrId; + } + public String getAttrType() { + return attrType; + } + public void setAttrType(String attrType) { + this.attrType = attrType; + } + public String getIsLov() { + return isLov; + } + public void setIsLov(String isLov) { + this.isLov = isLov; + } + public String getIsSendToERP() { + return isSendToERP; + } + public void setIsSendToERP(String isSendToERP) { + this.isSendToERP = isSendToERP; + } + public String getUnitDefaultValue() { + return unitDefaultValue; + } + public void setUnitDefaultValue(String unitDefaultValue) { + this.unitDefaultValue = unitDefaultValue; + } + public String[] getTableHeader() { + return tableHeader; + } + public void setTableHeader(String[] tableHeader) { + this.tableHeader = tableHeader; + } + public String[] getValues() { + return values; + } + public void setValues(String[] values) { + this.values = values; + } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((attrId == null) ? 0 : attrId.hashCode()); + result = prime * result + ((attrName == null) ? 0 : attrName.hashCode()); + result = prime * result + ((attrType == null) ? 0 : attrType.hashCode()); + result = prime * result + ((className == null) ? 0 : className.hashCode()); + result = prime * result + ((firstClass == null) ? 0 : firstClass.hashCode()); + result = prime * result + ((isLov == null) ? 0 : isLov.hashCode()); + result = prime * result + ((secondClass == null) ? 0 : secondClass.hashCode()); + result = prime * result + ((thirdClass == null) ? 0 : thirdClass.hashCode()); + result = prime * result + ((unitDefaultValue == null) ? 0 : unitDefaultValue.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AttrBean other = (AttrBean) obj; + if (attrId == null) { + if (other.attrId != null) + return false; + } else if (!attrId.equals(other.attrId)) + return false; + if (className == null) { + if (other.className != null) + return false; + } else if (!className.substring(0, 6).equals(other.className.substring(0,6))) + return false; + if (secondClass == null) { + if (other.secondClass != null) + return false; + } else if (!secondClass.substring(0, 2).equals(other.secondClass.substring(0, 2))) + return false; + if (thirdClass == null) { + if (other.thirdClass != null) + return false; + } else if (!thirdClass.substring(0, 4).equals(other.thirdClass.substring(0, 4))) + return false; + + return true; + } + @Override + public String toString() { + return "AttrBean [firstClass=" + firstClass + ", secondClass=" + secondClass + ", thirdClass=" + thirdClass + + ", className=" + className + ", attrName=" + attrName + ", attrId=" + attrId + ", attrType=" + + attrType + ", isLov=" + isLov + ", isSendToERP=" + isSendToERP + ", unitDefaultValue=" + + unitDefaultValue + "]"; + } + + interface AttrInterface{ + AttrBean setAttrs(String[] attrs, AttrBean classAttrBean); + } + + + public static class MethodProxy implements InvocationHandler { + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + + if (Object.class.equals(method.getDeclaringClass())) { + try { + return method.invoke(this, args); + } catch (Throwable t) { + t.printStackTrace(); + } + + } else { + System.out.println("走代理方法...."); + return run(method, args); + } + return null; + } + + + public Object run(Method method,Object[] s){ + String[] arg1 = (String[]) s[0]; + AttrBean arg2 = (AttrBean) s[1]; + String[] values = arg2.getValues(); + for(int i = 0;i cls){ + MethodProxy invocationHandler = new MethodProxy(); + Object newProxyInstance = Proxy.newProxyInstance( + cls.getClassLoader(), + new Class[] { cls }, + invocationHandler); + return (Object)newProxyInstance; + } + } + +} diff --git a/src/com/connor/dfl/plm/dfl036/MyComparator.java b/src/com/connor/dfl/plm/dfl036/MyComparator.java new file mode 100644 index 0000000..34f514e --- /dev/null +++ b/src/com/connor/dfl/plm/dfl036/MyComparator.java @@ -0,0 +1,14 @@ +package com.connor.dfl.plm.dfl036; + +import java.util.Comparator; + +public class MyComparator implements Comparator{ + + @Override + public int compare(AttrBean o1, AttrBean o2) { + + return Integer.valueOf(o1.getClassName().split("-")[0])>Integer.valueOf(o2.getClassName().split("-")[0])?1: +-1; + } + +} diff --git a/src/com/connor/dfl/plm/dfl036/SynAttrXml.java b/src/com/connor/dfl/plm/dfl036/SynAttrXml.java new file mode 100644 index 0000000..51d4025 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl036/SynAttrXml.java @@ -0,0 +1,204 @@ +package com.connor.dfl.plm.dfl036; + + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.output.FileWriterWithEncoding; +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.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.util.MessageBox; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.*; + +public class SynAttrXml { + + + + public Set getClassAttrBeanListByExcel(File file){ + Set classAttrBeanSet = new HashSet<>(); + + if(!(file.getName().endsWith(".xlsx") || file.getName().endsWith(".xls"))){ + MessageBox.post("请选中Excel表格对象!!!!","提示",MessageBox.INFORMATION); + return null; + } + try { + + XSSFWorkbook workbook=new XSSFWorkbook(FileUtils.openInputStream(file)); + DataFormatter formatter = new DataFormatter(); + + + Sheet sheet=workbook.getSheetAt(0); + Row firstRow = sheet.getRow(0); + + int lastCellNum = firstRow.getLastCellNum(); + + System.out.println("最后一列:--"+lastCellNum); + String[] tableHeader = new String[lastCellNum]; + + for(int i=0;i set){ + SynAttrXml util = new SynAttrXml(); + List list1 = util.getOrderListBySet(set,new MyComparator()); + ArrayList list = new ArrayList(); + int start=0; + while(start!=-1) { + start = customSort(start, list1, list); + } + + try { + Charset encoding = Charset.forName("utf-8"); + BufferedWriter writer = new BufferedWriter(new FileWriterWithEncoding(new File(exportFilePath),encoding)); + writer.write(""); + writer.newLine(); + writer.write(""); + writer.newLine(); + writer.write(""); + writer.newLine(); + writer.write("\t"); + writer.newLine(); + + int i=0; + String className = "初始化"; + + for (AttrBean bean: + list) { + String className1=null; + if((Integer.valueOf(bean.getClassName().substring(0, 2))>=10 && Integer.valueOf(bean.getClassName().substring(0, 2))<=24) || Integer.valueOf(bean.getClassName().substring(0, 2))==99) { + className1= "ICM0102"+list.get(i++).getClassName().split("-")[0]; + }else { + className1= "ICM0101"+list.get(i++).getClassName().split("-")[0]; + } + if("初始化".equals(className)){ + className = className1; + writer.write("\t\t"); + writer.newLine(); + writer.write("\t\t\t"); + writer.newLine(); + }else if(!className.equals(className1)){ +// System.out.println("不相等了"); + writer.write("\t\t"); + writer.newLine(); + className = className1; + writer.write("\t\t"); + writer.newLine(); + writer.write("\t\t\t"); + writer.newLine(); + }else{ + writer.write("\t\t\t"); + writer.newLine(); + } + } + writer.write("\t\t"); + writer.newLine(); + + writer.write("\t"); + writer.newLine(); + writer.write(""); + writer.newLine(); + + writer.flush(); + writer.close(); + }catch (Exception e){ + e.printStackTrace(); + } + + } + + public List getOrderListBySet(Set set,Comparator comparator){ + ArrayList list = new ArrayList<>(); + for (T bean: + set) { + list.add(bean); + } + list.sort(comparator); + return list; + + } + + public int customSort(int start,List list,List newList) { + ArrayList tempList = new ArrayList(); + AttrBean[] tempArray = new AttrBean[3]; + ArrayList tempArray1 = new ArrayList(); + String className = list.get(start).getClassName(); + for(int i=start;i set = utill.getClassAttrBeanListByExcel(fmsFile); + if(set==null) + return; + + utill.getXmlBySet(xmlPath,set); + + + TCComponent comp = session.stringToComponent(xmlPid); + + if(comp instanceof TCComponentDataset) { + System.out.println("是数据集"); + TCComponentDataset dataSet = (TCComponentDataset) comp; + //将历史版本的文件保留 + TCComponentTcFile[] files1 = dataSet.getTcFiles(); + TCComponentTcFile file1 = files1[0]; + File fmsFile1 = file1.getFmsFile(); + + String xmlHistoryDir = System.getProperty("java.io.tmpdir").substring(0, + System.getProperty("java.io.tmpdir").length() - 1) + "\\HistoryXmlPackage"; + if(!new File(xmlHistoryDir).exists()) { + new File(xmlHistoryDir).mkdirs(); + } + String xmlHistoryFileName = xmlHistoryDir+"\\"+string + "-传递ERP前一版本.xml"; + fmsFile1.renameTo(new File(xmlHistoryFileName)); + + + dataSet.removeNamedReference("Text"); + String as2[] = {"Text"}; + String as1[] = {xmlPath}; + dataSet.setFiles(as1, as2); + } + } + + public void updateMainExcelByDepts(String myExcelPid,String[] excelpids) throws Exception{ + Date date = new Date(System.currentTimeMillis()); +// System.out.println(date); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); + String string = format.format(date); + + File file = getMainExcelByDepts(excelpids); + + TCComponent comp = session.stringToComponent(myExcelPid); + + + + if(comp instanceof TCComponentDataset) { + System.out.println("是数据集"); + TCComponentDataset dataSet = (TCComponentDataset) comp; + + TCComponentTcFile[] files1 = dataSet.getTcFiles(); + TCComponentTcFile file1 = files1[0]; + File fmsFile1 = file1.getFmsFile(); + String xmlHistoryDir = System.getProperty("java.io.tmpdir").substring(0, + System.getProperty("java.io.tmpdir").length() - 1) + "\\HistoryMainExcelPackage"; + if(!new File(xmlHistoryDir).exists()) { + new File(xmlHistoryDir).mkdirs(); + } + String xmlHistoryFileName = xmlHistoryDir+"\\"+string + "-分类汇总前一版本.xlsx"; + fmsFile1.renameTo(new File(xmlHistoryFileName)); + + dataSet.removeNamedReference("excel"); + String as2[] = {"excel"}; + String as1[] = {file.getAbsolutePath()}; + dataSet.setFiles(as1, as2); + } + } + + public File getMainExcelByDepts(String[] excelpids) throws Exception { + SynAttrXml synAttrXml = new SynAttrXml(); + Date date = new Date(System.currentTimeMillis()); + Set countSet = new HashSet(); +// System.out.println(date); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); + String string = format.format(date); + + String excelPath = System.getProperty("java.io.tmpdir").substring(0, + System.getProperty("java.io.tmpdir").length() - 1) + "\\" + string + "-传ERP.xlsx"; + + for (String excelPid : excelpids) { + TCComponent comp1 = session.stringToComponent(excelPid.split("-")[0]); + TCComponentDataset dataSet1 = (TCComponentDataset) comp1; + TCComponentTcFile[] files = dataSet1.getTcFiles(); + TCComponentTcFile file = files[0]; + File fmsFile = file.getFmsFile(); + System.out.println(excelPid.split("-")[1]+"----"+fmsFile.getAbsolutePath()); + SynAttrXml utill = new SynAttrXml(); + Set set = utill.getClassAttrBeanListByExcel(fmsFile); + + for (AttrBean attrBean : set) { + if("是".equals(attrBean.getIsSendToERP())) { + countSet.add(attrBean); + } + } + } +// + System.out.println("DEBUG=>"+countSet); + List list = synAttrXml.getOrderListBySet(countSet, new MyComparator()); + + for (AttrBean attrBean : list) { + System.out.println("DEBUG==>list"+attrBean); + } + + List newList = new ArrayList(); + int start = 0; + while(start!=-1) { + start = customSort(start, list, newList); + } + System.out.println("---------------------------------"); + + for (AttrBean attrBean : newList) { + System.out.println("DEBUG==>newList"+attrBean); + } + + return getCountSendToERPExcel(newList, excelPath); + + } + + public static File getCountSendToERPExcel(List list,String exportFilepath) throws Exception { + + System.out.println("DEBUG=>"+list); + XSSFWorkbook workbook=new XSSFWorkbook(); + + Sheet sheet=workbook.createSheet(); + + Row row=sheet.createRow(0); + String[] title={"序号","1类","2类","3类","4类","名称","属性中文名","属性ID","属性类型","属性LOV","属性标识","默认值"}; + Cell cell=null; + for (int i=0;i list,List newList) { + ArrayList tempList = new ArrayList(); + AttrBean[] tempArray = new AttrBean[3]; + ArrayList tempArray1 = new ArrayList(); + String className = list.get(start).getClassName(); + for(int i=start;i set =new HashSet(); +// Set set1 =new HashSet(); +// Set set2 =new HashSet(); +// set1.add("123"); +// set2.add("234"); +// set.addAll(set1); +// set.addAll(set2); +// System.out.println(set); +// HashSet set; +// set.add(e) +// Date date = new Date(System.currentTimeMillis()); +// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); +// String string = format.format(date); +// +// +// String xmlHistoryDir = System.getProperty("java.io.tmpdir").substring(0, +// System.getProperty("java.io.tmpdir").length() - 1) + "\\HistoryXmlPackage"; +// new File(xmlHistoryDir).mkdirs(); +// String xmlHistoryFileName = xmlHistoryDir+"\\"+string + "-传递ERP.xml"; +// +// File file = new File("C:\\Users\\xuwubiao\\AppData\\Local\\Temp\\tc_1615787087103.xlsm"); +// file.renameTo(new File(xmlHistoryFileName)); + +// Set set = new HashSet(); +// AttrBean bean = new AttrBean(); +// bean.setClassName("010101-杨天乐"); +// bean.setAttrName("规格(型号)"); +// AttrBean bean1 = new AttrBean(); +// bean1.setClassName("010101-杨天乐"); +// bean1.setAttrName("品牌"); +// AttrBean bean2 = new AttrBean(); +// bean2.setClassName("010101-杨天乐"); +// bean2.setAttrName("订货码(填入)"); +// AttrBean bean3 = new AttrBean(); +// bean3.setClassName("010102-杨天乐"); +// bean3.setAttrName("电压"); +// AttrBean bean4 = new AttrBean(); +// bean4.setClassName("010102-杨天乐"); +// bean4.setAttrName("规格(型号)"); +// AttrBean bean5 = new AttrBean(); +// bean5.setClassName("010102-杨天乐"); +// bean5.setAttrName("品牌"); +// AttrBean bean6 = new AttrBean(); +// bean6.setClassName("010103-杨天乐"); +// bean6.setAttrName("规格(型号)"); +// AttrBean bean7 = new AttrBean(); +// bean7.setClassName("010103-杨天乐"); +// bean7.setAttrName("品牌"); +// set.add(bean); +// set.add(bean1); +// set.add(bean2); +// set.add(bean3); +// set.add(bean4); +// set.add(bean5); +// set.add(bean6); +// set.add(bean7); +// for (AttrBean attrBean : set) { +// System.out.println(attrBean); +// } +// System.out.println("----------------------"); +// SynAttrXml util = new SynAttrXml(); +// List orderList = util.getOrderListBySet(set, new MyComparator()); +// ArrayList newList = new ArrayList(); +// int start =0; +// while(start!=-1) { +// start=customSort(start,orderList,newList); +// } +// +// +// for (int i = 0; i < newList.size(); i++) { +// System.out.println(newList.get(i)); +// } + + + +// +//// SynchPassERPAttrOperation.getCountSendToERPExcel(orderList, +//// "C:\\Users\\xuwubiao\\Desktop\\111测试.xlsx"); +// Set countSet = new HashSet(); +// Set mySet = util.getClassAttrBeanListByExcel(new File("C:\\Users\\xuwubiao\\Desktop\\ERP操作手册\\2021-04-14-05-57-36冻干机-分类属性汇总清单 - 副本.xlsx")); +// Set sysSet = util.getClassAttrBeanListByExcel(new File("C:\\Users\\xuwubiao\\Desktop\\ERP操作手册\\2021-04-14-05-57-36冻干机-分类属性汇总清单.xlsx")); +// System.out.println("获得完成!"); +// Iterator myIterator = mySet.iterator(); +// +// System.out.println("开始去除我的表格中多余的项!"); +// +// while(myIterator.hasNext()) { +// AttrBean next = myIterator.next(); +// Boolean flag = false; +// for (AttrBean attrBean : sysSet) { +// if(next.getClassName().substring(0, 6).equals(attrBean.getClassName().substring(0, 6))) { +// if(next.getAttrId().equals(attrBean.getAttrId())) { +// flag = true; +// next.setFirstClass(attrBean.getFirstClass()); +// next.setSecondClass(attrBean.getSecondClass()); +// next.setThirdClass(attrBean.getThirdClass()); +// next.setClassName(attrBean.getClassName()); +// next.setAttrName(attrBean.getAttrName()); +// next.setAttrType(attrBean.getAttrType()); +// next.setIsLov(attrBean.getIsLov()); +// next.setUnitDefaultValue(attrBean.getUnitDefaultValue()); +// } +// } +// } +// if(!flag) { +// System.out.println("移除-----------:"+next); +// myIterator.remove(); +// } +// } +// +// System.out.println("去除完成!"); +// +//// for (AttrBean attrBean : mySet) { +//// System.out.println("DEBUG==>mySet:"+attrBean); +//// } +// +// System.out.println("开始整合是否传递ERP属性值"); +// countSet.addAll(sysSet); +// countSet.addAll(mySet); +// +// +// +// System.out.println("去除完成!"); +// +// System.out.println("countSet.size-----"+countSet.size()); +// +//// for (AttrBean attrBean : countSet) { +//// +//// System.out.println("DEBUG==>countSet:"+attrBean); +//// } +// +// List countList = util.getOrderListBySet(countSet, new MyComparator()); +// System.out.println("countList.size-" +// + "---"+countList.size()); +// +//// for (AttrBean attrBean : countList) { +//// System.out.println("DEBUG==>countList:"+attrBean); +//// } +// +// ArrayList newList = new ArrayList(); +// int start = 0; +// while(start!=-1) { +// start = customSort(start, countList, newList); +// } +// +//// for (AttrBean attrBean : newList) { +//// System.out.println("DEBUG==>newList:"+attrBean); +//// } +// +// System.out.println("----将countList转换成xlsx表"); +// File toERPExcel = GetLatestExcelOperation.getCountSendToERPExcel(newList, "C:\\Users\\xuwubiao\\Desktop\\123测试.xlsx"); +// + + Date date = new Date(); + System.out.println(date); + } + + public static int customSort(int start,List list,List newList) { + ArrayList tempList = new ArrayList(); + AttrBean[] tempArray = new AttrBean[3]; + ArrayList tempArray1 = new ArrayList(); + String className = list.get(start).getClassName(); + for(int i=start;i(); + AttrBean bean1 = new AttrBean(); + bean1.setIsSendToERP("是"); + AttrBean bean2 = new AttrBean(); + set.add(bean2); + set.add(bean1); + System.out.println(set); + } +} diff --git a/src/com/connor/dfl/plm/dfl036/TimerManager.java b/src/com/connor/dfl/plm/dfl036/TimerManager.java new file mode 100644 index 0000000..4db9f0c --- /dev/null +++ b/src/com/connor/dfl/plm/dfl036/TimerManager.java @@ -0,0 +1,41 @@ +package com.connor.dfl.plm.dfl036; + +import java.util.Calendar; +import java.util.Date; +import java.util.Timer; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCSession; + +public class TimerManager { + private AbstractAIFUIApplication app; + private InterfaceAIFComponent[] targets; + private TCSession session; + private static final long PERIOD_DAY = 2 * 60 * 60 * 1000; + public TimerManager(AbstractAIFUIApplication app, InterfaceAIFComponent[] targets, TCSession session) { + + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.HOUR_OF_DAY, 20); //凌晨2点 + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + Date date=calendar.getTime(); //第一次执行定时任务的时间 + //如果第一次执行定时任务的时间 小于当前的时间 + //此时要在 第一次执行定时任务的时间加一天,以便此任务在下个时间点执行。如果不加一天,任务会立即执行。 + if (date.before(new Date())) { + date = this.addDay(date, 1); + } + Timer timer = new Timer(); + Task task = new Task(app,targets,session); + //安排指定的任务在指定的时间开始进行重复的固定延迟执行。 + timer.schedule(task,date,PERIOD_DAY); + } + // 增加或减少天数 + public Date addDay(Date date, int num) { + Calendar startDT = Calendar.getInstance(); + startDT.setTime(date); + startDT.add(Calendar.DAY_OF_MONTH, num); + return startDT.getTime(); + + } +} diff --git a/src/com/connor/dfl/plm/dfl037/CNClassPropBean.java b/src/com/connor/dfl/plm/dfl037/CNClassPropBean.java new file mode 100644 index 0000000..eb5793c --- /dev/null +++ b/src/com/connor/dfl/plm/dfl037/CNClassPropBean.java @@ -0,0 +1,59 @@ +package com.connor.dfl.plm.dfl037; + +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 CNClassPropBean { + public int propID; + public String propDisName; + public String relValue; + public String displayValue; + public String annotation; + public String defaultValue; + 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 CNClassPropBean(ICSAdminClassAttribute icsAttr) { + 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(); + this.annotation = icsAttr.getAnnotation(); + this.defaultValue = icsAttr.getDefaultValue(); + 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); + } + } else { + this.isLov = false; + } + } + @Override + public String toString() { + return propDisName + ":"; + } + +} diff --git a/src/com/connor/dfl/plm/dfl037/Classbean.java b/src/com/connor/dfl/plm/dfl037/Classbean.java new file mode 100644 index 0000000..108e8be --- /dev/null +++ b/src/com/connor/dfl/plm/dfl037/Classbean.java @@ -0,0 +1,21 @@ +package com.connor.dfl.plm.dfl037; + +public class Classbean { + + private String id; + private String 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; + } + + +} diff --git a/src/com/connor/dfl/plm/dfl037/ExcelBean.java b/src/com/connor/dfl/plm/dfl037/ExcelBean.java new file mode 100644 index 0000000..2e4daf5 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl037/ExcelBean.java @@ -0,0 +1,29 @@ +package com.connor.dfl.plm.dfl037; + +import java.util.List; + +public class ExcelBean { + private int no; + private List list; + private CNClassPropBean cpbean; + public int getNo() { + return no; + } + public void setNo(int no) { + this.no = no; + } + public List getList() { + return list; + } + public void setList(List list) { + this.list = list; + } + public CNClassPropBean getCpbean() { + return cpbean; + } + public void setCpbean(CNClassPropBean cpbean) { + this.cpbean = cpbean; + } + + +} diff --git a/src/com/connor/dfl/plm/dfl037/ExportDialog.java b/src/com/connor/dfl/plm/dfl037/ExportDialog.java new file mode 100644 index 0000000..3d9a231 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl037/ExportDialog.java @@ -0,0 +1,164 @@ +package com.connor.dfl.plm.dfl037; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class ExportDialog extends AbstractAIFDialog{ + private static final long serialVersionUID = -8317156384208344816L; + private AbstractAIFApplication app; + private TCSession session; + private JPanel rootPanel; + private JPanel panel1; + private JPanel panel2; + private JButton okButton; + private JButton celButton; + private JButton fileButton; + private JTextField pathText; + private JFileChooser jfc; + private JTextField projCode; + + public ExportDialog(AbstractAIFApplication app) { + super(false); + this.app = app; + this.session = (TCSession) this.app.getSession(); + } + + @Override + public void run() { + init(); + } + + public void init() { + this.setTitle("导出分类清单"); + String path = FileSystemView.getFileSystemView().getHomeDirectory() + .getAbsolutePath(); + this.setPreferredSize(new Dimension(470, 160)); + jfc = new JFileChooser(); + jfc.setCurrentDirectory(new File(path));// 文件选择器的初始目录定为桌面 + okButton = new JButton("确定"); + celButton = new JButton("取消"); + fileButton = new JButton("..."); + + fileButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + selectFileButtonEvent(e); + } + }); + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + okEvent(e); + } + }); + celButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + celEvent(e); + } + }); + + pathText = new JTextField(30); + pathText.setText(path); + projCode = new JTextField(15); + + panel1 = new JPanel(new PropertyLayout()); + + panel1.add("1.1.right.top.preferred.preferred", new JLabel(" ")); + panel1.add("2.1.right.top.preferred.preferred", new JLabel("分类ID:")); + panel1.add("2.2.left.top.preferred.preferred", projCode); + panel1.add("3.1.right.top.preferred.preferred", new JLabel("选择文件夹:")); + panel1.add("3.2.left.top.preferred.preferred", pathText); + panel1.add("3.3.left.top.preferred.preferred", fileButton); + + panel2 = new JPanel(new FlowLayout()); + panel2.add(okButton); + panel2.add(new JLabel(" ")); + panel2.add(celButton); + + rootPanel = new JPanel(new BorderLayout()); + rootPanel.add(panel1, BorderLayout.CENTER); + rootPanel.add(panel2, BorderLayout.SOUTH); + + this.add(rootPanel, "Center"); + this.centerToScreen(1.0D, 0.75D); + this.pack(); + this.setResizable(false); + this.setVisible(true); + // this.centerToScreen(); + // this.showDialog(); + + } + + /** + * 文件夹选择按钮事件 + * + * @param e + */ + public void selectFileButtonEvent(ActionEvent e) { + jfc.setFileSelectionMode(1);// 设定只能选择到文件夹 + int state = jfc.showOpenDialog(null);// 此句是打开文件选择器界面的触发语句 + if (state == 1) { + return; + } else { + File f = jfc.getSelectedFile();// f为选择到的目录 + pathText.setText(f.getAbsolutePath()); + } + } + + /** + * 添加导出逻辑 + * + * @param e + */ + public void okEvent(ActionEvent e) { + try { + + + File tempFile = new File(pathText.getText()); + if (tempFile.exists() && tempFile.isDirectory()) { + this.dispose(); + ExportOperation operation=new ExportOperation(app, session,pathText.getText(),projCode.getText()); + //operation.executeOperation(); + session.queueOperation(operation); + + } else { + MessageBox.post("请选择导出目录", "Error", MessageBox.ERROR); + } + } catch (Exception e1) { + e1.printStackTrace(); + MessageBox.post("导出清单失败", "Error", MessageBox.ERROR); + } + + } + + /** + * 添加取消逻辑 + * + * @param e + */ + public void celEvent(ActionEvent e) { + this.dispose(); + } + +} diff --git a/src/com/connor/dfl/plm/dfl037/ExportHandler.java b/src/com/connor/dfl/plm/dfl037/ExportHandler.java new file mode 100644 index 0000000..e2d4a7a --- /dev/null +++ b/src/com/connor/dfl/plm/dfl037/ExportHandler.java @@ -0,0 +1,35 @@ +package com.connor.dfl.plm.dfl037; + +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; + + +/** + * Our sample handler extends AbstractHandler, an IHandler base class. + * + * @see org.eclipse.core.commands.IHandler + * @see org.eclipse.core.commands.AbstractHandler + */ +public class ExportHandler extends AbstractHandler { + /** + * The constructor. + */ + public ExportHandler() { + } + + /** + * the command has been executed, so extract extract the needed information + * from the application context. + */ + public Object execute(ExecutionEvent event) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + + + new Thread(new ExportDialog(app)).start(); + return null; + } +} diff --git a/src/com/connor/dfl/plm/dfl037/ExportOperation.java b/src/com/connor/dfl/plm/dfl037/ExportOperation.java new file mode 100644 index 0000000..21268b7 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl037/ExportOperation.java @@ -0,0 +1,324 @@ +package com.connor.dfl.plm.dfl037; + +import java.awt.Desktop; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.swing.JOptionPane; + +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.dfl.plm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCException; +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.ICSHierarchyNodeDescriptor; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.soaictstubs.booleanSeq_tHolder; + +public class ExportOperation extends AbstractAIFOperation { + private TCSession session; + private AbstractAIFApplication app; + + private ProgressBarThread wait; + + private String path; + private String classid; + private File file; + + private int levmax = 1; + private Boolean isMerge = false; + + + private TCClassificationService classificationService; + + private List excelList = new ArrayList(); + + public ExportOperation(AbstractAIFApplication app, TCSession session, + String path, String classid) { + this.session = session; + this.app = app; + this.path = path; + this.classid = classid; + } + + public ExportOperation(AbstractAIFApplication app, TCSession session, + String path, String classid,Boolean isMerge) { + this.session = session; + this.app = app; + this.path = path; + this.classid = classid; + this.isMerge = isMerge; + } + + @Override + public void executeOperation() throws Exception { + if(!isMerge) { + wait = new ProgressBarThread("数据导出", "数据导出中,请稍等..."); + wait.start();// 开启进度条 + System.out.println("不开起进度条"); + } + + getClassPro(); + + try { + //setByPass(session, true); + TCUserService userService = this.session.getUserService(); + + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");// 设置日期格式 + String time = df.format(new Date()); + String outPutFile = null; + if(isMerge) { + Date date = new Date(System.currentTimeMillis()); +// System.out.println(date); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); + String string = format.format(date); + outPutFile = System.getProperty("java.io.tmpdir").substring(0, System.getProperty("java.io.tmpdir").length()-1)+"\\"+string+"-分类属性汇总清单-系统现存.xlsx"; + + }else { + outPutFile = path + File.separator + "分类清单" + time + ".xlsx"; + } + + // 写入数据 + System.out.println("outPutFile=" + outPutFile); + File dest = new File(outPutFile); + writeExcel(outPutFile); + file = dest; + if(!isMerge) { + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + } + //setByPass(session, false); + if(!isMerge) { + int select = JOptionPane.showConfirmDialog(null, "文件已创建在【" + + outPutFile + "】下,是否打开", "提示", JOptionPane.YES_NO_OPTION); + if (select == JOptionPane.YES_OPTION) { + Desktop.getDesktop().open(dest); + } + } + + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + //setByPass(session, false); + if(!isMerge) { + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + } + MessageBox.post("生成报表失败" + e.getMessage(), "错误", MessageBox.ERROR); + } + + + } + + private void getClassPro() { + // TODO Auto-generated method stub + if (classid.equals("")) { + classid = "ICM"; + } + System.out.println("classid="+classid); + classificationService = session.getClassificationService(); + dgChildClass(classid, 1, new ArrayList()); + + } + + // ,Map map + /** + * 递归分类层级 + * + * @param classid2 + * @param lev + */ + private void dgChildClass(String classid2, int lev, List list) { + // TODO Auto-generated method stub + + try { + if (levmax < lev) { + levmax = lev; + } + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(classid2); + System.out.println("id=" + c.getId()); + System.out.println("name=" + c.getName()); + Classbean classbean = new Classbean(); + classbean.setId(c.getId()); + classbean.setName(c.getName()); + List list2 = new ArrayList(); + for (int i = 0; i < list.size(); i++) { + list2.add(list.get(i)); + } + list2.add(classbean); + ICSHierarchyNodeDescriptor[] dss = classificationService + .getChildren(classid2, true, true, 0, 0); + if (dss != null && dss.length > 0) { + for (int i = 0; i < dss.length; i++) { + System.out.println("name=" + dss[i].getName()); + System.out.println("id=" + dss[i].getId()); + dgChildClass(dss[i].getId(), lev + 1, list2); + + } + } else { + ICSAdminClassAttribute[] attributes = c.getAttributes(); + if (attributes != null && attributes.length > 0) { + for (int i = 0; i < attributes.length; i++) { + CNClassPropBean bean = new CNClassPropBean( + attributes[i]); + System.out.println("bean=" + bean); + ExcelBean excelbean = new ExcelBean(); + excelbean.setCpbean(bean); + excelbean.setList(list2); + excelList.add(excelbean); + } + + } + + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private void writeExcel( String outPutFile) { + // TODO Auto-generated method stub + + try { + + XSSFWorkbook wb = new XSSFWorkbook(); + XSSFSheet sheet = wb.createSheet("分类属性"); + XSSFCellStyle style = wb.createCellStyle(); + style.setAlignment(XSSFCellStyle.ALIGN_CENTER); + XSSFRow rowfist = sheet.getRow(0); + if (rowfist == null) { + rowfist = sheet.createRow(0); + } + for (int j = 0; j < levmax + 7; j++) { + + XSSFCell cell = rowfist.getCell(j); + if (cell == null) { + cell = rowfist.createCell(j); + } + cell.setCellStyle(style); + if (j == 0) { + cell.setCellValue("序号"); + } else if (j == levmax) { + cell.setCellValue("名称"); + } else if (j == levmax + 1) { + cell.setCellValue("属性中文名"); + } else if (j == levmax + 2) { + cell.setCellValue("属性ID"); + } else if (j == levmax + 3) { + cell.setCellValue("属性类型"); + }else if (j == levmax + 4) { + cell.setCellValue("属性LOV"); + } else if (j == levmax + 5) { + cell.setCellValue("属性标识"); + }else if (j == levmax + 6) { + cell.setCellValue("默认值"); + }else { + int li = j; + cell.setCellValue(li + "类"); + } + + } + int no = 1; + for (int i = 0; i < excelList.size(); i++) { + XSSFRow row = sheet.getRow(no); + if (row == null) { + row = sheet.createRow(no); + } + ExcelBean excelbean = excelList.get(i); + CNClassPropBean cpbean = excelbean.getCpbean(); + List list = excelbean.getList(); + + String propDisName = cpbean.propDisName; + int propID = cpbean.propID; + int attrType = cpbean.attrType; + boolean isLov = cpbean.isLov; + String isLovstr = ""; + String annotation = cpbean.annotation; + String defaultValue = cpbean.defaultValue; + if (isLov) { + isLovstr = "是"; + } + if (list.size() > 0) { + for (int j = 0; j < list.size() + 7; j++) { + + XSSFCell cell = row.getCell(j); + if (cell == null) { + cell = row.createCell(j); + } + cell.setCellStyle(style); + if (j == 0) { + cell.setCellValue(no); + } else if (j == levmax + 1) { + cell.setCellValue(propDisName); + } else if (j == levmax + 2) { + cell.setCellValue(propID); + } else if (j == levmax + 3) { + cell.setCellValue(attrType); + } else if (j == levmax + 4) { + cell.setCellValue(isLovstr); + }else if (j == levmax + 5) { + cell.setCellValue(annotation); + }else if (j == levmax + 6) { + cell.setCellValue(defaultValue); + }else if(j<=list.size()){ + String className = list.get(j - 1).getName(); + cell.setCellValue(className); + } + + } + } + + no++; + + } + FileOutputStream output = new FileOutputStream(new File(outPutFile)); + wb.write(output); + output.close(); + + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + // java调C 开关bypass + public void setByPass(TCSession session, boolean val) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = "origin"; + if (val) { + userservice.call("ORIGIN_set_bypass", obj); + } else { + userservice.call("ORIGIN_close_bypass", obj); + } + } + + public File getFile() { + return file; + } + +} diff --git a/src/com/connor/dfl/plm/dfl037/GetLatestExcelHandler.java b/src/com/connor/dfl/plm/dfl037/GetLatestExcelHandler.java new file mode 100644 index 0000000..e486cd8 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl037/GetLatestExcelHandler.java @@ -0,0 +1,30 @@ +package com.connor.dfl.plm.dfl037; + +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.TCSession; + +public class GetLatestExcelHandler extends AbstractHandler{ + + private AbstractAIFUIApplication app; + private InterfaceAIFComponent[] targets; + private TCSession session; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + this.session = (TCSession) app.getSession(); + this.targets = app.getTargetComponents(); + new TimerManager(app, targets, session); + System.out.println("开启定时,于晚上12点进行更新"); +// GetLatestExcelOperation operation = new +// GetLatestExcelOperation(targets,session,app); +// session.queueOperation(operation); System.out.println("获取最新"); + return null; + } + +} diff --git a/src/com/connor/dfl/plm/dfl037/GetLatestExcelOperation.java b/src/com/connor/dfl/plm/dfl037/GetLatestExcelOperation.java new file mode 100644 index 0000000..b26b536 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl037/GetLatestExcelOperation.java @@ -0,0 +1,543 @@ +package com.connor.dfl.plm.dfl037; + +import java.awt.Desktop; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.charset.Charset; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map.Entry; +import java.util.Set; + +import javax.swing.JOptionPane; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.output.FileWriterWithEncoding; +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.xssf.usermodel.XSSFWorkbook; + +import com.connor.dfl.plm.dfl036.AttrBean; +import com.connor.dfl.plm.dfl036.MyComparator; +import com.connor.dfl.plm.dfl036.SynAttrXml; +import com.connor.dfl.plm.util.ProgressBarThread; +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.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.MessageBox; + +import oracle.net.aso.s; + +public class GetLatestExcelOperation extends AbstractAIFOperation{ + + private InterfaceAIFComponent[] targets; + private TCSession session; + private AbstractAIFUIApplication app; + private TCClassificationService classificationService; + private TCTypeService service; + private TCComponentBOMWindowType winType; + private TCComponentItemType itemType; + private ProgressBarThread wait; + private Boolean isMyExcel = true; + private BufferedWriter writer; + private File sysFile; +// = new File("C:\\Users\\poul-ytl\\Desktop\\2021-06-24-07-07-09-分类属性汇总清单-系统现存.xlsx"); + + public GetLatestExcelOperation(InterfaceAIFComponent[] targets, TCSession session, AbstractAIFUIApplication app) { + super(); + this.session = session; + this.app = app; + this.targets = targets; + classificationService = session.getClassificationService(); + Date date = new Date(System.currentTimeMillis()); +// System.out.println(date); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); + String string = format.format(date); + String path1 = System.getProperty("java.io.tmpdir").substring(0, System.getProperty("java.io.tmpdir").length()-1)+"\\"+string+"-批量更新传ERP的Excel表.log"; + + + try { + writer = new BufferedWriter(new FileWriter(new File(path1))); + } catch (IOException e) { + // TODO Auto-generated catch block + System.out.println("日志文件路径错误"); + e.printStackTrace(); + return; + } + + + } + + @Override + public void executeOperation() throws Exception { + + +// 3、获取首选项里面的值并转化为数组 + String[] excelArrays=session.getPreferenceService().getStringValues("DFL_CLASS_Other_Excel"); + + + if (excelArrays == null || excelArrays.length <= 0) { + writer.write("首选项配置错误,请检查首选项名称是否为【DFL_CLASS_Other_Excel】"); + writer.newLine(); + if(writer!=null) { + writer.close(); + } + return; + } + + + for(int i=0;i utill = new SynAttrXml(); + Set countSet = new HashSet(); + + System.out.println("开始获取系统与自己表格中的属性Bean"); + Set sysSet = utill.getClassAttrBeanListByExcel(sysFile); +// Set mySet = utill.getClassAttrBeanListByExcel(new File(xmlHistoryFileName)); + System.out.println("获得完成!"); +// Iterator myIterator = mySet.iterator(); + +// System.out.println("开始去除我的表格中多余的项!"); + +// while(myIterator.hasNext()) { +// AttrBean next = myIterator.next(); +// Boolean flag = false; +// for (AttrBean attrBean : sysSet) { +// if(next.getClassName().substring(0, 6).equals(attrBean.getClassName().substring(0, 6))) { +// if(next.getAttrId().equals(attrBean.getAttrId())) { +// flag = true; +// next.setFirstClass(attrBean.getFirstClass()); +// next.setSecondClass(attrBean.getSecondClass()); +// next.setThirdClass(attrBean.getThirdClass()); +// next.setClassName(attrBean.getClassName()); +// next.setAttrName(attrBean.getAttrName()); +// next.setAttrType(attrBean.getAttrType()); +// next.setIsLov(attrBean.getIsLov()); +// next.setUnitDefaultValue(attrBean.getUnitDefaultValue()); +// } +// } +// } +// if(!flag) { +// System.out.println("移除-----------:"+next); +// myIterator.remove(); +// } +// } + +// System.out.println("去除完成!"); + +// for (AttrBean attrBean : mySet) { +// if(attrBean.getIsSendToERP()!=null && attrBean.getIsSendToERP().contains("是")) { +// System.out.println("DEBUG=>:mySet"+attrBean); +// +// System.exit(0); +// } +// +// } + +// for (AttrBean attrBean : sysSet) { +// if(attrBean.getIsSendToERP()!=null && attrBean.getIsSendToERP().contains("是")) { +// System.out.println("DEBUG=>:sysSet"+attrBean); +// +// System.exit(0); +// } +// +// } + + System.out.println("开始整合是否传递ERP属性值"); +// countSet.addAll(mySet); + countSet.addAll(sysSet); + + + +// System.out.println("去除完成!"); + + System.out.println("countSet.size-----"+countSet.size()); + +// for (AttrBean attrBean : countSet) { +// if("是".equals(attrBean.getIsSendToERP())) { +// System.out.println("DEBUG=>:countSet"+attrBean); +// System.exit(0); +// } +// +// } + + List countList = utill.getOrderListBySet(countSet, new MyComparator()); + System.out.println("countList.size-" + + "---"+countList.size()); + +// for (AttrBean attrBean : countList) { +// System.out.println("DEBUG==>countList:"+attrBean); +// } + + ArrayList newList = new ArrayList(); + int start = 0; + while(start!=-1) { + start = customSort(start, countList, newList); + } + + for (AttrBean attrBean : newList) { +// System.out.println("DEBUG==>newList:"+attrBean); + attrBean.setIsSendToERP("是"); + } + + System.out.println("----将countList转换成xlsx表"); + + File toERPExcel = getCountSendToERPExcel(newList, path); + System.out.println("----转换完成"); + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + + dataSet.removeNamedReference("excel"); + String as2[] = {"excel"}; + String as1[] = {toERPExcel.getAbsolutePath()}; + dataSet.setFiles(as1, as2); + + System.out.println("uid为【"+uid+"】的数据集生成成功!"); + writer.write("uid为【"+uid+"】的数据集生成成功!"); + writer.newLine(); + + + String xmlPath = System.getProperty("java.io.tmpdir").substring(0, + System.getProperty("java.io.tmpdir").length() - 1) + "\\" + string + "-传递ERP.xml"; + + + String[] stringArrays = null; + try { + stringArrays=session.getPreferenceService().getStringValues("DFL_CLASS_Xml1"); + System.out.println("Xml--------"+stringArrays[0]); + } catch (NullPointerException e) { + // TODO: handle exception + e.printStackTrace(); + MessageBox.post("首选项配置有误", "提示", MessageBox.INFORMATION); + return; + } + try { + getERPXmlByERPExcel(newList,stringArrays[0]); + MessageBox.post("生成成功!", "提示", MessageBox.INFORMATION); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post("生成传ERP的xml失败", "提示", MessageBox.ERROR); + e.printStackTrace(); + } + System.out.println("获取传递ERP属性XML"); + + } catch (Exception e) { + // TODO Auto-generated catch block + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + writer.write("uid为【"+uid+"】的数据集生成失败!"); + writer.newLine(); + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + + + + + } + + public static File getCountSendToERPExcel(List list,String exportFilepath) throws Exception { + + System.out.println("DEBUG=>"+list); + XSSFWorkbook workbook=new XSSFWorkbook(); + + Sheet sheet=workbook.createSheet(); + + Row row=sheet.createRow(0); + String[] title={"序号","1类","2类","3类","4类","名称","属性中文名","属性ID","属性类型","属性LOV","属性标识","默认值"};; + Cell cell=null; + for (int i=0;i list,List newList) { + ArrayList tempList = new ArrayList(); + AttrBean[] tempArray = new AttrBean[3]; + ArrayList tempArray1 = new ArrayList(); + String className = list.get(start).getClassName(); + for(int i=start;i excelList,String xmlPid) throws Exception { + Date date = new Date(System.currentTimeMillis()); +// System.out.println(date); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); + String string = format.format(date); + + String xmlPath = System.getProperty("java.io.tmpdir").substring(0, + System.getProperty("java.io.tmpdir").length() - 1) + "\\" + string + "-传递ERP.xml"; + + + getXmlBySet(xmlPath,excelList); + + + TCComponent comp = session.stringToComponent(xmlPid); + + if(comp instanceof TCComponentDataset) { + System.out.println("是数据集"); + TCComponentDataset dataSet = (TCComponentDataset) comp; + //将历史版本的文件保留 + TCComponentTcFile[] files1 = dataSet.getTcFiles(); + TCComponentTcFile file1 = files1[0]; + File fmsFile1 = file1.getFmsFile(); + + String xmlHistoryDir = System.getProperty("java.io.tmpdir").substring(0, + System.getProperty("java.io.tmpdir").length() - 1) + "\\HistoryXmlPackage"; + if(!new File(xmlHistoryDir).exists()) { + new File(xmlHistoryDir).mkdirs(); + } + String xmlHistoryFileName = xmlHistoryDir+"\\"+string + "-传递ERP前一版本.xml"; + fmsFile1.renameTo(new File(xmlHistoryFileName)); + + + dataSet.removeNamedReference("Text"); + String as2[] = {"Text"}; + String as1[] = {xmlPath}; + dataSet.setFiles(as1, as2); + } + } + + public void getXmlBySet(String exportFilePath,List list){ + SynAttrXml util = new SynAttrXml(); + + try { + Charset encoding = Charset.forName("utf-8"); + BufferedWriter writer = new BufferedWriter(new FileWriterWithEncoding(new File(exportFilePath),encoding)); + writer.write(""); + writer.newLine(); + writer.write(""); + writer.newLine(); + writer.write(""); + writer.newLine(); + writer.write("\t"); + writer.newLine(); + + int i=0; + String className = "初始化"; + + for (AttrBean bean: + list) { + String className1=null; + if(Integer.valueOf(bean.getClassName().substring(0, 2))>=10 && Integer.valueOf(bean.getClassName().substring(0, 2))<=24) { + className1= "ICM0102"+list.get(i++).getClassName().split("-")[0]; + }else { + className1= "ICM0101"+list.get(i++).getClassName().split("-")[0]; + } + if("初始化".equals(className)){ + className = className1; + writer.write("\t\t"); + writer.newLine(); + writer.write("\t\t\t"); + writer.newLine(); + }else if(!className.equals(className1)){ +// System.out.println("不相等了"); + writer.write("\t\t"); + writer.newLine(); + className = className1; + writer.write("\t\t"); + writer.newLine(); + writer.write("\t\t\t"); + writer.newLine(); + }else{ + writer.write("\t\t\t"); + writer.newLine(); + } + } + writer.write("\t\t"); + writer.newLine(); + + writer.write("\t"); + writer.newLine(); + writer.write(""); + writer.newLine(); + + writer.flush(); + writer.close(); + }catch (Exception e){ + e.printStackTrace(); + } + + } + + +} diff --git a/src/com/connor/dfl/plm/dfl037/Task.java b/src/com/connor/dfl/plm/dfl037/Task.java new file mode 100644 index 0000000..8ee7b24 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl037/Task.java @@ -0,0 +1,32 @@ +package com.connor.dfl.plm.dfl037; + +import java.util.TimerTask; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCSession; + +public class Task extends TimerTask{ + + private AbstractAIFUIApplication app; + private InterfaceAIFComponent[] targets; + private TCSession session; + + public Task(AbstractAIFUIApplication app, InterfaceAIFComponent[] targets, TCSession session) { + super(); + this.app = app; + this.targets = targets; + this.session = session; + } + + @Override + public void run() { + // TODO Auto-generated method stub + GetLatestExcelOperation operation = new GetLatestExcelOperation(targets,session,app); + session.queueOperation(operation); + + } + + + +} diff --git a/src/com/connor/dfl/plm/dfl037/TimerManager.java b/src/com/connor/dfl/plm/dfl037/TimerManager.java new file mode 100644 index 0000000..cfb9f1c --- /dev/null +++ b/src/com/connor/dfl/plm/dfl037/TimerManager.java @@ -0,0 +1,42 @@ +package com.connor.dfl.plm.dfl037; + +import java.util.Calendar; +import java.util.Date; +import java.util.Timer; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCSession; + +public class TimerManager { + + private AbstractAIFUIApplication app; + private InterfaceAIFComponent[] targets; + private TCSession session; + private static final long PERIOD_DAY = 2 * 60 * 60 * 1000; + public TimerManager(AbstractAIFUIApplication app, InterfaceAIFComponent[] targets, TCSession session) { + + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.HOUR_OF_DAY, 18); //下午18点 ,隔2小时执行一次 + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + Date date=calendar.getTime(); //第一次执行定时任务的时间 + //如果第一次执行定时任务的时间 小于当前的时间 + //此时要在 第一次执行定时任务的时间加一天,以便此任务在下个时间点执行。如果不加一天,任务会立即执行。 + if (date.before(new Date())) { + date = this.addDay(date, 1); + } + Timer timer = new Timer(); + Task task = new Task(app,targets,session); + //安排指定的任务在指定的时间开始进行重复的固定延迟执行。 + timer.schedule(task,date,PERIOD_DAY); + } + // 增加或减少天数 + public Date addDay(Date date, int num) { + Calendar startDT = Calendar.getInstance(); + startDT.setTime(date); + startDT.add(Calendar.DAY_OF_MONTH, num); + return startDT.getTime(); + + } +} diff --git a/src/com/connor/dfl/plm/dfl038/ChangeBean.java b/src/com/connor/dfl/plm/dfl038/ChangeBean.java new file mode 100644 index 0000000..8c698d5 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl038/ChangeBean.java @@ -0,0 +1,185 @@ +package com.connor.dfl.plm.dfl038; + +public class ChangeBean { + + + // DFL_CHANGEFORM DFL_CHANGEDETAILS 数据库表名 + + private String applyName;//申请人 + private String ChangeListCode ;//变更单号 + //private String objectCode;//对象id + private String applyDate;//申请时间 + + + //private String productDepartment;//所属产品部 + private String productName;//产品名称 + private String projectModel;//产品型号 + private String clientNae;//客户名称 + private String warehouseCode;//仓库编号 + private String NotifyEmergencyProcedures;//通知紧急程度 + private String TZChangeType;//图纸更改类型 + private String SUOSU_ProductDepartment;//所属产品部 + private String dutyDepartment;//责任部门 + private String dutyMan;//责任人 + private String changeType;//更改类型 + private String productType;//产品类型 + private String errorType;//错误类型 + private String priceBooking;//价格预售 + private String salseClassify;//销售分类 + private String isNotProductLoss;//是否产生成本损失 + private String projectState;//项目阶段 + private String receiveClassify;//料件领用分类 + private String drawingTo;//图纸发至 + + //private String affectedPart;//受影响的设备/零部件 + private String projectCode;//项目编号 + private String changeReason;//更改原因 + private String accountSet;//账套 + + public String getProjectState() { + return projectState; + } + public void setProjectState(String projectState) { + this.projectState = projectState; + } + public String getSUOSU_ProductDepartment() { + return SUOSU_ProductDepartment; + } + public void setSUOSU_ProductDepartment(String sUOSU_ProductDepartment) { + SUOSU_ProductDepartment = sUOSU_ProductDepartment; + } + public String getTZChangeType() { + return TZChangeType; + } + public void setTZChangeType(String tZChangeType) { + TZChangeType = tZChangeType; + } + public String getChangeListCode() { + return ChangeListCode; + } + public void setChangeListCode(String changeListCode) { + ChangeListCode = changeListCode; + } + public String getApplyName() { + return applyName; + } + public void setApplyName(String applyName) { + this.applyName = applyName; + } + public String getApplyDate() { + return applyDate; + } + public void setApplyDate(String applyDate) { + this.applyDate = applyDate; + } + public String getProjectCode() { + return projectCode; + } + public void setProjectCode(String projectCode) { + this.projectCode = projectCode; + } + public String getClientNae() { + return clientNae; + } + public void setClientNae(String clientNae) { + this.clientNae = clientNae; + } + + public String getProductName() { + return productName; + } + public void setProductName(String productName) { + this.productName = productName; + } + public String getProjectModel() { + return projectModel; + } + public void setProjectModel(String projectModel) { + this.projectModel = projectModel; + } + public String getChangeType() { + return changeType; + } + + public void setChangeType(String changeType) { + this.changeType = changeType; + } + public String getProductType() { + return productType; + } + public void setProductType(String productType) { + this.productType = productType; + } + public String getErrorType() { + return errorType; + } + public void setErrorType(String errorType) { + this.errorType = errorType; + } + public String getDutyDepartment() { + return dutyDepartment; + } + public void setDutyDepartment(String dutyDepartment) { + this.dutyDepartment = dutyDepartment; + } + public String getDutyMan() { + return dutyMan; + } + public void setDutyMan(String dutyMan) { + this.dutyMan = dutyMan; + } + public String getChangeReason() { + return changeReason; + } + public void setChangeReason(String changeReason) { + this.changeReason = changeReason; + } + public String getSalseClassify() { + return salseClassify; + } + public void setSalseClassify(String salseClassify) { + this.salseClassify = salseClassify; + } + public String getPriceBooking() { + return priceBooking; + } + public void setPriceBooking(String priceBooking) { + this.priceBooking = priceBooking; + } + public String getIsNotProductLoss() { + return isNotProductLoss; + } + public void setIsNotProductLoss(String isNotProductLoss) { + this.isNotProductLoss = isNotProductLoss; + } + public String getReceiveClassify() { + return receiveClassify; + } + public void setReceiveClassify(String receiveClassify) { + this.receiveClassify = receiveClassify; + } + public String getWarehouseCode() { + return warehouseCode; + } + public void setWarehouseCode(String warehouseCode) { + this.warehouseCode = warehouseCode; + } + public String getAccountSet() { + return accountSet; + } + public void setAccountSet(String accountSet) { + this.accountSet = accountSet; + } + public String getNotifyEmergencyProcedures() { + return NotifyEmergencyProcedures; + } + public void setNotifyEmergencyProcedures(String notifyEmergencyProcedures) { + NotifyEmergencyProcedures = notifyEmergencyProcedures; + } + public String getDrawingTo() { + return drawingTo; + } + public void setDrawingTo(String drawingTo) { + this.drawingTo = drawingTo; + } +} diff --git a/src/com/connor/dfl/plm/dfl038/DateChooser.java b/src/com/connor/dfl/plm/dfl038/DateChooser.java new file mode 100644 index 0000000..586a495 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl038/DateChooser.java @@ -0,0 +1,1391 @@ +package com.connor.dfl.plm.dfl038; + +import java.awt.BasicStroke; + +import java.awt.BorderLayout; + +import java.awt.Color; + +import java.awt.Component; + +import java.awt.Cursor; + +import java.awt.Dimension; + +import java.awt.Font; + +import java.awt.Graphics; + +import java.awt.Graphics2D; + +import java.awt.GridLayout; + +import java.awt.Point; + +import java.awt.Polygon; + +import java.awt.Stroke; + +import java.awt.Toolkit; + +import java.awt.event.FocusEvent; + +import java.awt.event.FocusListener; + +import java.awt.event.MouseAdapter; + +import java.awt.event.MouseEvent; + +import java.awt.event.MouseListener; + +import java.awt.event.MouseMotionListener; + +import java.text.SimpleDateFormat; + +import java.util.ArrayList; + +import java.util.Calendar; + +import java.util.Comparator; + +import java.util.Date; + +import java.util.List; + + + +import javax.swing.BorderFactory; + +import javax.swing.JComponent; + +import javax.swing.JFrame; + +import javax.swing.JLabel; + +import javax.swing.JPanel; + +import javax.swing.JTextField; + +import javax.swing.Popup; + +import javax.swing.PopupFactory; + +import javax.swing.SwingUtilities; + +import javax.swing.event.AncestorEvent; + +import javax.swing.event.AncestorListener; + + + +/** + + * 日期选择器,可以指定日期的显示格式 + + */ + +public class DateChooser extends JPanel { + + + + private static final long serialVersionUID = 4529266044762990227L; + + + + private Date initDate; + + private Calendar now = Calendar.getInstance(); + + private Calendar select; + + private JPanel monthPanel;//月历 + + private JP1 jp1;//四块面板,组成 + + private JP2 jp2; + + private JP3 jp3; + + private JP4 jp4; + + private Font font = new Font("宋体", Font.PLAIN, 12); + + private final LabelManager lm = new LabelManager(); + + private SimpleDateFormat sdf; + + private boolean isShow = false; + + private Popup pop; + + + + private JComponent showDate; + + + + public static DateChooser getInstance() { + + return new DateChooser(); + + } + + + + public static DateChooser getInstance(Date date) { + + return new DateChooser(date); + + } + + + + public static DateChooser getInstance(String format) { + + return new DateChooser(format); + + } + + + + public static DateChooser getInstance(Date date, String format) { + + return new DateChooser(date, format); + + } + + + + /** + + * Creates a new instance of DateChooser + + */ + + private DateChooser() { + + this(new Date()); + + } + + + + private DateChooser(Date date) { + + this(date, "yyyy年MM月dd日"); + + } + + + + private DateChooser(String format) { + + this(new Date(), format); + + } + + + + private DateChooser(Date date, String format) { + + initDate = date; + + sdf = new SimpleDateFormat(format); + + select = Calendar.getInstance(); + + select.setTime(initDate); + + initPanel(); + + } + + + + /** + + * 是否允许用户选择 + + */ + + public void setEnabled(boolean b) { + + super.setEnabled(b); + + showDate.setEnabled(b); + + } + + + + /** + + *得到当前选择框的日期 + + */ + + public Date getDate() { + + return select.getTime(); + + } + + + + public String getStrDate() { + + return sdf.format(select.getTime()); + + } + + + + public String getStrDate(String format) { + + sdf = new SimpleDateFormat(format); + + return sdf.format(select.getTime()); + + } + + + + //根据初始化的日期,初始化面板 + + private void initPanel() { + + monthPanel = new JPanel(new BorderLayout()); + + monthPanel.setBorder(BorderFactory.createLineBorder(Color.BLUE)); + + JPanel up = new JPanel(new BorderLayout()); + + up.add(jp1 = new JP1(), BorderLayout.NORTH); + + up.add(jp2 = new JP2(), BorderLayout.CENTER); + + monthPanel.add(jp3 = new JP3(), BorderLayout.CENTER); + + monthPanel.add(up, BorderLayout.NORTH); + + monthPanel.add(jp4 = new JP4(), BorderLayout.SOUTH); + + this.addAncestorListener(new AncestorListener() { + + public void ancestorAdded(AncestorEvent event) { + + + + } + + + + public void ancestorRemoved(AncestorEvent event) { + + + + } + + + + //只要祖先组件一移动,马上就让popup消失 + + public void ancestorMoved(AncestorEvent event) { + + hidePanel(); + + } + + }); + + } + + + + public void register(final JComponent showDate) { + + this.showDate = showDate; + + + + showDate.setRequestFocusEnabled(true); + + showDate.addMouseListener(new MouseAdapter() { + + public void mousePressed(MouseEvent me) { + + showDate.requestFocusInWindow(); + + } + + }); + + this.setBackground(Color.WHITE); + + this.add(showDate, BorderLayout.CENTER); + + this.setPreferredSize(new Dimension(90, 25)); + + this.setBorder(BorderFactory.createLineBorder(Color.GRAY)); + + showDate.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + if (showDate.isEnabled()) { + + showDate.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + showDate.setForeground(Color.RED); + + } + + } + + + + public void mouseExited(MouseEvent me) { + + if (showDate.isEnabled()) { + + showDate.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + showDate.setForeground(Color.BLACK); + + } + + } + + + + public void mousePressed(MouseEvent me) { + + if (showDate.isEnabled()) { + + showDate.setForeground(Color.CYAN); + + if (isShow) { + + hidePanel(); + + } else { + + showPanel(showDate); + + } + + } + + } + + + + public void mouseReleased(MouseEvent me) { + + if (showDate.isEnabled()) { + + showDate.setForeground(Color.BLACK); + + } + + } + + }); + + showDate.addFocusListener(new FocusListener() { + + public void focusLost(FocusEvent e) { + + hidePanel(); + + } + + + + public void focusGained(FocusEvent e) { + + + + } + + }); + + } + + + + //根据新的日期刷新 + + private void refresh() { + + jp1.updateDate(); + + jp2.updateDate(); + + jp3.updateDate(); + + jp4.updateDate(); + + SwingUtilities.updateComponentTreeUI(this); + + } + + + + //提交日期 + + private void commit() { + + //TODO add other components here + + if (showDate instanceof JTextField) { + + ((JTextField) showDate).setText(sdf.format(select.getTime())); + + }else if (showDate instanceof JLabel) { + + ((JLabel) showDate).setText(sdf.format(select.getTime())); + + } + + + + hidePanel(); + + } + + + + //隐藏日期选择面板 + + private void hidePanel() { + + if (pop != null) { + + isShow = false; + + pop.hide(); + + pop = null; + + } + + } + + + + //显示日期选择面板 + + private void showPanel(Component owner) { + + if (pop != null) { + + pop.hide(); + + } + + Point show = new Point(0, showDate.getHeight()); + + SwingUtilities.convertPointToScreen(show, showDate); + + Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); + + int x = show.x; + + int y = show.y; + + if (x < 0) { + + x = 0; + + } + + if (x > size.width - 295) { + + x = size.width - 295; + + } + + if (y < size.height - 170) { + + } else { + + y -= 188; + + } + + pop = PopupFactory.getSharedInstance().getPopup(owner, monthPanel, x, y); + + pop.show(); + + isShow = true; + + } + + + + /** + + * 最上面的面板用来显示月份的增减 + + */ + + private class JP1 extends JPanel { + + private static final long serialVersionUID = -5638853772805561174L; + + JLabel yearleft, yearright, monthleft, monthright, center, centercontainer; + + + + public JP1() { + + super(new BorderLayout()); + + this.setBackground(new Color(160, 185, 215)); + + initJP1(); + + } + + + + private void initJP1() { + + yearleft = new JLabel(" <<", JLabel.CENTER); + + yearleft.setToolTipText("上一年"); + + yearright = new JLabel(">> ", JLabel.CENTER); + + yearright.setToolTipText("下一年"); + + yearleft.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); + + yearright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); + + + + monthleft = new JLabel(" <", JLabel.RIGHT); + + monthleft.setToolTipText("上一月"); + + monthright = new JLabel("> ", JLabel.LEFT); + + monthright.setToolTipText("下一月"); + + monthleft.setBorder(BorderFactory.createEmptyBorder(2, 30, 0, 0)); + + monthright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 30)); + + + + centercontainer = new JLabel("", JLabel.CENTER); + + centercontainer.setLayout(new BorderLayout()); + + center = new JLabel("", JLabel.CENTER); + + + + centercontainer.add(monthleft, BorderLayout.WEST); + + centercontainer.add(center, BorderLayout.CENTER); + + centercontainer.add(monthright, BorderLayout.EAST); + + + + this.add(yearleft, BorderLayout.WEST); + + this.add(centercontainer, BorderLayout.CENTER); + + this.add(yearright, BorderLayout.EAST); + + this.setPreferredSize(new Dimension(295, 25)); + + + + updateDate(); + + + + yearleft.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + yearleft.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + yearleft.setForeground(Color.RED); + + } + + + + public void mouseExited(MouseEvent me) { + + yearleft.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + yearleft.setForeground(Color.BLACK); + + } + + + + public void mousePressed(MouseEvent me) { + + select.add(Calendar.YEAR, -1); + + yearleft.setForeground(Color.WHITE); + + refresh(); + + } + + + + public void mouseReleased(MouseEvent me) { + + yearleft.setForeground(Color.BLACK); + + } + + }); + + yearright.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + yearright.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + yearright.setForeground(Color.RED); + + } + + + + public void mouseExited(MouseEvent me) { + + yearright.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + yearright.setForeground(Color.BLACK); + + } + + + + public void mousePressed(MouseEvent me) { + + select.add(Calendar.YEAR, 1); + + yearright.setForeground(Color.WHITE); + + refresh(); + + } + + + + public void mouseReleased(MouseEvent me) { + + yearright.setForeground(Color.BLACK); + + } + + }); + + monthleft.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + monthleft.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + monthleft.setForeground(Color.RED); + + } + + + + public void mouseExited(MouseEvent me) { + + monthleft.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + monthleft.setForeground(Color.BLACK); + + } + + + + public void mousePressed(MouseEvent me) { + + select.add(Calendar.MONTH, -1); + + monthleft.setForeground(Color.WHITE); + + refresh(); + + } + + + + public void mouseReleased(MouseEvent me) { + + monthleft.setForeground(Color.BLACK); + + } + + }); + + monthright.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + monthright.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + monthright.setForeground(Color.RED); + + } + + + + public void mouseExited(MouseEvent me) { + + monthright.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + monthright.setForeground(Color.BLACK); + + } + + + + public void mousePressed(MouseEvent me) { + + select.add(Calendar.MONTH, 1); + + monthright.setForeground(Color.WHITE); + + refresh(); + + } + + + + public void mouseReleased(MouseEvent me) { + + monthright.setForeground(Color.BLACK); + + } + + }); + + } + + + + private void updateDate() { + + center.setText(select.get(Calendar.YEAR) + "年" + (select.get(Calendar.MONTH) + 1) + "月"); + + } + + } + + + + private class JP2 extends JPanel { + + private static final long serialVersionUID = -8176264838786175724L; + + + + public JP2() { + + this.setPreferredSize(new Dimension(295, 20)); + + } + + + + protected void paintComponent(Graphics g) { + + g.setFont(font); + + g.drawString("星期日 星期一 星期二 星期三 星期四 星期五 星期六", 5, 10); + + g.drawLine(0, 15, getWidth(), 15); + + } + + + + private void updateDate() { + + + + } + + } + + + + private class JP3 extends JPanel { + + private static final long serialVersionUID = 43157272447522985L; + + + + public JP3() { + + super(new GridLayout(6, 7)); + + this.setPreferredSize(new Dimension(295, 100)); + + initJP3(); + + } + + + + private void initJP3() { + + updateDate(); + + } + + + + public void updateDate() { + + this.removeAll(); + + lm.clear(); + + Date temp = select.getTime(); + + Calendar select = Calendar.getInstance(); + + select.setTime(temp); + + select.set(Calendar.DAY_OF_MONTH, 1); + + int index = select.get(Calendar.DAY_OF_WEEK); + + int sum = (index == 1 ? 8 : index); + + select.add(Calendar.DAY_OF_MONTH, 0 - sum); + + for (int i = 0; i < 42; i++) { + + select.add(Calendar.DAY_OF_MONTH, 1); + + lm.addLabel(new MyLabel(select.get(Calendar.YEAR), select.get(Calendar.MONTH), select.get(Calendar.DAY_OF_MONTH))); + + } + + for (MyLabel my : lm.getLabels()) { + + this.add(my); + + } + + select.setTime(temp); + + } + + } + + + + private class MyLabel extends JLabel implements Comparator, MouseListener, MouseMotionListener { + + private static final long serialVersionUID = 3668734399227577214L; + + private int year, month, day; + + private boolean isSelected; + + + + public MyLabel(int year, int month, int day) { + + super("" + day, JLabel.CENTER); + + this.year = year; + + this.day = day; + + this.month = month; + + this.addMouseListener(this); + + this.addMouseMotionListener(this); + + this.setFont(font); + + if (month == select.get(Calendar.MONTH)) { + + this.setForeground(Color.BLACK); + + } else { + + this.setForeground(Color.LIGHT_GRAY); + + } + + if (day == select.get(Calendar.DAY_OF_MONTH)) { + + this.setBackground(new Color(160, 185, 215)); + + } else { + + this.setBackground(Color.WHITE); + + } + + } + + + + public boolean getIsSelected() { + + return isSelected; + + } + + + + public void setSelected(boolean b, boolean isDrag) { + + isSelected = b; + + if (b && !isDrag) { + + int temp = select.get(Calendar.MONTH); + + select.set(year, month, day); + + if (temp == month) { + + SwingUtilities.updateComponentTreeUI(jp3); + + } else { + + refresh(); + + } + + } + + this.repaint(); + + } + + + + protected void paintComponent(Graphics g) { + + if (day == select.get(Calendar.DAY_OF_MONTH) && month == select.get(Calendar.MONTH)) { + + //如果当前日期是选择日期,则高亮显示 + + g.setColor(new Color(160, 185, 215)); + + g.fillRect(0, 0, getWidth(), getHeight()); + + } + + if (year == now.get(Calendar.YEAR) && month == now.get(Calendar.MONTH) && day == now.get(Calendar.DAY_OF_MONTH)) { + + //如果日期和当前日期一样,则用红框 + + Graphics2D gd = (Graphics2D) g; + + gd.setColor(Color.RED); + + Polygon p = new Polygon(); + + p.addPoint(0, 0); + + p.addPoint(getWidth() - 1, 0); + + p.addPoint(getWidth() - 1, getHeight() - 1); + + p.addPoint(0, getHeight() - 1); + + gd.drawPolygon(p); + + } + + if (isSelected) {//如果被选中了就画出一个虚线框出来 + + Stroke s = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL, 1.0f, new float[] { 2.0f, 2.0f }, 1.0f); + + Graphics2D gd = (Graphics2D) g; + + gd.setStroke(s); + + gd.setColor(Color.BLACK); + + Polygon p = new Polygon(); + + p.addPoint(0, 0); + + p.addPoint(getWidth() - 1, 0); + + p.addPoint(getWidth() - 1, getHeight() - 1); + + p.addPoint(0, getHeight() - 1); + + gd.drawPolygon(p); + + } + + super.paintComponent(g); + + } + + + + public boolean contains(Point p) { + + return this.getBounds().contains(p); + + } + + + + private void update() { + + repaint(); + + } + + + + public void mouseClicked(MouseEvent e) { + + } + + + + public void mousePressed(MouseEvent e) { + + isSelected = true; + + update(); + + } + + + + public void mouseReleased(MouseEvent e) { + + Point p = SwingUtilities.convertPoint(this, e.getPoint(), jp3); + + lm.setSelect(p, false); + + commit(); + + } + + + + public void mouseEntered(MouseEvent e) { + + } + + + + public void mouseExited(MouseEvent e) { + + } + + + + public void mouseDragged(MouseEvent e) { + + Point p = SwingUtilities.convertPoint(this, e.getPoint(), jp3); + + lm.setSelect(p, true); + + } + + + + public void mouseMoved(MouseEvent e) { + + } + + + + public int compare(MyLabel o1, MyLabel o2) { + + Calendar c1 = Calendar.getInstance(); + + c1.set(o1.year, o2.month, o1.day); + + Calendar c2 = Calendar.getInstance(); + + c2.set(o2.year, o2.month, o2.day); + + return c1.compareTo(c2); + + } + + } + + + + private class LabelManager { + + private List list; + + + + public LabelManager() { + + list = new ArrayList(); + + } + + + + public List getLabels() { + + return list; + + } + + + + public void addLabel(MyLabel my) { + + list.add(my); + + } + + + + public void clear() { + + list.clear(); + + } + + + + @SuppressWarnings("unused") + + public void setSelect(MyLabel my, boolean b) { + + for (MyLabel m : list) { + + if (m.equals(my)) { + + m.setSelected(true, b); + + } else { + + m.setSelected(false, b); + + } + + } + + } + + + + public void setSelect(Point p, boolean b) { + + //如果是拖动,则要优化一下,以提高效率 + + if (b) { + + //表示是否能返回,不用比较完所有的标签,能返回的标志就是把上一个标签和 + + //将要显示的标签找到了就可以了 + + boolean findPrevious = false, findNext = false; + + for (MyLabel m : list) { + + if (m.contains(p)) { + + findNext = true; + + if (m.getIsSelected()) { + + findPrevious = true; + + } else { + + m.setSelected(true, b); + + } + + } else if (m.getIsSelected()) { + + findPrevious = true; + + m.setSelected(false, b); + + } + + if (findPrevious && findNext) { + + return; + + } + + } + + } else { + + MyLabel temp = null; + + for (MyLabel m : list) { + + if (m.contains(p)) { + + temp = m; + + } else if (m.getIsSelected()) { + + m.setSelected(false, b); + + } + + } + + if (temp != null) { + + temp.setSelected(true, b); + + } + + } + + } + + + + } + + + + private class JP4 extends JPanel { + + private static final long serialVersionUID = -6391305687575714469L; + + + + public JP4() { + + super(new BorderLayout()); + + this.setPreferredSize(new Dimension(295, 20)); + + this.setBackground(new Color(160, 185, 215)); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日"); + + final JLabel jl = new JLabel("今天: " + sdf.format(new Date())); + + jl.setToolTipText("点击选择今天日期"); + + this.add(jl, BorderLayout.CENTER); + + jl.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + jl.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + jl.setForeground(Color.RED); + + } + + + + public void mouseExited(MouseEvent me) { + + jl.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + jl.setForeground(Color.BLACK); + + } + + + + public void mousePressed(MouseEvent me) { + + jl.setForeground(Color.WHITE); + + select.setTime(new Date()); + + refresh(); + + commit(); + + } + + + + public void mouseReleased(MouseEvent me) { + + jl.setForeground(Color.BLACK); + + } + + }); + + } + + + + private void updateDate() { + + + + } + + } + + + + public static void main(String[] args) { + + DateChooser dateChooser1 = DateChooser.getInstance("yyyy-MM-dd"); + + 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/dfl/plm/dfl038/Dfl038Dialog.java b/src/com/connor/dfl/plm/dfl038/Dfl038Dialog.java new file mode 100644 index 0000000..9ceb993 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl038/Dfl038Dialog.java @@ -0,0 +1,181 @@ +package com.connor.dfl.plm.dfl038; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.border.TitledBorder; +import javax.swing.filechooser.FileSystemView; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.PropertyLayout; + +public class Dfl038Dialog extends AbstractAIFDialog{ + + private TCSession session; + private JTextField textField; + private JButton okButton; + private JButton celButton; + private JButton pathButton; + private JTextField showDate1; + private JTextField showDate2; + private JComboBox proBox; + private TCPreferenceService service; + // 文件选择器 + private JFileChooser jFileChooser; + private Map proMap = new HashMap(); + public Dfl038Dialog(TCSession session){ + this.session = session; + this.service = session.getPreferenceService(); + } + public void run(){ + initUI(); + } + private void initUI() { + // TODO Auto-generated method stub + FileSystemView fsv = FileSystemView.getFileSystemView(); // 得到系统的fileview + String deskPath = fsv.getHomeDirectory().getPath(); // 当前用户的桌面路径 + + this.setSize(new Dimension(600, 400)); + this.setTitle("变更通知单报表"); + this.textField = new JTextField(deskPath); + + jFileChooser = new JFileChooser(); + this.jFileChooser.setCurrentDirectory(new File(deskPath));// 文件选择器的初始目录定为当前用户桌面 + this.jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + + this.pathButton = new JButton("浏览"); + this.okButton = new JButton("确定"); + this.celButton = new JButton("取消"); + DateChooser dateChooser1 = DateChooser.getInstance("yyyy-M-d HH:mm"); + + DateChooser dateChooser2 = DateChooser.getInstance("yyyy-M-d HH:mm"); + Date date = new Date(); + SimpleDateFormat df = new SimpleDateFormat("yyyy-M-d HH:mm"); + String time = df.format(date); + showDate1 = new JTextField(time); + + showDate2 = new JTextField(time); + dateChooser1.register(showDate1); + dateChooser2.register(showDate2); + proBox = new JComboBox(); + String[] values = service.getStringValues("T2_ECNReport"); + for (int i = 0; i < values.length; i++) { + proBox.addItem(values[i]); + } + JPanel midJPanel = new JPanel(new PropertyLayout()); + midJPanel.setBorder(new TitledBorder(BorderFactory + .createLineBorder(Color.WHITE), "请选择导出路径")); // 线框 TitleBorder + midJPanel.add("1.1.left.top", new JLabel(" ")); + midJPanel.add("2.1.left.top", new JLabel("申请时间晚于:")); + midJPanel.add("2.2.left.top", showDate1); + midJPanel.add("3.1.left.top", new JLabel("申请时间早于:")); + midJPanel.add("3.2.left.top", showDate2); + midJPanel.add("4.1.left.top", new JLabel("产品部门:")); + midJPanel.add("4.2.left.top", proBox); + midJPanel.add("5.1.left.top", new JLabel("导出路径:")); + midJPanel.add("5.2.left.top", this.textField); + midJPanel.add("5.3.left.top", this.pathButton); + JPanel rootJPanel = new JPanel(new FlowLayout()); + rootJPanel.add(this.okButton); + rootJPanel.add(this.celButton); + + pathButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + selectFileButtonEvent(); + } + }); + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + okEvent(); + + } + }); + celButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + celEvent(); + + } + }); + + this.setLayout(new BorderLayout()); + this.add(midJPanel, BorderLayout.CENTER); + this.add(rootJPanel, BorderLayout.SOUTH); + + this.centerToScreen(); + this.pack(); + this.setVisible(true); + this.showDialog(); + } + + public void celEvent() { + // TODO Auto-generated method stub + this.disposeDialog(); + this.dispose(); + } + + public void selectFileButtonEvent() { + int state = jFileChooser.showOpenDialog(null);// 此句是打开文件选择器界面的触发语句 + if (state == 1) { + return; + } else { + File f = jFileChooser.getSelectedFile();// f为选择到的目录 + textField.setText(f.getAbsolutePath()); + } + } + + public void okEvent() { + + this.disposeDialog(); + this.dispose(); + + try { + String path=textField.getText(); + System.out.println("ok"); + String time1 = showDate1.getText(); + String time2 = showDate2.getText(); + System.out.println("time1============"+time1); + System.out.println("time2============"+time2); + String pro = (String) proBox.getSelectedItem(); + Dfl038Operation op=new Dfl038Operation(session,time1,time2,path,pro); + session.queueOperation(op); + + + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + +} diff --git a/src/com/connor/dfl/plm/dfl038/Dfl038Handler.java b/src/com/connor/dfl/plm/dfl038/Dfl038Handler.java new file mode 100644 index 0000000..b52b38b --- /dev/null +++ b/src/com/connor/dfl/plm/dfl038/Dfl038Handler.java @@ -0,0 +1,22 @@ +package com.connor.dfl.plm.dfl038; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class Dfl038Handler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Dfl038Dialog dialog = new Dfl038Dialog(session); + new Thread(dialog).start(); + return null; + } + +} diff --git a/src/com/connor/dfl/plm/dfl038/Dfl038Operation.java b/src/com/connor/dfl/plm/dfl038/Dfl038Operation.java new file mode 100644 index 0000000..7533104 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl038/Dfl038Operation.java @@ -0,0 +1,300 @@ +package com.connor.dfl.plm.dfl038; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.dfl.plm.util.DataBaseControl; +import com.connor.dfl.plm.util.ProgressBarThread; +import com.spire.xls.ExcelVersion; +import com.spire.xls.OrderBy; +import com.spire.xls.SortComparsionType; +import com.spire.xls.Workbook; +import com.spire.xls.Worksheet; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +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; + + +public class Dfl038Operation extends AbstractAIFOperation{ + private TCSession session; + private String path; + private String time1; + private String time2; + private TCPreferenceService service; + private ProgressBarThread wait; + private String product; + public Dfl038Operation(TCSession session,String time1,String time2, String path,String product) { + this.session = session; + this.time1 = time1; + this.time2 = time2; + this.path = path; + this.product = product; + this.service = session.getPreferenceService(); + + } + @Override + public void executeOperation() throws Exception { +// String[] keys = new String[]{"所有权组","创建时间晚于","创建时间早于","类型"}; +// String[] values = new String[]{product,time1,time2,""}; +// List compList = queryObject("常规...", keys, values); +// if(compList == null){ +// MessageBox.post("未找到对应的数据!!!","提示",MessageBox.INFORMATION); +// return; +// } + DataBaseControl data = new DataBaseControl(session); + List beanList = data.getChangeMesg(product, time1, time2); + String puid = service.getStringValue("T2_ECNexport_Excel"); + if(puid == null || "".equals(puid)) { + MessageBox.post("报表模板首选项未配置,请检查!!!","提示",MessageBox.INFORMATION); + return; + } + TCComponentDataset excel = (TCComponentDataset) session.stringToComponent(puid); + File file = ((TCComponentDataset)excel).getTcFiles()[0].getFmsFile(); + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");// 设置日期格式 + String time = df.format(new Date()); + path = path + File.separator + "更改通知单报表-" + time + ".xlsx"; + wait = new ProgressBarThread("生成报表", + "生成数据中,请稍等..."); + wait.start();// 开启进度条 + try { + writeExcel(beanList,file,path); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + MessageBox.post("生成报表失败"+e.getMessage(),"错误",MessageBox.ERROR); + return; + } + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + MessageBox.post("生成报表完成,请查看","完成",MessageBox.INFORMATION); + Runtime.getRuntime().exec("cmd /c \"" + path + "\""); + } + + /** + * 通过查询构建器查询产品图对象 + * @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 writeExcel(List beanList, File file,String path){ + + try { +// for (int i = 0; i < compList.size(); i++) { +// TCComponent comp = compList.get(i); +// if(comp instanceof TCComponentItem){ +// String name = ""; +// TCComponentItem item = (TCComponentItem) comp; +// TCComponentItemRevision rev = item.getLatestItemRevision(); +// TCComponent form = rev.getReferenceListProperty("IMAN_master_form_rev")[0]; +// boolean flag = true; +// AIFComponentContext contex1[] = item.whereReferenced(); +// for (int j = 0; j < contex1.length; j++) { +// InterfaceAIFComponent comp2 = contex1[j].getComponent(); +// if(comp2 instanceof TCComponentItemRevision) { +// TCComponentItemRevision rev2 = (TCComponentItemRevision) comp2; +// if("T2_ECRRevision".equals(rev2.getType())) { +// TCComponent form1 = rev2.getReferenceListProperty("IMAN_master_form_rev")[0]; +// name = form1.getStringProperty("object_name"); +// flag = false; +// } +// } +// } +// if(flag) { +// name = form.getStringProperty("object_name"); +// } +// ChangeBean bean = data.getChangeMesg(name); +// beanList.add(bean); +// } +// } + FileInputStream is = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(is); + XSSFSheet sheet = wb.getSheetAt(0); + XSSFRow targetRow = sheet.getRow(0); + short h = targetRow.getHeight(); + XSSFCell targetCell = targetRow.getCell(0); + XSSFCellStyle cellStyle = targetCell.getCellStyle(); + for (int i = 0; i < beanList.size(); i++) { + ChangeBean bean = beanList.get(i); + String[] vals = new String[24]; + vals[0] = bean.getApplyName(); + vals[1] = bean.getChangeListCode(); + vals[2] = bean.getApplyDate(); + vals[3] = bean.getProductName(); + vals[4] = bean.getProjectModel(); + vals[5] = bean.getClientNae(); + vals[6] = bean.getWarehouseCode(); + vals[7] = bean.getNotifyEmergencyProcedures(); + vals[8] = bean.getTZChangeType(); + vals[9] = bean.getSUOSU_ProductDepartment(); + vals[10] = bean.getDutyDepartment(); + vals[11] = bean.getDutyMan(); + vals[12] = bean.getChangeType(); + vals[13] = bean.getProductType(); + vals[14] = bean.getErrorType(); + vals[15] = bean.getPriceBooking(); + vals[16] = bean.getSalseClassify(); + vals[17] = bean.getIsNotProductLoss(); + vals[18] = bean.getProjectState(); + vals[19] = bean.getReceiveClassify(); + vals[20] = bean.getDrawingTo(); + vals[21] = bean.getProjectCode(); + vals[22] = bean.getChangeReason(); + vals[23] = bean.getAccountSet(); + + XSSFRow row = sheet.getRow(i+1); + if(row == null){ + row = sheet.createRow(i+1); + } + row.setHeight(h); + for (int j = 0; j < vals.length; j++) { + XSSFCell cell = row.getCell(j); + if(cell == null){ + cell = row.createCell(j); + } + cell.setCellStyle(cellStyle); + cell.setCellValue(vals[j]); + } + } + FileOutputStream output = new FileOutputStream(new File(path)); + wb.write(output); + output.close(); + is.close(); + +// Workbook workbook = new Workbook(); +// workbook.loadFromFile(path); +// //获取第一个工作表 +// Worksheet sheet1 = workbook.getWorksheets().get(0); +// //指定要排序的列号(列号从0开始)以及排序方式(升序或降序) +// workbook.getDataSorter().getSortColumns().add(1, SortComparsionType.Values, OrderBy.Ascending); +// //指定要排序的数据区域 +// workbook.getDataSorter().sort(sheet1.getCellRange("A1:X"+beanList.size())); +// //保存文档 +// workbook.saveToFile(path, ExcelVersion.Version2013); +// FileInputStream is2 = new FileInputStream(new File(path)); +// XSSFWorkbook wb2 = new XSSFWorkbook(is2); +// wb2.removeSheetAt(1); +// FileOutputStream output2 = new FileOutputStream(new File(path)); +// wb2.write(output2); +// output2.close(); +// is2.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static String getCellValue(XSSFCell cell){ + String cellValue = ""; + if(cell == null){ + return cellValue; + } + switch (cell.getCellType()) { + case XSSFCell.CELL_TYPE_NUMERIC: + if(DateUtil.isCellDateFormatted(cell)){ + SimpleDateFormat sdf = null; + if(cell.getCellStyle().getDataFormat() == 14){ + sdf = new SimpleDateFormat("yyyy/MM/dd"); + }else if(cell.getCellStyle().getDataFormat() == 21){ + sdf = new SimpleDateFormat("HH:mm:ss"); + }else if(cell.getCellStyle().getDataFormat() == 22){ + sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + }else{ + throw new RuntimeException("日期格式错误!!!"); + } + Date date = cell.getDateCellValue(); + cellValue = sdf.format(date); + }else if(cell.getCellStyle().getDataFormat() == 0){ + cell.setCellType(XSSFCell.CELL_TYPE_STRING); + cellValue = String.valueOf(cell.getRichStringCellValue().getString()); + } + break; + case XSSFCell.CELL_TYPE_STRING: + cellValue = String.valueOf(cell.getStringCellValue()); + break; + case XSSFCell.CELL_TYPE_BOOLEAN: + cellValue = String.valueOf(cell.getBooleanCellValue()); + break; + case XSSFCell.CELL_TYPE_FORMULA: + cellValue = String.valueOf(cell.getCellFormula()); + break; + case XSSFCell.CELL_TYPE_BLANK: + cellValue = null; + break; + case XSSFCell.CELL_TYPE_ERROR: + cellValue = "非法字符"; + break; + default: + break; + } + return cellValue; + } + +// public static void main(String[] args) { +// Workbook workbook = new Workbook(); +// String path = "C:\\Users\\wangc\\Desktop\\测试pdf签字\\工作表 在 【东富龙PLM项目】二次开发功能规格书V5.0.xlsx"; +// workbook.loadFromFile(path); +// //获取第一个工作表 +// Worksheet sheet1 = workbook.getWorksheets().get(0); +// //指定要排序的列号(列号从0开始)以及排序方式(升序或降序) +// workbook.getDataSorter().getSortColumns().add(1, SortComparsionType.Values, OrderBy.Ascending); +// //指定要排序的数据区域 +// workbook.getDataSorter().sort(sheet1.getCellRange("A1:X3")); +// +// //保存文档 +// workbook.saveToFile(path, ExcelVersion.Version2013); +// +// try { +// FileInputStream is2 = new FileInputStream(path); +// XSSFWorkbook wb2 = new XSSFWorkbook(is2); +// wb2.removeSheetAt(1); +// FileOutputStream output = new FileOutputStream(new File(path)); +// wb2.write(output); +// output.close(); +// is2.close(); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// +// } +} diff --git a/src/com/connor/dfl/plm/dfl039/AttrBean.java b/src/com/connor/dfl/plm/dfl039/AttrBean.java new file mode 100644 index 0000000..5fd4ee6 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl039/AttrBean.java @@ -0,0 +1,77 @@ +package com.connor.dfl.plm.dfl039; + +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 AttrBean { + + private int propID; + private String propDisName; + public ICSAdminClassAttribute icsAttr; + public String formate; + public int intsize = 0; + public int floatsize = 0; + public int attrType; + public List keyList; + public boolean isLov; + + public AttrBean(ICSAdminClassAttribute icsAttr) { + // TODO Auto-generated constructor stub + // 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); + 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))){ + if(value.contains("&")) { + value.replace("&", "&"); + } + keyList.add(value); + System.out.println(value); + } + } + } else { + this.isLov = false; + } + } + + + + public AttrBean() { + super(); + keyList = new ArrayList(); + } + + + + public int getPropID() { + return propID; + } + + public String getPropDisName() { + return propDisName; + } + + +} diff --git a/src/com/connor/dfl/plm/dfl039/ClassBean.java b/src/com/connor/dfl/plm/dfl039/ClassBean.java new file mode 100644 index 0000000..4efa10c --- /dev/null +++ b/src/com/connor/dfl/plm/dfl039/ClassBean.java @@ -0,0 +1,26 @@ +package com.connor.dfl.plm.dfl039; + +import java.util.List; + +public class ClassBean { + private String classId; + private List attrBeans; + + public ClassBean(String classId,List attrBeans) { + this.classId = classId; + this.attrBeans = attrBeans; + } + + public void add(AttrBean attrBean) { + attrBeans.add(attrBean); + } + + public String getClassId() { + return classId; + } + + public List getAttrBeans() { + return attrBeans; + } + +} diff --git a/src/com/connor/dfl/plm/dfl039/DFL039Handler.java b/src/com/connor/dfl/plm/dfl039/DFL039Handler.java new file mode 100644 index 0000000..259bea9 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl039/DFL039Handler.java @@ -0,0 +1,28 @@ +package com.connor.dfl.plm.dfl039; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.dfl.plm.dfl031.ExportDialog; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class DFL039Handler extends AbstractHandler{ + public DFL039Handler() { + } + + /** + * the command has been executed, so extract extract the needed information + * from the application context. + */ + public Object execute(ExecutionEvent event) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + DFL039Operation operation = new DFL039Operation(session, app); + session.queueOperation(operation); + + return null; + } +} diff --git a/src/com/connor/dfl/plm/dfl039/DFL039Operation.java b/src/com/connor/dfl/plm/dfl039/DFL039Operation.java new file mode 100644 index 0000000..5bf48a4 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl039/DFL039Operation.java @@ -0,0 +1,370 @@ +package com.connor.dfl.plm.dfl039; + +import java.awt.Desktop; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.charset.Charset; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import javax.swing.JOptionPane; + +import org.apache.commons.io.output.FileWriterWithEncoding; +import org.apache.poi.hpsf.ClassID; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.dom4j.Document; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; + +import com.connor.dfl.plm.dfl019.ClassPropBean; +import com.connor.dfl.plm.dfl031.CNClassPropBean; +import com.connor.dfl.plm.dfl031.Classbean; +import com.connor.dfl.plm.dfl031.ExcelBean; +import com.connor.dfl.plm.dfl039.AttrBean; +import com.connor.dfl.plm.dfl039.MyComparator; +import com.connor.dfl.plm.dfl036.SynAttrXml; +import com.connor.dfl.plm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +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.ICSHierarchyNodeDescriptor; +import com.teamcenter.rac.util.MessageBox; + +public class DFL039Operation extends AbstractAIFOperation{ + + private String path; + private String classid = "ICM0102"; + private TCSession session; + private AbstractAIFApplication app; + private ProgressBarThread wait; + private int levmax = 1; + private TCClassificationService classificationService; + private List classList = new ArrayList(); + + public DFL039Operation(TCSession session,AbstractAIFApplication app) { + this.session = session; + this.app = app; + Date date = new Date(System.currentTimeMillis()); +// System.out.println(date); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); + String string = format.format(date); + path = System.getProperty("java.io.tmpdir").substring(0, System.getProperty("java.io.tmpdir").length()-1)+"\\"+string+"-系统现存分类属性汇总"; + } + + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + //开始导出系统中所有的属性 + wait = new ProgressBarThread("数据导出", "数据导出中,请稍等..."); + wait.start();// 开启进度条 + + getClassPro(); + + try { + //setByPass(session, true); + TCUserService userService = this.session.getUserService(); + + writeExcel(); + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + //setByPass(session, false); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + //setByPass(session, false); + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + MessageBox.post("生成报表失败" + e.getMessage(), "错误", MessageBox.ERROR); + } + + } + + private void getClassPro() { + // TODO Auto-generated method stub + if (classid.equals("")) { + classid = "ICM"; + } + System.out.println("classid="+classid); + classificationService = session.getClassificationService(); + dgChildClass(classid, 1, new ArrayList()); + + } + + private void dgChildClass(String classid2, int lev, List list) { + // TODO Auto-generated method stub + + try { + if (levmax < lev) { + levmax = lev; + } + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(classid2); + System.out.println("id=" + c.getId()); + System.out.println("name=" + c.getName()); + Classbean classbean = new Classbean(); + + List excelList = new ArrayList(); //属性id以及属性对应lov值 + classbean.setId(c.getId()); + classbean.setName(c.getName()); + List list2 = new ArrayList(); + for (int i = 0; i < list.size(); i++) { + list2.add(list.get(i)); + } + list2.add(classbean); + ICSHierarchyNodeDescriptor[] dss = classificationService + .getChildren(classid2, true, true, 0, 0); + if (dss != null && dss.length > 0) { + for (int i = 0; i < dss.length; i++) { + System.out.println("name=" + dss[i].getName()); + System.out.println("id=" + dss[i].getId()); + dgChildClass(dss[i].getId(), lev + 1, list2); + + } + } else { + ICSAdminClassAttribute[] attributes = c.getAttributes(); + for (int i = 0; i < attributes.length; i++) { + if (attributes[i].isReferenceAttribute()) { + continue; + } + if (attributes[i].isReference()) { + continue; + } + AttrBean bean = new AttrBean(attributes[i]); + if(bean.getPropDisName().contains("品牌")) { + excelList.add(bean); + } + + + } + ClassBean classBean2 = new ClassBean(c.getId(), excelList); + classList.add(classBean2); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + + private void writeExcel() { + // TODO Auto-generated method stub + Collections.sort(classList, new MyComparator()); + Date date = new Date(System.currentTimeMillis()); +// System.out.println(date); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); + String string = format.format(date); + + String xmlPath = System.getProperty("java.io.tmpdir").substring(0, + System.getProperty("java.io.tmpdir").length() - 1) + "\\" + string + "-品牌推优.xml"; + + TCComponent comp1; + try { + String stringValue = session.getPreferenceService().getStringValue("Brand_tag"); + if(stringValue ==null ||stringValue.length()<=0) { + MessageBox.post("首选项【Brand_tag】配置有误", "提示", MessageBox.INFORMATION); + return; + } + System.out.println(stringValue); + comp1 = session.stringToComponent(stringValue); + TCComponentDataset dataSet1 = (TCComponentDataset) comp1; + TCComponentTcFile[] files = dataSet1.getTcFiles(); + if(files.length<=0) { + MessageBox.post("首选项【Brand_tag】对应数据集无命名引用", "提示", MessageBox.INFORMATION); + return; + } + File file = files[0].getFmsFile(); + if(file == null) { + MessageBox.post("数据集对应文件为空", "提示", MessageBox.INFORMATION); + return; + } + System.out.println(file.getAbsolutePath()); + + List list = parseXMLCode(file); + + + + Charset encoding = Charset.forName("utf-8"); + BufferedWriter writer = new BufferedWriter(new FileWriterWithEncoding(new File(xmlPath),encoding)); + writer.write(""); + writer.newLine(); + writer.write(""); + writer.newLine(); + writer.write(""); + writer.newLine(); + writer.write("\t"); + writer.newLine(); + int i=0; + String className = "初始化"; + for (ClassBean classBean : classList) { + String className1=classBean.getClassId(); + if("初始化".equals(className)){ + className = className1; + writer.write("\t\t"); + writer.newLine(); + for (AttrBean attrBean : classBean.getAttrBeans()) { + for (String value : attrBean.keyList) { + //将value重新赋值写新的属性 + for (ClassBean classBean2 : list) { + if(className.equals(classBean2.getClassId())) { + for (AttrBean attrBean2 : classBean2.getAttrBeans()) { + for (String string2 : attrBean2.keyList) { + if(string2!=null && string2.split("_").length>1) { + System.out.println(string2.split("_")[1]+"==="+value); + if(string2.split("_")[1].equals(value)) { + value = string2.split("_")[0]+"_"+value; + } + + } + } + if(value.split("_").length<=1) { + value = "待定_"+value; + } + } + } + } + + System.out.println("new value=>:"+value); + writer.write("\t\t\t"); + writer.newLine(); + } + } + }else if(!className.equals(className1)){ +// System.out.println("不相等了"); + writer.write("\t\t"); + writer.newLine(); + className = className1; + writer.write("\t\t"); + writer.newLine(); + for (AttrBean attrBean : classBean.getAttrBeans()) { + for (String value : attrBean.keyList) { + //将value重新赋值写新的属性 + for (ClassBean classBean2 : list) { + if(className.equals(classBean2.getClassId())) { + for (AttrBean attrBean2 : classBean2.getAttrBeans()) { + for (String string2 : attrBean2.keyList) { + if(string2!=null && string2.split("_").length>1) { + System.out.println(string2.split("_")[1]+"==="+value); + if(string2.split("_")[1].equals(value)) { + value = string2.split("_")[0]+"_"+value; + } + } + } + if(value.split("_").length<=1) { + value = "待定_"+value; + } + } + } + } + System.out.println("before value=>:"+value); + writer.write("\t\t\t"); + System.out.println("before value=>:"+(value.contains("&")?value.replace("&", "&"):value)); + writer.newLine(); + } + } + } + } + writer.write("\t\t"); + writer.newLine(); + writer.write("\t"); + writer.newLine(); + writer.write(""); + writer.newLine(); + + writer.flush(); + writer.close(); + + dataSet1.removeNamedReference("Text"); + String as2[] = {"Text"}; + String as1[] = {xmlPath}; + dataSet1.setFiles(as1, as2); + + String dir = System.getProperty("java.io.tmpdir").substring(0, + System.getProperty("java.io.tmpdir").length() - 1) + "\\" + string + "-HistoryFile"; + new File(dir).mkdir(); + File file2 = new File(xmlPath); + file2.renameTo(new File(dir+"\\"+file2.getName())); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + + /** + * + * @param file + * @return + */ + public static List parseXMLCode(File file) { + List classList = 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"); + Iterator iter3 = recordEle2.elementIterator("prop");// prop标签 + AttrBean attrBean = new AttrBean(); + while (iter3.hasNext()) { + Element recordEle3 = (Element) iter3.next(); + String value = recordEle3.attributeValue("value"); + + attrBean.keyList.add(value); + } + ArrayList arrayList = new ArrayList(); + arrayList.add(attrBean); + ClassBean classBean = new ClassBean(classID, arrayList); + classList.add(classBean); + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + + return classList; + } + +// public static void main(String[] args) { +// List list = parseXMLCode(new File("C:\\Users\\xuwubiao\\Desktop\\2021-04-22-01-39-58-传递ERP .xml")); +// for (ClassBean classBean : list) { +// System.out.println(classBean.getClassId()); +// for (AttrBean attrBean : classBean.getAttrBeans()) { +// for (String value : attrBean.keyList) { +// System.out.println(value); +// } +// } +// } +// } + + +} diff --git a/src/com/connor/dfl/plm/dfl039/MyComparator.java b/src/com/connor/dfl/plm/dfl039/MyComparator.java new file mode 100644 index 0000000..139c21d --- /dev/null +++ b/src/com/connor/dfl/plm/dfl039/MyComparator.java @@ -0,0 +1,16 @@ +package com.connor.dfl.plm.dfl039; + +import java.util.Comparator; + +import com.connor.dfl.plm.dfl039.AttrBean; + +public class MyComparator implements Comparator{ + + @Override + public int compare(ClassBean arg0, ClassBean arg1) { + // TODO Auto-generated method stub + return Integer.parseInt(arg0.getClassId().substring(3,9))>Integer.parseInt(arg1.getClassId().substring(3,9))?1: + (Integer.parseInt(arg0.getClassId().substring(3,9)) list = parseXMLCode(new + * File("C:\\Users\\xuwubiao\\Desktop\\2021-04-22-01-39-58-传递ERP .xml")); for + * (ClassBean classBean : list) { System.out.println(classBean.getClassId()); + * for (AttrBean attrBean : classBean.getAttrBeans()) { for (String value : + * attrBean.keyList) { System.out.println(value); } } } + */ + String s = "&123qwe"; + System.out.println(s.replace("&", "&")); + } + + /** + * + * @param file + * @return + */ + public static List parseXMLCode(File file) { + List classList = 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"); + Iterator iter3 = recordEle2.elementIterator("prop");// prop标签 + AttrBean attrBean = new AttrBean(); + while (iter3.hasNext()) { + Element recordEle3 = (Element) iter3.next(); + String value = recordEle3.attributeValue("value"); + + attrBean.keyList.add(value); + } + ArrayList arrayList = new ArrayList(); + arrayList.add(attrBean); + ClassBean classBean = new ClassBean(classID, arrayList); + classList.add(classBean); + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + + return classList; + } +} diff --git a/src/com/connor/dfl/plm/dfl039/Test1.java b/src/com/connor/dfl/plm/dfl039/Test1.java new file mode 100644 index 0000000..07430fe --- /dev/null +++ b/src/com/connor/dfl/plm/dfl039/Test1.java @@ -0,0 +1,7 @@ +package com.connor.dfl.plm.dfl039; + +public class Test1 { + public static void main(String[] args) { + System.out.println(111); + } +} diff --git a/src/com/connor/dfl/plm/dfl040/ChangeFormBean.java b/src/com/connor/dfl/plm/dfl040/ChangeFormBean.java new file mode 100644 index 0000000..a3ba4a0 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl040/ChangeFormBean.java @@ -0,0 +1,82 @@ +package com.connor.dfl.plm.dfl040; + +import java.util.Map; + +import org.apache.commons.collections.map.HashedMap; + +public class ChangeFormBean { + private String applyhMan; + private String applyId; + private String projectId; + private String procuctModNum; + private String custName; + private String dutyDept; + private String dutyMan; + private String changeType; + private String productType; + private String drawChangeType; + private String cossLoss; + private String errorType; + private String changeReason; + public ChangeFormBean(String applyhMan, String applyId, String projectId, String procuctModNum, String custName, + String dutyDept, String dutyMan, String changeType, String productType, String drawChangeType, + String cossLoss, String errorType) { + super(); + this.applyhMan = applyhMan; + this.applyId = applyId; + this.projectId = projectId; + this.procuctModNum = procuctModNum; + this.custName = custName; + this.dutyDept = dutyDept; + this.dutyMan = dutyMan; + this.changeType = changeType; + this.productType = productType; + this.drawChangeType = drawChangeType; + this.cossLoss = cossLoss; + this.errorType = errorType; +// this.changeReason = changeReason; + } + + public Map getMap(){ + Map map = new HashedMap(); + map.put("APPLYNAME",applyhMan==null || "".equals(applyhMan.trim())?null:" AND APPLYNAME LIKE '%"+applyhMan+"%' "); + map.put("CHANGELISTCODE", applyId==null || "".equals(applyId.trim())?null:" AND CHANGELISTCODE LIKE '%"+applyId+"%' "); + map.put("PROJECTCODE", projectId==null || "".equals(projectId.trim())?null:" AND PROJECTCODE LIKE '%"+projectId+"%' "); + map.put("PROJECTMODEL", procuctModNum==null || "".equals(procuctModNum.trim())?null:"AND PROJECTMODEL LIKE '%"+procuctModNum+"%' "); + map.put("CLIENTNAME", custName==null || "".equals(custName.trim())?null:"AND CLIENTNAME LIKE '%"+custName+"%' "); + map.put("DUTYDEPARTMENT", dutyDept==null || "".equals(dutyDept.trim())?null:"AND DUTYDEPARTMENT LIKE '%"+dutyDept+"%' "); + map.put("DUTYMAN", dutyMan==null || "".equals(dutyMan.trim())?null:"AND DUTYMAN LIKE '%"+dutyMan+"%' "); + map.put("CHANGETYPE", changeType==null || "".equals(changeType.trim())?null:"AND CHANGETYPE LIKE '%"+changeType+"%' "); + map.put("PRODUCTTYPE", productType==null || "".equals(productType.trim())?null:" AND PRODUCTTYPE LIKE '%"+productType+"%' "); + map.put("TZGGLX", drawChangeType==null || "".equals(drawChangeType.trim())?null:"AND TZGGLX LIKE '%"+drawChangeType+"%' "); + map.put("ISNOTPRODUCTLOSS", cossLoss==null || "".equals(cossLoss.trim())?null:"AND ISNOTPRODUCTLOSS LIKE '%"+cossLoss+"%' "); + map.put("ERRORTYPE", errorType==null || "".equals(errorType.trim())?null:"AND ERRORTYPE LIKE '%"+errorType+"%' "); +// map.put("CHANGEREASON", changeReason==null?null:"AND APPLYNAME LIKE '%"+changeReason+"%' "); + + return map; + + } + + + + public ChangeFormBean() { + super(); + } + + public String generateSql() { + StringBuilder sql = new StringBuilder(); + for (Map.Entry entry : getMap().entrySet()) { + if(entry.getValue()!=null && !"".equals(entry.getValue())) { + sql.append(entry.getValue()); + } + } + return sql.toString(); + } + + public static void main(String[] args) { + System.out.println("'"+ + new ChangeFormBean("杨天乐","123",null,null,null,null,null,null,null,null,null,null).generateSql() + +"'"); + } + +} diff --git a/src/com/connor/dfl/plm/dfl040/DFL038Jframe.java b/src/com/connor/dfl/plm/dfl040/DFL038Jframe.java new file mode 100644 index 0000000..5e890c3 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl040/DFL038Jframe.java @@ -0,0 +1,1082 @@ +package com.connor.dfl.plm.dfl040; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.GraphicsEnvironment; +import java.awt.Insets; +import java.awt.Label; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.function.Consumer; +import java.util.function.IntConsumer; + +import javax.swing.BorderFactory; +import javax.swing.BoxLayout; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.border.Border; +import javax.swing.filechooser.FileSystemView; + +import org.apache.axis2.fastinfoset.FastInfosetBuilder; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.builder.StandardToStringStyle; +import org.apache.poi.hssf.util.CellRangeAddress; +import org.apache.poi.hssf.util.HSSFColor.RED; +import org.apache.poi.ss.usermodel.BorderStyle; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jacorb.idl.runtime.int_token; + +import com.connor.dfl.plm.util.DataBaseControl; +import com.connor.dfl.plm.util.ProgressBar; +import com.connor.dfl.plm.util.ProgressBarThread; +import com.lowagie.text.Row; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +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.util.MessageBox; + +import jdk.internal.org.objectweb.asm.tree.IntInsnNode; + +public class DFL038Jframe extends JFrame { + + private TCSession session; + + private String[] departs = new String[] { "全部", "冻干机产品部", "原料药事业部", "特需产品部" }; + + private String[] drawChangeType = new String[] { "全部", "其他" }; + + private String[] changeType = new String[] { "设计错误", "设计优化", "内部方案更改", "方案更改", "采购更改", "销售更改" }; + + private String[] productType = new String[] { "冻干机", "灭菌柜", "清洗机", "联动线", "自动机械", "灯检机" }; + + private String[] isCostLoss = new String[] { "是", "否" }; + + private String[] errorType = new String[] { "P&ID图", "容器图", "机架图", "BOM表", "外协件图", "平面布局图", "其他" }; + + private JLabel startDateLabel = new JLabel("申请日期晚于"); + private JLabel endDateLabel = new JLabel("申请日期早于"); + private JLabel depLabel = new JLabel("产品部门"); + private JLabel dirLabel = new JLabel("保存路径"); + private JTextField startDateField; + private JTextField endDateField; + private JComboBox comboBox; + private JTextField sourcefile; + + private JLabel applyNameLabel; + private JTextField applyNameField; + + private JLabel changeIdLabel; + private JTextField changeIdField; + + private JLabel productModNumLabel; + private JTextField productModNumField; + + private JLabel productIdLabel; + private JTextField productIdField; + + private JLabel clientNameLabel; + private JTextField clientNameField; + + private JLabel dutyDeptLabel; + private JComboBox dutyDeptBox; + + private JLabel dutyManLabel; + private JTextField dutyManField; + + private JLabel changeTypeLabel; + private JComboBox changeTypeBox; + + private JLabel productTypeLabel; + private JComboBox productTypeBox; + + private JLabel drawChangeTypeLabel; + private JComboBox drawChangeTypeBox; + + private JLabel isCostLossLabel; + private JComboBox isCostLossBox; + + private JLabel errorTypeLabel; + private JComboBox errorTypeBox; + + private JButton browserButton; + private JButton okbutton; + private JButton cancelButton; + private JPanel centerPanel1; + + private String[] title = new String[] { "产品部门", "产品名称", "变更通知单号", "产品型号", "客户名称", "更改类型", "更改原因", "图纸更改类型", "责任部门", + "责任人", "品号", "品名", "原版本", "现版本", "变更数量", "产品类型", "错误类型", "价格预告", "销售分类", "是否产生成本损失", "项目阶段", "料件领用分类", + "图纸发至", "项目编号", "通知紧急程度", "申请时间", "账套", "流程阶段" }; + + public DFL038Jframe(TCSession session) { + this.session = session; + departs = session.getPreferenceService().getStringValues("T2_ECNReport"); + changeType = session.getPreferenceService().getStringValues("T2_changeType"); + drawChangeType = session.getPreferenceService().getStringValues("T2_drawChangeType"); + productType = session.getPreferenceService().getStringValues("DFL_Form_Product_Type"); + errorType = session.getPreferenceService().getStringValues("DFL_Form_Error_Type"); + if (departs == null || changeType == null || productType == null || errorType == null || departs.length == 0 + || changeType.length == 0 || errorType.length == 0) { + MessageBox.post("首选项T2_ECNReport或者T2_changeType有问题,请联系管理员!", "错误", MessageBox.ERROR); + return; + } + + InitUI(); + } + + public DFL038Jframe() { + InitUI(); + } + + private void InitUI() { + // TODO Auto-generated method stub + // 初始化窗体 + + // 设置标题 + setTitle("变更通知单报表"); + + // 设置是否可以改变大小 + setResizable(false); + // 设置退出后进行的操作 + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + // 设置大小,以及居中显示 + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + Rectangle rect = ge.getMaximumWindowBounds(); + int sw = rect.width; + int sh = rect.height; + this.setBounds((sw - 1600) / 2, (sh - 1000) / 2, 1600, 1000); // 设置位置即大小 + + // 设置布局格式 + this.setLayout(new BorderLayout()); + + centerPanel1 = new JPanel(); + centerPanel1.setLayout(null); + + // 初始化控件加布局,先初始化控件,再考虑布局 + // 设置其余控件 + // 初始化日期控件 + Date date = new Date(); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + String time = df.format(date); + + applyNameLabel = new JLabel("申请人"); + applyNameLabel.setFont(new Font("微软雅黑", Font.BOLD, 20)); + applyNameField = new JTextField(); + applyNameField.setFont(new Font("微软雅黑", Font.BOLD, 20)); + + changeIdLabel = new JLabel("更改单号"); + changeIdLabel.setFont(new Font("微软雅黑", Font.BOLD, 20)); + changeIdLabel.setSize(100, 30); + changeIdField = new JTextField(10); + changeIdField.setSize(120, 30); + changeIdField.setFont(new Font("微软雅黑", Font.BOLD, 20)); + + startDateLabel.setFont(new Font("微软雅黑", Font.BOLD, 20)); + startDateLabel.setSize(100, 30); + startDateField = new JTextField(10); + startDateField.setText(time); + startDateField.setSize(120, 30); + startDateField.setFont(new Font("微软雅黑", Font.BOLD, 20)); + startDateField.setEditable(false); + + endDateLabel.setFont(new Font("微软雅黑", Font.BOLD, 20)); + endDateLabel.setSize(100, 30); + endDateField = new JTextField(10); + endDateField.setText(time); + endDateField.setSize(120, 30); + endDateField.setFont(new Font("微软雅黑", Font.BOLD, 20)); + endDateField.setEditable(false); + + productIdLabel = new JLabel("产品编号"); + productIdLabel.setFont(new Font("微软雅黑", Font.BOLD, 20)); + productIdLabel.setSize(100, 30); + productIdField = new JTextField(10); + productIdField.setSize(120, 30); + productIdField.setFont(new Font("微软雅黑", Font.BOLD, 20)); + + productModNumLabel = new JLabel("产品型号"); + productModNumLabel.setFont(new Font("微软雅黑", Font.BOLD, 20)); + productModNumLabel.setSize(100, 30); + productModNumField = new JTextField(10); + productModNumField.setFont(new Font("微软雅黑", Font.BOLD, 20)); + + clientNameLabel = new JLabel("客户名称"); + clientNameLabel.setFont(new Font("微软雅黑", Font.BOLD, 20)); + clientNameLabel.setSize(100, 30); + clientNameField = new JTextField(10); + clientNameField.setSize(120, 30); + clientNameField.setFont(new Font("微软雅黑", Font.BOLD, 20)); + + depLabel.setFont(new Font("微软雅黑", Font.BOLD, 20)); + depLabel.setSize(100, 30); + final DefaultComboBoxModel model = new DefaultComboBoxModel(); + comboBox = new JComboBox(model); + comboBox.setFont(new Font("微软雅黑", Font.BOLD, 20)); + model.addElement(""); + for (String string : departs) { + model.addElement(string); + } + + dutyDeptLabel = new JLabel("责任部门"); + dutyDeptLabel.setFont(new Font("微软雅黑", Font.BOLD, 20)); + dutyDeptLabel.setSize(100, 30); + final DefaultComboBoxModel dutyModel = new DefaultComboBoxModel(); + dutyDeptBox = new JComboBox(dutyModel); + dutyDeptBox.setFont(new Font("微软雅黑", Font.BOLD, 20)); + dutyModel.addElement(""); + for (String string : departs) { + dutyModel.addElement(string); + } + + dutyManLabel = new JLabel("责任人"); + dutyManLabel.setFont(new Font("微软雅黑", Font.BOLD, 20)); + dutyManLabel.setSize(100, 30); + dutyManField = new JTextField(10); + dutyManField.setSize(120, 30); + dutyManField.setFont(new Font("微软雅黑", Font.BOLD, 20)); + + changeTypeLabel = new JLabel("更改类型"); + changeTypeLabel.setFont(new Font("微软雅黑", Font.BOLD, 20)); + changeTypeLabel.setSize(100, 30); + final DefaultComboBoxModel changeTypeModel = new DefaultComboBoxModel(); + changeTypeBox = new JComboBox(changeTypeModel); + changeTypeBox.setBounds(200, 190, 170, 30); + changeTypeBox.setFont(new Font("微软雅黑", Font.BOLD, 20)); + changeTypeModel.addElement(""); + for (String string : changeType) { + changeTypeModel.addElement(string); + } + + productTypeLabel = new JLabel("产品类型"); + productTypeLabel.setFont(new Font("微软雅黑", Font.BOLD, 20)); + productTypeLabel.setSize(100, 30); + final DefaultComboBoxModel productTypeModel = new DefaultComboBoxModel(); + productTypeBox = new JComboBox(productTypeModel); + productTypeBox.setBounds(200, 190, 170, 30); + productTypeBox.setFont(new Font("微软雅黑", Font.BOLD, 20)); + productTypeModel.addElement(""); + for (String string : productType) { + productTypeModel.addElement(string); + } + + drawChangeTypeLabel = new JLabel("图纸更改类型"); + drawChangeTypeLabel.setFont(new Font("微软雅黑", Font.BOLD, 20)); + drawChangeTypeLabel.setSize(100, 30); + final DefaultComboBoxModel drawChangeTypeModel = new DefaultComboBoxModel(); + drawChangeTypeBox = new JComboBox(drawChangeTypeModel); + drawChangeTypeBox.setBounds(200, 190, 170, 30); + drawChangeTypeBox.setFont(new Font("微软雅黑", Font.BOLD, 20)); + drawChangeTypeModel.addElement(""); + for (String string : drawChangeType) { + drawChangeTypeModel.addElement(string); + } + isCostLossLabel = new JLabel("是否产生成本损失"); + isCostLossLabel.setFont(new Font("微软雅黑", Font.BOLD, 20)); + isCostLossLabel.setSize(100, 30); + final DefaultComboBoxModel isCostLossModel = new DefaultComboBoxModel(); + isCostLossBox = new JComboBox(isCostLossModel); + isCostLossBox.setBounds(200, 190, 170, 30); + isCostLossBox.setFont(new Font("微软雅黑", Font.BOLD, 20)); + isCostLossModel.addElement(""); + for (String string : isCostLoss) { + isCostLossModel.addElement(string); + } + + errorTypeLabel = new JLabel("错误类型"); + errorTypeLabel.setFont(new Font("微软雅黑", Font.BOLD, 20)); + errorTypeLabel.setSize(100, 30); + final DefaultComboBoxModel errorTypeModel = new DefaultComboBoxModel(); + errorTypeBox = new JComboBox(errorTypeModel); + errorTypeBox.setBounds(200, 190, 170, 30); + errorTypeBox.setFont(new Font("微软雅黑", Font.BOLD, 20)); + errorTypeModel.addElement(""); + for (String string : errorType) { + errorTypeModel.addElement(string); + } + + dirLabel.setFont(new Font("微软雅黑", Font.BOLD, 20)); + + // 注册日期面板 + DateChooser dateChooser1 = DateChooser.getInstance("yyyy-MM-dd"); + + DateChooser dateChooser2 = DateChooser.getInstance("yyyy-MM-dd"); + + dateChooser1.register(startDateField); + dateChooser2.register(endDateField); + + // 设置路径框 + sourcefile = new JTextField(10); + sourcefile.setFont(new Font("微软雅黑", Font.BOLD, 20)); + sourcefile.setEditable(false); + + FileSystemView fsv = FileSystemView.getFileSystemView(); + File com = fsv.getHomeDirectory(); + sourcefile.setText(com.getPath()); + + // 设置浏览按钮 + browserButton = new JButton("浏览"); + browserButton.setFont(new Font("微软雅黑", Font.BOLD, 20)); + browserButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + JFileChooser fcDlg = new JFileChooser(); + fcDlg.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + fcDlg.setDialogTitle("请选择路径"); + int returnVal = fcDlg.showOpenDialog(null); + if (returnVal == JFileChooser.APPROVE_OPTION) { + String filepath = fcDlg.getSelectedFile().getPath(); + sourcefile.setText(filepath); + } + } + }); + + // 设置导出按钮,添加事件,方便测试 + okbutton = new JButton("开始导出"); + okbutton.setFont(new Font("微软雅黑", Font.BOLD, 20)); + + cancelButton = new JButton("取消"); + cancelButton.setFont(new Font("微软雅黑", Font.BOLD, 20)); + + applyNameLabel.setBounds(160, 100, 60, 30); +// applyNameLabel.setBorder(BorderFactory.createLineBorder(Color.red)); + applyNameField.setBounds(260, 100, 150, 30); + + changeIdLabel.setBounds(450, 100, 80, 30); +// applyNameLabel.setBorder(BorderFactory.createLineBorder(Color.red)); + changeIdField.setBounds(560, 100, 150, 30); + + startDateLabel.setBounds(760, 100, 120, 30); + startDateField.setBounds(900, 100, 150, 30); + + endDateLabel.setBounds(1100, 100, 120, 30); + endDateField.setBounds(1240, 100, 150, 30); + +// ------------------------------------- + + productIdLabel.setBounds(160, 300, 80, 30); +// applyNameLabel.setBorder(BorderFactory.createLineBorder(Color.red)); + productIdField.setBounds(260, 300, 150, 30); + + productModNumLabel.setBounds(450, 300, 80, 30); +// applyNameLabel.setBorder(BorderFactory.createLineBorder(Color.red)); + productModNumField.setBounds(560, 300, 150, 30); + + clientNameLabel.setBounds(760, 300, 120, 30); + clientNameField.setBounds(900, 300, 150, 30); + + changeTypeLabel.setBounds(1100, 300, 120, 30); + changeTypeBox.setBounds(1240, 300, 150, 30); + + // ------------------------------------- + + depLabel.setBounds(160, 500, 80, 30); +// applyNameLabel.setBorder(BorderFactory.createLineBorder(Color.red)); + comboBox.setBounds(260, 500, 300, 30); + + dutyDeptLabel.setBounds(600, 500, 80, 30); +// applyNameLabel.setBorder(BorderFactory.createLineBorder(Color.red)); + dutyDeptBox.setBounds(710, 500, 300, 30); + + dutyManLabel.setBounds(1050, 500, 120, 30); + dutyManField.setBounds(1140, 500, 150, 30); + + // ------------------------------------- + + productTypeLabel.setBounds(160, 700, 80, 30); +// applyNameLabel.setBorder(BorderFactory.createLineBorder(Color.red)); + productTypeBox.setBounds(260, 700, 150, 30); + + drawChangeTypeLabel.setBounds(450, 700, 150, 30); +// applyNameLabel.setBorder(BorderFactory.createLineBorder(Color.red)); + drawChangeTypeBox.setBounds(610, 700, 150, 30); + + isCostLossLabel.setBounds(800, 700, 160, 30); + isCostLossBox.setBounds(990, 700, 150, 30); + + errorTypeLabel.setBounds(1160, 700, 120, 30); + errorTypeBox.setBounds(1280, 700, 150, 30); + + // ------------------------------------- + + dirLabel.setBounds(500, 800, 120, 30); + sourcefile.setBounds(600, 800, 300, 30); + browserButton.setBounds(920, 800, 80, 30); + + // ------------------------------------- + okbutton.setBounds(650, 900, 120, 30); + cancelButton.setBounds(850, 900, 80, 30); + + okbutton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + ProgressBarThread progressBarThread = new ProgressBarThread("数据导出", "数据导出中,请稍等..."); + progressBarThread.setBool(true); + progressBarThread.start(); + +// System.out.println(startDateField.getText()); +// System.out.println(endDateField.getText()); +// System.out.println(model.getElementAt(comboBox.getSelectedIndex())); +// System.out.println(sourcefile.getText()); + String startTime = startDateField.getText(); + String endTime = endDateField.getText(); + String depart = model.getElementAt(comboBox.getSelectedIndex()); + String selectPath = sourcefile.getText(); + + ChangeFormBean changeFormBean = new ChangeFormBean(applyNameField.getText(), changeIdField.getText(), + productIdField.getText(), productModNumField.getText(), clientNameField.getText(), + dutyModel.getElementAt(dutyDeptBox.getSelectedIndex()), dutyManField.getText(), + changeTypeModel.getElementAt(changeTypeBox.getSelectedIndex()), + productTypeModel.getElementAt(productTypeBox.getSelectedIndex()), + drawChangeTypeModel.getElementAt(drawChangeTypeBox.getSelectedIndex()), + (String) isCostLossModel.getElementAt(isCostLossBox.getSelectedIndex()), + errorTypeModel.getElementAt(errorTypeBox.getSelectedIndex())); + String conditions = changeFormBean.generateSql(); + String leftConditions = "D.OBJECTCODE = F.OBJECTCODE where "; + DataBaseControl control = new DataBaseControl("oracle.jdbc.driver.OracleDriver", + "jdbc:oracle:thin:@192.168.1.138:1521/tc12", "infodba", "infodba"); + control.openDataBase(); + + String colString = " F.PRODUCTDEPARTMENT,F.PRODUCTNAME,F.CHANGELISTCODE,F.PROJECTMODEL,F.CLIENTNAME,F.CHANGETYPE,F.CHANGEREASON,F.TZGGLX,F.DUTYDEPARTMENT,F.DUTYMAN,D.PH,D.PM,D.YBB,D.XBB,D.BGSL,F.PRODUCTTYPE,F.ERRORTYPE,F.PRICEBOOKING,F.SALSECLASSIFY,F.ISNOTPRODUCTLOSS,F.XMJD,F.RECEIVECLASSIFY,F.DRAWINGTO,F.PROJECTCODE,F.NOTIFYEMERGENCYPROCEDURES,F.APPLYDATE,F.ACCOUNTSET "; + + // 获取需要判断的列 + + // 如果先进行进行判断 + String sql1 = "select " + colString + " from DFL_CHANGEFORM F LEFT OUTER JOIN DFL_CHANGEDETAILS D ON " + + leftConditions + " (F.OBJECTCODE like'ECN%' or F.OBJECTCODE like'QECN%') " + + "AND F.PRODUCTDEPARTMENT = '" + depart + "' AND " + + " F.APPLYDATE IS NOT NULL AND to_date(F.applydate,'yyyy-MM-dd HH24:mi:ss') >= to_date('" + + startTime + + "','yyyy-MM-dd HH24:mi:ss') AND to_date(F.applydate,'yyyy-MM-dd HH24:mi:ss') <= to_date('" + + endTime + "','yyyy-MM-dd HH24:mi:ss') " + conditions+" order by F.PRODUCTDEPARTMENT,F.APPLYDATE"; + if (depart == null || depart.trim().equals("")) { + sql1 = "select " + colString + " from DFL_CHANGEFORM F LEFT OUTER JOIN DFL_CHANGEDETAILS D ON " + leftConditions + + " (F.OBJECTCODE like'ECN%' or F.OBJECTCODE like'QECN%') " + " AND " + + " F.APPLYDATE IS NOT NULL AND to_date(F.applydate,'yyyy-MM-dd HH24:mi:ss') >= to_date('" + + startTime + + "','yyyy-MM-dd HH24:mi:ss') AND to_date(F.applydate,'yyyy-MM-dd HH24:mi:ss') <= to_date('" + + endTime + "','yyyy-MM-dd HH24:mi:ss') " + conditions+" order by F.PRODUCTDEPARTMENT,F.APPLYDATE"; + } else if (depart != null && "全部".equals(depart)) { + sql1 = "select " + colString + " from DFL_CHANGEFORM F LEFT OUTER JOIN DFL_CHANGEDETAILS D ON " + leftConditions + + " (F.OBJECTCODE like'ECN%' or F.OBJECTCODE like'QECN%') " + " AND " + + " F.APPLYDATE IS NOT NULL AND to_date(F.applydate,'yyyy-MM-dd HH24:mi:ss') >= to_date('" + + startTime + + "','yyyy-MM-dd HH24:mi:ss') AND to_date(F.applydate,'yyyy-MM-dd HH24:mi:ss') <= to_date('" + + endTime + "','yyyy-MM-dd HH24:mi:ss') " + conditions+" order by F.PRODUCTDEPARTMENT,F.APPLYDATE"; + } + System.out.println(sql1); + + ResultSet dbQuery = control.dbQuery3(sql1); + + String sql2 = "select count(*),CHANGETYPE,substr(applydate,0,7) as date1 FROM DFL_CHANGEFORM WHERE productdepartment='" + + depart + + "' AND (OBJECTCODE like'ECN%' or OBJECTCODE like'QECN%') AND CHANGETYPE IS NOT NULL AND applydate IS NOT NULL AND to_date(applydate,'yyyy-MM-dd HH24:mi:ss') >= to_date('" + + startTime + + "','yyyy-MM-dd HH24:mi:ss') AND to_date(applydate,'yyyy-MM-dd HH24:mi:ss') <= to_date('" + + endTime + "','yyyy-MM-dd HH24:mi:ss') " + conditions + + " group by substr(applydate,0,7),CHANGETYPE order by date1 asc"; + if (depart == null || depart.trim().equals("")) { + sql2 = "select count(*),CHANGETYPE,substr(applydate,0,7) as date1 FROM DFL_CHANGEFORM WHERE (OBJECTCODE like'ECN%' or OBJECTCODE like'QECN%') AND CHANGETYPE IS NOT NULL AND applydate IS NOT NULL AND to_date(applydate,'yyyy-MM-dd HH24:mi:ss') >= to_date('" + + startTime + + "','yyyy-MM-dd HH24:mi:ss') AND to_date(applydate,'yyyy-MM-dd HH24:mi:ss') <= to_date('" + + endTime + "','yyyy-MM-dd HH24:mi:ss') " + conditions + + " group by substr(applydate,0,7),CHANGETYPE order by date1 asc"; + } else if (depart != null && "全部".equals(depart)) { + sql2 = "select count(*),CHANGETYPE,substr(applydate,0,7) as date1 FROM DFL_CHANGEFORM WHERE (OBJECTCODE like'ECN%' or OBJECTCODE like'QECN%') AND CHANGETYPE IS NOT NULL AND applydate IS NOT NULL AND to_date(applydate,'yyyy-MM-dd HH24:mi:ss') >= to_date('" + + startTime + + "','yyyy-MM-dd HH24:mi:ss') AND to_date(applydate,'yyyy-MM-dd HH24:mi:ss') <= to_date('" + + endTime + "','yyyy-MM-dd HH24:mi:ss') " + conditions + + " group by substr(applydate,0,7),CHANGETYPE order by date1 asc"; + } + ResultSet dbQuery2 = control.dbQuery3(sql2); + + System.out.println(sql1); + System.out.println(sql2); + +// if(dbQuery==null) { +// MessageBox.post("查无数据!", "提示", MessageBox.INFORMATION); +// return; +// } + + Date date = new Date(); + SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd_HHmm"); + String currentTime = df.format(date); + String absoluteFilePath = selectPath + "\\" + "更改通知单报表-" + currentTime + ".xlsx"; +// System.out.println(absoluteFilePath); + File file = new File(absoluteFilePath); + if (!file.exists()) { + try { + file.createNewFile(); +// System.out.println("111:"+file.getAbsolutePath()); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + try { + XSSFWorkbook workbook = new XSSFWorkbook(); + XSSFCellStyle cellStyle = workbook.createCellStyle(); + cellStyle.setBorderBottom(BorderStyle.THIN); // 下边框 + cellStyle.setBorderLeft(BorderStyle.THIN);// 左边框 + cellStyle.setBorderTop(BorderStyle.THIN);// 上边框 + cellStyle.setBorderRight(BorderStyle.THIN);// 右边框 + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 垂直居中 + cellStyle.setAlignment(HorizontalAlignment.CENTER); // 水平居中 + cellStyle.setWrapText(true); + // 写第一个单元格 + XSSFSheet sheet2 = workbook.createSheet("详细清单"); + + int i = 0; + XSSFRow titleRow = sheet2.createRow(i); + for (int j = 0; j < title.length; j++) { + XSSFCell createCell = titleRow.createCell(j); + createCell.setCellStyle(cellStyle); + createCell.setCellValue(title[j]); + } + Boolean flag = false; + Boolean isRelease = true; + String lastChangeFormId = null; + while (dbQuery.next()) { + i++; + XSSFRow Row = sheet2.createRow(i); + String changeFormId = dbQuery.getString(3); + if (changeFormId!=null && !changeFormId.equals(lastChangeFormId)) { + List queryObject = queryObject("零组件 ID", new String[] { "零组件 ID" }, + new String[] { changeFormId }); + System.out.println(changeFormId); + if (queryObject!=null && queryObject.size() > 0) { + TCComponent component = queryObject.get(0); + AIFComponentContext[] versions = component.getChildren("revision_list"); + TCComponent versionComponent = (TCComponent) versions[0].getComponent(); + TCProperty tcProperty = versionComponent.getTCProperty("release_status_list"); + TCComponent[] releases = tcProperty.getReferenceValueArray(); + if (releases == null || releases.length <= 0) { + isRelease = false; + } + } + } + + for (int j = 0; j < title.length - 1; j++) { + XSSFCell createCell = Row.createCell(j); + createCell.setCellStyle(cellStyle); + createCell.setCellValue(dbQuery.getString(j + 1)); + if (j == title.length - 2) { + createCell = Row.createCell(j + 1); + createCell.setCellStyle(cellStyle); + createCell.setCellValue(isRelease ? "已发布" : "未发布"); + } + } + } + + // 写第二个单元 + // 创建表头 + XSSFSheet sheet1 = workbook.createSheet("月份清单"); + XSSFRow titleRow2 = sheet1.createRow(0); + for (int j = 0; j < changeType.length; j++) { + XSSFCell createCell = titleRow2.createCell(j + 1); + createCell.setCellStyle(cellStyle); + createCell.setCellValue(changeType[j]); + } + Set set = new HashSet(); + + while (dbQuery2.next()) { + set.add(dbQuery2.getString(3)); + } + dbQuery2.first(); + dbQuery2.previous(); + + ArrayList list = new ArrayList(); + for (String string2 : set) { + list.add(string2); + } + +// Collections.sort(list,new MyComparator()); + Collections.sort(list); + + // 创建列头 + + XSSFRow[] rows = new XSSFRow[list.size()]; + for (int j = 0; j < list.size(); j++) { + rows[j] = sheet1.createRow(j + 1); + XSSFCell createCell = rows[j].createCell(0); + createCell.setCellStyle(cellStyle); + createCell.setCellValue( + list.get(j).endsWith("-") ? list.get(j).substring(0, list.get(j).length() - 1) + : list.get(j)); + } + + // 初始化每列的合计 + + int num[] = new int[changeType.length]; + for (int j = 0; j < changeType.length; j++) { + num[j] = 0; + } + + for (int rowNum = 1; rowNum <= list.size(); rowNum++) { + for (int colNum = 1; colNum <= changeType.length; colNum++) { + XSSFCell createCell = rows[rowNum - 1].createCell(colNum); + createCell.setCellStyle(cellStyle); + createCell.setCellValue(0); + } + } + + System.out.println(dbQuery2.getRow()+"--1--"+changeType.length); + int[][] CTN = new int[list.size()][changeType.length]; + + String year = list.get(0).substring(0,4); + int lastRN = list.size()+1; + + while (dbQuery2.next()) { + for (int j = 0; j < list.size(); j++) { + +// System.out.println(year+"-----2------"+rows[j].getCell(0).getStringCellValue().substring(0,4)); +// if(!year.equals(rows[j].getCell(0).getStringCellValue().substring(0,4))) { +// System.out.println(year); +// year = rows[j].getCell(0).getStringCellValue().substring(0,4); +// System.out.println("after"+year); +// XSSFRow row = sheet1.createRow(lastRN++); +// row.createCell(0).setCellValue("合计:"); +// for(int o=0;o 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; + } + } + + private void listByYear(String filePath) throws Exception { + // TODO Auto-generated method stub + FileInputStream fis = FileUtils.openInputStream(new File(filePath)); + XSSFWorkbook workbook = new XSSFWorkbook(fis); + XSSFCellStyle cellStyle = workbook.createCellStyle(); + cellStyle.setBorderBottom(BorderStyle.THIN); // 下边框 + cellStyle.setBorderLeft(BorderStyle.THIN);// 左边框 + cellStyle.setBorderTop(BorderStyle.THIN);// 上边框 + cellStyle.setBorderRight(BorderStyle.THIN);// 右边框 + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 垂直居中 + cellStyle.setAlignment(HorizontalAlignment.CENTER); // 水平居中 + cellStyle.setWrapText(true); + int startRow = 1; + XSSFSheet sheet = (XSSFSheet) workbook.getSheet("月份清单"); + int lastRowNum = sheet.getLastRowNum(); + int[] num = new int[changeType.length]; + for(int i=0;i comboBox; + private JTextField sourcefile; + private JButton okbutton; + private JButton browserButton; + private String[] title = new String[] {"OBJECTCODE","APPLYNAME","APPLYDATE","PROJECTCODE","CLIENTNAME","PRODUCTDEPARTMENT"}; + + + public DFL038JframeProtol(TCSession session) { + this.session = session; + daparts = session.getPreferenceService().getStringValues("T2_ECNReport"); + InitUI(); + } + + public DFL038JframeProtol() { + InitUI(); + } + + private void InitUI() { + // TODO Auto-generated method stub + //初始化窗体 + + // 设置标题 + setTitle("变更通知单报表"); + + // 设置是否可以改变大小 + setResizable(false); + // 设置退出后进行的操作 + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + //设置大小,以及居中显示 + GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment(); + Rectangle rect=ge.getMaximumWindowBounds(); + int sw=rect.width; + int sh=rect.height; + this.setBounds((sw-500)/2,(sh-400)/2,500,400); //设置位置即大小 + + //设置自由布局 + this.setLayout(null); + + + + //开始初始化各种控件 +// label1.setBorder(BorderFactory.createBevelBorder(1)); + + //先设置前面显示不变的Jlabel + label1.setFont(new Font("微软雅黑", Font.BOLD, 15)); + label1.setBounds(50, 50, 100, 30); + + label2.setFont(new Font("微软雅黑", Font.BOLD, 15)); + label2.setBounds(50, 120, 100, 30); + + label3.setFont(new Font("微软雅黑", Font.BOLD, 15)); + label3.setBounds(50, 190, 100, 30); +// + label4.setFont(new Font("微软雅黑", Font.BOLD, 15)); + label4.setBounds(50, 260, 100, 30); + + //设置其余控件 + //初始化日期控件 + Date date = new Date(); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + String time = df.format(date); + + startDateField = new JTextField(time); + startDateField.setBounds(250, 50, 120, 30); + startDateField.setFont(new Font("微软雅黑", Font.BOLD, 15)); + + endDateField = new JTextField(time); + endDateField.setBounds(250, 120, 120, 30); + endDateField.setFont(new Font("微软雅黑", Font.BOLD, 15)); + + //注册日期面板 + DateChooser dateChooser1 = DateChooser.getInstance("yyyy-MM-dd"); + + DateChooser dateChooser2 = DateChooser.getInstance("yyyy-MM-dd"); + + dateChooser1.register(startDateField); + dateChooser2.register(endDateField); + + //初始化部门下拉框 + DefaultComboBoxModel model = new DefaultComboBoxModel(); + comboBox = new JComboBox(model); + comboBox.setBounds(200,190,170,30); + comboBox.setFont(new Font("微软雅黑", Font.BOLD, 15)); + for (String string : daparts) { + model.addElement(string); + } + + //设置路径框 + sourcefile = new JTextField(); + sourcefile.setFont(new Font("微软雅黑", Font.BOLD, 15)); + sourcefile.setBounds(150, 260, 220, 30); + sourcefile.setEditable(false); + + FileSystemView fsv = FileSystemView.getFileSystemView(); + File com=fsv.getHomeDirectory(); + sourcefile.setText(com.getPath()); + + + //设置浏览按钮 + browserButton = new JButton("浏览"); + browserButton.setBounds(390, 260, 80, 30); + browserButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + JFileChooser fcDlg = new JFileChooser(); + fcDlg.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + fcDlg.setDialogTitle("请选择路径"); + int returnVal = fcDlg.showOpenDialog(null); + if (returnVal == JFileChooser.APPROVE_OPTION) { + String filepath = fcDlg.getSelectedFile().getPath(); + sourcefile.setText(filepath); + } + } + }); + + //设置导出按钮,添加事件,方便测试 + okbutton = new JButton("开始导出"); + okbutton.setBounds(200, 300, 100, 30); + + okbutton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + +// ProgressBarThread progressBarThread = new ProgressBarThread("数据导出", "数据导出中,请稍等..."); +// progressBarThread.setBool(true); +// progressBarThread.start(); + +// System.out.println(startDateField.getText()); +// System.out.println(endDateField.getText()); +// System.out.println(model.getElementAt(comboBox.getSelectedIndex())); +// System.out.println(sourcefile.getText()); + String startTime = startDateField.getText(); + String endTime = endDateField.getText(); +// String depart = model.getElementAt(comboBox.getSelectedIndex()); + String depart = "冻干机产品部"; + String selectPath = sourcefile.getText(); + + + DataBaseControl control = new DataBaseControl("oracle.jdbc.driver.OracleDriver", + "jdbc:oracle:thin:@192.168.1.138:1521/tc12", + "infodba", + "infodba"); + control.openDataBase(); + + //如果线进行判断 + + String sql1 = "select * from DFL_CHANGEFORM WHERE "+" OBJECTCODE LIKE '00%' "+"AND PRODUCTDEPARTMENT = '"+depart+"' AND "+" APPLYDATE IS NOT NULL AND to_date(applydate,'yyyy-MM-dd HH24:mi:ss') >= to_date('"+startTime+"','yyyy-MM-dd HH24:mi:ss') AND to_date(applydate,'yyyy-MM-dd HH24:mi:ss') <= to_date('"+endTime+"','yyyy-MM-dd HH24:mi:ss') "; + + + ResultSet dbQuery = control.dbQuery(sql1); + + + String sql2 = "select count(*),CHANGETYPE,substr(applydate,0,7) as date1 FROM DFL_CHANGEFORM WHERE productdepartment='"+depart+"' AND OBJECTCODE LIKE '00%' AND CHANGETYPE IS NOT NULL AND applydate IS NOT NULL AND to_date(applydate,'yyyy-MM-dd HH24:mi:ss') >= to_date('"+startTime+"','yyyy-MM-dd HH24:mi:ss') AND to_date(applydate,'yyyy-MM-dd HH24:mi:ss') <= to_date('"+endTime+"','yyyy-MM-dd HH24:mi:ss') "+" group by substr(applydate,0,7),CHANGETYPE order by date1 asc"; + + ResultSet dbQuery2 = control.dbQuery(sql2); + + changeType = new String[] {"手动激活","设计错误","设计错误1"}; + + + if(dbQuery==null) { + MessageBox.post("查无数据!", "提示", MessageBox.INFORMATION); + return; + } + + + + + Date date = new Date(); + SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd_HHmm"); + String currentTime = df.format(date); + String absoluteFilePath = selectPath+"\\"+ "更改通知单报表-"+currentTime+".xlsx"; +// System.out.println(absoluteFilePath); + File file = new File(absoluteFilePath); + if(!file.exists()) { + try { + file.createNewFile(); +// System.out.println("111:"+file.getAbsolutePath()); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + try { + XSSFWorkbook workbook = new XSSFWorkbook(); + XSSFCellStyle cellStyle = workbook.createCellStyle(); + cellStyle.setBorderBottom(BorderStyle.THIN); //下边框 + cellStyle.setBorderLeft(BorderStyle.THIN);//左边框 + cellStyle.setBorderTop(BorderStyle.THIN);//上边框 + cellStyle.setBorderRight(BorderStyle.THIN);//右边框 + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 垂直居中 + cellStyle.setAlignment(HorizontalAlignment.CENTER); // 水平居中 + + + //写第一个单元格 + XSSFSheet sheet2 = workbook.createSheet("详细清单"); + + int i=0; + XSSFRow titleRow = sheet2.createRow(i); + for(int j =0;j size.width - 295) { + x = size.width - 295; + } + if (y < size.height - 170) { + } else { + y -= 188; + } + pop = PopupFactory.getSharedInstance().getPopup(owner, monthPanel, x, y); + pop.show(); + isShow = true; + } + + /** + * 最上面的面板用来显示月份的增减 + */ + private class JP1 extends JPanel { + private static final long serialVersionUID = -5638853772805561174L; + JLabel yearleft, yearright, monthleft, monthright, center, centercontainer; + + public JP1() { + super(new BorderLayout()); + this.setBackground(new Color(160, 185, 215)); + initJP1(); + } + + private void initJP1() { + yearleft = new JLabel(" <<", JLabel.CENTER); + yearleft.setToolTipText("上一年"); + yearright = new JLabel(">> ", JLabel.CENTER); + yearright.setToolTipText("下一年"); + yearleft.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); + yearright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); + + monthleft = new JLabel(" <", JLabel.RIGHT); + monthleft.setToolTipText("上一月"); + monthright = new JLabel("> ", JLabel.LEFT); + monthright.setToolTipText("下一月"); + monthleft.setBorder(BorderFactory.createEmptyBorder(2, 30, 0, 0)); + monthright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 30)); + + centercontainer = new JLabel("", JLabel.CENTER); + centercontainer.setLayout(new BorderLayout()); + center = new JLabel("", JLabel.CENTER); + + centercontainer.add(monthleft, BorderLayout.WEST); + centercontainer.add(center, BorderLayout.CENTER); + centercontainer.add(monthright, BorderLayout.EAST); + + this.add(yearleft, BorderLayout.WEST); + this.add(centercontainer, BorderLayout.CENTER); + this.add(yearright, BorderLayout.EAST); + this.setPreferredSize(new Dimension(295, 25)); + + updateDate(); + + yearleft.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent me) { + yearleft.setCursor(new Cursor(Cursor.HAND_CURSOR)); + yearleft.setForeground(Color.RED); + } + + public void mouseExited(MouseEvent me) { + yearleft.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + yearleft.setForeground(Color.BLACK); + } + + public void mousePressed(MouseEvent me) { + select.add(Calendar.YEAR, -1); + yearleft.setForeground(Color.WHITE); + refresh(); + } + + public void mouseReleased(MouseEvent me) { + yearleft.setForeground(Color.BLACK); + } + }); + yearright.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent me) { + yearright.setCursor(new Cursor(Cursor.HAND_CURSOR)); + yearright.setForeground(Color.RED); + } + + public void mouseExited(MouseEvent me) { + yearright.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + yearright.setForeground(Color.BLACK); + } + + public void mousePressed(MouseEvent me) { + select.add(Calendar.YEAR, 1); + yearright.setForeground(Color.WHITE); + refresh(); + } + + public void mouseReleased(MouseEvent me) { + yearright.setForeground(Color.BLACK); + } + }); + monthleft.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent me) { + monthleft.setCursor(new Cursor(Cursor.HAND_CURSOR)); + monthleft.setForeground(Color.RED); + } + + public void mouseExited(MouseEvent me) { + monthleft.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + monthleft.setForeground(Color.BLACK); + } + + public void mousePressed(MouseEvent me) { + select.add(Calendar.MONTH, -1); + monthleft.setForeground(Color.WHITE); + refresh(); + } + + public void mouseReleased(MouseEvent me) { + monthleft.setForeground(Color.BLACK); + } + }); + monthright.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent me) { + monthright.setCursor(new Cursor(Cursor.HAND_CURSOR)); + monthright.setForeground(Color.RED); + } + + public void mouseExited(MouseEvent me) { + monthright.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + monthright.setForeground(Color.BLACK); + } + + public void mousePressed(MouseEvent me) { + select.add(Calendar.MONTH, 1); + monthright.setForeground(Color.WHITE); + refresh(); + } + + public void mouseReleased(MouseEvent me) { + monthright.setForeground(Color.BLACK); + } + }); + } + + private void updateDate() { + center.setText(select.get(Calendar.YEAR) + "年" + (select.get(Calendar.MONTH) + 1) + "月"); + } + } + + private class JP2 extends JPanel { + private static final long serialVersionUID = -8176264838786175724L; + + public JP2() { + this.setPreferredSize(new Dimension(295, 20)); + } + + protected void paintComponent(Graphics g) { + g.setFont(font); + g.drawString("星期日 星期一 星期二 星期三 星期四 星期五 星期六", 5, 10); + g.drawLine(0, 15, getWidth(), 15); + } + + private void updateDate() { + + } + } + + private class JP3 extends JPanel { + private static final long serialVersionUID = 43157272447522985L; + + public JP3() { + super(new GridLayout(6, 7)); + this.setPreferredSize(new Dimension(295, 100)); + initJP3(); + } + + private void initJP3() { + updateDate(); + } + + public void updateDate() { + this.removeAll(); + lm.clear(); + Date temp = select.getTime(); + Calendar select = Calendar.getInstance(); + select.setTime(temp); + select.set(Calendar.DAY_OF_MONTH, 1); + int index = select.get(Calendar.DAY_OF_WEEK); + int sum = (index == 1 ? 8 : index); + select.add(Calendar.DAY_OF_MONTH, 0 - sum); + for (int i = 0; i < 42; i++) { + select.add(Calendar.DAY_OF_MONTH, 1); + lm.addLabel(new MyLabel(select.get(Calendar.YEAR), select.get(Calendar.MONTH), select.get(Calendar.DAY_OF_MONTH))); + } + for (MyLabel my : lm.getLabels()) { + this.add(my); + } + select.setTime(temp); + } + } + + private class MyLabel extends JLabel implements Comparator, MouseListener, MouseMotionListener { + private static final long serialVersionUID = 3668734399227577214L; + private int year, month, day; + private boolean isSelected; + + public MyLabel(int year, int month, int day) { + super("" + day, JLabel.CENTER); + this.year = year; + this.day = day; + this.month = month; + this.addMouseListener(this); + this.addMouseMotionListener(this); + this.setFont(font); + if (month == select.get(Calendar.MONTH)) { + this.setForeground(Color.BLACK); + } else { + this.setForeground(Color.LIGHT_GRAY); + } + if (day == select.get(Calendar.DAY_OF_MONTH)) { + this.setBackground(new Color(160, 185, 215)); + } else { + this.setBackground(Color.WHITE); + } + } + + public boolean getIsSelected() { + return isSelected; + } + + public void setSelected(boolean b, boolean isDrag) { + isSelected = b; + if (b && !isDrag) { + int temp = select.get(Calendar.MONTH); + select.set(year, month, day); + if (temp == month) { + SwingUtilities.updateComponentTreeUI(jp3); + } else { + refresh(); + } + } + this.repaint(); + } + + protected void paintComponent(Graphics g) { + if (day == select.get(Calendar.DAY_OF_MONTH) && month == select.get(Calendar.MONTH)) { + //如果当前日期是选择日期,则高亮显示 + g.setColor(new Color(160, 185, 215)); + g.fillRect(0, 0, getWidth(), getHeight()); + } + if (year == now.get(Calendar.YEAR) && month == now.get(Calendar.MONTH) && day == now.get(Calendar.DAY_OF_MONTH)) { + //如果日期和当前日期一样,则用红框 + Graphics2D gd = (Graphics2D) g; + gd.setColor(Color.RED); + Polygon p = new Polygon(); + p.addPoint(0, 0); + p.addPoint(getWidth() - 1, 0); + p.addPoint(getWidth() - 1, getHeight() - 1); + p.addPoint(0, getHeight() - 1); + gd.drawPolygon(p); + } + if (isSelected) {//如果被选中了就画出一个虚线框出来 + Stroke s = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL, 1.0f, new float[] { 2.0f, 2.0f }, 1.0f); + Graphics2D gd = (Graphics2D) g; + gd.setStroke(s); + gd.setColor(Color.BLACK); + Polygon p = new Polygon(); + p.addPoint(0, 0); + p.addPoint(getWidth() - 1, 0); + p.addPoint(getWidth() - 1, getHeight() - 1); + p.addPoint(0, getHeight() - 1); + gd.drawPolygon(p); + } + super.paintComponent(g); + } + + public boolean contains(Point p) { + return this.getBounds().contains(p); + } + + private void update() { + repaint(); + } + + public void mouseClicked(MouseEvent e) { + } + + public void mousePressed(MouseEvent e) { + isSelected = true; + update(); + } + + public void mouseReleased(MouseEvent e) { + Point p = SwingUtilities.convertPoint(this, e.getPoint(), jp3); + lm.setSelect(p, false); + commit(); + } + + public void mouseEntered(MouseEvent e) { + } + + public void mouseExited(MouseEvent e) { + } + + public void mouseDragged(MouseEvent e) { + Point p = SwingUtilities.convertPoint(this, e.getPoint(), jp3); + lm.setSelect(p, true); + } + + public void mouseMoved(MouseEvent e) { + } + + public int compare(MyLabel o1, MyLabel o2) { + Calendar c1 = Calendar.getInstance(); + c1.set(o1.year, o2.month, o1.day); + Calendar c2 = Calendar.getInstance(); + c2.set(o2.year, o2.month, o2.day); + return c1.compareTo(c2); + } + } + + private class LabelManager { + private List list; + + public LabelManager() { + list = new ArrayList(); + } + + public List getLabels() { + return list; + } + + public void addLabel(MyLabel my) { + list.add(my); + } + + public void clear() { + list.clear(); + } + + @SuppressWarnings("unused") + public void setSelect(MyLabel my, boolean b) { + for (MyLabel m : list) { + if (m.equals(my)) { + m.setSelected(true, b); + } else { + m.setSelected(false, b); + } + } + } + + public void setSelect(Point p, boolean b) { + //如果是拖动,则要优化一下,以提高效率 + if (b) { + //表示是否能返回,不用比较完所有的标签,能返回的标志就是把上一个标签和 + //将要显示的标签找到了就可以了 + boolean findPrevious = false, findNext = false; + for (MyLabel m : list) { + if (m.contains(p)) { + findNext = true; + if (m.getIsSelected()) { + findPrevious = true; + } else { + m.setSelected(true, b); + } + } else if (m.getIsSelected()) { + findPrevious = true; + m.setSelected(false, b); + } + if (findPrevious && findNext) { + return; + } + } + } else { + MyLabel temp = null; + for (MyLabel m : list) { + if (m.contains(p)) { + temp = m; + } else if (m.getIsSelected()) { + m.setSelected(false, b); + } + } + if (temp != null) { + temp.setSelected(true, b); + } + } + } + + } + + private class JP4 extends JPanel { + private static final long serialVersionUID = -6391305687575714469L; + + public JP4() { + super(new BorderLayout()); + this.setPreferredSize(new Dimension(295, 20)); + this.setBackground(new Color(160, 185, 215)); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日"); + final JLabel jl = new JLabel("今天: " + sdf.format(new Date())); + jl.setToolTipText("点击选择今天日期"); + this.add(jl, BorderLayout.CENTER); + jl.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent me) { + jl.setCursor(new Cursor(Cursor.HAND_CURSOR)); + jl.setForeground(Color.RED); + } + + public void mouseExited(MouseEvent me) { + jl.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + jl.setForeground(Color.BLACK); + } + + public void mousePressed(MouseEvent me) { + jl.setForeground(Color.WHITE); + select.setTime(new Date()); + refresh(); + commit(); + } + + public void mouseReleased(MouseEvent me) { + jl.setForeground(Color.BLACK); + } + }); + } + + private void updateDate() { + + } + } + + public static void main(String[] args) { + DateChooser dateChooser1 = DateChooser.getInstance("yyyy-MM-dd"); + 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); + } +} diff --git a/src/com/connor/dfl/plm/dfl040/Dfl038Handler.java b/src/com/connor/dfl/plm/dfl040/Dfl038Handler.java new file mode 100644 index 0000000..dcd6e5f --- /dev/null +++ b/src/com/connor/dfl/plm/dfl040/Dfl038Handler.java @@ -0,0 +1,28 @@ +package com.connor.dfl.plm.dfl040; + +import javax.swing.JFrame; + +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.TCSession; + +public class Dfl038Handler extends AbstractHandler { + private AbstractAIFUIApplication app; + private InterfaceAIFComponent target; + private TCSession session; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + this.app = AIFUtility.getCurrentApplication(); + this.session = (TCSession) app.getSession(); + this.target = app.getTargetComponent(); + new DFL038Jframe(session); + return null; + } + +} diff --git a/src/com/connor/dfl/plm/dfl041/BomToErp.java b/src/com/connor/dfl/plm/dfl041/BomToErp.java new file mode 100644 index 0000000..a7c70f1 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl041/BomToErp.java @@ -0,0 +1,558 @@ +package com.connor.dfl.plm.dfl041; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.axis2.addressing.AddressingConstants.Final; +import org.jacorb.idl.runtime.int_token; + +import com.connor.dfl.plm.dfl020.ChirldBomBean; +import com.connor.dfl.plm.dfl020.FatherBomLineBean; +import com.connor.dfl.plm.util.AutoSign; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.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.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentProject; +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.kernel.TCTypeService; +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; +import com.teamcenter.schemas.core._2012_09.projectlevelsecurity.ProjectTeamsResponse; + +import oracle.sql.BLOB; + + + + +public class BomToErp extends AbstractAIFOperation{ + private AbstractAIFApplication app; + private TCSession session; + private List attrList; + + private String url ; + + private String user; + + private String password ; + private Connection conn = null;// + + private PreparedStatement pre = null;// + + private ResultSet result = null;// + private String outPutInfo= ""; + private String tops; + private String ns ; + + private String weiyi_id; + String accountSet; + private String zhangtao; + private AutoSign as = null; + String zong; + + + String z_peizhi = ""; + + String outString = ""; + + private String txt_pinhao; + + + public BomToErp(AbstractAIFApplication app, TCSession session ,String accountSet,String zhangtao) { + this.app = app; + this.session = session; + this.accountSet = accountSet; + this.as=new AutoSign(); + this.zhangtao = zhangtao; + } + public BomToErp(AbstractAIFApplication app, TCSession session) { + this.app = app; + this.session = session; + this.as=new AutoSign(); + String[] stringArrays = session.getPreferenceService().getStringValues("DFL_zhangtao"); + String[] BOMZT = session.getPreferenceService().getStringValues("DFL_ERPBom_zhangtao"); + if (BOMZT == null || BOMZT.length <= 0 ) { + MessageBox.post("首选项DFL_ERPBom_zhangtao未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + } + Map account_set = new HashMap(); + if (stringArrays == null || stringArrays.length <= 0 ) { + MessageBox.post("首选项DFL_zhangtao未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + }else { + for(int i = 0 ;i=2) { + for (int i = 0; i < BOMZT.length; i++) { + if(BOMZT[i].contains("=")) { + String[] zts = BOMZT[i].split("="); + if(names[names.length-2].equals(zts[0])) { + this.zhangtao = zts[1]; + this.accountSet = account_set.get(zhangtao); + break; + } + } + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + public void executeOperation(){ + + } + + public void sendBOMTOERP(AbstractAIFApplication app) { + //InterfaceAIFComponent[] comp = app.getTargetComponents(); + InterfaceAIFComponent[] comp = app.getTargetComponents(); + String uid =""; + + + String[] stringArray = ((TCSession) app.getSession()).getPreferenceService().getStringValues("DFL2_SQL_Connect"); + + url = "jdbc:oracle:thin:@//"+stringArray[0];// + + user = stringArray[1];// + + password = stringArray[2];// + + conn = null;// + + pre = null;// + + result = null;// + + TCComponentItemRevision rev = null; + TCComponentItem item =null; + try { + + if(comp[0] instanceof TCComponentItem ) { + item = (TCComponentItem) comp[0]; + } + + rev = item.getLatestItemRevision(); + //获取描述属性 + System.out.print(item.getProperty("object_string")); + + TCTypeService service = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = winType.create(null); + TCComponentBOMLine line = view.setWindowTopLine(item,item.getLatestItemRevision(), null, null); + AIFComponentContext[] childs = line.getChildren(); + if(childs != null && childs.length > 0) { + createXMLFile(line,zhangtao); + } + view.close(); + if(!("".equals(uid))&& !(" ".equals(uid))) { + + as.AutoSignServer(uid,session); + + } + MessageBox.post("BOM数据存储成功,准备传递ERP!!!", + "提示", MessageBox.WARNING); + + }catch (Exception e) { + // TODO Auto-generated catch block + MessageBox.post("BOM数据存储失败,请检查后重新传递!!!", + "提示", MessageBox.WARNING); + e.printStackTrace(); + } + } + + //生产xml文件 + + protected void createXMLFile(TCComponentBOMLine line ,String zhangtao) throws TCException, IOException { + + List list = new ArrayList(); + StringBuilder uidSB = new StringBuilder(); + try { + getBOMValue(line,list); + if(list.size() <=0) { + MessageBox.post("您传递的BOM都已经传递到ERP,请检查!", "提示", + MessageBox.INFORMATION); + return; + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post("BOM 传递失败,请检查BOM行是否正确!!!" ,"提示",MessageBox.INFORMATION); + return; + } + //获取父 属性 + StringBuilder sb2 = new StringBuilder(); + Date date = new Date(); + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmm"); + String plmls = df.format(date); + String userName = session.getUser().getUserName(); + + String s1 =""; + String s3 = ""; + String s4 = ""; + String s5 = ""; + String s6 = ""; + + sb2.append(s1); + sb2.append(s3); + sb2.append(s4); + sb2.append(s5); + sb2.append(s6); + for(int f_index = 0;f_index< list.size();f_index++) { + uidSB.append(list.get(f_index).getItem_uid()); + if(f_index< list.size()-1) { + uidSB.append(";"); + } + int iii = f_index+1; + System.out.println("==== 第"+ iii+"个配置"); + System.out.println("******品号"+list.get(f_index).getPinhao()+"*****"); + + String peizhi1 =""; + //String peizhi2 = "第"+iii +"个配置 "; + String peizhi3 = ""; + + sb2.append(peizhi1); + sb2.append(peizhi3); + sb2.append(peizhi4); + //z_peizhi+=peizhi; + List l = (List) list.get(f_index).getList(); + for(int z = 0 ;z"; + String yj = ""; + String sxrq = ""; + String yl = ""; + String zybh = ""; + String xjwz = ""; + String plmkey =""; + sb2.append(xh); + sb2.append(yj); + sb2.append(sxrq); + sb2.append(yl); + sb2.append(zybh); + sb2.append(xjwz); + sb2.append(plmkey); + } + sb2.append(""); + } + + + String bottomS =""; + sb2.append(bottomS); + outPutInfo = sb2.toString(); + System.out.println("================"+outPutInfo); + + String fileName ="BOM"+ plmls; + String tempPath = System.getProperty("java.io.tmpdir"); + String path = tempPath + fileName + ".txt"; + File file = new File(path); + + if (!file.exists()) { + //file.getParentFile().mkdirs(); + file.createNewFile(); + } + try { + FileOutputStream fos = new FileOutputStream(file); + fos.write(outPutInfo.getBytes()); + fos.flush(); + fos.close(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // + // InputStream in = new FileInputStream("c:/fugang.jpg"); + // + // byte[] fileContent = new byte[in.available()]; + // + // in.read(fileContent); + // + // in.close(); + // // + + //将txt文件 保存到数据库 + + weiyi_id = getId(); + + System.out.println("=======================唯一识别码" +weiyi_id); + + + as.insertNewTxtFile(fileName,file, weiyi_id,session.getUser().getUid() , url, user, password,"CreatePLMBOMDataRequest",list.get(0).getPinhao(),zhangtao,session.getUser().getUserId(),uidSB.toString()); + + + // as.insertNewTxtFile(fileName,file,weiyi_id,session.getUser().getUid(), url, user, password ,"CreateItemMasterData"); + + file.delete(); + } + + + private void getBOMValue(TCComponentBOMLine line, List list) + { + FatherBomLineBean fatherBean = new FatherBomLineBean(); + try + { + TCComponentItemRevision rev = line.getItemRevision(); + AIFComponentContext[] childrens = line.getChildren(); + if (childrens.length > 0) { + rev.getStringProperty("t2_ERPBomStatus"); + } else { + return; + } + List z_list = new ArrayList(); + String fuID = rev.getStringProperty("item_id"); + fuID = fuID.replace("-Y", ""); + String fuType = rev.getStringProperty("object_type"); + if ("T2_outsourceRevision".equals(fuType)) + { + String revId = rev.getStringProperty("item_revision_id"); + fuID = fuID + revId; + } + fatherBean.setPinhao(fuID); + fatherBean.setItem_uid(rev.getUid()); + int childLineNum = 0; + boolean ispack = false; + for (int i = 0; i < childrens.length; i++) + { + InterfaceAIFComponent childComp = childrens[i].getComponent(); + if ((childComp instanceof TCComponentBOMLine)) + { + TCComponentBOMLine childLine = (TCComponentBOMLine)childComp; + String num = childLine.getStringProperty( "T2_ActualConsumption");//实际用量 + if(num==null||"".equals(num.trim())) { + num = childLine.getStringProperty( "T2_DesignQuantity");//设计用量 + if(num==null||"".equals(num.trim())) { + num = childLine.getStringProperty( "bl_quantity");//用量 +// if(num==null||"".equals(num.trim())) { +// int num1=1; +// num =String.valueOf(num1);//默认为1 +// } + } + } + System.out.println("num=============="+num); + if(childLine.isPacked() && "已打包的注释".equals(num)) + { + childLine.unpack(); + ispack = true; + childLine.refresh(); + } + } + } + if (ispack) { + line.refresh(); + } + childrens = line.getChildren(); + List idList = new ArrayList(); + for (int i = 0; i < childrens.length; i++) + { + InterfaceAIFComponent childComp = childrens[i].getComponent(); + if ((childComp instanceof TCComponentBOMLine)) + { + TCComponentBOMLine childLine = (TCComponentBOMLine)childComp; + String occType = childLine.getStringProperty("TCAI_OCC_TYPE"); + if (!"Reference".equals(occType)) + { + getChildValue(childLine, z_list, childLineNum,idList); + childLineNum++; + } + } + } + + fatherBean.setList(z_list); + list.add(fatherBean); + for (int i = 0; i < childrens.length; i++) + { + TCComponentBOMLine z_line = (TCComponentBOMLine)childrens[i].getComponent(); + TCComponentItem item = z_line.getItem(); + String type = item.getType(); + System.out.println("type=============" + type); + if (!("T2_OutBuyPart".equals(type)) && !("T2_outsource".equals(type))) + { + String occType = z_line.getStringProperty("TCAI_OCC_TYPE"); + if (!"Reference".equals(occType)) + { + AIFComponentContext[] childrenAifs = z_line.getChildren(); + if (childrenAifs.length > 0) { + getBOMValue(z_line, list); + } + } + } + } + } + catch (TCException e) + { + e.printStackTrace(); + } + } + private String toString(int num1) { + // TODO Auto-generated method stub + return null; + } + public void getChildValue(TCComponentBOMLine childLine, List z_list,int childLineNum,List idList) { + try { + String occType = childLine.getStringProperty("TCAI_OCC_TYPE"); + if("Reference".equals(occType)) { + return; + } + String childID = childLine.getItem().getStringProperty("item_id"); + String Quantity = childLine.getStringProperty( "T2_ActualConsumption");//实际用量 + if(Quantity==null||"".equals(Quantity.trim())) { + Quantity = childLine.getStringProperty( "T2_DesignQuantity");//设计用量 + if(Quantity==null||"".equals(Quantity.trim())) { + Quantity = childLine.getStringProperty( "bl_quantity");//用量 + if(Quantity==null||"".equals(Quantity.trim())) { + + Quantity =1+"";//默认为1 + } + } + } + System.out.println("Quantity=============="+Quantity); + if(idList.contains(childID)) { + int index = idList.indexOf(childID); + ChirldBomBean child = z_list.get(index); + String yl = child.getYonglian(); + double d1 = Double.parseDouble(yl); + double d2 = 0; + if(Quantity != null && !("".equals(Quantity.trim()))) { + try { + d2 = Double.parseDouble(Quantity); + } catch (Exception e) { + // TODO: handle exception + d2 = 1; + } + }else { + d2 = 1; + } + + double d3 = d1 + d2; + child.setYonglian(d3+""); + return; + }else { + idList.add(childID); + } + ChirldBomBean childBean = new ChirldBomBean(); + //获取系统当前日期 + SimpleDateFormat sdf =new SimpleDateFormat("YYYYMMdd"); + String daatatext = sdf.format(new Date()); + int j = 0; + childBean.setNumber(childLineNum+1);//序号 + childBean.setYonglian(Quantity); + String childRev = childLine.getItemRevision().getStringProperty("item_revision_id"); + String childType = childLine.getItem().getStringProperty("object_type"); + childID = childID.replace("-Y", ""); + System.out.println("childID============"+childID); + System.out.println("childRev============"+childRev); + System.out.println("childType============"+childType); + if("T2_outsource".equals(childType)) { + StringBuilder sb = new StringBuilder(childID); + sb.append(childRev); + childID = sb.toString(); + } + System.out.println("childID2============"+childID); + childBean.setPinhao(childID);//元件。也就是品号 + //将获取到的date类型转换为String类型 + java.text.SimpleDateFormat formatter = new SimpleDateFormat( "yyyy/MM/dd"); + + Date released_time = childLine.getItemRevision().getDateProperty("last_mod_date"); + String date = formatter.format(released_time);//获取创建时间 + + childBean.setDate(date);//生效日期 + //外购 外协 要判断是否发布 + + + + childBean.setWork_id(childLine.getStringProperty("T2_JobNumber"));//作业编号 + childBean.setChajian_id(childLine.getStringProperty("T2_weihao"));//插件位置 + + // T2_DesignQuantity 设计用量 + // T2_JobNumber 作业编号 + // T2_remark 备注 + // T2_weihao 位号 + + childBean.setPlmkey(childID+"-"+childLine.getItemRevision().getStringProperty("item_revision_id") );//PLMkey + z_list.add(childBean); + + } catch (Exception e) { + // TODO: handle exception + } + } + + public static String getId(){ + String id=UUID.randomUUID().toString();//生成的id942cd30b-16c8-449e-8dc5-028f38495bb5中间含有横杠,用来生成数据库的主键id是很实用的。 + id=id.replace("-", "");//替换掉中间的那个斜杠 + return id; + } + +} + diff --git a/src/com/connor/dfl/plm/dfl041/CreateNoemBOMDialogs.java b/src/com/connor/dfl/plm/dfl041/CreateNoemBOMDialogs.java new file mode 100644 index 0000000..29a8603 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl041/CreateNoemBOMDialogs.java @@ -0,0 +1,479 @@ +package com.connor.dfl.plm.dfl041; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GridBagLayout; +import java.awt.GridLayout; +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.Iterator; +import java.util.List; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import org.jacorb.idl.runtime.int_token; + +import com.connor.dfl.plm.dfl019.Dfl019Operation; +import com.connor.dfl.plm.dfl020.Dfl020Operation; +import com.connor.dfl.plm.exportBOM.ChangeDbomUtil; +import com.connor.dfl.plm.util.CopyPropsBean; +import com.connor.dfl.plm.util.DataBaseControl; +import com.itextpdf.text.Jpeg; +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.aifrcp.AIFUtility; +import com.teamcenter.rac.commands.userpreferences.ProductContextPreferencesPanel; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.ServiceData; +import com.teamcenter.rac.kernel.SoaUtil; +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.TCComponentForm; +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.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +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.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Utilities; +import com.teamcenter.soaictstubs.stringSeq_tHolder; + +public class CreateNoemBOMDialogs extends AbstractAIFDialog { + private static final Object TCComponentItemRevision = null; + //private AbstractAIFApplication app; + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + private InterfaceAIFComponent targetComp; + private TCPreferenceService service; + private TCComponent comp; + private TCComponent comp1; + private TCComponent[] comp2; + private TCComponentFolder folder; + + TCSession session = (TCSession) app.getSession(); + + private JPanel panel1; + private JPanel buttonPanel; + + + private JLabel bomCode_lable; + private JComboBox bomCode_combobox; + + private JLabel BI_lABLE2; + + private JTextField id_field; + + private JButton certain_btn; + private JButton cancel_btn; + private Map groupMap=new HashMap(); + private Map sourceMap=new HashMap(); + private String[] alls; + private String[] eqgroup; + private String[] boms; + private String[] newArr; + private String bomCode; + private String xunigroup; + private List xunirevlist = new ArrayList();; + + public CreateNoemBOMDialogs(AbstractAIFApplication app,InterfaceAIFComponent targetComp) { + super(); + this.app = app; + this.session = session; + this.service = session.getPreferenceService(); + this.targetComp = targetComp; + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + alls = service.getStringValues("dfl_standard_bom"); + if(alls == null || alls.length <= 0) { + MessageBox.post("首选项dfl_standard_bom未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + } + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 模糊查询 字符串数组 并返回 含有 str 的 字符串数组 + * @param arr + * @param str + * @return + */ + public String[] filter(String[] strsz, String str){ + + ArrayList list = new ArrayList<>(); + for (String s : strsz) { + if (s.contains(str)){ + list.add(s); + } + } + System.out.println("模糊查询8.25======="+list); + + newArr= new String[list.size()]; + newArr=list.toArray(newArr); + return newArr; + } + + + private void init() throws TCException { + //标题 + this.setTitle("创建标准Bom"); + //大小 + this.setPreferredSize(new Dimension(450, 450)); + //this.setAlwaysOnTop(true); + this.setLayout(null); + + TCComponentItem item = null; + //new标签对象 + bomCode_lable = new JLabel(" 设备型号 :"); + //new下拉框对象 + bomCode_combobox = new JComboBox(); + bomCode_combobox.addItem(" "); + + //输出测试,获取首选值 + for(int i =0 ;i 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; + } + } + + protected void createItem() { + // TODO Auto-generated method stub + + try { + + InterfaceAIFComponent comp = app.getTargetComponent(); + comp = (TCComponent) targetComp; + //设置顶层对象 + TCComponentItem item = null; + item = (TCComponentItem) comp; + TCProperty item_type = item.getTCProperty("object_type"); + String equipmenttype = item_type.getStringValue(); + //获得对象关系,遍历关系中的文件夹 + AIFComponentContext[] refs = item.whereReferenced(); + + //List list = new ArrayList(); + + for (int i = 0 ; i<=refs.length-1;i++) { + AIFComponentContext parent= refs[i]; + comp1 = (TCComponent) parent.getComponent(); + + String folder_type = comp1.getProperty("object_type"); + System.out.println("关系对象类型"+folder_type); + //判断关系的对象的类型 + if ("文件夹".equals(folder_type) || "Home 文件夹".equals(folder_type)) { + folder = (TCComponentFolder) comp1; + if("文件夹".equals(folder_type)) { + folder = (TCComponentFolder) comp1; + } + //list.add(folder_type); + } + } + System.out.println("选中的对象类型"+equipmenttype); + //设置顶层最新版本版本 + TCComponentItemRevision rev =item.getLatestItemRevision(); + //item.whereReferenced(); + //获取设备版本的分群码和id + TCProperty pro2 = rev.getTCProperty("item_id"); + TCProperty pro3 = rev.getTCProperty("t2_groupCode"); + String equipmentname = pro2.getStringValue(); + + String equipmentgroup = pro3.getStringValue(); + System.out.println("设备分群码"+equipmentgroup); + + + this.setVisible(false); + //判断是否为东富龙设备 + if("T2_Equipment".equals(equipmenttype)) { + boolean flag = true; + String[] vals = null; + for (int i = 0; i < newArr.length; i++) { + String bom = newArr[i]; + vals = bom.split("!"); + String valss = vals[0]; + System.out.println("8.25valss=============="+valss); + String[] agree = valss.split("="); + String agreement = agree[1]; + System.out.println("8.25agreement==========="+agreement); + System.out.println("8.25bomCode_combobox============"+bomCode); + //判断选中的是否和首选项中的一致,是就跳出循环,不再赋值 + if(bomCode.equals(agreement)) { + flag = false; + break; + } + } + if(vals != null) { + + TCTypeService service = session.getTypeService(); + //获取BOMWindowType + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service + .getTypeComponent("BOMWindow"); + //创建一个新的window + TCComponentBOMWindow view = winType.create(null); + + view.lock(); + //设置顶层的bomline + TCComponentBOMLine line = view.setWindowTopLine(item,rev, null, null); + TCComponentItemType type = (TCComponentItemType) session.getTypeComponent("T2_Virtual"); + String[] values = vals[1].split(";"); + //设置虚拟件版本的分群码 + String itemrevbomgroup = vals[0];//字符串 设备分群码=虚拟件分群码#bom型号 + System.out.println("8.25分群码字段"+itemrevbomgroup); + String[] itemrevgroup = itemrevbomgroup.split("#");//数组设备分群码=虚拟件分群码 - bom型号 + String itemrevString = itemrevgroup[0];//字符串设备分群=虚拟件分群码 + String[] revgruop = itemrevString.split("=");//数组设备分群码 = 虚拟件分群码 + String revgropuString = revgruop[1];//字符串 虚拟件分群码 + //设置虚拟件版本的来源码 + String sourcecode = "X"; + TCComponentItem newItem =null; + TCComponentItemRevision xunirev = null; + for (int j = 0; j < values.length; j++) { + String[] nameID = values[j].split("\\|"); + String item_id = equipmentname + "" + nameID[0]; + String sysandjob =nameID[1];//系统名称$作业编号 + String job_num = null; + System.out.println("系统名称$作业编号8.23=="+sysandjob); + String[] sysandjobsz = sysandjob.split("\\$");//按照$来分开 + String object_name =sysandjobsz[0];//系统名称 + System.out.println("object_name8.23=="+object_name); + System.out.println(item_id); + newItem =new TCComponentItem(); + //创建新的虚拟件对象 + newItem = type.create(item_id, "01", "T2_Virtual", object_name, "", null); + //设置对象的位置 + folder.add("contents", newItem); + + //设置虚拟件版本的分群码 + xunirev = new TCComponentItemRevision(); + xunirev = newItem.getLatestItemRevision(); + if (revgropuString != null && revgropuString != "") { + xunirev.setStringProperty("t2_groupCode", revgropuString); + } + //设置虚拟件对象版本的描述 + if (object_name != null && object_name != "") { + newItem.setStringProperty("object_desc", object_name); + xunirev.setStringProperty("object_desc", object_name); + } + //设置虚拟件版本的来源码 + if (sourcecode != null && sourcecode != "") { + xunirev.setStringProperty("t2_sourceCode", sourcecode); + } + //将虚拟件版本添加到集合中 + xunirevlist.add(xunirev); + //添加子bomline + TCComponentBOMLine childBomline = line.add(newItem, newItem.getLatestItemRevision(), null, false, ""); + + childBomline.setStringProperty("bl_quantity", "1"); + //添加作业编号 + if (sysandjob.contains("$")) { + job_num = sysandjobsz[1];//作业编号 + childBomline.setStringProperty("T2_JobNumber", job_num);//设置bomline属性作业编号 + } + } + + //传递虚拟件物料到erp + //测试物料信息 + if (xunirevlist.size()>0) { + System.out.println("xunirevlist有值"); + for(int i = 0; i < xunirevlist.size(); i++){ + TCComponentItemRevision test =new TCComponentItemRevision(); + test=(TCComponentItemRevision)xunirevlist.get(i); + TCProperty revsid = test.getTCProperty("item_id"); + String revsString = revsid.getStringValue(); + System.out.println("创建标准bom方法内虚拟件版本id"+revsString); + } + }else { + System.out.println("xunirevlist无值"); + } + //物料传递erp + wuliaotoerp wuliaotoerp = new wuliaotoerp(app, session); + wuliaotoerp.Wuliaotoerp(xunirevlist); + + view.save(); + view.unlock(); + view.close(); + }else { + MessageBox.post("没有配置对应的标准BOM结构,需手动创建虚拟系统层级!!!", "提示", + MessageBox.INFORMATION); + } + }else { + MessageBox.post("您选中的不是东富龙设备对象","提示",MessageBox.INFORMATION); + return; + } + MessageBox.post("标准bom创建成功","提示",MessageBox.INFORMATION); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("错误:" + e.getMessage(), "错误", MessageBox.INFORMATION); + } + } + + private TCComponentItem TCComponentItem(TCComponent comp) { + // TODO Auto-generated method stub + return null; + } +} diff --git a/src/com/connor/dfl/plm/dfl041/Dfl041Handler.java b/src/com/connor/dfl/plm/dfl041/Dfl041Handler.java new file mode 100644 index 0000000..0d9efa2 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl041/Dfl041Handler.java @@ -0,0 +1,21 @@ +package com.connor.dfl.plm.dfl041; + +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; + +public class Dfl041Handler extends AbstractHandler { + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent com = app.getTargetComponent(); + CreateNoemBOMDialogs createEquipment = new CreateNoemBOMDialogs(app ,com); + new Thread(createEquipment).start(); + return null; + } + +} diff --git a/src/com/connor/dfl/plm/dfl041/wuliaotoerp.java b/src/com/connor/dfl/plm/dfl041/wuliaotoerp.java new file mode 100644 index 0000000..57955f6 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl041/wuliaotoerp.java @@ -0,0 +1,524 @@ +package com.connor.dfl.plm.dfl041; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +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.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import com.connor.dfl.plm.dfl019.ClassPropBean; +import com.connor.dfl.plm.dfl019.ItemBean; +import com.connor.dfl.plm.util.AutoSign; +import com.connor.dfl.plm.util.ClassValueBean; +import com.connor.dfl.plm.util.ClassValueUtil; +import com.connor.dfl.plm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFApplication; +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.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +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.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; + +import oracle.sql.BLOB; + + + + +public class wuliaotoerp extends AbstractAIFOperation{ + private AbstractAIFApplication app; + private TCSession session; + private List attrList; + private List errList1 = new ArrayList(); + private String url ; + private String user; + private String password ; + private Connection conn = null;// + private PreparedStatement pre = null;// + private ResultSet result = null;// + + private String tops; + private String ns=""; + private String accountSet; + private String zhangtao; + private AutoSign as = null; + private ProgressBarThread wait; + + public wuliaotoerp(AbstractAIFApplication app, TCSession session ,String accountSet,String zhangtao) { + this.app = app; + this.session = session; + this.accountSet = accountSet; + this.as=new AutoSign(); + this.zhangtao = zhangtao; + } + public wuliaotoerp(AbstractAIFApplication app, TCSession session ) { + this.app = app; + this.session = session; + this.as=new AutoSign(); + String[] stringArrays = session.getPreferenceService().getStringValues("DFL_zhangtao"); + Map account_set = new HashMap(); + if (stringArrays == null || stringArrays.length <= 0 ) { + MessageBox.post("首选项DFL_zhangtao未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + }else { + for(int i = 0 ;i revlist) throws Exception { +// InterfaceAIFComponent[] comp = app.getTargetComponents(); +// if(comp == null || comp.length <= 0) { +// MessageBox.post("请选中的要传递ERP的对象!!!!","提示",MessageBox.INFORMATION); +// return; +// } + + TCComponentItemRevision revs = null; + if(revlist.size() > 0){ + System.out.println("revlist有值"); + }else { + System.out.println("revlist无值"); + } + + String uid =""; + + String[] stringArray = ((TCSession) app.getSession()).getPreferenceService().getStringValues("DFL2_SQL_Connect"); + + url = "jdbc:oracle:thin:@//"+stringArray[0];// + + user = stringArray[1];// + + password = stringArray[2];// + + conn = null;// + + pre = null;// + + result = null;// + + + + List errList = new ArrayList(); + List beanList = getItemValue(revlist,errList); + //解开循环 +// for (int i = 0; i < revlist.size(); i++) { +// revs = new TCComponentItemRevision(); +// revs = (TCComponentItemRevision) revlist.get(i); +// beanList = getItemValue(revs,errList); +// for (int j = 0; j < beanList.size(); j++){ +// ItemBean test = new ItemBean(); +// test = beanList.get(j); +// System.out.println(); +// } +// System.out.println("8.16循环内的值beanList"+beanList); +// } + + System.out.println("8.16test"+errList); + //输出beanlist的值 + System.out.println("8.16testbeanList------"+beanList); + //如果beanlist的值为空或0,则返回 + if(beanList == null || beanList.size() <= 0) { + return; + } + for (int i = 0; i < beanList.size(); i++) { + ItemBean bean = beanList.get(i); + System.out.println("品号====="+bean.getItem_id()+ + "品名============"+bean.getItem_name()+ + "品牌============"+bean.getItem_brand()+ + "分群码============"+bean.getItem_groupCode()+ + "版本============"+bean.getItem_rev()+ + "来源码============"+bean.getItem_sourceCode()+ + "规格============"+bean.getItem_spec()+ + "单位============"+bean.getItem_unit()+"旧物料号============"+bean.getOldMateriel()); + } + try { + createXMLFile(beanList,zhangtao); + if(!("".equals(uid))&& !(" ".equals(uid))) { + as.AutoSignServer(uid,session); + } + //MessageBox.post("物料数据存储成功,准备传递ERP!!!", + // "提示", MessageBox.WARNING); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + return; + + } + } + + + public List getItemValue(List revslist,List errList) throws TCException { + List beanList = new ArrayList(); + boolean flag = false; + //循环遍历revslist + for (int i=0;i beanList, TCComponentItemRevision rev, List errList) throws TCException { + // TODO Auto-generated method stub + boolean flag2 = false; + //if(comp instanceof TCComponentItemRevision || comp instanceof TCComponentBOMLine) { + ItemBean bean = new ItemBean(); + //TCComponentItemRevision rev = null; + //定义属性为空值 + String spec = ""; + String unit = ""; + String brand =""; + String id =""; + String oldMateriel =""; + + try { + //获取属性 + String type = rev.getStringProperty("object_type"); + id = rev.getStringProperty("item_id"); + //对-Y的处理 + if(id.contains("-Y")) { + id = id.replace("-Y", ""); + } + String groupCode = rev.getStringProperty("t2_groupCode"); + System.out.println("t2_groupCode============"+groupCode); + String sourceCode = rev.getStringProperty("t2_sourceCode"); + System.out.println("t2_sourceCode============"+sourceCode); + + unit = "pcs"; + + if(spec.contains("&")) { + spec = spec.replace("&", "&"); + } + if(spec.contains("<")) { + spec = spec.replace("<", "<"); + } + if(spec.contains(">")) { + spec = spec.replace(">", ">"); + } + if(spec.contains("\"")) { + System.out.println("spec==============="+spec); + spec = spec.replace("\"", """); + System.out.println("11111spec = = = " + spec); + + } + if("".equals(unit.trim()) || unit == null) { + errList.add(id); + } + bean.setItem_spec(spec); + bean.setItem_unit(unit); + bean.setItem_brand(brand); + bean.setItem_id(id); + String item_name = rev.getStringProperty("object_name"); + if(item_name.contains("&")) { + item_name = item_name.replace("&", "&"); + } + if(item_name.contains("\"")) { + item_name = item_name.replace("\"", """); + } + if("".equals(oldMateriel)) { + bean.setItem_name(item_name); + }else { + bean.setItem_name(item_name+"-"+oldMateriel); + } + + bean.setItem_rev(rev.getStringProperty("item_revision_id")); + bean.setOldMateriel(oldMateriel); + bean.setItem_groupCode(groupCode); + bean.setItem_sourceCode(sourceCode); + bean.setItem_uid(rev.getUid()); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + beanList.add(bean); + //} + return flag2; + } + + + + protected void createXMLFile(List beanList ,String zhangtao) throws TCException, IOException { + String weiyi_id = ""; + Date date = new Date(); + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmm"); + StringBuilder uidSB = new StringBuilder(); + String fileName = session.getUser().getUserName()+ "-" +df.format(date); + + // String s1 = ""; + // String s2 =""; + // String s3 = ""; + // String s4 = ""; + + + + String sss1 = ""; + String sss2 =""; + tops = sss1 + sss2; + String bottom =""; + int j = 1; + int o = 1; + StringBuilder sss3SB = new StringBuilder(); + StringBuilder xmlSB = new StringBuilder(); + for (int i = 0; i < beanList.size(); i++) { + ItemBean bean = beanList.get(i); + uidSB.append(bean.getItem_uid()); + String n1 =""; + String n2 = ""; + String n3 = ""; + String n = n1 + n2 + n3; + xmlSB.append(n); + j++; + if(i > 0 && i%60 == 0) { + sss3SB.append(fileName); + sss3SB.append("-"+o++); + sss3SB.append(sss3); + sss3SB.append(xmlSB.toString()); + String zong= tops + sss3SB.toString()+bottom; + System.out.println(zong); + String tempPath = System.getProperty("java.io.tmpdir"); + String path = tempPath + fileName + ".txt"; + File file = new File(path); + if (!file.exists()) { + //file.getParentFile().mkdirs(); + file.createNewFile(); + } + try { + FileOutputStream fos = new FileOutputStream(file); + fos.write(zong.getBytes()); + fos.flush(); + fos.close(); + + weiyi_id = getId(); + + System.out.println("=======================唯一识别码" +weiyi_id); + + as.insertNewTxtFile(fileName,file,weiyi_id,session.getUser().getUid(), url, user, password ,"CreateItemMasterDataRequest",beanList.get(0).getItem_id(),zhangtao,session.getUser().getUserId(),uidSB.toString()); + file.delete(); + weiyi_id = ""; + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + j = 1; + uidSB = new StringBuilder(); + xmlSB = new StringBuilder(); + sss3SB = new StringBuilder(); + continue; + } + if(i < beanList.size()-1) { + uidSB.append(";"); + } + + } + if(!("".equals(uidSB.toString()))) { + sss3SB.append(fileName); + sss3SB.append("-"+o++); + sss3SB.append(sss3); + sss3SB.append(xmlSB.toString()); + String zong= tops + sss3SB.toString()+bottom; + System.out.println(zong); + String tempPath = System.getProperty("java.io.tmpdir"); + String path = tempPath + fileName + ".txt"; + File file = new File(path); + if (!file.exists()) { + //file.getParentFile().mkdirs(); + file.createNewFile(); + } + try { + FileOutputStream fos = new FileOutputStream(file); + fos.write(zong.getBytes()); + fos.flush(); + fos.close(); + + weiyi_id = getId(); + + System.out.println("=======================唯一识别码" +weiyi_id); + + as.insertNewTxtFile(fileName,file,weiyi_id,session.getUser().getUid(), url, user, password ,"CreateItemMasterDataRequest",beanList.get(0).getItem_id(),zhangtao,session.getUser().getUserId(),uidSB.toString()); + file.delete(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + + + + // InputStream in = new FileInputStream("c:/fugang.jpg"); + // + // byte[] fileContent = new byte[in.available()]; + // + // in.read(fileContent); + // + // in.close(); + } + public void insertMes(ItemBean bean ,String zhangtao) { + Connection con = null; + PreparedStatement stmt=null; + String sql = "insert into DFL_SEND_WULIAO_TO_ERP values(?,?,?,?,?,?,?,?,?)"; + try { + con = ConnectionFun( ); + stmt = con.prepareStatement(sql); + stmt.setString(1,bean.getItem_id()); + stmt.setString(2,bean.getItem_name()); + stmt.setString(3,bean.getItem_brand()); + stmt.setString(4,bean.getItem_groupCode()); + stmt.setString(5,bean.getItem_rev()); + stmt.setString(6,bean.getItem_sourceCode()); + stmt.setString(7,bean.getItem_spec()); + stmt.setString(8,bean.getItem_unit()); + stmt.setString(9,zhangtao); + stmt.executeUpdate() ; + System.out.println("数据插入数据库完成"); + + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + + public int ifcountdetial(String id) { + int i = 0; + Connection con = null; + PreparedStatement stmt=null; + String sql = "select * from DFL_SEND_WULIAO_TO_ERP where id=?"; + try { + con = ConnectionFun(); + stmt = con.prepareStatement(sql); + ResultSet rs=null; + stmt.setString(1,id); + rs=stmt.executeQuery(); + while(rs.next()) { + i=i+1; + + } + + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + return i; + } + + + + public void updateMes(ItemBean bean ,String zhangtao) { + Connection con = null; + PreparedStatement stmt=null; + + + String sql ="UPDATE DFL_SEND_WULIAO_TO_ERP SET NAME = ?, BRAND = ? , GROUPCODE=?, REV =? , SOURCECODE =? ,SPEC =?, UNIT =?, ACCOUNTSET =? WHERE ID =?"; + try { + con = ConnectionFun( ); + stmt = con.prepareStatement(sql); + + stmt.setString(1,bean.getItem_name()); + stmt.setString(2,bean.getItem_brand()); + stmt.setString(3,bean.getItem_groupCode()); + stmt.setString(4,bean.getItem_rev()); + stmt.setString(5,bean.getItem_sourceCode()); + stmt.setString(6,bean.getItem_spec()); + stmt.setString(7,bean.getItem_unit()); + stmt.setString(8,(String) zhangtao); + stmt.setString(9,bean.getItem_id()); + stmt.executeUpdate(); + + stmt.setString(1,bean.getItem_id()); + + stmt.setString(9,zhangtao); + + System.out.println("数据更新完成"); + + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + + + public Connection ConnectionFun() throws SQLException { + Connection conn = null;// + + try { + // System.out.println(url); + // System.out.println(user); + // System.out.println(password); + Class.forName("oracle.jdbc.driver.OracleDriver"); + System.out.println("驱动加载成功"); + } catch (ClassNotFoundException e) { + System.out.println("驱动加载失败"); + } + conn=DriverManager.getConnection(url,user,password); + System.out.println("数据库连接成功"); + return conn; + + + } + + public static String getId(){ + String id=UUID.randomUUID().toString();//生成的id942cd30b-16c8-449e-8dc5-028f38495bb5中间含有横杠,用来生成数据库的主键id是很实用的。 + id=id.replace("-", "");//替换掉中间的那个斜杠 + return id; + } +} + diff --git a/src/com/connor/dfl/plm/dfl042/DataBaseControl2.java b/src/com/connor/dfl/plm/dfl042/DataBaseControl2.java new file mode 100644 index 0000000..44b567b --- /dev/null +++ b/src/com/connor/dfl/plm/dfl042/DataBaseControl2.java @@ -0,0 +1,732 @@ +package com.connor.dfl.plm.dfl042; + +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.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Vector; + +import com.connor.dfl.plm.dfl027.ChangeOwnerbean; +import com.connor.dfl.plm.dfl038.ChangeBean; +import com.connor.dfl.plm.forms.ChangeOrderBean; +import com.connor.dfl.plm.util.CodeBean; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class DataBaseControl2 { + + /** ************************数据库类调用:声明部分*********************************** */ + /** + * 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 DataBaseControl2(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 DataBaseControl2(TCSession session) { + + String[] stringArray = session.getPreferenceService().getStringArray(4, + "DFL2_SQL_Connect"); + if (stringArray != null && stringArray.length == 3) { + strUrl = "jdbc:oracle:thin:@" + stringArray[0]; + strUserName = stringArray[1]; + strPassword = stringArray[2]; + } else { + MessageBox.post("未配置DFL2_SQL_Connect首选项,无法获得连接信息!", "错误", + MessageBox.ERROR); + } + + // 加载驱动 + try { + Class.forName(strDriver);// 通过反射加载驱动到内存 + } catch (ClassNotFoundException cnfe) { + cnfe.printStackTrace(); + } + + } + /** + * 构造器 + */ + public DataBaseControl2(TCSession session,String connect) { + + String[] stringArray = session.getPreferenceService().getStringArray(4, + connect); + if (stringArray != null && stringArray.length == 3) { + strUrl = "jdbc:oracle:thin:@" + stringArray[0]; + strUserName = stringArray[1]; + strPassword = stringArray[2]; + } else { + MessageBox.post("未配置"+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; + } + /** + * 表查询3 + * + * @param strSQLQuery + * @return + */ + public ResultSet dbQuery3(String strSQLQuery) { + ResultSet rs_result = null; + if (conn == null) + openDataBase(); + try { + stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); + rs_result = stmt.executeQuery(strSQLQuery); + + } 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(); + MessageBox.post("数据库连接错误" + 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; + } + + + public String getTaskIdea(String uid) + throws Exception { + openDataBase(); + String query = "select IDEA from PLM_Perform_Task where PUID= ?"; + // 查询该id在数据库中的内容 + ResultSet rs = dbQuery2(query, new Object[] { uid}); + String taskIdea = ""; + if (rs.next()) { + taskIdea = rs.getString(1); + System.out.println("taskIdea=" + taskIdea); + } + + closeDataBase(); + + return taskIdea; + + } + public void setTaskIdea(String uid,String idea) + throws Exception { + openDataBase(); + String query = "select IDEA from PLM_Perform_Task where PUID= ?"; + // 查询该id在数据库中的内容 + ResultSet rs = dbQuery2(query, new Object[] { uid}); + if(rs.next()) { + String upin = "update PLM_Perform_Task set IDEA= ? where PUID= ?"; + dbModify2(upin, new Object[] { idea, uid }); + }else { + String upin = "insert into PLM_Perform_Task(PUID,IDEA) values ( ? , ? )"; + dbModify2(upin, new Object[] { uid, idea }); + } + closeDataBase(); + + } + + /** + * 获得流水码 + * + * @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; + + } + + //获取变更单信息 + + public List getChangeMesg(String product,String time1,String time2) throws SQLException { + List list = new ArrayList(); + if("全部".equals(product)) { + product = ""; + } + String sql = "select * from DFL_CHANGEFORM where PRODUCTDEPARTMENT like '%"+product+"%'";// + SimpleDateFormat df = new SimpleDateFormat("yyyy-M-d HH:mm"); + openDataBase(); + System.out.println("sql============"+sql); + ResultSet rs = dbQuery(sql); + while(rs.next()){ + try { + String dateStr = rs.getString(3); + System.out.println("date========"+rs.getString(3)); + if(dateStr == null) { + continue; + } + Date date = df.parse(rs.getString(3)); + Date date1 = df.parse(time1); + Date date2 = df.parse(time2); + if(date.after(date2) && date.before(date1)) { + System.out.println("date2========"+rs.getString(3)); + } + if(date.after(date1) && date.before(date2)) { + ChangeBean bn = new ChangeBean(); + bn.setApplyName(rs.getString(2)); + bn.setApplyDate(rs.getString(3)); + bn.setProjectCode(rs.getString(4)); + bn.setClientNae(rs.getString(5)); + bn.setProductName(rs.getString(7)); + bn.setProjectModel(rs.getString(8)); + bn.setChangeType(rs.getString(10)); + bn.setProductType(rs.getString(11)); + bn.setErrorType(rs.getString(12)); + bn.setDutyDepartment(rs.getString(13)); + bn.setDutyMan(rs.getString(14)); + bn.setChangeReason(rs.getString(15)); + bn.setSalseClassify(rs.getString(16)); + bn.setPriceBooking(rs.getString(17)); + bn.setIsNotProductLoss(rs.getString(18)); + bn.setReceiveClassify(rs.getString(19)); + bn.setWarehouseCode(rs.getString(20)); + bn.setAccountSet(rs.getString(21)); + bn.setNotifyEmergencyProcedures(rs.getString(22)); + bn.setDrawingTo(rs.getString(23)); + bn.setChangeListCode(rs.getString(24)); + bn.setTZChangeType(rs.getString(25)); + bn.setSUOSU_ProductDepartment(rs.getString(26)); + bn.setProjectState(rs.getString(27)); + list.add(bn); + } + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + closeDataBase(); + return list; + } + /** + * 获得流水码 + * + * @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; + + } + + /** + * 获取最大流水码 + * + */ + public String getMaxCode(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 * from (select * from pitem where pitem_id like '"+prefix+"%' order by pitem_id desc) where rownum<=1"; + // 查询该id在数据库中的内容 + ResultSet rs = dbQuery(query); + String lshstr = col; + String lsh = ""; + if (rs.next()) { + lsh = rs.getString(2); + System.out.println("sslsh=" + lsh); + if ("".equals(lsh)) { + throw new Exception("流水码为空!"); + } + lsh = lsh.substring(6); + int ls = Integer.parseInt(lsh) + 1;// 新的流水码数 + lshstr = ls + ""; + System.out.println("lshstr=" + lshstr); + 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 }); + 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 ; + + } + + /** + * 获得ERP队列 + * + * @param value + * 查询条件 + * @param sql + * 查询语句 + * @return + * @throws Exception + */ + public List getRecord(String sql) + throws Exception { + List list=new ArrayList<>(); + openDataBase(); + // 查询该id在数据库中的内容 + ResultSet rs = dbQuery(sql); + while (rs.next()) { + ERPTransferStatusbean bean = new ERPTransferStatusbean(); + bean.setfun(rs.getString(1)); + bean.setitem_id(rs.getString(2)); + bean.setzhangtao(rs.getString(3)); + bean.setUser_id(rs.getString(4)); + list.add(bean); + } + closeDataBase(); + return list; + } + + // public List getRecord2(String value,String zhangT,String cangK,String sql) + // throws Exception { + // List list=new ArrayList<>(); + // openDataBase(); + // // 查询该id在数据库中的内容 + // ResultSet rs = dbQuery2(sql, new Object[] {value,zhangT,cangK}); + // while (rs.next()) { + // ChangeOwnerbean bean = new ChangeOwnerbean(); + // bean.setId(rs.getString(1)); + // bean.setCustomerName(rs.getString(2)); + // bean.setSpec(rs.getString(3)); + // bean.setZhangt(rs.getString(4)); + // bean.setCangk(rs.getString(5)); + // bean.setNum(rs.getString(6)); + // bean.setUnit(rs.getString(7)); + // list.add(bean); + // } + // closeDataBase(); + // return list; + // } + + public String getNum(Object[] values) + throws Exception { + openDataBase(); + // 查询该id在数据库中的内容 + String sql = "select NUM from DFL_OLD_ITEM where ITEM_ID= ? and ZHANGTAO= ? and WAREHOUSE= ?"; + String num = ""; + ResultSet rs = dbQuery2(sql, values); + if (rs.next()) { + num = rs.getString(1); + } + closeDataBase(); + return num; + } + + public double getNums(String sql) + throws Exception { + openDataBase(); + // 查询该id在数据库中的内容 + double nums = 0; + ResultSet rs = dbQuery(sql); + if (rs.next()) { + nums = rs.getInt(1); + } + closeDataBase(); + return nums; + } + /** + * 单例测试 + * + * @param args + */ + public static void main(String args[]) { + try { + + String str_DataBaseDriver = "oracle.jdbc.driver.OracleDriver"; + String str_URL = "jdbc:oracle:thin:@localhost:1521:tc12"; + String str_UserName = "infodba"; + String str_Password = "infodba"; + DataBaseControl2 dbc = new DataBaseControl2(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/dfl/plm/dfl042/Dfl042Action.java b/src/com/connor/dfl/plm/dfl042/Dfl042Action.java new file mode 100644 index 0000000..7b67538 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl042/Dfl042Action.java @@ -0,0 +1,24 @@ +package com.connor.dfl.plm.dfl042; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +public class Dfl042Action extends AbstractAIFAction { + + private AbstractAIFUIApplication app; + + public Dfl042Action(AbstractAIFUIApplication app, String string) { + super(app,string); + this.app=app; + } + + @Override + public void run() { + try { + new Dfl042Command(app).executeModal(); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/dfl/plm/dfl042/Dfl042Command.java b/src/com/connor/dfl/plm/dfl042/Dfl042Command.java new file mode 100644 index 0000000..5aec281 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl042/Dfl042Command.java @@ -0,0 +1,20 @@ +package com.connor.dfl.plm.dfl042; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCSession; + +public class Dfl042Command extends AbstractAIFCommand { + + private TCSession session; + + public Dfl042Command(AbstractAIFUIApplication app) { + this.session=(TCSession)app.getSession(); + } + + @Override + public void executeModal() throws Exception { + new Thread(new Dfl042Dialog(session)).start(); + } + +} diff --git a/src/com/connor/dfl/plm/dfl042/Dfl042Dialog.java b/src/com/connor/dfl/plm/dfl042/Dfl042Dialog.java new file mode 100644 index 0000000..a450577 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl042/Dfl042Dialog.java @@ -0,0 +1,445 @@ +package com.connor.dfl.plm.dfl042; + +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.MouseAdapter; +import java.awt.event.MouseEvent; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; +import java.util.MissingResourceException; + +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.JTextArea; +import javax.swing.JTextField; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableRowSorter; + +import com.connor.dfl.plm.dfl042.ERPTransferStatusbean; +import com.connor.dfl.plm.util.DataBaseControl; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.commands.open.OpenCommand; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Registry; + +public class Dfl042Dialog extends AbstractAIFDialog { + + private static final long serialVersionUID = 6130114042631785757L; + private static final int width=800; + DefaultTableModel model; + private TCSession session; +// private JButton qryBtn; + private JButton qryBtn2; + private JButton beforeBtn; + private JButton nextBtn; + private int page = 15; + private double pages = 1; + private JTextField idField; + private JTextField page1; + private JTextField page2; + private JTextField useridField; + private JTextField specField; + private JTextField cangKField; + private StringBuilder sb = new StringBuilder("select FUN,TXT_PINHAO,ZHANGTAO,USERID from DFL_SEND_TXT_TO_ERP where STATUS = 0 "); + private StringBuilder numsSb = new StringBuilder("select count(*) from DFL_SEND_TXT_TO_ERP where STATUS = 0 "); + private String sql2 = ""; + private JComboBox zhangTBox; + private String[] columnNames = {"序号","类型","品号","账套","用户"}; + private JTable qryTable; + private Object[][] beans; + private TCPreferenceService service; + private DataBaseControl2 data; + public Dfl042Dialog(TCSession session) { + super(false); + this.session=session; + this.service = session.getPreferenceService(); + this.data = new DataBaseControl2(session,"DFL2_SQL_Connect"); + } + /** + * 刷新table显示和设置宽度 + */ + private void refreshTable() { + qryTable.removeAll(); + model.setDataVector(beans, columnNames); + qryTable.getColumnModel().getColumn(0).setPreferredWidth(50); + qryTable.getColumnModel().getColumn(1).setPreferredWidth(130); + qryTable.getColumnModel().getColumn(2).setPreferredWidth(110); + qryTable.getColumnModel().getColumn(3).setPreferredWidth(110); + qryTable.getColumnModel().getColumn(4).setPreferredWidth(110); + } + + @Override + public void run() { + //显示窗口 + initUI(); + //启用查询按钮 +// qryBtn.setEnabled(true); + } + + + + @SuppressWarnings("serial") + private void initUI() { + this.setTitle("ERP队列"); + this.setLayout(new FlowLayout(FlowLayout.CENTER,2,3)); + this.setPreferredSize(new Dimension(width, 550)); + this.setLocation(2, 5); + //Object[][] cellData = getRecords("*"); + model = new DefaultTableModel() { + private static final long serialVersionUID = 6905817304437097181L; + public boolean isCellEditable(int row, int column) { + return true; + } + }; + + 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; + } + }; +// qryTable.addMouseListener(new MouseAdapter() { +// int tableRow = -1; +// +// public void mouseClicked(MouseEvent e){ +// if(e.getButton() == MouseEvent.BUTTON3){ +// // tableRow = qryTable.rowAtPoint(e.getPoint()); +// tableRow = qryTable.getSelectedRow(); +// qryTable.setRowSelectionInterval(tableRow, tableRow); +// int indexRow = qryTable.convertRowIndexToModel(tableRow); +// System.out.println("indexRow=============="+indexRow); +// if(tableRow >= 0){ +// System.out.println("1111111111111111111"); +// createPopupMenu(indexRow); +// +// } +// } +// } +// }); + 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 qryPanel=new JPanel(new PropertyLayout()); + + JLabel idLabel=new JLabel("按队列传递ERP,每条大约一分钟"); + idField = new JTextField(10); +// qryBtn=new JButton("查询"); + + JLabel cangKLabel=new JLabel(" 仓库编号:"); + cangKField = new JTextField(6); +// cangKBox = new JComboBox(); + JLabel zhangTLabel=new JLabel(" 账套:"); + zhangTBox = new JComboBox(); + //cangKBox.addItem(" "); +// zhangTBox.addItem(" "); +// String[] cangks = service.getStringValues("DFL_cangK_Num"); +// if(cangks == null || cangks.length <= 0) { +// MessageBox.post("首选项DFL_cangK_Num未配置,请联系管理员!!!", "错误", +// MessageBox.ERROR); +// return; +// } + page1 = new JTextField(1); + page2 = new JTextField(1); + JLabel useridLabel=new JLabel(" 工 号:"); + useridField = new JTextField(10); + JLabel specLabel=new JLabel("规格:"); + specField = new JTextField(10); + + String[] zhangts = service.getStringValues("DFL_zhangtao"); + if(zhangts == null || zhangts.length <= 0) { + MessageBox.post("首选项DFL_zhangtao未配置,请联系管理员!!!", "错误", + MessageBox.ERROR); + return; + } +// for (int i = 0; i < cangks.length; i++) { +// cangKBox.addItem(cangks[i]); +// } +// for (int i = 0; i < zhangts.length; i++) { +// zhangTBox.addItem(zhangts[i].split("=")[1]); +// } + qryBtn2=new JButton("查询"); + beforeBtn=new JButton("上一页"); + nextBtn=new JButton("下一页"); +// JLabel addNum=new JLabel(" 数量增加:"); +// addNumField = new JTextField(4); +// JLabel subtractNum=new JLabel(" 数量减少:"); +// subtractNumField = new JTextField(4); + qryPanel.add("1.1.center.top",idLabel);//添加零件id文本 +// qryPanel.add("1.2.center.top",idField);//添加零件id写入框 + qryPanel.add("1.2.center.top",useridLabel);//添加品名文本 + qryPanel.add("1.3.center.top",useridField);//添加品名写入框 + qryPanel.add("1.4.center.top",qryBtn2);//查询按钮 +// qryPanel.add("1.1.center.top",qryBtn); +// qryPanel.add("1.3.center.top",cangKLabel);//添加仓库id文本 +// qryPanel.add("1.2.center.top",cangKBox); +// qryPanel.add("1.4.center.top",cangKField);//添加仓库id写入框 +// qryPanel.add("1.5.center.top",zhangTLabel);//添加账套id文本 +// qryPanel.add("1.6.center.top",zhangTBox);//添加账套下拉框 +// qryPanel.add("2.1.center.top",nameLabel);//添加品名文本 +// qryPanel.add("2.2.center.top",nameField);//添加品名写入框 +// qryPanel.add("2.3.center.top",specLabel);//添加规格文本 +// qryPanel.add("2.4.center.top",specField);//添加规格写入框 +// qryPanel.add("2.5.center.top",new JLabel(" ")); +// qryPanel.add("2.6.center.top",qryBtn2); +// qryPanel.add("1.7.center.top",qryBtn2); +// qryPanel.add("2.1.center.top",addNum); +// qryPanel.add("2.2.center.top",addNumField); +// qryPanel.add("2.3.center.top",subtractNum); +// qryPanel.add("2.4.center.top",subtractNumField); + JPanel southPanel = new JPanel(new FlowLayout()); + //JButton okBtn = new JButton("确定"); + //okBtn.addActionListener(new ActionListener() { + + //public void actionPerformed(ActionEvent e) { +// int rows = qryTable.getRowCount(); +// if(rows <= 0) { +// MessageBox.post("请先查询相关数据信息再进行修改!!", +// "提示", MessageBox.INFORMATION); +// return ; +// } +// for (int i = 0; i < rows; i++) { +// //String id = idField.getText(); +// String id = (String) qryTable.getModel().getValueAt(i,0); +// String zhangT = (String) qryTable.getModel().getValueAt(i,3); +// String cangK = (String) qryTable.getModel().getValueAt(i,4); +// //String addNum = addNumField.getText(); +// //String subtractNum = subtractNumField.getText(); +// String addNum = (String) qryTable.getModel().getValueAt(i,8); +// String subtractNum = (String) qryTable.getModel().getValueAt(i,9); +// if("".equals(addNum.trim()) && "".equals(subtractNum.trim())) { +// continue; +// } +// Object[] values = new Object[] {id,zhangT,cangK}; +// String newNum = ""; +// try { +// String num = data.getNum(values); +// if("".equals(cangK.trim())) { +// MessageBox.post("请先用仓库编号查询数据!!","提示", MessageBox.INFORMATION); +// return; +// }else { +// if(!("".equals(addNum.trim()))) { +// int num1 = Integer.parseInt(addNum); +// int oldNum = Integer.parseInt(num); +// newNum = (num1+oldNum)+""; +// }else if(!("".equals(subtractNum.trim()))){ +// int num1 = Integer.parseInt(subtractNum); +// int oldNum = Integer.parseInt(num); +// newNum = (oldNum-num1)+""; +// }else { +// MessageBox.post("修改的数量不能为空!!","错误", MessageBox.ERROR); +// return; +// } +// } +// String sql = "update DFL_OLD_ITEM set NUM= ? where ITEM_ID= ? and ZHANGTAO= ? and WAREHOUSE= ?"; +// data.dbModify2(sql, new Object[] { newNum, id, zhangT, cangK}); +// } catch (Exception e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// } +// beans = getRecords(sql2); +// if(beans!=null) { +// refreshTable(); +// } + //disposeDialog(); + // } + //}); + JButton celBtn = new JButton("取消"); + celBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + beforeBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + if(page > 15){ + page = page - 15; + } + page1.setText("" + page/15); + queryResult(); + } + }); + nextBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + //int rowNum = 0; + //if(page < rowNum) { + page = page + 15; + page1.setText("" + page/15); + //} + queryResult(); + } + }); +// southPanel.add(okBtn); + //southPanel.add(qryBtn2); + southPanel.add(celBtn); + JPanel rootPanel=new JPanel(new ButtonLayout()); +// rootPanel.add("1.1.center.top",beforeBtn); +// rootPanel.add("1.2.left.top",new JLabel(" 第")); +// rootPanel.add("1.3.left.top",page1); +// rootPanel.add("1.4.left.top",new JLabel("页")); +// rootPanel.add("1.5.left.top",new JLabel("共")); +// rootPanel.add("1.6.left.top",page2); +// rootPanel.add("1.7.left.top",new JLabel("页")); +// rootPanel.add("1.8.center.top",nextBtn); +// qryBtn.setEnabled(false); +// qryBtn.addActionListener(new ActionListener() { +// +// public void actionPerformed(ActionEvent e) { +// String id = idField.getText(); +// String sql = "select ITEM_ID,ITEM_NAME,SPEC,ZHANGTAO,WAREHOUSE,NUM,UNIT,LOCATION from DFL_OLD_ITEM where ITEM_ID= ?"; +// beans = getRecords(sql,id); +// if(beans!=null) { +// refreshTable(); +// } +// } +// }); + qryBtn2.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + page = 15; + page1.setText("1"); + queryResult(); + } + }); + this.add(qryPanel); + this.add(scrollPane); + this.add(rootPanel); + this.setResizable(false); + this.setAlwaysOnTop(false); + this.showDialog(); + } + + /** + * 查询项目信息获取记录 + * @return table的dataVector + */ + private Object[][] getRecords(String sql){ + List list = new ArrayList(); + + try { + list = data.getRecord(sql); + list.toString(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if(list == null || list.size() <= 0 ) { + MessageBox.post("数据库中未查找到相应的数据!! 数据已全部传递!!", + "错误", MessageBox.ERROR); + return null; + } + + //封装结果集 + Object res[][] = new Object[list.size()][this.columnNames.length]; + int i=0; + for (ERPTransferStatusbean record : list) { + + String transtype = null; + + if("CreateItemMasterDataRequest".equals(record.getfun())) { + transtype = "物料"; + }else if("CreatePLMBOMDataRequest".equals(record.getfun())){ + transtype = "Bom"; + } + System.out.println("transtype9.14======="+transtype); + res[i++]=new Object[] {i,transtype,record.getitem_id(),record.getzhangtao(),record.getUser_id() + }; + } + 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 void queryResult() { + String userid = useridField.getText(); + if(!("".equals(userid.trim()))) { + sb.append("and userid" + "="+userid); + numsSb.append("and userid" + "="+userid); + } + + sql2 = sb.toString(); + System.out.println("sql===================="+sql2); + beans = getRecords(sql2); + String numsSql = numsSb.toString(); + System.out.println("numsSql===================="+numsSql); + try { + double nums = data.getNums(numsSql); + System.out.println("nums==================="+nums); + pages = nums/15; + pages = Math.ceil(pages); + int allPage = (int) pages; + page2.setText(""+allPage); + System.out.println("allPage==================="+allPage); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + if(beans!=null) { + refreshTable(); + } + } + +} diff --git a/src/com/connor/dfl/plm/dfl042/Dfl042Handler.java b/src/com/connor/dfl/plm/dfl042/Dfl042Handler.java new file mode 100644 index 0000000..81da68a --- /dev/null +++ b/src/com/connor/dfl/plm/dfl042/Dfl042Handler.java @@ -0,0 +1,19 @@ +package com.connor.dfl.plm.dfl042; + +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 Dfl042Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + new Thread(new Dfl042Action(app,"")).start(); + return null; + } + +} diff --git a/src/com/connor/dfl/plm/dfl042/ERPTransferStatusbean.java b/src/com/connor/dfl/plm/dfl042/ERPTransferStatusbean.java new file mode 100644 index 0000000..259e681 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl042/ERPTransferStatusbean.java @@ -0,0 +1,40 @@ +package com.connor.dfl.plm.dfl042; + +import javax.swing.JTextField; + +public class ERPTransferStatusbean { + + private String fun; //类别 + private String item_id;//品号 + private String zhangtao;//账套 + private String User_id;//用户id + + public String getfun() { + return fun; + } + public void setfun(String fun) { + this.fun = fun; + } + public String getitem_id() { + return item_id; + } + public void setitem_id(String item_id) { + this.item_id = item_id; + } + public String getzhangtao() { + return zhangtao; + } + public void setzhangtao(String zhangtao) { + this.zhangtao = zhangtao; + } + public String getUser_id() { + return User_id; + } + public void setUser_id(String User_id) { + this.User_id = User_id; + } + + + + +} diff --git a/src/com/connor/dfl/plm/exportBOM/AutoCreateBean.java b/src/com/connor/dfl/plm/exportBOM/AutoCreateBean.java new file mode 100644 index 0000000..469458c --- /dev/null +++ b/src/com/connor/dfl/plm/exportBOM/AutoCreateBean.java @@ -0,0 +1,77 @@ +package com.connor.dfl.plm.exportBOM; + +public class AutoCreateBean { + + private String item_id;//品号 + private String name;//名称 + private String spec;//规格 + private String unit;//单位 + private String design_num;//设计用量 + private String brand;//品牌 + private String weihao;//编号 + private String importance;//重要度 + private String num;//序号 + private int level;//等级 + public String getItem_id() { + return item_id; + } + public void setItem_id(String item_id) { + this.item_id = item_id; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getSpec() { + return spec; + } + public void setSpec(String spec) { + this.spec = spec; + } + public String getUnit() { + return unit; + } + public void setUnit(String unit) { + this.unit = unit; + } + public String getDesign_num() { + return design_num; + } + public void setDesign_num(String design_num) { + this.design_num = design_num; + } + public String getBrand() { + return brand; + } + public void setBrand(String brand) { + this.brand = brand; + } + public int getLevel() { + return level; + } + public void setLevel(int level) { + this.level = level; + } + public String getWeihao() { + return weihao; + } + public void setWeihao(String weihao) { + this.weihao = weihao; + } + public String getImportance() { + return importance; + } + public void setImportance(String importance) { + this.importance = importance; + } + public String getNum() { + return num; + } + public void setNum(String num) { + this.num = num; + } + + +} \ No newline at end of file diff --git a/src/com/connor/dfl/plm/exportBOM/BOMExportHandler.java b/src/com/connor/dfl/plm/exportBOM/BOMExportHandler.java new file mode 100644 index 0000000..28a63b4 --- /dev/null +++ b/src/com/connor/dfl/plm/exportBOM/BOMExportHandler.java @@ -0,0 +1,52 @@ +package com.connor.dfl.plm.exportBOM; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.handlers.HandlerUtil; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.pse.common.BOMLineNode; +import com.teamcenter.rac.pse.common.BOMTreeTableModel; +import com.teamcenter.rac.pse.operations.ExpandBelowOperation; +import com.teamcenter.rac.psebase.AbstractBOMLineViewerApplication; +import com.teamcenter.rac.psebase.common.AbstractViewableTreeTable; +import com.teamcenter.rac.util.AdapterUtil; +import com.teamcenter.rac.util.MessageBox; + +/** + * Our sample handler extends AbstractHandler, an IHandler base class. + * @see org.eclipse.core.commands.IHandler + * @see org.eclipse.core.commands.AbstractHandler + */ +public class BOMExportHandler extends AbstractHandler { + /** + * The constructor. + */ + public BOMExportHandler() { + } + + /** + * the command has been executed, so extract extract the needed information + * from the application context. + */ + + public Object execute(ExecutionEvent event) throws ExecutionException { + + AbstractAIFApplication app=AIFUtility.getCurrentApplication(); + //DL2_VehicleRevision DL2_EBOM + if(app.getTargetComponent() instanceof TCComponentBOMLine){ + TCSession session=(TCSession) app.getSession(); + BOMExportOperation operation=new BOMExportOperation(app, session); + session.queueOperation(operation); + }else{ + MessageBox.post("请选择BOMLine","",2); + } + return null; + } +} diff --git a/src/com/connor/dfl/plm/exportBOM/BOMExportOperation.java b/src/com/connor/dfl/plm/exportBOM/BOMExportOperation.java new file mode 100644 index 0000000..2cc0d2a --- /dev/null +++ b/src/com/connor/dfl/plm/exportBOM/BOMExportOperation.java @@ -0,0 +1,702 @@ +package com.connor.dfl.plm.exportBOM; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.swing.filechooser.FileSystemView; + +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jacorb.idl.runtime.int_token; + +import com.connor.dfl.plm.dfl019.ClassPropBean; +import com.connor.dfl.plm.dfl019.ItemBean; +import com.connor.dfl.plm.dfl019.ParseXMLUtil; +import com.connor.dfl.plm.util.ClassValueBean; +import com.connor.dfl.plm.util.ClassValueUtil; +import com.connor.dfl.plm.util.ProgressBarThread; +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.*; +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.pse.common.BOMLineNode; +import com.teamcenter.rac.psebase.AbstractBOMLineViewerApplication; +import com.teamcenter.rac.psebase.common.AbstractViewableTreeTable; +import com.teamcenter.rac.treetable.TreeTableNode; +import com.teamcenter.rac.util.MessageBox; + +public class BOMExportOperation extends AbstractAIFOperation { + private AbstractAIFApplication app; + private TCSession session; + private ProgressBarThread wait; + private List attrList; + private List list = new ArrayList(); + + private List errList = new ArrayList(); + + private String xuninum = "0"; + + private String item_id1 = "";//品号 item_id + private String name1 = "";//名称 object_name + private String spec1 = "";//规格 + private String unit1 = "";//单位 t2_unit + private String design_num1;//设计用量 bl_quantity + private String brand1 = "";//品牌 + private String weihao1 = "";//编号 T2_weihao + private String importance1 = "";//重要度 t2_BOMImportance + private int xuhao1 ; + private String lev1 = ""; + public BOMExportOperation(AbstractAIFApplication app, TCSession session) { + this.app = app; + this.session = session; + } + @Override + public void executeOperation() throws Exception { + // TCUserService service = session.getUserService(); +// ParseXMLUtil xml=new ParseXMLUtil(); +// File classfile=xml.getSXX("DFL_CLASS_Xml", session); +// attrList =xml.parseXMLCode(classfile); + try { + System.out.println("开旁路"); + ChangeDbomUtil.setByPass(true); + } catch (TCException e2) { + e2.printStackTrace(); + } + try { + System.out.println("开始获取BOM模板"); + String puid = session.getPreferenceService().getStringValue("DFL_BOM_UID"); + System.out.println("puid======================"+puid); + if (puid == null||"".equals(puid)) { + MessageBox.post("首选项DFL_BOM_UID未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + } + TCComponentDataset excel = (TCComponentDataset) session.stringToComponent(puid); + File file = ((TCComponentDataset)excel).getTcFiles()[0].getFmsFile(); + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");// 设置日期格式 + String time = df.format(new Date()); + FileSystemView fsv = FileSystemView.getFileSystemView(); + String pathRoute = fsv.getHomeDirectory().getPath() + File.separator + "BOM汇总表" + time + ".xlsx"; + String pathRoute1 = fsv.getHomeDirectory().getPath() + File.separator + "BOM对照表" + time + ".xlsx"; + wait = new ProgressBarThread("导出汇总表和对照表", "执行中,请稍等..."); + wait.start();// 开启进度条 + TCComponentBOMLine line = (TCComponentBOMLine) app.getTargetComponent(); + try { + int level = 0; + int num = 0; + getAndSetValue(line,level,num); + writeToExcel(file,pathRoute); + System.out.println("8.10(1)====="+list); + list.clear(); + System.out.println("8.10(2)====="+list); + getAndSetValue1(line,level,num); + + writeToExcel(file,pathRoute1); + System.out.println("9.15(3)====="+list); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + MessageBox.post("生成报表失败"+e.getMessage(),"错误",MessageBox.ERROR); + return; + } + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + MessageBox.post("生成报表完成,请查看","完成",MessageBox.INFORMATION); + Runtime.getRuntime().exec("cmd /c \"" + pathRoute + "\""); + Runtime.getRuntime().exec("cmd /c \"" + pathRoute1 + "\""); + } catch (Exception e) { + e.printStackTrace(); + } + try { + ChangeDbomUtil.setByPass(false); + } catch (TCException e2) { + e2.printStackTrace(); + } + + } + //对照表的获取方法 + private void getAndSetValue1(TCComponentBOMLine bomLine,int level,int num) { + // TODO Auto-generated method stub + try { + //通过解包方法来解包 + Unpack(bomLine); + System.out.println("level================"+level); + //获得子级对象 + AIFComponentContext[] childs = bomLine.getChildren(); + // + if(childs != null && childs.length > 0 ) { + //层级+1 + //level++; + //遍历子级对象 + for (int i = 0; i < childs.length; i++) { + //选中的对象 + InterfaceAIFComponent comp = childs[i].getComponent(); + //选中的对象的版本 + TCComponentItemRevision rev = ((TCComponentBOMLine) comp).getItemRevision(); + String type = rev.getStringProperty("object_type"); + String occType = bomLine.getStringProperty("TCAI_OCC_TYPE"); + //判断是否属于bomline + if(comp instanceof TCComponentBOMLine) { + //如果版本类型是外购件版本或者外协件版本则获取属性 + if("T2_outsourceRevision".equals(type) || "T2_OutBuyPartRevision".equals(type)) { + //序号+1 + num++; + //判断是否为无需传递的物料 + if (!"Reference".equals(occType)) + { + List beanList1 = new ArrayList(); + //将遍历的对象强转类型为bomline + TCComponentBOMLine ziLine = (TCComponentBOMLine) comp; + getItemValue1(ziLine,level,num); + + double a = Double.valueOf(xuninum).doubleValue(); + System.out.println("a--915======"+a); + double b = Double.valueOf(design_num1).doubleValue(); + System.out.println("b--915======"+b); + double c = a*b; + System.out.println("c--915======"+c); + design_num1 = ""+c; + System.out.println("design_num9.15======"+design_num1); + String xuhao2 = xuhao1+""; + //添加属性到字符串集合中 + beanList1.add(xuhao2); + beanList1.add(item_id1); + beanList1.add(name1); + //beanList1.add(lev1); //不要层级 + beanList1.add(spec1); + beanList1.add(unit1); + beanList1.add(design_num1); + beanList1.add(brand1); + beanList1.add(weihao1); + beanList1.add(importance1); + System.out.println("beanList19.15====="+beanList1); + //添加字符串集合到集合中 + list.add(beanList1); + System.out.println("list9.15====="+list); + } + } + //如果不是外购外协件则递归此方法 + else { + TCComponentBOMLine ziLine = (TCComponentBOMLine) comp; + design_num1 = "1"; + //先将虚拟件(xuninum)的值设为获取到的值 + xuninum = design_num1; + System.out.println("8.12虚拟件数量"+xuninum); + //设置虚拟件数量为double类型a + double a = Double.valueOf(xuninum).doubleValue(); + System.out.println("8.12虚拟件的double数量a"+a); + getItemValue1(ziLine,level,xuhao1); + //设置获取的数量为double类型b + double b = Double.valueOf(design_num1).doubleValue(); + System.out.println("8.12虚拟件的double数量b"+b); + //得到相乘的数量 + double c = a*b; + System.out.println("8.12虚拟件的double数量c"+c); + design_num1 = ""+c; + //而后获得一个乘积的值赋予给xuninum + xuninum = design_num1; + System.out.println("8.12第一个虚拟件"+xuninum); + //递归 + getAndSetValue1(ziLine,level,xuhao1); + } + } + } + //level--; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + private void getAndSetValue(TCComponentBOMLine bomLine,int level,int num) { + // TODO Auto-generated method stub + try { + System.out.println("level================"+level); + getItemValue(bomLine,level,num); + AIFComponentContext[] childs = bomLine.getChildren(); + if(childs != null && childs.length > 0 ) { + level++; + for (int i = 0; i < childs.length; i++) { + num++; + InterfaceAIFComponent comp = childs[i].getComponent(); + TCComponentItemRevision rev = ((TCComponentBOMLine) comp).getItemRevision(); + String type = rev.getStringProperty("object_type"); + + if(comp instanceof TCComponentBOMLine) { + TCComponentBOMLine ziLine = (TCComponentBOMLine) comp; + getAndSetValue(ziLine,level,num); + + + } + } + level--; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 写入到excel报表中 + * @throws Exception + */ + + private void writeToExcel(File file,String path) throws Exception{ + FileInputStream fis = new FileInputStream(file); + XSSFWorkbook workbook = new XSSFWorkbook(fis); + System.out.println("workBook:"+workbook); + XSSFSheet sheet = workbook.getSheetAt(0); + XSSFRow targetRow = sheet.getRow(0); + XSSFCell targetCell = targetRow.getCell(0); + XSSFCellStyle cellStyle = targetCell.getCellStyle(); + int startRow = 1; + + if(list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + XSSFRow row = sheet.getRow(startRow); + if(row == null) { + row = sheet.createRow(startRow); + } + List beanList = list.get(i); + for (int j = 0; j < beanList.size(); j++) { + XSSFCell cell = row.getCell(j); + if(cell == null) { + cell = row.createCell(j); + } + cell.setCellStyle(cellStyle); + cell.setCellValue(beanList.get(j)); + } + startRow++; + } + } + FileOutputStream output = new FileOutputStream(new File(path)); + workbook.write(output); + output.close(); + fis.close(); + } + + public List getOutBuyPartValue(TCComponentItemRevision rev) { + // TODO Auto-generated method stub + List vals = new ArrayList(); + StringBuilder sb = new StringBuilder(); + List classPropList = new ArrayList(); + TCClassificationService classificationService = session.getClassificationService(); + try { + String className = rev.getClassificationClass(); + TCComponentICO[] icos = rev.getClassificationObjects(); + 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); + System.out.println("classValue=================="+classValue); + if(classValue.contains(";")) { + String[] classValues = classValue.split(";"); + if(className.equals(classValues[0])) { + for (int k = 1; k < classValues.length; k++) { + String attrName = classValues[k]; + System.out.println("attrName=================="+attrName); + for (int i = 0; i < classPropList.size(); i++) { + ClassPropBean bean = classPropList.get(i); + System.out.println("bean.propDisName=================="+bean.propDisName); + if(attrName.equals(bean.propDisName)) { + String value = claMap.get(bean.propID); + System.out.println("bean.propID=================="+bean.propID); + if(bean.isLov) { + String lovValue = bean.lovMapping.get(value); + System.out.println("lovValue===================="+lovValue); + if("品牌".equals(attrName) || "单位".equals(attrName)) { + StringBuilder sb1 = new StringBuilder(attrName); + sb1.append("="); + sb1.append(lovValue); + vals.add(sb1.toString()); + if("/".equals(lovValue)) { + System.out.println("不进行拼接"); + break; + } + sb.append(lovValue); + if(k < classValues.length-1) { + sb.append(";"); + } + }else { + if("/".equals(lovValue)) { + System.out.println("不进行拼接"); + break; + } + sb.append(lovValue); + if(k < classValues.length-1) { + sb.append(";"); + } + } + }else { + if("品牌".equals(attrName) || "单位".equals(attrName)) { + StringBuilder sb1 = new StringBuilder(attrName); + sb1.append("="); + sb1.append(value); + vals.add(sb1.toString()); + if("/".equals(value)) { + System.out.println("不进行拼接"); + break; + } + sb.append(value); + if(k < classValues.length-1) { + sb.append(";"); + } + }else { + System.out.println("value===================="+value); + if("/".equals(value)) { + System.out.println("不进行拼接"); + break; + } + sb.append(value); + if(k < classValues.length-1) { + sb.append(";"); + } + } + } + break; + } + } + } + break; + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + String spec = sb.toString(); + vals.add(spec); + return vals; + } + private String getOutsourceValue(TCComponentItemRevision rev) { + // TODO Auto-generated method stub + StringBuilder sb = new StringBuilder(); + try { + String importance = rev.getStringProperty("t2_Importance"); + if(!("".equals(importance.trim()))) { + sb.append(importance); + sb.append(";"); + } + String material = rev.getStringProperty("t2_material"); + if(!("".equals(material.trim()))) { + sb.append(material); + sb.append(";"); + } + String mass = rev.getStringProperty("t2_MASS"); + if(!("".equals(mass.trim()))) { + sb.append(mass); + sb.append(";"); + } + String specifications = rev.getStringProperty("t2_Specifications"); + if(!("".equals(specifications.trim()))) { + sb.append(specifications); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + String spec = sb.toString(); + return spec; + } + + public void getItemValue(TCComponentBOMLine comp,int level,int num) throws TCException { + + List beanList = new ArrayList(); + String item_id = "";//品号 item_id + String name = "";//名称 object_name + String spec = "";//规格 + String unit = "";//单位 t2_unit + String design_num = "";//设计用量 bl_quantity + String brand = "";//品牌 + String weihao = "";//编号 T2_weihao + String importance = "";//重要度 t2_BOMImportance + String xuhao = num + ""; + String lev = level + ""; + TCComponentItemRevision rev = comp.getItemRevision(); + try { + design_num = comp.getStringProperty("T2_ActualConsumption"); + if(design_num == null || "".equals(design_num) || " ".equals(design_num)) { + design_num = comp.getStringProperty("T2_DesignQuantity"); + if(design_num == null || "".equals(design_num) || " ".equals(design_num)) { + design_num = comp.getStringProperty("bl_quantity"); + if(design_num == null || "".equals(design_num) || " ".equals(design_num)) { + design_num = "1"; + } + } + } + String type = rev.getStringProperty("object_type"); + weihao = comp.getStringProperty("T2_weihao"); + importance = comp.getStringProperty("t2_BOMImportance"); + item_id = rev.getStringProperty("item_id"); + name = rev.getStringProperty("object_name"); + if("T2_outsourceRevision".equals(type)) { + + String classID = item_id.substring(0, 2); + System.out.println("classID==============="+classID); + if("51".equals(classID) || "72".equals(classID) || "76".equals(classID)) { +// List vals= getOutBuyPartValue(rev); +// if(vals == null) { +// return ; +// } +// for (int j = 0; j < vals.size(); j++) { +// String value = vals.get(j); +// if(value.contains("=")) { +// if(value.contains("单位")) { +// String[] units = value.split("="); +// if(units.length >= 2) { +// unit = units[1]; +// } +// }else if(value.contains("品牌")) { +// String[] brands = value.split("="); +// if(brands.length >= 2) { +// brand = brands[1]; +// } +// }else { +// spec = value; +// } +// }else { +// spec = value; +// } +// } + ClassValueBean valueBean = ClassValueUtil.getOutBuyPartValue(rev,errList); + if(valueBean != null) { + spec = valueBean.getSpecs(); + }else { + return; + } + }else { + spec = getOutsourceValue(rev); + } + unit = rev.getStringProperty("t2_unit"); + + }else if("T2_OutBuyPartRevision".equals(type)) { +// List vals= getOutBuyPartValue(rev); +// for (int j = 0; j < vals.size(); j++) { +// String value = vals.get(j); +// if(value.contains("=")) { +// if(value.contains("单位")) { +// String[] units = value.split("="); +// if(units.length >= 2) { +// unit = units[1]; +// } +// }else if(value.contains("品牌")) { +// String[] brands = value.split("="); +// if(brands.length >= 2) { +// brand = brands[1]; +// } +// }else { +// spec = value; +// } +// }else { +// spec = value; +// } +// } + ClassValueBean valueBean = ClassValueUtil.getOutBuyPartValue(rev,errList); + if(valueBean != null) { + spec = valueBean.getSpecs(); + unit = valueBean.getUnit(); + brand = valueBean.getBrand(); + if(spec == null) { + spec = ""; + } + if(unit == null) { + unit = ""; + } + if(brand == null) { + brand = ""; + } + }else { + return; + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + System.out.println(item_id+"spec=================="+spec); + + beanList.add(xuhao); + beanList.add(item_id); + beanList.add(name); + //beanList.add(lev); + beanList.add(spec); + beanList.add(unit); + beanList.add(design_num); + beanList.add(brand); + beanList.add(weihao); + beanList.add(importance); + list.add(beanList); + } + public void getItemValue1(TCComponentBOMLine comp,int level,int num) throws TCException { + + + + //lev1 = level + ""; + TCComponentItemRevision rev = comp.getItemRevision(); + try { + design_num1 = comp.getStringProperty("T2_ActualConsumption"); + //如果实际用量是打包的,则解包再判断 + if("已打包的注释".equals(design_num1)) { + comp.unpack(); + comp.refresh(); + design_num1 = comp.getStringProperty("T2_ActualConsumption"); + } + //如果不是则继续判断是否为空 + else if(design_num1 == null || "".equals(design_num1) || " ".equals(design_num1)) { + design_num1 = comp.getStringProperty("T2_DesignQuantity"); + //如果设计用量是打包的,则解包再判断 + if("已打包的注释".equals(design_num1)) { + comp.unpack(); + comp.refresh(); + design_num1 = comp.getStringProperty("T2_DesignQuantity"); + } + //如果不是则继续判断是否为空 + else if(design_num1 == null || "".equals(design_num1) || " ".equals(design_num1)) { + design_num1 = comp.getStringProperty("bl_quantity"); + if(design_num1 == null || "".equals(design_num1) || " ".equals(design_num1)) { + design_num1 = "1"; + } + } + } + + String type = rev.getStringProperty("object_type"); + weihao1 = comp.getStringProperty("T2_weihao"); + importance1 = comp.getStringProperty("t2_BOMImportance"); + item_id1 = rev.getStringProperty("item_id"); + name1 = rev.getStringProperty("object_name"); + if("T2_outsourceRevision".equals(type)) { + xuhao1 = num ; + String classID = item_id1.substring(0, 2); + System.out.println("classID==============="+classID); + if("51".equals(classID) || "72".equals(classID) || "76".equals(classID)) { + + ClassValueBean valueBean = ClassValueUtil.getOutBuyPartValue(rev,errList); + if(valueBean != null) { + spec1 = valueBean.getSpecs(); + }else { + return; + } + }else { + spec1 = getOutsourceValue(rev); + } + unit1 = rev.getStringProperty("t2_unit"); + + }else if("T2_OutBuyPartRevision".equals(type)) { + xuhao1 = num; + ClassValueBean valueBean = ClassValueUtil.getOutBuyPartValue(rev,errList); + if(valueBean != null) { + spec1 = valueBean.getSpecs(); + unit1 = valueBean.getUnit(); + brand1 = valueBean.getBrand(); + if(spec1 == null) { + spec1 = ""; + } + if(unit1 == null) { + unit1 = ""; + } + if(brand1 == null) { + brand1 = ""; + } + }else { + return; + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + System.out.println(item_id1+"spec=================="+spec1); + } + + //若子bom中有已打包的注释则解包 + private void Unpack(TCComponentBOMLine unpackLine) { + try { + //获得子级对象 + AIFComponentContext[] childs = unpackLine.getChildren(); + if(childs != null && childs.length > 0 ) { + //遍历子级对象 + for (int i = 0; i < childs.length; i++) { + //选中的对象 + InterfaceAIFComponent comp = childs[i].getComponent(); + //选中的对象的版本 + TCComponentItemRevision rev = ((TCComponentBOMLine) comp).getItemRevision(); + String type = rev.getStringProperty("object_type"); + String occType = unpackLine.getStringProperty("TCAI_OCC_TYPE"); + //判断是否属于bomline + if(comp instanceof TCComponentBOMLine) { + if("T2_outsourceRevision".equals(type) || "T2_OutBuyPartRevision".equals(type)) { + if (!"Reference".equals(occType)) + { + List beanList1 = new ArrayList(); + //将遍历的对象强转类型为bomline + TCComponentBOMLine ziLine = (TCComponentBOMLine) comp; + //判断是否有已打包的注释,然后解包 + String Judgmentnote = null; + Judgmentnote=ziLine.getStringProperty("T2_ActualConsumption"); + if("已打包的注释".equals(Judgmentnote)) { + ziLine.unpack(); + ziLine.refresh(); + unpackLine.refresh(); + }else if (Judgmentnote == null || "".equals(Judgmentnote) || " ".equals(Judgmentnote)) { + Judgmentnote=ziLine.getStringProperty("T2_DesignQuantity"); + }if("已打包的注释".equals(Judgmentnote)) { + ziLine.unpack(); + ziLine.refresh(); + unpackLine.refresh(); + } + } + } + } + } + } + }catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/dfl/plm/exportBOM/ChangeDbomUtil.java b/src/com/connor/dfl/plm/exportBOM/ChangeDbomUtil.java new file mode 100644 index 0000000..9b12eec --- /dev/null +++ b/src/com/connor/dfl/plm/exportBOM/ChangeDbomUtil.java @@ -0,0 +1,56 @@ +package com.connor.dfl.plm.exportBOM; +import java.util.List; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMViewRevision; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentContextList; +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.TCQueryClause; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; + +public class ChangeDbomUtil { + public static TCPreferenceService service; + public static TCSession session; + public static TCUserService userservice;; + + static { + if (session == null) { + session = (TCSession) (AIFUtility.getCurrentApplication() + .getSession()); + } + if (service == null) + service = session.getPreferenceService(); + } + + public static void setByPass(boolean val) throws TCException { + 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); + } + } + + + +} \ No newline at end of file diff --git a/src/com/connor/dfl/plm/forms/AccountSetTaskListenerChangeApplyy.java b/src/com/connor/dfl/plm/forms/AccountSetTaskListenerChangeApplyy.java new file mode 100644 index 0000000..2438ded --- /dev/null +++ b/src/com/connor/dfl/plm/forms/AccountSetTaskListenerChangeApplyy.java @@ -0,0 +1,24 @@ +package com.connor.dfl.plm.forms; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class AccountSetTaskListenerChangeApplyy implements ActionListener{ + ChangeApplyForm cf; + + + + public AccountSetTaskListenerChangeApplyy(ChangeApplyForm cf) { + this.cf = cf; + } + + public void actionPerformed(ActionEvent e) { + + AcountSet_AddDialog_ChangeApply cp = new AcountSet_AddDialog_ChangeApply(cf); + + } + + + + +} diff --git a/src/com/connor/dfl/plm/forms/AccountSetTaskListenerChangeNotify.java b/src/com/connor/dfl/plm/forms/AccountSetTaskListenerChangeNotify.java new file mode 100644 index 0000000..7a876d0 --- /dev/null +++ b/src/com/connor/dfl/plm/forms/AccountSetTaskListenerChangeNotify.java @@ -0,0 +1,23 @@ +package com.connor.dfl.plm.forms; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class AccountSetTaskListenerChangeNotify implements ActionListener{ + ChangeNotifyForm cn; + + + + public AccountSetTaskListenerChangeNotify( ChangeNotifyForm cn ) { + this.cn = cn; + } + + public void actionPerformed(ActionEvent e) { + AcountSet_AddDialog_ChangeNotify sn = new AcountSet_AddDialog_ChangeNotify(cn); + + } + + + + +} diff --git a/src/com/connor/dfl/plm/forms/AccountSetTaskListenerPressureQECN.java b/src/com/connor/dfl/plm/forms/AccountSetTaskListenerPressureQECN.java new file mode 100644 index 0000000..85c1bb7 --- /dev/null +++ b/src/com/connor/dfl/plm/forms/AccountSetTaskListenerPressureQECN.java @@ -0,0 +1,22 @@ +package com.connor.dfl.plm.forms; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class AccountSetTaskListenerPressureQECN implements ActionListener{ + QuickChangeForm qf; + + + public AccountSetTaskListenerPressureQECN(QuickChangeForm qf ) { + this.qf = qf; + } + + public void actionPerformed(ActionEvent e) { + AcountSet_AddDialog_PresserQECN qfs = new AcountSet_AddDialog_PresserQECN(qf); + + } + + + + +} diff --git a/src/com/connor/dfl/plm/forms/AcountSet_AddDialog_ChangeApply.java b/src/com/connor/dfl/plm/forms/AcountSet_AddDialog_ChangeApply.java new file mode 100644 index 0000000..7873318 --- /dev/null +++ b/src/com/connor/dfl/plm/forms/AcountSet_AddDialog_ChangeApply.java @@ -0,0 +1,473 @@ +/** + * + */ +package com.connor.dfl.plm.forms; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Point; +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.List; +import java.util.Map; +import java.util.Vector; + +import javax.swing.DefaultCellEditor; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.LineBorder; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +import com.connor.dfl.plm.forms.ChangeApplyForm.MyTable; +import com.connor.dfl.plm.table.CTMap; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +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.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +/** + * + * + */ +public class AcountSet_AddDialog_ChangeApply extends AbstractAIFDialog { + AbstractAIFApplication app= AIFUtility.getCurrentApplication(); + + + private TCComponentItemType itemType; + private TCSession session; + private JButton okBtn; + private JButton celBtn; + private MyTable table; + DefaultTableModel model; + private DefaultTableCellRenderer tcr; + private JComboBox project_id; + private JButton addbtn; + private JButton delbtn; + int rows1 = 1; + private List AccountSet_lists = new ArrayList() ; + private String [] arrays ; + + + + + //private String[] tz_lists = {"物控","质保","生产","采购","服务","销售","容器"} ; + private List hadList = new ArrayList(); + + private String proid = ""; + private ChangeApplyForm cf; + + //private Project_Code code; + + public AcountSet_AddDialog_ChangeApply(ChangeApplyForm cf){ + super(true); + // this.code = code; + this.cf = cf; + this.session = (TCSession) app.getSession(); + try { + initUI(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private void initUI() throws TCException{ + + + + String[] stringArray = session.getPreferenceService().getStringValues("DFL_zhangtao"); + + if (stringArray == null || stringArray.length <= 0 ) { + MessageBox.post("首选项DFL_zhangtao未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + }else { + + arrays = new String[stringArray.length]; + + + for(int i = 0 ;i list =getChangeDetail(name); + int[] sRows = table.getSelectedRows(); + int p ; + for (int j = sRows.length-1; j >=0 ; j--) { + model.removeRow(table.getSelectedRow()); + for (int i = sRows[j]; i < table.getRowCount(); i++) { + model.setValueAt(Integer.toString(i + 1), i, 0); + } + rows1--; + + } + + + } + }); + + + + + + // for(int r = 0 ;r0) { + System.out.println(model.getValueAt(v, 1).toString()); + hadList.add((String) model.getValueAt(v, 1).toString()); + }else { + System.out.println("该单元格值为空"); + } + } + + if(hadList.size()>0) { + for(int li= 0 ;li map = new HashMap(); + + public void setComboCell(int r, int c, TableCellEditor ce) { + this.myRow = r; + this.myCol = c; + this.myEditor = ce; + map.put(new Point(r, c), ce); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + System.out.println(row + "," + column + ";" + myRow + "," + myCol + "," + myEditor); + + Point point = new Point(row, column); + if (map.containsKey(point)) { + return map.get(point); + } else { + return super.getCellEditor(row, column); + } + } + } + + + + + + + private static String[] insertElement(String original[],String element,int index){ + + int length=original.length; + + String destination[]=new String[length+1]; + + System.arraycopy(original, 0, destination, 0, index); + + destination[index]=element; + + System.arraycopy(original, index, destination, index+1, length-index); + + return destination; + } + + + + + + + + + + + + + + + + + +} diff --git a/src/com/connor/dfl/plm/forms/AcountSet_AddDialog_ChangeNotify.java b/src/com/connor/dfl/plm/forms/AcountSet_AddDialog_ChangeNotify.java new file mode 100644 index 0000000..c0651e5 --- /dev/null +++ b/src/com/connor/dfl/plm/forms/AcountSet_AddDialog_ChangeNotify.java @@ -0,0 +1,469 @@ +/** + * + */ +package com.connor.dfl.plm.forms; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Point; +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.List; +import java.util.Map; +import java.util.Vector; + +import javax.swing.DefaultCellEditor; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.LineBorder; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +import com.connor.dfl.plm.forms.ChangeApplyForm.MyTable; +import com.connor.dfl.plm.table.CTMap; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +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.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +/** + * + * + */ +public class AcountSet_AddDialog_ChangeNotify extends AbstractAIFDialog { + AbstractAIFApplication app= AIFUtility.getCurrentApplication(); + + + private TCComponentItemType itemType; + private TCSession session; + private JButton okBtn; + private JButton celBtn; + private MyTable table; + DefaultTableModel model; + private DefaultTableCellRenderer tcr; + private JComboBox project_id; + private JButton addbtn; + private JButton delbtn; + int rows1 = 1; + private List AccountSet_lists = new ArrayList() ; + private String [] arrays; + + + + + //private String[] tz_lists = {"物控","质保","生产","采购","服务","销售","容器"} ; + private List hadList = new ArrayList(); + + private String proid = ""; + private ChangeNotifyForm cn; + + //private Project_Code code; + + public AcountSet_AddDialog_ChangeNotify(ChangeNotifyForm cn){ + super(true); + // this.code = code; + this.cn = cn; + this.session = (TCSession) app.getSession(); + try { + initUI(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private void initUI() throws TCException{ + + + + String[] stringArray = session.getPreferenceService().getStringValues("DFL_zhangtao"); + + if (stringArray == null || stringArray.length <= 0 ) { + MessageBox.post("首选项DFL_zhangtao未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + }else { + arrays = new String[stringArray.length]; + + + for(int i = 0 ;i list =getChangeDetail(name); + int[] sRows = table.getSelectedRows(); + int p ; + for (int j = sRows.length-1; j >=0 ; j--) { + model.removeRow(table.getSelectedRow()); + for (int i = sRows[j]; i < table.getRowCount(); i++) { + model.setValueAt(Integer.toString(i + 1), i, 0); + } + rows1--; + + } + + + } + }); + + + + + + // for(int r = 0 ;r0) { + System.out.println(model.getValueAt(v, 1).toString()); + hadList.add((String) model.getValueAt(v, 1).toString()); + }else { + System.out.println("该单元格值为空"); + } + } + + if(hadList.size()>0) { + for(int li= 0 ;li map = new HashMap(); + + public void setComboCell(int r, int c, TableCellEditor ce) { + this.myRow = r; + this.myCol = c; + this.myEditor = ce; + map.put(new Point(r, c), ce); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + System.out.println(row + "," + column + ";" + myRow + "," + myCol + "," + myEditor); + + Point point = new Point(row, column); + if (map.containsKey(point)) { + return map.get(point); + } else { + return super.getCellEditor(row, column); + } + } + } + + + + + + + + +private static String[] insertElement(String original[],String element,int index){ + + int length=original.length; + + String destination[]=new String[length+1]; + + System.arraycopy(original, 0, destination, 0, index); + + destination[index]=element; + + System.arraycopy(original, index, destination, index+1, length-index); + + return destination; + } + + + + + + + + + + + + + + + +} diff --git a/src/com/connor/dfl/plm/forms/AcountSet_AddDialog_PresserQECN.java b/src/com/connor/dfl/plm/forms/AcountSet_AddDialog_PresserQECN.java new file mode 100644 index 0000000..1383379 --- /dev/null +++ b/src/com/connor/dfl/plm/forms/AcountSet_AddDialog_PresserQECN.java @@ -0,0 +1,452 @@ +/** + * + */ +package com.connor.dfl.plm.forms; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Point; +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.List; +import java.util.Map; +import java.util.Vector; + +import javax.swing.DefaultCellEditor; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.LineBorder; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +import com.connor.dfl.plm.forms.ChangeApplyForm.MyTable; +import com.connor.dfl.plm.table.CTMap; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +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.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +/** + * + * + */ +public class AcountSet_AddDialog_PresserQECN extends AbstractAIFDialog { + AbstractAIFApplication app= AIFUtility.getCurrentApplication(); + + + private TCComponentItemType itemType; + private TCSession session; + private JButton okBtn; + private JButton celBtn; + private MyTable table; + DefaultTableModel model; + private DefaultTableCellRenderer tcr; + private JComboBox project_id; + private JButton addbtn; + private JButton delbtn; + int rows1 = 1; + private List AccountSet_lists = new ArrayList() ; + private String [] arrays; + + + + + //private String[] tz_lists = {"物控","质保","生产","采购","服务","销售","容器"} ; + private List hadList = new ArrayList(); + + private String proid = ""; + private QuickChangeForm qf; + + //private Project_Code code; + + public AcountSet_AddDialog_PresserQECN(QuickChangeForm qf){ + super(true); + // this.code = code; + this.qf = qf; + this.session = (TCSession) app.getSession(); + try { + initUI(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private void initUI() throws TCException{ + + + + String[] stringArray = session.getPreferenceService().getStringValues("DFL_zhangtao"); + + if (stringArray == null || stringArray.length <= 0 ) { + MessageBox.post("首选项DFL_zhangtao未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + }else { + arrays = new String[stringArray.length]; + + for(int i = 0 ;i list =getChangeDetail(name); + int[] sRows = table.getSelectedRows(); + int p ; + for (int j = sRows.length-1; j >=0 ; j--) { + model.removeRow(table.getSelectedRow()); + for (int i = sRows[j]; i < table.getRowCount(); i++) { + model.setValueAt(Integer.toString(i + 1), i, 0); + } + rows1--; + + } + + + } + }); + + + + + + // for(int r = 0 ;r0) { + System.out.println(model.getValueAt(v, 1).toString()); + hadList.add((String) model.getValueAt(v, 1).toString()); + }else { + System.out.println("该单元格值为空"); + } + } + + if(hadList.size()>0) { + for(int li= 0 ;li map = new HashMap(); + + public void setComboCell(int r, int c, TableCellEditor ce) { + this.myRow = r; + this.myCol = c; + this.myEditor = ce; + map.put(new Point(r, c), ce); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + System.out.println(row + "," + column + ";" + myRow + "," + myCol + "," + myEditor); + + Point point = new Point(row, column); + if (map.containsKey(point)) { + return map.get(point); + } else { + return super.getCellEditor(row, column); + } + } + } + + + private static String[] insertElement(String original[],String element,int index){ + + int length=original.length; + + String destination[]=new String[length+1]; + + System.arraycopy(original, 0, destination, 0, index); + + destination[index]=element; + + System.arraycopy(original, index, destination, index+1, length-index); + + return destination; + } + + + + + +} diff --git a/src/com/connor/dfl/plm/forms/AddDialogApply.java b/src/com/connor/dfl/plm/forms/AddDialogApply.java new file mode 100644 index 0000000..5d30e8f --- /dev/null +++ b/src/com/connor/dfl/plm/forms/AddDialogApply.java @@ -0,0 +1,480 @@ +/** + * + */ +package com.connor.dfl.plm.forms; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Point; +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.List; +import java.util.Map; +import java.util.Vector; + +import javax.swing.DefaultCellEditor; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.LineBorder; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +import com.connor.dfl.plm.forms.ChangeApplyForm.MyTable; +import com.connor.dfl.plm.table.CTMap; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +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.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +/** + * + * + */ +public class AddDialogApply extends AbstractAIFDialog { + AbstractAIFApplication app= AIFUtility.getCurrentApplication(); + + + private TCComponentItemType itemType; + private TCSession session; + private JButton okBtn; + private JButton celBtn; + private MyTable table; + DefaultTableModel model; + private DefaultTableCellRenderer tcr; + private JComboBox project_id; + private JButton addbtn; + private JButton delbtn; + int rows1 = 1; + private String[] project_lists = null ; + List hadList = new ArrayList(); + String proid = ""; + private ChangeApplyForm changeform; + + //private Project_Code code; + + public AddDialogApply(ChangeApplyForm changeform){ + super(true); + // this.code = code; + this.changeform = changeform; + this.session = (TCSession) app.getSession(); + try { + initUI(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private void initUI() throws TCException{ + this.setTitle("选择要添加的项目"); + + this.setLayout(new BorderLayout()); + + // JPanel boxPabel = new JPanel(); + // boxPabel.setPreferredSize(new Dimension(300,590)); + // + + + + model = new DefaultTableModel(null, new String[] {"序号","项目ID"}) { + + public void setValueAt(Object value, int row, int col){ + + + Vector rowVector = (Vector) dataVector.elementAt(row); + rowVector.setElementAt(value, col); + fireTableCellUpdated(row, col); + + } + }; + + + + + table = new MyTable() { + @Override + public boolean isCellEditable(int row, int column) { + if(column == 1) { + return true; + } + return false; + + } + + }; + + + + table.setModel(model); + table.setColumnModel(getColumn(table, new int[] {80,200})); + table.setRowHeight(40); + + + + + + + + + + String[] keys = new String[] { "ID" }; + TCComponentUser user = session.getUser(); + String user_id = user.getStringProperty("user_id"); + String[] values = new String[] { user_id }; + List compList = queryObject("基于用户的项目", keys, values); + + if (compList != null && compList.size() > 0) { + project_lists =new String[compList.size()]; + for (int i = 0; i < compList.size(); i++) { + TCComponent comp1 = compList.get(i); + if (comp1 instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) comp1; + try { + + String id = project.getStringProperty("project_id"); + project_lists[i] = id; + // + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + } + + + addbtn = new JButton("添加"); + delbtn = new JButton("删除"); + + addbtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + model.addRow(new String[] { Integer.toString(rows1++) }); + table.setComboCell(rows1-2, 1, new com.connor.dfl.plm.table.MyComboBoxEditor2(project_lists)); + + } + }); + + + delbtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + int sRow = table.getSelectedRow(); + if(sRow == -1) { + javax.swing.JOptionPane.showMessageDialog(null, "请选中后移除", "系统提示", + javax.swing.JOptionPane.WARNING_MESSAGE); + return; + } + + //List list =getChangeDetail(name); + int[] sRows = table.getSelectedRows(); + int p ; + for (int j = sRows.length-1; j >=0 ; j--) { + model.removeRow(table.getSelectedRow()); + for (int i = sRows[j]; i < table.getRowCount(); i++) { + model.setValueAt(Integer.toString(i + 1), i, 0); + } + rows1--; + + } + + + } + }); + + + + + +// for(int r = 0 ;r0) { + System.out.println(model.getValueAt(v, 1).toString()); + hadList.add((String) model.getValueAt(v, 1).toString()); + }else { + System.out.println("该单元格值为空"); + } + } + + if(hadList.size()>0) { + for(int li= 0 ;li map = new HashMap(); + + public void setComboCell(int r, int c, TableCellEditor ce) { + this.myRow = r; + this.myCol = c; + this.myEditor = ce; + map.put(new Point(r, c), ce); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + System.out.println(row + "," + column + ";" + myRow + "," + myCol + "," + myEditor); + + Point point = new Point(row, column); + if (map.containsKey(point)) { + return map.get(point); + } else { + return super.getCellEditor(row, column); + } + } + } + + + + + + + + + + + + + + + + + /** + * 通过查询构建器查询项目对象 + * + * @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/dfl/plm/forms/AddDialogApply_TZ.java b/src/com/connor/dfl/plm/forms/AddDialogApply_TZ.java new file mode 100644 index 0000000..cc64708 --- /dev/null +++ b/src/com/connor/dfl/plm/forms/AddDialogApply_TZ.java @@ -0,0 +1,181 @@ +/** + * + */ +package com.connor.dfl.plm.forms; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Point; +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.List; +import java.util.Map; +import java.util.Vector; + +import javax.swing.DefaultCellEditor; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.LineBorder; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +import com.connor.dfl.plm.forms.ChangeApplyForm.MyTable; +import com.connor.dfl.plm.table.CTMap; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +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.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +/** + * + * + */ +public class AddDialogApply_TZ extends AbstractAIFDialog { + AbstractAIFApplication app= AIFUtility.getCurrentApplication(); + + + private TCComponentItemType itemType; + private TCSession session; + private JButton okBtn; + private JButton celBtn; + private JPanel btnPanel1; + //private MyTable table; + DefaultTableModel model; + //private DefaultTableCellRenderer tcr; + //private JComboBox project_id; + //private JButton addbtn; + //private JButton delbtn; + int rows1 = 1; + //private String[] tz_lists = {"物控","质保","生产","采购","服务","销售","容器"} ; + List hadList = new ArrayList(); + String proid = ""; + private ChangeApplyForm cf; + + //private Project_Code code; + + public AddDialogApply_TZ(ChangeApplyForm cf){ + super(true); + // this.code = code; + this.cf = cf; + this.session = (TCSession) app.getSession(); + try { + initUI(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private void initUI() throws TCException{ + this.setTitle("选择图纸发至"); + this.setLayout(new PropertyLayout()); + this.setPreferredSize(new Dimension(400, 150)); + btnPanel1 = new JPanel(); + String[] strs = session.getPreferenceService().getStringValues("DFL_to_Department"); + if (strs == null || strs.length <= 0 ) { + MessageBox.post("首选项DFL_to_Department未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + } + for (int i = 0; i < strs.length; i++) { + System.out.println("==========="+strs[i]); + JCheckBox checkBox = new JCheckBox(strs[i]); + btnPanel1.add(checkBox); + } + okBtn=new JButton("确定"); + celBtn=new JButton("取消"); + + okBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + + List list = new ArrayList(); + Component[] jcbs = btnPanel1.getComponents();//将勾选的内容存入数组 + for(Component component : jcbs) { + JCheckBox jcb = (JCheckBox) component; + if(jcb.isSelected()) { + list.add(jcb.getText()); + } + } + + String s = (cf.table1.getValueAt(7, 5) == null ? "" :cf.table1.getValueAt(7, 5).toString()); + + StringBuilder sb = new StringBuilder(s); + + for (int i = 0; i < list.size(); i++) { + if(s.contains(list.get(i))) { + continue; + } + if(!("".equals(s.trim()))) { + sb.append(";"); + } + sb.append(list.get(i)); + if(i < list.size()-1) { + sb.append(";"); + } + } + + //changeform.model1.setValueAt(proid, 8, 1); + cf.table1.setValueAt( sb.toString(), 7, 5); + disposeDialog(); + MessageBox.post("图纸发至添加完成!", "提示", MessageBox.INFORMATION); + } + }); + + celBtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + + JPanel btnPanel = new JPanel(); + btnPanel.setLayout(new PropertyLayout()); + //btnPanel.setPreferredSize(new Dimension(600, 100)); + + btnPanel.add("1.1.right.center",new JLabel(" ")); + btnPanel.add("1.2.right.center",okBtn); + btnPanel.add("1.3.right.center",new JLabel(" ")); + btnPanel.add("1.4.right.center",celBtn); + + this.add("1.1.left.top",btnPanel1); + this.add("2.1.left.top",btnPanel); + + this.setResizable(false); + //this.add(new JLabel(" ")); + this.setBounds(5, 5, 5, 5); + this.centerToScreen(); + this.showDialog(); + + } +} diff --git a/src/com/connor/dfl/plm/forms/AddDialogNotify.java b/src/com/connor/dfl/plm/forms/AddDialogNotify.java new file mode 100644 index 0000000..e0de3b6 --- /dev/null +++ b/src/com/connor/dfl/plm/forms/AddDialogNotify.java @@ -0,0 +1,480 @@ +/** + * + */ +package com.connor.dfl.plm.forms; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Point; +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.List; +import java.util.Map; +import java.util.Vector; + +import javax.swing.DefaultCellEditor; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.LineBorder; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +import com.connor.dfl.plm.forms.ChangeApplyForm.MyTable; +import com.connor.dfl.plm.table.CTMap; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +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.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +/** + * + * + */ +public class AddDialogNotify extends AbstractAIFDialog { + AbstractAIFApplication app= AIFUtility.getCurrentApplication(); + + + private TCComponentItemType itemType; + private TCSession session; + private JButton okBtn; + private JButton celBtn; + private MyTable table; + DefaultTableModel model; + private DefaultTableCellRenderer tcr; + private JComboBox project_id; + private JButton addbtn; + private JButton delbtn; + int rows1 = 1; + private String[] project_lists = null ; + List hadList = new ArrayList(); + String proid = ""; + private ChangeNotifyForm notifyform; + + //private Project_Code code; + + public AddDialogNotify(ChangeNotifyForm notifyform){ + super(true); + // this.code = code; + this.notifyform = notifyform; + this.session = (TCSession) app.getSession(); + try { + initUI(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private void initUI() throws TCException{ + this.setTitle("选择要添加的项目"); + + this.setLayout(new BorderLayout()); + + // JPanel boxPabel = new JPanel(); + // boxPabel.setPreferredSize(new Dimension(300,590)); + // + + + + model = new DefaultTableModel(null, new String[] {"序号","项目ID"}) { + + public void setValueAt(Object value, int row, int col){ + + + Vector rowVector = (Vector) dataVector.elementAt(row); + rowVector.setElementAt(value, col); + fireTableCellUpdated(row, col); + + } + }; + + + + + table = new MyTable() { + @Override + public boolean isCellEditable(int row, int column) { + if(column == 1) { + return true; + } + return false; + + } + + }; + + + + table.setModel(model); + table.setColumnModel(getColumn(table, new int[] {80,200})); + table.setRowHeight(40); + + + + + + + + + + String[] keys = new String[] { "ID" }; + TCComponentUser user = session.getUser(); + String user_id = user.getStringProperty("user_id"); + String[] values = new String[] { user_id }; + List compList = queryObject("基于用户的项目", keys, values); + + if (compList != null && compList.size() > 0) { + project_lists =new String[compList.size()]; + for (int i = 0; i < compList.size(); i++) { + TCComponent comp1 = compList.get(i); + if (comp1 instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) comp1; + try { + + String id = project.getStringProperty("project_id"); + project_lists[i] = id; + // + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + } + + + addbtn = new JButton("添加"); + delbtn = new JButton("删除"); + + addbtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + model.addRow(new String[] { Integer.toString(rows1++) }); + table.setComboCell(rows1-2, 1, new com.connor.dfl.plm.table.MyComboBoxEditor2(project_lists)); + + } + }); + + + delbtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + int sRow = table.getSelectedRow(); + if(sRow == -1) { + javax.swing.JOptionPane.showMessageDialog(null, "请选中后移除", "系统提示", + javax.swing.JOptionPane.WARNING_MESSAGE); + return; + } + + //List list =getChangeDetail(name); + int[] sRows = table.getSelectedRows(); + int p ; + for (int j = sRows.length-1; j >=0 ; j--) { + model.removeRow(table.getSelectedRow()); + for (int i = sRows[j]; i < table.getRowCount(); i++) { + model.setValueAt(Integer.toString(i + 1), i, 0); + } + rows1--; + + } + + + } + }); + + + + + +// for(int r = 0 ;r0) { + System.out.println(model.getValueAt(v, 1).toString()); + hadList.add((String) model.getValueAt(v, 1).toString()); + }else { + System.out.println("该单元格值为空"); + } + } + + if(hadList.size()>0) { + for(int li= 0 ;li map = new HashMap(); + + public void setComboCell(int r, int c, TableCellEditor ce) { + this.myRow = r; + this.myCol = c; + this.myEditor = ce; + map.put(new Point(r, c), ce); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + System.out.println(row + "," + column + ";" + myRow + "," + myCol + "," + myEditor); + + Point point = new Point(row, column); + if (map.containsKey(point)) { + return map.get(point); + } else { + return super.getCellEditor(row, column); + } + } + } + + + + + + + + + + + + + + + + + /** + * 通过查询构建器查询项目对象 + * + * @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/dfl/plm/forms/AddDialogNotify_TZ.java b/src/com/connor/dfl/plm/forms/AddDialogNotify_TZ.java new file mode 100644 index 0000000..e1afa29 --- /dev/null +++ b/src/com/connor/dfl/plm/forms/AddDialogNotify_TZ.java @@ -0,0 +1,147 @@ +/** + * + */ +package com.connor.dfl.plm.forms; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +/** + * + * + */ +public class AddDialogNotify_TZ extends AbstractAIFDialog { + AbstractAIFApplication app= AIFUtility.getCurrentApplication(); + + + private TCComponentItemType itemType; + private TCSession session; + private JButton okBtn; + private JButton celBtn; + private JPanel btnPanel1; + private JButton addbtn; + private JButton delbtn; + private ChangeNotifyForm nf; + + //private Project_Code code; + + public AddDialogNotify_TZ(ChangeNotifyForm nf){ + super(true); + // this.code = code; + this.nf = nf; + this.session = (TCSession) app.getSession(); + try { + initUI(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + + private void initUI() throws TCException{ + this.setTitle("选择图纸发至"); + this.setLayout(new PropertyLayout()); + this.setPreferredSize(new Dimension(400, 150)); + btnPanel1 = new JPanel(); + String[] strs = session.getPreferenceService().getStringValues("DFL_to_Department"); + if (strs == null || strs.length <= 0 ) { + MessageBox.post("首选项DFL_to_Department未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + } + for (int i = 0; i < strs.length; i++) { + System.out.println("==========="+strs[i]); + JCheckBox checkBox = new JCheckBox(strs[i]); + btnPanel1.add(checkBox); + } + + okBtn=new JButton("确定"); + celBtn=new JButton("取消"); + + okBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + + List list = new ArrayList(); + Component[] jcbs = btnPanel1.getComponents();//将勾选的内容存入数组 + for(Component component : jcbs) { + JCheckBox jcb = (JCheckBox) component; + if(jcb.isSelected()) { + list.add(jcb.getText()); + } + } + + String s = (nf.table1.getValueAt(7, 5) == null ? "" :nf.table1.getValueAt(7, 5).toString()); + StringBuilder sb = new StringBuilder(s); + + for (int i = 0; i < list.size(); i++) { + if(s.contains(list.get(i))) { + continue; + } + if(!("".equals(s.trim()))) { + sb.append(";"); + } + sb.append(list.get(i)); + if(i < list.size()-1) { + sb.append(";"); + } + } + + //changeform.model1.setValueAt(proid, 8, 1); + nf.table1.setValueAt( sb.toString(), 7, 5); + disposeDialog(); + MessageBox.post("图纸发至添加完成!", "提示", MessageBox.INFORMATION); + } + }); + + + + + + celBtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + + JPanel btnPanel = new JPanel(); + btnPanel.setLayout(new PropertyLayout()); + //btnPanel.setPreferredSize(new Dimension(600, 100)); + + btnPanel.add("1.1.right.center",new JLabel(" ")); + btnPanel.add("1.2.right.center",okBtn); + btnPanel.add("1.3.right.center",new JLabel(" ")); + btnPanel.add("1.4.right.center",celBtn); + + + this.add("1.1.left.top",btnPanel1); + this.add("2.1.left.top",btnPanel); + + + this.setResizable(false); + this.setBounds(5, 5, 5, 5); + this.centerToScreen(); + this.showDialog(); + + } +} + diff --git a/src/com/connor/dfl/plm/forms/AddDialogQuick.java b/src/com/connor/dfl/plm/forms/AddDialogQuick.java new file mode 100644 index 0000000..5223eeb --- /dev/null +++ b/src/com/connor/dfl/plm/forms/AddDialogQuick.java @@ -0,0 +1,480 @@ +/** + * + */ +package com.connor.dfl.plm.forms; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Point; +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.List; +import java.util.Map; +import java.util.Vector; + +import javax.swing.DefaultCellEditor; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.LineBorder; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +import com.connor.dfl.plm.forms.ChangeApplyForm.MyTable; +import com.connor.dfl.plm.table.CTMap; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +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.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +/** + * + * + */ +public class AddDialogQuick extends AbstractAIFDialog { + AbstractAIFApplication app= AIFUtility.getCurrentApplication(); + + + private TCComponentItemType itemType; + private TCSession session; + private JButton okBtn; + private JButton celBtn; + private MyTable table; + DefaultTableModel model; + private DefaultTableCellRenderer tcr; + private JComboBox project_id; + private JButton addbtn; + private JButton delbtn; + int rows1 = 1; + private String[] project_lists = null ; + List hadList = new ArrayList(); + String proid = ""; + private QuickChangeForm quickform; + + //private Project_Code code; + + public AddDialogQuick(QuickChangeForm quickform){ + super(true); + // this.code = code; + this.quickform = quickform; + this.session = (TCSession) app.getSession(); + try { + initUI(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private void initUI() throws TCException{ + this.setTitle("选择要添加的项目"); + + this.setLayout(new BorderLayout()); + + // JPanel boxPabel = new JPanel(); + // boxPabel.setPreferredSize(new Dimension(300,590)); + // + + + + model = new DefaultTableModel(null, new String[] {"序号","项目ID"}) { + + public void setValueAt(Object value, int row, int col){ + + + Vector rowVector = (Vector) dataVector.elementAt(row); + rowVector.setElementAt(value, col); + fireTableCellUpdated(row, col); + + } + }; + + + + + table = new MyTable() { + @Override + public boolean isCellEditable(int row, int column) { + if(column == 1) { + return true; + } + return false; + + } + + }; + + + + table.setModel(model); + table.setColumnModel(getColumn(table, new int[] {80,200})); + table.setRowHeight(40); + + + + + + + + + + String[] keys = new String[] { "ID" }; + TCComponentUser user = session.getUser(); + String user_id = user.getStringProperty("user_id"); + String[] values = new String[] { user_id }; + List compList = queryObject("基于用户的项目", keys, values); + + if (compList != null && compList.size() > 0) { + project_lists =new String[compList.size()]; + for (int i = 0; i < compList.size(); i++) { + TCComponent comp1 = compList.get(i); + if (comp1 instanceof TCComponentProject) { + TCComponentProject project = (TCComponentProject) comp1; + try { + + String id = project.getStringProperty("project_id"); + project_lists[i] = id; + // + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + } + + + addbtn = new JButton("添加"); + delbtn = new JButton("删除"); + + addbtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + model.addRow(new String[] { Integer.toString(rows1++) }); + table.setComboCell(rows1-2, 1, new com.connor.dfl.plm.table.MyComboBoxEditor2(project_lists)); + + } + }); + + + delbtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + int sRow = table.getSelectedRow(); + if(sRow == -1) { + javax.swing.JOptionPane.showMessageDialog(null, "请选中后移除", "系统提示", + javax.swing.JOptionPane.WARNING_MESSAGE); + return; + } + + //List list =getChangeDetail(name); + int[] sRows = table.getSelectedRows(); + int p ; + for (int j = sRows.length-1; j >=0 ; j--) { + model.removeRow(table.getSelectedRow()); + for (int i = sRows[j]; i < table.getRowCount(); i++) { + model.setValueAt(Integer.toString(i + 1), i, 0); + } + rows1--; + + } + + + } + }); + + + + + +// for(int r = 0 ;r0) { + System.out.println(model.getValueAt(v, 1).toString()); + hadList.add((String) model.getValueAt(v, 1).toString()); + }else { + System.out.println("该单元格值为空"); + } + } + + if(hadList.size()>0) { + for(int li= 0 ;li map = new HashMap(); + + public void setComboCell(int r, int c, TableCellEditor ce) { + this.myRow = r; + this.myCol = c; + this.myEditor = ce; + map.put(new Point(r, c), ce); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + System.out.println(row + "," + column + ";" + myRow + "," + myCol + "," + myEditor); + + Point point = new Point(row, column); + if (map.containsKey(point)) { + return map.get(point); + } else { + return super.getCellEditor(row, column); + } + } + } + + + + + + + + + + + + + + + + + /** + * 通过查询构建器查询项目对象 + * + * @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/dfl/plm/forms/AddDialogQuickChange_TZ.java b/src/com/connor/dfl/plm/forms/AddDialogQuickChange_TZ.java new file mode 100644 index 0000000..4e9c799 --- /dev/null +++ b/src/com/connor/dfl/plm/forms/AddDialogQuickChange_TZ.java @@ -0,0 +1,484 @@ +/** + * + */ +package com.connor.dfl.plm.forms; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Point; +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.List; +import java.util.Map; +import java.util.Vector; + +import javax.swing.DefaultCellEditor; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.LineBorder; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +import com.connor.dfl.plm.forms.ChangeApplyForm.MyTable; +import com.connor.dfl.plm.table.CTMap; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +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.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +/** + * + * + */ +public class AddDialogQuickChange_TZ extends AbstractAIFDialog { + AbstractAIFApplication app= AIFUtility.getCurrentApplication(); + + + private TCComponentItemType itemType; + private TCSession session; + private JButton okBtn; + private JButton celBtn; + private MyTable table; + DefaultTableModel model; + private DefaultTableCellRenderer tcr; + private JComboBox project_id; + private JButton addbtn; + private JButton delbtn; + private JPanel btnPanel1; + int rows1 = 1; + private String[] tz_lists = {"物控","质保","生产","采购","服务","销售","容器"} ; + List hadList = new ArrayList(); + String proid = ""; + private QuickChangeForm qf; + + //private Project_Code code; + + public AddDialogQuickChange_TZ(QuickChangeForm qf){ + super(true); + // this.code = code; + this.qf = qf; + this.session = (TCSession) app.getSession(); + try { + initUI(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + +// private void initUI() throws TCException{ +// this.setTitle("选择图纸发至"); +// +// this.setLayout(new BorderLayout()); +// +// // JPanel boxPabel = new JPanel(); +// // boxPabel.setPreferredSize(new Dimension(300,590)); +// // +// +// +// +// model = new DefaultTableModel(null, new String[] {"序号","图纸发至"}) { +// +// public void setValueAt(Object value, int row, int col){ +// +// +// Vector rowVector = (Vector) dataVector.elementAt(row); +// rowVector.setElementAt(value, col); +// fireTableCellUpdated(row, col); +// +// } +// }; +// +// +// +// +// table = new MyTable() { +// @Override +// public boolean isCellEditable(int row, int column) { +// if(column == 1) { +// return true; +// } +// return false; +// +// } +// +// }; +// +// +// +// table.setModel(model); +// table.setColumnModel(getColumn(table, new int[] {80,200})); +// table.setRowHeight(40); +// +// +// +// +// +// +// +// +// +// addbtn = new JButton("添加"); +// delbtn = new JButton("删除"); +// +// addbtn.addActionListener(new ActionListener() { +// +// public void actionPerformed(ActionEvent e) { +// model.addRow(new String[] { Integer.toString(rows1++) }); +// table.setComboCell(rows1-2, 1, new com.connor.dfl.plm.table.MyComboBoxEditor2(tz_lists)); +// +// } +// }); +// +// +// delbtn.addActionListener(new ActionListener() { +// +// public void actionPerformed(ActionEvent e) { +// int sRow = table.getSelectedRow(); +// if(sRow == -1) { +// javax.swing.JOptionPane.showMessageDialog(null, "请选中后移除", "系统提示", +// javax.swing.JOptionPane.WARNING_MESSAGE); +// return; +// } +// +// //List list =getChangeDetail(name); +// int[] sRows = table.getSelectedRows(); +// int p ; +// for (int j = sRows.length-1; j >=0 ; j--) { +// model.removeRow(table.getSelectedRow()); +// for (int i = sRows[j]; i < table.getRowCount(); i++) { +// model.setValueAt(Integer.toString(i + 1), i, 0); +// } +// rows1--; +// +// } +// +// +// } +// }); +// +// +// +// +// +//// for(int r = 0 ;r0) { +// System.out.println(model.getValueAt(v, 1).toString()); +// hadList.add((String) model.getValueAt(v, 1).toString()); +// }else { +// System.out.println("该单元格值为空"); +// } +// } +// +// if(hadList.size()>0) { +// for(int li= 0 ;li map = new HashMap(); +// +// public void setComboCell(int r, int c, TableCellEditor ce) { +// this.myRow = r; +// this.myCol = c; +// this.myEditor = ce; +// map.put(new Point(r, c), ce); +// } +// +// @Override +// public TableCellEditor getCellEditor(int row, int column) { +// System.out.println(row + "," + column + ";" + myRow + "," + myCol + "," + myEditor); +// +// Point point = new Point(row, column); +// if (map.containsKey(point)) { +// return map.get(point); +// } else { +// return super.getCellEditor(row, column); +// } +// } +// } +// + private void initUI() throws TCException{ + this.setTitle("选择图纸发至"); + this.setLayout(new PropertyLayout()); + this.setPreferredSize(new Dimension(400, 150)); + btnPanel1 = new JPanel(); + String[] strs = session.getPreferenceService().getStringValues("DFL_to_Department"); + if (strs == null || strs.length <= 0 ) { + MessageBox.post("首选项DFL_to_Department未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + } + for (int i = 0; i < strs.length; i++) { + System.out.println("==========="+strs[i]); + JCheckBox checkBox = new JCheckBox(strs[i]); + btnPanel1.add(checkBox); + } + + okBtn=new JButton("确定"); + celBtn=new JButton("取消"); + + okBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + + List list = new ArrayList(); + Component[] jcbs = btnPanel1.getComponents();//将勾选的内容存入数组 + for(Component component : jcbs) { + JCheckBox jcb = (JCheckBox) component; + if(jcb.isSelected()) { + list.add(jcb.getText()); + } + } + + String s = (qf.table1.getValueAt(7, 5) == null ? "" :qf.table1.getValueAt(7, 5).toString()); + StringBuilder sb = new StringBuilder(s); + + for (int i = 0; i < list.size(); i++) { + if(s.contains(list.get(i))) { + continue; + } + if(!("".equals(s.trim()))) { + sb.append(";"); + } + sb.append(list.get(i)); + if(i < list.size()-1) { + sb.append(";"); + } + } + + //changeform.model1.setValueAt(proid, 8, 1); + qf.table1.setValueAt( sb.toString(), 7, 5); + disposeDialog(); + MessageBox.post("图纸发至添加完成!", "提示", MessageBox.INFORMATION); + } + }); + + celBtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + + JPanel btnPanel = new JPanel(); + btnPanel.setLayout(new PropertyLayout()); + //btnPanel.setPreferredSize(new Dimension(600, 100)); + + btnPanel.add("1.1.right.center",new JLabel(" ")); + btnPanel.add("1.2.right.center",okBtn); + btnPanel.add("1.3.right.center",new JLabel(" ")); + btnPanel.add("1.4.right.center",celBtn); + + + this.add("1.1.left.top",btnPanel1); + this.add("2.1.left.top",btnPanel); + + + this.setResizable(false); + this.setBounds(5, 5, 5, 5); + this.centerToScreen(); + this.showDialog(); + + } +} diff --git a/src/com/connor/dfl/plm/forms/AddTaskListenerChangNotify.java b/src/com/connor/dfl/plm/forms/AddTaskListenerChangNotify.java new file mode 100644 index 0000000..1ef97dd --- /dev/null +++ b/src/com/connor/dfl/plm/forms/AddTaskListenerChangNotify.java @@ -0,0 +1,23 @@ +package com.connor.dfl.plm.forms; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class AddTaskListenerChangNotify implements ActionListener{ + ChangeNotifyForm nf; + + + + public AddTaskListenerChangNotify(ChangeNotifyForm nf) { + this.nf = nf; + } + + public void actionPerformed(ActionEvent e) { + AddDialogNotify ad = new AddDialogNotify(nf); + + } + + + + +} diff --git a/src/com/connor/dfl/plm/forms/AddTaskListenerChange.java b/src/com/connor/dfl/plm/forms/AddTaskListenerChange.java new file mode 100644 index 0000000..3a7bd50 --- /dev/null +++ b/src/com/connor/dfl/plm/forms/AddTaskListenerChange.java @@ -0,0 +1,23 @@ +package com.connor.dfl.plm.forms; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class AddTaskListenerChange implements ActionListener{ + ChangeApplyForm cf; + + + + public AddTaskListenerChange(ChangeApplyForm cf) { + this.cf = cf; + } + + public void actionPerformed(ActionEvent e) { + AddDialogApply ap = new AddDialogApply(cf); + + } + + + + +} diff --git a/src/com/connor/dfl/plm/forms/AddTaskListenerChange_TZ.java b/src/com/connor/dfl/plm/forms/AddTaskListenerChange_TZ.java new file mode 100644 index 0000000..7a2b099 --- /dev/null +++ b/src/com/connor/dfl/plm/forms/AddTaskListenerChange_TZ.java @@ -0,0 +1,23 @@ +package com.connor.dfl.plm.forms; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class AddTaskListenerChange_TZ implements ActionListener{ + ChangeApplyForm cf; + + + + public AddTaskListenerChange_TZ(ChangeApplyForm cf) { + this.cf = cf; + } + + public void actionPerformed(ActionEvent e) { + AddDialogApply_TZ atz = new AddDialogApply_TZ(cf); + + } + + + + +} diff --git a/src/com/connor/dfl/plm/forms/AddTaskListenerNotify_TZ.java b/src/com/connor/dfl/plm/forms/AddTaskListenerNotify_TZ.java new file mode 100644 index 0000000..c9e1b9a --- /dev/null +++ b/src/com/connor/dfl/plm/forms/AddTaskListenerNotify_TZ.java @@ -0,0 +1,23 @@ +package com.connor.dfl.plm.forms; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class AddTaskListenerNotify_TZ implements ActionListener{ + ChangeNotifyForm nf; + + + + public AddTaskListenerNotify_TZ(ChangeNotifyForm nf) { + this.nf = nf; + } + + public void actionPerformed(ActionEvent e) { + AddDialogNotify_TZ at =new AddDialogNotify_TZ(nf); + + } + + + + +} diff --git a/src/com/connor/dfl/plm/forms/AddTaskListenerQuickChange.java b/src/com/connor/dfl/plm/forms/AddTaskListenerQuickChange.java new file mode 100644 index 0000000..cfd5f47 --- /dev/null +++ b/src/com/connor/dfl/plm/forms/AddTaskListenerQuickChange.java @@ -0,0 +1,20 @@ +package com.connor.dfl.plm.forms; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class AddTaskListenerQuickChange implements ActionListener{ + QuickChangeForm qf ; + + + public AddTaskListenerQuickChange(QuickChangeForm qf) { + this.qf = qf; + } + + public void actionPerformed(ActionEvent e) { + AddDialogQuick aq = new AddDialogQuick(qf); + + } + + +} diff --git a/src/com/connor/dfl/plm/forms/AddTaskListenerQuickChange_TZ.java b/src/com/connor/dfl/plm/forms/AddTaskListenerQuickChange_TZ.java new file mode 100644 index 0000000..5259dbd --- /dev/null +++ b/src/com/connor/dfl/plm/forms/AddTaskListenerQuickChange_TZ.java @@ -0,0 +1,23 @@ +package com.connor.dfl.plm.forms; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class AddTaskListenerQuickChange_TZ implements ActionListener{ + QuickChangeForm qf ; + + + + public AddTaskListenerQuickChange_TZ( QuickChangeForm qf ) { + this.qf = qf; + } + + public void actionPerformed(ActionEvent e) { + AddDialogQuickChange_TZ at = new AddDialogQuickChange_TZ(qf); + + } + + + + +} diff --git a/src/com/connor/dfl/plm/forms/CalendarPanel.java b/src/com/connor/dfl/plm/forms/CalendarPanel.java new file mode 100644 index 0000000..8337bfe --- /dev/null +++ b/src/com/connor/dfl/plm/forms/CalendarPanel.java @@ -0,0 +1,757 @@ +package com.connor.dfl.plm.forms; +/** + * 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.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.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; + +import org.jibx.binding.Run; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class CalendarPanel extends JDialog { + + private TCSession session; + AbstractAIFApplication app= AIFUtility.getCurrentApplication(); + 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; + + static String daatatext ; + +// private TableWithRowHead twrh; + private boolean bo; + public Date getSelecttime() { + return selecttime; +} +public void setSelecttime(Date selecttime) { + this.selecttime = selecttime; +} + + +public String getDaatatext() { + return daatatext; +} +public void setDaatatext(String daatatext) { + this.daatatext = daatatext; +} +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.session = ((TCSession) app.getSession()); + 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)); + daatatext = sdf.format(selecttime); + + insertMes(daatatext); + + + + + 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); + } + }); + */ + + } + + + + public void insertMes(String daatatext) { + Connection con = null; + PreparedStatement stmt=null; + String sql = "insert into dfl_changetime values(?)"; + try { + con = ConnectionFun(); + stmt = con.prepareStatement(sql); + + stmt.setString(1,daatatext); + + stmt.executeUpdate() ; + System.out.println("数据插入数据库完成"); + + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + + } + + + + + String[] stringArray = ((TCSession) app.getSession()).getPreferenceService().getStringValues("DFL2_SQL_Connect"); + + private String url = "jdbc:oracle:thin:@//"+stringArray[0];// + + private String user = stringArray[1];// + + private String password = stringArray[2];// + + private Connection conn = null;// + + private PreparedStatement pre = null;// + + private ResultSet result = null;// + + + + public Connection ConnectionFun() throws SQLException { + + try { + System.out.println(url); + System.out.println(user); + System.out.println(password); + Class.forName("oracle.jdbc.driver.OracleDriver"); + System.out.println("驱动加载成功"); + } catch (ClassNotFoundException e) { + System.out.println("驱动加载失败"); + } + + conn=DriverManager.getConnection(url,user,password); + + System.out.println("数据库连接成功"); + return conn; + + + } + + + + + + + + + + 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); +// } +// + +// private void run() { +// JFrame frame = new JFrame(); +// frame.setDefaultCloseOperation(EXIT_ON_CLOSE); +// CalendarPanel calendarPanel = new CalendarPanel(frame); +// 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/dfl/plm/forms/ChangeApplyForm.java b/src/com/connor/dfl/plm/forms/ChangeApplyForm.java new file mode 100644 index 0000000..3bcb060 --- /dev/null +++ b/src/com/connor/dfl/plm/forms/ChangeApplyForm.java @@ -0,0 +1,1583 @@ +package com.connor.dfl.plm.forms; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Point; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +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.List; +import java.util.Map; +import java.util.Vector; + +import javax.swing.DefaultCellEditor; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.ScrollPaneConstants; +import javax.swing.SwingConstants; +import javax.swing.border.LineBorder; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + + + +import com.connor.dfl.plm.table.CTMap; +import com.connor.dfl.plm.table.CTable; +import com.connor.dfl.plm.util.DateChooser; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +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.TCSession; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + + +public class ChangeApplyForm extends AbstractRendering { + private TCComponentForm form; + private TCSession session; + AbstractAIFApplication app= AIFUtility.getCurrentApplication(); + private InterfaceAIFComponent targetComp = app.getTargetComponent(); + private TCComponentItemType itemType; + public ChangeApplyForm selfform; + private DefaultTableCellRenderer tcr; + CTable table1; + private MyTable table2; + String pid = ""; + + + // Project_Code pc = new Project_Code(); + + public List hadList; + + //private CTMap model1, model2; + private CTMap model1; + DefaultTableModel model2; + private String name; + + private JButton addButton; + private JButton delButton; + + private JButton addProjectBtn; + + private JComboBox ChangeTypeBox;//更改类型 + private JComboBox ProductTypecBox;//产品类型 + private JComboBox ErrorTypeBox;//错误类型 + private JComboBox DutyDepartmentBox;//责任部门 + private JComboBox SalesClassifyBox;//销售分类 + private JComboBox EmergencyNotifyBox;//通知紧急程度 + private JComboBox ProductDepartmentBox;//产品部门 + private JComboBox DrawingChangeTypeBox;//图纸更改类型 + private JComboBox IsNotProductLossBox;//是否产生成本损失 + private JComboBox ReceiveClassifyBox;//料件领用分类 + private JComboBox WAPYJBox;//未制品意见 + private JComboBox ZZYJBox;//在制意见 + private JComboBox SSYJBox;//生产意见 + private JComboBox CLYJBox;//处理意见 + + + + + //时间 + public DefaultComboBoxModel jsrBoxModel; + String projectid; + + //private JComboBox projectCode;//项目编号 + static String time; + int rows1 = 1; + String applyname; + + private String clientname; + private String pd; + private String productname; + private String productmodel; + private String producttype; + private String department; + private String duty; + private String type; + private String projectState; + private Project_Code code; + + private String my_item_id; + private String applyDate; + private String projectCode; + private String affectedPart; + + + //存放table2中的数据,保存到数据库中使用 + List changedeList = new ArrayList(); + + + + + + + + + public ChangeApplyForm() throws Exception { + + } + + + + public ChangeApplyForm(TCComponent arg0) throws Exception { + super(arg0); + form = (TCComponentForm) arg0; + this.session = ((TCSession) app.getSession()); + this.selfform = this; + loadRendering(); + } + + String[] stringArray = ((TCSession) app.getSession()).getPreferenceService().getStringValues("DFL2_SQL_Connect"); + + private String url = "jdbc:oracle:thin:@//"+stringArray[0];// + + private String user = stringArray[1];// + + private String password = stringArray[2];// + + private Connection conn = null;// + + private PreparedStatement pre = null;// + + private ResultSet result = null;// + + + + public Connection ConnectionFun() throws SQLException { + + try { + System.out.println(url); + System.out.println(user); + System.out.println(password); + Class.forName("oracle.jdbc.driver.OracleDriver"); + System.out.println("驱动加载成功"); + } catch (ClassNotFoundException e) { + System.out.println("驱动加载失败"); + } + + conn=DriverManager.getConnection(url,user,password); + + System.out.println("数据库连接成功"); + return conn; + + + } + + + + @Override + public void loadRendering() throws TCException { + try { + initUI(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + private void initUI() throws TCException, SQLException { + + + this.hadList = new ArrayList(); + + String[] change_type_stringArrays = session.getPreferenceService().getStringValues("DFL_Form_ChangeType"); + if (change_type_stringArrays == null || change_type_stringArrays.length <= 0 ) { + MessageBox.post("首选项DFL_Form_ChangeType未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + } + //更改类型 + ChangeTypeBox = new JComboBox(); + for(int change_type_number = 0;change_type_number=2) { + groupname = buisnisDivisions[buisnisDivisions.length-2]; + + } + + table1.setValueAt("申请人", 0, 0); + table1.setValueAt(applyname, 0,1); + + table1.setValueAt("申请变更单号", 0, 2); + System.out.println("申请变更单号 "+my_item_id); + table1.setValueAt(my_item_id, 0, 3); + + + table1.setValueAt("申请时间", 0, 4); + table1.setValueAt(applyDate, 0, 5); + table1.setValueAt("产品名称", 1, 0); + table1.setValueAt(productname, 1, 1); + + + table1.setValueAt("产品型号", 1, 2); + table1.setValueAt(productmodel, 1, 3); + + + + table1.setValueAt("客户名称", 1, 4); + + table1.setValueAt(clientname, 1, 5); + + + table1.setValueAt("仓库编号", 2, 0);// + + + String[] stringArray_warehouse = ((TCSession) app.getSession()).getPreferenceService().getStringValues("DFL_Form_WarehouseCode"); + + + if (stringArray_warehouse == null || stringArray_warehouse.length <= 0 ) { + MessageBox.post("首选项DFL_Form_WarehouseCode未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + } + + + String warehouse = ""; + + + for(int z = 0 ;z 0) { + List list = new ArrayList(); + for (int i = 0; i < allRev.length; i++) { + // 下拉框-版本:item_revision_id + list.add(allRev[i].getProperty("item_revision_id")); + } + String[] rev = new String[list.size()]; + // list去除重复数据 + for (int i = 0; i < list.size() - 1; i++) { + for (int j = list.size() - 1; j > i; j--) { + if (list.get(j).equals(list.get(i))) { + list.remove(j); + } + } + } + for (int i = 0; i < list.size(); i++) { + // System.out.println("===" + list.get(i)); + rev[i] = list.get(i); + System.out.println("版本===" + rev[i]); + } + + table2.setValueAt(objectname, table2.getSelectedRow(), 2); + table2.setComboCell(table2.getSelectedRow(), 3, new com.connor.dfl.plm.table.MyComboBoxEditor2(rev)); + table2.setComboCell(table2.getSelectedRow(), 4, new com.connor.dfl.plm.table.MyComboBoxEditor2(rev)); + table2.setComboCell(table2.getSelectedRow(), 9, new DefaultCellEditor(WAPYJBox)); + table2.setComboCell(table2.getSelectedRow(), 11, new DefaultCellEditor(ZZYJBox)); + table2.setComboCell(table2.getSelectedRow(), 13, new DefaultCellEditor(SSYJBox)); + table2.setComboCell(table2.getSelectedRow(), 15, new DefaultCellEditor(CLYJBox)); + + } else { + javax.swing.JOptionPane.showMessageDialog(null, "输入品号有误或该品写没有版本", "系统提示", + javax.swing.JOptionPane.WARNING_MESSAGE); + + setValueAt("", table2.getSelectedRow(), 2); + setValueAt("", table2.getSelectedRow(), 3); + } + } + } catch (Exception e) { + System.out.println("eeee="+e.getMessage()); + e.printStackTrace(); + } + Vector rowVector = (Vector) dataVector.elementAt(row); + rowVector.setElementAt(value, col); + fireTableCellUpdated(row, col); + + } + }; + + + + + table2 = new MyTable() { + @Override + public boolean isCellEditable(int row, int column) { + if(column == 0) { + return false; + } + return true; + } + + }; + + + + table2.setModel(model2); +// table2.setColumnModel(getColumn(table2, new int[] { 40, 90, 60, 50,50,50,50, 70, 75,75,70,70, 60, 70,60,70 })); + table2.setColumnModel(getColumn(table2, new int[] { 90, 180, 180, 180,180,180,180, 180, 180,180,180,180, 180, 180,180,180 })); +// table2.setColumnModel(getColumn(table2, new int[] { 90, 90, 90, 90,90,90,90, 90, 90,90,90,90, 90, 90,90,90 })); + table2.setRowHeight(35); + + + + + + tcr = new DefaultTableCellRenderer(); + tcr.setHorizontalAlignment(SwingConstants.CENTER); + table1.setBorder(new LineBorder(Color.BLACK)); + table1.setDefaultRenderer(Object.class, tcr); + + table2.setBorder(new LineBorder(Color.BLACK)); + table2.setDefaultRenderer(Object.class, tcr); + table2.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + + + addButton = new JButton("添加"); + delButton = new JButton("删除"); + + List listdetils = getChangeDetail(name); + if(listdetils.size()>0) { + + for(int j = 0;j< listdetils.size();j++) { + + model2.addRow(new String[] { Integer.toString(rows1++) }); + + + ChangeDetils cd = (ChangeDetils) listdetils.get(j); + System.out.println("%%%%%%%%%%%%%"+cd.getPH()); + + System.out.println(cd.getObjectCode()); + int count = table2.getRowCount(); + System.out.println("==============="+count); + + table2.setValueAt( cd.getPH(),j, 1); + table2.setValueAt(cd.getPM(), j, 2); + table2.setValueAt(cd.getYBB(), j, 3); + table2.setValueAt(cd.getXBB(), j, 4); + table2.setValueAt(cd.getYSL() , j, 5); + table2.setValueAt(cd.getXSL(), j, 6); + table2.setValueAt(cd.getBGSL(), j, 7); + table2.setValueAt(cd.getWZPSL(), j, 8); + table2.setValueAt(cd.getWZPUJ(), j, 9); + table2.setValueAt(cd.getZZSL(), j, 10); + table2.setValueAt(cd.getZZYJ(), j, 11); + table2.setValueAt(cd.getSCSL(), j, 12); + table2.setValueAt(cd.getSSYJ(), j, 13); + table2.setValueAt(cd.getCKSL(), j, 14); + table2.setValueAt(cd.getCLYJ() , j, 15); + + } + } + + + + addButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + model2.addRow(new String[] { Integer.toString(rows1++) }); +// Object[] rowData = new Object[] {"","","","","","","","","",WAPYJBox,"",ZZYJBox,"","","",""}; +// model2.addRow(rowData); + } + }); + + delButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + int sRow = table2.getSelectedRow(); + if(sRow == -1) { + javax.swing.JOptionPane.showMessageDialog(null, "请选中后移除", "系统提示", + javax.swing.JOptionPane.WARNING_MESSAGE); + return; + } + + //List list =getChangeDetail(name); + int[] sRows = table2.getSelectedRows(); + int p ; + for (int j = sRows.length-1; j >=0 ; j--) { + String PH = (String) model2.getValueAt(sRows[j], 1); + System.out.println("=============品号"+PH); + delChangedetil(name, PH); + model2.removeRow(table2.getSelectedRow()); + for (int i = sRows[j]; i < table2.getRowCount(); i++) { + model2.setValueAt(Integer.toString(i + 1), i, 0); + } + rows1--; + + } + } + }); + + JPanel tablePanel1 = new JPanel(); + tablePanel1.add(table1); + tablePanel1.setPreferredSize(new Dimension(1600, 700)); + JScrollPane tablePanel2 = new JScrollPane(table2); + tablePanel2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + tablePanel2.setPreferredSize(new Dimension(1600, 300)); + + JPanel buttonPanel = new JPanel(new PropertyLayout()); + buttonPanel.add("1.1.left.top",addButton); + buttonPanel.add("2.1.left.top",delButton); + JPanel buttonPanel0 = new JPanel(new PropertyLayout()); + buttonPanel0.add("1.1.left.top",new JLabel(" ")); + buttonPanel0.add("2.1.left.top",new JLabel(" ")); + buttonPanel0.add("3.1.left.top",new JLabel(" ")); + buttonPanel0.add("4.1.left.top",new JLabel(" ")); + buttonPanel0.add("5.1.left.top",new JLabel(" ")); + buttonPanel0.add("6.1.left.top",new JLabel(" ")); + buttonPanel0.add("7.1.left.top",new JLabel(" ")); + buttonPanel0.add("8.1.left.top",new JLabel(" ")); + buttonPanel0.add("9.1.left.top",new JLabel(" ")); + buttonPanel0.add("10.1.left.top",new JLabel(" ")); + buttonPanel0.add("11.1.left.top",new JLabel(" ")); + buttonPanel0.add("12.1.left.top",new JLabel(" ")); + buttonPanel0.add("13.1.left.top",new JLabel(" ")); + buttonPanel0.add("14.1.left.top",new JLabel(" ")); + buttonPanel0.add("15.1.left.top",new JLabel(" ")); + buttonPanel0.add("16.1.left.top",btn_tzfz); + buttonPanel0.add("17.1.left.top",new JLabel(" ")); + buttonPanel0.add("18.1.left.top",new JLabel(" ")); + buttonPanel0.add("19.1.left.top",new JLabel(" ")); + // buttonPanel0.add("20.1.left.top",btn); + buttonPanel0.add("20.1.left.top",new JLabel(" ")); + buttonPanel0.add("21.1.left.top",new JLabel(" ")); + buttonPanel0.add("22.1.left.top",zt_btn); + buttonPanel0.add("23.1.left.top",new JLabel(" ")); + buttonPanel0.add("24.1.left.top",new JLabel(" ")); + buttonPanel0.add("25.1.left.top",new JLabel(" ")); + + + JPanel rootPanel = new JPanel(new PropertyLayout()); + + JLabel detailsLable = new JLabel("更改明细"); + detailsLable.setFont(new Font("宋体", 1, 14)); + + + rootPanel.add("1.1.center.top",titleLable); + rootPanel.add("2.1.left.top",tablePanel1); + rootPanel.add("2.2.left.top",buttonPanel0); + + + //rootPanel.add("2.2.left.top",showCalendarPanel); + + + rootPanel.add("3.1.left.top",detailsLable); + + rootPanel.add("4.1.left.top",tablePanel2); + rootPanel.add("4.2.left.top",buttonPanel); + + //this.setPreferredSize(new Dimension(1820, 1000)); + this.setSize(1600, 1300); + + this.setLayout(new BorderLayout()); + JScrollPane scrollPane = new JScrollPane(rootPanel); + scrollPane.getVerticalScrollBar().setUnitIncrement(20); + this.add(scrollPane,BorderLayout.CENTER); + this.setBackground(Color.WHITE); + this.setVisible(true); + + } + + @Override + public void saveRendering() { + delChangeForm(name); + ChangeOrderBean bn = new ChangeOrderBean(); + bn.setObjectCode(name); + bn.setApplyName(model1.getValueAt(0, 1) == null ? "" :model1.getValueAt(0, 1).toString()); + bn.setApplyDate(model1.getValueAt(0, 5) == null ? "" :model1.getValueAt(0, 5).toString()); + bn.setProjectCode(model1.getValueAt(8, 1) == null ? "" :model1.getValueAt(8, 1).toString()); + bn.setClientNae(model1.getValueAt(1, 5) == null ? "" :model1.getValueAt(1, 5).toString()); + bn.setProductDepartment(model1.getValueAt(3, 1) == null ? "" :model1.getValueAt(3, 1).toString()); + bn.setProductName(model1.getValueAt(1, 1) == null ? "" :model1.getValueAt(1, 1).toString()); + bn.setProjectModel(model1.getValueAt(1, 3) == null ? "" :model1.getValueAt(1, 3).toString()); + //受影响的设备 + bn.setAffectedPart(model1.getValueAt(6, 1) == null ? "" :model1.getValueAt(6, 1).toString()); + + bn.setChangeType(model1.getValueAt(4, 1) == null ? "" :model1.getValueAt(4, 1).toString()); + bn.setProductType(model1.getValueAt(4, 3) == null ? "" :model1.getValueAt(4, 3).toString()); + bn.setErrorType(model1.getValueAt(4, 5) == null ? "" :model1.getValueAt(4, 5).toString()); + bn.setDutyDepartment(model1.getValueAt(3, 3) == null ? "" :model1.getValueAt(3, 3).toString()); + bn.setDutyMan(model1.getValueAt(3, 5) == null ? "" :model1.getValueAt(3, 5).toString()); + //更改原因 + bn.setChangeReason(model1.getValueAt(9, 1) == null ? "" :model1.getValueAt(9, 1).toString()); + + bn.setSalseClassify(model1.getValueAt(5, 3) == null ? "" :model1.getValueAt(5, 3).toString()); + + bn.setPriceBooking(model1.getValueAt(5, 1) == null ? "" :model1.getValueAt(5, 1).toString()); + + bn.setIsNotProductLoss(model1.getValueAt(5, 5) == null ? "" :model1.getValueAt(5, 5).toString()); + bn.setReceiveClassify(model1.getValueAt(7, 3) == null ? "" :model1.getValueAt(7, 3).toString()); + bn.setWarehouseCode(model1.getValueAt(2, 1) == null ? "" :model1.getValueAt(2, 1).toString()); + //通知紧急程度 + bn.setNotifyEmergencyProcedures(model1.getValueAt(2, 3) == null ? "" :model1.getValueAt(2, 3).toString()); + + bn.setDrawingTo(model1.getValueAt(7, 5) == null ? "" :model1.getValueAt(7, 5).toString()); + + bn.setChangeListCode(model1.getValueAt(0, 3) == null ? "" :model1.getValueAt(0, 3).toString()); + bn.setTZChangeType(model1.getValueAt(2, 5) == null ? "" :model1.getValueAt(2, 5).toString()); + bn.setSUOSU_ProductDepartment(" "); + //model1.getValueAt(6, 1) == null ? "" :model1.getValueAt(6, 1).toString() + //公司账套 + bn.setAccountSet(model1.getValueAt(10, 1) == null ? "" :model1.getValueAt(10, 1).toString()); + + bn.setProjectState(model1.getValueAt(7, 1) == null ? "" :model1.getValueAt(7, 1).toString()); + insertMes(bn); + + + + + + //=================================================================== + + + + delAllChangedetil(name); + for(int cdss = 0 ; cdss 0) { + ChangeOrderBean bn = (ChangeOrderBean) list.get(list.size()-1); + + System.out.println(bn.getApplyName()); + table1.setValueAt(bn.getApplyName(),0, 1); + table1.setValueAt(bn.getApplyDate(),0, 5); + table1.setValueAt(bn.getProjectCode(),8, 1); + table1.setValueAt(bn.getClientNae(),1, 5); + table1.setValueAt(bn.getProductDepartment(),3, 1); + table1.setValueAt(bn.getProductName(),1, 1); + table1.setValueAt(bn.getProjectModel(),1, 3); + //受影响的零部件 + table1.setValueAt(bn.getAffectedPart(),6, 1); + + table1.setValueAt(bn.getChangeType(),4, 1); + table1.setValueAt(bn.getProductType(),4, 3); + table1.setValueAt(bn.getErrorType(),4, 5); + table1.setValueAt(bn.getDutyDepartment(),3, 3); + table1.setValueAt(bn.getDutyMan(),3, 5); + table1.setValueAt(bn.getChangeReason(),9, 1); + table1.setValueAt(bn.getSalseClassify(),5, 3); + table1.setValueAt(bn.getPriceBooking(),5, 1); + table1.setValueAt(bn.getIsNotProductLoss(),5, 5); + table1.setValueAt(bn.getReceiveClassify(),7, 3); + table1.setValueAt(bn.getWarehouseCode(),2, 1); + + //账套 + table1.setValueAt(bn.getAccountSet(),10, 1); + //通知紧急程度 + table1.setValueAt(bn.getNotifyEmergencyProcedures(),2, 3); + + table1.setValueAt(bn.getDrawingTo(),7, 5); + + table1.setValueAt(bn.getChangeListCode(),0, 3); + table1.setValueAt(bn.getTZChangeType(),2, 5); + // table1.setValueAt(bn.getSUOSU_ProductDepartment(),6, 1); + table1.setValueAt(bn.getProjectState(),7, 1); + + + //table2 添加行加入数 + } + + + // List listsss = getChangeDetail(name); + // System.out.println(listsss.size()); + // if(listsss.size()>0) { + // // + // } + // } + + + + + + } + + + //保存时提交到数据库 + public void insertMes(ChangeOrderBean bn) { + Connection con = null; + PreparedStatement stmt=null; + String sql = "insert into DFL_CHANGEFORM values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + try { + con = ConnectionFun(); + stmt = con.prepareStatement(sql); + + stmt.setString(1,bn.getObjectCode()); + stmt.setString(2,bn.getApplyName()); + stmt.setString(3,bn.getApplyDate()); + stmt.setString(4,bn.getProjectCode()); + stmt.setString(5,bn.getClientNae()); + stmt.setString(6,bn.getProductDepartment()); + stmt.setString(7,bn.getProductName()); + + stmt.setString(8,bn.getProjectModel()); + stmt.setString(9,bn.getAffectedPart()); + stmt.setString(10,bn.getChangeType()); + stmt.setString(11,bn.getProductType()); + + + stmt.setString(12,bn.getErrorType()); + stmt.setString(13,bn.getDutyDepartment()); + stmt.setString(14,bn.getDutyMan()); + + stmt.setString(15,bn.getChangeReason()); + + stmt.setString(16,bn.getSalseClassify()); + + stmt.setString(17,bn.getPriceBooking()); + + stmt.setString(18,bn.getIsNotProductLoss()); + stmt.setString(19,bn.getReceiveClassify()); + stmt.setString(20,bn.getWarehouseCode()); + stmt.setString(21,bn.getAccountSet()); + + stmt.setString(22,bn.getNotifyEmergencyProcedures()); + stmt.setString(23,bn.getDrawingTo()); + stmt.setString(24,bn.getChangeListCode()); + + stmt.setString(25,bn.getTZChangeType()); + stmt.setString(26,bn.getSUOSU_ProductDepartment()); + stmt.setString(27,bn.getProjectState()); + stmt.executeUpdate() ; + System.out.println("数据插入数据库完成"); + + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + + } + + + + + + /** + * 插入更改明细 + */ + + + + public void insertChangeDetailsMes(ChangeDetils cd) { + Connection con = null; + PreparedStatement stmt=null; + String sql = "insert into DFL_CHANGEDETAILS values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + try { + con = ConnectionFun(); + stmt = con.prepareStatement(sql); + stmt.setString(1,cd.getObjectCode()); + stmt.setString(2,cd.getPH()); + stmt.setString(3,cd.getPM()); + stmt.setString(4,cd.getYBB()); + stmt.setString(5,cd.getXBB()); + stmt.setString(6,cd.getYSL()); + stmt.setString(7,cd.getXSL()); + stmt.setString(8,cd.getBGSL()); + stmt.setString(9,cd.getWZPSL()); + stmt.setString(10,cd.getWZPUJ()); + stmt.setString(11,cd.getZZSL()); + stmt.setString(12,cd.getZZYJ()); + stmt.setString(13,cd.getSCSL()); + stmt.setString(14,cd.getSSYJ()); + stmt.setString(15,cd.getCKSL()); + stmt.setString(16,cd.getCLYJ()); + stmt.executeUpdate() ; + System.out.println("数据插入数据库完成"); + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + } + + //删除时间 + public void del_date() { + Connection con = null; + String sql = "delete from dfl_changetime"; + System.out.println(sql); + try { + con = ConnectionFun(); + PreparedStatement prepStmt = conn.prepareStatement(sql); + prepStmt.executeUpdate(); + System.out.println("数据库删除成功"); + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + + + + + public void delChangeForm(String id) { + Connection con = null; + String sql = "delete from dfl_changeform where objectCode=?"; + System.out.println(sql); + try { + con = ConnectionFun(); + PreparedStatement prepStmt = conn.prepareStatement(sql); + prepStmt.setString(1,id); + prepStmt.executeUpdate(); + System.out.println("数据库删除成功"); + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + + + + + + + + public void delChangedetil(String id ,String ph) { + Connection con = null; + String sql = "delete from DFL_CHANGEDETAILS where objectCode=? and PH = ?"; + System.out.println(sql); + try { + con = ConnectionFun(); + + PreparedStatement prepStmt = conn.prepareStatement(sql); + prepStmt.setString(1,id); + prepStmt.setString(2,ph); + prepStmt.executeUpdate(); + + // Statement stmt=conn.createStatement();//创建Statement对象 + // stmt.executeUpdate(sql);//执行sql语句 + System.out.println("数据库删除成功"); + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + + + } + + + } + + + + public void delAllChangedetil(String id ) { + Connection con = null; + String sql = "delete from DFL_CHANGEDETAILS where objectCode=?"; + System.out.println(sql); + try { + con = ConnectionFun(); + + PreparedStatement prepStmt = conn.prepareStatement(sql); + prepStmt.setString(1,id); + + prepStmt.executeUpdate(); + + // Statement stmt=conn.createStatement();//创建Statement对象 + // stmt.executeUpdate(sql);//执行sql语句 + System.out.println("数据库删除成功"); + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + + + } + + + } + + + + + + //查找数据库中是都有该对象 + + public int ifcountform(String id) { + int i = 0; + Connection con = null; + PreparedStatement stmt=null; + String sql = "select * from DFL_CHANGEFORM where objectCode=?"; + try { + con = ConnectionFun(); + stmt = con.prepareStatement(sql); + ResultSet rs=null; + stmt.setString(1,id); + rs=stmt.executeQuery(); + while(rs.next()) { + i=i+1; + + } + + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + return i; + } + //统计数量 + public int ifcountdetial(String id) { + int i = 0; + Connection con = null; + PreparedStatement stmt=null; + String sql = "select * from DFL_CHANGEDETAILS where objectCode=?"; + try { + con = ConnectionFun(); + stmt = con.prepareStatement(sql); + ResultSet rs=null; + stmt.setString(1,id); + rs=stmt.executeQuery(); + while(rs.next()) { + i=i+1; + + } + + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + return i; + } + + + + + + /** + * JTable设置列宽 + */ + public static TableColumnModel getColumn(JTable table, int[] width) { + TableColumnModel columns = table.getColumnModel(); + for (int i = 0; i < width.length; i++) { + TableColumn column = columns.getColumn(i); + column.setPreferredWidth(width[i]); + } + return columns; + } + + + + + class MyButtonEditor extends DefaultCellEditor { + protected DateButton button; + + public MyButtonEditor(JCheckBox checkBox) { + super(checkBox); + button = new DateButton(); + } + + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, + int column) { + if (isSelected) { + button.setForeground(table.getSelectionForeground()); + button.setBackground(table.getSelectionBackground()); + } else { + button.setForeground(table.getForeground()); + button.setBackground(table.getBackground()); + } + return button; + } + } + + + + class MyTable extends JTable { + int myRow = -1, myCol = -1; + TableCellEditor myEditor; + Map map = new HashMap(); + + public void setComboCell(int r, int c, TableCellEditor ce) { + this.myRow = r; + this.myCol = c; + this.myEditor = ce; + map.put(new Point(r, c), ce); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + System.out.println(row + "," + column + ";" + myRow + "," + myCol + "," + myEditor); + + Point point = new Point(row, column); + if (map.containsKey(point)) { + return map.get(point); + } else { + return super.getCellEditor(row, column); + } + } + } + + /** + * 通过查询构建器查询项目对象 + * + * @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/dfl/plm/forms/ChangeDetils.java b/src/com/connor/dfl/plm/forms/ChangeDetils.java new file mode 100644 index 0000000..300cdc5 --- /dev/null +++ b/src/com/connor/dfl/plm/forms/ChangeDetils.java @@ -0,0 +1,163 @@ +package com.connor.dfl.plm.forms; + +/** + * + * @author 孙毅 + * 更改明细 + */ +public class ChangeDetils { + private String objectCode; + private String PH; + private String PM; + private String YBB; + private String XBB; + private String YSL; + private String XSL; + private String BGSL; + private String WZPSL; + private String WZPUJ; + private String ZZSL; + private String ZZYJ; + private String SCSL; + private String SSYJ; + private String CKSL; + private String CLYJ; + + + + + + public ChangeDetils() { + } + + public ChangeDetils(String objtctCode,String pH, String pM, String yBB, String xBB, String ySL, String xSL, String bGSL, String wZPSL, + String wZPUJ, String zZSL, String zZYJ, String sCSL, String sSYJ, String cKSL, String cLYJ) { + this.objectCode= objtctCode; + this.PH = pH; + this.PM = pM; + this.YBB = yBB; + this.XBB = xBB; + this.YSL = ySL; + this.XSL = xSL; + this.BGSL = bGSL; + this.WZPSL = wZPSL; + this.WZPUJ = wZPUJ; + this.ZZSL = zZSL; + this.ZZYJ = zZYJ; + this.SCSL = sCSL; + this.SSYJ = sSYJ; + this.CKSL = cKSL; + this.CLYJ = cLYJ; + } + public String getObjectCode() { + return objectCode; + } + + public void setObjectCode(String objectCode) { + this.objectCode = objectCode; + } + + public String getPH() { + return PH; + } + public void setPH(String pH) { + PH = pH; + } + public String getPM() { + return PM; + } + public void setPM(String pM) { + PM = pM; + } + public String getYBB() { + return YBB; + } + public void setYBB(String yBB) { + YBB = yBB; + } + public String getXBB() { + return XBB; + } + public void setXBB(String xBB) { + XBB = xBB; + } + public String getYSL() { + return YSL; + } + public void setYSL(String ySL) { + YSL = ySL; + } + public String getXSL() { + return XSL; + } + public void setXSL(String xSL) { + XSL = xSL; + } + public String getBGSL() { + return BGSL; + } + public void setBGSL(String bGSL) { + BGSL = bGSL; + } + public String getWZPSL() { + return WZPSL; + } + public void setWZPSL(String wZPSL) { + WZPSL = wZPSL; + } + public String getWZPUJ() { + return WZPUJ; + } + public void setWZPUJ(String wZPUJ) { + WZPUJ = wZPUJ; + } + public String getZZSL() { + return ZZSL; + } + public void setZZSL(String zZSL) { + ZZSL = zZSL; + } + public String getZZYJ() { + return ZZYJ; + } + public void setZZYJ(String zZYJ) { + ZZYJ = zZYJ; + } + public String getSCSL() { + return SCSL; + } + public void setSCSL(String sCSL) { + SCSL = sCSL; + } + public String getSSYJ() { + return SSYJ; + } + public void setSSYJ(String sSYJ) { + SSYJ = sSYJ; + } + public String getCKSL() { + return CKSL; + } + public void setCKSL(String cKSL) { + CKSL = cKSL; + } + public String getCLYJ() { + return CLYJ; + } + public void setCLYJ(String cLYJ) { + CLYJ = cLYJ; + } + + + + + + + + + + + + + +} diff --git a/src/com/connor/dfl/plm/forms/ChangeNotifyForm.java b/src/com/connor/dfl/plm/forms/ChangeNotifyForm.java new file mode 100644 index 0000000..49b7748 --- /dev/null +++ b/src/com/connor/dfl/plm/forms/ChangeNotifyForm.java @@ -0,0 +1,1809 @@ +package com.connor.dfl.plm.forms; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Point; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +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.sql.Statement; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.EventObject; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Vector; + +import javax.swing.DefaultCellEditor; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.ScrollPaneConstants; +import javax.swing.SwingConstants; +import javax.swing.border.LineBorder; +import javax.swing.event.CellEditorListener; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + + + +import com.connor.dfl.plm.table.CTMap; +import com.connor.dfl.plm.table.CTable; +import com.connor.dfl.plm.util.DateChooser; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +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.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + + +public class ChangeNotifyForm extends AbstractRendering { + private TCComponentForm form; + private TCSession session; + AbstractAIFApplication app= AIFUtility.getCurrentApplication(); + private InterfaceAIFComponent targetComp = app.getTargetComponent(); + private TCComponentItemType itemType; + private ChangeNotifyForm selfform; + private DefaultTableCellRenderer tcr; + CTable table1; + private MyTable table2; + + //private CTMap model1, model2; + private CTMap model1; + DefaultTableModel model2; + + private String name; + private String masterName; + + private JButton addButton; + private JButton delButton; + + private JComboBox ChangeTypeBox;//更改类型 + private JComboBox ProductTypecBox;//产品类型 + private JComboBox ErrorTypeBox; + private JComboBox DutyDepartmentBox; + private JComboBox SalesClassifyBox;//销售分类 + private JComboBox EmergencyNotifyBox;//通知紧急程度 + private JComboBox ProductDepartmentBox;//产品部门 + private JComboBox DrawingChangeTypeBox;//图纸更改类型 + private JComboBox IsNotProductLossBox;//是否产生成本损失 + private JComboBox ReceiveClassifyBox;//料件领用分类 + private JComboBox WAPYJBox;//未制品意见 + private JComboBox ZZYJBox;//在制意见 + private JComboBox SSYJBox;//生产意见 + private JComboBox CLYJBox;//处理意见 + + //时间 + + public DefaultComboBoxModel jsrBoxModel; + + + + + //private JComboBox projectCode;//项目编号 + static String time; + int rows1 = 1; + private String applyname; + + private String my_item_id; + + + + + //存放table2中的数据,保存到数据库中使用 + List changedeList = new ArrayList(); + + + + + private String applyName ;//申请人 + private String applyDate;//申请时间 + private String projectCode ;//项目编号 + private String clientNae ;//客户名称 + private String productDepartment ;//所属产品部 + // private String productCode;//产品编号 + private String productName ;//产品名称 + private String projectModel ;//产品型号 + private String affectedPart ;//受影响的设备/零部件 + private String changeType ;//更改类型 + private String productType ;//产品类型 + private String errorType;//错误类型 + private String dutyDepartment ;//责任部门 + private String dutyMan ;//责任人 + private String changeReason;//更改原因 + private String salseClassify ;//销售分类 + private String priceBooking ;//价格预售 + // private String change;//更改明细 + private String isNotProductLoss ;//是否产生产品损失 + private String receiveClassify ;//料件领用分类 + private String warehouseCode ;//厂库编号 + private String accountSet ;//账套 + private String NotifyEmergencyProcedures;//通知紧急程序 + private String drawingTo ;//图纸发至 + private String ChangeListCode;//变更单号 + private String TZChangeType ; + private String SUOSU_productdepartment ; + private String projectState ; + + + + + + public ChangeNotifyForm(TCComponent arg0) throws Exception { + super(arg0); + form = (TCComponentForm) arg0; + this.session = ((TCSession) app.getSession()); + this.selfform = this; + loadRendering(); + } + + String[] stringArray = ((TCSession) app.getSession()).getPreferenceService().getStringValues("DFL2_SQL_Connect"); + + private String url = "jdbc:oracle:thin:@//"+stringArray[0];// + + private String user = stringArray[1];// + + private String password = stringArray[2];// + + private Connection conn = null;// + + private PreparedStatement pre = null;// + + private ResultSet result = null;// + + + + public Connection ConnectionFun() throws SQLException { + + try { + System.out.println(url); + System.out.println(user); + System.out.println(password); + Class.forName("oracle.jdbc.driver.OracleDriver"); + System.out.println("驱动加载成功"); + } catch (ClassNotFoundException e) { + System.out.println("驱动加载失败"); + } + + conn=DriverManager.getConnection(url,user,password); + + System.out.println("数据库连接成功"); + return conn; + + + } + + + + @Override + public void loadRendering() throws TCException { + try { + initUI(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + private void initUI() throws TCException, SQLException { + + // private JComboBox ChangeTypeBox; + // private JComboBox ProductTypecBox; + // private JComboBox ErrorTypeBox; + // private JComboBox DutyDepartmentBox; + // private JComboBox SalesClassifyBox; + // private JCheckBox EmergencyNotifyBox; + // public DefaultComboBoxModel jsrBoxModel; + + + + //更改类型 + String[] change_type_stringArrays = session.getPreferenceService().getStringValues("DFL_Form_ChangeType"); + if (change_type_stringArrays == null || change_type_stringArrays.length <= 0 ) { + MessageBox.post("首选项DFL_Form_ChangeType未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + } + //更改类型 + ChangeTypeBox = new JComboBox(); + for(int change_type_number = 0;change_type_number0) { + ChangeOrderBean cb = (ChangeOrderBean) applyformlist.get(applyformlist.size()-1); + + applyName = cb.getApplyName();//申请人 + //applyDate = cb.getApplyDate();//申请时间 + projectCode = cb.getProjectCode();//项目编号 + clientNae = cb.getClientNae() ;//客户名称 + productDepartment = cb.getProductDepartment();//所属产品部 + // String productCode;//产品编号 + productName = cb.getProductName();//产品名称 + projectModel = cb.getProjectModel();//产品型号 + affectedPart = cb.getAffectedPart();//受影响的设备/零部件 + changeType = cb.getChangeType();//更改类型 + productType = cb.getProductType();//产品类型 + errorType = cb.getErrorType();//错误类型 + dutyDepartment = cb.getDutyDepartment();//责任部门 + dutyMan = cb.getDutyMan();//责任人 + changeReason = cb.getChangeReason();//更改原因 + salseClassify = cb.getSalseClassify();//销售分类 + priceBooking = cb.getPriceBooking();//价格预售 + // change;//更改明细 + isNotProductLoss = cb.getIsNotProductLoss();//是否产生产品损失 + receiveClassify = cb.getReceiveClassify();//料件领用分类 + warehouseCode = cb.getWarehouseCode();//厂库编号 + accountSet = cb.getAccountSet();//账套 + NotifyEmergencyProcedures = cb.getNotifyEmergencyProcedures();//通知紧急程序 + drawingTo = cb.getDrawingTo();//图纸发至 + ChangeListCode = cb.getChangeListCode();//变更单号 + TZChangeType = cb.getTZChangeType(); + SUOSU_productdepartment = cb.getSUOSU_ProductDepartment(); + projectState = cb.getProjectState(); + + } + } + } + + //lcomp + + + + + + + + + + + String titleName =masterName+"变更通知单" ; + JLabel titleLable = new JLabel(titleName); + titleLable.setFont(new Font("宋体", 1, 16)); + + + model1 = new CTMap(11, 6) { + + public void setValueAt(Object value, int row, int column) { + if(row ==0 && column ==1) { + if(value == null) { + return; + } + + } + Vector rowVector = (Vector) dataVector.elementAt(row); + rowVector.setElementAt(value, column); + fireTableCellUpdated(row, column); + + } + + }; + + model1.combine(new int[]{8}, new int[] {1,2,3,4,5}); + model1.combine(new int[]{9}, new int[] {1,2,3,4,5}); + model1.combine(new int[]{10}, new int[] {1,2,3,4,5}); + model1.combine(new int[]{6}, new int[] {1,2,3,4,5}); + + table1 = new CTable(model1) { + @Override + public boolean isCellEditable(int row, int column) { + if(column == 0&&row<8 || column ==2&&row<8 || column==4&&row<8 ) { + return false; + } + if(column == 0 && row ==6) { + return false; + + } + if(column == 0 && row ==8) { + return false; + + } + if(column == 0 && row ==9) { + return false; + + } + + if(column == 0 && row ==10) { + + return false; + + } + return true; + + } + }; + + // table1.setCombo(2, 1, new DefaultCellEditor(cBox3)); + + + + String groupnames = session.getGroup().getStringProperty("display_name"); + String [] buisnisDivisions= groupnames.split("\\."); + String groupname =""; + + if(buisnisDivisions.length>=2) { + groupname = buisnisDivisions[buisnisDivisions.length-2]; + + } + + + + table1.setValueAt("申请人", 0, 0); + table1.setValueAt(applyname, 0,1); + + + table1.setValueAt("变更通知单号", 0, 2); + table1.setValueAt(my_item_id, 0, 3); + + table1.setValueAt("申请时间", 0, 4); + + + + table1.setValueAt("产品名称", 1, 0); + table1.setValueAt(productName, 1, 1); + + + table1.setValueAt("产品型号", 1, 2); + table1.setValueAt(projectModel, 1, 3); + + + + table1.setValueAt("客户名称", 1, 4); + table1.setValueAt(clientNae, 1, 5); + + + table1.setValueAt("仓库编号", 2, 0);// + + + + String[] stringArray_warehouse = ((TCSession) app.getSession()).getPreferenceService().getStringValues("DFL_Form_WarehouseCode"); + String warehouse = ""; + for(int z = 0 ;z 0) { + List list = new ArrayList(); + for (int i = 0; i < allRev.length; i++) { + // 下拉框-版本:item_revision_id + list.add(allRev[i].getProperty("item_revision_id")); + } + String[] rev = new String[list.size()]; + // list去除重复数据 + for (int i = 0; i < list.size() - 1; i++) { + for (int j = list.size() - 1; j > i; j--) { + if (list.get(j).equals(list.get(i))) { + list.remove(j); + } + } + } + for (int i = 0; i < list.size(); i++) { + // System.out.println("===" + list.get(i)); + rev[i] = list.get(i); + System.out.println("版本===" + rev[i]); + } + table2.setValueAt(objectname, table2.getSelectedRow(), 2); + table2.setComboCell(table2.getSelectedRow(), 3, new com.connor.dfl.plm.table.MyComboBoxEditor2(rev)); + table2.setComboCell(table2.getSelectedRow(), 4, new com.connor.dfl.plm.table.MyComboBoxEditor2(rev)); + table2.setComboCell(table2.getSelectedRow(), 9, new DefaultCellEditor(WAPYJBox)); + table2.setComboCell(table2.getSelectedRow(), 11, new DefaultCellEditor(ZZYJBox)); + table2.setComboCell(table2.getSelectedRow(), 13, new DefaultCellEditor(SSYJBox)); + table2.setComboCell(table2.getSelectedRow(), 15, new DefaultCellEditor(CLYJBox)); + + + } else { + javax.swing.JOptionPane.showMessageDialog(null, "输入品号有误或该品写没有版本", "系统提示", + javax.swing.JOptionPane.WARNING_MESSAGE); + + setValueAt("", table2.getSelectedRow(), 2); + setValueAt("", table2.getSelectedRow(), 3); + } + } + } catch (Exception e) { + System.out.println("eeee="+e.getMessage()); + e.printStackTrace(); + } + Vector rowVector = (Vector) dataVector.elementAt(row); + rowVector.setElementAt(value, col); + fireTableCellUpdated(row, col); + + } + }; + + + table2 = new MyTable() { + @Override + public boolean isCellEditable(int row, int column) { + if(column == 0) { + return false; + } + return true; + } + + }; + + + + table2.setModel(model2); + table2.setColumnModel(getColumn(table2, new int[] { 90, 180, 180, 180,180,180,180, 180, 180,180,180,180, 180, 180,180,180 })); + table2.setRowHeight(50); + + + + + + tcr = new DefaultTableCellRenderer(); + tcr.setHorizontalAlignment(SwingConstants.CENTER); + table1.setBorder(new LineBorder(Color.BLACK)); + table1.setDefaultRenderer(Object.class, tcr); + table2.setBorder(new LineBorder(Color.BLACK)); + table2.setDefaultRenderer(Object.class, tcr); + table2.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + + + addButton = new JButton("添加"); + delButton = new JButton("删除"); + + List listdetils = getChangeDetail(masterName); + if(listdetils.size()>0) { + + for(int j = 0;j< listdetils.size();j++) { + + model2.addRow(new String[] { Integer.toString(rows1++) }); + + //int i =1; + //for(int j =0 ;j list =getChangeDetail(name); + int[] sRows = table2.getSelectedRows(); + int p ; + for (int j = sRows.length-1; j >=0 ; j--) { + String PH = (String) model2.getValueAt(sRows[j], 1); + System.out.println("=============品号"+PH); + delChangedetil(masterName, PH); + // Connection con = null; + // + // String sql = "delete from DFL_CHANGEDETAILS where PH=?"; + // System.out.println(sql); + // try { + // con = ConnectionFun(); + // PreparedStatement prepStmt = conn.prepareStatement(sql); + // prepStmt.setString(1,PH); + // prepStmt.executeUpdate(); + // // + // int result =prepStmt.executeUpdate();// 返回值代表收到影响的行数 + // if(result>0) { + // System.out.println("删除成功"); + // }else { + // System.out.println("删除失败"); + // } + // // + // + // //p=prepStmt.executeUpdate(); + // + // + // + // // Statement stmt=conn.createStatement();//创建Statement对象 + // // stmt.executeUpdate(sql);//执行sql语句 + // System.out.println("数据库删除成功"); + // } catch (Exception ex) { + // ex.printStackTrace(); + // } finally { + // try { + // con.close(); + // } catch (Exception ex) { + // ex.printStackTrace(); + // } + // } + + // for(int k=0 ;k 0) { + ChangeOrderBean bn = (ChangeOrderBean) list.get(list.size()-1); + + System.out.println(bn.getApplyName()); + table1.setValueAt(bn.getApplyName(),0, 1); + table1.setValueAt(bn.getApplyDate(),0, 5); + table1.setValueAt(bn.getProjectCode(),8, 1); + table1.setValueAt(bn.getClientNae(),1, 5); + table1.setValueAt(bn.getProductDepartment(),3, 1); + table1.setValueAt(bn.getProductName(),1, 1); + table1.setValueAt(bn.getProjectModel(),1, 3); + //受影响的零部件 + table1.setValueAt(bn.getAffectedPart(),6, 1); + + table1.setValueAt(bn.getChangeType(),4, 1); + table1.setValueAt(bn.getProductType(),4, 3); + table1.setValueAt(bn.getErrorType(),4, 5); + table1.setValueAt(bn.getDutyDepartment(),3, 3); + table1.setValueAt(bn.getDutyMan(),3, 5); + table1.setValueAt(bn.getChangeReason(),9, 1); + table1.setValueAt(bn.getSalseClassify(),5, 3); + table1.setValueAt(bn.getPriceBooking(),5, 1); + table1.setValueAt(bn.getIsNotProductLoss(),5, 5); + table1.setValueAt(bn.getReceiveClassify(),7, 3); + table1.setValueAt(bn.getWarehouseCode(),2, 1); + + //账套 + table1.setValueAt(bn.getAccountSet(),10, 1); + //通知紧急程度 + table1.setValueAt(bn.getNotifyEmergencyProcedures(),2, 3); + + table1.setValueAt(bn.getDrawingTo(),7, 5); + + table1.setValueAt(bn.getChangeListCode(),0, 3); + table1.setValueAt(bn.getTZChangeType(),2, 5); + //table1.setValueAt(bn.getSUOSU_ProductDepartment(),6, 1); + table1.setValueAt(bn.getProjectState(),7, 1); + + + //table2 添加行加入数 + } + + + + } + + + //保存时提交到数据库 + public void insertMes(ChangeOrderBean bn) { + Connection con = null; + PreparedStatement stmt=null; + String sql = "insert into DFL_CHANGEFORM values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + try { + con = ConnectionFun(); + stmt = con.prepareStatement(sql); + + stmt.setString(1,bn.getObjectCode()); + stmt.setString(2,bn.getApplyName()); + stmt.setString(3,bn.getApplyDate()); + stmt.setString(4,bn.getProjectCode()); + stmt.setString(5,bn.getClientNae()); + stmt.setString(6,bn.getProductDepartment()); + stmt.setString(7,bn.getProductName()); + + stmt.setString(8,bn.getProjectModel()); + stmt.setString(9,bn.getAffectedPart()); + stmt.setString(10,bn.getChangeType()); + stmt.setString(11,bn.getProductType()); + + + stmt.setString(12,bn.getErrorType()); + stmt.setString(13,bn.getDutyDepartment()); + stmt.setString(14,bn.getDutyMan()); + + stmt.setString(15,bn.getChangeReason()); + + stmt.setString(16,bn.getSalseClassify()); + + stmt.setString(17,bn.getPriceBooking()); + + stmt.setString(18,bn.getIsNotProductLoss()); + stmt.setString(19,bn.getReceiveClassify()); + stmt.setString(20,bn.getWarehouseCode()); + stmt.setString(21,bn.getAccountSet()); + + stmt.setString(22,bn.getNotifyEmergencyProcedures()); + stmt.setString(23,bn.getDrawingTo()); + stmt.setString(24,bn.getChangeListCode()); + + stmt.setString(25,bn.getTZChangeType()); + stmt.setString(26,bn.getSUOSU_ProductDepartment()); + stmt.setString(27,bn.getProjectState()); + stmt.executeUpdate() ; + System.out.println("数据插入数据库完成"); + + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + + } + + + + + /** + * 插入更改明细 + */ + + + + public void insertChangeDetailsMes(ChangeDetils cd) { + Connection con = null; + PreparedStatement stmt=null; + String sql = "insert into DFL_CHANGEDETAILS values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + try { + con = ConnectionFun(); + stmt = con.prepareStatement(sql); + stmt.setString(1,cd.getObjectCode()); + stmt.setString(2,cd.getPH()); + stmt.setString(3,cd.getPM()); + stmt.setString(4,cd.getYBB()); + stmt.setString(5,cd.getXBB()); + stmt.setString(6,cd.getYSL()); + stmt.setString(7,cd.getXSL()); + stmt.setString(8,cd.getBGSL()); + stmt.setString(9,cd.getWZPSL()); + stmt.setString(10,cd.getWZPUJ()); + stmt.setString(11,cd.getZZSL()); + stmt.setString(12,cd.getZZYJ()); + stmt.setString(13,cd.getSCSL()); + stmt.setString(14,cd.getSSYJ()); + stmt.setString(15,cd.getCKSL()); + stmt.setString(16,cd.getCLYJ()); + stmt.executeUpdate() ; + System.out.println("数据插入数据库完成"); + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + + } + + + + public void delChangeForm(String id) { + Connection con = null; + String sql = "delete from dfl_changeform where objectCode=?"; + System.out.println(sql); + try { + con = ConnectionFun(); + PreparedStatement prepStmt = conn.prepareStatement(sql); + prepStmt.setString(1,id); + prepStmt.executeUpdate(); + System.out.println("数据库删除成功"); + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + + + public void delChangedetil(String id ,String ph) { + Connection con = null; + String sql = "delete from DFL_CHANGEDETAILS where objectCode=? and PH = ?"; + System.out.println(sql); + try { + con = ConnectionFun(); + + PreparedStatement prepStmt = conn.prepareStatement(sql); + prepStmt.setString(1,id); + prepStmt.setString(2,ph); + prepStmt.executeUpdate(); + + // Statement stmt=conn.createStatement();//创建Statement对象 + // stmt.executeUpdate(sql);//执行sql语句 + System.out.println("数据库删除成功"); + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + + + } + } + + + + + public void delAllChangedetil(String id ) { + Connection con = null; + String sql = "delete from DFL_CHANGEDETAILS where objectCode=?"; + System.out.println(sql); + try { + con = ConnectionFun(); + + PreparedStatement prepStmt = conn.prepareStatement(sql); + prepStmt.setString(1,id); + + prepStmt.executeUpdate(); + + // Statement stmt=conn.createStatement();//创建Statement对象 + // stmt.executeUpdate(sql);//执行sql语句 + System.out.println("数据库删除成功"); + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + + + } + } + + + //查找数据库中是都有该对象 + + public int ifcountform(String id) { + int i = 0; + Connection con = null; + PreparedStatement stmt=null; + String sql = "select * from DFL_CHANGEFORM where objectCode=?"; + try { + con = ConnectionFun(); + stmt = con.prepareStatement(sql); + ResultSet rs=null; + stmt.setString(1,id); + rs=stmt.executeQuery(); + while(rs.next()) { + i=i+1; + + } + + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + return i; + } + //统计数量 + public int ifcountdetial(String id) { + int i = 0; + Connection con = null; + PreparedStatement stmt=null; + String sql = "select * from DFL_CHANGEDETAILS where objectCode=?"; + try { + con = ConnectionFun(); + stmt = con.prepareStatement(sql); + ResultSet rs=null; + stmt.setString(1,id); + rs=stmt.executeQuery(); + while(rs.next()) { + i=i+1; + } + + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + return i; + } + + + + + + /** + * JTable设置列宽 + */ + public static TableColumnModel getColumn(JTable table, int[] width) { + TableColumnModel columns = table.getColumnModel(); + for (int i = 0; i < width.length; i++) { + TableColumn column = columns.getColumn(i); + column.setPreferredWidth(width[i]); + } + return columns; + } + + + + + class MyButtonEditor extends DefaultCellEditor { + protected DateButton button; + + public MyButtonEditor(JCheckBox checkBox) { + super(checkBox); + button = new DateButton(); + } + + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, + int column) { + if (isSelected) { + button.setForeground(table.getSelectionForeground()); + button.setBackground(table.getSelectionBackground()); + } else { + button.setForeground(table.getForeground()); + button.setBackground(table.getBackground()); + } + return button; + } + } + + + class MyTable extends JTable { + int myRow = -1, myCol = -1; + TableCellEditor myEditor; + Map map = new HashMap(); + + public void setComboCell(int r, int c, TableCellEditor ce) { + this.myRow = r; + this.myCol = c; + this.myEditor = ce; + map.put(new Point(r, c), ce); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + System.out.println(row + "," + column + ";" + myRow + "," + myCol + "," + myEditor); + + Point point = new Point(row, column); + if (map.containsKey(point)) { + return map.get(point); + } else { + return super.getCellEditor(row, column); + } + } + } + + /** + * 通过查询构建器查询项目对象 + * + * @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/dfl/plm/forms/ChangeOrderBean.java b/src/com/connor/dfl/plm/forms/ChangeOrderBean.java new file mode 100644 index 0000000..c96f50b --- /dev/null +++ b/src/com/connor/dfl/plm/forms/ChangeOrderBean.java @@ -0,0 +1,260 @@ +package com.connor.dfl.plm.forms; + +public class ChangeOrderBean { + + +// DFL_CHANGEFORM DFL_CHANGEDETAILS 数据库表名 + private String objectCode;//对象id + private String applyName;//申请人 + private String applyDate;//申请时间 + private String projectCode;//项目编号 + private String clientNae;//客户名称 + private String productDepartment;//所属产品部 + private String productName;//产品名称 + private String projectModel;//产品型号 + private String affectedPart;//受影响的设备/零部件 + private String changeType;//更改类型 + private String productType;//产品类型 + private String errorType;//错误类型 + private String dutyDepartment;//责任部门 + private String dutyMan;//责任人 + private String changeReason;//更改原因 + private String salseClassify;//销售分类 + private String priceBooking;//价格预售 + private String isNotProductLoss;//是否产生产品损失 + private String receiveClassify;//料件领用分类 + private String warehouseCode;//厂库编号 + private String accountSet;//账套 + private String NotifyEmergencyProcedures;//通知紧急程序 + private String drawingTo;//图纸发至 + private String ChangeListCode ;//变更单号 + private String TZChangeType;//图纸更改类型 + private String SUOSU_ProductDepartment;//所属产品部 + private String projectState;//项目阶段 + + + + + + + + + + + public String getProjectState() { + return projectState; + } + public void setProjectState(String projectState) { + this.projectState = projectState; + } + public ChangeOrderBean() { + + } + public ChangeOrderBean(String objectCode,String applyName, String applyDate, String projectCode, String clientNae, + String productDepartment, String productCode, String productName, String projectModel, String affectedPart, + String changeType, String productType, String errorType, String dutyDepartment, String dutyMan, + String changeReason, String salseClassify, String priceBooking, String isNotProductLoss, + String receiveClassify, String warehouseCode, String accountSet, String notifyEmergencyProcedures, + String drawingTo,String ChangeListCode,String TZChangeType,String SUOSU_ProductDepartment,String projectState) { + + this.projectState =projectState; + this.SUOSU_ProductDepartment = SUOSU_ProductDepartment; + this.TZChangeType = TZChangeType; + this.ChangeListCode = ChangeListCode; + this.objectCode = objectCode; + this.applyName = applyName; + this.applyDate = applyDate; + this.projectCode = projectCode; + this.clientNae = clientNae; + this.productDepartment = productDepartment; + + this.productName = productName; + this.projectModel = projectModel; + this.affectedPart = affectedPart; + this.changeType = changeType; + this.productType = productType; + this.errorType = errorType; + this.dutyDepartment = dutyDepartment; + this.dutyMan = dutyMan; + this.changeReason = changeReason; + this.salseClassify = salseClassify; + this.priceBooking = priceBooking; + this.isNotProductLoss = isNotProductLoss; + this.receiveClassify = receiveClassify; + this.warehouseCode = warehouseCode; + this.accountSet = accountSet; + this.NotifyEmergencyProcedures = notifyEmergencyProcedures; + this.drawingTo = drawingTo; + } + + public String getSUOSU_ProductDepartment() { + return SUOSU_ProductDepartment; + } + public void setSUOSU_ProductDepartment(String sUOSU_ProductDepartment) { + SUOSU_ProductDepartment = sUOSU_ProductDepartment; + } + public String getTZChangeType() { + return TZChangeType; + } + public void setTZChangeType(String tZChangeType) { + TZChangeType = tZChangeType; + } + public String getObjectCode() { + return objectCode; + } + public void setObjectCode(String objectCode) { + this.objectCode = objectCode; + } + public String getChangeListCode() { + return ChangeListCode; + } + public void setChangeListCode(String changeListCode) { + ChangeListCode = changeListCode; + } + public String getApplyName() { + return applyName; + } + public void setApplyName(String applyName) { + this.applyName = applyName; + } + public String getApplyDate() { + return applyDate; + } + public void setApplyDate(String applyDate) { + this.applyDate = applyDate; + } + public String getProjectCode() { + return projectCode; + } + public void setProjectCode(String projectCode) { + this.projectCode = projectCode; + } + public String getClientNae() { + return clientNae; + } + public void setClientNae(String clientNae) { + this.clientNae = clientNae; + } + public String getProductDepartment() { + return productDepartment; + } + public void setProductDepartment(String productDepartment) { + this.productDepartment = productDepartment; + } + + public String getProductName() { + return productName; + } + public void setProductName(String productName) { + this.productName = productName; + } + public String getProjectModel() { + return projectModel; + } + public void setProjectModel(String projectModel) { + this.projectModel = projectModel; + } + public String getAffectedPart() { + return affectedPart; + } + public void setAffectedPart(String affectedPart) { + this.affectedPart = affectedPart; + } + public String getChangeType() { + return changeType; + } + + public void setChangeType(String changeType) { + this.changeType = changeType; + } + public String getProductType() { + return productType; + } + public void setProductType(String productType) { + this.productType = productType; + } + public String getErrorType() { + return errorType; + } + public void setErrorType(String errorType) { + this.errorType = errorType; + } + public String getDutyDepartment() { + return dutyDepartment; + } + public void setDutyDepartment(String dutyDepartment) { + this.dutyDepartment = dutyDepartment; + } + public String getDutyMan() { + return dutyMan; + } + public void setDutyMan(String dutyMan) { + this.dutyMan = dutyMan; + } + public String getChangeReason() { + return changeReason; + } + public void setChangeReason(String changeReason) { + this.changeReason = changeReason; + } + public String getSalseClassify() { + return salseClassify; + } + public void setSalseClassify(String salseClassify) { + this.salseClassify = salseClassify; + } + public String getPriceBooking() { + return priceBooking; + } + public void setPriceBooking(String priceBooking) { + this.priceBooking = priceBooking; + } + public String getIsNotProductLoss() { + return isNotProductLoss; + } + public void setIsNotProductLoss(String isNotProductLoss) { + this.isNotProductLoss = isNotProductLoss; + } + public String getReceiveClassify() { + return receiveClassify; + } + public void setReceiveClassify(String receiveClassify) { + this.receiveClassify = receiveClassify; + } + public String getWarehouseCode() { + return warehouseCode; + } + public void setWarehouseCode(String warehouseCode) { + this.warehouseCode = warehouseCode; + } + public String getAccountSet() { + return accountSet; + } + public void setAccountSet(String accountSet) { + this.accountSet = accountSet; + } + public String getNotifyEmergencyProcedures() { + return NotifyEmergencyProcedures; + } + public void setNotifyEmergencyProcedures(String notifyEmergencyProcedures) { + NotifyEmergencyProcedures = notifyEmergencyProcedures; + } + public String getDrawingTo() { + return drawingTo; + } + public void setDrawingTo(String drawingTo) { + this.drawingTo = drawingTo; + } + + + + + + + + + + + + +} diff --git a/src/com/connor/dfl/plm/forms/PressureChangeBean.java b/src/com/connor/dfl/plm/forms/PressureChangeBean.java new file mode 100644 index 0000000..56c9f2c --- /dev/null +++ b/src/com/connor/dfl/plm/forms/PressureChangeBean.java @@ -0,0 +1,262 @@ +package com.connor.dfl.plm.forms; + +public class PressureChangeBean { + + private String id; + private String company; //用人单位 + private String productId;//产品编号 + private String changeFun; //更改方式 + private String prodectType; //产品型号 + private String changeId ; //更改单号 + private String chartId ;//图号 + private String changeReason ;//更改理由 + + private String firstContidion ;//原有情况 + + + private String shouldChange ;//应该为 + + + private String changeResult; //更改结果 + + + private String changeMan ;//更改者 + private String changeManDate;//更改者日期 + private String checkMan ;//校核者 + private String checkManDate ;//校核者日期 + private String auditorMan; //审核者 + private String auditorManDate;//审核者日期 + + + private String remark; //备注 + + + + + + public PressureChangeBean() { + } + + + + + + public PressureChangeBean(String id, String company, String productId, String changeFun, String prodectType, + String changeId, String chartId, String changeReason, String firstContidion, String shouldChange, + String changeResult, String changeMan, String changeManDate, String checkMan, String checkManDate, + String auditorMan, String auditorManDate, String remark) { + this.id = id; + this.company = company; + this.productId = productId; + this.changeFun = changeFun; + this.prodectType = prodectType; + this.changeId = changeId; + this.chartId = chartId; + this.changeReason = changeReason; + this.firstContidion = firstContidion; + this.shouldChange = shouldChange; + this.changeResult = changeResult; + this.changeMan = changeMan; + this.changeManDate = changeManDate; + this.checkMan = checkMan; + this.checkManDate = checkManDate; + this.auditorMan = auditorMan; + this.auditorManDate = auditorManDate; + this.remark = remark; + } + + + + + + public String getId() { + return id; + } + + + + + + public void setId(String id) { + this.id = id; + } + + + + + + public String getCompany() { + return company; + } + + + public void setCompany(String company) { + this.company = company; + } + + + public String getProductId() { + return productId; + } + + + public void setProductId(String productId) { + this.productId = productId; + } + + + public String getChangeFun() { + return changeFun; + } + + + public void setChangeFun(String changeFun) { + this.changeFun = changeFun; + } + + + public String getProdectType() { + return prodectType; + } + + + public void setProdectType(String prodectType) { + this.prodectType = prodectType; + } + + + public String getChangeId() { + return changeId; + } + + + public void setChangeId(String changeId) { + this.changeId = changeId; + } + + + public String getChartId() { + return chartId; + } + + + public void setChartId(String chartId) { + this.chartId = chartId; + } + + + public String getChangeReason() { + return changeReason; + } + + + public void setChangeReason(String changeReason) { + this.changeReason = changeReason; + } + + + public String getFirstContidion() { + return firstContidion; + } + + + public void setFirstContidion(String firstContidion) { + this.firstContidion = firstContidion; + } + + + public String getShouldChange() { + return shouldChange; + } + + + public void setShouldChange(String shouldChange) { + this.shouldChange = shouldChange; + } + + + public String getChangeResult() { + return changeResult; + } + + + public void setChangeResult(String changeResult) { + this.changeResult = changeResult; + } + + + public String getChangeMan() { + return changeMan; + } + + + public void setChangeMan(String changeMan) { + this.changeMan = changeMan; + } + + + public String getChangeManDate() { + return changeManDate; + } + + + public void setChangeManDate(String changeManDate) { + this.changeManDate = changeManDate; + } + + + public String getCheckMan() { + return checkMan; + } + + + public void setCheckMan(String checkMan) { + this.checkMan = checkMan; + } + + + public String getCheckManDate() { + return checkManDate; + } + + + public void setCheckManDate(String checkManDate) { + this.checkManDate = checkManDate; + } + + + public String getAuditorMan() { + return auditorMan; + } + + + public void setAuditorMan(String auditorMan) { + this.auditorMan = auditorMan; + } + + + public String getAuditorManDate() { + return auditorManDate; + } + + + public void setAuditorManDate(String auditorManDate) { + this.auditorManDate = auditorManDate; + } + + + public String getRemark() { + return remark; + } + + + public void setRemark(String remark) { + this.remark = remark; + } + + + + + + +} diff --git a/src/com/connor/dfl/plm/forms/PressureChangeForm.java b/src/com/connor/dfl/plm/forms/PressureChangeForm.java new file mode 100644 index 0000000..0ad12cc --- /dev/null +++ b/src/com/connor/dfl/plm/forms/PressureChangeForm.java @@ -0,0 +1,1012 @@ + + +package com.connor.dfl.plm.forms; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Point; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +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.sql.Statement; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.EventObject; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Vector; + +import javax.swing.DefaultCellEditor; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.LineBorder; +import javax.swing.event.CellEditorListener; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + + +import com.connor.dfl.plm.table.CTMap; +import com.connor.dfl.plm.table.CTable; +import com.connor.dfl.plm.util.DateChooser; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +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.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + + +public class PressureChangeForm extends AbstractRendering { + /** + * + */ + + private TCComponentForm form; + private TCSession session; + AbstractAIFApplication app= AIFUtility.getCurrentApplication(); + private InterfaceAIFComponent targetComp = app.getTargetComponent(); + private TCComponentItemType itemType; + + private DefaultTableCellRenderer tcr; + private CTable table1; + private CTable table2; + private CTable table3; + private CTable table4; + private CTable table5; + + + private CTMap model1; + private CTMap model2; + private CTMap model3; + private CTMap model4; + private CTMap model5; + + + + private String name; + + + + //时间 + + public DefaultComboBoxModel jsrBoxModel; + + + + + + static String time; + int rows1 = 1; + private String applyname; + + private String my_item_id; + + + + + + + + + + + + + public PressureChangeForm(TCComponent arg0) throws Exception { + super(arg0); + form = (TCComponentForm) arg0; + this.session = ((TCSession) app.getSession()); + loadRendering(); + } + + String[] stringArray = ((TCSession) app.getSession()).getPreferenceService().getStringValues("DFL2_SQL_Connect"); + + private String url = "jdbc:oracle:thin:@//"+stringArray[0];// + + private String user = stringArray[1];// + + private String password = stringArray[2];// + + private Connection conn = null;// + + private PreparedStatement pre = null;// + + private ResultSet result = null;// + + + + public Connection ConnectionFun() throws SQLException { + + try { + System.out.println(url); + System.out.println(user); + System.out.println(password); + Class.forName("oracle.jdbc.driver.OracleDriver"); + System.out.println("驱动加载成功"); + } catch (ClassNotFoundException e) { + System.out.println("驱动加载失败"); + } + + conn=DriverManager.getConnection(url,user,password); + + System.out.println("数据库连接成功"); + return conn; + + + } + + + + @Override + public void loadRendering() throws TCException { + try { + initUI(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + private void initUI() throws TCException, SQLException { + + + + + + + + + + TCComponent comp = (TCComponent) targetComp; + name = comp.getStringProperty("object_name"); + + String applyname= comp.getTCProperty("owning_user").getReferenceValueInString(); + + System.out.println("========"+name); + + + + String titleName =name+"压力容器施工图变更通知单" ; + JLabel titleLable = new JLabel(titleName); + titleLable.setFont(new Font("宋体", 1, 16)); + + + + + + model1 = new CTMap(3, 6) { + + public void setValueAt(Object value, int row, int column) { + if(row ==0 && column ==1) { + if(value == null) { + return; + } + + } + Vector rowVector = (Vector) dataVector.elementAt(row); + rowVector.setElementAt(value, column); + fireTableCellUpdated(row, column); + + } + + }; + + model1.combine(new int[]{2}, new int[] {1,2,3,4,5}); + + + table1 = new CTable(model1) { + @Override + public boolean isCellEditable(int row, int column) { + if(column == 0&&row<2 || column ==2&&row<2|| column==4&&row<2 ) { + return false; + } + if(column == 0 && row ==2) { + return false; + + } + + return true; + + } + }; + + + + + + table1.setValueAt("用人单位",0, 0); + table1.setValueAt("产品编号",0, 2); + table1.setValueAt("更改方式",0, 4); + + table1.setValueAt("产品型号",1, 0); + table1.setValueAt("更改单号",1, 2); + table1.setValueAt("图号",1, 4); + + table1.setValueAt("更改理由",2, 0); + + + + table1.getColumnModel().getColumn(0).setPreferredWidth(100); + table1.getColumnModel().getColumn(1).setPreferredWidth(200); + table1.getColumnModel().getColumn(2).setPreferredWidth(100); + table1.getColumnModel().getColumn(3).setPreferredWidth(200); + table1.getColumnModel().getColumn(4).setPreferredWidth(100); + table1.getColumnModel().getColumn(5).setPreferredWidth(200); + table1.setRowHeight(50); + table1.setRowHeight(2,200); + table1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + JPanel tablePanel1 = new JPanel(); + tablePanel1.add(table1); + + + + + + JLabel firstConditionLable = new JLabel("原有状情况(含图号、原有状况)"); + firstConditionLable.setFont(new Font("宋体", 1, 14)); + + model2 = new CTMap(1, 1) { + + public void setValueAt(Object value, int row, int column) { + if(row ==0 && column ==0) { + if(value == null) { + return; + } + + } + Vector rowVector = (Vector) dataVector.elementAt(row); + rowVector.setElementAt(value, column); + fireTableCellUpdated(row, column); + + } + + }; + + + + table2 = new CTable(model2) { + @Override + public boolean isCellEditable(int row, int column) { + + return true; + + } + }; + + table2.getColumnModel().getColumn(0).setPreferredWidth(900); + table2.setRowHeight(150); + + + JPanel tablePanel2 = new JPanel(); + tablePanel2.add(table2); + + + + + + JLabel shouldConditionLable = new JLabel("应改为(含图号、更改后状态)"); + shouldConditionLable.setFont(new Font("宋体", 1, 14)); + + model3 = new CTMap(1, 1) { + + public void setValueAt(Object value, int row, int column) { + if(row ==0 && column ==0) { + if(value == null) { + return; + } + + } + Vector rowVector = (Vector) dataVector.elementAt(row); + rowVector.setElementAt(value, column); + fireTableCellUpdated(row, column); + + } + + }; + + + + table3 = new CTable(model3) { + @Override + public boolean isCellEditable(int row, int column) { + + return true; + + } + }; + + table3.getColumnModel().getColumn(0).setPreferredWidth(900); + table3.setRowHeight(150); + + JPanel tablePanel3 = new JPanel(); + tablePanel3.add(table3); + + + + + + + JLabel changeResult = new JLabel("更改结果(含图号、更改后版本)"); + changeResult.setFont(new Font("宋体", 1, 14)); + + model4 = new CTMap(1, 1) { + + public void setValueAt(Object value, int row, int column) { + if(row ==0 && column ==0) { + if(value == null) { + return; + } + + } + Vector rowVector = (Vector) dataVector.elementAt(row); + rowVector.setElementAt(value, column); + fireTableCellUpdated(row, column); + + } + + }; + + + + table4 = new CTable(model4) { + @Override + public boolean isCellEditable(int row, int column) { + + return true; + + } + }; + + table4.getColumnModel().getColumn(0).setPreferredWidth(900); + table4.setRowHeight(150); + + JPanel tablePanel4 = new JPanel(); + tablePanel4.add(table4); + + + + + model5 = new CTMap(3, 5) { + public void setValueAt(Object value, int row, int column) { + if(row ==0 && column ==1) { + if(value == null) { + return; + } + } + Vector rowVector = (Vector) dataVector.elementAt(row); + rowVector.setElementAt(value, column); + fireTableCellUpdated(row, column); + + } + + }; + + + + + + + model5.combine(new int[]{1,2}, new int[] {4}); + + + table5 = new CTable(model5) { + @Override + public boolean isCellEditable(int row, int column) { + if(column == 0&&row<2 || column ==2&&row<2) { + return false; + } + return true; + } + }; + + + + table5.setValueAt("更改者",0, 0); + table5.setValueAt("日期",0, 2); + + table5.setValueAt("校核者",1, 0); + table5.setValueAt("日期",1,2); + + table5.setValueAt("审核者",2, 0); + table5.setValueAt("日期",2, 2); + + table5.setValueAt("备注",0,4); + + + + + DateChooser dateChooser1 = DateChooser.getInstance("yyyy-M-d"); + DateChooser dateChooser2 = DateChooser.getInstance("yyyy-M-d"); + DateChooser dateChooser3 = DateChooser.getInstance("yyyy-M-d"); + + Date date = new Date(); + SimpleDateFormat df = new SimpleDateFormat("yyyy-M-d"); + + String time = df.format(date); + + + + JTextField showDate1 = new JTextField(time); + JTextField showDate2 = new JTextField(time); + JTextField showDate3 = new JTextField(time); + + dateChooser1.register(showDate1); + dateChooser2.register(showDate2); + dateChooser3.register(showDate3); + + + table5.setCombo(0,3,new DefaultCellEditor(showDate1)); + table5.setCombo(1,3,new DefaultCellEditor(showDate2)); + table5.setCombo(2,3,new DefaultCellEditor(showDate3)); + + + + + + + table5.getColumnModel().getColumn(0).setPreferredWidth(100); + table5.getColumnModel().getColumn(1).setPreferredWidth(200); + table5.getColumnModel().getColumn(2).setPreferredWidth(100); + table5.getColumnModel().getColumn(3).setPreferredWidth(200); + table5.getColumnModel().getColumn(4).setPreferredWidth(300); + + table5.setRowHeight(50); + + + JPanel tablePanel5 = new JPanel(); + tablePanel5.add(table5); + + + + setValue(); + + + + // + // + // + // + // + // + // + // + // + // + // + // + // + + + + + + + + + + + + + + + + + tcr = new DefaultTableCellRenderer(); + tcr.setHorizontalAlignment(SwingConstants.CENTER); + table1.setBorder(new LineBorder(Color.BLACK)); + table1.setDefaultRenderer(Object.class, tcr); + table2.setBorder(new LineBorder(Color.BLACK)); + table2.setDefaultRenderer(Object.class, tcr); + table3.setBorder(new LineBorder(Color.BLACK)); + table3.setDefaultRenderer(Object.class, tcr); + table4.setBorder(new LineBorder(Color.BLACK)); + table4.setDefaultRenderer(Object.class, tcr); + table5.setBorder(new LineBorder(Color.BLACK)); + table5.setDefaultRenderer(Object.class, tcr); + + + + JPanel rootPanel = new JPanel(new PropertyLayout()); + + + + + + + + + rootPanel.add("1.1.center.top",titleLable); + rootPanel.add("2.1.left.top",tablePanel1); + + rootPanel.add("3.1.left.top",firstConditionLable); + rootPanel.add("4.1.left.top",tablePanel2); + + rootPanel.add("5.1.left.top",shouldConditionLable); + rootPanel.add("6.1.left.top",tablePanel3); + + + rootPanel.add("7.1.left.top",changeResult); + rootPanel.add("8.1.left.top",tablePanel4); + + + rootPanel.add("9.1.left.top",tablePanel5); + + + + + + + this.setLayout(new BorderLayout()); + + this.add(rootPanel,BorderLayout.CENTER); + JScrollPane scrollPane = new JScrollPane(rootPanel); + scrollPane.getVerticalScrollBar().setUnitIncrement(20); + this.add(scrollPane,BorderLayout.CENTER); + this.setBackground(Color.WHITE); + this.setVisible(true); + + + + } + + @Override + public void saveRendering() { + + delChangeForm(name); + PressureChangeBean bn = new PressureChangeBean(); + + bn.setId(name); + + bn.setCompany(model1.getValueAt(0, 1) == null ? "" :model1.getValueAt(0, 1).toString()); + + bn.setProductId(model1.getValueAt(0, 3) == null ? "" :model1.getValueAt(0, 3).toString()); + + bn.setChangeFun(model1.getValueAt(0, 5) == null ? "" :model1.getValueAt(0, 5).toString()); + + bn.setProdectType(model1.getValueAt(1, 1) == null ? "" :model1.getValueAt(1, 1).toString()); + + bn.setChangeId(model1.getValueAt(1, 3) == null ? "" :model1.getValueAt(1, 3).toString()); + + bn.setChartId(model1.getValueAt(1, 5) == null ? "" :model1.getValueAt(1, 5).toString()); + + bn.setChangeReason(model1.getValueAt(2, 1) == null ? "" :model1.getValueAt(2, 1).toString()); + + bn.setFirstContidion(model2.getValueAt(0, 0) == null ? "" :model2.getValueAt(0, 0).toString()); + + + bn.setShouldChange(model3.getValueAt(0, 0) == null ? "" :model3.getValueAt(0, 0).toString()); + + + bn.setChangeResult(model4.getValueAt(0, 0) == null ? "" :model4.getValueAt(0, 0).toString()); + + + + bn.setChangeMan(model5.getValueAt(0, 1) == null ? "" :model5.getValueAt(0, 1).toString()); + bn.setChangeManDate(model5.getValueAt(0, 3) == null ? "" :model5.getValueAt(0, 3).toString()); + + bn.setCheckMan(model5.getValueAt(1, 1) == null ? "" :model5.getValueAt(1, 1).toString()); + bn.setCheckManDate(model5.getValueAt(1, 3) == null ? "" :model5.getValueAt(1, 3).toString()); + + bn.setAuditorMan(model5.getValueAt(2, 1) == null ? "" :model5.getValueAt(2, 1).toString()); + bn.setAuditorManDate(model5.getValueAt(2, 3) == null ? "" :model5.getValueAt(2, 3).toString()); + + + bn.setRemark(model5.getValueAt(1, 4) == null ? "" :model5.getValueAt(1, 4).toString()); + + insertMes(bn); + + + + + + + + + + } + + + + + + + + + + + + + public void setValue() { + System.out.println("加载数据"); + List list = getChangeMesg(name); + + if(list.size() > 0) { + PressureChangeBean bn = (PressureChangeBean) list.get(list.size()-1); + + + table1.setValueAt(bn.getCompany(),0, 1); + table1.setValueAt(bn.getProductId(),0, 3); + table1.setValueAt(bn.getChangeFun(),0, 5); + + table1.setValueAt(bn.getProdectType(),1, 1); + table1.setValueAt(bn.getChangeId(),1, 3); + table1.setValueAt(bn.getChartId(),1, 5); + table1.setValueAt(bn.getChangeReason(),2, 1); + + + table2.setValueAt(bn.getFirstContidion(),0,0); + + table3.setValueAt(bn.getShouldChange(),0,0); + + table4.setValueAt(bn.getChangeResult(),0,0); + + table5.setValueAt(bn.getChangeMan(),0, 1); + + table5.setValueAt(bn.getChangeManDate(),0, 3); + + table5.setValueAt(bn.getCheckMan(),1, 1); + table5.setValueAt(bn.getCheckManDate(),1, 3); + + + + table5.setValueAt(bn.getAuditorMan(),2, 1); + table5.setValueAt(bn.getAuditorManDate(),2, 3); + + + table5.setValueAt(bn.getRemark(),1, 4); + + + + + + + + + + + //table2 添加行加入数 + } + + } + + + + + + + + + + + + + + + + + + + //获取变更单信息 + + private List getChangeMesg(String id) { + List list = new ArrayList(); + PressureChangeBean bn = new PressureChangeBean(); + ResultSet r = null; + Connection con = null; + PreparedStatement stmt=null; + String sql = "select * from DFL_PRESSURE_CHANGE where id=?";// + try { + con = ConnectionFun(); + stmt=con.prepareStatement(sql); + stmt.setString(1,id); + r=stmt.executeQuery(); + while(r.next()){ + bn.setId(r.getString(1)); + // company; //用人单位 + bn.setCompany(r.getString(2)); + + + // productId;//产品编号 + bn.setProductId(r.getString(3)); + + // changeFun; //更改方式 + bn.setChangeFun(r.getString(4)); + // prodectType; //产品型号 + + bn.setProdectType(r.getString(5)); + // changeId ; //更改单号 + bn.setChangeId(r.getString(6)); + // chartId ;//图号 + bn.setChartId(r.getString(7)); + // changeReason ;//更改理由 + bn.setChangeReason(r.getString(8)); + // firstContidion ;//原有情况 + bn.setFirstContidion(r.getString(9)); + // shouldChange ;//应该为 + bn.setShouldChange(r.getString(10)); + // changeResult; //更改结果 + bn.setChangeResult(r.getString(11)); + // changeMan ;//更改者 + bn.setChangeMan(r.getString(12)); + + // changeManDate;//更改者日期 + bn.setChangeManDate(r.getString(13)); + // checkMan ;//校核者 + bn.setCheckMan(r.getString(14)); + // checkManDate ;//校核者日期 + bn.setCheckManDate(r.getString(15)); + // auditorMan; //审核者 + bn.setAuditorMan(r.getString(16)); + // auditorManDate;//审核者日期 + bn.setAuditorManDate(r.getString(17)); + // private String remark; //备注 + bn.setRemark(r.getString(18)); + + list.add(bn); + } + }catch (SQLException e) { + e.printStackTrace(); + }finally{ + try { + r.close(); + stmt.close(); + con.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + return list; + } + + + + + + + //保存时提交到数据库 + public void insertMes(PressureChangeBean bn) { + Connection con = null; + PreparedStatement stmt=null; + + + + + + // /String sqlupdate="update DFL_SEND_TXT_TO_ERP SET id="+bn.getId()+" , " + // + " company="+bn.getCompany()+" ," + // + " where myuid='"+weiyi_id+"' "; + + // id; + // company; //用人单位 + // productId;//产品编号 + // changeFun; //更改方式 + // prodectType; //产品型号 + // changeId ; //更改单号 + // chartId ;//图号 + // changeReason ;//更改理由 + // firstContidion ;//原有情况 + // shouldChange ;//应该为 + // changeResult; //更改结果 + // changeMan ;//更改者 + // changeManDate;//更改者日期 + // checkMan ;//校核者 + // checkManDate ;//校核者日期 + // auditorMan; //审核者 + // auditorManDate;//审核者日期 + // private String remark; //备注 + + + String insert_sql = "insert into DFL_PRESSURE_CHANGE values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + try { + con = ConnectionFun(); + + + + + + + stmt = con.prepareStatement(insert_sql); + + + + // id; + stmt.setString(1,bn.getId()); + // company; //用人单位 + stmt.setString(2,bn.getCompany()); + // productId;//产品编号 + stmt.setString(3,bn.getProductId()); + // changeFun; //更改方式 + stmt.setString(4,bn.getChangeFun()); + // prodectType; //产品型号 + stmt.setString(5,bn.getProdectType()); + // changeId ; //更改单号 + stmt.setString(6,bn.getChangeId()); + // chartId ;//图号 + stmt.setString(7,bn.getChartId()); + // changeReason ;//更改理由 + stmt.setString(8,bn.getChangeReason()); + // firstContidion ;//原有情况 + stmt.setString(9,bn.getFirstContidion()); + // shouldChange ;//应该为 + stmt.setString(10,bn.getShouldChange()); + // changeResult; //更改结果 + stmt.setString(11,bn.getChangeResult()); + // changeMan ;//更改者 + stmt.setString(12,bn.getChangeMan()); + // changeManDate;//更改者日期 + stmt.setString(13,bn.getChangeManDate()); + // checkMan ;//校核者 + stmt.setString(14,bn.getCheckMan()); + // checkManDate ;//校核者日期 + stmt.setString(15,bn.getCheckManDate()); + // auditorMan; //审核者 + stmt.setString(16,bn.getAuditorMan()); + // auditorManDate;//审核者日期 + stmt.setString(17,bn.getAuditorManDate()); + // private String remark; //备注 + stmt.setString(18,bn.getRemark()); + + + + + stmt.executeUpdate() ; + System.out.println("数据插入数据库完成"); + + + + + + + + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + } + + + + + + + public void delChangeForm(String id) { + Connection con = null; + String sql = "delete from DFL_PRESSURE_CHANGE where id=?"; + System.out.println(sql); + try { + con = ConnectionFun(); + PreparedStatement prepStmt = conn.prepareStatement(sql); + prepStmt.setString(1,id); + prepStmt.executeUpdate(); + System.out.println("数据库删除成功"); + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + + + + + + + + /** + * JTable设置列宽 + */ + public static TableColumnModel getColumn(JTable table, int[] width) { + TableColumnModel columns = table.getColumnModel(); + for (int i = 0; i < width.length; i++) { + TableColumn column = columns.getColumn(i); + column.setPreferredWidth(width[i]); + } + return columns; + } + + + + + class MyButtonEditor extends DefaultCellEditor { + protected DateButton button; + + public MyButtonEditor(JCheckBox checkBox) { + super(checkBox); + button = new DateButton(); + } + + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, + int column) { + if (isSelected) { + button.setForeground(table.getSelectionForeground()); + button.setBackground(table.getSelectionBackground()); + } else { + button.setForeground(table.getForeground()); + button.setBackground(table.getBackground()); + } + return button; + } + } + + + + class MyTable extends JTable { + int myRow = -1, myCol = -1; + TableCellEditor myEditor; + Map map = new HashMap(); + + public void setComboCell(int r, int c, TableCellEditor ce) { + this.myRow = r; + this.myCol = c; + this.myEditor = ce; + map.put(new Point(r, c), ce); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + System.out.println(row + "," + column + ";" + myRow + "," + myCol + "," + myEditor); + + Point point = new Point(row, column); + if (map.containsKey(point)) { + return map.get(point); + } else { + return super.getCellEditor(row, column); + } + } + } + + + +} diff --git a/src/com/connor/dfl/plm/forms/Project_Code.java b/src/com/connor/dfl/plm/forms/Project_Code.java new file mode 100644 index 0000000..a3e22b2 --- /dev/null +++ b/src/com/connor/dfl/plm/forms/Project_Code.java @@ -0,0 +1,25 @@ +package com.connor.dfl.plm.forms; + +public class Project_Code { + private String projecID; + + + + public Project_Code() { + } + + public Project_Code(String projecID) { + this.projecID = projecID; + } + + public String getProjecID() { + return projecID; + } + + public void setProjecID(String projecID) { + this.projecID = projecID; + } + + + +} diff --git a/src/com/connor/dfl/plm/forms/QuickChangeForm.java b/src/com/connor/dfl/plm/forms/QuickChangeForm.java new file mode 100644 index 0000000..a6407ea --- /dev/null +++ b/src/com/connor/dfl/plm/forms/QuickChangeForm.java @@ -0,0 +1,1771 @@ +package com.connor.dfl.plm.forms; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Point; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +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.sql.Statement; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.EventObject; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Vector; + +import javax.swing.DefaultCellEditor; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.ScrollPaneConstants; +import javax.swing.SwingConstants; +import javax.swing.border.LineBorder; +import javax.swing.event.CellEditorListener; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + + +import com.connor.dfl.plm.table.CTMap; +import com.connor.dfl.plm.table.CTable; +import com.connor.dfl.plm.util.DateChooser; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +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.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + + +public class QuickChangeForm extends AbstractRendering { + private TCComponentForm form; + private TCSession session; + AbstractAIFApplication app= AIFUtility.getCurrentApplication(); + private InterfaceAIFComponent targetComp = app.getTargetComponent(); + private TCComponentItemType itemType; + private QuickChangeForm selfform; + private DefaultTableCellRenderer tcr; + CTable table1; + private MyTable table2; + + //private CTMap model1, model2; + private CTMap model1; + DefaultTableModel model2; + + private String name; + + private JButton addButton; + private JButton delButton; + + private JComboBox ChangeTypeBox; + private JComboBox ProductTypecBox; + private JComboBox ErrorTypeBox; + private JComboBox DutyDepartmentBox; + private JComboBox SalesClassifyBox; + private JComboBox EmergencyNotifyBox; + private JComboBox ProductDepartmentBox;//产品部门 + private JComboBox DrawingChangeTypeBox;//图纸更改类型 + private JComboBox IsNotProductLossBox;//是否产生成本损失 + private JComboBox ReceiveClassifyBox;//料件领用分类 + private JComboBox WAPYJBox;//未制品意见 + private JComboBox ZZYJBox;//在制意见 + private JComboBox SSYJBox;//生产意见 + private JComboBox CLYJBox;//处理意见 + + //时间 + + public DefaultComboBoxModel jsrBoxModel; + + + + + //private JComboBox projectCode;//项目编号 + static String time; + int rows1 = 1; + private String applyname; + + private String my_item_id; + + private String clientname; + private String pd; + private String productname; + private String productmodel; + private String producttype; + private String department; + private String duty; + private String type; + private String projectState; + + + //存放table2中的数据,保存到数据库中使用 + List changedeList = new ArrayList(); + + + + + + + + + + public QuickChangeForm(TCComponent arg0) throws Exception { + super(arg0); + form = (TCComponentForm) arg0; + this.session = ((TCSession) app.getSession()); + this.selfform = this; + loadRendering(); + } + + String[] stringArray = ((TCSession) app.getSession()).getPreferenceService().getStringValues("DFL2_SQL_Connect"); + + private String url = "jdbc:oracle:thin:@//"+stringArray[0];// + + private String user = stringArray[1];// + + private String password = stringArray[2];// + + private Connection conn = null;// + + private PreparedStatement pre = null;// + + private ResultSet result = null;// + + + + public Connection ConnectionFun() throws SQLException { + + try { + System.out.println(url); + System.out.println(user); + System.out.println(password); + Class.forName("oracle.jdbc.driver.OracleDriver"); + System.out.println("驱动加载成功"); + } catch (ClassNotFoundException e) { + System.out.println("驱动加载失败"); + } + + conn=DriverManager.getConnection(url,user,password); + + System.out.println("数据库连接成功"); + return conn; + + + } + + + + @Override + public void loadRendering() throws TCException { + try { + initUI(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + private void initUI() throws TCException, SQLException { + + + //更改类型 + + String[] change_type_stringArrays = session.getPreferenceService().getStringValues("DFL_Form_ChangeType"); + if (change_type_stringArrays == null || change_type_stringArrays.length <= 0 ) { + MessageBox.post("首选项DFL_Form_ChangeType未配置,请联系管理员!!", + "错误", MessageBox.ERROR); + return; + } + //更改类型 + ChangeTypeBox = new JComboBox(); + for(int change_type_number = 0;change_type_number=2) { + groupname = buisnisDivisions[buisnisDivisions.length-2]; + + } + + + table1.setValueAt("申请人", 0, 0); + table1.setValueAt(applyname, 0,1); + + table1.setValueAt("快速变更单号", 0, 2); + table1.setValueAt(my_item_id, 0, 3); + + + + table1.setValueAt("申请时间", 0, 4); + + table1.setValueAt("产品名称", 1, 0); + table1.setValueAt(productname, 1, 1); + + + table1.setValueAt("产品型号", 1, 2); + table1.setValueAt(productmodel, 1, 3); + + + + table1.setValueAt("客户名称", 1, 4); + + table1.setValueAt(clientname, 1, 5); + + + table1.setValueAt("仓库编号", 2, 0);// + String[] stringArray_warehouse = ((TCSession) app.getSession()).getPreferenceService().getStringValues("DFL_Form_WarehouseCode"); + String warehouse = ""; + for(int z = 0 ;z0) { + // DateBean dbs=(DateBean) ll.get(ll.size()-1); + // table1.setValueAt(dbs.getDate(),0, 5); + // del_date(); + // flag = false; + // } + // } + // + // } + + + + // String[] keys = new String[] { "ID" }; + // TCComponentUser user = session.getUser(); + // String user_id = user.getStringProperty("user_id"); + // String[] values = new String[] { user_id }; + // List compList = queryObject("基于用户的项目", keys, values); + // if (compList != null && compList.size() > 0) { + // for (int i = 0; i < compList.size(); i++) { + // TCComponent comp1 = compList.get(i); + // if (comp1 instanceof TCComponentProject) { + // TCComponentProject project = (TCComponentProject) comp1; + // try { + // String id = project.getStringProperty("project_id"); + // projectCode.addItem(id); + // } catch (TCException e1) { + // // TODO Auto-generated catch block + // e1.printStackTrace(); + // } + // } + // } + // } + + + + + + + //更改类型 + table1.setCombo(4,1,new DefaultCellEditor(ChangeTypeBox)); + //产品类型 + table1.setCombo(4,3,new DefaultCellEditor(ProductTypecBox)); + //错误类型 + table1.setCombo(4,5,new DefaultCellEditor(ErrorTypeBox)); + //销售分类 + table1.setCombo(5,3,new DefaultCellEditor(SalesClassifyBox)); + //责任部门 + //table1.setCombo(3,3,new DefaultCellEditor(DutyDepartmentBox)); + //紧急程度通知 + table1.setCombo(2,3,new DefaultCellEditor(EmergencyNotifyBox)); + //时间 + //产品部门 + table1.setCombo(3,1,new DefaultCellEditor(ProductDepartmentBox)); + //图纸更改类型 + table1.setCombo(2,5,new DefaultCellEditor(DrawingChangeTypeBox)); + //是否产生成本损失 + table1.setCombo(5,5,new DefaultCellEditor(IsNotProductLossBox)); + //料件领用分类 + table1.setCombo(7,3,new DefaultCellEditor(ReceiveClassifyBox)); + //table1.setCombo(0,5,new DefaultCellEditor(datetime)); + + + + + //table1.setCombo(8, 1, new DefaultCellEditor(projectCode)); + + + table1.getColumnModel().getColumn(0).setPreferredWidth(130); + table1.getColumnModel().getColumn(1).setPreferredWidth(400); + table1.getColumnModel().getColumn(2).setPreferredWidth(130); + table1.getColumnModel().getColumn(3).setPreferredWidth(400); + table1.getColumnModel().getColumn(4).setPreferredWidth(130); + table1.getColumnModel().getColumn(5).setPreferredWidth(400); + + table1.setRowHeight(50); + table1.setRowHeight(9, 100); + table1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + + + + + + + + + + model2 = new DefaultTableModel(null, new String[] {"序号","品号","品名","原版本","现版本","原数量","现数量","变更数量","未制品数量","未制品意见","在制数量","在制意见","生产数量","生产意见","仓库数量","处理意见"}) { + + public void setValueAt(Object value, int row, int col){ + try { + if (row == table2.getSelectedRow() && col == 1) { + String val = value.toString(); + itemType = (TCComponentItemType) session.getTypeComponent("Item"); + TCComponentItem item = itemType.find(val); + String objectname = item.getStringProperty("object_name"); + TCComponent[] allRev = item.getRelatedComponents("revision_list"); + if (allRev.length > 0) { + List list = new ArrayList(); + for (int i = 0; i < allRev.length; i++) { + // 下拉框-版本:item_revision_id + list.add(allRev[i].getProperty("item_revision_id")); + } + String[] rev = new String[list.size()]; + // list去除重复数据 + for (int i = 0; i < list.size() - 1; i++) { + for (int j = list.size() - 1; j > i; j--) { + if (list.get(j).equals(list.get(i))) { + list.remove(j); + } + } + } + for (int i = 0; i < list.size(); i++) { + // System.out.println("===" + list.get(i)); + rev[i] = list.get(i); + System.out.println("版本===" + rev[i]); + } + table2.setValueAt(objectname, table2.getSelectedRow(), 2); + table2.setComboCell(table2.getSelectedRow(), 3, new com.connor.dfl.plm.table.MyComboBoxEditor2(rev)); + table2.setComboCell(table2.getSelectedRow(), 4, new com.connor.dfl.plm.table.MyComboBoxEditor2(rev)); + table2.setComboCell(table2.getSelectedRow(), 9, new DefaultCellEditor(WAPYJBox)); + table2.setComboCell(table2.getSelectedRow(), 11, new DefaultCellEditor(ZZYJBox)); + table2.setComboCell(table2.getSelectedRow(), 13, new DefaultCellEditor(SSYJBox)); + table2.setComboCell(table2.getSelectedRow(), 15, new DefaultCellEditor(CLYJBox)); + + } else { + javax.swing.JOptionPane.showMessageDialog(null, "输入品号有误或该品写没有版本", "系统提示", + javax.swing.JOptionPane.WARNING_MESSAGE); + + setValueAt("", table2.getSelectedRow(), 2); + setValueAt("", table2.getSelectedRow(), 3); + } + } + } catch (Exception e) { + System.out.println("eeee="+e.getMessage()); + e.printStackTrace(); + } + Vector rowVector = (Vector) dataVector.elementAt(row); + rowVector.setElementAt(value, col); + fireTableCellUpdated(row, col); + + } + }; + + + table2 = new MyTable() { + @Override + public boolean isCellEditable(int row, int column) { + if(column == 0) { + return false; + } + return true; + } + + }; + + + + table2.setModel(model2); + table2.setColumnModel(getColumn(table2, new int[] { 90, 180, 180, 180,180,180,180, 180, 180,180,180,180, 180, 180,180,180 })); + table2.setRowHeight(50); + + + + + + tcr = new DefaultTableCellRenderer(); + tcr.setHorizontalAlignment(SwingConstants.CENTER); + table1.setBorder(new LineBorder(Color.BLACK)); + table1.setDefaultRenderer(Object.class, tcr); + table2.setBorder(new LineBorder(Color.BLACK)); + table2.setDefaultRenderer(Object.class, tcr); + table2.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + + + addButton = new JButton("添加"); + delButton = new JButton("删除"); + + List listdetils = getChangeDetail(name); + if(listdetils.size()>0) { + + for(int j = 0;j< listdetils.size();j++) { + + model2.addRow(new String[] { Integer.toString(rows1++) }); + + //int i =1; + //for(int j =0 ;j list =getChangeDetail(name); + int[] sRows = table2.getSelectedRows(); + int p ; + for (int j = sRows.length-1; j >=0 ; j--) { + String PH = (String) model2.getValueAt(sRows[j], 1); + System.out.println("=============品号"+PH); + delChangedetil(name, PH); + // Connection con = null; + // + // String sql = "delete from DFL_CHANGEDETAILS where PH=?"; + // System.out.println(sql); + // try { + // con = ConnectionFun(); + // PreparedStatement prepStmt = conn.prepareStatement(sql); + // prepStmt.setString(1,PH); + // prepStmt.executeUpdate(); + // // + // int result =prepStmt.executeUpdate();// 返回值代表收到影响的行数 + // if(result>0) { + // System.out.println("删除成功"); + // }else { + // System.out.println("删除失败"); + // } + // // + // + // //p=prepStmt.executeUpdate(); + // + // + // + // // Statement stmt=conn.createStatement();//创建Statement对象 + // // stmt.executeUpdate(sql);//执行sql语句 + // System.out.println("数据库删除成功"); + // } catch (Exception ex) { + // ex.printStackTrace(); + // } finally { + // try { + // con.close(); + // } catch (Exception ex) { + // ex.printStackTrace(); + // } + // } + + // for(int k=0 ;k 0) { + ChangeOrderBean bn = (ChangeOrderBean) list.get(list.size()-1); + System.out.println(bn.getApplyName()); + table1.setValueAt(bn.getApplyName(),0, 1); + table1.setValueAt(bn.getApplyDate(),0, 5); + table1.setValueAt(bn.getProjectCode(),8, 1); + table1.setValueAt(bn.getClientNae(),1, 5); + table1.setValueAt(bn.getProductDepartment(),3, 1); + table1.setValueAt(bn.getProductName(),1, 1); + table1.setValueAt(bn.getProjectModel(),1, 3); + //受影响的零部件 + table1.setValueAt(bn.getAffectedPart(),6, 1); + + table1.setValueAt(bn.getChangeType(),4, 1); + table1.setValueAt(bn.getProductType(),4, 3); + table1.setValueAt(bn.getErrorType(),4, 5); + table1.setValueAt(bn.getDutyDepartment(),3, 3); + table1.setValueAt(bn.getDutyMan(),3, 5); + table1.setValueAt(bn.getChangeReason(),9, 1); + table1.setValueAt(bn.getSalseClassify(),5, 3); + table1.setValueAt(bn.getPriceBooking(),5, 1); + table1.setValueAt(bn.getIsNotProductLoss(),5, 5); + table1.setValueAt(bn.getReceiveClassify(),7, 3); + table1.setValueAt(bn.getWarehouseCode(),2, 1); + //账套 + table1.setValueAt(bn.getAccountSet(),10, 1); + //通知紧急程度 + table1.setValueAt(bn.getNotifyEmergencyProcedures(),2, 3); + + table1.setValueAt(bn.getDrawingTo(),7, 1); + + table1.setValueAt(bn.getChangeListCode(),0, 3); + table1.setValueAt(bn.getTZChangeType(),2, 5); + //table1.setValueAt(bn.getSUOSU_ProductDepartment(),6, 1); + table1.setValueAt(bn.getProjectState(),7, 5); + //table2 添加行加入数 + } + } + + + //保存时提交到数据库 + public void insertMes(ChangeOrderBean bn) { + Connection con = null; + PreparedStatement stmt=null; + String sql = "insert into DFL_CHANGEFORM values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + try { + con = ConnectionFun(); + stmt = con.prepareStatement(sql); + + stmt.setString(1,bn.getObjectCode()); + stmt.setString(2,bn.getApplyName()); + stmt.setString(3,bn.getApplyDate()); + stmt.setString(4,bn.getProjectCode()); + stmt.setString(5,bn.getClientNae()); + stmt.setString(6,bn.getProductDepartment()); + stmt.setString(7,bn.getProductName()); + + stmt.setString(8,bn.getProjectModel()); + stmt.setString(9,bn.getAffectedPart()); + stmt.setString(10,bn.getChangeType()); + stmt.setString(11,bn.getProductType()); + + + stmt.setString(12,bn.getErrorType()); + stmt.setString(13,bn.getDutyDepartment()); + stmt.setString(14,bn.getDutyMan()); + + stmt.setString(15,bn.getChangeReason()); + + stmt.setString(16,bn.getSalseClassify()); + + stmt.setString(17,bn.getPriceBooking()); + + stmt.setString(18,bn.getIsNotProductLoss()); + stmt.setString(19,bn.getReceiveClassify()); + stmt.setString(20,bn.getWarehouseCode()); + stmt.setString(21,bn.getAccountSet()); + + stmt.setString(22,bn.getNotifyEmergencyProcedures()); + stmt.setString(23,bn.getDrawingTo()); + stmt.setString(24,bn.getChangeListCode()); + + stmt.setString(25,bn.getTZChangeType()); + stmt.setString(26,bn.getSUOSU_ProductDepartment()); + stmt.setString(27,bn.getProjectState()); + stmt.executeUpdate() ; + System.out.println("数据插入数据库完成"); + + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + + } + + + + + + /** + * 插入更改明细 + */ + + + + public void insertChangeDetailsMes(ChangeDetils cd) { + Connection con = null; + PreparedStatement stmt=null; + String sql = "insert into DFL_CHANGEDETAILS values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + try { + con = ConnectionFun(); + stmt = con.prepareStatement(sql); + stmt.setString(1,cd.getObjectCode()); + stmt.setString(2,cd.getPH()); + stmt.setString(3,cd.getPM()); + stmt.setString(4,cd.getYBB()); + stmt.setString(5,cd.getXBB()); + stmt.setString(6,cd.getYSL()); + stmt.setString(7,cd.getXSL()); + stmt.setString(8,cd.getBGSL()); + stmt.setString(9,cd.getWZPSL()); + stmt.setString(10,cd.getWZPUJ()); + stmt.setString(11,cd.getZZSL()); + stmt.setString(12,cd.getZZYJ()); + stmt.setString(13,cd.getSCSL()); + stmt.setString(14,cd.getSSYJ()); + stmt.setString(15,cd.getCKSL()); + stmt.setString(16,cd.getCLYJ()); + stmt.executeUpdate() ; + System.out.println("数据插入数据库完成"); + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + + } + + //删除时间 + public void del_date() { + Connection con = null; + String sql = "delete from dfl_changetime"; + System.out.println(sql); + try { + con = ConnectionFun(); + PreparedStatement prepStmt = conn.prepareStatement(sql); + prepStmt.executeUpdate(); + System.out.println("数据库删除成功"); + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + + + + + public void delChangeForm(String id) { + Connection con = null; + String sql = "delete from dfl_changeform where objectCode=?"; + System.out.println(sql); + try { + con = ConnectionFun(); + PreparedStatement prepStmt = conn.prepareStatement(sql); + prepStmt.setString(1,id); + prepStmt.executeUpdate(); + System.out.println("数据库删除成功"); + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + + + + + + + + public void delChangedetil(String id ,String ph) { + Connection con = null; + String sql = "delete from DFL_CHANGEDETAILS where objectCode=? and PH = ?"; + System.out.println(sql); + try { + con = ConnectionFun(); + + PreparedStatement prepStmt = conn.prepareStatement(sql); + prepStmt.setString(1,id); + prepStmt.setString(2,ph); + prepStmt.executeUpdate(); + + // Statement stmt=conn.createStatement();//创建Statement对象 + // stmt.executeUpdate(sql);//执行sql语句 + System.out.println("数据库删除成功"); + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + + + } + + + } + + + + public void delAllChangedetil(String id ) { + Connection con = null; + String sql = "delete from DFL_CHANGEDETAILS where objectCode=?"; + System.out.println(sql); + try { + con = ConnectionFun(); + + PreparedStatement prepStmt = conn.prepareStatement(sql); + prepStmt.setString(1,id); + + prepStmt.executeUpdate(); + + // Statement stmt=conn.createStatement();//创建Statement对象 + // stmt.executeUpdate(sql);//执行sql语句 + System.out.println("数据库删除成功"); + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + + + } + + + } + + + + + + //查找数据库中是都有该对象 + + public int ifcountform(String id) { + int i = 0; + Connection con = null; + PreparedStatement stmt=null; + String sql = "select * from DFL_CHANGEFORM where objectCode=?"; + try { + con = ConnectionFun(); + stmt = con.prepareStatement(sql); + ResultSet rs=null; + stmt.setString(1,id); + rs=stmt.executeQuery(); + while(rs.next()) { + i=i+1; + + } + + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + return i; + } + //统计数量 + public int ifcountdetial(String id) { + int i = 0; + Connection con = null; + PreparedStatement stmt=null; + String sql = "select * from DFL_CHANGEDETAILS where objectCode=?"; + try { + con = ConnectionFun(); + stmt = con.prepareStatement(sql); + ResultSet rs=null; + stmt.setString(1,id); + rs=stmt.executeQuery(); + while(rs.next()) { + i=i+1; + + } + + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + return i; + } + + + + + + /** + * JTable设置列宽 + */ + public static TableColumnModel getColumn(JTable table, int[] width) { + TableColumnModel columns = table.getColumnModel(); + for (int i = 0; i < width.length; i++) { + TableColumn column = columns.getColumn(i); + column.setPreferredWidth(width[i]); + } + return columns; + } + + + + + class MyButtonEditor extends DefaultCellEditor { + protected DateButton button; + + public MyButtonEditor(JCheckBox checkBox) { + super(checkBox); + button = new DateButton(); + } + + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, + int column) { + if (isSelected) { + button.setForeground(table.getSelectionForeground()); + button.setBackground(table.getSelectionBackground()); + } else { + button.setForeground(table.getForeground()); + button.setBackground(table.getBackground()); + } + return button; + } + } + + + + class MyTable extends JTable { + int myRow = -1, myCol = -1; + TableCellEditor myEditor; + Map map = new HashMap(); + + public void setComboCell(int r, int c, TableCellEditor ce) { + this.myRow = r; + this.myCol = c; + this.myEditor = ce; + map.put(new Point(r, c), ce); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + System.out.println(row + "," + column + ";" + myRow + "," + myCol + "," + myEditor); + + Point point = new Point(row, column); + if (map.containsKey(point)) { + return map.get(point); + } else { + return super.getCellEditor(row, column); + } + } + } + + /** + * 通过查询构建器查询项目对象 + * + * @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/dfl/plm/table/ButtonEditor.java b/src/com/connor/dfl/plm/table/ButtonEditor.java new file mode 100644 index 0000000..1a79eeb --- /dev/null +++ b/src/com/connor/dfl/plm/table/ButtonEditor.java @@ -0,0 +1,55 @@ +package com.connor.dfl.plm.table; + +import java.awt.Component; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.swing.DefaultCellEditor; +import javax.swing.JCheckBox; +import javax.swing.JTable; + +import com.teamcenter.rac.util.DateButton; + +public class ButtonEditor extends DefaultCellEditor { + protected DateButton button; + private String label; + private boolean isPushed; + + public ButtonEditor(JCheckBox checkBox) { + super(checkBox); + button = new DateButton(); + + } + + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, int row, int column) { + if (isSelected) { + button.setForeground(table.getSelectionForeground()); + button.setBackground(table.getSelectionBackground()); + } else { + button.setForeground(table.getForeground()); + button.setBackground(table.getBackground()); + } + + return button; + } + + public Object getCellEditorValue() { + //yyyy年MM月dd日 + SimpleDateFormat format=new SimpleDateFormat("yyyy年MM月dd日"); + SimpleDateFormat format2=new SimpleDateFormat("MM月"); + SimpleDateFormat format3=new SimpleDateFormat("dd日"); + Date data = new Date(); + System.out.println("aaa===>"+format2.format(data)); + System.out.println("bbb===>"+format3.format(data)); + System.out.println("ccc===>"+format.format(data)); + + System.out.println("时间=="+button.getDate());//Mon Aug 06 16:06:25 CST 2018 + if(button.getDate()==null){ + return null; + }else + return format.format(button.getDate());//监听判断 + //return format.format(button.getDate()); + } + +} \ No newline at end of file diff --git a/src/com/connor/dfl/plm/table/ButtonEditor2.java b/src/com/connor/dfl/plm/table/ButtonEditor2.java new file mode 100644 index 0000000..80ce77b --- /dev/null +++ b/src/com/connor/dfl/plm/table/ButtonEditor2.java @@ -0,0 +1,48 @@ +package com.connor.dfl.plm.table; + +import java.awt.Component; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.swing.DefaultCellEditor; +import javax.swing.JCheckBox; +import javax.swing.JTable; + +import com.teamcenter.rac.util.DateButton; + +public class ButtonEditor2 extends DefaultCellEditor { + + protected DateButton button; + private String label; + private boolean isPushed; + + public ButtonEditor2(JCheckBox checkBox) { + super(checkBox); + button = new DateButton(); + + } + + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, int row, int column) { + if (isSelected) { + button.setForeground(table.getSelectionForeground()); + button.setBackground(table.getSelectionBackground()); + } else { + button.setForeground(table.getForeground()); + button.setBackground(table.getBackground()); + } + + return button; + } + + public Object getCellEditorValue() { + //yyyy年MM月dd日 HH:mm + SimpleDateFormat format=new SimpleDateFormat("HH:mm"); + Date data = new Date(); + System.out.println("ccc===>"+format.format(data)); + + return format.format(button.getDate()); + } + + +} diff --git a/src/com/connor/dfl/plm/table/CTMap.java b/src/com/connor/dfl/plm/table/CTMap.java new file mode 100644 index 0000000..738deab --- /dev/null +++ b/src/com/connor/dfl/plm/table/CTMap.java @@ -0,0 +1,197 @@ +package com.connor.dfl.plm.table; + +import java.awt.Dimension; +import java.util.Vector; + +import javax.swing.event.TableModelEvent; +import javax.swing.table.DefaultTableModel; + +public class CTMap extends DefaultTableModel implements CellSpan { + protected int rowSize; + protected int columnSize; + protected int[][][] span; // CellSpan + + public int[] getSpan(int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) { + int[] ret_code = { 1, 1 }; + return ret_code; + } + return span[row][column]; + } + + public void setSpan(int[] span, int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return; + this.span[row][column] = span; + } + + public boolean isVisible(int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return false; + if ((span[row][column][CellSpan.COLUMN] < 1) || (span[row][column][CellSpan.ROW] < 1)) + return false; + return true; + } + + public void combine(int[] rows, int[] columns) { + // TODO Auto-generated method stub + + int rowSpan = rows.length; + int columnSpan = columns.length; + int startRow = rows[0]; + int startColumn = columns[0]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + if ((span[startRow + i][startColumn + j][CellSpan.COLUMN] != 1) + || (span[startRow + i][startColumn + j][CellSpan.ROW] != 1)) { + // System.out.println("can't combine"); + return; + } + } + } + for (int i = 0, ii = 0; i < rowSpan; i++, ii--) { + for (int j = 0, jj = 0; j < columnSpan; j++, jj--) { + span[startRow + i][startColumn + j][CellSpan.COLUMN] = jj; + span[startRow + i][startColumn + j][CellSpan.ROW] = ii; + // System.out.println("r " +ii +" c " +jj); + } + } + span[startRow][startColumn][CellSpan.COLUMN] = columnSpan; + span[startRow][startColumn][CellSpan.ROW] = rowSpan; + } + + public void setSize(Dimension size) { + columnSize = size.width; + rowSize = size.height; + span = new int[rowSize][columnSize][2]; // 2: COLUMN,ROW + initValue(); + } + + protected boolean isOutOfBounds(int row, int column) { + if ((row < 0) || (rowSize <= row) || (column < 0) || (columnSize <= column)) { + return true; + } + return false; + } + + + + public void addRow() { + + Vector newData = new Vector(getColumnCount()); + dataVector.add(newData); + + // + newRowsAdded(new TableModelEvent(this, getRowCount() - 1, getRowCount() - 1, TableModelEvent.ALL_COLUMNS, + TableModelEvent.INSERT)); + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows + 1][numColumns][2]; + System.arraycopy(oldSpan, 0, span, 0, numRows); + for (int i = 0; i < numColumns; i++) { + span[numRows][i][CellSpan.COLUMN] = 1; + span[numRows][i][CellSpan.ROW] = 1; + } + rowSize = span.length; + } + public void addColumn(Object columnName) { + + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows][numColumns + 1][2]; + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[0].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + + columnSize = span[0].length; + addColumn(columnName, (Vector) null); + } + + + public void insertRow(int row) { + Vector rowData = new Vector(getColumnCount()); + + dataVector.insertElementAt(rowData, row); + System.out.println("size:" + dataVector.size()); + + // + newRowsAdded(new TableModelEvent(this, row, row, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT)); + int[][][] newSpan = new int[span.length + 1][span[0].length][2]; + + int numRows = span.length; + int numColumns = span[0].length; + for (int i = 0; i < newSpan.length; i++) { + if (i < row) { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = span[i][j][0]; + newSpan[i][j][1] = span[i][j][1]; + } + } else if (i == row) { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = 1; + newSpan[i][j][1] = 1; + } + } else { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = span[i - 1][j][0]; + newSpan[i][j][1] = span[i - 1][j][1]; + } + } + } + span = newSpan; + rowSize = span.length; + } + + + public CTMap(int numRows, int numColumns) { + Vector names = new Vector(numColumns); + names.setSize(numColumns); + setColumnIdentifiers(names); + dataVector = new Vector(); + setNumRows(numRows); + setSize(new Dimension(numColumns, numRows)); + } + + protected void initValue() { + System.out.println(span.length); + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[i].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + } + + public void split(int row, int column) { + if (isOutOfBounds(row, column)) + return; + int columnSpan = span[row][column][CellSpan.COLUMN]; + int rowSpan = span[row][column][CellSpan.ROW]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + span[row + i][column + j][CellSpan.COLUMN] = 1; + span[row + i][column + j][CellSpan.ROW] = 1; + } + } + } + + public void removeCol() { + + columnIdentifiers.removeElementAt(columnIdentifiers.size()-1); + dataVector.setSize(getRowCount()); + + for (int i = 0; i < getRowCount()-1; i++) { + + ((Vector)dataVector.elementAt(i)).setSize(getColumnCount()); + } + fireTableStructureChanged(); + } +} diff --git a/src/com/connor/dfl/plm/table/CTUI.java b/src/com/connor/dfl/plm/table/CTUI.java new file mode 100644 index 0000000..6378b67 --- /dev/null +++ b/src/com/connor/dfl/plm/table/CTUI.java @@ -0,0 +1,94 @@ +package com.connor.dfl.plm.table; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; + +import javax.swing.JComponent; +import javax.swing.plaf.basic.BasicTableUI; +import javax.swing.table.TableCellRenderer; + +public class CTUI extends BasicTableUI { + + public void paint(Graphics g, JComponent c){ + Rectangle oldClipBounds = g.getClipBounds(); + Rectangle clipBounds = new Rectangle(oldClipBounds); + int tableWidth = table.getColumnModel().getTotalColumnWidth(); + clipBounds.width = Math.min(clipBounds.width, tableWidth); + g.setClip(clipBounds); + + int firstIndex = table.rowAtPoint(new Point(0, clipBounds.y)); + int lastIndex = table.getRowCount() - 1; + Rectangle rowRect = new Rectangle(0, 0, tableWidth, table.getRowHeight() + table.getRowMargin()); + rowRect.y = firstIndex * rowRect.height; + for (int index = firstIndex; index <= lastIndex; index++) { + if (rowRect.intersects(clipBounds)) { + // System.out.println(); // debug + // System.out.print("" + index +": "); // row + paintRow(g, index); + } + rowRect.y += rowRect.height; + } + g.setClip(oldClipBounds); + } + + private void paintRow(Graphics g, int row) { + Rectangle rect = g.getClipBounds(); + boolean drawn = false; + CellSpan cellAtt = (CellSpan) table.getModel(); + int numColumns = table.getColumnCount(); + + for (int column = 0; column < numColumns; column++) { + Rectangle cellRect = table.getCellRect(row, column, true); + + int cellRow, cellColumn; + if (cellAtt.isVisible(row, column)) { + cellRow = row; + cellColumn = column; + // System.out.print(" "+column+" "); // debug + } else { + cellRow = row + cellAtt.getSpan(row, column)[CellSpan.ROW]; + cellColumn = column + cellAtt.getSpan(row, column)[CellSpan.COLUMN]; + // System.out.print(" ("+column+")"); // debug + } + if (cellRect.intersects(rect)) { + drawn = true; + paintCell(g, cellRect, cellRow, cellColumn); + } else { + if (drawn) + break; + } + } + + } + + private void paintCell(Graphics g, Rectangle cellRect, int row, int column) { + int spacingHeight = table.getRowMargin(); + int spacingWidth = table.getColumnModel().getColumnMargin(); + + Color c = g.getColor(); + g.setColor(table.getGridColor()); + g.drawRect(cellRect.x, cellRect.y, cellRect.width - 1, cellRect.height - 1); + g.setColor(c); + + cellRect.setBounds(cellRect.x + spacingWidth / 2, cellRect.y + spacingHeight / 2, cellRect.width - spacingWidth, + cellRect.height - spacingHeight); + + if (table.isEditing() && table.getEditingRow() == row && table.getEditingColumn() == column) { + Component component = table.getEditorComponent(); + component.setBounds(cellRect); + component.validate(); + } else { + TableCellRenderer renderer = table.getCellRenderer(row, column); + Component component = table.prepareRenderer(renderer, row, column); + + if (component.getParent() == null) { + rendererPane.add(component); + } + rendererPane.paintComponent(g, component, table, cellRect.x, cellRect.y, cellRect.width, cellRect.height, + true); + } + } +} \ No newline at end of file diff --git a/src/com/connor/dfl/plm/table/CTable.java b/src/com/connor/dfl/plm/table/CTable.java new file mode 100644 index 0000000..59ab063 --- /dev/null +++ b/src/com/connor/dfl/plm/table/CTable.java @@ -0,0 +1,148 @@ +package com.connor.dfl.plm.table; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +public class CTable extends JTable { + Map map; + public CTable(TableModel model) { + super(model); + setUI(new CTUI()); + getTableHeader().setReorderingAllowed(false); // 设置表格列不可重排 + setCellSelectionEnabled(true); // 设置单元格选择方式 + setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); // 设置选择模式 一次选择一个连续的索引范围 只能选择连续的几项 + //test自适应 + setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); // 设置 + map=new HashMap(); + } + public String getToolTipText(MouseEvent e) { + int row=this.rowAtPoint(e.getPoint()); + int col=this.columnAtPoint(e.getPoint()); + String tiptextString=null; + if(row>-1 && col>-1){ + Object value=this.getValueAt(row, col); + if(null!=value && !"".equals(value)) + tiptextString=value.toString();//悬浮显示单元格内容 + } + return tiptextString; + } + public Rectangle getCellRect(int row, int column, boolean includeSpacing) { + Rectangle sRect = super.getCellRect(row, column, includeSpacing); + if ((row < 0) || (column < 0) || (getRowCount() <= row) || (getColumnCount() <= column)) { + return sRect; + } + CellSpan cellAtt = (CellSpan) getModel(); + if (!cellAtt.isVisible(row, column)) { + int temp_row = row; + int temp_column = column; + row += cellAtt.getSpan(temp_row, temp_column)[CellSpan.ROW]; + column += cellAtt.getSpan(temp_row, temp_column)[CellSpan.COLUMN]; + } + int[] n = cellAtt.getSpan(row, column); + + int index = 0; + int columnMargin = getColumnModel().getColumnMargin(); + Rectangle cellFrame = new Rectangle(); + int aCellHeight = rowHeight + rowMargin; + cellFrame.y = row * aCellHeight; + cellFrame.height = n[CellSpan.ROW] * aCellHeight; + + Enumeration eeration = getColumnModel().getColumns(); + while (eeration.hasMoreElements()) { + TableColumn aColumn = (TableColumn) eeration.nextElement(); + cellFrame.width = aColumn.getWidth() + columnMargin; + if (index == column) + break; + cellFrame.x += cellFrame.width; + index++; + } + for (int i = 0; i < n[CellSpan.COLUMN] - 1; i++) { + TableColumn aColumn = (TableColumn) eeration.nextElement(); + cellFrame.width += aColumn.getWidth() + columnMargin; + } + + if (!includeSpacing) { + Dimension spacing = getIntercellSpacing(); + cellFrame.setBounds(cellFrame.x + spacing.width / 2, cellFrame.y + spacing.height / 2, + cellFrame.width - spacing.width, cellFrame.height - spacing.height); + } + return cellFrame; + } + + private int[] rowColumnAtPoint(Point point) { + int[] retValue = { -1, -1 }; + int row = point.y / (rowHeight + rowMargin); + if ((row < 0) || (getRowCount() <= row)) + return retValue; + int column = getColumnModel().getColumnIndexAtX(point.x); + + CellSpan cellAtt = (CellSpan) getModel(); + + if (cellAtt.isVisible(row, column)) { + retValue[CellSpan.COLUMN] = column; + retValue[CellSpan.ROW] = row; + return retValue; + } + retValue[CellSpan.COLUMN] = column + cellAtt.getSpan(row, column)[CellSpan.COLUMN]; + retValue[CellSpan.ROW] = row + cellAtt.getSpan(row, column)[CellSpan.ROW]; + return retValue; + } + + public int rowAtPoint(Point point) { + return rowColumnAtPoint(point)[CellSpan.ROW]; + } + + public int columnAtPoint(Point point) { + return rowColumnAtPoint(point)[CellSpan.COLUMN]; + } + + public void columnSelectionChanged(ListSelectionEvent e) { + repaint(); + } + + public void valueChanged(ListSelectionEvent e) { + int firstIndex = e.getFirstIndex(); + int lastIndex = e.getLastIndex(); + if (firstIndex == -1 && lastIndex == -1) { // Selection cleared. + repaint(); + } + Rectangle dirtyRegion = getCellRect(firstIndex, 0, false); + int numCoumns = getColumnCount(); + int index = firstIndex; + for (int i = 0; i < numCoumns; i++) { + dirtyRegion.add(getCellRect(index, i, false)); + } + index = lastIndex; + for (int i = 0; i < numCoumns; i++) { + dirtyRegion.add(getCellRect(index, i, false)); + } + repaint(dirtyRegion.x, dirtyRegion.y, dirtyRegion.width, dirtyRegion.height); + } + public void setCombo(int row,int col,TableCellEditor ce){ + map.put(new Point(row,col), ce); + } + public TableCellEditor getCellEditor(int row, int column){ + Point point = new Point(row,column); + if(map.containsKey(point)){ + return map.get(point); + }else{ + return super.getCellEditor(row, column); + } + } + public void setRowHeight(int row, int rowHeight) { + super.setRowHeight(row, rowHeight); + } +} + diff --git a/src/com/connor/dfl/plm/table/CTest.java b/src/com/connor/dfl/plm/table/CTest.java new file mode 100644 index 0000000..98bdddd --- /dev/null +++ b/src/com/connor/dfl/plm/table/CTest.java @@ -0,0 +1,41 @@ +package com.connor.dfl.plm.table; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JScrollPane; + +//import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +public class CTest { + static int[] rows; + static JScrollPane pane; + + public static void main(String args[]) { + final CTMap map = new CTMap(5,5); + final CTable table = new CTable(map); + table.setDefaultRenderer(Object.class, new TableCellTextAreaRenderer()); + pane = new JScrollPane(table); + JButton button = new JButton("add"); + table.setShowGrid(false); + final JDialog dialog = new JDialog(); + dialog.setLayout(new BorderLayout()); + button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + table.setRowHeight(2,50); + table.revalidate(); + table.repaint(); + + } + }); + dialog.add(pane, BorderLayout.CENTER); + dialog.add(button, BorderLayout.SOUTH); + dialog.setPreferredSize(new Dimension(500,500)); + dialog.show(); + } +} \ No newline at end of file diff --git a/src/com/connor/dfl/plm/table/CellSpan.java b/src/com/connor/dfl/plm/table/CellSpan.java new file mode 100644 index 0000000..be7e174 --- /dev/null +++ b/src/com/connor/dfl/plm/table/CellSpan.java @@ -0,0 +1,14 @@ +package com.connor.dfl.plm.table; + +interface CellSpan { + public final int ROW = 0; + public final int COLUMN = 1; + + public int[] getSpan(int row, int column); + public void setSpan(int[] span, int row, int column); + + public boolean isVisible(int row, int column); + + public void combine(int[] rows, int[] columns); + +} \ No newline at end of file diff --git a/src/com/connor/dfl/plm/table/DefaultModel.java b/src/com/connor/dfl/plm/table/DefaultModel.java new file mode 100644 index 0000000..9d54e35 --- /dev/null +++ b/src/com/connor/dfl/plm/table/DefaultModel.java @@ -0,0 +1,96 @@ +package com.connor.dfl.plm.table; + +import java.awt.Dimension; +import java.util.Vector; + +import javax.swing.table.DefaultTableModel; + +public class DefaultModel extends DefaultTableModel implements CellSpan { + protected int rowSize; + protected int columnSize; + protected int[][][] span; // CellSpan + public int[] getSpan(int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) { + int[] ret_code = { 1, 1 }; + return ret_code; + } + return span[row][column]; + } + + public void setSpan(int[] span, int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return; + this.span[row][column] = span; + } + + public boolean isVisible(int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return false; + if ((span[row][column][CellSpan.COLUMN] < 1) || (span[row][column][CellSpan.ROW] < 1)) + return false; + return true; + } + + public void combine(int[] rows, int[] columns) { + // TODO Auto-generated method stub + int rowSpan = rows.length; + int columnSpan = columns.length; + int startRow = rows[0]; + int startColumn = columns[0]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + if ((span[startRow + i][startColumn + j][CellSpan.COLUMN] != 1) + || (span[startRow + i][startColumn + j][CellSpan.ROW] != 1)) { + // System.out.println("can't combine"); + return; + } + } + } + for (int i = 0, ii = 0; i < rowSpan; i++, ii--) { + for (int j = 0, jj = 0; j < columnSpan; j++, jj--) { + span[startRow + i][startColumn + j][CellSpan.COLUMN] = jj; + span[startRow + i][startColumn + j][CellSpan.ROW] = ii; + // System.out.println("r " +ii +" c " +jj); + } + } + span[startRow][startColumn][CellSpan.COLUMN] = columnSpan; + span[startRow][startColumn][CellSpan.ROW] = rowSpan; + } + + public void setSize(Dimension size) { + columnSize = size.width; + rowSize = size.height; + span = new int[rowSize][columnSize][2]; // 2: COLUMN,ROW + initValue(); + } + + protected void initValue() { + System.out.println(span.length); + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[i].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + } + + protected boolean isOutOfBounds(int row, int column) { + if ((row < 0) || (rowSize <= row) || (column < 0) || (columnSize <= column)) { + return true; + } + return false; + } + + public DefaultModel(int numRows, int numColumns) { + Vector names = new Vector(numColumns); + names.setSize(numColumns); + setColumnIdentifiers(names); + dataVector = new Vector(); + setNumRows(numRows); + setSize(new Dimension(numColumns, numRows)); + } + +} diff --git a/src/com/connor/dfl/plm/table/MyComboBoxEditor2.java b/src/com/connor/dfl/plm/table/MyComboBoxEditor2.java new file mode 100644 index 0000000..2c9186b --- /dev/null +++ b/src/com/connor/dfl/plm/table/MyComboBoxEditor2.java @@ -0,0 +1,17 @@ +/** + * + */ +package com.connor.dfl.plm.table; + +import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; + +/** + * @author 61666 + * + */ +public class MyComboBoxEditor2 extends DefaultCellEditor { + public MyComboBoxEditor2(String[] items) { + super(new JComboBox(items)); + } +} \ No newline at end of file diff --git a/src/com/connor/dfl/plm/table/TableCellTextAreaRenderer.java b/src/com/connor/dfl/plm/table/TableCellTextAreaRenderer.java new file mode 100644 index 0000000..4003f95 --- /dev/null +++ b/src/com/connor/dfl/plm/table/TableCellTextAreaRenderer.java @@ -0,0 +1,70 @@ +package com.connor.dfl.plm.table; + +import java.awt.Color; +import java.awt.Component; + +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.table.TableCellRenderer; + +public class TableCellTextAreaRenderer extends JTextArea implements TableCellRenderer { + public TableCellTextAreaRenderer() { + setLineWrap(true); + setWrapStyleWord(true); + + } + + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + 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); + } + setBackground(Color.white); + setForeground(Color.black); + if(isSelected){ + setBackground(new Color(0, 120, 215)); + setForeground(Color.white); + } + if (table.getRowHeight(row) != maxPreferredHeight) // 少了这行则处理器瞎忙 + table.setRowHeight(row, maxPreferredHeight); + + setText(value == null ? "" : value.toString()); + return this; + } + +// @Override +// public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, +// int row, int column) { +// // TODO Auto-generated method stub +// 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); +// } +// setBorder(BorderFactory.createLineBorder(Color.white)); +// setBackground(Color.white); +// setForeground(Color.black); +// if(isSelected){ +// setBackground(new Color(0, 120, 215)); +// setForeground(Color.white); +// } +// String val=(String) table.getValueAt(row, column); +// int w=0; +// if(val!=null){ +// w=val.length()*6/table.getColumn(table.getColumnName(column)).getWidth(); +// } +// if(w!=0){ +// //System.out.println("height:"+table.getRowHeight()*(w+1)); +// table.setRowHeight(row,table.getRowHeight()*(w+1)); +// } +// +// +// setText(value == null ? "" : value.toString()); +// return this; +// } +} \ No newline at end of file diff --git a/src/com/connor/dfl/plm/util/AutoSign.java b/src/com/connor/dfl/plm/util/AutoSign.java new file mode 100644 index 0000000..6e7e03b --- /dev/null +++ b/src/com/connor/dfl/plm/util/AutoSign.java @@ -0,0 +1,155 @@ +package com.connor.dfl.plm.util; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +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.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; + +import oracle.sql.BLOB; + +public class AutoSign { + // private TCSession session; + // AbstractAIFApplication app; + // + // + // public AutoSign(TCSession session, AbstractAIFApplication app) { + // this.session = session; + // this.app = app; + // } + // + + + + 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("DFL_AutoSignServer", obj); + System.out.println("=========uid" +obj[0]+ "=======" +obj[1]); + + + + } + + public Connection ConnectionFun(String url,String user,String password) throws SQLException { + Connection conn = null;// + + try { +// System.out.println(url); +// System.out.println(user); +// System.out.println(password); + Class.forName("oracle.jdbc.driver.OracleDriver"); + System.out.println("驱动加载成功"); + } catch (ClassNotFoundException e) { + System.out.println("驱动加载失败"); + } + + conn=DriverManager.getConnection(url,user,password); + + System.out.println("数据库连接成功"); + return conn; + + + } + + + + + + public void insertNewTxtFile(String filename,File file,String uid ,String user_id ,String url,String user,String password,String fun,String txt_pinhao,String zhangtao,String userID,String item_uid) { + Connection con = null; + PreparedStatement stmt=null; + ResultSet rs = null; + BufferedInputStream bis = null; + java.io.OutputStream out = null; + String tempPath = System.getProperty("java.io.tmpdir"); + String sqlNewdate ="insert into DFL_SEND_TXT_TO_ERP values(seq_on_DFL.nextval,'"+fun+"', '"+filename+"',empty_blob(),0,'"+uid+"' ,'"+user_id+"','"+txt_pinhao+"','"+zhangtao+"','"+userID+"','"+item_uid+"')"; + // insert into dfl_send_txt_to_erp VALUES(seq_on_DFL.nextval,'33','33',empty_blob(),2,'fdfdfdfd'); + //String sqlupdate="update DFL_SEND_TXT_TO_ERP SET TXTFILE=empty_blob() where myuid='"+uid+"' for update "; + String sql = "select * from DFL_SEND_TXT_TO_ERP where myuid ='"+uid+"' for update "; + String insert="update DFL_SEND_TXT_TO_ERP SET TXTFILE=? where myuid='"+uid+"'"; + + try { + con = ConnectionFun( url, user, password); + con.setAutoCommit(false); + stmt = con.prepareStatement(sqlNewdate); + stmt.executeUpdate(); + System.out.println("新的数据插入数据库完成"); + stmt.close(); + // stmt = con.prepareStatement(sqlupdate); + // + // stmt.executeUpdate(); + // stmt.close(); + stmt =con.prepareStatement(sql); + con.commit(); + rs = stmt.executeQuery(); + while(rs.next()) { + String ss = rs.getString(2); + System.out.println("-=================" + ss); + BLOB blob = (BLOB) rs.getBlob(4); + int size = blob.getBufferSize(); + bis = new BufferedInputStream(new FileInputStream(new File(tempPath + filename + ".txt")),size); + out = blob.getBinaryOutputStream(); + System.out.println(size); + + + byte b[]=new byte[size]; + int en=0; + + + while((en = bis.read(b,0,size))!=-1) { + out.write(b,0,en); + + } + out.flush(); + + stmt =con.prepareStatement(insert); + stmt.setBlob(1, blob); + //stmt.setString(2, uid); + stmt.executeUpdate(); + bis.close(); + out.close(); + con.commit(); + } + + + + + + + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + try { + + stmt.close(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + + + + + + + +} diff --git a/src/com/connor/dfl/plm/util/ClassAttributeBean.java b/src/com/connor/dfl/plm/util/ClassAttributeBean.java new file mode 100644 index 0000000..7425fbc --- /dev/null +++ b/src/com/connor/dfl/plm/util/ClassAttributeBean.java @@ -0,0 +1,56 @@ +package com.connor.dfl.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/dfl/plm/util/ClassProperty.java b/src/com/connor/dfl/plm/util/ClassProperty.java new file mode 100644 index 0000000..cc9062b --- /dev/null +++ b/src/com/connor/dfl/plm/util/ClassProperty.java @@ -0,0 +1,42 @@ +package com.connor.dfl.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/dfl/plm/util/ClassValueBean.java b/src/com/connor/dfl/plm/util/ClassValueBean.java new file mode 100644 index 0000000..c7c8f8a --- /dev/null +++ b/src/com/connor/dfl/plm/util/ClassValueBean.java @@ -0,0 +1,40 @@ +package com.connor.dfl.plm.util; + +public class ClassValueBean { + private String brand; + private String unit; + private String spec; + private String specs; + private String code; + public String getBrand() { + return brand; + } + public void setBrand(String brand) { + this.brand = brand; + } + public String getUnit() { + return unit; + } + public void setUnit(String unit) { + this.unit = unit; + } + public String getSpec() { + return spec; + } + public void setSpec(String spec) { + this.spec = spec; + } + public String getSpecs() { + return specs; + } + public void setSpecs(String specs) { + this.specs = specs; + } + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + +} diff --git a/src/com/connor/dfl/plm/util/ClassValueUtil.java b/src/com/connor/dfl/plm/util/ClassValueUtil.java new file mode 100644 index 0000000..4dbf6ff --- /dev/null +++ b/src/com/connor/dfl/plm/util/ClassValueUtil.java @@ -0,0 +1,258 @@ +package com.connor.dfl.plm.util; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.connor.dfl.plm.dfl019.ClassPropBean; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCClassificationService; +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.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; + +public class ClassValueUtil { + + + public static ClassValueBean getOutBuyPartValue(TCComponentItemRevision rev,List errList) { + // TODO Auto-generated method stub + ClassValueBean valueBean = new ClassValueBean(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + List vals = new ArrayList(); + StringBuilder sb = new StringBuilder(); + List classPropList = new ArrayList(); + TCClassificationService classificationService = session.getClassificationService(); + try { + String className = rev.getClassificationClass(); + if("".equals(className.trim())) { + errList.add(className); + MessageBox.post(rev.getStringProperty("item_id")+"该物料没有发送至分类,请先发送分类!!", + "提示", MessageBox.WARNING); + return null; + } + TCComponentICO[] icos = rev.getClassificationObjects(); + 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); + } + } + boolean have = true; + for (int i = 0; i < classPropList.size(); i++) { + ClassPropBean bean = classPropList.get(i); + String attrName = bean.propDisName; + System.out.println("attrName==========="+attrName); + String value = claMap.get(bean.propID); + if(bean.isLov) { + String lovValue = bean.lovMapping.get(value); + if("品牌".equals(attrName)) { + valueBean.setBrand(lovValue); + }else if("单位".equals(attrName)){ + valueBean.setUnit(lovValue); + } + else if(attrName.contains("规格")){ + String kaitou1 = attrName.substring(0,2); + //前两个字是否为规格 + if("规格".equals(kaitou1)) { + valueBean.setSpec(value); + } + } + else if(attrName.contains("订货码")){ + valueBean.setCode(lovValue); + }else { + if("/".equals(lovValue) || "null".equals(lovValue)) { + System.out.println("不进行拼接"); + continue; + } + sb.append(lovValue); + if(i < classPropList.size()-1) { + sb.append(";"); + } + } + }else { + if("品牌".equals(attrName)) { + valueBean.setBrand(value); + }else if("单位".equals(attrName)){ + valueBean.setUnit(value); + }else if(attrName.contains("规格")){ + String kaitou2 = attrName.substring(0,2); + //前两个字是否为规格 + if("规格".equals(kaitou2)) { + valueBean.setSpec(value); + } + }else if(attrName.contains("订货码")){ + valueBean.setCode(value); + }else { + if("/".equals(value) || "null".equals(value)) { + System.out.println("不进行拼接"); + continue; + } + sb.append(value); + if(i < classPropList.size()-1) { + sb.append(";"); + } + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + StringBuilder specSB = new StringBuilder(); + if(valueBean.getBrand() != null) { + if(!("".equals((valueBean.getBrand()).trim())) + && !("/".equals((valueBean.getBrand()).trim())) + && !("null".equals((valueBean.getBrand()).trim()))) { + specSB.append(valueBean.getBrand()); + specSB.append(";"); + } + } + if(valueBean.getSpec() != null) { + if(!("".equals((valueBean.getSpec()).trim())) + && !("/".equals((valueBean.getSpec()).trim())) + && !("null".equals((valueBean.getSpec()).trim()))) { + specSB.append(valueBean.getSpec()); + specSB.append(";"); + } + } + if(valueBean.getCode() != null) { + if(!("".equals((valueBean.getCode()).trim())) + && !("/".equals((valueBean.getCode()).trim())) + && !("null".equals((valueBean.getCode()).trim()))) { + specSB.append(valueBean.getCode()); + specSB.append(";"); + } + } + specSB.append(sb.toString()); + valueBean.setSpecs(specSB.toString()); + return valueBean; + } + + public static ClassValueBean getOutSourcePartValue(TCComponentItemRevision rev,List errList) { + // TODO Auto-generated method stub + ClassValueBean valueBean = new ClassValueBean(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + List vals = new ArrayList(); + StringBuilder sb = new StringBuilder(); + List classPropList = new ArrayList(); + TCClassificationService classificationService = session.getClassificationService(); + try { + String className = rev.getClassificationClass(); + if("".equals(className.trim())) { + errList.add(className); + MessageBox.post(rev.getStringProperty("item_id")+"该物料没有发送至分类,请先发送分类!!", + "提示", MessageBox.WARNING); + return null; + } + TCComponentICO[] icos = rev.getClassificationObjects(); + 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); + } + } + boolean have = true; + for (int i = 0; i < classPropList.size(); i++) { + ClassPropBean bean = classPropList.get(i); + String attrName = bean.propDisName; + System.out.println("attrName==========="+attrName); + String value = claMap.get(bean.propID); + if(bean.isLov) { + String lovValue = bean.lovMapping.get(value); + if("品牌".equals(attrName)) { + valueBean.setBrand(lovValue); + }else { + if("/".equals(lovValue) || "null".equals(lovValue)) { + System.out.println("不进行拼接"); + continue; + } + sb.append(lovValue); + if(i < classPropList.size()-1) { + sb.append(";"); + } + } + }else { + if("品牌".equals(attrName)) { + valueBean.setBrand(value); + }else { + if("/".equals(value) || "null".equals(value)) { + System.out.println("不进行拼接"); + continue; + } + sb.append(value); + if(i < classPropList.size()-1) { + sb.append(";"); + } + } + } + + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + StringBuilder specSB = new StringBuilder(); + if(valueBean.getBrand() != null) { + if(!("".equals((valueBean.getBrand()).trim())) + && !("/".equals((valueBean.getBrand()).trim())) + && !("null".equals((valueBean.getBrand()).trim()))) { + specSB.append(valueBean.getBrand()); + specSB.append(";"); + } + } + specSB.append(sb.toString()); + valueBean.setSpecs(specSB.toString()); + return valueBean; + } +} diff --git a/src/com/connor/dfl/plm/util/CodeBean.java b/src/com/connor/dfl/plm/util/CodeBean.java new file mode 100644 index 0000000..019b3a7 --- /dev/null +++ b/src/com/connor/dfl/plm/util/CodeBean.java @@ -0,0 +1,97 @@ +package com.connor.dfl.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/dfl/plm/util/CopyPropsBean.java b/src/com/connor/dfl/plm/util/CopyPropsBean.java new file mode 100644 index 0000000..f9227f3 --- /dev/null +++ b/src/com/connor/dfl/plm/util/CopyPropsBean.java @@ -0,0 +1,26 @@ +package com.connor.dfl.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/dfl/plm/util/DataBaseControl.java b/src/com/connor/dfl/plm/util/DataBaseControl.java new file mode 100644 index 0000000..efce79f --- /dev/null +++ b/src/com/connor/dfl/plm/util/DataBaseControl.java @@ -0,0 +1,735 @@ +package com.connor.dfl.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.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Vector; + +import com.connor.dfl.plm.dfl027.ChangeOwnerbean; +import com.connor.dfl.plm.dfl038.ChangeBean; +import com.connor.dfl.plm.forms.ChangeOrderBean; +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, + "DFL2_SQL_Connect"); + if (stringArray != null && stringArray.length == 3) { + strUrl = "jdbc:oracle:thin:@" + stringArray[0]; + strUserName = stringArray[1]; + strPassword = stringArray[2]; + } else { + MessageBox.post("未配置DFL2_SQL_Connect首选项,无法获得连接信息!", "错误", + MessageBox.ERROR); + } + + // 加载驱动 + try { + Class.forName(strDriver);// 通过反射加载驱动到内存 + } catch (ClassNotFoundException cnfe) { + cnfe.printStackTrace(); + } + + } + /** + * 构造器 + */ + public DataBaseControl(TCSession session,String connect) { + + String[] stringArray = session.getPreferenceService().getStringArray(4, + connect); + if (stringArray != null && stringArray.length == 3) { + strUrl = "jdbc:oracle:thin:@" + stringArray[0]; + strUserName = stringArray[1]; + strPassword = stringArray[2]; + } else { + MessageBox.post("未配置"+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; + } + /** + * 表查询3 + * + * @param strSQLQuery + * @return + */ + public ResultSet dbQuery3(String strSQLQuery) { + ResultSet rs_result = null; + if (conn == null) + openDataBase(); + try { + stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); + rs_result = stmt.executeQuery(strSQLQuery); + + } 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(); + MessageBox.post("数据库连接错误" + 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; + } + + + public String getTaskIdea(String uid) + throws Exception { + openDataBase(); + String query = "select IDEA from PLM_Perform_Task where PUID= ?"; + // 查询该id在数据库中的内容 + ResultSet rs = dbQuery2(query, new Object[] { uid}); + String taskIdea = ""; + if (rs.next()) { + taskIdea = rs.getString(1); + System.out.println("taskIdea=" + taskIdea); + } + + closeDataBase(); + + return taskIdea; + + } + public void setTaskIdea(String uid,String idea) + throws Exception { + openDataBase(); + String query = "select IDEA from PLM_Perform_Task where PUID= ?"; + // 查询该id在数据库中的内容 + ResultSet rs = dbQuery2(query, new Object[] { uid}); + if(rs.next()) { + String upin = "update PLM_Perform_Task set IDEA= ? where PUID= ?"; + dbModify2(upin, new Object[] { idea, uid }); + }else { + String upin = "insert into PLM_Perform_Task(PUID,IDEA) values ( ? , ? )"; + dbModify2(upin, new Object[] { uid, idea }); + } + closeDataBase(); + + } + + /** + * 获得流水码 + * + * @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; + + } + + //获取变更单信息 + + public List getChangeMesg(String product,String time1,String time2) throws SQLException { + List list = new ArrayList(); + if("全部".equals(product)) { + product = ""; + } + String sql = "select * from DFL_CHANGEFORM where PRODUCTDEPARTMENT like '%"+product+"%'";// + SimpleDateFormat df = new SimpleDateFormat("yyyy-M-d HH:mm"); + openDataBase(); + System.out.println("sql============"+sql); + ResultSet rs = dbQuery(sql); + while(rs.next()){ + try { + String dateStr = rs.getString(3); + System.out.println("date========"+rs.getString(3)); + if(dateStr == null) { + continue; + } + Date date = df.parse(rs.getString(3)); + Date date1 = df.parse(time1); + Date date2 = df.parse(time2); + if(date.after(date2) && date.before(date1)) { + System.out.println("date2========"+rs.getString(3)); + } + if(date.after(date1) && date.before(date2)) { + ChangeBean bn = new ChangeBean(); + bn.setApplyName(rs.getString(2)); + bn.setApplyDate(rs.getString(3)); + bn.setProjectCode(rs.getString(4)); + bn.setClientNae(rs.getString(5)); + bn.setProductName(rs.getString(7)); + bn.setProjectModel(rs.getString(8)); + bn.setChangeType(rs.getString(10)); + bn.setProductType(rs.getString(11)); + bn.setErrorType(rs.getString(12)); + bn.setDutyDepartment(rs.getString(13)); + bn.setDutyMan(rs.getString(14)); + bn.setChangeReason(rs.getString(15)); + bn.setSalseClassify(rs.getString(16)); + bn.setPriceBooking(rs.getString(17)); + bn.setIsNotProductLoss(rs.getString(18)); + bn.setReceiveClassify(rs.getString(19)); + bn.setWarehouseCode(rs.getString(20)); + bn.setAccountSet(rs.getString(21)); + bn.setNotifyEmergencyProcedures(rs.getString(22)); + bn.setDrawingTo(rs.getString(23)); + bn.setChangeListCode(rs.getString(24)); + bn.setTZChangeType(rs.getString(25)); + bn.setSUOSU_ProductDepartment(rs.getString(26)); + bn.setProjectState(rs.getString(27)); + list.add(bn); + } + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + closeDataBase(); + return list; + } + /** + * 获得流水码 + * + * @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; + + } + + /** + * 获取最大流水码 + * + */ + public String getMaxCode(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 * from (select * from pitem where pitem_id like '"+prefix+"%' order by pitem_id desc) where rownum<=1"; + // 查询该id在数据库中的内容 + ResultSet rs = dbQuery(query); + String lshstr = col; + String lsh = ""; + if (rs.next()) { + lsh = rs.getString(2); + System.out.println("sslsh=" + lsh); + if ("".equals(lsh)) { + throw new Exception("流水码为空!"); + } + lsh = lsh.substring(6); + int ls = Integer.parseInt(lsh) + 1;// 新的流水码数 + lshstr = ls + ""; + System.out.println("lshstr=" + lshstr); + 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 }); + 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 value + * 查询条件 + * @param sql + * 查询语句 + * @return + * @throws Exception + */ + public List getRecord(String sql) + throws Exception { + List list=new ArrayList<>(); + openDataBase(); + // 查询该id在数据库中的内容 + ResultSet rs = dbQuery(sql); + while (rs.next()) { + ChangeOwnerbean bean = new ChangeOwnerbean(); + bean.setZhangt(rs.getString(1)); + bean.setId(rs.getString(2)); + bean.setCustomerName(rs.getString(3)); + bean.setSpec(rs.getString(4)); + bean.setUnit(rs.getString(5)); + bean.setCangk(rs.getString(6)); + bean.setCangkName(rs.getString(7)); + bean.setNum(rs.getString(8)); + bean.setLocation(rs.getString(9)); + list.add(bean); + } + closeDataBase(); + return list; + } + // public List getRecord2(String value,String zhangT,String cangK,String sql) + // throws Exception { + // List list=new ArrayList<>(); + // openDataBase(); + // // 查询该id在数据库中的内容 + // ResultSet rs = dbQuery2(sql, new Object[] {value,zhangT,cangK}); + // while (rs.next()) { + // ChangeOwnerbean bean = new ChangeOwnerbean(); + // bean.setId(rs.getString(1)); + // bean.setCustomerName(rs.getString(2)); + // bean.setSpec(rs.getString(3)); + // bean.setZhangt(rs.getString(4)); + // bean.setCangk(rs.getString(5)); + // bean.setNum(rs.getString(6)); + // bean.setUnit(rs.getString(7)); + // list.add(bean); + // } + // closeDataBase(); + // return list; + // } + + public String getNum(Object[] values) + throws Exception { + openDataBase(); + // 查询该id在数据库中的内容 + String sql = "select NUM from DFL_OLD_ITEM where ITEM_ID= ? and ZHANGTAO= ? and WAREHOUSE= ?"; + String num = ""; + ResultSet rs = dbQuery2(sql, values); + if (rs.next()) { + num = rs.getString(1); + } + closeDataBase(); + return num; + } + + public double getNums(String sql) + throws Exception { + openDataBase(); + // 查询该id在数据库中的内容 + double nums = 0; + ResultSet rs = dbQuery(sql); + if (rs.next()) { + nums = rs.getInt(1); + } + closeDataBase(); + return nums; + } + /** + * 单例测试 + * + * @param args + */ + public static void main(String args[]) { + try { + + String str_DataBaseDriver = "oracle.jdbc.driver.OracleDriver"; + String str_URL = "jdbc:oracle:thin:@localhost:1521:tc12"; + 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/dfl/plm/util/DateChooser.java b/src/com/connor/dfl/plm/util/DateChooser.java new file mode 100644 index 0000000..413ddc2 --- /dev/null +++ b/src/com/connor/dfl/plm/util/DateChooser.java @@ -0,0 +1,1391 @@ +package com.connor.dfl.plm.util; + +import java.awt.BasicStroke; + +import java.awt.BorderLayout; + +import java.awt.Color; + +import java.awt.Component; + +import java.awt.Cursor; + +import java.awt.Dimension; + +import java.awt.Font; + +import java.awt.Graphics; + +import java.awt.Graphics2D; + +import java.awt.GridLayout; + +import java.awt.Point; + +import java.awt.Polygon; + +import java.awt.Stroke; + +import java.awt.Toolkit; + +import java.awt.event.FocusEvent; + +import java.awt.event.FocusListener; + +import java.awt.event.MouseAdapter; + +import java.awt.event.MouseEvent; + +import java.awt.event.MouseListener; + +import java.awt.event.MouseMotionListener; + +import java.text.SimpleDateFormat; + +import java.util.ArrayList; + +import java.util.Calendar; + +import java.util.Comparator; + +import java.util.Date; + +import java.util.List; + + + +import javax.swing.BorderFactory; + +import javax.swing.JComponent; + +import javax.swing.JFrame; + +import javax.swing.JLabel; + +import javax.swing.JPanel; + +import javax.swing.JTextField; + +import javax.swing.Popup; + +import javax.swing.PopupFactory; + +import javax.swing.SwingUtilities; + +import javax.swing.event.AncestorEvent; + +import javax.swing.event.AncestorListener; + + + +/** + + * 日期选择器,可以指定日期的显示格式 + + */ + +public class DateChooser extends JPanel { + + + + private static final long serialVersionUID = 4529266044762990227L; + + + + private Date initDate; + + private Calendar now = Calendar.getInstance(); + + private Calendar select; + + private JPanel monthPanel;//月历 + + private JP1 jp1;//四块面板,组成 + + private JP2 jp2; + + private JP3 jp3; + + private JP4 jp4; + + private Font font = new Font("宋体", Font.PLAIN, 12); + + private final LabelManager lm = new LabelManager(); + + private SimpleDateFormat sdf; + + private boolean isShow = false; + + private Popup pop; + + + + private JComponent showDate; + + + + public static DateChooser getInstance() { + + return new DateChooser(); + + } + + + + public static DateChooser getInstance(Date date) { + + return new DateChooser(date); + + } + + + + public static DateChooser getInstance(String format) { + + return new DateChooser(format); + + } + + + + public static DateChooser getInstance(Date date, String format) { + + return new DateChooser(date, format); + + } + + + + /** + + * Creates a new instance of DateChooser + + */ + + private DateChooser() { + + this(new Date()); + + } + + + + private DateChooser(Date date) { + + this(date, "yyyy年MM月dd日"); + + } + + + + private DateChooser(String format) { + + this(new Date(), format); + + } + + + + private DateChooser(Date date, String format) { + + initDate = date; + + sdf = new SimpleDateFormat(format); + + select = Calendar.getInstance(); + + select.setTime(initDate); + + initPanel(); + + } + + + + /** + + * 是否允许用户选择 + + */ + + public void setEnabled(boolean b) { + + super.setEnabled(b); + + showDate.setEnabled(b); + + } + + + + /** + + *得到当前选择框的日期 + + */ + + public Date getDate() { + + return select.getTime(); + + } + + + + public String getStrDate() { + + return sdf.format(select.getTime()); + + } + + + + public String getStrDate(String format) { + + sdf = new SimpleDateFormat(format); + + return sdf.format(select.getTime()); + + } + + + + //根据初始化的日期,初始化面板 + + private void initPanel() { + + monthPanel = new JPanel(new BorderLayout()); + + monthPanel.setBorder(BorderFactory.createLineBorder(Color.BLUE)); + + JPanel up = new JPanel(new BorderLayout()); + + up.add(jp1 = new JP1(), BorderLayout.NORTH); + + up.add(jp2 = new JP2(), BorderLayout.CENTER); + + monthPanel.add(jp3 = new JP3(), BorderLayout.CENTER); + + monthPanel.add(up, BorderLayout.NORTH); + + monthPanel.add(jp4 = new JP4(), BorderLayout.SOUTH); + + this.addAncestorListener(new AncestorListener() { + + public void ancestorAdded(AncestorEvent event) { + + + + } + + + + public void ancestorRemoved(AncestorEvent event) { + + + + } + + + + //只要祖先组件一移动,马上就让popup消失 + + public void ancestorMoved(AncestorEvent event) { + + hidePanel(); + + } + + }); + + } + + + + public void register(final JComponent showDate) { + + this.showDate = showDate; + + + + showDate.setRequestFocusEnabled(true); + + showDate.addMouseListener(new MouseAdapter() { + + public void mousePressed(MouseEvent me) { + + showDate.requestFocusInWindow(); + + } + + }); + + this.setBackground(Color.WHITE); + + this.add(showDate, BorderLayout.CENTER); + + this.setPreferredSize(new Dimension(90, 25)); + + this.setBorder(BorderFactory.createLineBorder(Color.GRAY)); + + showDate.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + if (showDate.isEnabled()) { + + showDate.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + showDate.setForeground(Color.RED); + + } + + } + + + + public void mouseExited(MouseEvent me) { + + if (showDate.isEnabled()) { + + showDate.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + showDate.setForeground(Color.BLACK); + + } + + } + + + + public void mousePressed(MouseEvent me) { + + if (showDate.isEnabled()) { + + showDate.setForeground(Color.CYAN); + + if (isShow) { + + hidePanel(); + + } else { + + showPanel(showDate); + + } + + } + + } + + + + public void mouseReleased(MouseEvent me) { + + if (showDate.isEnabled()) { + + showDate.setForeground(Color.BLACK); + + } + + } + + }); + + showDate.addFocusListener(new FocusListener() { + + public void focusLost(FocusEvent e) { + + hidePanel(); + + } + + + + public void focusGained(FocusEvent e) { + + + + } + + }); + + } + + + + //根据新的日期刷新 + + private void refresh() { + + jp1.updateDate(); + + jp2.updateDate(); + + jp3.updateDate(); + + jp4.updateDate(); + + SwingUtilities.updateComponentTreeUI(this); + + } + + + + //提交日期 + + private void commit() { + + //TODO add other components here + + if (showDate instanceof JTextField) { + + ((JTextField) showDate).setText(sdf.format(select.getTime())); + + }else if (showDate instanceof JLabel) { + + ((JLabel) showDate).setText(sdf.format(select.getTime())); + + } + + + + hidePanel(); + + } + + + + //隐藏日期选择面板 + + private void hidePanel() { + + if (pop != null) { + + isShow = false; + + pop.hide(); + + pop = null; + + } + + } + + + + //显示日期选择面板 + + private void showPanel(Component owner) { + + if (pop != null) { + + pop.hide(); + + } + + Point show = new Point(0, showDate.getHeight()); + + SwingUtilities.convertPointToScreen(show, showDate); + + Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); + + int x = show.x; + + int y = show.y; + + if (x < 0) { + + x = 0; + + } + + if (x > size.width - 295) { + + x = size.width - 295; + + } + + if (y < size.height - 170) { + + } else { + + y -= 188; + + } + + pop = PopupFactory.getSharedInstance().getPopup(owner, monthPanel, x, y); + + pop.show(); + + isShow = true; + + } + + + + /** + + * 最上面的面板用来显示月份的增减 + + */ + + private class JP1 extends JPanel { + + private static final long serialVersionUID = -5638853772805561174L; + + JLabel yearleft, yearright, monthleft, monthright, center, centercontainer; + + + + public JP1() { + + super(new BorderLayout()); + + this.setBackground(new Color(160, 185, 215)); + + initJP1(); + + } + + + + private void initJP1() { + + yearleft = new JLabel(" <<", JLabel.CENTER); + + yearleft.setToolTipText("上一年"); + + yearright = new JLabel(">> ", JLabel.CENTER); + + yearright.setToolTipText("下一年"); + + yearleft.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); + + yearright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); + + + + monthleft = new JLabel(" <", JLabel.RIGHT); + + monthleft.setToolTipText("上一月"); + + monthright = new JLabel("> ", JLabel.LEFT); + + monthright.setToolTipText("下一月"); + + monthleft.setBorder(BorderFactory.createEmptyBorder(2, 30, 0, 0)); + + monthright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 30)); + + + + centercontainer = new JLabel("", JLabel.CENTER); + + centercontainer.setLayout(new BorderLayout()); + + center = new JLabel("", JLabel.CENTER); + + + + centercontainer.add(monthleft, BorderLayout.WEST); + + centercontainer.add(center, BorderLayout.CENTER); + + centercontainer.add(monthright, BorderLayout.EAST); + + + + this.add(yearleft, BorderLayout.WEST); + + this.add(centercontainer, BorderLayout.CENTER); + + this.add(yearright, BorderLayout.EAST); + + this.setPreferredSize(new Dimension(295, 25)); + + + + updateDate(); + + + + yearleft.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + yearleft.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + yearleft.setForeground(Color.RED); + + } + + + + public void mouseExited(MouseEvent me) { + + yearleft.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + yearleft.setForeground(Color.BLACK); + + } + + + + public void mousePressed(MouseEvent me) { + + select.add(Calendar.YEAR, -1); + + yearleft.setForeground(Color.WHITE); + + refresh(); + + } + + + + public void mouseReleased(MouseEvent me) { + + yearleft.setForeground(Color.BLACK); + + } + + }); + + yearright.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + yearright.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + yearright.setForeground(Color.RED); + + } + + + + public void mouseExited(MouseEvent me) { + + yearright.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + yearright.setForeground(Color.BLACK); + + } + + + + public void mousePressed(MouseEvent me) { + + select.add(Calendar.YEAR, 1); + + yearright.setForeground(Color.WHITE); + + refresh(); + + } + + + + public void mouseReleased(MouseEvent me) { + + yearright.setForeground(Color.BLACK); + + } + + }); + + monthleft.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + monthleft.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + monthleft.setForeground(Color.RED); + + } + + + + public void mouseExited(MouseEvent me) { + + monthleft.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + monthleft.setForeground(Color.BLACK); + + } + + + + public void mousePressed(MouseEvent me) { + + select.add(Calendar.MONTH, -1); + + monthleft.setForeground(Color.WHITE); + + refresh(); + + } + + + + public void mouseReleased(MouseEvent me) { + + monthleft.setForeground(Color.BLACK); + + } + + }); + + monthright.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + monthright.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + monthright.setForeground(Color.RED); + + } + + + + public void mouseExited(MouseEvent me) { + + monthright.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + monthright.setForeground(Color.BLACK); + + } + + + + public void mousePressed(MouseEvent me) { + + select.add(Calendar.MONTH, 1); + + monthright.setForeground(Color.WHITE); + + refresh(); + + } + + + + public void mouseReleased(MouseEvent me) { + + monthright.setForeground(Color.BLACK); + + } + + }); + + } + + + + private void updateDate() { + + center.setText(select.get(Calendar.YEAR) + "年" + (select.get(Calendar.MONTH) + 1) + "月"); + + } + + } + + + + private class JP2 extends JPanel { + + private static final long serialVersionUID = -8176264838786175724L; + + + + public JP2() { + + this.setPreferredSize(new Dimension(295, 20)); + + } + + + + protected void paintComponent(Graphics g) { + + g.setFont(font); + + g.drawString("星期日 星期一 星期二 星期三 星期四 星期五 星期六", 5, 10); + + g.drawLine(0, 15, getWidth(), 15); + + } + + + + private void updateDate() { + + + + } + + } + + + + private class JP3 extends JPanel { + + private static final long serialVersionUID = 43157272447522985L; + + + + public JP3() { + + super(new GridLayout(6, 7)); + + this.setPreferredSize(new Dimension(295, 100)); + + initJP3(); + + } + + + + private void initJP3() { + + updateDate(); + + } + + + + public void updateDate() { + + this.removeAll(); + + lm.clear(); + + Date temp = select.getTime(); + + Calendar select = Calendar.getInstance(); + + select.setTime(temp); + + select.set(Calendar.DAY_OF_MONTH, 1); + + int index = select.get(Calendar.DAY_OF_WEEK); + + int sum = (index == 1 ? 8 : index); + + select.add(Calendar.DAY_OF_MONTH, 0 - sum); + + for (int i = 0; i < 42; i++) { + + select.add(Calendar.DAY_OF_MONTH, 1); + + lm.addLabel(new MyLabel(select.get(Calendar.YEAR), select.get(Calendar.MONTH), select.get(Calendar.DAY_OF_MONTH))); + + } + + for (MyLabel my : lm.getLabels()) { + + this.add(my); + + } + + select.setTime(temp); + + } + + } + + + + private class MyLabel extends JLabel implements Comparator, MouseListener, MouseMotionListener { + + private static final long serialVersionUID = 3668734399227577214L; + + private int year, month, day; + + private boolean isSelected; + + + + public MyLabel(int year, int month, int day) { + + super("" + day, JLabel.CENTER); + + this.year = year; + + this.day = day; + + this.month = month; + + this.addMouseListener(this); + + this.addMouseMotionListener(this); + + this.setFont(font); + + if (month == select.get(Calendar.MONTH)) { + + this.setForeground(Color.BLACK); + + } else { + + this.setForeground(Color.LIGHT_GRAY); + + } + + if (day == select.get(Calendar.DAY_OF_MONTH)) { + + this.setBackground(new Color(160, 185, 215)); + + } else { + + this.setBackground(Color.WHITE); + + } + + } + + + + public boolean getIsSelected() { + + return isSelected; + + } + + + + public void setSelected(boolean b, boolean isDrag) { + + isSelected = b; + + if (b && !isDrag) { + + int temp = select.get(Calendar.MONTH); + + select.set(year, month, day); + + if (temp == month) { + + SwingUtilities.updateComponentTreeUI(jp3); + + } else { + + refresh(); + + } + + } + + this.repaint(); + + } + + + + protected void paintComponent(Graphics g) { + + if (day == select.get(Calendar.DAY_OF_MONTH) && month == select.get(Calendar.MONTH)) { + + //如果当前日期是选择日期,则高亮显示 + + g.setColor(new Color(160, 185, 215)); + + g.fillRect(0, 0, getWidth(), getHeight()); + + } + + if (year == now.get(Calendar.YEAR) && month == now.get(Calendar.MONTH) && day == now.get(Calendar.DAY_OF_MONTH)) { + + //如果日期和当前日期一样,则用红框 + + Graphics2D gd = (Graphics2D) g; + + gd.setColor(Color.RED); + + Polygon p = new Polygon(); + + p.addPoint(0, 0); + + p.addPoint(getWidth() - 1, 0); + + p.addPoint(getWidth() - 1, getHeight() - 1); + + p.addPoint(0, getHeight() - 1); + + gd.drawPolygon(p); + + } + + if (isSelected) {//如果被选中了就画出一个虚线框出来 + + Stroke s = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL, 1.0f, new float[] { 2.0f, 2.0f }, 1.0f); + + Graphics2D gd = (Graphics2D) g; + + gd.setStroke(s); + + gd.setColor(Color.BLACK); + + Polygon p = new Polygon(); + + p.addPoint(0, 0); + + p.addPoint(getWidth() - 1, 0); + + p.addPoint(getWidth() - 1, getHeight() - 1); + + p.addPoint(0, getHeight() - 1); + + gd.drawPolygon(p); + + } + + super.paintComponent(g); + + } + + + + public boolean contains(Point p) { + + return this.getBounds().contains(p); + + } + + + + private void update() { + + repaint(); + + } + + + + public void mouseClicked(MouseEvent e) { + + } + + + + public void mousePressed(MouseEvent e) { + + isSelected = true; + + update(); + + } + + + + public void mouseReleased(MouseEvent e) { + + Point p = SwingUtilities.convertPoint(this, e.getPoint(), jp3); + + lm.setSelect(p, false); + + commit(); + + } + + + + public void mouseEntered(MouseEvent e) { + + } + + + + public void mouseExited(MouseEvent e) { + + } + + + + public void mouseDragged(MouseEvent e) { + + Point p = SwingUtilities.convertPoint(this, e.getPoint(), jp3); + + lm.setSelect(p, true); + + } + + + + public void mouseMoved(MouseEvent e) { + + } + + + + public int compare(MyLabel o1, MyLabel o2) { + + Calendar c1 = Calendar.getInstance(); + + c1.set(o1.year, o2.month, o1.day); + + Calendar c2 = Calendar.getInstance(); + + c2.set(o2.year, o2.month, o2.day); + + return c1.compareTo(c2); + + } + + } + + + + private class LabelManager { + + private List list; + + + + public LabelManager() { + + list = new ArrayList(); + + } + + + + public List getLabels() { + + return list; + + } + + + + public void addLabel(MyLabel my) { + + list.add(my); + + } + + + + public void clear() { + + list.clear(); + + } + + + + @SuppressWarnings("unused") + + public void setSelect(MyLabel my, boolean b) { + + for (MyLabel m : list) { + + if (m.equals(my)) { + + m.setSelected(true, b); + + } else { + + m.setSelected(false, b); + + } + + } + + } + + + + public void setSelect(Point p, boolean b) { + + //如果是拖动,则要优化一下,以提高效率 + + if (b) { + + //表示是否能返回,不用比较完所有的标签,能返回的标志就是把上一个标签和 + + //将要显示的标签找到了就可以了 + + boolean findPrevious = false, findNext = false; + + for (MyLabel m : list) { + + if (m.contains(p)) { + + findNext = true; + + if (m.getIsSelected()) { + + findPrevious = true; + + } else { + + m.setSelected(true, b); + + } + + } else if (m.getIsSelected()) { + + findPrevious = true; + + m.setSelected(false, b); + + } + + if (findPrevious && findNext) { + + return; + + } + + } + + } else { + + MyLabel temp = null; + + for (MyLabel m : list) { + + if (m.contains(p)) { + + temp = m; + + } else if (m.getIsSelected()) { + + m.setSelected(false, b); + + } + + } + + if (temp != null) { + + temp.setSelected(true, b); + + } + + } + + } + + + + } + + + + private class JP4 extends JPanel { + + private static final long serialVersionUID = -6391305687575714469L; + + + + public JP4() { + + super(new BorderLayout()); + + this.setPreferredSize(new Dimension(295, 20)); + + this.setBackground(new Color(160, 185, 215)); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日"); + + final JLabel jl = new JLabel("今天: " + sdf.format(new Date())); + + jl.setToolTipText("点击选择今天日期"); + + this.add(jl, BorderLayout.CENTER); + + jl.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + jl.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + jl.setForeground(Color.RED); + + } + + + + public void mouseExited(MouseEvent me) { + + jl.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + jl.setForeground(Color.BLACK); + + } + + + + public void mousePressed(MouseEvent me) { + + jl.setForeground(Color.WHITE); + + select.setTime(new Date()); + + refresh(); + + commit(); + + } + + + + public void mouseReleased(MouseEvent me) { + + jl.setForeground(Color.BLACK); + + } + + }); + + } + + + + private void updateDate() { + + + + } + + } + + + + public static void main(String[] args) { + + DateChooser dateChooser1 = DateChooser.getInstance("yyyy-MM-dd"); + + 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/dfl/plm/util/ExcelUtil.java b/src/com/connor/dfl/plm/util/ExcelUtil.java new file mode 100644 index 0000000..1235532 --- /dev/null +++ b/src/com/connor/dfl/plm/util/ExcelUtil.java @@ -0,0 +1,268 @@ +package com.connor.dfl.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 codeBeanList; + + public GetCodeBean(TCSession session){ + ParseXML xml=new ParseXML(); + File file=xml.getSXX("DFL_Code_Xml", 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{ + MessageBox.post("未找到该类型的对象配置信息,请联系管理员!","错误",MessageBox.ERROR); + } + + return menuBean; + } +} diff --git a/src/com/connor/dfl/plm/util/JTableLearning.java b/src/com/connor/dfl/plm/util/JTableLearning.java new file mode 100644 index 0000000..d959718 --- /dev/null +++ b/src/com/connor/dfl/plm/util/JTableLearning.java @@ -0,0 +1,166 @@ +package com.connor.dfl.plm.util; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.util.List; +import java.util.Vector; + +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.AbstractTableModel; + +public class JTableLearning extends JFrame { + + private JTable jg_table; + private JScrollPane jsp; + + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + JTableLearning frame = new JTableLearning(); + frame.pack(); + frame.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + public JTableLearning() { + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setBounds(100, 100, 100, 100); + getContentPane().setLayout(new BorderLayout(0, 0)); + + AbstractTableModel tm; + final Vector> vect;// 声明一个向量对象 + + final String title[] = { "职工号", "职工名", "性别", "出生日期", "工资" }; // 二维表列名 + vect = new Vector>();// 实例化向量 + tm = new AbstractTableModel() { + public int getColumnCount() { + return title.length; + }// 取得表格列数 + + public int getRowCount() { + return vect.size(); + }// 取得表格行数 + + public Object getValueAt(int row, int column) { + if (!vect.isEmpty()) + return ((Vector) vect.elementAt(row)).elementAt(column); + else + return null; + }// 取得单元格中的属性值 + + public String getColumnName(int column) { + return title[column]; + }// 设置表格列名 + + public void setValueAt(Object value, int row, int column) { + } // 数据模型不可编辑,该方法设置为空 + + public Class getColumnClass(int c) { + return getValueAt(0, c).getClass(); + }// 取得列所属对象类 + + public boolean isCellEditable(int row, int column) { + return false; + }// 设置单元格不可编辑,为缺省实现 + }; + + vect.removeAllElements();// 初始化向量对象 + tm.fireTableStructureChanged();// 更新表格内容 + + Vector list = new Vector(); + + list.add("fda"); + list.add("aaa"); + list.add("ssa"); + list.add("dda"); + list.add("mma"); + + vect.addElement(list); + vect.addElement(list); + vect.addElement(list); + vect.addElement(list); + tm.fireTableStructureChanged(); + // }; + // 定制表格: + jg_table = new JTable(tm);// 生成自己的数据模型 + jg_table.setToolTipText("显示全部查询结果"); + // 设置帮助提示 + jg_table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + // 设置表格调整尺寸模式 + jg_table.setCellSelectionEnabled(false); + // 设置单元格选择方式 + jg_table.setShowVerticalLines(true);// + // 设置是否显示单元格间的分割线 + jg_table.setShowHorizontalLines(true); + + jsp = new JScrollPane(jg_table);// 给表格加上滚动杠 + + jsp.addComponentListener(new ComponentAdapter() { + @Override + public void componentResized(ComponentEvent e) { + resizeTable(true); + } + }); + getContentPane().add(jsp, BorderLayout.CENTER); + } + + public void resizeTable(boolean bool) { + Dimension containerwidth = null; + if (!bool) { + // 初始化时,父容器大小为首选大小,实际大小为0 + containerwidth = jsp.getPreferredSize(); + } else { + // 界面显示后,如果父容器大小改变,使用实际大小而不是首选大小 + containerwidth = jsp.getSize(); + } + // 计算表格总体宽度 getTable(). + int allwidth = jg_table.getIntercellSpacing().width; + for (int j = 0; j < jg_table.getColumnCount(); j++) { + // 计算该列中最长的宽度 + int max = 0; + for (int i = 0; i < jg_table.getRowCount(); i++) { + int width = jg_table + .getCellRenderer(i, j) + .getTableCellRendererComponent(jg_table, + jg_table.getValueAt(i, j), false, false, i, j) + .getPreferredSize().width; + if (width > max) { + max = width; + } + } + // 计算表头的宽度 + int headerwidth = jg_table + .getTableHeader() + .getDefaultRenderer() + .getTableCellRendererComponent( + jg_table, + jg_table.getColumnModel().getColumn(j) + .getIdentifier(), false, false, -1, j) + .getPreferredSize().width; + // 列宽至少应为列头宽度 + max += headerwidth; + // 设置列宽 + jg_table.getColumnModel().getColumn(j).setPreferredWidth(max); + // 给表格的整体宽度赋值,记得要加上单元格之间的线条宽度1个像素 + allwidth += max + jg_table.getIntercellSpacing().width; + } + allwidth += jg_table.getIntercellSpacing().width; + // 如果表格实际宽度大小父容器的宽度,则需要我们手动适应;否则让表格自适应 + if (allwidth > containerwidth.width) { + jg_table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + } else { + jg_table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); + } + } +} + diff --git a/src/com/connor/dfl/plm/util/MenuBean.java b/src/com/connor/dfl/plm/util/MenuBean.java new file mode 100644 index 0000000..703b496 --- /dev/null +++ b/src/com/connor/dfl/plm/util/MenuBean.java @@ -0,0 +1,31 @@ +package com.connor.dfl.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/dfl/plm/util/MenuCodeBean.java b/src/com/connor/dfl/plm/util/MenuCodeBean.java new file mode 100644 index 0000000..10c9e6c --- /dev/null +++ b/src/com/connor/dfl/plm/util/MenuCodeBean.java @@ -0,0 +1,27 @@ +package com.connor.dfl.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/dfl/plm/util/ParseXML.java b/src/com/connor/dfl/plm/util/ParseXML.java new file mode 100644 index 0000000..f24f268 --- /dev/null +++ b/src/com/connor/dfl/plm/util/ParseXML.java @@ -0,0 +1,278 @@ +package com.connor.dfl.plm.util; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +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 + * @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"); + 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"); + 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) { + MessageBox.post("数据集没有命名引用的文件或文件过多,请检查!", "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:\\2.xml"); +// ParseXML t = new ParseXML(); +// // t.parseXML(file); +// t.parseXMLCode(file2); +// } +} diff --git a/src/com/connor/dfl/plm/util/PartBean.java b/src/com/connor/dfl/plm/util/PartBean.java new file mode 100644 index 0000000..6846bba --- /dev/null +++ b/src/com/connor/dfl/plm/util/PartBean.java @@ -0,0 +1,25 @@ +package com.connor.dfl.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/dfl/plm/util/ProgressBar.java b/src/com/connor/dfl/plm/util/ProgressBar.java new file mode 100644 index 0000000..21bad4a --- /dev/null +++ b/src/com/connor/dfl/plm/util/ProgressBar.java @@ -0,0 +1,171 @@ +/** + * @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.dfl.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/dfl/plm/util/ProgressBarThread.java b/src/com/connor/dfl/plm/util/ProgressBarThread.java new file mode 100644 index 0000000..1f59b26 --- /dev/null +++ b/src/com/connor/dfl/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.dfl.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/dfl/plm/util/PropBean.java b/src/com/connor/dfl/plm/util/PropBean.java new file mode 100644 index 0000000..c8dcb1c --- /dev/null +++ b/src/com/connor/dfl/plm/util/PropBean.java @@ -0,0 +1,88 @@ +package com.connor.dfl.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]非必填 + 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/dfl/plm/util/RealBean.java b/src/com/connor/dfl/plm/util/RealBean.java new file mode 100644 index 0000000..7a08aa2 --- /dev/null +++ b/src/com/connor/dfl/plm/util/RealBean.java @@ -0,0 +1,40 @@ +package com.connor.dfl.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/dfl/plm/util/SoaServerUtil.java b/src/com/connor/dfl/plm/util/SoaServerUtil.java new file mode 100644 index 0000000..1f00a18 --- /dev/null +++ b/src/com/connor/dfl/plm/util/SoaServerUtil.java @@ -0,0 +1,234 @@ +package com.connor.dfl.plm.util; + +import java.util.List; + +import net.sf.json.JSONArray; + +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; + +/** + * 发送分类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 { + 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(); + openByPass(tcSession); + accessControlService.grantPrivilege(tempItem, user, as2); + closeByPass(tcSession); + + openByPass(tcSession); + accessControlService.grantPrivilege(tccomponent, user, as2); + closeByPass(tcSession); + } else { + openByPass(tcSession); + accessControlService.grantPrivilege(tccomponent, user, as2); + closeByPass(tcSession); + } + } catch (TCException e) { + 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 { + 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(); + openByPass(tcSession); + accessControlService.grantPrivilege(tempItem, user, as2); + closeByPass(tcSession); + + openByPass(tcSession); + accessControlService.grantPrivilege(tccomponent, user, as2); + closeByPass(tcSession); + } else { + openByPass(tcSession); + accessControlService.grantPrivilege(tccomponent, user, as2); + closeByPass(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 + } + +} diff --git a/src/com/connor/dfl/plm/worklist/CusRoot.java b/src/com/connor/dfl/plm/worklist/CusRoot.java new file mode 100644 index 0000000..c6c89c9 --- /dev/null +++ b/src/com/connor/dfl/plm/worklist/CusRoot.java @@ -0,0 +1,38 @@ +/*jadclipse*/// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. +// Jad home page: http://www.kpdus.com/jad.html +// Decompiler options: packimports(3) radix(10) lradix(10) +package com.connor.dfl.plm.worklist; + +import java.util.ArrayList; +import java.util.List; + +import com.teamcenter.rac.cm.ui.ICNTreeRoot; + +public class CusRoot extends ICNTreeRoot { + private List elements; + + public CusRoot(Object obj) { + super(obj); + elements = new ArrayList(); + elements.add(obj); + } + + @Override + public Object[] getElements() { + return elements.toArray(new Object[elements.size()]); + } + + public void addElement(Object obj) { + elements.add(obj); + } + +} + +/* + * DECOMPILATION REPORT + * + * Decompiled from: + * C:\TC\Siemens\Teamcenter11\portal\plugins\com.teamcenter.rac.cm_11000.2.0.jar + * Total time: 16 ms Jad reported messages/errors: Exit status: 0 Caught + * exceptions: + */ \ No newline at end of file diff --git a/src/com/connor/dfl/plm/worklist/MyView.java b/src/com/connor/dfl/plm/worklist/MyView.java new file mode 100644 index 0000000..8b22adb --- /dev/null +++ b/src/com/connor/dfl/plm/worklist/MyView.java @@ -0,0 +1,624 @@ +package com.connor.dfl.plm.worklist; + +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.Calendar; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; + +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.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFolderType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.views.TCComponentView; +import com.teamcenter.rac.util.PlatformHelper; +import com.teamcenter.rac.viewer.provider.node.ComponentNode; + +public class MyView extends TCComponentView{ + + private static final String JDBC_DRIVER = "oracle.jdbc.OracleDriver"; + public static final String ID = MyView.class.getName(); + public static final String FOLDER1_NAME = "已发起任务"; + public static final String FOLDER2_NAME = "已参与任务"; + public static final SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd"); + private TCSession session; + private String userId; + private TCComponent folder1;// 已发起 + private TCComponent folder2;// 已参与 + private long timeInterval = 900000; + private int maxYear; //获得的工作流程最晚年份 + private int maxMonth; //获得的工作流程月份年份 + private int maxDay; //获得的工作流程最晚日期 + private int currentYear; + private int curretnMonth; + + public MyView() { + super(); + } + + private AIFComponentContext contextChange; + + @Override + protected void processSetInput(IWorkbenchPart iWorkbenchPart, List list) { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); + timeInterval = session.getPreferenceService().getIntegerValue("DFL2_WorkListHistory_timeInterval"); + timeInterval = timeInterval <= 0 ? 900000 : timeInterval * 60 * 1000; + getTime(); + try { + //获得当前登录用户id + userId = session.getUser().getUserId(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + ComponentNode object; + // Object object4 = list.isEmpty() ? null : list.get(0); + object = new ComponentNode(); + try { + TCComponent[] search = session.search("常规...", new String[] { "类型", "所有权用户" }, + new String[] { "我的工作列表", userId }); + ComponentNode node = new ComponentNode(); + node.setObject(search[0]); + //判断我的工作列表文件夹是否存在 + TCComponent workFolder = isFolderExisted("我的工作列表历史"); + this.setInputObject(iWorkbenchPart, search[0]); + this.updatePartDetails(search[0]); + CusRoot cusRoot = new CusRoot(node); + ComponentNode addNode = addNode(object, workFolder); + cusRoot.addElement(addNode); + this.getTreeViewer().setInput(cusRoot); + this.selectAndExpand(this.contextChange, 1); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + protected void makeViewBlank(IWorkbenchPart iWorkbenchPart, List list, boolean bl) { + IWorkbenchPage iWorkbenchPage; + super.makeViewBlank(iWorkbenchPart, list, bl); + if (!this.isDisposed() && (iWorkbenchPage = PlatformHelper.getCurrentPage()) != null) { + iWorkbenchPage.hideView(this); + } + } + + + @Override + public void refreshDataInView() { + // TODO Auto-generated method stub + super.refreshDataInView(); + System.out.println("------刷新"); + } + @Override + public void refreshTrim() { + // TODO Auto-generated method stub + super.refreshTrim(); + System.out.println("------刷新2"); + } + //刷新 + public void refreshs(){ + ExecutorService es = Executors.newFixedThreadPool(5); + es.execute(new Runnable() { + @Override + public void run() { + try { + addTask(folder1, 0); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }); + es.execute(new Runnable() { + @Override + public void run() { + try { + addTask(folder2, 1); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }); + } + + + private ComponentNode addNode(ComponentNode object, TCComponent workFolder) { + getRootFolder(workFolder); + System.out.println("**********************************"); + ExecutorService es = Executors.newFixedThreadPool(5); + es.execute(new Runnable() { + @Override + public void run() { + try { + while (true) { + addTask(folder1, 0); + Thread.sleep(timeInterval); + } + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }); + es.execute(new Runnable() { + @Override + public void run() { + try { + while (true) { + addTask(folder2, 1); + Thread.sleep(timeInterval); + } + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }); + object.setObject(workFolder); + // cusRoot = new CusRoot(object); + return object; + } + + /** + * @param folder + * @param type + */ + private void addTask(TCComponent folder, int type) { + Map> taskFolderMap = getTaskFolder(folder); + //获得年任务文件夹 + Map yearMap = getYearFolder(folder); + // + Integer[] lastDate = getLastDate(taskFolderMap); + //System.out.println(lastDate[0]+"+++++++++++"+lastDate[1]); + List workFlowList = getWorkFlowList(lastDate, type); + System.out.println("workFlowList数量="+workFlowList.size()); + boolean flag1 = false; + boolean flag2 = false; + if (workFlowList.size() == 0) { + return; + } else { + //参与任务 type = 2 ;发起任务 type = 0; + for (Workflow_InfoBean workflow_InfoBean : workFlowList) { + //System.out.println(workflow_InfoBean); + String timeinfo = workflow_InfoBean.getTimeinfo(); + int year = Integer.valueOf(timeinfo.split("-")[0]); + int month = Integer.valueOf(timeinfo.split("-")[1]); + TCComponent yearFolder = null; + TCComponent monthFolder = null; + if (taskFolderMap.containsKey(year)) { + if(!taskFolderMap.get(year).containsKey(month)){ + System.out.println("存在月份异常数据:"+workflow_InfoBean); + continue; + } + monthFolder = taskFolderMap.get(year).get(month); + TCComponent stringToComponent=workflow_InfoBean.getComp(); + try { + monthFolder.add("contents", stringToComponent); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + /*if(month == 2 &&workflow_InfoBean.getWf_type() ==2){ + try { + System.out.println("type:"+workflow_InfoBean.getWf_type()+",comp:"+workflow_InfoBean.getComp().getProperty("job_name")+"("+workflow_InfoBean.getComp()+")"+workflow_InfoBean.getComp()+",date:"+workflow_InfoBean.getDate()+",timeinfo="+workflow_InfoBean.getTimeinfo()); + System.out.println("Date:"+workflow_InfoBean.getComp().getDateProperty("last_mod_date")); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } */ + }else{ + System.out.println("存在年份异常数据:"+workflow_InfoBean); + } + } + } +} + /** + * 获得查询日期 + * + * @param lastDate + * @return + */ + private String searchDate(Integer[] lastDate) { + int year = lastDate[0]; + int month = lastDate[1]; + return year + "-" + (month < 10 ? "0" + month : month) + "-" + "01"; + } + + /** + * 得到根文件夹 + * + * @param workFolder + * @throws TCException + * @get 已发起文件夹 已参与文件夹 + */ + private void getRootFolder(TCComponent workFolder) { + try { + AIFComponentContext[] children = workFolder.getChildren("contents"); + for (AIFComponentContext aifComponentContext : children) { + TCComponent folder = (TCComponent) aifComponentContext.getComponent(); + String name = folder.getProperty("object_name"); + if (name.equals(FOLDER1_NAME)) { + folder1 = folder; + } else if (name.equals(FOLDER2_NAME)) { + folder2 = folder; + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 获得task文件夹最晚的时间 + * + * @param taskFolder + * @return + */ + private Integer[] getLastDate(Map> taskFolder) { + System.out.println("task文件夹最晚的时间:==="+maxYear+"年"+maxMonth+"月"); + return new Integer[] { maxYear, maxMonth }; + } + + /** + * 获得任务文件夹集合 + * + * @return Map> + * + */ + private Map> getTaskFolder(TCComponent parent) { + System.out.println(parent == null); + System.out.println("parent :===="+parent); + Map> map = new HashMap<>(); + try { + for (AIFComponentContext aifComponentContext : parent.getChildren("contents")) { + TCComponent folder = (TCComponent) aifComponentContext.getComponent(); + map.put(Integer.valueOf(folder.getProperty("object_name").split("年")[0]), getMonthFolder(folder)); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return map; + } + + /** + * 获得年任务文件夹集合 + * + * @return Map key 年 value 年任务文件夹 + * + */ + private Map getYearFolder(TCComponent parent) { + Map map = new HashMap<>(); + try { + for (AIFComponentContext aifComponentContext : parent.getChildren("contents")) { + TCComponent folder = (TCComponent) aifComponentContext.getComponent(); + Integer year = Integer.valueOf(folder.getProperty("object_name").split("年")[0]); + map.put(year, folder); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return map; + } + + /** + * 获得月任务文件夹集合 + * + * @return Map key 月 value 月任务文件夹 + * + */ + private Map getMonthFolder(TCComponent parent) { + Map map = new HashMap<>(); + try { + for (AIFComponentContext aifComponentContext : parent.getChildren("contents")) { + TCComponent folder = (TCComponent) aifComponentContext.getComponent(); + map.put(Integer.parseInt(folder.getProperty("object_name").split("月")[0]), folder); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return map; + } + + /** + * 判断 历史文件夹是否创建 + * + * @param folderName + * @return folder + */ + private TCComponent isFolderExisted(String folderName) { + TCComponent folder = null; + try { + System.out.println(userId); + TCComponent[] search = session.search("常规...", new String[] { "名称", "类型", "所有权用户" }, + new String[] { folderName, "Folder", userId }); + System.out.println("长度:" + search.length); + //若历史文件夹未创建则新建文件夹1、2 + if (search.length == 0) { + folder = createFolder(folderName, null); + //createFolder(FOLDER1_NAME, folder); + //createFolder(FOLDER2_NAME, folder); + clearhistory((TCComponentFolder)folder); + } else { + folder = search[0]; + clearhistory((TCComponentFolder)folder); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return folder; + } + + /** + * 创建文件夹 + * + * @param folderName + * @return + */ + private TCComponent createFolder(String folderName, TCComponent parent) { + TCComponent folder = null; + try { + TCComponentFolderType type = (TCComponentFolderType) session.getTypeComponent("Folder"); + folder = type.create(folderName, null, "Folder"); + if (parent != null) { + parent.add("contents", folder); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return folder; + } + + /** + * 获得的工作列表 + * + * @return + */ + private List getWorkFlowList(Integer[] lastDate, int type) { + ResultSet rs = null; + PreparedStatement ps = null; + Connection conn = null; + List list = new ArrayList<>(); + try { + String[] stringValues = session.getPreferenceService().getStringValues("DFL2_SQL_Connect"); + String url = "jdbc:oracle:thin:@" + stringValues[0]; + String password = stringValues[2]; + String user = stringValues[1]; + // 加载驱动 + Class.forName(JDBC_DRIVER); + conn = DriverManager.getConnection(url, user, password); + String sql = null; + if (type == 0) { + sql = "select * from workflow_info where USERID=? and LOGTIME>=? and WF_TYPE=? order by LOGTIME desc"; + //System.out.println("开始查找数据--升序 type=0"); + } else { + sql = "select * from workflow_info where USERID=? and LOGTIME>=? and WF_TYPE>=? order by LOGTIME desc"; + //System.out.println("开始查找数据--升序 type=else"); + } + + ps = conn.prepareStatement(sql); + ps.setString(1, userId); + ps.setString(2, searchDate(lastDate)); + ps.setInt(3, type); + rs = ps.executeQuery(); + int rslen=0; + while (rs.next()) { + rslen++; + String puid = rs.getString(1); + TCComponent stringToComponent=null; + try { + stringToComponent = session.stringToComponent(puid); + } catch (Exception e) { + System.out.println("err:"+e.getMessage()); + } + + if (stringToComponent == null) { + continue; + } + + Date date = null; + date = getExecutiontime(stringToComponent, rs.getString(3)); + Workflow_InfoBean bean = new Workflow_InfoBean(); + bean.setPuid(rs.getString(1)); + bean.setUserId(rs.getString(3)); + bean.setTimeinfo(rs.getString(4)); + bean.setWf_type(rs.getInt(2)); + bean.setLogTime(rs.getString(5)); + bean.setComp(stringToComponent); + bean.setDate(date); + list.add(bean); + //System.out.println(rslen+"----------------------"+bean); + } + Collections.sort(list, new SortByDate()); + return list; + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + // 关闭数据库链接 + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if (ps != null) { + try { + ps.close(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if (conn != null) { + try { + conn.close(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + return list; + } + + //每次加载前清空历史文件夹并生成需要的年月文件夹 + public void clearhistory(TCComponentFolder folder) { + try { + //AIFComponentContext[] children = folder.getChildren("contents"); + TCComponent[] children = folder.getRelatedComponents("contents"); + if(children.length >0) { + folder.remove("contents", children); + } + //已发起 文件夹 + TCComponentFolder sponsorFolder = (TCComponentFolder) createFolder(FOLDER1_NAME, folder); + //已参与 文件夹 + TCComponentFolder participationFolder = (TCComponentFolder) createFolder(FOLDER2_NAME, folder); + if(currentYear == maxYear) { + TCComponentFolder yearFolder1 = (TCComponentFolder) createFolder(String.valueOf(maxYear)+"年", sponsorFolder); + TCComponentFolder yearFolder2 = (TCComponentFolder) createFolder(String.valueOf(maxYear)+"年", participationFolder); + for(int i=maxMonth;i<=curretnMonth;i++) { + TCComponentFolder monthFolder1 =null; + TCComponentFolder monthFolder2 =null; + monthFolder1 = (TCComponentFolder) createFolder(String.valueOf(i)+"月", yearFolder1); + monthFolder2 = (TCComponentFolder) createFolder(String.valueOf(i)+"月", yearFolder2); + System.out.println(maxYear+"年"+i+"月文件夹添加成功"); + } + }else { + //去年 + TCComponentFolder yearFolder1 = (TCComponentFolder) createFolder(String.valueOf(maxYear)+"年", sponsorFolder); + TCComponentFolder yearFolder2 = (TCComponentFolder) createFolder(String.valueOf(maxYear)+"年", participationFolder); + for(int i=maxMonth;i<=12;i++) { + TCComponentFolder monthFolder1 =null; + TCComponentFolder monthFolder2 =null; + monthFolder1 = (TCComponentFolder) createFolder(String.valueOf(i)+"月", yearFolder1); + monthFolder2 = (TCComponentFolder) createFolder(String.valueOf(i)+"月", yearFolder2); + System.out.println(maxYear+"年"+i+"月文件夹添加成功"); + } + //当前年份 + TCComponentFolder yearFolder3 = (TCComponentFolder) createFolder(String.valueOf(currentYear)+"年", sponsorFolder); + TCComponentFolder yearFolder4 = (TCComponentFolder) createFolder(String.valueOf(currentYear)+"年", participationFolder); + for(int i=1;i<=curretnMonth;i++) { + TCComponentFolder monthFolder1 =null; + TCComponentFolder monthFolder2 =null; + monthFolder1 = (TCComponentFolder) createFolder(String.valueOf(i)+"月", yearFolder3); + monthFolder2 = (TCComponentFolder) createFolder(String.valueOf(i)+"月", yearFolder4); + System.out.println(currentYear+"年"+i+"月文件夹添加成功"); + } + } + System.out.println("历史工作列表初始化成功"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void getTime() { + //获得当前时间的前三个月时间点 + Calendar cal = Calendar.getInstance(); + currentYear =cal.get(Calendar.YEAR); + curretnMonth = cal.get(Calendar.MONTH)+1; + int currentDay = cal.get(Calendar.DATE); + + if(curretnMonth <4) { + this.maxYear = currentYear-1; + this.maxMonth = curretnMonth+9; + }else { + this.maxYear = currentYear; + this.maxMonth = curretnMonth-3; + } + + } + + //获取多人审核节点用户执行时间 + private Date getExecutiontime(TCComponent task,String userID) { + Date time = null; + try { + String type = task.getProperty("task_type"); + // 认可节点或审核节点 + if (type.equals("EPMAcknowledgeTask") || type.equals("EPMReviewTask")) { + TCComponent[] childs = task.getRelatedComponents("child_tasks"); + // 获得签审小节点 + TCComponent signoff = null; + if(childs.length>1){ + signoff = childs[1]; + } + // 获得有效签发 + TCComponent[] valid_signoffs = task.getRelatedComponents("valid_signoffs"); + if (valid_signoffs != null && valid_signoffs.length>1) { + //System.out.println("-----该节点多人审核-----"); + //System.out.println(task.getProperty("job_name")+"("+task.getProperty("fnd0AliasTaskName")+")"); + for (TCComponent valid : valid_signoffs) { + String assign = valid.getProperty("fnd0Assignee"); + if(assign.contains(userID)){ + String result = valid.getProperty("decision"); + Date date = valid.getDateProperty("decision_date"); + //System.out.println("[节点="+task+";被指派者=" + assign + ";决定=" + result + ";决定日期=" + date + "]"); + return date; + } + + } + } + + } /*// 条件节点 + else if (type.equals("EPMConditionTask")) { + + } // do任务 + else if (type.equals("EPMDoTask")) { + + }*/ + time = task.getDateProperty("last_mod_date"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return time; + } + + +} + +//比较 签审时间 降序 +class SortByDate implements Comparator { + public int compare(Object o1, Object o2) { + Workflow_InfoBean s1 = (Workflow_InfoBean) o1; + Workflow_InfoBean s2 = (Workflow_InfoBean) o2; + return s2.getDate().compareTo(s1.getDate()); + } + +} + + diff --git a/src/com/connor/dfl/plm/worklist/WorkListView.java b/src/com/connor/dfl/plm/worklist/WorkListView.java new file mode 100644 index 0000000..244ce45 --- /dev/null +++ b/src/com/connor/dfl/plm/worklist/WorkListView.java @@ -0,0 +1,87 @@ +package com.connor.dfl.plm.worklist; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFolderType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.views.TCComponentView; +import com.teamcenter.rac.viewer.provider.node.ComponentNode; +import java.util.List; +import org.eclipse.ui.IWorkbenchPart; + +public class WorkListView extends TCComponentView +{ + public static final String FOLDER1_NAME = "已发起任务"; + public static final String FOLDER2_NAME = "已参与任务"; + private TCSession session; + private long timeInterval; + private String userId; + private AIFComponentContext contextChange; + + @Override + protected void processSetInput(IWorkbenchPart iWorkbenchPart, List list) + { + try + { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + this.session = ((TCSession)app.getSession()); + this.timeInterval = this.session.getPreferenceService().getIntegerValue("WX_WorkListHistory_timeInterval").intValue(); + System.out.println("timeInterval: " + this.timeInterval); + this.timeInterval = (this.timeInterval <= 0L ? 900000L : this.timeInterval * 60L * 1000L); + this.userId = this.session.getUser().getUserId(); + System.out.println("用户Id号: " + this.userId); + new ComponentNode(); + ComponentNode node = new ComponentNode(); + TCComponent[] search = this.session.search("常规...", new String[] { "类型", "所有权用户" }, new String[] { "我的工作列表", this.userId }); + handlerWorkList("我的工作列表历史"); + node.setObject(search[0]); + updatePartDetails(search[0]); + setInputObject(iWorkbenchPart, search[0]); + CusRoot cusRoot = new CusRoot(node); + getTreeViewer().setInput(cusRoot); + selectAndExpand(this.contextChange, 1); + } catch (Exception e) { + System.out.println("发生异常-----------> " + e.getMessage()); + e.printStackTrace(); + } + } + + + + private TCComponent handlerWorkList(String folderName) + { + TCComponent folder = null; + try { + TCComponent[] search = this.session.search("常规...", new String[] { "名称", "类型", "所有权用户" }, new String[] { folderName, "Folder", this.userId }); + if (search.length == 0) { + folder = createFolder(folderName); + TCComponentFolder folder1 = createFolder("已发起任务"); + TCComponentFolder folder2 = createFolder("已参与任务"); + folder.add("contents", folder1); + folder.add("contents", folder2); + } else { + folder = search[0]; + } + } + catch (Exception localException) {} + + return folder; + } + + private TCComponentFolder createFolder(String folderName) { + TCComponentFolder folder = null; + try { + TCComponentFolderType type = (TCComponentFolderType)this.session.getTypeComponent("Folder"); + folder = type.create(folderName, null, "Folder"); + } catch (TCException e) { + System.out.println("创建Folder发生异常---------------> " + e.getMessage()); + e.printStackTrace(); + } + return folder; + } +} + + diff --git a/src/com/connor/dfl/plm/worklist/Workflow_InfoBean.java b/src/com/connor/dfl/plm/worklist/Workflow_InfoBean.java new file mode 100644 index 0000000..75423b6 --- /dev/null +++ b/src/com/connor/dfl/plm/worklist/Workflow_InfoBean.java @@ -0,0 +1,81 @@ +package com.connor.dfl.plm.worklist; + +import java.util.Date; + +import com.teamcenter.rac.kernel.TCComponent; + +public class Workflow_InfoBean { + private String puid; + private int wf_type; + private String userId; + private String timeinfo; + private String logTime; + private TCComponent comp; + private Date date; + + public String getLogTime() { + return logTime; + } + + public void setLogTime(String logTime) { + this.logTime = logTime; + } + + public String getPuid() { + return puid; + } + + public void setPuid(String puid) { + this.puid = puid; + } + + public int getWf_type() { + return wf_type; + } + + public void setWf_type(int wf_type) { + this.wf_type = wf_type; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTimeinfo() { + return timeinfo; + } + + public void setTimeinfo(String timeinfo) { + this.timeinfo = timeinfo; + } + + + public TCComponent getComp() { + return comp; + } + + public void setComp(TCComponent comp) { + this.comp = comp; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + @Override + public String toString() { + return "Workflow_InfoBean [puid=" + puid + ", wf_type=" + wf_type + ", userId=" + userId + ", timeinfo=" + + timeinfo + ", logTime=" + logTime + ", comp=" + comp + ", date=" + date + "]"; + } + + + +} diff --git a/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties b/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties new file mode 100644 index 0000000..0f4401d --- /dev/null +++ b/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties @@ -0,0 +1,8 @@ +T2_ECRRevisionMaster.FORMJAVARENDERING=com.connor.dfl.plm.forms.ChangeApplyForm +T2_ECNRevisionMaster.FORMJAVARENDERING=com.connor.dfl.plm.forms.ChangeNotifyForm +T2_QECNRevisionMaster.FORMJAVARENDERING=com.connor.dfl.plm.forms.QuickChangeForm +T2_PVECNRevisionMaster.FORMJAVARENDERING=com.connor.dfl.plm.forms.PressureChangeForm + + + +