commit 0325660cf66bad528fca8c0b2d9c6ffd035d3f6d Author: lijh Date: Tue Jun 3 11:01:04 2025 +0800 20250603 diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..807c97a --- /dev/null +++ b/.classpath @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..543aeb4 --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + hsteam-center-project + + + + + + 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..0fee6a9 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,15 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000..bed95d3 --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,1171 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Plm +Bundle-SymbolicName: com.connor.hs2.plm.project;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Vendor: connor +Require-Bundle: org.eclipse.ui, + com.teamcenter.rac.aifrcp, + com.teamcenter.rac.common, + com.teamcenter.rac.kernel, + com.teamcenter.rac.tcapps, + com.teamcenter.rac.util, + org.eclipse.core.runtime;bundle-version="3.12.0", + com.teamcenter.rac.schedule, + com.teamcenter.rac.ui.commands, + TcSoaCoreRac, + com.teamcenter.rac.cme.bvr.connect, + com.teamcenter.rac.cme.license, + TcSoaStructureManagementRac, + com.teamcenter.rac.ms.util, + com.teamcenter.rac.cme.framework, + com.teamcenter.rac.cme.kernel, + com.teamcenter.rac.cme.common +Automatic-Module-Name: com.connor.hs2.plm.project +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +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.nbhs.plm.hs001, + com.connor.nbhs.plm.shentu.BOMTransform, + com.connor.nbhs.plm.shentu.createDelivery, + com.connor.nbhs.plm.shentu.handlers, + com.connor.nbhs.plm.shentu.hs013SpotcheckDelivery, + com.connor.nbhs.plm.shentu.utils, + 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.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, + com.teamcenter.rac.cme.bvr.create.fromtemplate, + 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.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.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 +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/cn.com.origin.autocode_1.0.0.jar, + lib/cn.com.origin.autocodemanager_1.0.0.jar, + lib/commons-beanutils-1.7.0.jar, + lib/commons-cli-1.2.jar, + lib/commons-fileupload-1.2.jar, + lib/commons-httpclient-3.1.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/jxl.jar, + lib/log4j-1.2.15.jar, + lib/log4j-core-2.8.2.jar, + lib/mail-1.4.jar, + lib/mex-1.6.2-impl.jar, + lib/neethi-3.0.2.jar, + lib/org.eclipse.osgi.services_3.7.100.v20180827-1536.jar, + lib/org.eclipse.osgi.services.nl_12000.2.0.jar, + lib/regexp-1.2.jar, + lib/Spire.Xls.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/ojdbc8.jar, + lib/swingx-1.6.2.jar, + lib/commons-compress-1.21.jar, + lib/commons-math3-3.6.1.jar, + lib/curvesapi-1.07.jar, + lib/log4j-api-2.17.2.jar, + lib/poi-5.2.2.jar, + lib/poi-ooxml-5.2.2.jar, + lib/poi-ooxml-full-5.2.2.jar, + lib/poi-ooxml-schemas-3.7-20101029.jar, + lib/slf4j-api-1.7.36.jar, + lib/SparseBitSet-1.2.jar, + lib/xmlbeans-5.0.3.jar, + lib/commons-codec-1.15.jar, + lib/commons-collections4-4.4.jar, + lib/commons-io-2.11.0.jar, + lib/commons-logging-1.2.jar, + ., + lib/commons-collections-3.1.jar, + lib/TcSoaClassificationRac_12000.2.0.jar, + lib/TcSoaClient_12000.2.0.jar, + lib/TcSoaCommon_12000.2.0.jar, + lib/TcSoaClassificationStrong-12.3.0.jar, + lib/TcSoaCoreStrong-12.3.0.jar, + lib/TcSoaStrongModel-12.3.0.jar +Import-Package: com.teamcenter.services.loose.projectmanagement._2015_07, + com.teamcenter.services.rac.projectmanagement._2007_01, + com.teamcenter.services.rac.projectmanagement._2015_07 diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..ff1947c --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1,2 @@ +/com/ +/sql.properties diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..1e94e62 --- /dev/null +++ b/build.properties @@ -0,0 +1,114 @@ +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/cn.com.origin.autocode_1.0.0.jar,\ + lib/cn.com.origin.autocodemanager_1.0.0.jar,\ + lib/commons-beanutils-1.7.0.jar,\ + lib/commons-cli-1.2.jar,\ + lib/commons-fileupload-1.2.jar,\ + lib/commons-httpclient-3.1.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/jxl.jar,\ + lib/log4j-1.2.15.jar,\ + lib/log4j-core-2.8.2.jar,\ + lib/mail-1.4.jar,\ + lib/mex-1.6.2-impl.jar,\ + lib/neethi-3.0.2.jar,\ + lib/org.eclipse.osgi.services_3.7.100.v20180827-1536.jar,\ + lib/org.eclipse.osgi.services.nl_12000.2.0.jar,\ + lib/regexp-1.2.jar,\ + lib/Spire.Xls.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/ojdbc8.jar,\ + lib/swingx-1.6.2.jar,\ + lib/commons-compress-1.21.jar,\ + lib/commons-math3-3.6.1.jar,\ + lib/curvesapi-1.07.jar,\ + lib/log4j-api-2.17.2.jar,\ + lib/poi-5.2.2.jar,\ + lib/poi-ooxml-5.2.2.jar,\ + lib/poi-ooxml-full-5.2.2.jar,\ + lib/poi-ooxml-schemas-3.7-20101029.jar,\ + lib/slf4j-api-1.7.36.jar,\ + lib/SparseBitSet-1.2.jar,\ + lib/xmlbeans-5.0.3.jar,\ + lib/commons-codec-1.15.jar,\ + lib/commons-collections4-4.4.jar,\ + lib/commons-io-2.11.0.jar,\ + lib/commons-logging-1.2.jar,\ + lib/commons-collections-3.1.jar,\ + lib/TcSoaClassificationRac_12000.2.0.jar,\ + lib/TcSoaClient_12000.2.0.jar,\ + lib/TcSoaCommon_12000.2.0.jar,\ + lib/TcSoaClassificationStrong-12.3.0.jar,\ + lib/TcSoaCoreStrong-12.3.0.jar,\ + lib/TcSoaStrongModel-12.3.0.jar diff --git a/icons/sample.png b/icons/sample.png new file mode 100644 index 0000000..02c4b79 Binary files /dev/null and b/icons/sample.png differ diff --git a/icons/sample@2x.png b/icons/sample@2x.png new file mode 100644 index 0000000..c1224d1 Binary files /dev/null and b/icons/sample@2x.png differ diff --git a/lib/SparseBitSet-1.2.jar b/lib/SparseBitSet-1.2.jar new file mode 100644 index 0000000..bdb6771 Binary files /dev/null and b/lib/SparseBitSet-1.2.jar 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/TcSoaClassificationRac_12000.2.0.jar b/lib/TcSoaClassificationRac_12000.2.0.jar new file mode 100644 index 0000000..b0c2074 Binary files /dev/null and b/lib/TcSoaClassificationRac_12000.2.0.jar differ diff --git a/lib/TcSoaClassificationStrong-12.3.0.jar b/lib/TcSoaClassificationStrong-12.3.0.jar new file mode 100644 index 0000000..14d536b Binary files /dev/null and b/lib/TcSoaClassificationStrong-12.3.0.jar differ diff --git a/lib/TcSoaClient_12000.2.0.jar b/lib/TcSoaClient_12000.2.0.jar new file mode 100644 index 0000000..4a8850c Binary files /dev/null and b/lib/TcSoaClient_12000.2.0.jar differ diff --git a/lib/TcSoaCommon_12000.2.0.jar b/lib/TcSoaCommon_12000.2.0.jar new file mode 100644 index 0000000..f935151 Binary files /dev/null and b/lib/TcSoaCommon_12000.2.0.jar differ diff --git a/lib/TcSoaCoreStrong-12.3.0.jar b/lib/TcSoaCoreStrong-12.3.0.jar new file mode 100644 index 0000000..3fe6149 Binary files /dev/null and b/lib/TcSoaCoreStrong-12.3.0.jar differ diff --git a/lib/TcSoaStrongModel-12.3.0.jar b/lib/TcSoaStrongModel-12.3.0.jar new file mode 100644 index 0000000..cfe35c0 Binary files /dev/null and b/lib/TcSoaStrongModel-12.3.0.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..403f1b9 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..9e1d54e 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.15.jar b/lib/commons-codec-1.15.jar new file mode 100644 index 0000000..f14985a Binary files /dev/null and b/lib/commons-codec-1.15.jar differ diff --git a/lib/commons-collections-3.1.jar b/lib/commons-collections-3.1.jar new file mode 100644 index 0000000..41e230f Binary files /dev/null and b/lib/commons-collections-3.1.jar differ diff --git a/lib/commons-collections4-4.4.jar b/lib/commons-collections4-4.4.jar new file mode 100644 index 0000000..da06c3e Binary files /dev/null and b/lib/commons-collections4-4.4.jar differ diff --git a/lib/commons-compress-1.21.jar b/lib/commons-compress-1.21.jar new file mode 100644 index 0000000..4892334 Binary files /dev/null and b/lib/commons-compress-1.21.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-2.11.0.jar b/lib/commons-io-2.11.0.jar new file mode 100644 index 0000000..be507d9 Binary files /dev/null and b/lib/commons-io-2.11.0.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.2.jar b/lib/commons-logging-1.2.jar new file mode 100644 index 0000000..93a3b9f Binary files /dev/null and b/lib/commons-logging-1.2.jar differ diff --git a/lib/commons-math3-3.6.1.jar b/lib/commons-math3-3.6.1.jar new file mode 100644 index 0000000..0ff582c Binary files /dev/null and b/lib/commons-math3-3.6.1.jar differ diff --git a/lib/curvesapi-1.07.jar b/lib/curvesapi-1.07.jar new file mode 100644 index 0000000..2b05714 Binary files /dev/null and b/lib/curvesapi-1.07.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/log4j-api-2.17.2.jar b/lib/log4j-api-2.17.2.jar new file mode 100644 index 0000000..16d9061 Binary files /dev/null and b/lib/log4j-api-2.17.2.jar differ diff --git a/lib/log4j-core-2.8.2.jar b/lib/log4j-core-2.8.2.jar new file mode 100644 index 0000000..eb658af Binary files /dev/null and b/lib/log4j-core-2.8.2.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/minio-8.4.5-all.jar b/lib/minio-8.4.5-all.jar new file mode 100644 index 0000000..0e0f57c Binary files /dev/null and b/lib/minio-8.4.5-all.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/ojdbc8.jar b/lib/ojdbc8.jar new file mode 100644 index 0000000..4c91569 Binary files /dev/null and b/lib/ojdbc8.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/poi-5.2.2.jar b/lib/poi-5.2.2.jar new file mode 100644 index 0000000..add8419 Binary files /dev/null and b/lib/poi-5.2.2.jar differ diff --git a/lib/poi-ooxml-5.2.2.jar b/lib/poi-ooxml-5.2.2.jar new file mode 100644 index 0000000..9bfe818 Binary files /dev/null and b/lib/poi-ooxml-5.2.2.jar differ diff --git a/lib/poi-ooxml-full-5.2.2.jar b/lib/poi-ooxml-full-5.2.2.jar new file mode 100644 index 0000000..54c1322 Binary files /dev/null and b/lib/poi-ooxml-full-5.2.2.jar differ diff --git a/lib/regexp-1.2.jar b/lib/regexp-1.2.jar new file mode 100644 index 0000000..713441c Binary files /dev/null and b/lib/regexp-1.2.jar differ diff --git a/lib/slf4j-api-1.7.36.jar b/lib/slf4j-api-1.7.36.jar new file mode 100644 index 0000000..7d3ce68 Binary files /dev/null and b/lib/slf4j-api-1.7.36.jar differ diff --git a/lib/swingx-1.6.2.jar b/lib/swingx-1.6.2.jar new file mode 100644 index 0000000..6ec2699 Binary files /dev/null and b/lib/swingx-1.6.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-5.0.3.jar b/lib/xmlbeans-5.0.3.jar new file mode 100644 index 0000000..63b0ab8 Binary files /dev/null and b/lib/xmlbeans-5.0.3.jar differ diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..21fb438 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,979 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sql.properties b/sql.properties new file mode 100644 index 0000000..fcf139a --- /dev/null +++ b/sql.properties @@ -0,0 +1,31 @@ +SETPFMEASELECT=SELECT * FROM AHMC_PFMEA WHERE PROCESSPUID = \'%s\' AND REVISIONID=\'%s\' ORDER BY to_number(NO),to_number(HH) +PFMEALIBRARYSELECT2=SELECT * FROM AHMC_PFMEALIBRARY WHERE PUID = \'%s\' order by NUM + +BOMCHECKSAVESELECTPFMEA=select MEOPID,station,gybh,GCMC from AHMC_PFMEA where PROCESSPUID = \'%s\' + +BOMCHECKSAVESELECTPFMEA2=select * from AHMC_PFMEA where PROCESSPUID = \'%s\' and MEOPID not in %s + +DELETEPFMEA=delete from AHMC_PFMEA where MEOPID = \'%s\' and PROCESSPUID = \'%s\' + +INSERTPFMEA=INSERT INTO AHMC_PFMEA VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + +PFMEALIBRARYSELECT=SELECT * FROM AHMC_PFMEA_NODE WHERE PARENT_ID = \'%s\' order BY ID +SETPFMEASELECT2=SELECT MEOPID,REQUIREMENT from AHMC_PFMEA where PROCESSPUID = \'%s\' group by MEOPID,REQUIREMENT +SETPFMEADELETE=delete from AHMC_PFMEA where PLMEID = \'%s\' + +SETPFMEAUPDATE=update AHMC_PFMEA set GYBH = ?,GCMC = ?,STATION = ?,REQUIREMENT = ?,QZSXMS = ?,QZSXHG = ?,YZD = ?,JB = ?,QZSXQY = ?,XXGCKZYF = ?,PDS = ?,XXGCKZTC = ?,TCD = ?,RPN = ?,JYCS = ?,ZZR = ?,JHWCRQ = ?,CQDCS = ?,NEW_SEV = ?,NEW_OCC = ?,NEW_DET = ?,NEW_RPN = ?,IDEAL_STATE = ?,SPECIAL = ?,HH = ?,HBDYG = ? ,OCCURRRENCE = ?,DETECTION = ?,PRIORITY = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ? where plmeid = \'%s\' AND revisionid=\'%s\' +TM2PFMEATREESELECT=select * from AHMC_PFMEA_TREE ORDER BY PARENT_ID,ID + +CONTROLPLANLIBRARYSELECT=SELECT * FROM AHMC_CONTROLPLAN_NODE WHERE PARENT_ID = \'%s\' order BY ID + +TM2CONTROLPLANTREESELECT=select * from AHMC_CONTROLPLAN_TREE ORDER BY TO_NUMBER(PARENT_ID) + +TM2THESAURUSTREESELECT=select * from AHMC_THESAURUS_TREE ORDER BY TO_NUMBER(PARENT_ID) + +TM2THESAURUSNODESELECT=SELECT * FROM AHMC_THESAURUS_NODE WHERE PARENT_ID = \'%s\' order BY ID + +PFMEALIBRARYUPDATE=update AHMC_PFMEA_NODE set ID = ?, STATION = ?,REQUIREMENT = ?,QZSXMS = ?,QZSXHG = ?,YZD = ?,JB = ?,QZSXQY = ?,XXGCKZYF = ?,PDS = ?,XXGCKZTC = ?,TCD = ?,RPN = ?,JYCS = ?,ZZR = ?,JHWCRQ = ?,CQDCS = ?,NEW_SEV = ?,NEW_OCC = ?,NEW_DET = ?,NEW_RPN = ?,IDEAL_STATE = ?,SPECIAL = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ?,P6 = ?,P7 = ?,P8 = ? where plmeid = \'%s\' + +PFMEALIBRARYDELETE=delete from AHMC_PFMEA_NODE where PLMEID = \'%s\' + +PFMEALIBRARYINSERT=INSERT INTO AHMC_PFMEA_NODE VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) \ No newline at end of file diff --git a/src/com/connor/hs/plm/GCLCT/GCLCTDialog.java b/src/com/connor/hs/plm/GCLCT/GCLCTDialog.java new file mode 100644 index 0000000..b2526a8 --- /dev/null +++ b/src/com/connor/hs/plm/GCLCT/GCLCTDialog.java @@ -0,0 +1,459 @@ +package com.connor.hs.plm.GCLCT; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import javax.naming.InitialContext; +import javax.swing.JOptionPane; + +import com.connor.hs2.plm.PFMEA.GXZDS.MethodUtil; +import com.spire.xls.InsertOptionsType; +import com.spire.xls.LineShapeType; +import com.spire.xls.ShapeArrowStyleType; +import com.spire.xls.Workbook; +import com.spire.xls.Worksheet; +import com.spire.xls.collections.WorksheetsCollection; +import com.spire.xls.core.ILineShape; +import com.spire.xls.core.spreadsheet.collections.LineCollection; +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.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class GCLCTDialog extends AbstractAIFDialog{ + private int end=0; + private File file ; + private TCSession session ; + private TCComponentItemRevision topRevision; + private TCComponentItemRevision targetRev; + private TCComponentBOMLine line; + public GCLCTDialog(TCSession session, TCComponentItemRevision topRevision, TCComponentItemRevision targetRev) { + + file = MethodUtil.getFiles(session, "过程流程图", "MSExcel"); + this.session = session; + this.topRevision = topRevision; + this.targetRev = targetRev; + + try { + TCComponentBOMWindowType bopWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow bopWindow = bopWindowType.create(null); + TCComponentBOMLine topBopline = bopWindow.setWindowTopLine(targetRev.getItem(), targetRev , null, null); + this.line = topBopline; + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + +// this.line=line; + init(); + } + + private Map map = new HashMap(); + private void getRefs() { + // TODO Auto-generated method stub + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues("Characteristic_PIC"); + if (modelFiles == null) + { + System.out.println("未找到首选项"); + return; + } + for(String string :modelFiles ) { + + String[] split = string.split("-"); + + if(split.length ==2) { + + String string2 = split[1]; + try { + TCComponentDataset component = (TCComponentDataset) session.stringToComponent(string2); + TCComponentTcFile[] tcFile = component.getTcFiles(); + map.put(split[0], tcFile[0].getFmsFile()); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + } + + } + public static void setSheetText(Worksheet sheet,int row,int cell,String value) { + + sheet.setText(row, cell, (value==null || value.equals(""))?" ":value); + } + private ArrayList bomlines=new ArrayList(); + private String nameString=""; + private String outPathString =System.getenv("TEMP") + "\\";//导出路径 + private void init() { + // TODO Auto-generated method stub + + try { + getRefs(); //Keycharacteristics 关键 Processcharacteristics 过程 KeyandProcess all + Workbook wb = new Workbook(); + + FileInputStream input1 = new FileInputStream(this.file); + wb.loadFromHtml(input1); + //加载一个测试文档 + //wb.loadFromFile("C:\\美菱导出测试\\作业指导书.xlsx"); + //MessageBox.post(outPathString,"错误",MessageBox.ERROR); + //获取第一个工作表 + WorksheetsCollection worksheets = wb.getWorksheets(); + Worksheet sheet = worksheets.get(2); + if(worksheets.getCount()==4) { + worksheets.remove(3); + } +// Worksheet sheet2 = wb.getWorksheets().add("Copy"); +// sheet2.copyFrom(sheet); + nameString = targetRev.getStringProperty("object_name"); + + TCComponent material = topRevision.getRelatedComponent("IMAN_METarget"); + if(material==null) { + MessageBox.post("顶层工艺IMAN_METarget下没有物料对象","提示",2); + System.out.println("顶层工艺IMAN_METarget下没有物料对象"); +// sout("顶层工艺IMAN_METarget下没有物料对象","提升",2); + }else { + System.out.println(material.getStringProperty("object_string")); + TCComponent pic = material.getRelatedComponent("TC_Is_Represented_By"); + if(pic!=null ) { + setSheetText(sheet,4,3,pic.getStringProperty("item_id")+"-"+pic.getStringProperty("object_name")); + + }else { + int option = JOptionPane.showOptionDialog(null, "当前工艺所绑定的总成物料未找到关联图纸,是否需要继续生成过程流程图?", "", 0, 1, null, null, + Integer.valueOf(0)); + if(option==0) { + setSheetText(sheet,7,3 ,material.getStringProperty("object_name")); //劳保工具 + setSheetText(sheet,7,13,material.getStringProperty("item_id")); + }else { + return; + } + } + } + + TCComponent material2 = targetRev.getRelatedComponent("IMAN_METarget"); + if(material2!=null) { + System.out.println(material2.getStringProperty("object_string")); + TCComponent pic2 = material2.getRelatedComponent("TC_Is_Represented_By"); +// sheet + if(pic2!=null) { + setSheetText(sheet,5,3,pic2.getStringProperty("object_name")); + setSheetText(sheet,6,3,pic2.getStringProperty("item_id")); + } + + } + + + if(targetRev.getItem().getType().equals("HS2_ProductMEP")) { + AIFComponentContext[] children = line.getChildren(); + for(AIFComponentContext child:children) { + TCComponentBOMLine component = (TCComponentBOMLine) child.getComponent(); + if(component.getItem().getType().equals("HS2_SpecialMEP")) { + System.out.println("HS2_SpecialMEP -----"); + AIFComponentContext[] children2 = component.getChildren(); + for(AIFComponentContext context:children2) { + bomlines.add((TCComponentBOMLine) context.getComponent()); + } + } + + } + }else { + AIFComponentContext[] children = line.getChildren(); + for(AIFComponentContext context:children) { + bomlines.add((TCComponentBOMLine) context.getComponent()); + } + } + System.out.println(bomlines.toString()); + + int t=10; + + int old=0; + + StringBuffer errBuffer = new StringBuffer(); + for(int i=0;i18 && i!=bomlines.size()-1) { + sheet.insertRow(t,1,InsertOptionsType.FormatAsBefore); + } + sheet.setRowHeight(t, sheet.getRowHeight(10)); + String stringProperty = bomlines.get(i).getStringProperty("hs2_ProcessNo"); + TCComponentItemRevision itemRevision = bomlines.get(i).getItemRevision(); + setSheetText(sheet,t,9,itemRevision.getStringProperty("object_name")); + String type = itemRevision.getStringProperty("hs2_Processoperation"); + System.out.println(type); + String insertType = getInsertType(type); + System.out.println("end"+end+"insertType"+insertType+"old"+old); + insertPicToSheet(sheet,t,itemRevision); + setSheetText(sheet,t,1,stringProperty); + if(end==0) { + continue; + } + setSheetText(sheet,t,end,insertType); + if(i>0 && old !=0 && end!=0) { + + if(old<=end) { + + addLineRight(old,end,t-1,sheet); + }else { + addLeftRight(old,end,t-1,sheet); + } + + } + old = end; + t=t+1; + } + + + + + + try { +// TCComponentItemRevision revision = this.target.getLatestItemRevision(); + Boolean hasB = false; + TCComponent[] refs = targetRev.getItem().getReferenceListProperty("IMAN_reference"); + for(TCComponent ref:refs) { + if(ref.getStringProperty("object_name").contains("-过程流程图")) { + System.out.println("已经存在过程流程图"); + hasB = true; +// TCComponentItem itemRef =(TCComponentItem) ref; +// if(MethodUtil.getExcelToItem(session,itemRef.getLatestItemRevision(), +// "IMAN_specification", "MSExcelX",nameString+"过程流程图") != null) { +// MethodUtil.changeDataSet(MethodUtil.getExcelToDataset(session,itemRef.getLatestItemRevision(), +// "IMAN_specification", "MSExcelX",nameString+"过程流程图"), "excel", "MSExcelX", outPathString+nameString+"过程流程图.xlsx"); +// } +// revRevision.ge +// MethodUtil.changeDataSet(MethodUtil.getExcelToDataset(session,latestItemRevision, +// "IMAN_specification", "MSExcelX",nameString+"过程流程图"), "excel", "MSExcelX", outPathString+nameString+"过程流程图.xlsx"); + } + } + String hs2_ProcessNo = this.targetRev.getStringProperty("hs2_ProcessNo"); + String objName = this.targetRev.getStringProperty("object_name"); + String string = hs2_ProcessNo+"-"+objName+"-过程流程图.xlsx"; + string = string.replaceAll("/","-"); + wb.saveToFile(outPathString+string); + nameString = string; + Worksheet sheetRemove = wb.getWorksheets().get(wb.getActiveSheetIndex());//删除有水印的最后一页 + sheetRemove.remove(); + wb.saveToFile(outPathString+string); + if(!hasB) { + + TCComponentItemType tcComponentItemType = (TCComponentItemType) session.getTypeComponent("HS2_Process"); + String newID = tcComponentItemType.getNewID(); + String newRev = tcComponentItemType.getNewRev(null); + TCComponentItem item = tcComponentItemType.create(newID, newRev, "HS2_Process", hs2_ProcessNo+"-"+objName+"-过程流程图", "", null); + this.targetRev.getItem().add("IMAN_reference", item); + TCComponentItemRevision latestItemRevision = item.getLatestItemRevision(); + MethodUtil.setExcelToItem(session,latestItemRevision,outPathString+nameString,hs2_ProcessNo+"-"+objName+"-过程流程图","IMAN_specification", + "MSExcelX", true); + } +// else { +// MethodUtil.setExcelToItem(session,latestItemRevision,outPathString+nameString+"过程流程图.xlsx",nameString+"过程流程图","IMAN_specification", +// "MSExcelX", true); +// +// } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if(new File(outPathString+nameString).exists()) { + new File(outPathString+nameString).delete(); + } + + MessageBox.post("生成过程流程图完成","提升",2); + + } catch (FileNotFoundException | TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + private void insertPicToSheet(Worksheet sheet, int t, TCComponentItemRevision itemRevision) { + // TODO Auto-generated method stub + //Keycharacteristics 关键 Processcharacteristics 过程 KeyandProcess all + try { + boolean key=false; + boolean process=false; + TCComponent[] hs2_ProcessControls = itemRevision.getReferenceListProperty("hs2_ProcessControl"); + for(TCComponent control:hs2_ProcessControls) { + + String hs2_Characteristic = control.getStringProperty("hs2_Characteristic"); + if(hs2_Characteristic.equals("Keycharacteristics")) { + key=true; + }else if (hs2_Characteristic.equals("Processcharacteristics")) { + process = true; + }else if (hs2_Characteristic.equals("KeyandProcess")) { + key=true; + process = true; + } + + } + + if(key && map.containsKey("Keycharacteristics")) { + File file2 = map.get("Keycharacteristics"); + MethodUtil.InsertTitlePicture(sheet,file2,new int[] {t}, + new int[] {13,14},true,4); + } + if(process && map.containsKey("Processcharacteristics")) { + File file2 = map.get("Processcharacteristics"); + MethodUtil.InsertTitlePicture(sheet,file2,new int[] {t}, + new int[] {17},true,4); + } + + + } catch (TCException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + + + + } + private void addLeftRight(int old, int end, int t, Worksheet sheet) { + // TODO Auto-generated method stub + LineCollection typedLines = sheet.getTypedLines(); + ILineShape addLine = typedLines.addLine(1,1,1,1,LineShapeType.LineInv); + addLine.setTop(getHeightByRow(t,sheet)+12); + addLine.setLeft(getWidthByCol(end,sheet)+5); + addLine.setWidth(getWidthByCol(old,sheet)-getWidthByCol(end,sheet)-15); + addLine.setHeight(sheet.getRowHeightPixels(10)-15); + + addLine.setBeginArrowHeadStyle(ShapeArrowStyleType.LineArrow); + addLine.setEndArrowHeadStyle(ShapeArrowStyleType.LineNoArrow); + } + private void addLineRight(int old, int end,int t, Worksheet sheet) { + // TODO Auto-generated method stub + + + + LineCollection typedLines = sheet.getTypedLines(); + ILineShape addLine = typedLines.addLine(); + + if(old==end) { + addLine.setTop(getHeightByRow(t,sheet)+8); + addLine.setLeft(getWidthByCol(old,sheet)); + addLine.setWidth(getWidthByCol(end,sheet)-getWidthByCol(old,sheet)-17); + addLine.setHeight(sheet.getRowHeightPixels(10)-14); + }else { + addLine.setTop(getHeightByRow(t,sheet)+6); + addLine.setLeft(getWidthByCol(old,sheet)+8); + addLine.setWidth(getWidthByCol(end,sheet)-getWidthByCol(old,sheet)-17); + addLine.setHeight(sheet.getRowHeightPixels(10)-14); + } + + + + addLine.setBeginArrowHeadStyle(ShapeArrowStyleType.LineNoArrow); + addLine.setEndArrowHeadStyle(ShapeArrowStyleType.LineArrow); + + } + + private static int getHeightByRow(int row,Worksheet sheet) { + int colWidth=0; + for(int i=1;i map = new HashMap(); + private void getRefs() { + // TODO Auto-generated method stub + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues("Characteristic_PIC"); + if (modelFiles == null) + { + System.out.println("未找到首选项"); + return; + } + for(String string :modelFiles ) { + + String[] split = string.split("-"); + + if(split.length ==2) { + + String string2 = split[1]; + try { + TCComponentDataset component = (TCComponentDataset) session.stringToComponent(string2); + TCComponentTcFile[] tcFile = component.getTcFiles(); + map.put(split[0], tcFile[0].getFmsFile()); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + } + + } + public static void setSheetText(Worksheet sheet,int row,int cell,String value) { + + sheet.setText(row, cell, (value==null || value.equals(""))?" ":value); + } + private Map revMap =new HashMap(); + private Map> sheetMap =new HashMap>(); + private ArrayList bomlines=new ArrayList(); //专项工艺 + private String nameString=""; + private String outPathString =System.getenv("TEMP") + "\\";//导出路径 + private void init() { + // TODO Auto-generated method stub + + try { + getRefs(); //Keycharacteristics 关键 Processcharacteristics 过程 KeyandProcess all + Workbook wb = new Workbook(); + FileInputStream input1 = new FileInputStream(this.file); + wb.loadFromHtml(input1); + //加载一个测试文档 + //wb.loadFromFile("C:\\美菱导出测试\\作业指导书.xlsx"); + //MessageBox.post(outPathString,"错误",MessageBox.ERROR); + //获取第一个工作表 + WorksheetsCollection worksheets = wb.getWorksheets(); + Worksheet sheet = worksheets.get(2); +// Worksheet sheet2 = wb.getWorksheets().add("Copy"); +// sheet2.copyFrom(sheet); + nameString = targetRev.getStringProperty("object_name"); + + TCComponent material = topRevision.getRelatedComponent("IMAN_METarget"); + String proName=""; + if(material==null) { + MessageBox.post("顶层工艺IMAN_METarget下没有物料对象","提示",2); + System.out.println("顶层工艺IMAN_METarget下没有物料对象"); +// sout("顶层工艺IMAN_METarget下没有物料对象","提升",2); + }else { + System.out.println(material.getStringProperty("object_string")); + TCComponent pic = material.getRelatedComponent("TC_Is_Represented_By"); + if(pic!=null ) { + + proName = pic.getStringProperty("item_id")+"-"+pic.getStringProperty("object_name"); + + + }else { + int option = JOptionPane.showOptionDialog(null, "当前工艺所绑定的总成物料未找到关联图纸,是否需要继续生成过程流程图?", "", 0, 1, null, null, + Integer.valueOf(0)); + if(option==0) { + proName = material.getStringProperty("object_name"); +// setSheetText(sheet,7,3 ,material.getStringProperty("object_name")); //劳保工具 +// setSheetText(sheet,7,13,material.getStringProperty("item_id")); + }else { + return; + } + } + } + Worksheet sheetCopy = worksheets.get(3); + boolean isfirst = true; + if(targetRev.getItem().getType().equals("HS2_ProductMEP")) { + AIFComponentContext[] children = line.getChildren(); + for(AIFComponentContext child:children) { + TCComponentBOMLine component = (TCComponentBOMLine) child.getComponent(); + if(component.getItem().getType().equals("HS2_SpecialMEP")) { + //所有专项工艺工序放一起 + System.out.println("HS2_SpecialMEP -----"); + AIFComponentContext[] children2 = component.getChildren(); + for(AIFComponentContext context:children2) { + bomlines.add((TCComponentBOMLine) context.getComponent()); + } + }else if (component.getItem().getType().equals("HS2_AssemblyMEP")) { + //装配工艺的新加个sheet页 + String assemName = component.getItemRevision().getStringProperty("object_name"); + ArrayList assemblyLine=new ArrayList(); + AIFComponentContext[] children2 = component.getChildren(); + for(AIFComponentContext context:children2) { + assemblyLine.add((TCComponentBOMLine) context.getComponent()); + } +// if(sheetMap.containsKey(assemName)) { +// sheetMap.put(assemName+"1", assemblyLine); +// }else { + String pattern = "[/:*?\"]"; + assemName = assemName.replaceAll(pattern, ""); + sheetMap.put(assemName, assemblyLine); + revMap.put(assemName, component.getItemRevision()); +// } + if(isfirst) { + Worksheet sheet2 = worksheets.get(3); + isfirst = false; + sheet2.setName(assemName); + + }else { + Worksheet sheet2 = worksheets.add("Copy"); + sheet2.copyFrom(sheetCopy); + + sheet2.setName(assemName); + } + + } + } + } + + if(isfirst) { + worksheets.remove(3); + } + + setSheetText(sheet,4,3,proName); + + addSheet(bomlines,sheet,topRevision,true); + int count = worksheets.getCount(); + for(int i=3;i"+name); + if(sheetMap.containsKey(name)) { + ArrayList arrayList = sheetMap.get(name); + addSheet(arrayList,worksheet,revMap.get(name),false); + } + } + revMap.clear(); + sheetMap.clear(); + try { +// TCComponentItemRevision revision = this.target.getLatestItemRevision(); + //新建对象,数据集放对象下面 + Boolean hasB = false; + TCComponent[] refs = targetRev.getItem().getReferenceListProperty("IMAN_reference"); + for(TCComponent ref:refs) { + if(ref.getStringProperty("object_name").contains("-过程流程图")) { + System.out.println("已经存在过程流程图"); + hasB = true; +// TCComponentItem itemRef =(TCComponentItem) ref; +// if(MethodUtil.getExcelToItem(session,itemRef.getLatestItemRevision(), +// "IMAN_specification", "MSExcelX",nameString+"过程流程图") != null) { +// MethodUtil.changeDataSet(MethodUtil.getExcelToDataset(session,itemRef.getLatestItemRevision(), +// "IMAN_specification", "MSExcelX",nameString+"过程流程图"), "excel", "MSExcelX", outPathString+nameString+"过程流程图.xlsx"); +// } +// revRevision.ge +// MethodUtil.changeDataSet(MethodUtil.getExcelToDataset(session,latestItemRevision, +// "IMAN_specification", "MSExcelX",nameString+"过程流程图"), "excel", "MSExcelX", outPathString+nameString+"过程流程图.xlsx"); + } + } + String hs2_ProcessNo = this.targetRev.getStringProperty("hs2_ProcessNo"); + String objName = this.targetRev.getStringProperty("object_name"); + String string = hs2_ProcessNo+"-"+objName+"-过程流程图.xlsx"; + string = string.replaceAll("/","-"); + wb.saveToFile(outPathString+string); + nameString = string; + Worksheet sheetRemove = wb.getWorksheets().get(wb.getActiveSheetIndex());//删除有水印的最后一页 + sheetRemove.remove(); + wb.saveToFile(outPathString+string); + if(!hasB) { + + TCComponentItemType tcComponentItemType = (TCComponentItemType) session.getTypeComponent("HS2_Process"); + String newID = tcComponentItemType.getNewID(); + String newRev = tcComponentItemType.getNewRev(null); + TCComponentItem item = tcComponentItemType.create(newID, newRev, "HS2_Process", hs2_ProcessNo+"-"+objName+"-过程流程图", "", null); + this.targetRev.getItem().add("IMAN_reference", item); + TCComponentItemRevision latestItemRevision = item.getLatestItemRevision(); + MethodUtil.setExcelToItem(session,latestItemRevision,outPathString+nameString,hs2_ProcessNo+"-"+objName+"-过程流程图","IMAN_specification", + "MSExcelX", true); + } +// else { +// MethodUtil.setExcelToItem(session,latestItemRevision,outPathString+nameString+"过程流程图.xlsx",nameString+"过程流程图","IMAN_specification", +// "MSExcelX", true); +// +// } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if(new File(outPathString+nameString).exists()) { + new File(outPathString+nameString).delete(); + } + + MessageBox.post("生成过程流程图完成","提升",2); + + } catch (FileNotFoundException | TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + private void addSheet(ArrayList childLines,Worksheet sheet,TCComponentItemRevision revision,boolean isTop) throws TCException { + // TODO Auto-generated method stub + end=0; + System.out.println(childLines.toString()); + if(!isTop) { + TCComponent material = revision.getRelatedComponent("IMAN_METarget"); + String proName=""; + if(material==null) { +// sout("顶层工艺IMAN_METarget下没有物料对象","提升",2); + }else { + TCComponent pic = material.getRelatedComponent("TC_Is_Represented_By"); + if(pic!=null ) { + proName = pic.getStringProperty("item_id")+"-"+pic.getStringProperty("object_name"); + + }else { +// int option = JOptionPane.showOptionDialog(null, "当前工艺所绑定的总成物料未找到关联图纸,是否需要继续生成过程流程图?", "", 0, 1, null, null, +// Integer.valueOf(0)); +// if(option==0) { + proName = material.getStringProperty("object_name"); +// }else { +// return; +// } + } + } + setSheetText(sheet,4,3,proName); + } + + TCComponent material2 = revision.getRelatedComponent("IMAN_METarget"); + if(material2!=null) { + System.out.println(material2.getStringProperty("object_string")); + TCComponent pic2 = material2.getRelatedComponent("TC_Is_Represented_By"); +// sheet + if(pic2!=null) { + setSheetText(sheet,5,3,pic2.getStringProperty("object_name")); + sheet.setName(pic2.getStringProperty("object_name")); + setSheetText(sheet,6,3,pic2.getStringProperty("item_id")); + } + + } + int t=10; + + int old=0; + + StringBuffer errBuffer = new StringBuffer(); + for(int i=0;i18 && i!=childLines.size()-1) { + sheet.insertRow(t,1,InsertOptionsType.FormatAsBefore); + } + sheet.setRowHeight(t, sheet.getRowHeight(10)); + String stringProperty = childLines.get(i).getStringProperty("hs2_ProcessNo"); + TCComponentItemRevision itemRevision = childLines.get(i).getItemRevision(); + setSheetText(sheet,t,9,itemRevision.getStringProperty("object_name")); + String type = itemRevision.getStringProperty("hs2_Processoperation"); + System.out.println(type); + String insertType = getInsertType(type); + System.out.println("end"+end+"insertType"+insertType+"old"+old); + insertPicToSheet(sheet,t,itemRevision); + setSheetText(sheet,t,1,stringProperty); + if(end==0) { + continue; + } + setSheetText(sheet,t,end,insertType); + if(i>0 && old !=0 && end!=0) { + + if(old<=end) { + + addLineRight(old,end,t-1,sheet); + }else { + addLeftRight(old,end,t-1,sheet); + } + + } + old = end; + t=t+1; + } + } + private void insertPicToSheet(Worksheet sheet, int t, TCComponentItemRevision itemRevision) { + // TODO Auto-generated method stub + //Keycharacteristics 关键 Processcharacteristics 过程 KeyandProcess all + try { + boolean key=false; + boolean process=false; + TCComponent[] hs2_ProcessControls = itemRevision.getReferenceListProperty("hs2_ProcessControl"); + for(TCComponent control:hs2_ProcessControls) { + + String hs2_Characteristic = control.getStringProperty("hs2_Characteristic"); + if(hs2_Characteristic.equals("Keycharacteristics")) { + key=true; + }else if (hs2_Characteristic.equals("Processcharacteristics")) { + process = true; + }else if (hs2_Characteristic.equals("KeyandProcess")) { + key=true; + process = true; + } + + } + + if(key && map.containsKey("Keycharacteristics")) { + File file2 = map.get("Keycharacteristics"); + MethodUtil.InsertTitlePicture(sheet,file2,new int[] {t}, + new int[] {13,14},true,4); + } + if(process && map.containsKey("Processcharacteristics")) { + File file2 = map.get("Processcharacteristics"); + MethodUtil.InsertTitlePicture(sheet,file2,new int[] {t}, + new int[] {17},true,4); + } + + + } catch (TCException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + + + + } + private void addLeftRight(int old, int end, int t, Worksheet sheet) { + // TODO Auto-generated method stub + LineCollection typedLines = sheet.getTypedLines(); + ILineShape addLine = typedLines.addLine(1,1,1,1,LineShapeType.LineInv); + addLine.setTop(getHeightByRow(t,sheet)+12); + addLine.setLeft(getWidthByCol(end,sheet)+5); + addLine.setWidth(getWidthByCol(old,sheet)-getWidthByCol(end,sheet)-15); + addLine.setHeight(sheet.getRowHeightPixels(10)-15); + + addLine.setBeginArrowHeadStyle(ShapeArrowStyleType.LineArrow); + addLine.setEndArrowHeadStyle(ShapeArrowStyleType.LineNoArrow); + } + private void addLineRight(int old, int end,int t, Worksheet sheet) { + // TODO Auto-generated method stub + + + + LineCollection typedLines = sheet.getTypedLines(); + ILineShape addLine = typedLines.addLine(); + + if(old==end) { + addLine.setTop(getHeightByRow(t,sheet)+8); + addLine.setLeft(getWidthByCol(old,sheet)); + addLine.setWidth(getWidthByCol(end,sheet)-getWidthByCol(old,sheet)-17); + addLine.setHeight(sheet.getRowHeightPixels(10)-14); + }else { + addLine.setTop(getHeightByRow(t,sheet)+6); + addLine.setLeft(getWidthByCol(old,sheet)+8); + addLine.setWidth(getWidthByCol(end,sheet)-getWidthByCol(old,sheet)-17); + addLine.setHeight(sheet.getRowHeightPixels(10)-14); + } + + + + addLine.setBeginArrowHeadStyle(ShapeArrowStyleType.LineNoArrow); + addLine.setEndArrowHeadStyle(ShapeArrowStyleType.LineArrow); + + } + + private static int getHeightByRow(int row,Worksheet sheet) { + int colWidth=0; + for(int i=1;i list; + private String[] objArray; + + public MyComboBox(List list) { + this.list = list; + objArray = new String[list.size()]; + for (int i = 0; i < list.size(); i++) { + objArray[i] = list.get(i).getValue(); + } + this.setModel(new javax.swing.DefaultComboBoxModel(objArray)); + } + + + public String getSelectedCode() { + int index = getSelectedIndex(); + return list.get(index).getCode(); + } + + public String getSelectValue() { + int index = getSelectedIndex(); + return list.get(index).getValue(); + } + + public void setSelectedByCode(String code) { + int index = 0; + for (int i = 0; i < list.size(); i++) { + if (list.get(i).getCode().equals(code)) { + index = i; + break; + } + } + this.setSelectedIndex(index); + } + + public void setSelectedByValue(String value) { + int index = 0; + for (int i = 0; i < list.size(); i++) { + if (list.get(i).getValue().equals(value)) { + index = i; + break; + } + } + this.setSelectedIndex(index); + } + + } + public JTableDemo() { + List list = new ArrayList(); + for (int i=0;i<5;i++) { + CodeValue codeValue = new CodeValue(); + codeValue.setValue(i + " | " + i); + codeValue.setCode(i+""); + list.add(codeValue); + } + MyComboBox box = new MyComboBox(list); + this.add(box); + this.pack(); +// this.validate(); + this.setVisible(true); + } + private void createRoot() { + // TODO Auto-generated method stub + rootPanel = new JPanel(); + + JComboBox comboBox = new JComboBox(); + comboBox.addItem("供应商A"); + + rootPanel.add(new JLabel("供应商列表:")); + rootPanel.add(comboBox); + rootPanel.add(new JButton("刷新显示")); + + } + private void addSouthPanel(JPanel mainJPanel) { + // TODO Auto-generated method stub + + JPanel panel = new JPanel(); + JButton parentBtn = new JButton("确定"); + parentBtn.setPreferredSize(new Dimension(80, 20)); + + JButton matBtn = new JButton("取消"); + matBtn.setPreferredSize(new Dimension(80, 20)); + + + panel.add(matBtn); + panel.add(parentBtn); + mainJPanel.add(BorderLayout.SOUTH,panel); + + } + private JPanel panel; + private JPanel panelN = new JPanel(new BorderLayout()); + private JPanel panelS = new JPanel(new BorderLayout()); +// private JTable eastTableN; +// private JTable eastTableS; + private void addEastPanel(JPanel mainJPanel) { + // TODO Auto-generated method stub + + panel = new JPanel(new BorderLayout()); + +// panel. + + JTable eastTableN = getjTable(null, null, columnNamesLeft,null); + JScrollPane jscrollpane = new JScrollPane(eastTableN); + jscrollpane.setPreferredSize(new Dimension(500,250)); + + panelN.add(jscrollpane); + + JTable eastTableS = getjTable(null, null, columnNamesLeft,null); + JScrollPane jscrollpane2 = new JScrollPane(eastTableS); + jscrollpane2.setPreferredSize(new Dimension(500,250)); + + panelS.add(jscrollpane2); + + panel.add(BorderLayout.NORTH , panelN); + panel.add(BorderLayout.SOUTH , panelS); + + mainJPanel.add(BorderLayout.EAST,panel); + + } + public static DefaultTableModel getTableModel(DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + DefaultTableModel tableModel = null; + if (dtm == null) { + tableModel = new DefaultTableModel(values, titleNames) { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + } + + return tableModel; + } + private String[] columnNamesLeft = new String[] { "序号", "物料编码", "物料描述","可选BOM" ,"所有者","状态"}; + + public static JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(getTableModel(dtm, titleNames, values)); + partsTable.setRowHeight(20); + RowSorter sorter = new TableRowSorter(partsTable.getModel()); + partsTable.setRowSorter(sorter); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } +// partsTable.getColumnModel().getColumn(0).setPreferredWidth(40); + } + return partsTable; + } + private JScrollPane jscrollpaneW; + private void addWestPanel(JPanel mainJPanel) { + // TODO Auto-generated method stub + JTable westTable = getjTable(null, null, columnNamesLeft,null); + jscrollpaneW = new JScrollPane(westTable); + jscrollpaneW.setPreferredSize(new Dimension(500,300)); + + + mainJPanel.add(BorderLayout.WEST,jscrollpaneW); + + } + private JPanel centerPanel; + private void addCenterPanel(JPanel mainJPanel) { + // TODO Auto-generated method stub + + centerPanel = new JPanel(); + + centerPanel.setLayout(null); + + centerPanel.setPreferredSize(new Dimension(200,300)); + + JButton button = new JButton(" 替换 >> "); + + JButton button2 = new JButton(" << 移除 "); + + JButton button3 = new JButton(" 升版并替换 >> "); + + button.setBounds(40, 100, 120, 30); + button2.setBounds(40, 250, 120, 30); + button3.setBounds(40, 400, 120, 30); + + centerPanel.add(button); + centerPanel.add(button2); + centerPanel.add(button3); + +// centerPanel.pack + + mainJPanel.add(BorderLayout.CENTER,centerPanel); + + } +// public static void main(String[] args) +// { +// JFrame frame = new JFrame("xxx"); +// frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); +// frame.setLocation(400, 200); +// +// frame.setLayout(new BorderLayout()); +// +// JPanel left = new JPanel(); +// left.setPreferredSize(new Dimension(300, 320)); +// JPanel right = new JPanel(); +// right.setPreferredSize(new Dimension(200, 320)); +// +// left.setLayout(new BorderLayout()); +// JPanel left_1 = new JPanel(); +// left_1.setPreferredSize(new Dimension(300, 300)); +// left_1.setBackground(Color.RED); +// +// JPanel left_2 = new JPanel(); +// left_2.setPreferredSize(new Dimension(300, 100)); +// left_2.setBackground(Color.GREEN); +// +// left.add(left_1, BorderLayout.CENTER); +// left.add(left_2, BorderLayout.SOUTH); +// +// right.setLayout(new BorderLayout()); +// JPanel right_1 = new JPanel(); +// right_1.setBackground(Color.WHITE); +// right_1.setPreferredSize(new Dimension(200, 100)); +// +// JPanel right_2 = new JPanel(); +// right_2.setBackground(Color.BLUE); +// right_2.setPreferredSize(new Dimension(200, 100)); +// +// JPanel right_3 = new JPanel(); +// right_3.setBackground(Color.BLACK); +// right_3.setPreferredSize(new Dimension(200, 120)); +// +// right.add(right_1, BorderLayout.NORTH); +// right.add(right_2, BorderLayout.CENTER); +// right.add(right_3, BorderLayout.SOUTH); +// +// frame.add(left, BorderLayout.CENTER); +// frame.add(right, BorderLayout.EAST); +// +// +// frame.setVisible(true); +// frame.pack(); +// } + public static String number2chinese(int src) { + final String num[] = {"〇", "一", "二", "三", "四", "五", "六", "七", "八", "九"}; + String dst = ""; +// int count = 0; + while(src > 0) { + dst = (num[src % 10]) + dst; + src = src / 10; +// count++; + } + return dst.replaceAll("零[千百十]", "零").replaceAll("零+万", "万") + .replaceAll("零+亿", "亿").replaceAll("亿万", "亿零") + .replaceAll("零+", "零").replaceAll("零$", ""); + } + public static void main(String[] args) + { + + JTableDemo jDemo = new JTableDemo(); +// MinioClient.builder() +// .endpoint("http://192.168.0.172:9000") +// .credentials("123", "secretKey") +// .build(); +// GY/GH-CN2020-15-10-001/00.00-长客嘉兴有轨电车车载储能系统长客嘉兴有轨电车车载储能系统I型工艺路线表 + +// try { +// String name= "长客嘉兴有轨电车车载储能系统长客嘉兴有轨电车车载储能系统I型工艺路线表"; +// +// int ids = 10; +// +// String format = String.format("%03d", ids+1); +// +// int nameLen = name.getBytes("UTF-8").length; +// +// System.out.println("nameLen === >" + nameLen + "format ===>" +format); +// +//// return nameLen>100; +// +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// Collections.sort(noList, new Comparator() +// { +// @Override +// public int compare(Object o1, Object o2) { +// +// String s1 = (String) o1; +// String s2 = (String) o2; +// return s1.compareTo(s2); +// } +// }); +// System.out.println(asList.toString()); + + +// System.out.println(getNumInstr("12B21B12")); + +// String number2chinese = number2chinese(2022); +// System.out.println(number2chinese); + +// JTableDemo demo = new JTableDemo(); +// String a2="2022-9-09 13:10"; +// String a1="2022-9-09 13:11"; +// +// System.out.println(a2.compareTo(a1)); + +// Object[] options = {"打包一层","打包所有层"}; +// int response = JOptionPane.showOptionDialog(null, "选择打包层级", "选择",JOptionPane.YES_OPTION, +// JOptionPane.QUESTION_MESSAGE, null, options, options[0]); +// System.out.println(response); + + } + public static int getNumInstr(String string) { + // TODO Auto-generated method stub + String str2 = ""; + boolean isFirst = false; + boolean flag = false; + for(int t=0;t=48 && string.charAt(t)<=57) && !flag ) { + isFirst = true; + str2 = str2+string.charAt(t); + }else if(isFirst && !flag) { + flag = true; +// break; + }else if(flag) { + return 19999; +// break; + } + } + if(str2.equals("")) { + + return 19999; + }else { + return Integer.valueOf(str2); + } + } + +} diff --git a/src/com/connor/hs/plm/GCLCT/TableCellCheckboxRenderer.java b/src/com/connor/hs/plm/GCLCT/TableCellCheckboxRenderer.java new file mode 100644 index 0000000..fbb4d66 --- /dev/null +++ b/src/com/connor/hs/plm/GCLCT/TableCellCheckboxRenderer.java @@ -0,0 +1,50 @@ +package com.connor.hs.plm.GCLCT; + +import java.awt.Component; +import java.util.List; + +import javax.swing.JCheckBox; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.TableCellRenderer; + + +public class TableCellCheckboxRenderer extends JCheckBox implements + TableCellRenderer { + private List processRows; + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + //private TestTreeTableModel tableModel; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + + } + + public TableCellCheckboxRenderer(final JTable table) { + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 + this.setBorderPainted(true); + + if(value != null) + { + this.setSelected(value.toString().equals("1")); + } + else + { + this.setSelected(false); + } + return this; + } +} \ No newline at end of file diff --git a/src/com/connor/hs/plm/createFolder/TestAIFAction.java b/src/com/connor/hs/plm/createFolder/TestAIFAction.java new file mode 100644 index 0000000..284e132 --- /dev/null +++ b/src/com/connor/hs/plm/createFolder/TestAIFAction.java @@ -0,0 +1,27 @@ +package com.connor.hs.plm.createFolder; + +import java.awt.Frame; + +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + + + +public class TestAIFAction extends AbstractAIFAction{ + + public TestAIFAction(Frame arg0, String arg1) { + super(arg0, arg1); + // TODO Auto-generated constructor stub + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + new TestAIFCommand().executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }; + } + +} diff --git a/src/com/connor/hs/plm/createFolder/TestAIFCommand.java b/src/com/connor/hs/plm/createFolder/TestAIFCommand.java new file mode 100644 index 0000000..cf37f42 --- /dev/null +++ b/src/com/connor/hs/plm/createFolder/TestAIFCommand.java @@ -0,0 +1,9 @@ +package com.connor.hs.plm.createFolder; + +import com.teamcenter.rac.aif.AbstractAIFCommand; + +public class TestAIFCommand extends AbstractAIFCommand{ + public TestAIFCommand() { + setRunnable(new TestAIFDialog()); + } +} diff --git a/src/com/connor/hs/plm/createFolder/TestAIFDialog.java b/src/com/connor/hs/plm/createFolder/TestAIFDialog.java new file mode 100644 index 0000000..510c896 --- /dev/null +++ b/src/com/connor/hs/plm/createFolder/TestAIFDialog.java @@ -0,0 +1,149 @@ +package com.connor.hs.plm.createFolder; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +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.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCException; + +public class TestAIFDialog extends AbstractAIFDialog{ + JComboBox box1=new JComboBox<>(); + TestAIFOperation operation=new TestAIFOperation(); + //获取用户选中的模板名称 + String tem; + //文件夹的名称 + List name; + //super(false)设置弹窗不被主界面遮挡住 + public TestAIFDialog() { + super(false); + } + public void close() { + this.dispose(); + } + @Override + public void run() { + regName(); + setBox(); + initView(); + this.showDialog(); + } + + + //绘制界面的方法 + public void initView() { + this.setTitle("模板复刻"); + this.setPreferredSize(new Dimension(400,300)); + this.setLayout(new BorderLayout()); + + //往弹窗中添加控件 + this.add(BorderLayout.CENTER,initCenter()); + } + + + private Component initCenter() { + // TODO Auto-generated method stub + JPanel jp=new JPanel(new GridBagLayout()); + //创建一个GridBagConstraints对象来约束GridBagLayout的布局 + Insets ins=new Insets(0,0,0,0); + GridBagConstraints s=new GridBagConstraints(0,0,1,1,0,0,GridBagConstraints.CENTER, + GridBagConstraints.NONE,ins, 0,0); + + s.weightx = 2.0D; + s.anchor = 13; + jp.add(new JLabel("请选择模板:"), s); + s.gridx++; + s.anchor = 17; + this.box1.setSelectedIndex(0); + jp.add(this.box1, s); + ins.top = 10; + s.gridx = 0; + s.gridy++; + s.weightx = 2.0D; + s.anchor = 13; + jp.add(new JLabel("输入文件夹名:"), s); + s.gridx++; + s.anchor = 17; + final JTextField filename = new JTextField(10); + jp.add(filename, s); + s.gridx = 0; + s.anchor = 10; + s.gridy++; + s.weightx = 1.0D; + ins.top = 60; + JButton b1=new JButton("确定"); + b1.addActionListener(new ActionListener() { + + + @Override + public void actionPerformed(ActionEvent e) { + //获取用户选中的选项 + + tem=(String) box1.getSelectedItem(); + if(tem!=null) { + try { + operation.getFolderByName(tem,filename.getText()); + close(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + }); + jp.add(b1,s); + + + s.gridx++; + JButton b2=new JButton("取消"); + b2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + //关闭弹窗 + close(); + } + }); + jp.add(b2,s); + + return jp; + } + + + //初始化文件夹名称 + public void regName(){ + try { + name=operation.getFolder(); + + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + } + //将文件夹名称放入下拉框中 + public void setBox() { + //将文件夹的名称放入下拉框中 + if(name!=null) { + for(String str:name){ + box1.addItem(str); + } + } + } +} diff --git a/src/com/connor/hs/plm/createFolder/TestAIFOperation.java b/src/com/connor/hs/plm/createFolder/TestAIFOperation.java new file mode 100644 index 0000000..fd0401c --- /dev/null +++ b/src/com/connor/hs/plm/createFolder/TestAIFOperation.java @@ -0,0 +1,190 @@ +package com.connor.hs.plm.createFolder; + +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.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.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.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; +import com.teamcenter.services.rac.core.DataManagementService; +import com.teamcenter.services.rac.core._2008_06.DataManagement; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse; + +public class TestAIFOperation extends AbstractAIFOperation{ + TCComponent target=(TCComponent)AIFUtility.getCurrentApplication().getTargetComponent(); + TCSession session=(TCSession)AIFUtility.getCurrentApplication().getSession(); + String object_name; + Map folders=new HashMap(); + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + getFolder(); + } + + //获取首选项的值(首选项存放的是文件夹的UID) + public String[] getPre() { + TCPreferenceService preferenceService = session.getPreferenceService(); + String[] pre = preferenceService.getStringValues("HMC_ProjectFolderTemplate"); + return pre; + } + + + + //通过首选项中的值获取文件夹的信息 + public List getFolder() throws TCException { + String[] pre = getPre();//获取到的UID + List name=new ArrayList();//存放文件夹名称 + int i=0; + TCComponent[] stringToComponent = session.stringToComponent(pre); + //获取文件夹的名称,将文件夹的名称放入字符串数组中 + for(TCComponent tc:stringToComponent) { + object_name=tc.getProperty("object_name"); + name.add(object_name); + folders.put(object_name,pre[i]); + i++; + } + return name; + } + + public TCComponentFolder createFolderBySOA(TCSession session,String tyeString,String name,String desc) throws ServiceException { + + DataManagementService service = DataManagementService.getService(session); + CreateIn[] input=new CreateIn[1]; + input[0]=new CreateIn(); + input[0].clientId="Test"; + DataManagement.CreateInput createInput=new DataManagement.CreateInput(); + + Map stringProps = new HashMap(); + + stringProps.put("object_name", name); + stringProps.put("object_desc", desc); + createInput.boName=tyeString; + createInput.stringProps=stringProps; + + input[0].data=createInput; + + CreateResponse createObjects = service.createObjects(input); + com.teamcenter.rac.kernel.ServiceData serviceData = createObjects.serviceData; + if(serviceData.sizeOfPartialErrors()>0) { + System.out.println(serviceData.getPartialError(0).getMessages()[0]); + } + + if(serviceData.sizeOfCreatedObjects()>0) { + TCComponent createdObject = serviceData.getCreatedObject(0); + return (TCComponentFolder)createdObject; + } + + + + return null; + } + + + //根据文件夹名称遍历文件夹下的内容 + public void getFolderByName(String name,String filename) throws Exception { + //通过名称获取uid + String uid = (String)folders.get(name); + TCComponent comp =session.stringToComponent(uid); + getAllFolderMsg(comp,filename); + } + //文件夹整合 + public void getAllFolderMsg(TCComponent comp,String filename) throws Exception { + AIFComponentContext[] children = comp.getChildren(); + String type = comp.getType(); + System.out.println("type ==>" +type); + + TCComponentFolder topFolder = createFolderBySOA(session,type,filename, "根据模板创建的文件"); + +// TCComponentFolderType topFolderType = (TCComponentFolderType)session.getTypeComponent(type); +// TCComponentFolder topFolder = topFolderType.create(filename, "根据模板创建的文件",type); + getFolderName1(comp,topFolder); + try { + target.add("contents", topFolder); + }catch(Exception e) { + System.out.println("文件名重复!"); + } + } + + //根据模板文件创建新文件 + public TCComponent createTCComp(TCComponent tc) { + try { + System.out.println("item type ==>"+tc.getType()); + String name = tc.getProperty("object_name"); + + TCComponentFolder topFolder = createFolderBySOA(session,tc.getType(),name, name+"的描述"); + +// TCComponentFolderType topFolderType = (TCComponentFolderType)session.getTypeComponent(tc.getType()); +// TCComponentFolder topFolder = topFolderType.create(name,name+"的描述",tc.getType()); + return topFolder; + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + //文件夹递归遍历方法 + public void getFolderName1(TCComponent tc,TCComponent tc1) { + AIFComponentContext[] children; + try { + //获取文件夹下的子文件 + children = tc.getChildren(); + if(children!=null&&children.length>0) { + //遍历子文件 + for(AIFComponentContext ch:children) { + String label = ch.getLabel(ch); + //获取子文件对应的组件 + TCComponent comp = (TCComponent)ch.getComponent(); + //判断组件是否为文件夹 + if(comp instanceof TCComponentFolder) { + TCComponent createTCComp = createTCComp(comp); + tc1.add("contents", createTCComp); + +// System.out.println(label+"*******"); + + //递归 + getFolderName1(comp,createTCComp); + }else if(comp instanceof TCComponentItem) {//如果是零组件的话另存处理 + //String id =comp.getProperty("item_id"); +// TCComponentItem item = getItemByName(id); + TCComponentItem item=(TCComponentItem)comp; + TCComponentItemType itemType = item.getTypeComponent(); + String newID = itemType.getNewID(); + String newRev = itemType.getNewRev(null); + TCComponentItemRevision re = item.getLatestItemRevision(); + + TCComponentItem newItem = re.saveAsItem(newID,newRev); + tc1.add("contents",newItem); + }else { + tc1.add("contents", comp); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + //通过名称获取零组件 + @SuppressWarnings("deprecation") + public TCComponentItem getItemByName(String n) throws TCException { + TCComponentItemType type = (TCComponentItemType)session.getTypeComponent("Item"); + TCComponentItem item = type.find(n); + return item; + } +} diff --git a/src/com/connor/hs/plm/createFolder/TestHandler.java b/src/com/connor/hs/plm/createFolder/TestHandler.java new file mode 100644 index 0000000..abe9121 --- /dev/null +++ b/src/com/connor/hs/plm/createFolder/TestHandler.java @@ -0,0 +1,16 @@ +package com.connor.hs.plm.createFolder; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +public class TestHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + new Thread(new TestAIFAction(null, null)).start(); + return null; + } + +} diff --git a/src/com/connor/hs/plm/createFolder/test.java b/src/com/connor/hs/plm/createFolder/test.java new file mode 100644 index 0000000..ce71bc9 --- /dev/null +++ b/src/com/connor/hs/plm/createFolder/test.java @@ -0,0 +1,54 @@ +package com.connor.hs.plm.createFolder; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +public class test { + public static void main(String[] args) { + createFolder(new File("D:\\aa")); + } + + public static void createFolder(File dirFile) {// 删除目录(文件夹)以及目录下的文件 + + boolean isLast=true; + + List fileList=new ArrayList(); + + List dicList=new ArrayList(); + +// = new File(dirPath); + // 如果dir对应的文件不存在,或者不是一个目录,则退出 + if (!dirFile.exists() || !dirFile.isDirectory()) { + return; + } + File[] files = dirFile.listFiles();// 获得传入路径下的所有文件 + for (int i = 0; i < files.length; i++) {// 循环遍历删除文件夹下的所有文件(包括子目录) + if (files[i].isFile()) { + + fileList.add(files[i]); + + + } else if(files[i].isDirectory()){ + dicList.add(files[i]); + isLast=false; + + } + } + + if(isLast) { + System.out.println("创建当前文件夹 类型HS2_Folder"); + + + + }else { + for(File f:dicList) { + String name = f.getName(); + System.out.println(name); + createFolder(f); + } + } + + + } +} diff --git a/src/com/connor/hs/plm/rename/UpdateNameCommand.java b/src/com/connor/hs/plm/rename/UpdateNameCommand.java new file mode 100644 index 0000000..2f1aa0d --- /dev/null +++ b/src/com/connor/hs/plm/rename/UpdateNameCommand.java @@ -0,0 +1,50 @@ +package com.connor.hs.plm.rename; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCAccessControlService; +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class UpdateNameCommand extends AbstractAIFCommand { + private AbstractAIFApplication app; + private TCSession session; + + public UpdateNameCommand(AbstractAIFApplication app, TCSession session) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + final InterfaceAIFComponent cmp = app.getTargetComponent(); + //判断选中的对象是否是文件夹或者版本 + if(!(cmp instanceof TCComponentFolder) && !(cmp instanceof TCComponentItemRevision)) + { + MessageBox.post("请选中文件夹或版本对象!", "错误", MessageBox.ERROR); + return; + } + TCAccessControlService aclService = session.getTCAccessControlService(); + if(!aclService.checkPrivilege((TCComponent)cmp, "WRITE")) + { + MessageBox.post("无编辑权限!", "错误", MessageBox.ERROR); + return; + } + // 获取选中对象 + new Thread() { + @Override + public void run() { + UpdateNameDialog dialog = new UpdateNameDialog(app, session, cmp); + } + }.start(); + super.executeModal(); + } +} diff --git a/src/com/connor/hs/plm/rename/UpdateNameDialog.java b/src/com/connor/hs/plm/rename/UpdateNameDialog.java new file mode 100644 index 0000000..cac11b2 --- /dev/null +++ b/src/com/connor/hs/plm/rename/UpdateNameDialog.java @@ -0,0 +1,108 @@ +package com.connor.hs.plm.rename; + +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.JTextField; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class UpdateNameDialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent cmp; + + private JLabel nameLabel; + private JTextField nameTextField; + + private JButton okButton; + + public UpdateNameDialog(AbstractAIFApplication app, TCSession session, InterfaceAIFComponent cmp) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.cmp = cmp; + + init(); + } + + private void init() { + // TODO Auto-generated method stub + this.setTitle("重命名"); + this.setPreferredSize(new Dimension(300, 80)); + + this.nameLabel = new JLabel("名称"); + this.nameLabel.setPreferredSize(new Dimension(50, 25)); + this.nameTextField = new JTextField(); + this.nameTextField.setPreferredSize(new Dimension(150, 25)); + this.okButton = new JButton("确定"); + + this.setLayout(new PropertyLayout()); + + this.add("1.1.left.top",nameLabel); + this.add("1.2.left.top",nameTextField); + this.add("1.3.left.top",okButton); + + createActionEvent(); + this.pack(); + this.setLocationRelativeTo(null); + this.show(); + } + + // 添加监听 + public void createActionEvent() { + this.okButton.addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.okButton)) + { + try { + if(cmp instanceof TCComponentItemRevision) + { + TCComponentItemRevision itemRevision = (TCComponentItemRevision) cmp; + TCComponentItem item = itemRevision.getItem(); + itemRevision.lock(); + itemRevision.setStringProperty("object_name", this.nameTextField.getText()); + itemRevision.save(); + itemRevision.unlock(); + itemRevision.refresh(); + item.lock(); + item.setStringProperty("object_name", this.nameTextField.getText()); + item.save(); + item.unlock(); + item.refresh(); + } + else + { + TCComponentFolder folder = (TCComponentFolder) cmp; + folder.lock(); + folder.setStringProperty("object_name", this.nameTextField.getText()); + folder.save(); + folder.unlock(); + folder.refresh(); + } + MessageBox.post("修改成功!", "成功", MessageBox.INFORMATION); + this.disposeDialog(); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + } + } + } +} diff --git a/src/com/connor/hs/plm/rename/UpdateNameHandler.java b/src/com/connor/hs/plm/rename/UpdateNameHandler.java new file mode 100644 index 0000000..5f51513 --- /dev/null +++ b/src/com/connor/hs/plm/rename/UpdateNameHandler.java @@ -0,0 +1,28 @@ +package com.connor.hs.plm.rename; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class UpdateNameHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + UpdateNameCommand command = new UpdateNameCommand(app,session); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/GXZDS/GXZYZDSCommand.java b/src/com/connor/hs2/plm/PFMEA/GXZDS/GXZYZDSCommand.java new file mode 100644 index 0000000..20c3e3d --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/GXZDS/GXZYZDSCommand.java @@ -0,0 +1,242 @@ +package com.connor.hs2.plm.PFMEA.GXZDS; + +import java.awt.image.RenderedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.imageio.ImageIO; +import javax.xml.crypto.Data; + +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + + + +public class GXZYZDSCommand extends AbstractAIFCommand { + + private InterfaceAIFComponent comp; + private TCSession session; + private TCComponentBOMLine BomLine = null; + private List> JobDatas=new ArrayList>(); + private String ProductCode=""; + private String ProductType=""; + private File file; + private boolean isMEOP=false; + private boolean isAtree; + private ListerrorList=new ArrayList(); + public GXZYZDSCommand(InterfaceAIFComponent comp, TCSession session,boolean isMEOP, File file, boolean isAtree) { + // TODO Auto-generated constructor stub + this.comp = comp; + this.session = session; + this.isMEOP=isMEOP; + this.file=file; + this.isAtree = isAtree; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + //获取选中的对象 + + System.out.println("comp"+comp.toString()); + + System.out.println("isMEOP" +isMEOP); + + + if(comp instanceof TCComponentBOMLine) { + BomLine = (TCComponentBOMLine) comp; + }else if(comp instanceof TCComponentItemRevision){ + TCComponentItemRevision revision = (TCComponentItemRevision)comp; + TCComponentBOMWindowType bopWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow bopWindow = bopWindowType.create(null); + TCComponentBOMLine topBopline = bopWindow.setWindowTopLine(revision.getItem(), revision , null, null); + BomLine = topBopline; + } + // List> JobData=new ArrayList>(); +// //判断对象类型 +// TCComponentItem item = BomLine.getItem(); + + + //获取产品版本对象 +// TCComponentBOMLine topBomLine=MethodUtil.getTopLine(BomLine); + + + //从选中目标逐层分解类型:工序则生成指导书,工艺就继续分解 + if(isMEOP) { + getMeopValues(BomLine); + }else { + getOP(BomLine); + } + + //非工序的错误信息统一打印 + if(errorList.size()>0) { + String errorMessage=""; + for(int i=0;i-1) { + getOP(bomLine); + }else if(bomLine.getItem().getType().equals("HS2_MEOP")) { + getMeopValues(bomLine); + } + } + } + + //获取工序数据 + public void getMeopValues(TCComponentBOMLine MEOP) throws TCException, Exception { + + int hsTime=0; + + List> WorkStepDatas=new ArrayList>();//工步数据 +// List> MaterialDatas=new ArrayList>();//物料数据 +// List> FrockDatas=new ArrayList>();//工装数据 + Tree02 jobTree=new Tree02(); +// jobTree.setProductCode(ProductCode); +// jobTree.setProductType(ProductType); + + TCComponentBOMLine MEOPBomLine=MEOP; + jobTree.setItemID(MEOPBomLine.getItemRevision().getStringProperty("hs2_OPNO"));//工序号 + jobTree.setHs2_ProcessNo(MEOPBomLine.getStringProperty("hs2_ProcessNo")); +// jobTree.setItemID(ExcelUtil07.getID(MEOPBomLine.getStringProperty("hs2_managementNo")));// 管理编号 + jobTree.setName(MEOPBomLine.getItemRevision().getItem().getStringProperty("object_name"));//工序名称 + jobTree.setHs2_Maturedays(MEOPBomLine.getItemRevision().getStringProperty("hs2_Maturedays")); + String tcProperty = MEOPBomLine.getItemRevision().getPropertyDisplayableValue("hs2_Protectiontools"); + + jobTree.setHs2_Protectiontools(tcProperty); + + String tools =MEOPBomLine.getItemRevision().getPropertyDisplayableValue("hs2_tools"); +// MEOPBomLine.getItemRevision().getTCProperty("hs2_tools"); + jobTree.setHs2_tools(tools); +// + jobTree.setHs2_applicablemodel(MEOPBomLine.getItemRevision().getStringProperty("hs2_Productname")); + jobTree.setHs2_sequenceandpoints(MEOPBomLine.getItemRevision().getStringProperty("hs2_ProductpartNo")); + + + jobTree.setHs2_change( MEOPBomLine.getItemRevision().getReferenceListProperty("hs2_Change")); + jobTree.setHs2_OPType( MEOPBomLine.getItemRevision().getStringProperty("hs2_Prohibitedmatters") ); // + jobTree.setBl_sequeseNo( MEOPBomLine.getItemRevision().getStringProperty("hs2_Exceptionhandling") );//标准时间 // + jobTree.setHs2_selfcheck(MEOPBomLine.getItemRevision().getReferenceListProperty("hs2_ProcessControl")); +// MessageBox.post(MEOPBomLine.getItem().getType(),"cuowu",MessageBox.ERROR); + + //获取工序下工步 + AIFComponentContext[] WorkSteps=MEOPBomLine.getChildren(); //.getReferenceListProperty("Mfg0sub_elements"); + + if(WorkSteps==null||WorkSteps.length==0) { + //选中的对象不是工序的话就要将报错信息统一打出 + if(((TCComponentBOMLine)comp).getItem().getType().equals("HS2_MEOP")) { + MessageBox.post("工序:"+MEOPBomLine.getStringProperty("bl_line_name")+"下没有内容。","错误",MessageBox.ERROR); + }else { + errorList.add(MEOPBomLine.getStringProperty("bl_line_name")); + } + + } + List partList =new ArrayList(); + List workStepliList =new ArrayList(); + jobTree.setPartList(partList); + jobTree.setWorkStepliList(workStepliList); + if(MEOPBomLine.getItemRevision().getProperty("release_status_list") != ""){ + MessageBox.post("工序:"+MEOPBomLine.getStringProperty("bl_line_name")+"已发布,无法生成工序作业指导书。","错误",MessageBox.ERROR); + }else{ +// int frockNo=0; + for(int j=0;j> WorkStepDatas=new ArrayList>();//工步 +// private List> MaterialDatas=new ArrayList>();//物料 +// private List> FrockDatas=new ArrayList>();//工装 + private Tree02 tree; + private TCComponentItem target; + private String outPathString =System.getenv("TEMP") + "\\";//导出路径 + private String nameString=""; + private CellStyle cellStyle; +// private double RowHeight=20; + private File file; + private boolean isAtree; + public GXZYZDSDialog(InterfaceAIFComponent comp, TCSession session,Tree02 tree,TCComponentItem target, File file, boolean isAtree) throws IOException { + // TODO Auto-generated constructor stub + super(false); + this.session = session; + this.comp = comp; + this.tree=tree; + this.target=target; + nameString=tree.getItemID()+tree.getName(); + this.file=file; + this.isAtree=isAtree; + init(); + } + private TCComponentItemRevision revision; + private void getTopProcee(TCComponentItemRevision item) throws TCException { + // TODO Auto-generated method stub + TCComponent[] whereUsed = item.whereUsed((short) 0); + System.out.println("whereUsed 被使用的数量"+whereUsed.length); + if(whereUsed.length==0) { + TCComponentItem item2 = item.getItem(); + System.out.println(item2.getType()); +// if() + if(item2.getType().equals("HS2_ProductMEP")||item2.getType().equals("HS2_AssemblyMEP")|| + item2.getType().equals("HS2_SpecialMEP")||item2.getType().equals("HS2_ProcessMEP") || item2 instanceof TCComponentMEProcess) {//工艺 + revision = item; + System.out.println("revision"+revision.getStringProperty("object_string")); + } + } + for(TCComponent used:whereUsed) { + if(used instanceof TCComponentItemRevision) { + TCComponentItemRevision revision = (TCComponentItemRevision) used; + getTopProcee(revision); + } + } + + } + int finalrow = 0; + List rowHeights=new ArrayList(); + private void init() throws IOException { + + + //创建Workbook对象 + + try { + getTopProcee(target.getLatestItemRevision()); + TCComponent[] refs = target.getReferenceListProperty("IMAN_reference"); + for(TCComponent refComponent : refs) { + String objName = refComponent.getStringProperty("object_name"); + if(objName.contains("工序作业指导书")) { + System.out.println("已有工序作业指导书 "); + return; + } + } + + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + + + + getRefs(); + Workbook wb = new Workbook(); +// File file1 = null; +// file1=MethodUtil.getFile(session, "工序作业指导书", "MSExcelX"); + FileInputStream input1 = new FileInputStream(this.file); + wb.loadFromHtml(input1); + //加载一个测试文档 + //wb.loadFromFile("C:\\美菱导出测试\\作业指导书.xlsx"); + //MessageBox.post(outPathString,"错误",MessageBox.ERROR); + //获取第一个工作表 + Worksheet sheet = wb.getWorksheets().get(0); +// sheet.setName(nameString+"工序作业指导书"); + +// changeType(sheet,tree.getHs2_OPType()); +// 设置工序固定属性 + setSheetText(sheet,3,3 , tree.getName()); //工序名称 + setSheetText(sheet,3,13 , tree.getHs2_ProcessNo()); //工序号 + setSheetText(sheet,3,17 , tree.getHs2_Maturedays()); //时间 + +// String[] hs2_Protectiontools = tree.getHs2_Protectiontools(); + String hs2_Protectiontool = tree.getHs2_Protectiontools(); +// for(int t = 0; t0) { +// hs2_Protectiontool = hs2_Protectiontool+","; +// } +// hs2_Protectiontool = hs2_Protectiontool + hs2_Protectiontools[t]; +// +// } + String hs2_tools = tree.getHs2_tools(); +// String hs2tool = ""; +// for(int t = 0; t0) { +// hs2tool = hs2tool+","; +// } +// hs2tool = hs2tool + Hs2_tools[t]; +// +// } + if(hs2_tools.startsWith(",")) { + hs2_tools = hs2_tools.substring(1,hs2_tools.length()); + } + if(hs2_Protectiontool.startsWith(",")) { + hs2_Protectiontool = hs2_Protectiontool.substring(1,hs2_Protectiontool.length()); + } + + setSheetText(sheet,5,3 , hs2_Protectiontool); //劳保工具 + setSheetText(sheet,6,3 , hs2_tools); //劳保工具 + + try { + if(revision!=null) { + TCComponent material = revision.getRelatedComponent("IMAN_METarget"); + if(material==null) { + int option = JOptionPane.showOptionDialog(null, "当前工艺未绑定总成物料,是否需要继续生成工序作业指导书?", "", 0, 1, null, null, + Integer.valueOf(0)); + if(option==0) { + + }else { + return; + } +// sout("顶层工艺IMAN_METarget下没有物料对象","提升",2); + }else { + System.out.println(material.getStringProperty("object_string")); + TCComponent pic = material.getRelatedComponent("TC_Is_Represented_By"); + if(pic!=null) { + setSheetText(sheet,7,3 ,pic.getStringProperty("object_name")); //劳保工具 + setSheetText(sheet,7,13,pic.getStringProperty("item_id")); + }else { + int option = JOptionPane.showOptionDialog(null, "当前工艺所绑定的总成物料未找到关联图纸,是否需要继续生成工序作业指导书?", "", 0, 1, null, null, + Integer.valueOf(0)); + if(option==0) { + setSheetText(sheet,7,3 ,material.getStringProperty("object_name")); //劳保工具 + setSheetText(sheet,7,13,material.getStringProperty("item_id")); + }else { + return; + } + } + + } + } + + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + + + setSheetText(sheet,8,3 , tree.getHs2_sequenceandpoints()); //劳保工具 + TCComponent[] hs2_change = tree.getHs2_change(); + int changeStart = 22 ; + + for(int i=0;i list2map = list2map(hs2_Controlitems, 176); + System.out.println("hs2_Controlitems"+list2map.size()); + if(list2map.size()>=2) { + double rowHeight = sheet.getRowHeight(32); + double rowHeight2 = rowHeight*list2map.size()/1.5; + sheet.setRowHeight(31+j+addRow, rowHeight2); + } +// sheet.setText(31+j+addRow,2,); //插入图片 + setSheetText(sheet,31+j+addRow,3,hs2_Controlitems); + setSheetText(sheet,31+j+addRow,8,hs2_Controlstandards); + setSheetText(sheet,31+j+addRow,16,hs2_Inspectionmethod); + setSheetText(sheet,31+j+addRow,20,hs2_Frequency); + setSheetText(sheet,31+j+addRow,22,hs2_Controlmethod); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +// s + int ss=38; + if(!isAtree) { + ss = 39; + } + setSheetText(sheet,ss+addRow, 1 ,tree.getHs2_OPType()); + setSheetText(sheet,ss+addRow, 13 ,tree.getBl_sequeseNo()); + List partList = tree.getPartList(); + + System.out.println("partList"+partList.size()); + + if(partList.size()>5) { + int t=partList.size()-5; + sheet.insertRow(39+addRow,t,InsertOptionsType.FormatAsBefore); + finalrow = addRow; + } + int partRow = 38; + if(isAtree) { + partRow = 37; + } + for(int t=0;t ) + + setSheetText(sheet,partRow+addRow+t, 24 ,String.valueOf(t+1)); + try { + setSheetText(sheet,partRow+addRow+t, 27 ,parTcComponent.getStringProperty("item_id")); + setSheetText(sheet,partRow+addRow+t, 35 ,parTcComponent.getStringProperty("object_name")); + setSheetText(sheet,partRow+addRow+t, 42 ,String.valueOf(float1)); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + +// getWorkStepsPage(); + + } +// + rowHeights.clear(); + for(int t=1;t<=42+finalrow;t++) { + rowHeights.add(sheet.getRowHeight(t)); + } + + getWorkStepsPage(sheet,tree.getWorkStepliList()); + + //获取行高 +// RowHeight=sheet.getRowHeight(5); + +// Worksheet sheet = wb.getWorksheets().get(0); +// List rowHeights=new ArrayList(); +// for(int i=1;i<19;i++) { +// rowHeights.add(sheet.getRowHeight(i)); +// } + + + + + try { + TCComponentItemRevision revision = this.target.getLatestItemRevision(); + String hs2_ProcessNo = revision.getStringProperty("hs2_ProcessNo"); + String objName = revision.getStringProperty("object_name"); + String string = hs2_ProcessNo+"-"+objName+"-工序作业指导书.xlsx"; + string = string.replaceAll("/","-"); + nameString = string; + System.out.println(string); + wb.saveToFile(outPathString+string); + Worksheet sheetRemove = wb.getWorksheets().get(wb.getActiveSheetIndex());//删除有水印的最后一页 + sheetRemove.remove(); + wb.saveToFile(outPathString+string); + + + TCComponentItemType tcComponentItemType = (TCComponentItemType) session.getTypeComponent("HS2_Instruction"); + String newID = tcComponentItemType.getNewID(); + String newRev = tcComponentItemType.getNewRev(null); + TCComponentItem item = tcComponentItemType.create(newID, newRev, "HS2_Instruction", hs2_ProcessNo+"-"+objName+"-工序作业指导书", "", null); + target.add("IMAN_reference", item); + TCComponentItemRevision latestItemRevision = item.getLatestItemRevision(); +// if(MethodUtil.getExcelToItem(session,latestItemRevision, +// "IMAN_specification", "MSExcelX",nameString+"工序作业指导书") != null) { +//// MethodUtil.changeDataSet(MethodUtil.getExcelToDataset(session,latestItemRevision, +//// "IMAN_specification", "MSExcelX",nameString+"工序作业指导书"), "excel", "MSExcelX", outPathString+nameString+"工序作业指导书.xlsx"); +// }else { + MethodUtil.setExcelToItem(session,latestItemRevision,outPathString+string,hs2_ProcessNo+"-"+objName+"-工序作业指导书","IMAN_specification", + "MSExcelX", true); + +// } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if(new File(outPathString+nameString).exists()) { + new File(outPathString+nameString).delete(); + } + } +// private void setSheetTextWrap(Worksheet sheet, int i, int j, String hs2_Controlitems) { +// // TODO Auto-generated method stub +// +// } + private Map map = new HashMap(); + + private void getRefs() { + // TODO Auto-generated method stub + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues("Characteristic_PIC"); + if (modelFiles == null) + { + System.out.println("未找到首选项"); + return; + } + for(String string :modelFiles ) { + + String[] split = string.split("-"); + + if(split.length ==2) { + + String string2 = split[1]; + try { + TCComponentDataset component = (TCComponentDataset) session.stringToComponent(string2); + TCComponentTcFile[] tcFile = component.getTcFiles(); + map.put(split[0], tcFile[0].getFmsFile()); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + } + + } + + //根据表格属性计算复制几页 + public void getWorkStepsPage(Worksheet sheet,List list) { +// int k=0; + double resolveWidth0 = 0; + for(int t=2;t<=9;t++) { + resolveWidth0 = resolveWidth0 + sheet.getColumnWidth(t); + } + System.out.println("resolveWidth"+resolveWidth0); + + double resolveWidth1 = 0; + for(int t=13;t<=18;t++) { + resolveWidth1 = resolveWidth1 + sheet.getColumnWidth(t); + } + System.out.println("resolveWidth"+resolveWidth1); + + double resolveWidth2 = 0; + for(int t=19;t<=23;t++) { + resolveWidth2 = resolveWidth2 + sheet.getColumnWidth(t); + } + System.out.println("resolveWidth"+resolveWidth2); + + double cnt = 230/resolveWidth2; + + int len1 = (int)(resolveWidth0*cnt ); + int len2 = (int)(resolveWidth1*cnt ); + String string = ""; + int usedRow = 0; + double resolveWidth = 0; + for(int t=2;t<=9;t++) { + resolveWidth = resolveWidth + sheet.getColumnWidth(t); + } + int end = 0; + //计算属性长度要放几行 + list2map(string, (int)resolveWidth); +// for(int i=0;i list2map = list2map(hs2_Resolve, len1); +// TCComponent[] hs2_Important = workStep.getHs2_Important(); +// String zybz = workStep.getObject_name(); +// List list2map1 = list2map(zybz, len2); +// int t=0; +// for(TCComponent hsComponent:hs2_Important) { +// t = t+2; +// try { +// String hs2_Stress = hsComponent.getStringProperty("hs2_Stress"); +// List stressMap = list2map(hs2_Stress,230); +// +// if(stressMap.size() > 1) { +// t = t + stressMap.size() -1 ; +// } +// +// +// String hs2_Stressreason = hsComponent.getStringProperty("hs2_Stressreason"); +// List reasonMap = list2map(hs2_Stressreason,230); +// if(reasonMap.size() > 1) { +// t = t + reasonMap.size() -1 ; +// } +// if( t+usedRow <14) { +// +// }else { +// usedRow = 0; +// t= reasonMap.size() -1; +// try { +// k=k+1; +// copyTable(sheet, (44+finalrow)*k, (44+finalrow)*k + 42, rowHeights); +// end = (44+finalrow)*k + 42; +// sheet.getCellRange((44+finalrow)*k+5,22).setFormula("=IF(V6=\"\",\"\",V6)"); +// sheet.getCellRange((44+finalrow)*k+7,22).setFormula("=IF(V8=\"\",\"\",V8)"); +// sheet.getCellRange((44+finalrow)*k+9,22).setFormula("=IF(V10=\"\",\"\",V10)"); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// if(t>=list2map.size() && t>=list2map1.size()) { +// usedRow = usedRow + t; +// }else if (list2map.size() >= list2map1.size()) { +// usedRow = usedRow + list2map.size(); +// }else if(list2map1.size()>list2map.size()){ +// usedRow = usedRow + list2map1.size(); +// }else if(list2map.size()==0&&list2map1.size()==0){ +// usedRow = usedRow +1; +// } +// System.out.println(usedRow+"-----------"); +// if(usedRow>=14) { +// usedRow = 0; +// try { +// k=k+1; +// //表格属性填了超过14行就换一页新的 +// copyTable(sheet, (44+finalrow)*k, (44+finalrow)*k + 42, rowHeights); +// sheet.getCellRange((44+finalrow)*k+5,22).setFormula("=IF(V6=\"\",\"\",V6)"); +// sheet.getCellRange((44+finalrow)*k+7,22).setFormula("=IF(V8=\"\",\"\",V8)"); +// sheet.getCellRange((44+finalrow)*k+9,22).setFormula("=IF(V10=\"\",\"\",V10)"); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// } +// String sizeString = "共"+String.valueOf(k+1)+"页"; //13 11 + Double allTime = 0.0; + int table = 0; + int inx=1; + usedRow = 0; + int k=0; + //算完要复制几页,然后开始对每一页填写值了 + for(int i=0;i=2?table-1:0; + System.out.println("======>"+xt + " ==== "+table); + WorkStep workStep = list.get(i); + boolean pageRow = getPageRow(workStep.getHs2_Important(),usedRow); + if(pageRow) { + usedRow = 0; + table = table +1; + + //复制表格 + k= k+1; + addTable(sheet,k); + end = (44+finalrow)*k + 42; + } + xt = table>=2?table-1:0; + String hs2_Resolve = workStep.getHs2_Resolve(); + List list2map = list2map(hs2_Resolve, len1); + if(list2map.size()>1) { +// if(list2map.size() > 1) { +// usedRow = usedRow + list2map.size() -1 ; +// } + System.out.println("usedRow --------"+usedRow); + if( usedRow + list2map.size() -1 >=14) { + table = table +1; + usedRow = 0; + } + for(int j=0;j list2map1 = list2map(zybz, len2); + + if(list2map1.size()>1) { + + for(int j=0;j stressMap = list2map(hs2_Stress,230); + List reasonMap = list2map(hs2_Stressreason,230); + + + xt = table>=2?table-1:0; + if(stressMap.size()>=2) { +// + for(int j=0;j"+String.valueOf(13+xt+usedRow+x+stressMap.size()-1 + table*(43+finalrow)) + "start ===>"+String.valueOf(13+xt+usedRow+x + table*(43+finalrow))); + sheet.getRange().get("S".concat(String.valueOf(13+xt+usedRow+x + table*(43+finalrow))).concat(":W".concat(String.valueOf(13+xt+usedRow+x+stressMap.size()-1 + table*(43+finalrow))))).merge(); +// sheet.getRange().get("A1").getStyle().setWrapText(true); + sheet.getRange().get("S".concat(String.valueOf(13+xt+usedRow+x + table*(43+finalrow))).concat(":W".concat(String.valueOf(13+xt+usedRow+x+stressMap.size()-1 + table*(43+finalrow))))).getStyle().setWrapText(true); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + } + setSheetText(sheet,13+xt+usedRow+x + table*(43+finalrow), 19 , hs2_Stress); + usedRow = usedRow + stressMap.size(); + +// x=x+1; +// if(reasonMap.size() > 1) { +// t = t + reasonMap.size() -1 ; +// } + + xt = table>=2?table-1:0; + System.out.println("xt ===== >"+xt); + if(reasonMap.size()>=2) { +// + for(int j=0;j"+String.valueOf(13+xt+usedRow+x+reasonMap.size()-1 + table*(43+finalrow)) + "start ===>"+String.valueOf(13+xt+usedRow+x + table*(43+finalrow))); + sheet.getRange().get("S".concat(String.valueOf(13+xt+usedRow+x + table*(43+finalrow))).concat(":W".concat(String.valueOf(13+xt+usedRow+x+reasonMap.size()-1 + table*(43+finalrow))))).merge(); +// sheet.getRange().get("A1").getStyle().setWrapText(true); + sheet.getRange().get("S".concat(String.valueOf(13+xt+usedRow+x + table*(43+finalrow))).concat(":W".concat(String.valueOf(13+xt+usedRow+x+reasonMap.size()-1 + table*(43+finalrow))))).getStyle().setWrapText(true); + } + setSheetText(sheet,13+xt+usedRow+x + table*(43+finalrow), 19 , hs2_Stressreason); + usedRow = usedRow + reasonMap.size(); + t = t + reasonMap.size()+stressMap.size(); +// x=x+1; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +// if(t>=list2map.size() && t>=list2map1.size()) { +// usedRow = usedRow + t ; +// }else + if (list2map.size() >= list2map1.size() && list2map.size() >t) { + usedRow = usedRow + list2map.size()-t; + } + else if(list2map1.size()>=list2map.size() && list2map1.size() >t){ + usedRow = usedRow + list2map1.size(); + } +// if(list2map.size()==0&&list2map1.size()==0){ +// usedRow = usedRow +1; +// } + System.out.println(usedRow+"usedRow+======"); + if(usedRow>=14) { + System.out.println(" ============== "); + table = table +1; + x=0; + usedRow = 0; + t= 0; + k= k+1; + addTable(sheet,k); + end = (44+finalrow)*k + 42; + } + } + + String sizeString = "共"+String.valueOf(k+1)+"页"; //13 11 + for(int j=0;j<=k;j++) { + System.out.println("set allTime"+allTime); + int t=0; + if(j>=2) { + t = j-1; + } + setSheetText( sheet , 2 + j*(43+finalrow)+t , 11 , "第"+String.valueOf(j+1)+"页"); + setSheetText( sheet , 2 + j*(43+finalrow)+t , 13 , sizeString); + setSheetText( sheet , 27 + j*(43+finalrow)+t , 11 , String.valueOf(allTime)); + } + System.out.println(end); + if(k>=1) { + System.out.println("设置打印区域"); //打印区域 + PageSetup pageSetup = sheet.getPageSetup(); + String areaString = "A1:AR"+String.valueOf(end); + pageSetup.setPrintArea(areaString); + } + + } + +// 13 -26 + + + private boolean getPageRow(TCComponent[] hs2_Important,int usedRow) { + // TODO Auto-generated method stub + + for(TCComponent hsComponent : hs2_Important) { + + try { + String hs2_Stressreason = hsComponent.getStringProperty("hs2_Stressreason"); + String hs2_Stress = hsComponent.getStringProperty("hs2_Stress"); + List stressMap = list2map(hs2_Stress,230); + List reasonMap = list2map(hs2_Stressreason,230); + usedRow = stressMap.size()+reasonMap.size()+usedRow; + if(usedRow>14) { + return true; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + return false; + + } + + + // /** +// * list转Map,获取指定长度的内容和图片 +// * @param list +// * @param width +// * @return +// */ + //76 + public static List list2map(String str, int width) { + List list2 = new ArrayList(); + Font font = new Font("宋体", Font.PLAIN, 11); + FontMetrics fm = sun.font.FontDesignMetrics.getMetrics(font); + + String tmp_str = ""; + int tmp_width = 0; + int tmp_pic_width = 0; + Pattern pattern = Pattern.compile("w{1}(\\+)?(\\-)?(\\d+\\.\\d+)|(\\d+)"); + + String value = str; + + + + int index = 0; + + for (int j = 0; j < value.length(); j++) { + tmp_str = tmp_str+value.charAt(j); + + //System.out.println("tmp_str:"+tmp_str); + + //System.out.println("tmp width="+((fm.stringWidth(tmp_str)+tmp_pic_width)-tmp_width)); + + if(((fm.stringWidth(tmp_str)+tmp_pic_width)-tmp_width)>=width) + { + //如果有数字、规格、公差等字符时,需要在同一行输出 + int len = tmp_str.length(); + Matcher matcherBall = pattern.matcher(tmp_str); + boolean flag = false; + while (matcherBall.find()) + { + + //System.out.println("matcherBall.find"); + + int beginIndex = matcherBall.start(); + int endIndex = matcherBall.end(); + + + + if(endIndex==len) + { + //判断下一个值 + if(j rowHeights) throws IOException { + String s1="A".concat(String.valueOf(startRow)); + String s2=":AR".concat(String.valueOf(endRow)); + sheet.copy(sheet.getCellRange("A1:AR42"),sheet.getCellRange( + s1.concat(s2)),true,true,false); +// + + + for(int i=0;i", " "); + newName = newName.replace("|", " "); + System.out.println("newName===="+newName); + comps[0].lock(); + comps[0].setStringProperty("original_file_name", newName); + comps[0].save(); + comps[0].unlock(); + item.add(relationType, tccomponentDataset); + if (isDelete) { + new File(tcResource).delete(); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /** + * 改变数据集的命名引用 + * + * @param tccomponentDataset + * @param quote + * @param type + * @param path + * @throws TCException + */ + public static void changeDataSet(TCComponentDataset tccomponentDataset, String quote, String type, String path) + throws TCException { + String myPath[] = { path }; + String myQuote[] = { quote };// 引用"excel" + String myType[] = { type };// 类型"MSExcelX" + String myPlain[] = { "Plain" }; + + // 删除数据集的引用 + deleDateSetRef(tccomponentDataset);//删除数据集里面的内容 + // 数据集的替换 + tccomponentDataset.setFiles(myPath, myType, myPlain, myQuote);//将新内容添加到数据集 + + } + /** + * 删除数据集的命名引用 + * + * @param dataset + * @throws TCException + */ + private static void deleDateSetRef(TCComponentDataset dataset) throws TCException { + + TCComponentTcFile[] tcFiles = dataset.getTcFiles(); + for (int i = 0; i < tcFiles.length; i++) { + // 得到数据集的引用类型 + String str_temp = getNamedRefType(dataset, tcFiles[i]); + // 删除引用 + dataset.removeNamedReference(str_temp); + } + + } + + /** + * 得到数据集的引用类型 + * + * @param datasetComponent + * @param tccomponent + * @return + * @throws TCException + */ + private static String getNamedRefType(TCComponentDataset datasetComponent, TCComponentTcFile tccomponent) + throws TCException { + String s; + s = ""; + TCProperty tcproperty; + TCProperty tcproperty1; + TCComponent atccomponent[]; + String as[]; + int i; + int j; + int k; + try { + tcproperty = datasetComponent.getTCProperty("ref_list"); + tcproperty1 = datasetComponent.getTCProperty("ref_names"); + if (tcproperty == null || tcproperty1 == null) + return s; + } catch (TCException tcexception) { + return s; + } + atccomponent = tcproperty.getReferenceValueArray(); + as = tcproperty1.getStringValueArray(); + if (atccomponent == null || as == null) + return s; + i = atccomponent.length; + if (i != as.length) + return s; + j = -1; + k = 0; + do { + if (k >= i) + break; + if (tccomponent == atccomponent[k]) { + j = k; + break; + } + k++; + } while (true); + if (j != -1) + s = as[j]; + return s; + } + /** + * 获取命名的引用 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + public static TCComponentDataset getExcelToDataset(TCSession session, TCComponentItemRevision item, + String relationType, String fileType,String name) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (TCComponent zyzdsChildren : zyzdsChildrens) { + if (fileType.equals(zyzdsChildren.getType())&&name.equals(zyzdsChildren.getStringProperty("object_name"))) { + return (TCComponentDataset) zyzdsChildren; +// TCComponentTcFile[] tcFile = dateSet.getTcFiles(); +// return tcFile[0].getFmsFile(); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + /** + * 获取需要的数据集 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + public static File getExcelDateSet(TCSession session, TCComponentItemRevision item, String relationType, + String fileType,String targetName) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (TCComponent zyzdsChildren : zyzdsChildrens) { + if (fileType.equals(zyzdsChildren.getType())&&zyzdsChildren.getStringProperty("object_name").equals(targetName)) { + TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren; + TCComponentTcFile[] tcFile = dateSet.getTcFiles(); + return tcFile[0].getFmsFile(); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + public static void InsertTitlePicture(Worksheet sheet,File picturePath,int[] Rows,int[] colunms, + boolean isProportion,int x) throws IOException { +// //获取系统分辨率 +// int screenWidth=((int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().width); +// int screenHeight = ((int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().height); + + double ColumnWidth=0.0;//列宽单元格像素 + double RowHeight=0.0;//行高像素 +// double ColumnWidthCM=0.0;//列宽单元格CM +// double RowHeightCM=0.0;//行高CM + for(int i=0;i pic1.getWidth()) { + int t=(int)(ColumnWidth - pic1.getWidth())/2; + System.out.println(t+left); + pic1.setLeft(t+left); + }else { + pic1.setLeft(left); + } + + + }else { + pic1.setWidth((int) ColumnWidth); + pic1.setHeight((int) RowHeight); + } + } + + public static void InsertTitlePicture(Worksheet sheet,String picturePath,int[] Rows,int[] colunms, + boolean isProportion) throws IOException { +// //获取系统分辨率 +// int screenWidth=((int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().width); +// int screenHeight = ((int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().height); + + double ColumnWidth=0.0;//列宽单元格像素 + double RowHeight=0.0;//行高像素 +// double ColumnWidthCM=0.0;//列宽单元格CM +// double RowHeightCM=0.0;//行高CM + for(int i=0;iRH) { +// w=W/CW; +// h=(H/CW)*w1/h1;//w1是放图片区域列宽占的厘米数除以像素(0.18);h1是行高的占的厘米数除以像素(0.23) +// }else { +// h=H/RH; +// w=(W/RH)*h1/w1; +// } +// double d = ColumnWidth; + double d2 = RowHeight; + pic1.setWidth((int) (d2 * W / H)); + pic1.setHeight((int) (d2)); + int t=(int)(ColumnWidth - pic1.getWidth())/2; + System.out.println(t+left); + pic1.setLeft(t+left); + +// System.out.println(left + "t+left"+t/100+left); +// +//// System.out.println(d); +// if(d>d2) { +// System.out.println(d+"d2"+d*HW); +// pic1.setWidth((int) (d)); +// pic1.setHeight((int) (d*HW)); +// }else { +// System.out.println(d2*WH+"d"+d2); +// pic1.setWidth((int) (d2*WH)); +// pic1.setHeight((int) (d2)); +// } + + + }else { + pic1.setWidth((int) ColumnWidth); + pic1.setHeight((int) RowHeight); + } + } + public static void InsertTitlePicture(Worksheet sheet,String picturePath,int[] Rows,int[] colunms) throws IOException { +// //获取系统分辨率 +// int screenWidth=((int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().width); +// int screenHeight = ((int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().height); + + double ColumnWidth=0.0;//列宽单元格像素 + double RowHeight=0.0;//行高像素 +// double ColumnWidthCM=0.0;//列宽单元格CM +// double RowHeightCM=0.0;//行高CM + for(int i=0;i= revId) { + itemRevision = items[i]; + revId = letterToNumber(revisionId); + } + } + return itemRevision; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + public static File getFiles(TCSession session,String fileName,String Filetype) { + // TODO Auto-generated method stub + try { + File file = null; + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues("PROCESS_MODEL_FILE"); + if (modelFiles == null) + { + System.out.println("未找到首选项"); + return null; + } + for (int i = 0; i < modelFiles.length; i++) { + if(modelFiles[i].split("-")[0].equals(fileName)) + { + String item_id = modelFiles[i].split("-")[1]; + String desc = modelFiles[i].split("-")[2]; + + TCComponentItem find = ((TCComponentItemType)(session.getTypeComponent("Item"))).find(item_id); + TCComponentItemRevision fileItemLastRev = find.getLatestItemRevision(); + TCComponent[] comps = fileItemLastRev.getReferenceListProperty("IMAN_specification"); + for (TCComponent compt : comps) { + // 获取对象类型 + String type = compt.getType(); + System.out.println(" TYPE = " + type); + // 判断类型 + if (type.equals(Filetype)) { + TCComponentDataset dat = (TCComponentDataset)compt; + TCComponentTcFile[] tcFile = dat.getTcFiles(); + if(tcFile != null && tcFile.length == 0) + { + System.out.println("未找到配置文件"); + } + else + { + file = tcFile[0].getFmsFile(); + } + } + } + } + } + + return file; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } + + public static Map getFiles(TCSession session,String fileName,String Filetype,JComboBox comboBox) { + // TODO Auto-generated method stub + try { + + Map map=new HashMap(); + + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues("PROCESS_MODEL_FILE"); + if (modelFiles == null) + { + System.out.println("未找到首选项"); + return null; + } + for (int i = 0; i < modelFiles.length; i++) { + if(modelFiles[i].split("-")[0].equals(fileName)) + { + String item_id = modelFiles[i].split("-")[1]; + String desc = modelFiles[i].split("-")[2]; + if(comboBox!=null) { + comboBox.addItem(desc); + } + + TCComponentItem find = ((TCComponentItemType)(session.getTypeComponent("Item"))).find(item_id); + TCComponentItemRevision fileItemLastRev = find.getLatestItemRevision(); + TCComponent[] comps = fileItemLastRev.getReferenceListProperty("IMAN_specification"); + for (TCComponent compt : comps) { + // 获取对象类型 + String type = compt.getType(); + System.out.println(" TYPE = " + type); + // 判断类型 + if (type.equals(Filetype)) { + TCComponentDataset dat = (TCComponentDataset)compt; + TCComponentTcFile[] tcFile = dat.getTcFiles(); + if(tcFile != null && tcFile.length == 0) + { + System.out.println("未找到配置文件"); + } + else + { + map.put(desc, tcFile[0].getFmsFile()); + } + } + } + } + } + + return map; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } + + public static File getFile(TCSession session,String fileName,String Filetype) { + // TODO Auto-generated method stub + try { + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues("PROCESS_MODEL_FILE"); + if (modelFiles == null) + { + System.out.println("未找到首选项"); + return null; + } + String puid = ""; + String item_id=""; + for (int i = 0; i < modelFiles.length; i++) { + if(modelFiles[i].split("-")[0].equals(fileName)) + { + item_id = modelFiles[i].split("-")[1]; + } + } + //通过item的id来找item对象 + puid =((TCComponentItemType)(session.getTypeComponent("Item"))).find(item_id).getUid(); + TCComponentItem fileItem = (TCComponentItem)session + .stringToComponent(puid); + TCComponentDataset dat = null; + TCComponentItemRevision fileItemLastRev = fileItem.getLatestItemRevision(); + TCComponent[] comps = fileItemLastRev.getReferenceListProperty("IMAN_specification"); + System.out.println("count =" + comps == null ? "null" + : comps.length); + // 遍历TC_Attaches关系下的所有对象 + for (TCComponent compt : comps) { + // 获取对象类型 + String type = compt.getType(); + System.out.println(" TYPE = " + type); + // 判断类型 + if (type.equals(type)) { + dat = (TCComponentDataset)compt; + } + } + TCComponentTcFile[] tcFile = dat.getTcFiles(); + if(tcFile != null && tcFile.length == 0) + { + System.out.println("未找到配置文件"); + } + else + { + return tcFile[0].getFmsFile(); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } + public static TCComponentBOMLine getTopLine(TCComponentBOMLine BomLine) { + TCComponentBOMLine bomLine = null; + TCComponentBOMLine bomLineisnull = null; + bomLine=BomLine; + bomLineisnull=bomLine.getCachedParent(); + while (bomLineisnull!=null) { + bomLine=bomLine.getCachedParent(); + bomLineisnull=bomLine.getCachedParent(); + } + return bomLine; + } + + public static void CopyPic(File path1,String path2) { + // 创建文件字节输入流对象 + FileInputStream fis = null; + // 创建文件字节输出流对象 + FileOutputStream fos = null; + try { + // 连接文件字节输入流 + fis = new FileInputStream(path1); + // 连接文件字节输出流 + fos = new FileOutputStream(path2); + //准备一个byte[]数组,存储字节码,大小为1024字节,即1KB + byte[] bytes = new byte[1024]; + int readCount = 0; + // 开始读和写 + while ((readCount = fis.read(bytes)) != -1) { + // 将数组中读到的字节码写入 + fos.write(bytes, 0, readCount); + } + // 最后刷新管道,强制输出完数据 + fos.flush(); + + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (fis != null) { + try { + fis.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (fos != null) { + try { + fos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/GXZDS/SelectMoudleFile.java b/src/com/connor/hs2/plm/PFMEA/GXZDS/SelectMoudleFile.java new file mode 100644 index 0000000..153e23b --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/GXZDS/SelectMoudleFile.java @@ -0,0 +1,104 @@ +package com.connor.hs2.plm.PFMEA.GXZDS; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCSession; + +public class SelectMoudleFile extends AbstractAIFDialog{ + private TCSession session; + private InterfaceAIFComponent comp; + private boolean isMEOP; + public SelectMoudleFile(InterfaceAIFComponent comp,TCSession session,boolean isMEOP) { + this.session=session; + this.isMEOP=isMEOP; + this.comp=comp; +// init(); + } + +// private void init() { +// // TODO Auto-generated method stub +// +// } +// + @Override + public void run() { + this.setTitle("选择导出模板"); +// File file1 = null; + JComboBox comboBox=new JComboBox(); + Map fileMap = MethodUtil.getFiles(session, "工序作业指导书", "MSExcel",comboBox); + + this.setLayout(new BorderLayout()); + this.setPreferredSize(new Dimension(400,150)); + + JPanel jPanel=new JPanel(); + jPanel.setPreferredSize(new Dimension(300,100)); + + jPanel.add(new JLabel("选择模板")); + jPanel.add(comboBox); + + JPanel nouthPanel=new JPanel(); + JButton okBtn=new JButton("确认"); + JButton disBtn=new JButton("取消"); + + disBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + dispose(); + } + }); + + okBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + dispose(); + String selectedItem = (String) comboBox.getSelectedItem(); + boolean isAtree = false; + if(selectedItem.contains("A3")) { + isAtree = true; + } + + if(fileMap.containsKey(selectedItem)) { + File file = fileMap.get(selectedItem); + GXZYZDSCommand command = new GXZYZDSCommand(comp,session,isMEOP,file,isAtree);//工序 + try { + command.executeModal(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + + + } + }); + + nouthPanel.add(okBtn);nouthPanel.add(disBtn); + this.add(jPanel,BorderLayout.CENTER); + this.add(nouthPanel,BorderLayout.SOUTH); + + this.setAlwaysOnTop(true); + + this.pack(); +// dialog.validate(); + this.centerToScreen(); + this.setVisible(true); + } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/GXZDS/Tree02.java b/src/com/connor/hs2/plm/PFMEA/GXZDS/Tree02.java new file mode 100644 index 0000000..7fc0373 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/GXZDS/Tree02.java @@ -0,0 +1,149 @@ +package com.connor.hs2.plm.PFMEA.GXZDS; + +import java.util.ArrayList; +import java.util.List; + +import com.teamcenter.rac.kernel.TCComponent; + +public class Tree02 { +// private String ProductCode;//产品代号 +// private String ProductType;//产品型号 + private String ItemID;//工序编号 + private String Name;//工序名称 +// private String Time;//标准时间 + private String hs2_OPType;//类型 + private List workStepliList; + public List getWorkStepliList() { + return workStepliList; + } + public void setWorkStepliList(List workStepliList) { + this.workStepliList = workStepliList; + } + public String getHs2_OPType() { + return hs2_OPType; + } + public void setHs2_OPType(String hs2_OPType) { + this.hs2_OPType = hs2_OPType; + } + private String bl_sequeseNo; + private String hs2_applicablemodel;//适应型号 + private String hs2_sequenceandpoints;//作业顺序及要点事项 + private List partList ; + public List getPartList() { + return partList; + } + public void setPartList(List partList) { + this.partList = partList; + } + private String hs2_Maturedays; // 习熟天数 + private String hs2_Protectiontools;//劳保 + public String getHs2_Maturedays() { + return hs2_Maturedays; + } + public void setHs2_Maturedays(String hs2_Maturedays) { + this.hs2_Maturedays = hs2_Maturedays; + } + public String getHs2_Protectiontools() { + return hs2_Protectiontools; + } + public void setHs2_Protectiontools(String hs2_Protectiontools) { + this.hs2_Protectiontools = hs2_Protectiontools; + } + public String getHs2_tools() { + return hs2_tools; + } + public void setHs2_tools(String hs2_tools) { + this.hs2_tools = hs2_tools; + } + private String hs2_tools;//工具 +// private String + +// private String Time;//标准时间 +// private String Time;//标准时间 + private String hs2_ProcessNo; + + public String getHs2_ProcessNo() { + return hs2_ProcessNo; + } + public void setHs2_ProcessNo(String hs2_ProcessNo) { + this.hs2_ProcessNo = hs2_ProcessNo; + } + private TCComponent[] hs2_selfcheck;//作业员自检项目 + private TCComponent[] hs2_change; //更改明细栏 + public TCComponent[] getHs2_selfcheck() { + return hs2_selfcheck; + } + public void setHs2_selfcheck(TCComponent[] hs2_selfcheck) { + this.hs2_selfcheck = hs2_selfcheck; + } + public TCComponent[] getHs2_change() { + return hs2_change; + } + public void setHs2_change(TCComponent[] hs2_change) { + this.hs2_change = hs2_change; + } + private String hs2Time; + public String getHs2Time() { + return hs2Time; + } + public void setHs2Time(String hs2Time) { + this.hs2Time = hs2Time; + } + private List> WorkStep=new ArrayList>();//工步 + +// public void setProductCode(String ProductCode) { +// this.ProductCode=ProductCode; +// } +// public String getProductCode() { +// return this.ProductCode; +// } +// public void setProductType(String ProductType) { +// this.ProductType=ProductType; +// } +// public String getProductType() { +// return this.ProductType; +// } + public void setItemID(String ItemID) { + this.ItemID=ItemID; + } + public String getBl_sequeseNo() { + return bl_sequeseNo; + } + public void setBl_sequeseNo(String bl_sequeseNo) { + this.bl_sequeseNo = bl_sequeseNo; + } + public String getHs2_applicablemodel() { + return hs2_applicablemodel; + } + public void setHs2_applicablemodel(String hs2_applicablemodel) { + this.hs2_applicablemodel = hs2_applicablemodel; + } + public String getHs2_sequenceandpoints() { + return hs2_sequenceandpoints; + } + public void setHs2_sequenceandpoints(String hs2_sequenceandpoints) { + this.hs2_sequenceandpoints = hs2_sequenceandpoints; + } + public String getItemID() { + return this.ItemID; + } + public void setName(String Name) { + this.Name=Name; + } + public String getName() { + return this.Name; + } +// public void setTime(String Time) { +// this.Time=Time; +// } +// public String getTime() { +// return this.Time; +// } + + public void setWorkStep(List> WorkStep) { + this.WorkStep=WorkStep; + } + public List> getWorkStep() { + return this.WorkStep; + } +} diff --git a/src/com/connor/hs2/plm/PFMEA/GXZDS/WorkStep.java b/src/com/connor/hs2/plm/PFMEA/GXZDS/WorkStep.java new file mode 100644 index 0000000..49936e4 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/GXZDS/WorkStep.java @@ -0,0 +1,37 @@ +package com.connor.hs2.plm.PFMEA.GXZDS; + +import com.teamcenter.rac.kernel.TCComponent; + +public class WorkStep { + + private String hs2_Resolve; + private String hs2_time; + private String object_name; + private TCComponent[] hs2_Important; + public String getHs2_Resolve() { + return hs2_Resolve; + } + public void setHs2_Resolve(String hs2_Resolve) { + this.hs2_Resolve = hs2_Resolve; + } + public String getHs2_time() { + return hs2_time; + } + public void setHs2_time(String hs2_time) { + this.hs2_time = hs2_time; + } + public String getObject_name() { + return object_name; + } + public void setObject_name(String object_name) { + this.object_name = object_name; + } + public TCComponent[] getHs2_Important() { + return hs2_Important; + } + public void setHs2_Important(TCComponent[] hs2_Important) { + this.hs2_Important = hs2_Important; + } + + +} diff --git a/src/com/connor/hs2/plm/PFMEA/GXZDS/test.java b/src/com/connor/hs2/plm/PFMEA/GXZDS/test.java new file mode 100644 index 0000000..4a81b5d --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/GXZDS/test.java @@ -0,0 +1,346 @@ +package com.connor.hs2.plm.PFMEA.GXZDS; + +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.imageio.ImageIO; + +import com.spire.xls.CellRange; +import com.spire.xls.ExcelPicture; +import com.spire.xls.InsertOptionsType; +import com.spire.xls.LineShapeType; +import com.spire.xls.PageSetup; +import com.spire.xls.ShapeArrowStyleType; +import com.spire.xls.Workbook; +import com.spire.xls.Worksheet; +import com.spire.xls.core.ILineShape; +import com.spire.xls.core.IPrstGeomShape; +import com.spire.xls.core.IRectangleShape; +import com.spire.xls.core.IRectangleShapes; +import com.spire.xls.core.IXLSRange; +import com.spire.xls.core.spreadsheet.collections.LineCollection; + +public class test { + + + + public static boolean canParseInt(String str){ + if(str == null){ //验证是否为空 + return false; + + } + + return str.matches("\\d+"); //使用正则表达式判断该字符串是否为数字,第一个\是转义符,\d+表示匹配1个或 //多个连续数字,"+"和"*"类似,"*"表示0个或多个 + + } + + public static void InsertTitlePicture(Worksheet sheet,String picturePath,int[] Rows,int[] colunms, + boolean isProportion,double RowHeightCM,double ColumnWidthCM) throws IOException { +// //获取系统分辨率 +// int screenWidth=((int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().width); +// int screenHeight = ((int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().height); + + double ColumnWidth=0.0;//列宽单元格像素 + double RowHeight=0.0;//行高像素 +// double ColumnWidthCM=0.0;//列宽单元格CM +// double RowHeightCM=0.0;//行高CM + for(int i=0;iRH) { + w=W/CW; + h=(H/CW)*w1/h1;//w1是放图片区域列宽占的厘米数除以像素(0.18);h1是行高的占的厘米数除以像素(0.23) + }else { + h=H/RH; + w=(W/RH)*h1/w1; + } + pic1.setWidth((int) (w)); + pic1.setHeight((int) (h)); + }else { + pic1.setWidth((int) ColumnWidth); + pic1.setHeight((int) RowHeight); + } + } + + public static void copyTable(Worksheet sheet, int startRow,int endRow, List rowHeights) throws IOException { + String s1="A".concat(String.valueOf(startRow)); + String s2=":AR".concat(String.valueOf(endRow)); + sheet.copy(sheet.getCellRange("A1:AR45"),sheet.getCellRange( + s1.concat(s2)),true,true,false); +// + + + for(int i=0;i list2map(String str, int width) { + List list2 = new ArrayList(); + Font font = new Font("宋体", Font.PLAIN, 11); + FontMetrics fm = sun.font.FontDesignMetrics.getMetrics(font); + + String tmp_str = ""; + int tmp_width = 0; + int tmp_pic_width = 0; + Pattern pattern = Pattern.compile("w{1}(\\+)?(\\-)?(\\d+\\.\\d+)|(\\d+)"); + + String value = str; + + + + int index = 0; + + for (int j = 0; j < value.length(); j++) { + tmp_str = tmp_str+value.charAt(j); + + //System.out.println("tmp_str:"+tmp_str); + + //System.out.println("tmp width="+((fm.stringWidth(tmp_str)+tmp_pic_width)-tmp_width)); + + if(((fm.stringWidth(tmp_str)+tmp_pic_width)-tmp_width)>=width) + { + //如果有数字、规格、公差等字符时,需要在同一行输出 + int len = tmp_str.length(); + Matcher matcherBall = pattern.matcher(tmp_str); + boolean flag = false; + while (matcherBall.find()) + { + + //System.out.println("matcherBall.find"); + + int beginIndex = matcherBall.start(); + int endIndex = matcherBall.end(); + + + + if(endIndex==len) + { + //判断下一个值 + if(j rowHeights=new ArrayList(); + for(int t=1;t<=42;t++) { + rowHeights.add(sheet.getRowHeight(t)); + } +// String string="哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇"; +// double resolveWidth = 0; +// for(int t=3;t<=7;t++) { +// resolveWidth = resolveWidth + sheet.getColumnWidth(t); +// } +// System.out.println("resolveWidth"+resolveWidth); +// +// double resolveWidth1 = 0; +// for(int t=13;t<=18;t++) { +// resolveWidth1 = resolveWidth1 + sheet.getColumnWidth(t); +// } +// System.out.println("resolveWidth"+resolveWidth1); +// +// double resolveWidth2 = 0; +// for(int t=19;t<=23;t++) { +// resolveWidth2 = resolveWidth2 + sheet.getColumnWidth(t); +// } +// System.out.println("resolveWidth"+resolveWidth2); + String string = ""; + List list2map = list2map(string, 176); +// sout + System.out.println(list2map.size()); +// int len1 = (int)(resolveWidth*cnt ); +// System.out.println(len1); +// System.out.println(list2map); +// int height = 0; +// for(int i=1;i<=12;i++) { +// System.out.println(); +// height = sheet.getRowHeightPixels(i)+height; +// } +// MethodUtil.InsertTitlePicture(sheet,new File("D:\\excel模板\\1.jpeg") ,new int[] {31}, +// new int[] {2},true,3); +//// sheet.getCellRange(6,22).setFormula("=IF(V8=\"\",\"\",V8)"); +////// int columnWidthPixels=0; +////// for(int i=1;i<=2;i++) { +////// columnWidthPixels = sheet.getColumnWidthPixels(i)+columnWidthPixels; +////// } +// +// int end = 0; +// for(int i=1;i<=4;i++) { +// System.out.println(43*i + "end"+(44*i+41)); +// end = 45*i+42; +// copyTable(sheet, 45*i+1, 45*i+42, rowHeights); +// } +// for(int j=0;j<=4;j++) { +// System.out.println("set allTime"); +// int t=0; +// if(j>=2) { +// t = j-1; +// } +// setSheetText( sheet , 2 + j*(45) , 11 , "第"+String.valueOf(j+1)+"页"); +// setSheetText( sheet , 2 + j*(45) , 13 , "共4页"); +// setSheetText( sheet , 27 + j*(45) , 11 , String.valueOf("100")); +// } +// PageSetup pageSetup = sheet.getPageSetup(); +// String areaString = "A1:AR"+String.valueOf(end); +// pageSetup.setPrintArea(areaString); +// wb.print + +// +// +// columnWidthPixels = sheet.getColumnWidthPixels(3)/2+columnWidthPixels; +// height = height +sheet.getRowHeightPixels(10)/2; +// for(int t=11;t<=19;t++) { +// sheet.setRowHeight(t, sheet.getRowHeight(10)); +// } +// setLineInSheet(sheet,height,columnWidthPixels); + wb.saveToFile("D:\\excel模板\\test111.xlsx"); + Worksheet sheetRemove = wb.getWorksheets().get(wb.getActiveSheetIndex());//删除有水印的最后一页 + sheetRemove.remove(); + wb.saveToFile("D:\\excel模板\\test111.xlsx"); + System.out.println("ok"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + + } + public static void setSheetText(Worksheet sheet,int row,int cell,String value) { + + sheet.setText(row, cell, (value==null || value.equals(""))?" ":value); + } + private static int getWidthByCol(int col,Worksheet sheet) { + int colWidth=0; + for(int i=1;i combineMap = new HashMap();// 存放合并单元格 + //private Map combineMap2 = new HashMap();// 存放合并单元格 + private TCProperty[] properties; + private TCProperty[] itemProperties; + // private List> processRowList = new + // ArrayList>(); + private List processRows = new ArrayList(); + private TCComponentUser user;// 当前登录用户 + private List> dataList = new ArrayList>();// 表格PFMEA中的数据 + private List> dataList2 = new ArrayList>();// 表格PFMEA经验数据库中的数据 + private List> pfmeaDataList = new ArrayList>();// PFMEA库中的数据 + private List plmeidList = new ArrayList();// 工序对象的ItemId + private String UID; + private boolean isRelease=false; + public DesignPFMEACommand() { + super(); + } + + public DesignPFMEACommand(AbstractAIFApplication app, TCSession session,String UID) { + this.session = session; + this.app = app; + this.comp = app.getTargetComponent(); + this.user = session.getUser(); + this.UID=UID; + } + /** + * 获取数据库中的数据 + */ + private void getData() { + // TODO Auto-generated method stub + ResultSet rs = null; + ResultSet rs2 = null; + ResultSet rs21 = null; + InputStream input = null; + try { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + if (meprocess != null) { + String sql = String.format(pro.getProperty("SETPFMEASELECT"), + meprocess.getUid(),comp.getUid()); + rs = SqlUtilT.read(sql); + String sql2 = String.format(pro.getProperty("PFMEALIBRARYSELECT2"), + comp.getUid()); + rs2 = SqlUtilT.read(sql2); + //表格1数据 + int num=rs.getFetchSize()/80; + int num1=1; + int num2=0; + while (rs.next()) { + //++++ + if(num2==num*num1) { + progressBar.setValue(num1+10); + num1++; + } + num2++; + //+++ + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("GYBH"));//GYBH放“问题”数据 + rowList.add(rs.getString("GCMC"));//GCMC放历史变更授权数据 + rowList.add(rs.getString("STATION")); + rowList.add(rs.getString("REQUIREMENT")); + rowList.add(rs.getString("QZSXMS")); + rowList.add(rs.getString("QZSXHG")); + rowList.add(rs.getString("YZD")); + rowList.add(rs.getString("JB")); + rowList.add(rs.getString("QZSXQY")); + rowList.add(rs.getString("XXGCKZYF")); + rowList.add(rs.getString("PDS")); + rowList.add(rs.getString("XXGCKZTC")); + rowList.add(rs.getString("TCD")); + rowList.add(rs.getString("RPN")); + rowList.add(rs.getString("JYCS")); + rowList.add(rs.getString("ZZR")); + rowList.add(rs.getString("JHWCRQ")); + rowList.add(rs.getString("CQDCS")); + rowList.add(rs.getString("NEW_SEV")); + rowList.add(rs.getString("NEW_OCC")); + rowList.add(rs.getString("NEW_DET")); + rowList.add(rs.getString("NEW_RPN")); + rowList.add(rs.getString("IDEAL_STATE")); + rowList.add(rs.getString("SPECIAL")); + rowList.add(rs.getInt("HH"));//25 + rowList.add(rs.getString("HBDYG"));//26 + rowList.add(rs.getInt("HHC"));//27 + rowList.add(rs.getString("OCCURRRENCE")); + rowList.add(rs.getString("DETECTION")); + rowList.add(rs.getString("PRIORITY")); + rowList.add(rs.getString("P1")); + rowList.add(rs.getString("P2")); + rowList.add(rs.getString("P3")); + rowList.add(rs.getString("P4")); + rowList.add(rs.getString("P5")); + rowList.add(rs.getString("NO")); + dataList.add(rowList); + } + + //表格2数据 + while(rs2.next()) { + List rowList2=new ArrayList(); + rowList2.add(rs2.getString("PLMID")); + rowList2.add(rs2.getString("NUM")); + rowList2.add(rs2.getString("P1")); + rowList2.add(rs2.getString("P2")); + rowList2.add(rs2.getString("P3")); + rowList2.add(rs2.getString("P4")); + rowList2.add(rs2.getString("P5")); + rowList2.add(rs2.getString("P6")); + rowList2.add(rs2.getString("P7")); + rowList2.add(""); + rowList2.add(""); +// rowList2.add(rs2.getString("HBDYG")); //9 +// Integer sscInteger=rs2.getInt("HHC"); +// rowList2.add(sscInteger.toString()); //10 + dataList2.add(rowList2); + } + System.out.println("dataList2.size()"+dataList2.size()); + if(dataList2.size()==0) { + Date now = new Date(); +// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//可以方便地修改日期格式 + SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = dateFormat1.format(now); + UUID uuid = UUID.randomUUID(); + String uid=uuid.toString().replace("-", ""); + //插入数据到数据库 + String insert = "insert into AHMC_PFMEALIBRARY values(?,?,?,?,?,?,?,?,?,?,?,?)"; + SqlUtilT.getTCConnection(); + SqlUtilT.write(new String[] {uid,comp.getUid(),null,null,null,null,null,null,null,null,null,time} + ,insert); + List rowList2=new ArrayList(); + rowList2.add(uid); + rowList2.add(time); + rowList2.add(""); + rowList2.add(""); + rowList2.add(""); + rowList2.add(""); + rowList2.add(""); + rowList2.add(""); + rowList2.add(""); + rowList2.add(""); + rowList2.add(""); + dataList2.add(rowList2); + } + // 将表中的行重新排序,并获取当前用户可修改的行号 + String userName = form.getReferenceProperty("owning_user") + .getStringProperty("user_id"); +// // 判断是否发布 +// boolean isRelease = item.getLatestItemRevision().getProperty( +// "release_status_list") != ""; + + //+++ + for (int i = 0; i < dataList.size(); i++) { + // 行号差 + dataList.get(i).set(27,i- Integer.parseInt(dataList.get(i).get(25).toString())); + if(user.getGroups()[0].getGroupName().equals("dba")) + { + isOwning = true; + processRows.add(i); + plmeidList.add(dataList.get(i).get(0).toString()); + continue; + } + else if (isRelease && !user.getGroups()[0].getGroupName().equals("dba")) + { + continue; + } + if (user.getUserId().equals(userName)) { + isOwning = true; + processRows.add(i); + plmeidList.add((String) dataList.get(i).get(0)); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + /** + * 获取对象属性 + */ + public void getPropertys() { + // 获取选择的目标对象 + try { + // 获取选中对象的版本表单 + if (comp instanceof TCComponentItemRevision + && comp.getType().toUpperCase().indexOf("PFMEA") >= 0) { + item = ((TCComponentItemRevision) comp).getItem(); + AIFComponentContext[] context = item.whereReferenced(); +// this.itemProperties = item.getTCProperties(itemProperName); //.getRelatedComponent("IMAN_master_form") + for (int i = 0; i < context.length; i++) { + if (context[i].getComponent().getType().equals("HS2_ProductMEP")|| + context[i].getComponent().getType().equals("HS2_AssemblyMEP") + ||context[i].getComponent().getType().equals("HS2_SpecialMEP")|| + context[i].getComponent().getType().equals("HS2_ProcessMEP")) { //.getType().equals("HS2_MEOP") + meprocess = (TCComponentItem) context[i].getComponent(); + } + } + //获取到 comp 最新版本对象的版本表单 IMAN_master_form_rev + form = ((TCComponentItemRevision) comp); +// .getRelatedComponent("IMAN_master_form_rev"); + } else { + MessageBox.post("请选择PFMEA版本对象!", "错误", MessageBox.ERROR); + return; + } + if (form != null) { + properties = form.getTCProperties(properName); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void getCombineMap() { + try { + if (dataList != null && dataList.size() > 0) { + for (int i = 0; i < dataList.size(); i++) { + if (dataList.get(i).get(26) != null + && !dataList.get(i).get(26).equals("")) { + String sombine = dataList.get(i).get(26).toString(); + int rowDif = Integer.parseInt(dataList.get(i).get(27) + .toString()); + String[] sombines; + if (sombine.indexOf("-") >= 0) { + sombines = sombine.split("-"); + } else { + sombines = new String[] { sombine }; + } + for (int j = 0; j < sombines.length; j++) { + if (sombines[j].indexOf("/") >= 0) { + int[] row; + int[] cloumn; + String[] cells = sombines[j].split("/"); + if (cells[0].indexOf(",") >= 0) { + String[] rows = cells[0].split(","); + row = new int[rows.length]; + for (int k = 0; k < rows.length; k++) { + row[k] = Integer.parseInt(rows[k]) + + rowDif; + } + } else { + row = new int[] { Integer + .parseInt(cells[0]) + rowDif }; + } + if (cells[1].indexOf(",") >= 0) { + String[] cloumns = cells[1].split(","); + cloumn = new int[cloumns.length]; + for (int k = 0; k < cloumns.length; k++) { + cloumn[k] = Integer + .parseInt(cloumns[k]); + } + } else { + cloumn = new int[] { Integer + .parseInt(cells[1]) }; + } + this.combineMap.put(row, cloumn); + } + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void executeModal() throws Exception { + //+++++++判断是否发布 + isRelease= comp.getProperty( + "release_status_list") != ""; + //++++如果没发布isRelease为false就看是否有写的权限 + if(!isRelease) { + try { + TCComponentUser user = session.getUser(); + TCComponentGroup group = session.getCurrentGroup(); + TCComponentRole role = session.getCurrentRole(); + + TCComponent coms[] = { user, group, role }; + TCAccessControlService service = session + .getTCAccessControlService(); + boolean[] flags = service.checkAccessorsPrivileges(coms, (TCComponent) app.getTargetComponent(), + new String[] { "WRITE" }); + for (boolean b : flags) { + if (!b) { + //没有写的权限就让isRelease为true,就不让其编辑 + isRelease = true; + break; + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + if(!isRelease) { + //判断是否打开签出 + if(((TCComponent) comp).isCheckedOut()) { + MessageBox.post("PFMEA正在编辑!(已签出)", "错误", MessageBox.ERROR); + return; + } + //没签出则在打开时签出对象 + new ReserveOperation(new AIFComponentContext(comp, + comp, "context")).executeModeless(); + } + + + + // 获取版本表单的所有者 + try { + getPropertys(); + //+++添加进度条 + frame.setSize(300, 70); + frame.setLocationRelativeTo(null); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.setLayout(new BorderLayout()); + progressBar.setOrientation(JProgressBar.HORIZONTAL); + progressBar.setSize(300, 50); + progressBar.setMinimum(0); + progressBar.setMaximum(100); + progressBar.setBorderPainted(true); + progressBar.setUI(new MetalProgressBarUI()); + progressBar.setBackground(Color.white); + progressBar.setForeground(Color.green); + progressBar.setStringPainted(true); + frame.setAlwaysOnTop(true); + frame.add(progressBar); + frame.setVisible(true); + progressBar.setValue(1); + //+++ +// System.out.println("工艺ID"+meprocess.getStringProperty("item_id")); +// //没发布的版本要同步bom更新 +// if(comp.getProperty("release_status_list")==null||comp.getProperty("release_status_list").equals("")) { +// SavePfmea savePfmea = new SavePfmea(session, meprocess,comp); +// savePfmea.insertData(); +// } + + //++++如果版本的版本不是“00”就获取最后版本的数据给新修订的版本 + // 获取数据库连接 + ResultSet rs0 = null; + ResultSet rs = null; +// InputStream input = null; + SqlUtilT.getTCConnection(); + InputStream input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + String revisionID=app.getTargetComponent().getProperty("item_revision_id"); + TCComponent[] Revisions=(((TCComponent) comp).getReferenceListProperty("revision_list")); + + //查看选中目标是否是第一次打开,是新修订的版本就把最新版本的数据复制给他 + String sql0 = String.format(pro.getProperty("SETPFMEASELECT"), + meprocess.getUid(),comp.getUid()); + rs0 = SqlUtilT.read(sql0); + if(!revisionID.equals("A01")&&!rs0.next()) { + List> addData=new ArrayList>(); + try { + SqlUtilT.getTCConnection(); + String sql = String.format(pro.getProperty("SETPFMEASELECT"), + meprocess.getUid(),Revisions[Revisions.length-2].getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(rs.getString("PROCESSPUID")); + rowList.add(rs.getString("MEOPID")); + rowList.add(rs.getString("GYBH")); + rowList.add(rs.getString("GCMC")); + rowList.add(rs.getString("STATION")); + rowList.add(rs.getString("REQUIREMENT")); + rowList.add(rs.getString("QZSXMS")); + rowList.add(rs.getString("QZSXHG")); + rowList.add(rs.getString("YZD")); + rowList.add(rs.getString("JB")); + rowList.add(rs.getString("QZSXQY")); + rowList.add(rs.getString("XXGCKZYF")); + rowList.add(rs.getString("PDS")); + rowList.add(rs.getString("XXGCKZTC")); + rowList.add(rs.getString("TCD")); + rowList.add(rs.getString("RPN")); + rowList.add(rs.getString("JYCS")); + rowList.add(rs.getString("ZZR")); + rowList.add(rs.getString("JHWCRQ")); + rowList.add(rs.getString("CQDCS")); + rowList.add(rs.getString("NEW_SEV")); + rowList.add(rs.getString("NEW_OCC")); + rowList.add(rs.getString("NEW_DET")); + rowList.add(rs.getString("NEW_RPN")); + rowList.add(rs.getString("IDEAL_STATE")); + Integer ssInteger=rs.getInt("HH"); + rowList.add(ssInteger.toString());//rowList.add(rs.getInt("HH")); + rowList.add(rs.getString("HBDYG")); + Integer sscInteger=rs.getInt("HHC"); + rowList.add(sscInteger.toString());//rowList.add(rs.getInt("HHC")); + rowList.add(rs.getString("SPECIAL")); + rowList.add(rs.getString("TYPE")); + rowList.add(rs.getString("BAK")); + rowList.add(rs.getString("OCCURRRENCE")); + rowList.add(rs.getString("DETECTION")); + rowList.add(rs.getString("PRIORITY")); + rowList.add(rs.getString("P1")); + rowList.add(rs.getString("P2")); + rowList.add(rs.getString("P3")); + rowList.add(rs.getString("P4")); + rowList.add(rs.getString("P5")); + rowList.add(comp.getUid());//选择的对象的puid放在数据库的REVISIONID中 + rowList.add(rs.getString("NO")); + addData.add(rowList); + } + }catch (Exception e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + for(int i=0;i data=new ArrayList(); + data=addData.get(i); + String[] dataString=data.toArray(new String[]{}); + SqlUtilT.getTCConnection(); + String insertSQL = pro.getProperty("INSERTPFMEA"); + SqlUtilT.write2(dataString, insertSQL); + } + } + progressBar.setValue(5); + //++++++++ + +// //没发布的版本要同步bom更新 +// if(comp.getProperty("release_status_list")==null||((TCComponent)comp).getReferenceListProperty("release_status_list").length==0) { +// System.out.println("未发布"); +// SavePfmea savePfmea = new SavePfmea(session, meprocess,comp); +// savePfmea.insertData(); +// } + progressBar.setValue(10); + + //未添加工序则无数据 + getData(); + if(dataList==null||dataList.size()==0) { + //没发布的版本要同步bom更新 + if(comp.getProperty("release_status_list")==null||((TCComponent)comp).getReferenceListProperty("release_status_list").length==0) { + System.out.println("未发布"); + SavePfmea savePfmea = new SavePfmea(session, meprocess,comp); + savePfmea.insertData(); + } + dataList2.clear(); + getData(); + } + //System.out.println("=========dataList为:"+dataList.toString()); + getCombineMap(); + if (properties == null) { + return; + } + + //获取属性 + final PFMEABean pfmeaBean = new PFMEABean(); + pfmeaBean.setPfmeaNumber(item.getStringProperty("item_id")); +// int newestRevisiovId = 0; +// if(item.getLatestItemRevision().getProperty("release_status_list") != "") +// { +// newestRevisiovId = Integer.parseInt(item.getLatestItemRevision().getProperty("item_revision_id")); +// } +// else +// { +// newestRevisiovId = Integer.parseInt(item.getLatestItemRevision().getProperty("item_revision_id"))-1; +// } +// TCComponent[] items = (item.getReferenceListProperty("revision_list")); +// for (int i = 0; i < items.length; i++) { +// if(items[i] instanceof TCComponentItemRevision) +// { +// TCComponentItemRevision revComponent = ((TCComponentItemRevision)items[i]); +// int revId = Integer.parseInt(revComponent.getStringProperty("item_revision_id")); +// if(revId != 0 && revComponent.getProperty("release_status_list") != "") +// { +// //获取第一版本表单 +// TCComponent revMaster = revComponent.getRelatedComponent("IMAN_master_form_rev"); +// } +// if(revId == newestRevisiovId) +// { +// //最新版本 +// TCComponent revMaster = revComponent.getRelatedComponent("IMAN_master_form_rev"); +// } +// } +// } + progressBar.setValue(95); +// if(pfmeaBean.getChangeDate() == null) +// { +// pfmeaBean.setChangeDate(""); +// } + //根据工序获取产品 +// AIFComponentContext[] productItems = meprocess.whereReferenced(); +// for (int i = 0; i < productItems.length; i++) { +// if(productItems[i].getComponent().getType().indexOf("Product") >= 0 && productItems[i].getComponent() instanceof TCComponentItem) +// { +// TCComponentItem product = (TCComponentItem) productItems[i].getComponent(); +// } +// } + progressBar.setValue(96); +// 项目名称获取产品对象的客户项目号rb3_khxmh, + +// 编制日期对应第一个版本的编制日期rb3_bianzhiriqi, +// 更改日期对应最新发布版本的版本表单上的编制日期, + +// 编制对应PFMEA第一个版本表单的编制rb3_bianzhi, +// 增加产品型号,对应产品的item_id, +// 客户图号对应产品对象属性rb3_khth, +// PFMEA号对应PFMEA的item_id + //获取PFMEA版本 +// TCComponent[] itemRevs = (item.getReferenceListProperty("revision_list")); + final List> changValueList = new ArrayList>(); +// for (int i = 0; i < itemRevs.length; i++) { +// if(itemRevs[i].getProperty("release_status_list") != "" && !itemRevs[i].getStringProperty("item_revision_id").equals("00")) +// { +// //获取更改日期,和更改人 +// List changValue = new ArrayList(); +//// TCComponent revMaster = itemRevs[i].getRelatedComponent("IMAN_master_form_rev"); +// changValue.add(itemRevs[i].getStringProperty("hs2_bianzhiriqi")); +// changValue.add(itemRevs[i].getStringProperty("hs2_bianzhi")); +// changValue.add(itemRevs[i].getStringProperty("hs2_drawup_date")); +// changValueList.add(changValue); +// } +// } + progressBar.setValue(100); + new Thread() { + @Override + public void run() { + DesignPFMEADialog dialog = new DesignPFMEADialog( + app, session, processRows, + (TCComponentItemRevision) comp, meprocess, + properties,pfmeaBean,itemProperties,changValueList, combineMap, dataList,dataList2,plmeidList, + isOwning,UID); + frame.dispose(); + } + }.start(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + super.executeModal(); + } + + +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog.java b/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog.java new file mode 100644 index 0000000..504b484 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog.java @@ -0,0 +1,4851 @@ +package com.connor.hs2.plm.PFMEA.design; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringReader; +import java.sql.ResultSet; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; +import java.util.UUID; +import java.util.Vector; + +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.JTextPane; +import javax.swing.JViewport; +import javax.swing.ListCellRenderer; +import javax.swing.ListSelectionModel; +import javax.swing.RowFilter; +import javax.swing.UIManager; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; + +import org.apache.poi.hssf.usermodel.HSSFCell; +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.CellType; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jdesktop.swingx.renderer.DefaultTableRenderer; +import org.jdesktop.swingx.renderer.FormatStringValue; +import org.jdesktop.swingx.renderer.StringValue; +import org.jdesktop.swingx.table.DatePickerCellEditor; + +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.Adapter1; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTMap2; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.CTextField; +import com.connor.renben.process.plm.util.ExcelUtil; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.MultiComboBox; +import com.connor.renben.process.plm.util.MyTableModel; +import com.connor.renben.process.plm.util.TextAreaCellEditor; +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.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.services.rac.core.ReservationService; + + +public class DesignPFMEADialog extends JFrame implements ActionListener { + private AbstractAIFApplication app; + private InterfaceAIFComponent comp; + private TCSession session; + private TCProperty[] properties; + private PFMEABean pfmeaBean; + private TCProperty[] itemProperties; + private List> changValueList; + private CTMap map; + private CTMap2 map2; + static JScrollPane scrollPane; + private Timer timer; +// private String[] header = new String[] { "PLMEID", "问题", "历史/变更授\n权(适用时)", "1. 过程项系\n统、子系统、\n零件要素或过\n程名称", +// "2. 过程步骤\n工位编号和关\n注要素名称", "3. 过程工作\n要素 4M法", "1.过程项的\n功能系统、子\n系统、组件要\n素或过程的功\n能", "2.过程步骤\n的功能和产品\n特性(量值为\n可选项)", +// "3.过程工作\n要素的功能和\n过程特性", "1.对上一较\n高级别要和\n/或终端用户\n失效影响(F\nE)", "失效影响的严\n重度(S)", "2.关注要素\n的失效模式(\nFM)", "3.工作要素\n的失效起因\n(FC)", +// "对失效起因的\n当前预防控制\n(PC)", "失效起因的频\n度(O)", "对失效起因或\n失效模式的当\n前探测控制(\nDC)", "失效起因/失\n效模式的可探\n测度(D)", "PFMEA措\n施优先级", "产品特性", +// "筛选器代码(\n可选)", "预防措施", "探测措施", "负责人姓名", "目标完成日期", "状态", "采取基于证据\n的措施", "完成日期", "严重度(S)\nSeverity(S)", +// "频度(O)\nOccurrence\n(O)", "可探测度\n(D)\nDetection\n(D)", "产品特性", "PFMEA AP ", "备注","查找编号" }; + private String[] header = new String[] { "PLMEID", "问题", "历史/变更授\n权(适用时)", "1. 过程项", + "2. 过程步骤", "3. 过程工作\n要素", "1.过程项\n功能", "2.过程步骤\n的功能和产品\n特性", + "3.过程工作\n要素的功能和\n过程特性", "1.失效影响\n(FE)", "严重度(S)", "2.作业步骤\n的失效模式(\nFM)", "3.作业要素\n的失效起因\n(FC)", + "现行预防控制\n(PC)", "发生度(O)", "现行探测控制(\nDC)", "探测度(D)", "AP", "特殊特性", + "筛选器代码\n(选填)", "预防措施", "探测措施", "负责人", "目标完成\n时间", "状态", "采取基于证据\n的措施", "实际完成\n时间", "S", + "O", "D", "特殊特性", "AP ", "备注","查找编号" }; + private String[] pfmeaHeader = new String[] { "PLMEID", "问题", "1. 过程项", + "2. 过程步骤", "3. 过程工作要素", "1.过程项功能" , "2.过程步骤的功能和产品特性" , + "3.过程工作要素的功能和过程特性", "1.失效影响(FE)", "严重度(S)", "2.作业步骤的失效模式(FM)", "3.工作要素的失效起因(FC)", + "现行预防控制(PC)", "发生度(O)", "现行探测控制(DC)", "探测度(D)", "AP", "特殊特性", + "筛选器代码(选填)", "预防措施", "探测措施", "负责人", "目标完成时间", "状态", "采取基于证据的措施", "实际完成时间", "S", + "O", "D", "特殊特性", "AP ", "备注", "父节点ID" }; + private String[] pfmeaKuHeader = new String[] { "PLMEID", "选择" ,"问题", "历史/变更授\n权(适用时)", "1. 过程项", + "2. 过程步骤", "3. 过程工作要素", "1.过程项功能" , "2.过程步骤的功能和产品特性" , + "3.过程工作要素的功能和过程特性", "1.失效影响(FE)", "严重度(S)", "2.作业步骤的失效模式(FM)", "3.工作要素的失效起因(FC)", + "现行预防控制(PC)", "发生度(O)", "现行探测控制(DC)", "探测度(D)", "AP", "特殊特性", + "筛选器代码(选填)", "预防措施", "探测措施", "负责人", "目标完成时间", "状态", "采取基于证据的措施", "实际完成时间", "S", + "O", "D", "特殊特性", "AP ", "备注", "父节点ID" }; +// private String[] pfmeaHeader = new String[] { "PLMEID", "ID", "1. 过程项" + "系统、子系统、零件要素或过程名称", +// "2. 过程步骤" + "工位编号和关注要素名称", "3. 过程工作要素 4M法", "1.过程项的功能" + "系统、子系统、组件要素或过程的功能", "2.过程步骤的功能和产品特性" + "(量值为可选项)", +// "3.过程工作要素的功能和过程特性", "1.对上一较高级别要和/或终端用户失效影响(FE)", "失效影响的严重度(S)", "2.关注要素的失效模式(FM)", "3.工作要素的失效起因(FC)", +// "对失效起因的当前预防控制(PC)", "失效起因的频度(O)", "对失效起因或失效模式的当前探测控制(DC)", "失效起因/失效模式的可探测度(D)", "PFMEA措施优先级", "产品特性", +// "筛选器代码(可选)", "预防措施", "探测措施", "负责人姓名", "目标完成日期", "状态", "采取基于证据的措施", "完成日期", "严重度(S)Severity(S)", +// "频度(O)Occurrence(O)", "可探测度(D)Detection(D)", "产品特性", "PFMEA AP ", "备注", "父节点ID" }; +// private String[] pfmeaHeader = new String[] { "PLMEID","ID", "Station", "要求", +// "潜在失效模式", "潜在失效后果", "严重度S", "级别", "潜在失效起因/机理", "现行过程控制预防", "频度数O", +// "现行过程控制探测", "探测度D", "RPN", "建议措施", "责任人", "计划完成日期", "采取的措施", +// "New_SEV", "New_OCC", "New_DET", "New_RPN", "Ideal_State", "父节点ID", +// "特殊符号位置" };//,"发生频率","检测频率","优先级"}; + private String[] recordHeader = new String[] { "PLMID","序号","日期", "章节", "修订原因", "修订内容", "修订后版本", "制/修订人", "核准人" }; + private String[] leftHeader = new String[] { "PLMEID", "ID", "名称", "名称" }; + private Map combineMap;// 存放合并单元格 + //private Map combineMap2;// 存放合并单元格 + private Map excelCombineMap = new HashMap();// 存放合并单元格 + private TCComponentItemRevision itemRevision;// 选中对象的版本 + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-M-dd HH:mm"); + private TCComponentItem meprocess;// 选中所在的工艺 + // private List> processRowList;//当前用户可修改的行号 + private List processRows;// 当前用户可修改的行号 + private List> dataList; + private List> dataList2; + private List> excelDataList = new ArrayList>(); + private List plmeidList; + private List deleteRows = new ArrayList(); + private SpecialDialog specialDialog; + private LibraryDialog libraryDialog; + private Properties pro = new Properties(); + private boolean isComplete = false; + private boolean isOwning; + private int selectRow = -1; + private int selectColumn = -1; + private int recordSelectRow = -1; + private int recordSelectColumn = -1; + + //表格2菜单 + private static JPopupMenu menu2; + private JMenuItem addItem2; + private JMenuItem remItem2; + private JMenuItem upItem2; + // 判断单元格显示框是否获取焦点 + private boolean isFocusOwner = false; + // 判断履历单元格显示框是否获取焦点 + private boolean recordIsFocusOwner = false; + + // 界面所需控件 + private JPanel titlePanel;// 标题 + private JLabel titleLabel; + + private JPanel mainPanel;// 属性填写 + + private JLabel companyNameLabel;// 公司名称 + private JComboBox companyNameField; + private JLabel projectLabel;// 项目 + private CTextField projectField; + private JLabel pfmeaIdLabel;// PFMEA ID编号 + private CTextField pfmeaIdField; + private JLabel addressLabel;// 制造地址 + private CTextField addressField; + + private JLabel pfmeaStartLabel;// PFMEA开始日期 + private DateButton pfmeaStartButton; + private JLabel pfmeaUpdateLabel;// PFMEA修订日期 + private DateButton pfmeaUpdateButton; + private JLabel processDutyLabel;// 过程职责 + private CTextField processDutyField; + + private JLabel customerNameLabel;// 顾客名称 + private JTextField customerNameField; + private JLabel securityClassificationLabel;// 保密级别 + private DateButton securityClassificationField; + private JLabel modelPlatformLabel;// 车型/平台 + private CTextField modelPlatformField; + private JLabel functionalTeamsLabel;// 跨职能团队 + private CTextField functionalTeamsField; +// private JLabel expiryDateLabel; //逾期日期 +// private DateButton expiryDateButton; + + // 显示选中单元格内容 + private JTextPane showValuePane; + private JTextPane showRecordValuePane;// 履历 + + // 标签页 + private JTabbedPane tabbedPane; + // 第一页 + private JPanel firstPanel;// 表格控件 + private static CTable table; + // 第二页 + private int selectMainRow2=-1; + private JPanel secondPanel;// 表格控件 + private JTable table2; + + //设置frameSize + private JButton reSetSize;// 重置界面大小 + private int[] SizeLoca=new int[4]; + private int[] table1Size=new int[32]; + private int[] table2Size=new int[7]; + private int initRowHeight = 50; + private String userName=""; + private String type=""; + private boolean isFirstOpen=false;//判断是否是第一次打开,同时如果是第一次打开,当第一次保存后已向数据库插入了数据isFirstOpen会置false,再保存时就只会更新,不会重复插入 + private boolean isReSet=false; + + + + + // 右键菜单 + private static JPopupMenu menu; + // 右键菜单项 + private JMenuItem openLibarary; + private JMenuItem addRowItem; + private JMenuItem addRowsItem; + private JMenuItem addItem; + private JMenuItem addCombineRowsItem; + private JMenuItem remItem; + private JMenuItem comBineItem; + //private JMenuItem comBineItem2; + private JMenuItem splitItem; + private JMenuItem shrinkColumnItem; + private JMenuItem celShrinkColumnItem; + // private JMenuItem deleteSpecialItem; + private JPanel rootPanel;// 按钮 +// private JButton addButton;// 添加 +// private JButton remButton;// 移除 +// private JButton comBinebutton;// 合并 +// private JButton splitButton;// 拆分 + private JButton saveButton;// 保存 + private JButton completeButton;// 完成 + private JButton clearData;// 完成 + // private JButton addSpecialButton;// 添加特殊符号 +// private JButton deleteSpecialButton;// 移除特殊符号 + private JButton libraryButton;// 打开PFME库 + private JButton RefreshButton;// 删除所有数据后刷新按钮 + private JTextField setHeightTxt;// 删除所有数据后刷新按钮 + private JButton setHeightBtn;// 删除所有数据后刷新按钮 + private String UID; + // PFMEA库 + + public DesignPFMEADialog(AbstractAIFApplication app, TCSession session, List processRows, + TCComponentItemRevision itemRevision, TCComponent meprocess, TCProperty[] properties, PFMEABean pfmeaBean, + TCProperty[] itemProperties, List> changValueList, Map combineMap, + List> dataList,List> dataList2, List plmeidList, boolean isOwning,String UID) { + super(); + // this.processRowList = processRowList; + this.processRows = processRows; + this.dataList = dataList; + this.dataList2 = dataList2; + this.plmeidList = plmeidList; + this.combineMap = combineMap; + //this.combineMap2=combineMap2; + this.itemRevision = itemRevision; + this.meprocess = (TCComponentItem) meprocess; + this.properties = properties; + this.pfmeaBean = pfmeaBean; + this.itemProperties = itemProperties; + this.changValueList = changValueList; + this.app = app; + this.session = session; + this.userName=this.session.getUser().toString(); + this.type="PFMEADialog"; + this.isOwning = isOwning; + this.isOwning=true; + this.UID=UID; + //获取选中对象 + this.comp = app.getTargetComponent(); + runTask(); + + init(); + this.processRows = processRows; + // setProcessRows(this.processRowList); + comBine(); + } + + + public void getFrameSize() { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + ResultSet rs = null; + ResultSet rs0 = null; + InputStream input = null; + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + String sql = String.format("select * from AHMC_PFMEAFRAME_SIZE WHERE USERNAME = '%s' AND TYPE = '%s'",userName,type); + rs = SqlUtilT.read(sql); + List rowList = new ArrayList(); + while (rs.next()) { + rowList.add(rs.getString("FRAMESIZE"));//界面大小、位置 + rowList.add(rs.getString("TABLE1SIZE"));//第一个表格的列宽数据 + rowList.add(rs.getString("TABLE2SIZE"));//第二格表格的列宽数据 + rowList.add(rs.getString("ROWHEIGHT"));//第1格表格的行高数据 + break; + } + if(rowList.size()==4) {//解析界面大小,位置,表格列宽数据 + analyticSize(rowList); + }else { + String sql0 = String.format("select * from AHMC_PFMEAFRAME_SIZE WHERE USERNAME = '%s' AND TYPE = '%s'","iniUser",type); + rs0 = SqlUtilT.read(sql0); + while (rs0.next()) { + rowList.add(rs0.getString("FRAMESIZE"));//界面大小、位置 + rowList.add(rs0.getString("TABLE1SIZE"));//第一个表格的列宽数据 + rowList.add(rs0.getString("TABLE2SIZE"));//第二格表格的列宽数据 + rowList.add(rs0.getString("ROWHEIGHT"));//第1格表格的行高数据 + break; + } + if(rowList.size()<=0) { + MessageBox.post("(数据库)未设置界面最初尺寸,请先配置!", "错误", MessageBox.ERROR); + return; + }else { + isFirstOpen=true; + analyticSize(rowList); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if(rs0 != null) { + SqlUtilT.free(rs0); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } +} + + //解析界面数据 + public void analyticSize(List rowList) { + if(rowList.get(0).indexOf("/")>-1) {//获取界面大小位置 + String[] data=rowList.get(0).split("/"); + for(int i=0;i<4;i++) { + SizeLoca[i]=Integer.parseInt(data[i]); + } + } + if(rowList.get(1).indexOf("/")>-1) { + String[] data=rowList.get(1).split("/"); + for(int i=0;i<32;i++) { + table1Size[i]=Integer.parseInt(data[i]); + } + } + if(rowList.get(2).indexOf("/")>-1) { + String[] data=rowList.get(2).split("/"); + for(int i=0;i<7;i++) { + table2Size[i]=Integer.parseInt(data[i]); + } + } + + if(!rowList.get(3).equals("")) { + initRowHeight = Integer.valueOf(rowList.get(3)); + } + + + } + + + + + public void comBine() { + // TODO Auto-generated method stub + if (combineMap != null && combineMap.size() != 0) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + map.combine(entry.getKey(), entry.getValue()); + } + } +// if (combineMap2 != null && combineMap2.size() != 0) { +// Iterator> it = combineMap2.entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// map2.combine(entry.getKey(), entry.getValue()); +// } +// } + + } + + // /** + // * 动态设置可修改列 + // */ + // public void setProcessRows(List> processRowList) { + // for (int i = 0; i < processRowList.size(); i++) { + // for (int j = 0; j < processRowList.get(i).size(); j++) { + // this.processRows.add(processRowList.get(i).get(j)); + // } + // } + // if(this.processRows != null && this.processRows.size()>0) + // { + // this.map.setProcessRowList(this.processRows); + // } + // } + + private JLabel expiryDateLabel; + private JTextField expiryTextField; + private void init() { + getFrameSize(); + //获取国际化语言 + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + this.setTitle(rb.getString("txPFMEA10_display.TITLE")); + // this.setLocationRelativeTo(null); + // this.setUndecorated(true); + this.setPreferredSize(new Dimension(SizeLoca[0], SizeLoca[1])); + this.setLocation(SizeLoca[2], SizeLoca[3]); + this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + if(!isOwning) { + DesignPFMEADialog.this.dispose(); + }else { + int i = JOptionPane.showConfirmDialog(null, "是否保存?", "保存", JOptionPane.YES_NO_OPTION); + if (i == JOptionPane.YES_OPTION) { + okEvent(true, true); + DesignPFMEADialog.this.dispose(); + } else if (i == JOptionPane.NO_OPTION) { + DesignPFMEADialog.this.dispose(); + } + } + } + }); + // 初始化标题部分控件 + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel(rb.getString("qzsxmsjhgfx10_display.TITLE")); + this.titleLabel.setFont(new Font("宋体", 1, 18)); + this.titlePanel.add(titleLabel); + // 初始化菜单部分控件 + this.mainPanel = new JPanel(new PropertyLayout()); + this.companyNameLabel = new JLabel(rb.getString("gsmc10_display.TITLE")); + this.companyNameField = new JComboBox(); + try { + TCComponentType mycomponenttype = session.getTypeComponent("ListOfValues"); + TCComponentListOfValuesType myComponentListOfValuesType = (TCComponentListOfValuesType) mycomponenttype; + TCComponentListOfValues[] Arraylistofvalues = myComponentListOfValuesType + .find("HS2_CompanyName_LOV"); + TCComponentListOfValues ML8_BOMPurpose_LOV = Arraylistofvalues[0]; + utils.dymanicLov(session, ML8_BOMPurpose_LOV, companyNameField); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + this.companyNameField.setPreferredSize(new Dimension(160, 20)); + this.projectLabel = new JLabel("产品名称"); + this.projectLabel.setPreferredSize(new Dimension(90, 20)); + this.projectField = new CTextField(this.properties[1].getStringValue()); + this.projectField.setPreferredSize(new Dimension(160, 20)); + this.pfmeaIdLabel = new JLabel(rb.getString("PFMEAIDbh10_display.TITLE"));// PFMEA号 + this.pfmeaIdField = new CTextField(this.pfmeaBean.getPfmeaNumber()); + this.pfmeaIdField.setPreferredSize(new Dimension(160, 20)); + this.addressLabel = new JLabel(rb.getString("zzdz10_display.TITLE")); + this.addressField = new CTextField(this.properties[2].getStringValue()); + this.addressField.setPreferredSize(new Dimension(160, 20)); + + this.pfmeaStartLabel = new JLabel(rb.getString("PFMEAksrq10_display.TITLE")); + this.pfmeaStartButton = new DateButton(dateFormat); + this.pfmeaStartButton.setText(this.properties[3].getStringValue()); + this.pfmeaStartButton.setPreferredSize(new Dimension(160, 20)); + this.pfmeaUpdateLabel = new JLabel(rb.getString("PFMEAxdrq10_display.TITLE")); + this.pfmeaUpdateLabel.setPreferredSize(new Dimension(90, 20)); + this.pfmeaUpdateButton = new DateButton(dateFormat); + this.pfmeaUpdateButton.setText(this.properties[4].getStringValue()); + this.pfmeaUpdateButton.setPreferredSize(new Dimension(160, 20)); + this.processDutyLabel = new JLabel(rb.getString("gczz10_display.TITLE")); + this.processDutyLabel.setPreferredSize(new Dimension(80, 20)); + this.processDutyField = new CTextField(this.properties[5].getStringValue()); + this.processDutyField.setPreferredSize(new Dimension(160, 20)); + + this.customerNameLabel = new JLabel(rb.getString("gkmc10_display.TITLE")); + this.customerNameField = new CTextField(this.properties[6].getStringValue()); + this.customerNameField.setPreferredSize(new Dimension(160, 20)); + + this.securityClassificationLabel = new JLabel(rb.getString("bmjb10_display.TITLE")); + this.securityClassificationField =new DateButton(dateFormat); + this.securityClassificationField.setText(this.properties[7].getStringValue()); + this.securityClassificationField.setPreferredSize(new Dimension(160, 20)); + this.modelPlatformLabel = new JLabel(rb.getString("cxpt10_display.TITLE")); + this.modelPlatformLabel.setPreferredSize(new Dimension(90, 20)); + this.modelPlatformField = new CTextField(this.properties[8].getStringValue()); + this.modelPlatformField.setPreferredSize(new Dimension(160, 20)); + this.functionalTeamsLabel = new JLabel(rb.getString("kzntd10_display.TITLE")); + this.functionalTeamsLabel.setPreferredSize(new Dimension(80, 20)); + this.functionalTeamsField = new CTextField(this.properties[9].getStringValue()); + this.functionalTeamsField.setPreferredSize(new Dimension(160, 20)); + + this.expiryDateLabel = new JLabel("产品零件号"); +// this.expiryDateLabel.setPreferredSize(new Dimension(80, 20)); + + this.expiryTextField = new CTextField(this.properties[10].getStringValue()); + this.expiryTextField.setPreferredSize(new Dimension(140, 20)); +// this.expiryDateButton = new DateButton(dateFormat); +// +// this.expiryDateButton.setText(this.properties[11].getStringValue()); +// this.expiryDateButton.setPreferredSize(new Dimension(160, 20)); +// try { +// if(this.pfmeaBean.getChangeDate()!= null && !this.pfmeaBean.getChangeDate().equals("")) +// { +// this.changeDateButton.setDate(new SimpleDateFormat( +// "yyyy-M-dd").parse(this.pfmeaBean.getChangeDate())); +// } +// else { +// this.changeDateButton.setDate(""); +// } +// } catch (ParseException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } + // this.changeDateButton.setPreferredSize(new Dimension(160, 20)); + + this.mainPanel.add("1.1.left.top", this.companyNameLabel); + this.mainPanel.add("1.2.left.top", this.companyNameField); + this.mainPanel.add("1.3.left.top", this.projectLabel); + this.mainPanel.add("1.4.left.top", this.projectField); + this.mainPanel.add("1.5.left.top", this.pfmeaIdLabel); + this.mainPanel.add("1.6.left.top", this.pfmeaIdField); + this.mainPanel.add("1.7.left.top", this.addressLabel); + this.mainPanel.add("1.8.left.top", this.addressField); + + this.mainPanel.add("2.1.left.top", this.pfmeaStartLabel); + this.mainPanel.add("2.2.left.top", this.pfmeaStartButton); + this.mainPanel.add("2.3.left.top", this.pfmeaUpdateLabel); + this.mainPanel.add("2.4.left.top", this.pfmeaUpdateButton); + this.mainPanel.add("2.5.left.top", this.processDutyLabel); + this.mainPanel.add("2.6.left.top", this.processDutyField); + this.mainPanel.add("2.7.left.top", this.customerNameLabel); + this.mainPanel.add("2.8.left.top", this.customerNameField); + + this.mainPanel.add("3.1.left.top", this.securityClassificationLabel); + this.mainPanel.add("3.2.left.top", this.securityClassificationField); + this.mainPanel.add("3.3.left.top", this.modelPlatformLabel); + this.mainPanel.add("3.4.left.top", this.modelPlatformField); + this.mainPanel.add("3.5.left.top", this.functionalTeamsLabel); + this.mainPanel.add("3.6.left.top", this.functionalTeamsField); + this.mainPanel.add("3.7.left.top", this.expiryDateLabel); + this.mainPanel.add("3.8.left.top", this.expiryTextField); + + JPanel topPanel = new JPanel(new PropertyLayout()); + topPanel.add("1.1.left.top", this.mainPanel); + + this.firstPanel = new JPanel(new BorderLayout()); + this.table = getjTable(null, null, header, null); + for(int i=1;i<=table1Size.length;i++) { + this.table.getColumnModel().getColumn(i).setPreferredWidth(table1Size[i-1]);; + } + this.table.addMouseListener(new MouseAdapter() { + + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + selectMainRow2 = table.getSelectedRow(); + } + }); + // 添加键盘监听 + this.table.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent arg0) { + // TODO Auto-generated method stub + //delete键清空 + + if (arg0.getKeyCode() == KeyEvent.VK_DELETE) { + int[] selectRows = table.getSelectedRows(); + int[] selectColumns = table.getSelectedColumns(); + for (int i = 0; i < selectRows.length; i++) { + if (processRows != null && processRows.size() != 0 && !(processRows.contains(selectRows[i]))) { + continue; + } + for (int j = 0; j < selectColumns.length; j++) { + if(selectColumns.length==table.getColumnCount()) {//Ctrl+A全选时 + if(j>0&&j-1) { + if(selectRows= 0) + { + sb.append(values[i].replace("\n", " $")); + } + else + { + sb.append(values[i]); + } + } + //System.out.println("sb++++++++"+sb.toString()); + + if(sb.indexOf("$")>-1) { + if(selectRows widMap = new HashMap< String,Integer>(); + String[] widString = transferData1.split(""+s[i]); + if(s[i].indexOf("rowspan")>0||s[i].indexOf("colspan")>0){ + //System.out.println("===>第"+i+"行:"); + String[] ss=s[i].split("0||ss[j].indexOf("colspan")>0){ + int combineRow=1; + int combineColumn=1; + if(getIndex(ss[j],"rowspan")>0){//如果有合并的行数有值则返回合并行数,如合并了两行就返回getIndex为2 + combineRow=getIndex(ss[j],"rowspan"); + // System.out.println("第"+j+"列:"); + //System.out.println("合并行数:"+getIndex(ss[j],"rowspan")); + } + if(getIndex(ss[j],"colspan")>0){ + combineColumn=getIndex(ss[j],"colspan"); + //System.out.println("合并列数:"+getIndex(ss[j],"colspan")); + } + //combineRow需要减1.因为例如当合并时2行时,combineRow为2,但是只要选中两行,所以要combineRow-1 + //当没有合并行或列时,1-1为0,相当于就只是选中一行或者一列 + String[] split = ss[j].split(" width="); + if(split.length==2) { + String[] split2 = split[1].split(" style="); +// if(spl) + Integer integer = 0; + if(widMap.containsKey(split2[0])) { + integer = widMap.get(split2[0]); + } + + table.setRowSelectionInterval(selectRow+i-1, selectRow+i-1+combineRow-1); + table.setColumnSelectionInterval(selectColumn-1+integer, selectColumn-1+integer+combineColumn-1); + System.out.println("rowselecttion"+(selectRow+i-1)+"end"+(selectRow+i-1+combineRow-1)); + System.out.println(integer +"column select"+(selectColumn+integer-1)+"end"+(selectColumn-1+integer+combineColumn-1)); + if(combineRow > 2) { + as = true; + } + comBineCell(); + } + + } + } +// if(as) { +// index = index+1; +// } + } + } + //最后要让选中的行和列回归初始状态以便插入数据 + table.setRowSelectionInterval(selectRow, selectRow+selectRows-1); + table.setColumnSelectionInterval(selectColumn, selectColumn+selectColumns-1); + } + //+++ + // System.out.println(transferData); + } catch (UnsupportedFlavorException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + super.keyPressed(arg0); + } + }); + + //++++切换单元格超出保存字数的添加监听 + this.table.getModel().addTableModelListener(new TableModelListener() { + @Override + public void tableChanged(TableModelEvent e) { + if (e.getType() == TableModelEvent.UPDATE){ + int row = table.getSelectedRow(); + int col = table.getSelectedColumn(); + if(row>-1&&col>-1) { + // String value=(String) table.getValueAt(row, col).toString(); + String value=String.valueOf(table.getValueAt(row, col));//可以将null转化 + // System.out.println("修改后=>" + value.getBytes().length); + if(value.getBytes().length>512) { + table.setValueAt(subStringByte(value,512), row, col); + MessageBox.post("第"+(row+1)+"行,"+col+"列数据"+"填写超出字数,已将超出字段删除,请重新检查。", "错误", MessageBox.ERROR); + } + } + } + } + }); + + + + // 添加滚动条 + JScrollPane scrollPane = new JScrollPane(this.table);// this.table + scrollPane.getVerticalScrollBar().setUnitIncrement(10); + this.firstPanel.add(scrollPane, BorderLayout.CENTER); + + this.secondPanel = new JPanel(new BorderLayout()); + this.table2 = getjTable2(null, null, recordHeader, null); + for(int i=2;i<=table2Size.length+1;i++) { + this.table2.getColumnModel().getColumn(i).setPreferredWidth(table2Size[i-2]);; + } +// if (changValueList.size() == 0) { +// this.table2 = getNewjTable(null, null, recordHeader, 1, true); +// } else { +// this.table2 = getNewjTable(null, null, recordHeader, itemProperties.length, true); +// } + // 添加监听 + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + StringValue sv = new FormatStringValue(df); + TableCellRenderer r = new DefaultTableRenderer(sv); + + table2.getColumnModel().getColumn(2).setCellEditor(new DatePickerCellEditor(df)); + table2.getColumnModel().getColumn(2).setCellRenderer(r); + this.table2.addMouseListener(new MouseAdapter() { + + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + +// System.out.println("selectMainRow2"+"--------"+selectMainRow2); +// if (mouseevent.getClickCount() == 2) { +// if(table2.getSelectedColumn()==2) { +// int selectRow = table2.getSelectedRow(); +// if(selectRow!=-1) { +// Date now = new Date(); +//// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//可以方便地修改日期格式 +// SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// String time = dateFormat1.format(now); +// table2.setValueAt(time, selectRow, 2); +// table2.invalidate(); +// } +// } +// } + if (mouseevent.getClickCount() == 1) { + ((CTMap2) table2.getModel()).setRow(table2.getSelectedRow()); + if(table2.getSelectedColumn()>=2) { + ((CTMap2) table2.getModel()).setColumn(table2.getSelectedColumn()); + } +// + if (recordIsFocusOwner && recordSelectRow != -1 && recordSelectColumn != -1) { + table2.setValueAt(showRecordValuePane.getText(), recordSelectRow, recordSelectRow); + } + + if (table2.getValueAt(table2.getSelectedRow(), table2.getSelectedColumn()) != null) { + showRecordValuePane.setText(""); + showRecordValuePane.setText( + table2.getValueAt(table2.getSelectedRow(), table2.getSelectedColumn()).toString()); + } else { + showRecordValuePane.setText(""); + } + + } + recordSelectRow = table2.getSelectedRow(); + recordSelectColumn = table2.getSelectedColumn(); + recordIsFocusOwner = false; + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + if(isOwning) { + menu2.show(table2.getTableHeader(), mouseevent.getX(), mouseevent.getY()); + menu2.show(table2, mouseevent.getX(), mouseevent.getY()); + } + } + } + }); + table2.setRowHeight(40); + // 添加键盘监听 + this.table2.addKeyListener(new KeyAdapter() { + + @Override + public void keyPressed(KeyEvent arg0) { + // TODO Auto-generated method stub + //delete键清空 + if (arg0.getKeyChar() == KeyEvent.VK_DELETE) { + } + super.keyPressed(arg0); + } + }); + + +// 插入数据(之前的履历表格)+++++++++++++++++++ + this.secondPanel.add(new JScrollPane(this.table2), BorderLayout.CENTER); + + this.showValuePane = new JTextPane(); + this.showValuePane.addFocusListener(new FocusListener() { + @Override + public void focusLost(FocusEvent focusevent) { + // TODO Auto-generated method stub +// if(selectRow != -1 && selectColumn != -1) +// { +// table.setValueAt(showValuePane.getText(), selectRow, selectColumn); +// } + } + + @Override + public void focusGained(FocusEvent focusevent) { + // TODO Auto-generated method stub + isFocusOwner = true; + // this.row = table.getSelectedRow(); + // this.column = table.getSelectedColumn(); + } + }); + showValuePane.setPreferredSize(new Dimension(800, 40)); + // JScrollPane js = new JScrollPane(this.showValuePane); + // 履历显示选中单元格的值 + this.showRecordValuePane = new JTextPane(); + this.showRecordValuePane.addFocusListener(new FocusListener() { + // private int row; + // private int column; + @Override + public void focusLost(FocusEvent focusevent) { + // TODO Auto-generated method stub +// if(recordSelectRow != -1 && recordSelectColumn != -1) +// { +// table2.setValueAt(showRecordValuePane.getText(), recordSelectRow, recordSelectColumn); +// } + } + + @Override + public void focusGained(FocusEvent focusevent) { + // TODO Auto-generated method stub + recordIsFocusOwner = true; + // this.row = table2.getSelectedRow(); + // this.column = table2.getSelectedColumn(); + } + }); + showRecordValuePane.setPreferredSize(new Dimension(800, 40)); + + JSplitPane showSeleceCellValuePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT); + showSeleceCellValuePanel.setOneTouchExpandable(true);// 让分割线显示出箭头 + showSeleceCellValuePanel.setContinuousLayout(true);// 操作箭头,重绘图形 + showSeleceCellValuePanel.setTopComponent(new JScrollPane(showValuePane)); + showSeleceCellValuePanel.setBottomComponent(new JScrollPane(this.firstPanel)); + + JSplitPane showRecordSeleceCellValuePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT); + showRecordSeleceCellValuePanel.setOneTouchExpandable(true);// 让分割线显示出箭头 + showRecordSeleceCellValuePanel.setContinuousLayout(true);// 操作箭头,重绘图形 + showRecordSeleceCellValuePanel.setTopComponent(new JScrollPane(showRecordValuePane)); + showRecordSeleceCellValuePanel.setBottomComponent(new JScrollPane(this.secondPanel)); + + this.tabbedPane = new JTabbedPane(); + this.tabbedPane.add("PFMEA", showSeleceCellValuePanel); + this.tabbedPane.add("PFMEA更改履历", showRecordSeleceCellValuePanel); + + // 初始化右键菜单 + // 右键菜单 + menu = new JPopupMenu(); + addRowItem = new JMenuItem(rb.getString("tjh_display.TITLE")); + addRowsItem = new JMenuItem(rb.getString("tjdh_display.TITLE")); + addItem = new JMenuItem(rb.getString("tjhbh_display.TITLE")); + addCombineRowsItem = new JMenuItem(rb.getString("tjdghbh_display.TITLE")); + comBineItem = new JMenuItem(rb.getString("hbh_display.TITLE")); + splitItem = new JMenuItem(rb.getString("cfhbdyg_display.TITLE")); + remItem = new JMenuItem(rb.getString("yczh_display.TITLE")); + shrinkColumnItem = new JMenuItem(rb.getString("sxxzl_display.TITLE")); + celShrinkColumnItem = new JMenuItem(rb.getString("qxsxxzl_display.TITLE")); + openLibarary = new JMenuItem("打开PFMEA库"); + + //comBineItem2 = new JMenuItem(rb.getString("hbh_display.TITLE")); + // deleteSpecialItem = new JMenuItem("移除特殊符号"); + + // menu.add(deleteSpecialItem); + menu2 = new JPopupMenu(); + addItem2 = new JMenuItem("添加行"); + remItem2 = new JMenuItem("移除行"); + if(isOwning) { + menu.add(addRowItem); + menu.add(addRowsItem); + menu.add(addItem); + menu.add(addCombineRowsItem); + menu.add(remItem); + menu.add(comBineItem); + menu.add(splitItem); + menu.add(shrinkColumnItem); + menu.add(celShrinkColumnItem); + menu2.add(addItem2); + menu2.add(remItem2); + menu.add(openLibarary); + //menu2.add(comBineItem2); + } + + + this.rootPanel = new JPanel(new FlowLayout()); +// this.addButton = new JButton("添加"); +// this.remButton = new JButton("移除"); +// this.comBinebutton = new JButton("合并"); +// this.splitButton = new JButton("拆分"); + this.saveButton = new JButton(rb.getString("bc_display.TITLE")); + this.clearData = new JButton(rb.getString("qksj_display.TITLE")); + this.completeButton = new JButton(rb.getString("dcPFMEA10_display.TITLE")); + // this.addSpecialButton = new JButton("添加特殊符号"); +// this.deleteSpecialButton = new JButton("移除特殊符号"); + this.libraryButton = new JButton(rb.getString("PFMEAc10_display.TITLE")); + this.RefreshButton = new JButton(rb.getString("cxjz_display.TITLE")); + this.setHeightTxt = new JTextField(); + this.setHeightTxt.setPreferredSize(new Dimension(160, 20)); + this.setHeightBtn = new JButton("调整行高"); + this.reSetSize = new JButton("重置界面大小"); + // this.sendbutton = new JButton("导出"); + // this.sendbutton.addActionListener(this); +// this.rootPanel.add(addButton); +// this.rootPanel.add(remButton); +// this.rootPanel.add(comBinebutton); +// this.rootPanel.add(splitButton); + //++++ + if (isOwning) { + this.rootPanel.add(completeButton); + this.rootPanel.add(RefreshButton); + this.rootPanel.add(saveButton); + this.rootPanel.add(clearData); + this.rootPanel.add(completeButton); + this.rootPanel.add(libraryButton); + this.rootPanel.add(reSetSize); + this.rootPanel.add(setHeightTxt); + this.rootPanel.add(setHeightBtn); + } else { + this.rootPanel.add(reSetSize); + this.rootPanel.add(completeButton); + setPanelEnabled(mainPanel,false); + } + //++++ + setHeightBtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + String selectedText = setHeightTxt.getText(); + try { +// Double valueOf = Double.valueOf(selectedText); + Integer valueOf = Integer.valueOf(selectedText); + if(valueOf>10 || valueOf<1) { + MessageBox.post("调整行高建议在1-10倍之间","提示",2); + } + int rowCount = table.getRowCount(); + int rowHeight = 40; + System.out.println("valueOf"+valueOf+"rowHeight"+rowHeight); + rowHeight = (int) (rowHeight*valueOf); + System.out.println("new rowHeight"+rowHeight); + table.setRowHeight(rowHeight); +// mainTable.invalidate(); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); +// System.out.println("输入数字"); + } + + + } + }); + + JPanel centerPanel = new JPanel(new BorderLayout()); + centerPanel.add(titlePanel, BorderLayout.NORTH); + centerPanel.add(topPanel, BorderLayout.CENTER); + + JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); + splitPane.setOneTouchExpandable(true);// 让分割线显示出箭头 + splitPane.setContinuousLayout(true);// 操作箭头,重绘图形 + splitPane.setTopComponent(centerPanel); + splitPane.setBottomComponent(tabbedPane); + // JPanel centerPanel2 = new JPanel(new BorderLayout()); + // centerPanel2.add(centerPanel,BorderLayout.NORTH); + // centerPanel2.add(tabbedPane, BorderLayout.CENTER); + + // JSplitPane splitPane = new JSplitPane(); + // splitPane.setOneTouchExpandable(true);//让分割线显示出箭头 + // splitPane.setContinuousLayout(true);//操作箭头,重绘图形 + // splitPane.setLeftComponent(centerPanel2); + // splitPane.setRightComponent(treePanel); + + // 添加鼠标监听 + this.createActionEvent(); + this.setLayout(new BorderLayout()); + // this.add(centerPanel, BorderLayout.NORTH); + // this.add(centerPanel2, BorderLayout.CENTER); + this.add(splitPane, BorderLayout.CENTER); + // dialog.add(tablePanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + // this.add(utilPanel, BorderLayout.EAST); + this.pack(); + this.show(); + } + + //按照字节截取字符串 + public static String subStringByte(String source, int length) { + StringBuffer buffer = new StringBuffer(); + char[] chars = source.toCharArray(); + char c; + for (int i = 0;; i++) { + if (length <= 0) { + break; + } + c = source.charAt(i); + buffer.append(c); + length -= String.valueOf(c).getBytes().length; + if (i + 1 < chars.length) { + if (String.valueOf(chars[i + 1]).getBytes().length > length) { + break; + }; + } + } + return buffer.toString(); + } + + + + // 添加监听 + public void createActionEvent() { + this.addItem2.addActionListener(this); + this.remItem2.addActionListener(this); + this.openLibarary.addActionListener(this); + this.addRowItem.addActionListener(this); + this.addRowsItem.addActionListener(this); + this.addCombineRowsItem.addActionListener(this); + this.addItem.addActionListener(this); + this.remItem.addActionListener(this); + this.comBineItem.addActionListener(this); + //this.comBineItem2.addActionListener(this); + this.splitItem.addActionListener(this); + this.shrinkColumnItem.addActionListener(this); + this.celShrinkColumnItem.addActionListener(this); + this.saveButton.addActionListener(this); + this.reSetSize.addActionListener(this); + // this.addSpecialButton.addActionListener(this); + // this.deleteSpecialItem.addActionListener(this); + this.libraryButton.addActionListener(this); + this.RefreshButton.addActionListener(this); + this.clearData.addActionListener(this); + this.completeButton.addActionListener(this); + } + + //复制excel数据时检查是否有合并的行和列。"rowspan"是合并的行,"colspan"是合并的列。然后返回rowspan(colspan)=的值 + public static int getIndex(String tag1,String tag2){ + int loca=0; + if(tag1.indexOf(tag2)>0){ + int l=tag1.indexOf(tag2); + while(!tag1.substring(l,l+1).equals("=")){ + l++; + } + int start=++l; + while(!tag1.substring(l,l+1).equals(" ")){ + l++; + } + loca=Integer.valueOf(tag1.substring(start,l)); + } + return loca; + } + + + + //设置控件权限 + public void setPanelEnabled(JPanel panel, boolean enabled) { + for (int i = 0; i < panel.getComponentCount(); i++) { + if (panel.getComponent(i) instanceof JPanel) { + JPanel chidPanel = (JPanel) panel.getComponent(i); + for (int j = 0; j < chidPanel.getComponentCount(); j++) { + + chidPanel.getComponent(j).setEnabled(enabled);//一行 + if (chidPanel.getComponent(j) instanceof MultiComboBox) { + MultiComboBox multiComboBox = (MultiComboBox) chidPanel.getComponent(j); + multiComboBox.editor.enable(enabled); + if(enabled) {multiComboBox.popup.show();}else {multiComboBox.popup.hide();} + } + if (chidPanel.getComponent(j) instanceof JScrollPane) { + JScrollPane scrollPane = (JScrollPane) chidPanel.getComponent(j); + JViewport jViewport = scrollPane.getViewport(); + jViewport.getView().setEnabled(enabled); + } + } + } + panel.getComponent(i).setEnabled(enabled); + if (panel.getComponent(i) instanceof MultiComboBox) { + MultiComboBox multiComboBox = (MultiComboBox) panel.getComponent(i); + + multiComboBox.editor.enable(enabled); + if(enabled) {multiComboBox.popup.show();}else {multiComboBox.popup.hide();} + } + if (panel.getComponent(i) instanceof JScrollPane) { + JScrollPane scrollPane = (JScrollPane) panel.getComponent(i); + JViewport jViewport = scrollPane.getViewport(); + jViewport.getView().setEnabled(enabled); + } + } + } + + + /** + * 写入数据到Jtable中 + * 第一个表格 + */ + private void setJTable() { + for (int i = 0; i < dataList.size(); i++) { + List rowList = dataList.get(i); + int c = dataList.size(); + for (int j = 0; j < header.length; j++) { + if (j > 24) { + map.setValueAt(rowList.get(j + 3), i, j); + } else { + map.setValueAt(rowList.get(j), i, j); + } + } + } + } + /** + * 写入数据到Jtable中 + * 第二个表格 + */ + private void setJTable2() { + for (int i = 0; i < dataList2.size(); i++) { + List rowList = dataList2.get(i); + int c = dataList2.size(); + for (int j = 0; j < recordHeader.length; j++) { + map2.setValueAt(rowList.get(j), i, j); + } + } + } + public CTable getNewjTable(CTable partsTable, DefaultTableModel dtm, Object[] titleNames, int rows, + boolean isEditable) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + final CTMap2 map = new CTMap2(rows, titleNames.length); + map.setColumnIdentifiers(titleNames); + map.setEditable(isEditable); + partsTable = new CTable(map); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + partsTable.setRowHeight(50); + // 设置显示器渲染 + TableCellTextAreaRenderer2 renderer = new TableCellTextAreaRenderer2(); + partsTable.setDefaultRenderer(Object.class, renderer); + + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + // Jtable通用方法 +// public JTable getNewjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, int rows, +// boolean isEditable,int xxx) { +// int simpleLen = 100; +// int totleLen = 1000; +// if (partsTable == null) { +// final CTMap2 map = new CTMap2(rows, titleNames.length); +// map.setColumnIdentifiers(titleNames); +// map.setEditable(isEditable); +// partsTable = new JTable(map); +// partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); +// partsTable.setRowHeight(50); +// // 设置显示器渲染 +// TableCellTextAreaRenderer2 renderer = new TableCellTextAreaRenderer2(); +// partsTable.setDefaultRenderer(Object.class, renderer); +// +// if (simpleLen * titleNames.length >= totleLen) { +// for (int i = 0; i < titleNames.length; i++) { +// partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); +// } +// partsTable.setAutoResizeMode(0); +// } else { +// partsTable.setAutoResizeMode(1); +// } +// } +// return partsTable; +// } + + @Override + public void dispose() { + // TODO Auto-generated method stub + this.timer.cancel(); + super.dispose(); + //关闭权限修改 + closePermission(); + } + + // Jtable通用方法 + public CTable getjTable(CTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + this.map = new CTMap(dataList.size(), titleNames.length); + map.setColumnIdentifiers(titleNames); + this.map.setEditable(true); + if (processRows != null && processRows.size() > 0) { + this.map.setProcessRowList(processRows); + } +// partsTable = new CTable(map); +// partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); +// Adapter adapter = new Adapter(partsTable); + setJTable(); + partsTable = new CTable(map) ; +// { +// public boolean isCellEditable(int row,int column){ +// if(column == 0){ +// return false; +// }else{ +// return true; +// } +// } +// }; + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + Adapter1 adapter = new Adapter1(partsTable); + + if(initRowHeight==0) { + partsTable.setRowHeight(50); + }else { + partsTable.setRowHeight(initRowHeight); + } + + // 隐藏列 + partsTable.HiddenCell(0); + partsTable.HiddenCell(titleNames.length-1); + // //设置显示器渲染 + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + renderer.setProcessRows(processRows); + // //设置居中 + partsTable.setDefaultRenderer(Object.class, renderer); + + + // 添加监听 + partsTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + map.setRow(table.getSelectedRow()); + map.setColumn(table.getSelectedColumn()); + if (isFocusOwner && selectRow != -1 && selectColumn != -1) { + table.setValueAt(showValuePane.getText(), selectRow, selectColumn); + } + + if (table.getValueAt(table.getSelectedRow(), table.getSelectedColumn()) != null) { + showRecordValuePane.setText(""); + showValuePane.setText( + table.getValueAt(table.getSelectedRow(), table.getSelectedColumn()).toString()); + } else { + showValuePane.setText(""); + } + selectRow = table.getSelectedRow(); + selectColumn = table.getSelectedColumn(); + isFocusOwner = false; + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + if(isOwning) { + menu.show(table, mouseevent.getX(), mouseevent.getY()); + } + } + } + }); + // //设置编辑器渲染 + // this.textAreaCellEditor = new TextAreaCellEditor(); + // partsTable.setDefaultEditor(Object.class, + // this.textAreaCellEditor); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + if(!isOwning) { + partsTable.setEnabled(false); + } + + + //++ + MultiLineHeaderRenderer renderer = new MultiLineHeaderRenderer(); + Enumeration e = partsTable.getColumnModel().getColumns(); + while (e.hasMoreElements()) { + ( (TableColumn) e.nextElement()).setHeaderRenderer(renderer); + } + //++ + return partsTable; + } + + // Jtable通用方法 + public JTable getjTable2(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + System.out.println("-----init() map2 -------"+dataList2.toString()); + this.map2 = new CTMap2(dataList2.size(), titleNames.length); + map2.setColumnIdentifiers(titleNames); + this.map2.setEditable(true); + + partsTable = new JTable(map2); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + Adapter adapter = new Adapter(partsTable); + partsTable.setRowHeight(50); + setJTable2(); + + // 隐藏列 + HiddenCell(1,partsTable); + HiddenCell(0,partsTable); +// partsTable.HiddenCell(0); +// partsTable.HiddenCell(1); + // //设置显示器渲染 + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + if (processRows != null && processRows.size() > 0) { + List dataList2List = new ArrayList(); + for(int i2=0;i2= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + if(!isOwning) { + partsTable.setEnabled(false); + } +// partsTable.setEnabled(true); + //++ + MultiLineHeaderRenderer rendererM = new MultiLineHeaderRenderer(); + Enumeration e = partsTable.getColumnModel().getColumns(); + while (e.hasMoreElements()) { + ( (TableColumn) e.nextElement()).setHeaderRenderer(rendererM); + } +// partsTable.setRowHeight(40); + //++ + return partsTable; + + } + + private void HiddenCell(int column,JTable table) { + + TableColumn tc = table.getTableHeader().getColumnModel().getColumn(column); + tc.setMaxWidth(0); + tc.setPreferredWidth(0); + tc.setWidth(0); + tc.setMinWidth(0); + table.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); + table.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + + } + + + @Override + public void actionPerformed(ActionEvent arg0) { + Object source = arg0.getSource(); + if(source.equals(this.addItem2)) { + if (!isOwning) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + JTable table = this.table2; + if (table.getSelectedRow() > -1) { + ((CTMap2) table.getModel()).insertRow(table2.getRowCount()); + Date now = new Date(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//可以方便地修改日期格式 +// map2.setValueAt(dateFormat.format(now), table2.getRowCount()-1, 2); + SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = dateFormat1.format(now); +// map2.setValueAt(Long.valueOf(time), table2.getRowCount()-1, 1); + UUID uuid = UUID.randomUUID(); + String uid=uuid.toString().replace("-", ""); + map2.setValueAt(uid, table2.getRowCount()-1, 0); + //插入数据到数据库 + SqlUtilT.getTCConnection(); + String insert = "insert into AHMC_PFMEALIBRARY values(?,?,?,?,?,?,?,?,?,?,?,?)"; + SqlUtilT.write(new String[] {uid,UID,null,null,null,null,null,null,null,null,null,time} + ,insert); + } + + }else if (source.equals(this.openLibarary)) { + + CTable table = this.table; +// int selectMainRow2 = table.getSelectedRow(); + System.out.println(selectMainRow2+"-------"); + if(selectMainRow2!=-1) { + System.out.println("当前选中的row"+selectMainRow2); + +// if (this.libraryDialog == null) { + System.out.println(table.getSelectedRow() + "===" + table.getSelectedColumn()); + String valueAt = (String) table.getValueAt(selectMainRow2, 4); + System.out.println(valueAt+"valueAt"); + this.libraryDialog = new LibraryDialog(valueAt); +// } +// else { +// System.out.println(table.getSelectedRow() + "===" + table.getSelectedColumn()); +// this.libraryDialog.show(); +// } + } + + + } + else if(source.equals(this.remItem2)) { + if (!isOwning) { + MessageBox.post("无权限删除行!", "错误", MessageBox.ERROR); + return; + } + int i=JOptionPane.showConfirmDialog(null, "是否删除选中行?", "删除", JOptionPane.YES_NO_OPTION); + if(i!=JOptionPane.YES_OPTION){ + return; + } + JTable table = this.table2; +// if(table.getRowCount() == 1) { +// +// } + if (table.getSelectedRow() >= 0 + && table.getSelectedColumn() > 1) { + (table.getCellEditor(table.getSelectedRow(), + table.getSelectedColumn())).stopCellEditing(); + if (((CTMap2) table.getModel()).getValueAt( + table.getSelectedRow(), 0) != null) { + //根据plmid删除数据库中选中行的信息 + String delete = String + .format("delete from AHMC_PFMEALIBRARY where PLMID = \'%s\'",table.getValueAt(table.getSelectedRow(), 0).toString()); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(delete); + } + ((CTMap2) table.getModel()).removeRow(table + .getSelectedRow()); + table.revalidate(); + table.repaint(); + if(table.getRowCount()==0) { +// table.addR + ((CTMap2) table.getModel()).addRow(); + } + table.revalidate(); + table.repaint(); + //this.tabbedPane.updateUI(); + } + + }else if (source.equals(this.addRowItem)) { + if (!isOwning) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + addRow(); + } else if (source.equals(this.addRowsItem)) { + if (!isOwning) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + if (this.tabbedPane.getSelectedIndex() == 1) { + AddRowsDialog addRowsDialog = new AddRowsDialog(source); + } else { + int row = table.getSelectedRow(); + if (this.processRows != null && this.processRows.size() == 0 && !(this.processRows.contains(row))) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + AddRowsDialog addRowsDialog = new AddRowsDialog(source); + } + } else if (source.equals(this.addCombineRowsItem)) { + if (!isOwning) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + if (this.tabbedPane.getSelectedIndex() == 1) { + AddRowsDialog addRowsDialog = new AddRowsDialog(source); + } else { + int row = table.getSelectedRow(); + if (this.processRows != null && this.processRows.size() == 0 && !(this.processRows.contains(row))) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + AddRowsDialog addRowsDialog = new AddRowsDialog(source); + } + } else if (source.equals(this.addItem)) { + if (!isOwning) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + addCombineRow(); + } else if (source.equals(this.remItem)) { + if (!isOwning) { + MessageBox.post("无权限删除行!", "错误", MessageBox.ERROR); + return; + } + int i = JOptionPane.showConfirmDialog(null, "是否删除选中行?", "删除", JOptionPane.YES_NO_OPTION); + if (i != JOptionPane.YES_OPTION) { + return; + } + remRow(); + } else if (source.equals(this.comBineItem)) { + if (!isOwning) { + MessageBox.post("无权限合并行!", "错误", MessageBox.ERROR); + return; + } + comBineCell(); + } else if (source.equals(this.splitItem)) { + if (!isOwning) { + MessageBox.post("无权限操作行!", "错误", MessageBox.ERROR); + return; + } + splitCell(); + } else if (source.equals(this.saveButton)) { + if(isOwning) { + okEvent(true, true); + //this.dispose(); + }else { + MessageBox.post("无权限保存!", "错误", MessageBox.ERROR); + } + + } + else if (source.equals(this.clearData)) { + if (!isOwning) { + MessageBox.post("无权限!", "错误", MessageBox.ERROR); + return; + } + clearDatas(); + } + + else if (source.equals(shrinkColumnItem)) { + for (int i = 0; i < table.getSelectedColumns().length; i++) { + table.getColumnModel().getColumn(table.getSelectedColumns()[i]).setPreferredWidth(5); + } + table.revalidate(); + table.repaint(); + } else if (source.equals(celShrinkColumnItem)) { + for (int i = 0; i < table.getSelectedColumns().length; i++) { + table.getColumnModel().getColumn(table.getSelectedColumns()[i]).setPreferredWidth(100); + } + table.revalidate(); + table.repaint(); + } else if (source.equals(libraryButton)) { + if (!isOwning) { + MessageBox.post("无权限查看!", "错误", MessageBox.ERROR); + return; + } + + if (this.libraryDialog == null) { + System.out.println(table.getSelectedRow() + "===" + table.getSelectedColumn()); + this.libraryDialog = new LibraryDialog(); + } else { + System.out.println(table.getSelectedRow() + "===" + table.getSelectedColumn()); + this.libraryDialog.show(); + } + } else if (source.equals(completeButton)) { + isComplete = true; + if(isOwning) { + okEvent(false, true); + // this.disposeDialog(); + }else { + //MessageBox.post("无权限保存!", "错误", MessageBox.ERROR); + PFMEABean pfmeaBean = new PFMEABean(); + pfmeaBean.setCompanyName((String)this.companyNameField.getSelectedItem()); + pfmeaBean.setProject(this.projectField.getText()); + pfmeaBean.setAddress(this.addressField.getText()); + pfmeaBean.setPfmeaStartDate(this.pfmeaStartButton.getText()); + pfmeaBean.setPfmeaUpdateDate(this.pfmeaUpdateButton.getText()); + pfmeaBean.setProcessDuty(this.processDutyField.getText()); + pfmeaBean.setCustomerName(this.customerNameField.getText()); + pfmeaBean.setSecurityClassification(this.securityClassificationField.getText()); + pfmeaBean.setModelPlatform(this.modelPlatformField.getText()); + pfmeaBean.setFunctionalTeams(this.functionalTeamsField.getText()); + pfmeaBean.setProductCode(this.expiryTextField.getText()); + try { + pfmeaBean.setPfmeaNumber(itemRevision.getStringProperty("item_id")); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + getData(); + getCombineMap(); + //获取table2中数据保存 + String[][] dataValue = new String[this.table2.getRowCount()][8]; + for (int i = 0; i < this.table2.getRowCount(); i++) { + for (int j = 0; j < 8; j++) { + if(j==0) { + dataValue[i][j]=this.table2.getValueAt(i, 0).toString(); + }else { + dataValue[i][j] = this.table2.getValueAt(i, j+1) == null ? "" + : this.table2.getValueAt(i, j+1).toString(); + } + } + } + try { + String name = this.itemRevision.getStringProperty("object_name"); + new selectExportPath(pfmeaBean, this.excelDataList, dataValue,name); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + this.dispose(); + }else if (source.equals(reSetSize)) { + int i=JOptionPane.showConfirmDialog(null, "是否重置界面大小,点击“是”将在下次打开界面时生效!", "重置", JOptionPane.YES_NO_OPTION); + if(i==JOptionPane.YES_OPTION){ + SqlUtilT.getTCConnection(); + InputStream input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + String deleteSQL = String.format( + "DELETE FROM AHMC_PFMEAFRAME_SIZE WHERE USERNAME = '%s' AND TYPE = '%s'",userName,type); + SqlUtilT.delete(deleteSQL); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + isReSet=true; + SqlUtilT.freeAll(); + } + } + else if (source.equals(RefreshButton)) { + this.dispose(); + DesignPFMEACommand command = new DesignPFMEACommand(app, + session,UID); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + else { + // this.disposeDialog(); + this.dispose(); + } + } + + private void okEvent(boolean isSave, boolean isAuto) { + // TODO Auto-generated method stub + //获取屏幕尺寸和位置+++++ + String list1=String.valueOf(((int)this.getSize().getWidth()))+"/"+String.valueOf((int)this.getSize().getHeight()) + +"/"+String.valueOf(((int)this.getLocation().getX()))+"/"+String.valueOf((((int)this.getLocation().getY()))); + + String list2=""; + for(int i=1;i"+this.userName); + System.out.println("this.type====>"+this.type); + System.out.println("list1====>"+list1.toString()); + System.out.println("list2====>"+list2.toString()); + System.out.println("list3====>"+list3.toString()); + if(isFirstOpen) { + String insertSQL = "INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?,?)"; + SqlUtilT.write(new String[] { + UUID.randomUUID().toString().replace("-", ""), + this.userName,this.type,list1,list2,list3,String.valueOf(table.getRowHeight())}, insertSQL); + System.out.println("insertSQL====>"+insertSQL); + isFirstOpen=false; + }else if(!isReSet){ + String updateSQL = String.format( + "update AHMC_PFMEAFRAME_SIZE set FRAMESIZE = ?, TABLE1SIZE = ?, TABLE2SIZE = ?,ROWHEIGHT = ? WHERE USERNAME ='%s' AND TYPE = '%s'",userName,type); + SqlUtilT.update( + new String[] {list1,list2,list3,String.valueOf(table.getRowHeight())},updateSQL); + } + SqlUtilT.freeAll(); + ///++++++ + + + + + // 将数据保存到表单中 + try { +// if(table.getRowCount()!=0) { +// if(table.getValueAt(0,0)=="") { +// MessageBox.post("操作失误,请勿清除全部内容保存","错误",MessageBox.ERROR); +// return; +// }} + if (table.getSelectedRow() >= 0 && table.getSelectedColumn() >= 0) { + (table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn())).stopCellEditing(); + } + if (table2.getSelectedRow() >= 0 && table2.getSelectedColumn() >= 0) { + (table2.getCellEditor(table2.getSelectedRow(), table2.getSelectedColumn())).stopCellEditing(); + } + PFMEABean pfmeaBean = new PFMEABean(); + pfmeaBean.setCompanyName((String)this.companyNameField.getSelectedItem()); + pfmeaBean.setProject(this.projectField.getText()); + pfmeaBean.setAddress(this.addressField.getText()); + pfmeaBean.setPfmeaStartDate(this.pfmeaStartButton.getText()); + pfmeaBean.setPfmeaUpdateDate(this.pfmeaUpdateButton.getText()); + pfmeaBean.setProcessDuty(this.processDutyField.getText()); + pfmeaBean.setCustomerName(this.customerNameField.getText()); + pfmeaBean.setSecurityClassification(this.securityClassificationField.getText()); + pfmeaBean.setModelPlatform(this.modelPlatformField.getText()); + pfmeaBean.setFunctionalTeams(this.functionalTeamsField.getText()); + pfmeaBean.setPfmeaNumber(itemRevision.getStringProperty("item_id")); + pfmeaBean.setProductCode(this.expiryTextField.getText()); + + // 获取JTable中的数据 + List> dataValeList = getTableValue(); + System.out.println(dataValeList.toString()); + DesignPFMEAOperation operation = new DesignPFMEAOperation(this.itemRevision, this.meprocess, + this.session, properties, this.itemProperties, pfmeaBean, dataValeList, plmeidList, + deleteRows, isOwning,comp,UID); + operation.executeOperation(); + for (int j = 0; j < processRows.size(); j++) { + plmeidList.add(table.getValueAt(processRows.get(j), 0).toString()); + } + //获取table2中数据保存 + String[][] dataValue = new String[this.table2.getRowCount()][8]; + for (int i = 0; i < this.table2.getRowCount(); i++) { + for (int j = 0; j < 8; j++) { + if(j==0) { + dataValue[i][j]=this.table2.getValueAt(i, 0).toString(); + } + else if (j==1) { + Object valueO = this.table2.getValueAt(i, j+1); + if(valueO instanceof String) { + dataValue[i][j] = (String) valueO; + }else if (valueO instanceof Date) { +// System.out.println(valueO + "String"+ (String) this.table2.getValueAt(i, j+2)); + SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd"); + String time = dateFormat1.format((Date)valueO); + dataValue[i][j] = time; + System.out.println(time); + } + } + else { + System.out.println(this.table2.getValueAt(i, j+1)); + dataValue[i][j] = this.table2.getValueAt(i, j+1) == null ? "" + : this.table2.getValueAt(i, j+1).toString(); + } + } + } +// System.out.println("dataValue ==========>"+dataValue); + for(int i=0;i rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("GYBH")); + rowList.add(rs.getString("GCMC")); + rowList.add(rs.getString("STATION")); + rowList.add(rs.getString("REQUIREMENT")); + rowList.add(rs.getString("QZSXMS")); + rowList.add(rs.getString("QZSXHG")); + rowList.add(rs.getString("YZD")); + rowList.add(rs.getString("JB")); + rowList.add(rs.getString("QZSXQY")); + rowList.add(rs.getString("XXGCKZYF")); + rowList.add(rs.getString("PDS")); + rowList.add(rs.getString("XXGCKZTC")); + rowList.add(rs.getString("TCD")); + rowList.add(rs.getString("RPN")); + rowList.add(rs.getString("JYCS")); + rowList.add(rs.getString("ZZR")); + rowList.add(rs.getString("JHWCRQ")); + rowList.add(rs.getString("CQDCS")); + rowList.add(rs.getString("NEW_SEV")); + rowList.add(rs.getString("NEW_OCC")); + rowList.add(rs.getString("NEW_DET")); + rowList.add(rs.getString("NEW_RPN")); + rowList.add(rs.getString("IDEAL_STATE")); + rowList.add(rs.getString("SPECIAL")); + rowList.add(rs.getInt("HH")); + rowList.add(rs.getString("HBDYG")); + rowList.add(rs.getInt("HHC")); + + rowList.add(rs.getString("OCCURRRENCE")); + rowList.add(rs.getString("DETECTION")); + rowList.add(rs.getString("PRIORITY"));//PRIORITY + rowList.add(rs.getString("P1")); + rowList.add(rs.getString("P2")); + rowList.add(rs.getString("P3")); + rowList.add(rs.getString("P4")); + rowList.add(rs.getString("P5")); + rowList.add(rs.getString("NO")); + excelDataList.add(rowList); + } +// for (int i = 0; i < excelDataList.size(); i++) { +// // 行号差 +// excelDataList.get(i).set(27, i - Integer.parseInt(excelDataList.get(i).get(25).toString())); +// } + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + /** + * 获取合并单元格 + */ + public void getCombineMap() { + try { + if (excelDataList != null && excelDataList.size() > 0) { + for (int i = 0; i < excelDataList.size(); i++) { + if (excelDataList.get(i).get(26) != null && !excelDataList.get(i).get(26).equals("")) { + String sombine = excelDataList.get(i).get(26).toString(); + int rowDif = Integer.parseInt(excelDataList.get(i).get(27).toString()); + String[] sombines; + if (sombine.indexOf("-") >= 0) { + sombines = sombine.split("-"); + } else { + sombines = new String[] { sombine }; + } + for (int j = 0; j < sombines.length; j++) { + if (sombines[j].indexOf("/") >= 0) { + int[] row; + int[] cloumn; + String[] cells = sombines[j].split("/"); + if (cells[0].indexOf(",") >= 0) { + String[] rows = cells[0].split(","); + row = new int[rows.length]; + for (int k = 0; k < rows.length; k++) { + row[k] = Integer.parseInt(rows[k]) + rowDif; + } + } else { + row = new int[] { Integer.parseInt(cells[0]) + rowDif }; + } + if (cells[1].indexOf(",") >= 0) { + String[] cloumns = cells[1].split(","); + cloumn = new int[cloumns.length]; + for (int k = 0; k < cloumns.length; k++) { + cloumn[k] = Integer.parseInt(cloumns[k]); + } + } else { + cloumn = new int[] { Integer.parseInt(cells[1]) }; + } + this.excelCombineMap.put(row, cloumn); + } + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 输出PFMEA + * + * @param pfmeaBean + * @param dataValeList + */ + private void outPutExcel(PFMEABean pfmeaBean, List> dataValeList, String[][] dataValue,String name) { + // TODO Auto-generated method stub + InputStream input = null; + try { + File pfmeaFile = TMomMethodUtil.getFile(session, "PFMEA", "MSExcel"); + if (pfmeaFile != null) { + input = new FileInputStream(pfmeaFile); + } else { + MessageBox.post("未找到PFMEA模板!", "错误", MessageBox.ERROR); + return; + } + String outFilePath = System.getenv("TEMP") + "\\" + "PFMEA.xlsx"; + FileOutputStream output = new FileOutputStream(new File(outFilePath)); // +// HSSFWorkbook wb = new HSSFWorkbook(input);// ( +// outPutSheet1(wb, dataValue); +// HSSFSheet sheet = wb.getSheetAt(1); + XSSFWorkbook wb = new XSSFWorkbook(input); + XSSFSheet sheet = wb.getSheetAt(1); + XSSFSheet sheet2 = wb.getSheetAt(2); + + + //第一页导出++++ + int startRow = 10; + XSSFRow row4 = sheet.getRow(3); + if(row4==null) { + row4=sheet.createRow(3); + } + setCellValue(row4,4,pfmeaBean.getCompanyName()); + //setCellValue(row,,pfmeaBean); + setCellValue(row4,8,pfmeaBean.getProject()); + setCellValue(row4,15,pfmeaBean.getSecurityClassification()); +// 15 2 + XSSFRow row1 = sheet.getRow(1); + setCellValue(row1,15,pfmeaBean.getPfmeaNumber()); + XSSFRow row5 = sheet.getRow(4); + if(row5==null) { + row5=sheet.createRow(4); + } + setCellValue(row5,4,pfmeaBean.getAddress()); + setCellValue(row5,8,pfmeaBean.getProductCode()); //零件版本好 + setCellValue(row5,15,pfmeaBean.getPfmeaStartDate()); + XSSFRow row6 = sheet.getRow(5); + if(row6==null) { + row6=sheet.createRow(5); + } + setCellValue(row6,4,pfmeaBean.getCustomerName()); + setCellValue(row6,8,pfmeaBean.getProcessDuty()); //processDutyField + setCellValue(row6,15,pfmeaBean.getPfmeaUpdateDate()); //关键日期 + XSSFRow row7 = sheet.getRow(6); + if(row7==null) { + row5=sheet.createRow(6); + } + setCellValue(row7,4,pfmeaBean.getModelPlatform()); + setCellValue(row7,8,pfmeaBean.getFunctionalTeams()); + + for (int i = 0; i < dataValeList.size(); i++) { + XSSFRow row = null; + Boolean isCreat = false; + row = sheet.getRow(i + startRow); + if(row==null) { + row = sheet.createRow(i+ startRow); + isCreat = true; + } +// if(i<17) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// }else{ +// row = sheet.createRow(i+ startRow); +// isCreat = true; +// } + if (isCreat) { + XSSFRow oldRow = sheet.getRow(i + startRow - 1); + + if(oldRow==null) { + oldRow = sheet.createRow(i + startRow - 1); + } + for (int j = 0; j < 32; j++) { + XSSFCell oldCell = oldRow.getCell(j); + if(oldCell==null) { + oldCell=oldRow.createCell(j); + } + XSSFCell newCell = row.createCell(j); + newCell.setCellStyle(oldCell.getCellStyle()); + newCell.setCellType(oldCell.getCellType()); + } + } + //循环添加列 + for(int j=1;j<33;j++) { + XSSFCell cell = row.getCell(j-1); + if(cell==null) { + cell=row.createCell(j-1); + } + + if(j<25) { + cell.setCellValue((String)dataValeList.get(i).get(j)); + }else { + cell.setCellValue((String)dataValeList.get(i).get(j+3)); + } + } + } + //+++++++++++++ + + //第二页导出++++++ + int startRow2 = 3; +// XSSFRow row21 = sheet2.getRow(2); +// if(row21==null) { +// row21=sheet2.createRow(2); +// } +// setCellValue(row21,0,"项目:"+pfmeaBean.getProject()); +// setCellValue(row21,3,"设计职责:"+pfmeaBean.getProcessDuty()); +// setCellValue(row21,7,"FMEA编号:"+pfmeaBean.getPfmeaNumber()); + XSSFRow row22 = sheet2.getRow(3); + if(row22==null) { + row22=sheet2.createRow(3); + } +// setCellValue(row22,0,"FMEA日期(原始):"+pfmeaBean.getPfmeaStartDate()); + + for (int i = 0; i < dataValue.length; i++) { + XSSFRow row = null; + Boolean isCreat = false; + + row = sheet2.getRow(i + startRow2); + if(row ==null) { + row = sheet2.createRow(i+ startRow2); + isCreat = true; + }else { + isCreat = false; + } + +// if(i<15) { +// row = sheet2.getRow(i + startRow2); +// isCreat = false; +// }else{ +// row = sheet2.createRow(i+ startRow2); +// isCreat = true; +// } + if (isCreat) { + XSSFRow oldRow = sheet2.getRow(i + startRow2 - 1); + if(oldRow==null) { + oldRow = sheet2.createRow(i + startRow2 - 1); + } + for (int j = 0; j < 9; j++) { + XSSFCell oldCell = oldRow.getCell(j); + XSSFCell newCell = row.createCell(j); + if(oldCell==null) { + oldCell=oldRow.createCell(j); + } + newCell.setCellStyle(oldCell.getCellStyle()); + newCell.setCellType(oldCell.getCellType()); + } + combine(sheet2, new int[] { i + startRow2 }, new int[] { 3, 5 }); + } + //循环添加列 +// XSSFCell cell0 = row.getCell(0); + setCellValue(row,0,String.valueOf(i+1)); //关键日期 + setCellValue(row,1,dataValue[i][1]); + setCellValue(row,2,itemRevision.getStringProperty("item_revision_id")); + setCellValue(row,3,dataValue[i][3]); + setCellValue(row,4,dataValue[i][4]); + setCellValue(row,5,dataValue[i][5]); + setCellValue(row,6,dataValue[i][6]); +// for(int j=1;j<8;j++) { +// +// if(j<5) { +// XSSFCell cell = row.getCell(j-1); +// +// if(cell==null) { +// cell=row.createCell(j-1); +// } +// cell.setCellValue(dataValue[i][j]); +// }else { +// XSSFCell cell = row.getCell(j+1); +// if(cell==null) { +// cell=row.createCell(j+1); +// } +// cell.setCellValue(dataValue[i][j]); +// } +// } + } + +// } + // 合并单元格 + if (excelCombineMap != null && excelCombineMap.size() > 0) { + Iterator> it = excelCombineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + int[] row = new int[entry.getKey().length]; + int[] column = new int[entry.getValue().length]; + for (int k = 0; k < entry.getKey().length; k++) { + //row[k] = entry.getKey()[k] + 17; + row[k] = entry.getKey()[k]+10 ; + } + for (int k = 0; k < entry.getValue().length; k++) { + if (entry.getValue()[k] == 1) { + //column[k] = entry.getValue()[k] + 1; + column[k] = entry.getValue()[k] -1; + } else { + //column[k] = entry.getValue()[k] + column[k] = entry.getValue()[k]-1; + } + } + ExcelUtil.combine_XSSF(sheet, row, column); + } + } + + + //2022/10/22插入图片 + System.out.println("开始插入图片。。。"); + String pref = "hs_sign_info"; + String[] stringValues = session.getPreferenceService().getStringValues(pref); + if(stringValues!=null) { + Map uidMap = new HashMap(); + List keyList = new ArrayList(); + Map numMap = new HashMap(); + for(String s:stringValues) { + String[] split = s.split("=",-1); + if(split.length==3) { + keyList.add(split[0]); + uidMap.put(split[0], split[1]); + numMap.put(split[0], Integer.valueOf(split[2])); + }else { + MessageBox.post("首选项"+pref+"配置有误!","",MessageBox.INFORMATION); + return; + } + } + int [] columns = {6,7,17,29}; + utils.reSetRowHeight(wb,sheet,10,sheet.getLastRowNum(),columns); + for(int i = 0;i sheet.getLastRowNum()) { + row = sheet.createRow(i + 1); + isCreat = true; + } else { + row = sheet.getRow(i + 1); + isCreat = false; + } + for (int j = 0; j < dataValue.length; j++) { + HSSFCell cell = null; + if (isCreat) { + cell = row.createCell(j); + } else { + cell = row.getCell(j); + } + + if (cell == null) { + cell = row.createCell(j); + } + cell.setCellType(CellType.STRING);// 文本格式 + cell.setCellValue(dataValue[j][i]); + } + } + + } + + private List> getTableValue() { + // TODO Auto-generated method stub + List> dataValeList = new ArrayList>(); + + for (int j = 0; j < processRows.size(); j++) { + List rowValue = new ArrayList(); + int a = this.map.getColumnCount(); + for (int j2 = 0; j2 < this.map.getColumnCount()-1; j2++) { +// if (j2 == 1) { +// //table.getValueAt(j, j2) != null && isStr2Num(table.getValueAt(j, j2).toString()) +// if (table.getValueAt(j, j2) != null ) { +// rowValue.add(table.getValueAt(j, j2).toString()); +// } else { +// rowValue.add(""); +// } +// } +// +// else { + if (j2 < 25) { + rowValue.add(table.getValueAt(j, j2) == null ? "" : table.getValueAt(j, j2).toString()); + } +// } +// // rowValue.add(getCellValue(processRows.get(j), j2)); + } + rowValue.add(processRows.get(j).toString());//25行号 + // rowValue.add("1"); + if (combineMap.size() > 0) { + rowValue.add(TMomMethodUtil.getCombineCell(combineMap, processRows.get(j)));//26合并单元格 + } else { + rowValue.add(""); + } +// if (rowValue.size() == 26) { +// rowValue.add(""); +// } +// if (isComplete) { +// rowValue.add("1"); +// } else { + rowValue.add("");//27行号差 +// } + rowValue.add("");//28 + rowValue.add("");//29 + + for (int j2 = 25; j2 < this.map.getColumnCount()-1; j2++) { + rowValue.add(table.getValueAt(j, j2) == null ? "" : table.getValueAt(j, j2).toString()); + } + rowValue.add(getCellValue(processRows.get(j),this.map.getColumnCount()-1 )); + dataValeList.add(rowValue); + } + // for (int i = 0; i < processRowList.size(); i++) { + // List rows = processRowList.get(i); + // } + return dataValeList; + } + + private String getCellValue(int row, int cloumn) { + // TODO Auto-generated method stub + String resultValue = ""; + if (this.map.getValueAt(row, cloumn) != null) { + resultValue = this.map.getValueAt(row, cloumn).toString(); + } + if (combineMap != null && combineMap.size() > 0) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + List valuesList = new ArrayList<>(); + for (int k = 0; k < entry.getKey().length; k++) { + keysList.add(entry.getKey()[k]); + } + for (int k = 0; k < entry.getValue().length; k++) { + valuesList.add(entry.getValue()[k]); + } + if (keysList.contains(row) && valuesList.contains(cloumn)) { + return (String) this.map.getValueAt(Integer.parseInt(keysList.get(0).toString()), + Integer.parseInt(valuesList.get(0).toString())); + } + } + } else { + if (this.map.getValueAt(row, cloumn) != null) { + return this.map.getValueAt(row, cloumn).toString(); + } + + } + return resultValue; + } + + //修改描述信息,关闭权限 + private void closePermission() { + if(isOwning) { + //关闭权限修改 + if(((TCComponent) comp).isCheckedOut()) { + ReservationService service=ReservationService.getService((TCSession)app.getSession()); + service.checkin(new TCComponent[] {(TCComponent) this.comp});//签入 + } + } + } + + private String[] setCombineMap() { + String[] combines = new String[combineMap.size()]; + Iterator> it = combineMap.entrySet().iterator(); + int index = 0; + while (it.hasNext()) { + Map.Entry entry = it.next(); + StringBuffer rowSb = new StringBuffer(); + StringBuffer columnSb = new StringBuffer(); + for (int i = 0; i < entry.getKey().length; i++) { + rowSb.append(entry.getKey()[i]); + rowSb.append(","); + } + for (int i = 0; i < entry.getValue().length; i++) { + columnSb.append(entry.getValue()[i]); + columnSb.append(","); + } + combines[index] = rowSb.substring(0, rowSb.length() - 1) + "/" + + columnSb.substring(0, columnSb.length() - 1); + index++; + } + return combines; + } + + private int[] Union(int[] a1, int[] a2) { + List list1 = new ArrayList(); + List list2 = new ArrayList(); + for (int i : a1) { + list1.add(i); + } + for (int i : a2) { + list2.add(i); + } + list1.removeAll(list2); + list2.addAll(list1); + int[] result = new int[list2.size()]; + for (int i = 0; i < list2.size(); i++) { + result[i] = list2.get(i); + } + return result; + } + + /** + * 添加行 + */ + private void addRow() { + // TODO Auto-generated method stub + if (this.tabbedPane.getSelectedIndex() == 1) { + CTMap2 map = ((CTMap2) this.table2.getModel()); + map.insertRow(this.table2.getSelectedRow() + 1); + } else { + int row = table.getSelectedRow(); + if (this.processRows != null && this.processRows.size() == 0 && !(this.processRows.contains(row))) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + Map cellMap = new HashMap(); + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + if (keysList.contains(row)) { + int[] newKey = new int[entry.getKey().length]; + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + newKey[i] = entry.getKey()[i]; + } + it.remove(); + // newKey[entry.getKey().length] = newKey[entry.getKey().length - 1] + 1; + cellMap.put(newKey, entry.getValue()); + } else if (!keysList.contains(row) && Integer.parseInt(keysList.get(0).toString()) > row) { + int[] newKey = new int[entry.getKey().length]; + for (int i = 0; i < entry.getKey().length; i++) { + newKey[i] = entry.getKey()[i] + 1; + } + it.remove(); + cellMap.put(newKey, entry.getValue()); + } + } + map.insertRow(table.getSelectedRow() + 1); + table.setValueAt(UUID.randomUUID().toString().replace("-", ""), table.getSelectedRow() + 1, 0); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 4), table.getSelectedRow() + 1, 4); + table.setValueAt(table.getValueAt(table.getSelectedRow(), table.getColumnCount() - 1), table.getSelectedRow() + 1, table.getColumnCount() - 1); + //this.processRows = map.getProcessRowList(); + Iterator> cellIt = cellMap.entrySet().iterator(); + while (cellIt.hasNext()) { + Map.Entry entry = cellIt.next(); + map.combine(entry.getKey(), entry.getValue()); + combineMap.put(entry.getKey(), entry.getValue()); + } + table.revalidate(); + table.repaint(); + } + } + + /** + * 添加合并行 + */ + private void addCombineRow() { + // TODO Auto-generated method stub + if (this.tabbedPane.getSelectedIndex() == 1) { + CTMap2 map = ((CTMap2) this.table2.getModel()); + map.insertRow(this.table2.getSelectedRow() + 1); + } else { + int row = table.getSelectedRow(); + if (this.processRows != null && this.processRows.size() == 0 && !(this.processRows.contains(row))) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + Map cellMap = new HashMap(); + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + if (keysList.contains(row)) { + int[] newKey = new int[entry.getKey().length + 1]; + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + newKey[i] = entry.getKey()[i]; + } + it.remove(); + newKey[entry.getKey().length] = newKey[entry.getKey().length - 1] + 1; + cellMap.put(newKey, entry.getValue()); + } else if (!keysList.contains(row) && Integer.parseInt(keysList.get(0).toString()) > row) { + int[] newKey = new int[entry.getKey().length]; + for (int i = 0; i < entry.getKey().length; i++) { + newKey[i] = entry.getKey()[i] + 1; + } + it.remove(); + cellMap.put(newKey, entry.getValue()); + } + } + map.insertRow(table.getSelectedRow() + 1); + table.setValueAt(UUID.randomUUID().toString().replace("-", ""), table.getSelectedRow() + 1, 0); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 4), table.getSelectedRow() + 1, 4); + table.setValueAt(table.getValueAt(table.getSelectedRow(), table.getColumnCount() - 1), table.getSelectedRow() + 1, table.getColumnCount() - 1); + // this.processRows = map.getProcessRowList(); + Iterator> cellIt = cellMap.entrySet().iterator(); + while (cellIt.hasNext()) { + Map.Entry entry = cellIt.next(); + map.combine(entry.getKey(), entry.getValue()); + combineMap.put(entry.getKey(), entry.getValue()); + } + table.revalidate(); + table.repaint(); + } + } + + /** + * 移除行 + */ + private void remRow() { + // TODO Auto-generated method stub + if (this.tabbedPane.getSelectedIndex() == 1) { + if (table2.getSelectedRow() > 0 && table2.getSelectedColumn() > 0) { + (table2.getCellEditor(table2.getSelectedRow(), table2.getSelectedColumn())).stopCellEditing(); + } + int[] rows = table2.getSelectedRows(); + CTMap map = ((CTMap) this.table2.getModel()); + for (int i = 0; i < rows.length; i++) { + map.removeRow(table2.getSelectedRow()); + } + } else { + if (table.getSelectedRow() > 0 && table.getSelectedColumn() > 0) { + (table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn())).stopCellEditing(); + } + int[] rows = table.getSelectedRows(); + for (int i1 = 0; i1 < rows.length; i1++) { + if (this.processRows != null && this.processRows.size() > 0 + && !(this.processRows.contains(table.getSelectedRow()))) { + MessageBox.post("无权限删除行!", "错误", MessageBox.ERROR); + return; + } + Map cellMap = new HashMap(); + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + if (keysList.contains(table.getSelectedRow())) { + int[] newKey = new int[entry.getKey().length - 1]; + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + if (i < newKey.length) { + newKey[i] = entry.getKey()[i]; + } + } + it.remove(); + cellMap.put(newKey, entry.getValue()); + } else if (!keysList.contains(table.getSelectedRow()) + && Integer.parseInt(keysList.get(0).toString()) > table.getSelectedRow()) { + int[] newKey = new int[entry.getKey().length]; + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + newKey[i] = entry.getKey()[i] - 1; + } + it.remove(); + cellMap.put(newKey, entry.getValue()); + } + } + if (map.getValueAt(table.getSelectedRow(), 0) != null + && plmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + deleteRows.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + map.removeRow(table.getSelectedRow()); + // this.processRows = map.getProcessRowList(); + Iterator> cellIt = cellMap.entrySet().iterator(); + while (cellIt.hasNext()) { + Map.Entry entry = cellIt.next(); + if (entry.getKey().length > 0 && entry.getValue().length > 0) { + map.combine(entry.getKey(), entry.getValue()); + combineMap.put(entry.getKey(), entry.getValue()); + } + } + table.revalidate(); + table.repaint(); + } + } + } + +// /** +// * 合并单元格 +// */ +// private void comBineCell2() { +// // TODO Auto-generated method stub +// // table.setRowHeight(2, 50); +// int[] rows = table2.getSelectedRows(); +// int[] columns = table2.getSelectedColumns(); +// if (rows.length <= 0) { +// MessageBox.post("请选择要合并的单元格!", "错误", MessageBox.ERROR); +// return; +// } +//// for (int i = 0; i < rows.length; i++) { +//// if (this.processRows != null && this.processRows.size() > 0 && !(this.processRows.contains(rows[i]))) { +//// MessageBox.post("无权限合并单元格", "错误", MessageBox.ERROR); +//// return; +//// } +//// } +// if (combineMap2 != null && combineMap2.size() != 0) { +// for (int i = 0; i < rows.length; i++) { +// Iterator> it = combineMap2.entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// List keysList = new ArrayList<>(); +// for (int j = 0; j < entry.getKey().length; j++) { +// keysList.add(entry.getKey()[j]); +// } +// if (keysList.contains(rows[i])) { +// for (int j = 0; j < columns.length; j++) { +// List valueList = new ArrayList<>(); +// for (int k = 0; k < entry.getValue().length; k++) { +// valueList.add(entry.getValue()[k]); +// } +// if (valueList.contains(columns[j])) { +// columns = Union(columns, entry.getValue()); +// rows = Union(rows, entry.getKey()); +// if (combineMap2.get(entry.getKey()) != null) { +// it.remove(); +// } +// } +// } +// } +// } +// } +// combineMap2.put(rows, columns); +// } else { +// combineMap2.put(rows, columns); +// } +// for (int i = 0; i < rows.length; i++) { +// for (int j = 0; j < columns.length; j++) { +// map2.split(rows[i], columns[j]); +// } +// } +// Arrays.sort(rows); +// Arrays.sort(columns); +// map2.combine(rows, columns); +// // map.removeRow(table.getSelectedRow()); +// table2.revalidate(); +// table2.repaint(); +// } + + /** + * 合并单元格 + */ + private void comBineCell() { + // TODO Auto-generated method stub + // table.setRowHeight(2, 50); + int[] rows = table.getSelectedRows(); + int[] columns = table.getSelectedColumns(); +// if(rows.length<=1&&columns.length<=1) { +// return; +// } + if (rows.length <= 0) { + MessageBox.post("请选择要合并的单元格!", "错误", MessageBox.ERROR); + return; + } + for (int i = 0; i < rows.length; i++) { + if (this.processRows != null && this.processRows.size() > 0 && !(this.processRows.contains(rows[i]))) { + MessageBox.post("无权限合并单元格", "错误", MessageBox.ERROR); + return; + } + } + if (combineMap != null && combineMap.size() != 0) { + for (int i = 0; i < rows.length; i++) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + if (keysList.contains(rows[i])) { + for (int j = 0; j < columns.length; j++) { + List valueList = new ArrayList<>(); + for (int k = 0; k < entry.getValue().length; k++) { + valueList.add(entry.getValue()[k]); + } + if (valueList.contains(columns[j])) { + columns = Union(columns, entry.getValue()); + rows = Union(rows, entry.getKey()); + if (combineMap.get(entry.getKey()) != null) { + it.remove(); + } + } + } + } + } + } +// combineMap + combineMap.put(rows, columns); + } else { + combineMap.put(rows, columns); + } + for (int i = 0; i < rows.length; i++) { + for (int j = 0; j < columns.length; j++) { + map.split(rows[i], columns[j]); + } + } + Arrays.sort(rows); + Arrays.sort(columns); + System.out.println("rows"+rows.length+"columns"+columns.length); + map.combine(rows, columns); + // map.removeRow(table.getSelectedRow()); + table.invalidate(); + table.revalidate(); + table.repaint(); + } + + /** + * 拆分单元格 + */ + private void splitCell() { + // TODO Auto-generated method stub + int row = table.getSelectedRow(); + int colmn = table.getSelectedColumn(); + if (row < 0) { + MessageBox.post("请选择要拆分的单元格!", "错误", MessageBox.ERROR); + return; + } +// if (this.processRows != null && this.processRows.size() > 0 +// && !(this.processRows.contains(row))) { +// MessageBox.post("无权限拆分单元格!", "错误", MessageBox.ERROR); +// return; +// } + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + List valuesList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + for (int j = 0; j < entry.getValue().length; j++) { + valuesList.add(entry.getValue()[j]); + } + if (keysList.contains(row) && valuesList.contains(colmn)) { + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + } + it.remove(); + } + } + + table.revalidate(); + table.repaint(); + } + + /** + * 查看一个字符串是否可以转换为数字 + * + * @param str 字符串 + * @return true 可以; false 不可以 + */ + public boolean isStr2Num(String str) { + try { + Integer.parseInt(str); + return true; + } catch (NumberFormatException e) { + return false; + } + } + + /** + * 定时保存 + */ + public void runTask() { + timer = new Timer(); + timer.schedule(new TimerTask() { + + @Override + public void run() { + // TODO Auto-generated method stub + System.out.println("....."); +// if(isOwning) { +// okEvent(true, false); +// } + } + }, 300 * 1000, 300 * 1000); + +// final long timeInterval = 120000;// 两分钟运行一次 +// Runnable runnable = new Runnable() { +// public void run() { +// while (true) { +// // ------- code for task to run +// okEvent(true); +// // ------- ends here +// //System.out.println(123); +// try { +// Thread.sleep(timeInterval); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// } +// } +// }; +// Thread thread = new Thread(runnable); +// thread.start(); + } + + private class selectExportPath extends AbstractAIFDialog implements ActionListener { + // 界面控件 + private JPanel mainPanel; + private JFileChooser jfc; + private JButton okButton; + private JButton celButton; + private JButton fileButton; + private JTextField pathText; + private JTextField fleName; + private PFMEABean pfmeaBean; + private List> dataValeList; + private String[][] dataValue; + private String name; + public selectExportPath(PFMEABean pfmeaBean, List> dataValeList, String[][] dataValue,String name) { + this.pfmeaBean=pfmeaBean; + this.dataValeList=dataValeList; + this.dataValue=dataValue; + this.name = name; + init(); + } + + private void init() { + //获取国际化语言 + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + // TODO Auto-generated method stub + this.setTitle(rb.getString("xzdclj31_display.TITLE")); + this.setPreferredSize(new Dimension(480, 200)); + jfc = new JFileChooser(); + jfc.setCurrentDirectory(new File("c:\\"));// 文件选择器的初始目录定为d盘 + this.okButton = new JButton(rb.getString("dc_display.TITLE")); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.fileButton = new JButton("..."); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.fileButton.addActionListener(this); + this.fileButton.setPreferredSize(new Dimension(50, 30)); + this.pathText = new JTextField(); + pathText.setText("C:"); + this.pathText.setPreferredSize(new Dimension(300, 30)); + fleName = new JTextField(); + fleName.setText("PFMEA"); + this.fleName.setPreferredSize(new Dimension(300, 30)); + + JLabel label = new JLabel(rb.getString("wjmc31_display.TITLE")); + label.setPreferredSize(new Dimension(100, 30)); + JLabel label2 = new JLabel(rb.getString("xzwjj_display.TITLE")); + label2.setPreferredSize(new Dimension(100, 30)); + + JPanel panel1 = new JPanel(new FlowLayout()); + panel1.add(label); + panel1.add(fleName); + JPanel panel2 = new JPanel(new FlowLayout()); + panel2.add(label2); + panel2.add(pathText); + panel2.add(fileButton); + + this.mainPanel = new JPanel(new PropertyLayout()); + + this.mainPanel.add("1.1.left.top", panel1); + this.mainPanel.add("2.1.left.top", panel2); + + JPanel rootPanel = new JPanel(new FlowLayout()); + rootPanel.add(new JLabel(" ")); + rootPanel.add(new JLabel(" ")); + rootPanel.add(this.okButton); + rootPanel.add(new JLabel(" ")); + rootPanel.add(this.celButton); + + + this.setLayout(new BorderLayout()); + this.add(mainPanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + // this.centerToScreen(); + this.showDialog(); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.fileButton)) { + selectFileButtonEvent(e); + } else if (source.equals(this.okButton)) { + // 获取导出模板 + String outFilePath = this.pathText.getText() + "\\"+this.name.replace("/", "-")+".xlsx"; +//+++++++ + + InputStream input = null; + try { + File pfmeaFile = TMomMethodUtil.getFile(session, "PFMEA", "MSExcel"); + if (pfmeaFile != null) { + input = new FileInputStream(pfmeaFile); + } else { + MessageBox.post("未找到PFMEA模板!", "错误", MessageBox.ERROR); + return; + } + FileOutputStream output = new FileOutputStream(new File(outFilePath)); + XSSFWorkbook wb = new XSSFWorkbook(input); + XSSFSheet sheet = wb.getSheetAt(1); + XSSFSheet sheet2 = wb.getSheetAt(2); + //第一页导出++++ + int startRow = 10; + XSSFRow row4 = sheet.getRow(3); + setCellValue(row4,4,pfmeaBean.getCompanyName()); + //setCellValue(row,,pfmeaBean); + setCellValue(row4,7,pfmeaBean.getProject()); + setCellValue(row4,9,pfmeaBean.getPfmeaNumber()); + XSSFRow row5 = sheet.getRow(4); + setCellValue(row5,4,pfmeaBean.getAddress()); + setCellValue(row5,7,pfmeaBean.getPfmeaStartDate()); + setCellValue(row5,9,pfmeaBean.getProcessDuty()); + XSSFRow row6 = sheet.getRow(5); + setCellValue(row6,4,pfmeaBean.getCustomerName()); + setCellValue(row6,7,pfmeaBean.getPfmeaUpdateDate()); + setCellValue(row6,9,pfmeaBean.getSecurityClassification()); + XSSFRow row7 = sheet.getRow(6); + setCellValue(row7,4,pfmeaBean.getModelPlatform()); + setCellValue(row7,7,pfmeaBean.getFunctionalTeams()); + + for (int i = 0; i < dataValeList.size(); i++) { + XSSFRow row = null; + Boolean isCreat = false; + row = sheet.getRow(i + startRow); + if(row==null) { + row = sheet.createRow(i+ startRow); + isCreat = true; + } + +// if(i<17) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// }else{ +// row = sheet.createRow(i+ startRow); +// isCreat = true; +// } + if (isCreat) { + XSSFRow oldRow = sheet.getRow(i + startRow - 1); + if(oldRow==null) { + oldRow = sheet.createRow(i + startRow - 1); + } + for (int j = 0; j < 32; j++) { + XSSFCell oldCell = oldRow.getCell(j); + XSSFCell newCell = row.createCell(j); + if(oldCell==null) { + oldCell=oldRow.createCell(j); + } + newCell.setCellStyle(oldCell.getCellStyle()); + newCell.setCellType(oldCell.getCellType()); + } + } + //循环添加列 + for(int j=1;j<33;j++) { + XSSFCell cell = row.getCell(j-1); + if(j<25) { + cell.setCellValue((String)dataValeList.get(i).get(j)); + }else { + cell.setCellValue((String)dataValeList.get(i).get(j+3)); + } + } + } + //+++++++++++++ + + //第二页导出++++++ + int startRow2 = 6; + XSSFRow row21 = sheet2.getRow(2); + setCellValue(row21,0,"项目:"+pfmeaBean.getProject()); + setCellValue(row21,3,"设计职责:"+pfmeaBean.getProcessDuty()); + setCellValue(row21,7,"FMEA编号:"+pfmeaBean.getPfmeaNumber()); + XSSFRow row22 = sheet2.getRow(3); + setCellValue(row22,0,"FMEA日期(原始):"+pfmeaBean.getPfmeaStartDate()); + + for (int i = 0; i < dataValue.length; i++) { + XSSFRow row = null; + Boolean isCreat = false; + + if(row==null) { + row = sheet2.createRow(i+ startRow2); + isCreat = true; + } +// if(i<15) { +// row = sheet2.getRow(i + startRow2); +// isCreat = false; +// }else{ +// row = sheet2.createRow(i+ startRow2); +// isCreat = true; +// } + if (isCreat) { + XSSFRow oldRow = sheet2.getRow(i + startRow2 - 1); + if(oldRow==null) { + oldRow = sheet2.createRow(i + startRow2 - 1); + } + for (int j = 0; j < 9; j++) { + XSSFCell oldCell = oldRow.getCell(j); + if(oldCell==null) { + oldCell=oldRow.createCell(j); + } + XSSFCell newCell = row.createCell(j); + newCell.setCellStyle(oldCell.getCellStyle()); + newCell.setCellType(oldCell.getCellType()); + } + combine(sheet2, new int[] { i + startRow2 }, new int[] { 3, 5 }); + } + //循环添加列 + for(int j=1;j<8;j++) { + if(j<5) { + XSSFCell cell = row.getCell(j-1); + cell.setCellValue(dataValue[i][j]); + }else { + XSSFCell cell = row.getCell(j+1); + cell.setCellValue(dataValue[i][j]); + } + } + } + + // 合并单元格 + if (excelCombineMap != null && excelCombineMap.size() > 0) { + Iterator> it = excelCombineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + int[] row = new int[entry.getKey().length]; + int[] column = new int[entry.getValue().length]; + for (int k = 0; k < entry.getKey().length; k++) { + //row[k] = entry.getKey()[k] + 17; + row[k] = entry.getKey()[k]+10 ; + } + for (int k = 0; k < entry.getValue().length; k++) { + if (entry.getValue()[k] == 1) { + //column[k] = entry.getValue()[k] + 1; + column[k] = entry.getValue()[k] -1; + } else { + //column[k] = entry.getValue()[k] + column[k] = entry.getValue()[k]-1; + } + } + ExcelUtil.combine_XSSF(sheet, row, column); + } + } + wb.write(output); + output.close(); + input.close(); + } catch (Exception e1) { + // TODO: handle exception + MessageBox.post(e1.toString(), "错误", MessageBox.ERROR); + e1.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } +//+++++++ + MessageBox.post("导出Excel成功!", "成功", MessageBox.INFORMATION); + this.dispose(); + } else if (source.equals(this.celButton)) { + this.dispose(); + } + } + + /** + * 文件夹选择按钮事件 + * + * @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()); + } + } + } + + + + + private class SpecialDialog extends JFrame implements ActionListener { + private JPanel tablePanel;// 表格控件 + private JTable table; + + private JPanel rootPanel;// 按钮 + private JButton okButton;// 确定 + private JButton celButton;// 取消 + + public SpecialDialog() { + // TODO Auto-generated constructor stub + super(); + init(); + } + + private void init() { + //获取国际化语言 + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + // TODO Auto-generated method stub + this.setTitle(rb.getString("xztsfh10_display.TITLE")); + this.table = getjTable(this.table, null, new Object[] { 1, 2, 3, 4, 5, 6, 7, 8 }, + new Object[][] { { 1, 2, 3, 4, 5, 6, 7, 8 }, { 9, 0, "q", "w", "e", "r", "t", "y" } }); + this.setLocationRelativeTo(this); + this.table.setRowHeight(30); + this.table.getTableHeader().setVisible(false); + this.table.setFont(new Font("Y14.5M", 0, 15)); + this.tablePanel = new JPanel(new BorderLayout()); + this.tablePanel.add(this.table); + + this.okButton = new JButton(rb.getString("qd_display.TITLE")); + this.okButton.addActionListener(this); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.celButton.addActionListener(this); + this.rootPanel = new JPanel(new FlowLayout()); + this.rootPanel.add(this.okButton); + this.rootPanel.add(this.celButton); + + this.add(this.tablePanel, BorderLayout.CENTER); + this.add(this.rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + // Jtable通用方法 + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(this.getTableModel(dtm, titleNames, values)); + partsTable.setCellSelectionEnabled(true); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + public DefaultTableModel getTableModel(DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + MyTableModel tableModel = null; + if (dtm == null) { + tableModel = new MyTableModel(values, titleNames); + } + return tableModel; + } + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + Object source = actionevent.getSource(); + if (source.equals(this.okButton)) { + int row = DesignPFMEADialog.table.getSelectedRow(); + int column = DesignPFMEADialog.table.getSelectedColumn(); + // 保存特殊符号位置 + String columnName = DesignPFMEADialog.table + .getColumnName(DesignPFMEADialog.table.getSelectedColumn()); + + int cursorIndex = ((TextAreaCellEditor) (DesignPFMEADialog.table.getCellEditor(row, column))) + .getIndex(); + System.out.println("index+" + cursorIndex); + (DesignPFMEADialog.table.getCellEditor(row, column)).stopCellEditing(); + // DesignPFMEADialog.table.getDefaultEditor(Object.class).stopCellEditing(); + StringBuilder sb = new StringBuilder(DesignPFMEADialog.table.getValueAt(row, column).toString()); + + // 定义循环,如果index的位置不是-1,就一直查找 + Integer index = 0; + while ((index = sb.toString().indexOf("\n", index)) != -1) { + + // 每循环一次就要明确下一次查找的位置 + index = index + "\n".length(); + // 每查找一次计数器自增 + cursorIndex++; + } + // 特殊符号 + Object special = DesignPFMEADialog.table.getValueAt(row, + DesignPFMEADialog.table.getColumnCount() - 1); + if (special == null || special.toString() == "") { + DesignPFMEADialog.table.setValueAt(columnName + "-" + cursorIndex, row, + DesignPFMEADialog.table.getColumnCount() - 1); + } else { + DesignPFMEADialog.table.setValueAt(special + "|" + columnName + "-" + cursorIndex, row, + DesignPFMEADialog.table.getColumnCount() - 1); + } + System.out.println(sb.length()); + String s = sb + .insert(cursorIndex, this.table + .getValueAt(this.table.getSelectedRow(), this.table.getSelectedColumn()).toString()) + .toString(); + DesignPFMEADialog.table.setValueAt(s, DesignPFMEADialog.table.getSelectedRow(), + DesignPFMEADialog.table.getSelectedColumn()); + System.out.println(DesignPFMEADialog.table.getValueAt(row, column).toString()); + } else { + this.dispose(); + } + } + } + + private class LibraryDialog extends JFrame { + private List beans = new ArrayList(); + private int index = -1; + private List dontMove = new ArrayList(); + private TableRowSorter mainSorter; + // 查询框 + private JTextField findLeftField; + private JButton findLeftButton; + // 查询框 + private JTextField findMainField; + private JTextField findColumnField; + private JButton findMainButton; + + private JTextField heightField; + private JButton heightButton; + private JButton saveBtnSize; + private JButton findColumnButton; + // 界面所需控件 + private JTextPane selectCellValuePane; + private JPanel titlePanel;// 标题 + private JLabel titleLabel; + // 导航栏 + private CTable leftTable; + private JTable mainTable; + private int setRowHeight = 0; + private int selectMainRow = -1; + private int selectMainCol = -1; + private Map combineMap=new HashMap();// 存放合并单元格 + +// private Map combineMap2=new HashMap();// 存放合并单元格 + private CTMap2 map; + + // 右键菜单 + private JPopupMenu libraryMenu; + // 右键菜单项 + private JMenuItem copyRowItem;// 复制多行 + + private String gcbz; + // 标签控件 + // private JTabbedPane tabbedPane; + public LibraryDialog(String string) { + // TODO Auto-generated constructor stub + super(); + // getData(); + this.gcbz=string; + getPFMEAData(); + init(); + } + public LibraryDialog() { + // TODO Auto-generated constructor stub + super(); + // getData(); + getPFMEAData(); + init(); + } + public void HiddenCell(int column,JTable table) { + TableColumn tc = table.getTableHeader().getColumnModel().getColumn(column); + tc.setMaxWidth(0); + tc.setPreferredWidth(0); + tc.setWidth(0); + tc.setMinWidth(0); + table.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); + table.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + } + public void HiddenRow(int row,JTable table) { +// TableColumn tc = table.getTableHeader().getColumnModel().getColumn(column); +// table.getRow + table.setRowHeight(row, 1); +// table.getModel() +// tc.setMaxWidth(0); +// tc.setPreferredWidth(0); +// tc.setWidth(0); +// tc.setMinWidth(0); +// table.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); +// table.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + } + public void analyticSize2(List rowList) { + if(rowList.get(0).indexOf("/")>-1) {//获取界面大小位置 + String[] data=rowList.get(0).split("/"); + for(int i=0;i<4;i++) { + SizeLoca2[i]=Integer.parseInt(data[i]); + } + } + if(rowList.get(1).indexOf("/")>-1) { + String[] data=rowList.get(1).split("/"); + for(int i=0;i<3;i++) { + table1Size2[i]=Integer.parseInt(data[i]); + } + } + if(rowList.get(2).indexOf("/")>-1) { + String[] data=rowList.get(2).split("/"); + for(int i=0;i<30;i++) { + table2Size2[i]=Integer.parseInt(data[i]); + } + } + + if(!rowList.get(3).equals("")) { + initRowHeight2 = Integer.valueOf(rowList.get(3)); + } + + + } + private boolean isFirstOpen2=false; + public void getFrameSize2() { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + ResultSet rs = null; + ResultSet rs0 = null; + InputStream input = null; + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + String sql = String.format("select * from AHMC_PFMEAFRAME_SIZE WHERE USERNAME = '%s' AND TYPE = '%s'",userName,"PFMEAlibraryDialog"); + rs = SqlUtilT.read(sql); + List rowList = new ArrayList(); + while (rs.next()) { + rowList.add(rs.getString("FRAMESIZE"));//界面大小、位置 + rowList.add(rs.getString("TABLE1SIZE"));//第一个表格的列宽数据 + rowList.add(rs.getString("TABLE2SIZE"));//第二格表格的列宽数据 + rowList.add(rs.getString("ROWHEIGHT"));//第1格表格的行高数据 + break; + } + if(rowList.size()==4) {//解析界面大小,位置,表格列宽数据 + analyticSize2(rowList); + }else { + String sql0 = String.format("select * from AHMC_PFMEAFRAME_SIZE WHERE USERNAME = '%s' AND TYPE = '%s'","iniUser","PFMEAlibraryDialog"); + rs0 = SqlUtilT.read(sql0); + while (rs0.next()) { + rowList.add(rs0.getString("FRAMESIZE"));//界面大小、位置 + rowList.add(rs0.getString("TABLE1SIZE"));//第一个表格的列宽数据 + rowList.add(rs0.getString("TABLE2SIZE"));//第二格表格的列宽数据 + + rowList.add(rs0.getString("ROWHEIGHT"));//第1格表格的行高数据 + break; + } + if(rowList.size()<=0) { + MessageBox.post("(数据库)未设置界面最初尺寸,请先配置!", "错误", MessageBox.ERROR); + return; + }else { + isFirstOpen=true; + analyticSize2(rowList); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if(rs0 != null) { + SqlUtilT.free(rs0); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + private int[] SizeLoca2=new int[4]; + private int[] table1Size2=new int[3]; + private int[] table2Size2=new int[30]; + private int initRowHeight2 = 50; + private TableRowSorter sorter; + private void init() { + getFrameSize2(); + //获取国际化语言 + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + // TODO Auto-generated method stub + this.setTitle(rb.getString("PFMEAc10_display.TITLE")); +// this.setPreferredSize(new Dimension(850, 600)); + this.setPreferredSize(new Dimension(SizeLoca2[0], SizeLoca2[1])); + System.out.println(SizeLoca2[0]+"sizes"+ SizeLoca2[1]); + this.setLocation(SizeLoca2[2], SizeLoca2[3]); + // 初始化标题部分控件 + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel(rb.getString("qzsxmsjhgfx10_display.TITLE")); + this.titleLabel.setFont(new Font("宋体", 1, 18)); + this.titlePanel.add(this.titleLabel); + + JPanel centerPanel = new JPanel(new BorderLayout()); + centerPanel.add(titlePanel, BorderLayout.NORTH); + + JPanel findLeftPanel = new JPanel(new PropertyLayout()); + this.findLeftField = new JTextField(); + this.findLeftField.setPreferredSize(new Dimension(100, 20)); + this.findLeftButton = new JButton(rb.getString("cz10_display.TITLE")); + findLeftPanel.add("1.1.left.top", this.findLeftField); + findLeftPanel.add("1.2.left.top", this.findLeftButton); + + this.leftTable = getNewjTable(null, null, leftHeader, beans.size(), false); + // 隐藏列 + leftTable.HiddenCell(0); + leftTable.HiddenCell(3); + leftTable.setRowHeight(30); + int ind = -1; + for (int i = 0; i < beans.size(); i++) { +// this.leftTable.setValueAt(beans.get(i).getPlmeid(), i, 0); + this.leftTable.setValueAt(beans.get(i).getId(), i, 1); + if(gcbz!=null) { + System.out.println("beans.get(i).getName() " + beans.get(i).getName() + " gcbz"+gcbz); + if(gcbz.contains(beans.get(i).getName())) { + ind = i; + } + } + + this.leftTable.setValueAt(beans.get(i).getName(), i, 2); +// this.leftTable.setValueAt(beans.get(i).getParentId(), i, 3); + } + CTMap2 cmodel = (CTMap2) this.leftTable.getModel(); + sorter = new TableRowSorter(cmodel); + this.leftTable.setRowSorter(sorter); // 为JTable设置排序器 + for(int i=1;i<=2;i++) { + leftTable.getColumnModel().getColumn(i).setPreferredWidth(table1Size[i-1]);; + } + this.findLeftButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (findLeftField.getText().length() == 0) { + sorter.setRowFilter(null); + } else { + sorter.setRowFilter(RowFilter.regexFilter(findLeftField.getText()));// 为JTable设置基于正则表达式的过滤条件 + } + } + }); + leftTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent arg0) { + // TODO Auto-generated method stub + if (index == -1) { + refreshPFMEATable(); + index = leftTable.getSelectedRow(); + } else if (index != -1 && index != leftTable.getSelectedRow()) { + refreshPFMEATable(); + index = leftTable.getSelectedRow(); + } + } + }); + JPanel findMainPanel = new JPanel(new PropertyLayout()); + this.findMainField = new JTextField(); + this.findMainField.setPreferredSize(new Dimension(100, 20)); + this.findMainButton = new JButton(rb.getString("cz10_display.TITLE")); + + this.findColumnField = new JTextField(); + this.findColumnField.setPreferredSize(new Dimension(100, 20)); + this.findColumnButton = new JButton("列查询"); + + this.heightField = new JTextField(); + this.heightField.setPreferredSize(new Dimension(100, 20)); + this.heightButton = new JButton("行高调整"); + + this.saveBtnSize = new JButton("界面保存"); + + findMainPanel.add("1.1.left.top", this.findMainField); + findMainPanel.add("1.2.left.top", this.findMainButton); + + findMainPanel.add("1.3.left.top", this.findColumnField); + findMainPanel.add("1.4.left.top", this.findColumnButton); + + findMainPanel.add("1.5.left.top", this.heightField); + findMainPanel.add("1.6.left.top", this.heightButton); + findMainPanel.add("1.7.left.top", this.saveBtnSize); + + this.mainTable = getNewjTable(null, null, pfmeaKuHeader, 0, false); + // 隐藏列 + HiddenCell(0,mainTable); +// mainTable.HiddenCell(0); +// mainTable.HiddenCell(pfmeaKuHeader.length - 1); + HiddenCell(pfmeaKuHeader.length - 1,mainTable); + if(initRowHeight2==0) { + mainTable.setRowHeight(40); + }else { + mainTable.setRowHeight(initRowHeight2); + } + + for(int i=2;i<=table2Size2.length+1;i++) { + this.mainTable.getColumnModel().getColumn(i).setPreferredWidth(table2Size2[i-2]);; + } +// mainSorter = new TableRowSorter(this.mainTable.getModel()); +// this.mainTable.setRowSorter(mainSorter); // 为JTable设置排序器 + this.saveBtnSize.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + try { + String list1=String.valueOf(((int)getSize().getWidth()))+"/"+String.valueOf((int)getSize().getHeight()) + +"/"+String.valueOf(((int)getLocation().getX()))+"/"+String.valueOf((((int)getLocation().getY()))); + +// String list2=""; +// for(int i=1;i"+userName); + System.out.println("this.type====>"+"DesignToLib"); + System.out.println("list1====>"+list1.toString()); +// System.out.println("list2====>"+list2.toString()); + System.out.println("list3====>"+list3.toString()); + if(isFirstOpen) { +// String insertSQL = "INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?,?)"; +// SqlUtilT.write(new String[] { +// UUID.randomUUID().toString().replace("-", ""), +// userName,"PFMEAlibraryDialog",list1,list2,list3,String.valueOf(mainTable.getRowHeight())}, insertSQL); +// System.out.println("insertSQL====>"+insertSQL); +// isFirstOpen=false; + System.out.println("first?"); + }else { + String updateSQL = String.format( + "update AHMC_PFMEAFRAME_SIZE set FRAMESIZE = ?, TABLE2SIZE = ?,ROWHEIGHT = ? WHERE USERNAME ='%s' AND TYPE = '%s'",userName,"PFMEAlibraryDialog"); + SqlUtilT.update( + new String[] {list1,list3,String.valueOf(mainTable.getRowHeight())},updateSQL); + } + SqlUtilT.freeAll(); + ///++++++ + } catch (Exception e3) { + // TODO: handle exception + } +// +// mainTable.invalidate(); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); +// System.out.println("输入数字"); + } + } + }); + this.heightButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + String selectedText = heightField.getText(); + try { +// Double valueOf = Double.valueOf(selectedText); + int rowCount = mainTable.getRowCount(); + int rowHeight = 40; + Integer valueOf = Integer.valueOf(selectedText); + if(valueOf>10 || valueOf<1) { + MessageBox.post("调整行高建议在1-10倍之间","提示",2); + } + System.out.println("valueOf"+valueOf+"rowHeight"+rowHeight); + rowHeight = (int) (rowHeight*valueOf); + System.out.println("new rowHeight"+rowHeight); + setRowHeight = rowHeight; + mainTable.setRowHeight(rowHeight); +// mainTable.invalidate(); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); +// System.out.println("输入数字"); + } + + + } + }); + this.findColumnButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + +// leftTable.setRowSelectionInterval(lastSelectedRow,lastSelectedRow); + try { + + dontMove.clear(); + System.out.println(lastSelectedRow+"lastSelectedRow"); + refreshPFMEATable((String)leftTable.getValueAt(lastSelectedRow, 1)); + JTable jTable = mainTable; + CTMap2 model = (CTMap2) jTable.getModel(); + System.out.println(jTable.getRowCount()); +// int columnSelect = jTable.getSelectedColumnCount(); +// int rowSelect = jTable.getSelectedRow(); + System.out.println("jTable"+selectMainRow+"columnSelect"+selectMainCol); + if(selectMainRow ==-1 || selectMainCol==-1) { + System.out.println("未选中某一列"); + }else { + List removeRows = new ArrayList(); +// combineMap.get(0); +// int index + String text = findColumnField.getText(); + System.out.println("查询的内容"+text); + int rowCount = jTable.getRowCount(); + if(!text.trim().equals("")) { + int removes = 0; +// int + combineMap.clear(); + for(int t=0;t list = rememberRow.get(t); + String object = (String) list.get(35); +// System.out.println(rememberRow.get(index)); + String valueAt =(String)rememberRow.get(t).get(selectMainCol); //(String) jTable.getValueAt(t, selectMainCol); + System.out.println("valueAt =====> "+valueAt); +// index = index + 1; + if(valueAt ==null || !valueAt.contains(text)) { + System.out.println( "remove ======> "+t); + removeRows.add(t); + removes = removes + 1; + }else { + comBine(object,removes); + } + } + System.out.println(dontMove.toString()+"---------"); + for(int t = removeRows.size()-1;t>=0;t--) { +// ta + if(!dontMove.contains(removeRows.get(t))) { + model.removeRow(removeRows.get(t)); + } + } +// map.in +// map = new CTMap2(model.getRowCount(),pfmeaKuHeader.length); + map.setNumRows(model.getRowCount()); + map.setSize(new Dimension(pfmeaKuHeader.length, model.getRowCount())); + System.out.println("combineMap2"+combineMap.size()); + if (combineMap != null && combineMap.size() != 0) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); +// for() + int[] key = entry.getKey(); + for(int xx=0;xx= 0) { + if(mainTable.getSelectedColumn()==2) { + DesignPFMEADialog.table.getCellEditor(DesignPFMEADialog.table.getSelectedRow(), + DesignPFMEADialog.table.getSelectedColumn()).stopCellEditing(); + for (int i = 2; i < mainTable.getColumnCount(); i++) { + if (i == mainTable.getColumnCount() - 1 || i== 5) {//最后一个父节点不能复制 + continue; + } + else { + DesignPFMEADialog.table.setValueAt( + mainTable.getValueAt(mainTable.getSelectedRow(), i), + DesignPFMEADialog.table.getSelectedRow(), i-1); + } + } +// for (int j = 2; j < mainTable.getColumnCount(); j++) { +// //+++ +// if(j == mainTable.getColumnCount() - 1 || j== 5) {//最后一个父节点不能复制 +// continue; +// }else { +// if((DesignPFMEADialog.table.getSelectedRow()) selectRowAll = new ArrayList(); + for(int t=0;t0) { + int z = selectRowAll.get(k) - selectRows[k-1]; + if(z>1) { + low = low + z -1; + } + } + } + DesignPFMEADialog.table.revalidate(); + DesignPFMEADialog.table.repaint(); + + //用于通过在PFMEA库中的行定位到PFMEA中的行 + int Dvalue=DesignPFMEADialog.table.getSelectedRow()-firstRow; + + Set combinRows=combineMap.keySet(); + //检查选中的行里面是否包含合并的行 + for(int[] combinRow:combinRows) { + if(iscontain(selectRows, combinRow)!=null) { + System.out.println("------找到要合并的单元格"); + int[] hbh=iscontain(selectRows, combinRow); + System.out.println("------合并"+hbh[hbh.length-1]+Dvalue); + int[] hbl=combineMap.get(combinRow); + int start = hbh[0] - firstRow; + System.out.println("------合并"+start+"xxxxx" +Dvalue +"hbl[0]"+hbl[0] +"hbl[hbl.length-1]"+hbl[hbl.length-1]); + //System.out.println("合并行号====>:"+Arrays.toString(hbh)); + //通过Dvalue转化合并行在PFMEA和PFMEA库中相对选中行的的位置 + + DesignPFMEADialog.table.setRowSelectionInterval( hbh[0] + Dvalue - low, hbh[hbh.length-1]+Dvalue - low); + //因为PFMEA中有前面三行(0,1,2)没存储数据而PFMEA库只有两行(0,1)。故处理行时要加1 + DesignPFMEADialog.table.setColumnSelectionInterval(hbl[0]-1, hbl[hbl.length-1]-1); + comBineCell(); + } + } + //合并行结束需要将选中行回到初始位置,用于插入数据 + DesignPFMEADialog.table.setRowSelectionInterval(PFMEADialogSelectrow, PFMEADialogSelectrow+PFMEADialogSelectrows-1); + DesignPFMEADialog.table.setColumnSelectionInterval(PFMEADialogSelectColumn, PFMEADialogSelectColumn+PFMEADialogSelectColumns-1); + + + + for (int i = 0; i < selectRowAll.size() ; i++) { + if (DesignPFMEADialog.table.getSelectedRow() >= 0) { + DesignPFMEADialog.table.getCellEditor(DesignPFMEADialog.table.getSelectedRow(), + DesignPFMEADialog.table.getSelectedColumn()).stopCellEditing(); + for (int j = 2; j < jtable.getColumnCount(); j++) { + //+++ + if(j == mainTable.getColumnCount() - 1 || j== 5) {//最后一个父节点不能复制 + continue; + }else { + if((DesignPFMEADialog.table.getSelectedRow() + i)-1) { + lastSelectedRow = ind; + System.out.println("ind"+ind); + leftTable.setRowSelectionInterval(ind,ind); + leftTable.invalidate(); + refreshPFMEATable((String)leftTable.getValueAt(ind, 1)); + + } + } + + /** + * 获取数据库中的数据 + */ + private void getPFMEAData() { + // TODO Auto-generated method stub + ResultSet rs = null; + InputStream input = null; + try { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + pro.load(input); + String sql = String.format(pro.getProperty("TM2PFMEATREESELECT")); + rs = SqlUtilT.read(sql); + while (rs.next()) { + TreeBean bean = new TreeBean(); + bean.setPlmeid(rs.getString("PLMEID")); + bean.setId(rs.getString("ID")); + bean.setName(rs.getString("NAME")); + bean.setParentId(rs.getString("PARENT_ID")); + beans.add(bean); + } + // createTabbedPane(beans); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + } + private List> rememberRow; + private int lastSelectedRow; + private void refreshPFMEATable(String valueAt) { + // TODO Auto-generated method stub + + + try { + String list1=String.valueOf(((int)this.getSize().getWidth()))+"/"+String.valueOf((int)this.getSize().getHeight()) + +"/"+String.valueOf(((int)this.getLocation().getX()))+"/"+String.valueOf((((int)this.getLocation().getY()))); + +// String list2=""; +// for(int i=1;i"+userName); + System.out.println("this.type====>"+"DesignToLib"); + System.out.println("list1====>"+list1.toString()); +// System.out.println("list2====>"+list2.toString()); + System.out.println("list3====>"+list3.toString()); + if(isFirstOpen) { +// String insertSQL = "INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?,?)"; +// SqlUtilT.write(new String[] { +// UUID.randomUUID().toString().replace("-", ""), +// userName,"PFMEAlibraryDialog",list1,list2,list3,String.valueOf(mainTable.getRowHeight())}, insertSQL); +// System.out.println("insertSQL====>"+insertSQL); +// isFirstOpen=false; + System.out.println("first?"); + }else { + String updateSQL = String.format( + "update AHMC_PFMEAFRAME_SIZE set FRAMESIZE = ?, TABLE2SIZE = ?,ROWHEIGHT = ? WHERE USERNAME ='%s' AND TYPE = '%s'",userName,"PFMEAlibraryDialog"); + SqlUtilT.update( + new String[] {list1,list3,String.valueOf(mainTable.getRowHeight())},updateSQL); + } + SqlUtilT.freeAll(); + ///++++++ + } catch (Exception e) { + // TODO: handle exception + } + + + ResultSet rs = null; + InputStream input = null; + try { + + SqlUtilT.getTCConnection(); + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); +// lastSelectedRow = leftTable.getSelectedRow(); + String sql = String.format(pro.getProperty("PFMEALIBRARYSELECT"), + valueAt); + rs = SqlUtilT.read(sql); + List> rowList = new ArrayList>(); + List> rowList2 = new ArrayList>(); + while (rs.next()) { + List list = new ArrayList(); + List list2 = new ArrayList(); + + list2.add(rs.getString("PLMEID")); + list2.add(false); + list2.add(rs.getString("ID")); + list2.add(rs.getString("LSBG")); + list2.add(rs.getString("STATION")); + list2.add(rs.getString("REQUIREMENT")); + list2.add(rs.getString("QZSXMS")); + list2.add(rs.getString("QZSXHG")); + list2.add(rs.getString("YZD")); + list2.add(rs.getString("JB")); + list2.add(rs.getString("QZSXQY")); + list2.add(rs.getString("XXGCKZYF")); + list2.add(rs.getString("PDS")); + list2.add(rs.getString("XXGCKZTC")); + list2.add(rs.getString("TCD")); + list2.add(rs.getString("RPN")); + list2.add(rs.getString("JYCS")); + list2.add(rs.getString("ZZR")); + list2.add(rs.getString("JHWCRQ")); + list2.add(rs.getString("CQDCS")); + list2.add(rs.getString("NEW_SEV")); + list2.add(rs.getString("NEW_OCC")); + list2.add(rs.getString("NEW_DET")); + list2.add(rs.getString("NEW_RPN")); + list2.add(rs.getString("IDEAL_STATE")); + list2.add(rs.getString("SPECIAL")); + list2.add(rs.getString("P1")); + list2.add(rs.getString("P2")); + list2.add(rs.getString("P3")); + list2.add(rs.getString("P4")); + list2.add(rs.getString("P5")); + list2.add(rs.getString("P6")); + list2.add(rs.getString("P7")); + list2.add(rs.getString("P8")); + list2.add(rs.getString("PARENT_ID")); + list2.add(rs.getString("HBDYG")); + rowList2.add(list2); + // + list.add(rs.getString("PLMEID")); + list.add(rs.getString("ID")); + list.add(rs.getString("LSBG")); + list.add(rs.getString("STATION")); + list.add(rs.getString("REQUIREMENT")); + list.add(rs.getString("QZSXMS")); + list.add(rs.getString("QZSXHG")); + list.add(rs.getString("YZD")); + list.add(rs.getString("JB")); + list.add(rs.getString("QZSXQY")); + list.add(rs.getString("XXGCKZYF")); + list.add(rs.getString("PDS")); + list.add(rs.getString("XXGCKZTC")); + list.add(rs.getString("TCD")); + list.add(rs.getString("RPN")); + list.add(rs.getString("JYCS")); + list.add(rs.getString("ZZR")); + list.add(rs.getString("JHWCRQ")); + list.add(rs.getString("CQDCS")); + list.add(rs.getString("NEW_SEV")); + list.add(rs.getString("NEW_OCC")); + list.add(rs.getString("NEW_DET")); + list.add(rs.getString("NEW_RPN")); + list.add(rs.getString("IDEAL_STATE")); + list.add(rs.getString("SPECIAL")); + list.add(rs.getString("P1")); + list.add(rs.getString("P2")); + list.add(rs.getString("P3")); + list.add(rs.getString("P4")); + list.add(rs.getString("P5")); + list.add(rs.getString("P6")); + list.add(rs.getString("P7")); + list.add(rs.getString("P8")); + list.add(rs.getString("PARENT_ID")); + list.add(rs.getString("HBDYG")); + rowList.add(list); + } + if (rowList.size() > 0) { + rememberRow = rowList2; + map = new CTMap2(rowList.size(), pfmeaKuHeader.length); + System.out.println(map.getColumnClass(1)+"---------"); + map.setColumnIdentifiers(pfmeaKuHeader); + map.setEditable(true); + mainTable.setModel(map); + try { + map.setRowCount(0); + mainTable.removeAll(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + + mainSorter = new TableRowSorter(map); + this.mainTable.setRowSorter(mainSorter); // 为JTable设置排序器 +// map.getCo + TableColumn tcm1 = mainTable.getColumnModel().getColumn(1); + tcm1.setCellEditor(mainTable.getDefaultEditor(Boolean.class)); + tcm1.setCellRenderer(mainTable.getDefaultRenderer(Boolean.class)); + for (int j = 0; j < rowList2.size(); j++) { + map.addRow(rowList2.get(j).toArray()); + } + comBine(rowList2); + + } else { + map = new CTMap2(1, pfmeaHeader.length); + map.setColumnIdentifiers(pfmeaHeader); + mainTable.setModel(map); + mainSorter = new TableRowSorter(map); + this.mainTable.setRowSorter(mainSorter); // 为JTable设置排序器 + map.setValueAt(leftTable.getValueAt(leftTable.getSelectedRow(), 1), 0, + mainTable.getColumnCount() - 1); + } + getFrameSize2(); + for(int i=1;i<=30;i++) { + mainTable.getColumnModel().getColumn(i+1).setPreferredWidth(table2Size2[i-1]);; + } + for(int i=1;i<=2;i++) { + leftTable.getColumnModel().getColumn(i).setPreferredWidth(table1Size2[i-1]);; + } + if(initRowHeight2!=0) { + mainTable.setRowHeight(initRowHeight2); + } + if(setRowHeight!=0) { + mainTable.setRowHeight(setRowHeight); + } + leftTable.setRowHeight(30); + HiddenCell(0,mainTable); +// mainTable.HiddenCell(0); +// mainTable.HiddenCell(pfmeaKuHeader.length - 1); + HiddenCell(pfmeaKuHeader.length - 1,mainTable); + mainTable.invalidate(); + } catch (Exception e) { + // TODO: handle exception + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + private void refreshPFMEATable() { + // TODO Auto-generated method stub + // 刷新右侧数据 + try { + String list1=String.valueOf(((int)this.getSize().getWidth()))+"/"+String.valueOf((int)this.getSize().getHeight()) + +"/"+String.valueOf(((int)this.getLocation().getX()))+"/"+String.valueOf((((int)this.getLocation().getY()))); + +// String list2=""; +// for(int i=1;i"+userName); + System.out.println("this.type====>"+"DesignToLib"); + System.out.println("list1====>"+list1.toString()); +// System.out.println("list2====>"+list2.toString()); + System.out.println("list3====>"+list3.toString()); + if(isFirstOpen) { +// String insertSQL = "INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?,?)"; +// SqlUtilT.write(new String[] { +// UUID.randomUUID().toString().replace("-", ""), +// userName,"PFMEAlibraryDialog",list1,list2,list3,String.valueOf(mainTable.getRowHeight())}, insertSQL); +// System.out.println("insertSQL====>"+insertSQL); +// isFirstOpen=false; + System.out.println("?"); + }else { + String updateSQL = String.format( + "update AHMC_PFMEAFRAME_SIZE set FRAMESIZE = ?, TABLE2SIZE = ?,ROWHEIGHT = ? WHERE USERNAME ='%s' AND TYPE = '%s'",userName,"PFMEAlibraryDialog"); + SqlUtilT.update( + new String[] {list1,list3,String.valueOf(mainTable.getRowHeight())},updateSQL); + } + SqlUtilT.freeAll(); + ///++++++ + } catch (Exception e) { + // TODO: handle exception + } + ResultSet rs = null; + InputStream input = null; + try { + + SqlUtilT.getTCConnection(); + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + lastSelectedRow = leftTable.getSelectedRow(); + String sql = String.format(pro.getProperty("PFMEALIBRARYSELECT"), + leftTable.getValueAt(leftTable.getSelectedRow(), 1)); + rs = SqlUtilT.read(sql); + List> rowList = new ArrayList>(); + List> rowList2 = new ArrayList>(); + while (rs.next()) { + List list = new ArrayList(); + List list2 = new ArrayList(); + + list2.add(rs.getString("PLMEID")); + list2.add(false); + list2.add(rs.getString("ID")); + list2.add(rs.getString("LSBG")); + list2.add(rs.getString("STATION")); + list2.add(rs.getString("REQUIREMENT")); + list2.add(rs.getString("QZSXMS")); + list2.add(rs.getString("QZSXHG")); + list2.add(rs.getString("YZD")); + list2.add(rs.getString("JB")); + list2.add(rs.getString("QZSXQY")); + list2.add(rs.getString("XXGCKZYF")); + list2.add(rs.getString("PDS")); + list2.add(rs.getString("XXGCKZTC")); + list2.add(rs.getString("TCD")); + list2.add(rs.getString("RPN")); + list2.add(rs.getString("JYCS")); + list2.add(rs.getString("ZZR")); + list2.add(rs.getString("JHWCRQ")); + list2.add(rs.getString("CQDCS")); + list2.add(rs.getString("NEW_SEV")); + list2.add(rs.getString("NEW_OCC")); + list2.add(rs.getString("NEW_DET")); + list2.add(rs.getString("NEW_RPN")); + list2.add(rs.getString("IDEAL_STATE")); + list2.add(rs.getString("SPECIAL")); + list2.add(rs.getString("P1")); + list2.add(rs.getString("P2")); + list2.add(rs.getString("P3")); + list2.add(rs.getString("P4")); + list2.add(rs.getString("P5")); + list2.add(rs.getString("P6")); + list2.add(rs.getString("P7")); + list2.add(rs.getString("P8")); + list2.add(rs.getString("PARENT_ID")); + list2.add(rs.getString("HBDYG")); + rowList2.add(list2); + // + list.add(rs.getString("PLMEID")); + list.add(rs.getString("ID")); + list.add(rs.getString("LSBG")); + list.add(rs.getString("STATION")); + list.add(rs.getString("REQUIREMENT")); + list.add(rs.getString("QZSXMS")); + list.add(rs.getString("QZSXHG")); + list.add(rs.getString("YZD")); + list.add(rs.getString("JB")); + list.add(rs.getString("QZSXQY")); + list.add(rs.getString("XXGCKZYF")); + list.add(rs.getString("PDS")); + list.add(rs.getString("XXGCKZTC")); + list.add(rs.getString("TCD")); + list.add(rs.getString("RPN")); + list.add(rs.getString("JYCS")); + list.add(rs.getString("ZZR")); + list.add(rs.getString("JHWCRQ")); + list.add(rs.getString("CQDCS")); + list.add(rs.getString("NEW_SEV")); + list.add(rs.getString("NEW_OCC")); + list.add(rs.getString("NEW_DET")); + list.add(rs.getString("NEW_RPN")); + list.add(rs.getString("IDEAL_STATE")); + list.add(rs.getString("SPECIAL")); + list.add(rs.getString("P1")); + list.add(rs.getString("P2")); + list.add(rs.getString("P3")); + list.add(rs.getString("P4")); + list.add(rs.getString("P5")); + list.add(rs.getString("P6")); + list.add(rs.getString("P7")); + list.add(rs.getString("P8")); + list.add(rs.getString("PARENT_ID")); + list.add(rs.getString("HBDYG")); + rowList.add(list); + } + if (rowList.size() > 0) { + map = new CTMap2(rowList.size(), pfmeaKuHeader.length); + System.out.println(map.getColumnClass(1)+"---------"); + map.setColumnIdentifiers(pfmeaKuHeader); + map.setEditable(true); + mainTable.setModel(map); + try { + map.setRowCount(0); + mainTable.removeAll(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + + mainSorter = new TableRowSorter(map); + this.mainTable.setRowSorter(mainSorter); // 为JTable设置排序器 +// map.getCo + TableColumn tcm1 = mainTable.getColumnModel().getColumn(1); + tcm1.setCellEditor(mainTable.getDefaultEditor(Boolean.class)); + tcm1.setCellRenderer(mainTable.getDefaultRenderer(Boolean.class)); + for (int j = 0; j < rowList.size(); j++) { + map.addRow(rowList2.get(j).toArray()); + } + comBine(rowList2); + + } else { + map = new CTMap2(1, pfmeaHeader.length); + map.setColumnIdentifiers(pfmeaHeader); + mainTable.setModel(map); + mainSorter = new TableRowSorter(map); + this.mainTable.setRowSorter(mainSorter); // 为JTable设置排序器 + map.setValueAt(leftTable.getValueAt(leftTable.getSelectedRow(), 1), 0, + mainTable.getColumnCount() - 1); + } + getFrameSize2(); + for(int i=1;i<=30;i++) { + mainTable.getColumnModel().getColumn(i+1).setPreferredWidth(table2Size2[i-1]);; + } + for(int i=1;i<=2;i++) { + leftTable.getColumnModel().getColumn(i).setPreferredWidth(table1Size2[i-1]);; + } + if(initRowHeight2!=0) { + mainTable.setRowHeight(initRowHeight2); + } +// if(rowHeightAll!=0) { +// mainTable.setRowHeight(rowHeightAll); +// } + if(setRowHeight!=0) { + mainTable.setRowHeight(setRowHeight); + } + leftTable.setRowHeight(30); + HiddenCell(0,mainTable); +// mainTable.HiddenCell(0); +// mainTable.HiddenCell(pfmeaKuHeader.length - 1); + HiddenCell(pfmeaKuHeader.length - 1,mainTable); + mainTable.invalidate(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + + //检查数组a是否包含数组b + public int[] iscontain( int[] a, int[] b){ + + for (int i = 0; i < a.length; i++) { + for (int j = 0; j < b.length&&j<(a.length-i); j++) { + if(a[i+j]==b[j]){ + if(j==b.length-1){ + return b; + }else if(j==a.length-1-i) { + return Arrays.copyOfRange(a,i,a.length);//截取a数组从i到最后的数组数据 + } + continue; + }else{ + break; + } + } + } + return null; + } + + + public void comBine(String combs,int moved) { + System.out.println("String.valueOf(selectMainCol-1)"+String.valueOf(selectMainCol-1)); + + if (combs!= null && !combs.equals("")) { + System.out.println(moved); + System.out.println(combs); + String sombine = combs; + String[] sombines; + if (sombine.indexOf("-") >= 0) { + sombines = sombine.split("-"); + } else { + sombines = new String[] { sombine }; + } + for (int j = 0; j < sombines.length; j++) { + if (sombines[j].indexOf("/") >= 0) { + int[] row; + int[] cloumn; + String[] cells = sombines[j].split("/"); + if (cells[0].indexOf(",") >= 0) { + String[] rows = cells[0].split(","); + row = new int[rows.length]; + for (int k = 0; k < rows.length; k++) { + row[k] = Integer.parseInt(rows[k]) - moved; + if(cells[1].contains(String.valueOf(selectMainCol-1))) { + dontMove.add(Integer.parseInt(rows[k])); + } + } + } else { + row = new int[] { Integer + .parseInt(cells[0]) - moved}; + if(cells[1].contains(String.valueOf(selectMainCol-1))) { + dontMove.add(Integer.parseInt(cells[0])); + } + + } + if (cells[1].indexOf(",") >= 0) { + String[] cloumns = cells[1].split(","); + cloumn = new int[cloumns.length]; + for (int k = 0; k < cloumns.length; k++) { + cloumn[k] = Integer + .parseInt(cloumns[k])+1; + } + } else { + cloumn = new int[1]; //cells[1]+1 + cloumn[0] = Integer.parseInt(cells[1])+1; + } + this.combineMap.put(row, cloumn); + } + } + } + } + //加载合并单元格 + public void comBine(List> rowList) { + + + combineMap.clear(); + if (rowList != null && rowList.size() > 0) { + for (int i = 0; i < rowList.size(); i++) { + if (rowList.get(i).get(35)!= null + && !rowList.get(i).get(35).equals("")) { + String sombine = rowList.get(i).get(35).toString(); +// int rowDif = 0; + String[] sombines; + if (sombine.indexOf("-") >= 0) { + sombines = sombine.split("-"); + } else { + sombines = new String[] { sombine }; + } + for (int j = 0; j < sombines.length; j++) { + if (sombines[j].indexOf("/") >= 0) { + int[] row; + int[] cloumn; + String[] cells = sombines[j].split("/"); + if (cells[0].indexOf(",") >= 0) { + String[] rows = cells[0].split(","); + row = new int[rows.length]; + for (int k = 0; k < rows.length; k++) { + row[k] = Integer.parseInt(rows[k]); + } + } else { + row = new int[] { Integer.parseInt(cells[0])}; + } + if (cells[1].indexOf(",") >= 0) { + String[] cloumns = cells[1].split(","); + cloumn = new int[cloumns.length]; + for (int k = 0; k < cloumns.length; k++) { + cloumn[k] = Integer + .parseInt(cloumns[k])+1; + } + } else { + cloumn = new int[1]; //cells[1]+1 + cloumn[0] = Integer.parseInt(cells[1])+1; + } + this.combineMap.put(row, cloumn); + } + } + } + } + } + + try { + if (combineMap != null && combineMap.size() != 0) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + map.combine(entry.getKey(), entry.getValue()); + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + // TODO Auto-generated method stub + + } + + + } + + public class AddRowsDialog extends AbstractAIFDialog implements ActionListener { + + private JPanel panel; + private JLabel label; + private JTextField textField; + private JButton button; + + private Object source; + + public AddRowsDialog(Object source) { + // TODO Auto-generated constructor stub + super(); + this.source = source; + init(); + } + + private void init() { + //获取国际化语言 + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + // TODO Auto-generated method stub + this.panel = new JPanel(new PropertyLayout()); + this.label = new JLabel(rb.getString("crhs10_display.TITLE")); + this.textField = new JTextField(20); + this.textField.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent arg0) { + if (arg0.getKeyCode() == KeyEvent.VK_ENTER) { + okEvent(); + } else { + super.keyPressed(arg0); + } + } + }); + this.button = new JButton(rb.getString("qd_display.TITLE")); + this.button.addActionListener(this); + this.panel.add("1.1.left.top", label); + this.panel.add("1.2.left.top", textField); + this.panel.add("1.3.left.top", button); + + this.add(this.panel, BorderLayout.CENTER); + this.pack(); + this.showDialog(); + } + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + Object source = actionevent.getSource(); + if (source.equals(this.button)) { + okEvent(); + } + } + + private void okEvent() { + // TODO Auto-generated method stub + if (this.source.equals(addRowsItem)) { + if (!isStr2Num(textField.getText())) { + MessageBox.post("请输入正确的数字!", "错误!", MessageBox.ERROR); + return; + } + for (int i1 = 0; i1 < Integer.parseInt(textField.getText()); i1++) { + addRow(); + } + this.disposeDialog(); + this.dispose(); + } else if (this.source.equals(addCombineRowsItem)) { + if (!isStr2Num(textField.getText())) { + MessageBox.post("请输入正确的数字!", "错误!", MessageBox.ERROR); + return; + } + for (int i1 = 0; i1 < Integer.parseInt(textField.getText()); i1++) { + addCombineRow(); + } + this.disposeDialog(); + this.dispose(); + } + } + } + /** + * 设置单元格 + * + * @param row1 + * @param index + * @param str + */ + public static void setCellValue(XSSFRow row1, int index, String str) { + XSSFCell cell = row1.getCell(index); + if(cell==null) { + cell=row1.createCell(index); + } + cell.setCellType(CellType.STRING); + cell.setCellValue(str); + } + + /** + * 设置单元格 + * + * @param row1 + * @param index + * @param str + */ + public static void setCellValue(Row row1, int index, String str) { + Cell cell = row1.getCell(index); + cell.setCellType(CellType.STRING); + cell.setCellValue(str); + } + public static boolean combine(XSSFSheet sheet, int[] rows, int[] columns) { + boolean isOK = false; + if (rows.length <=1 && columns.length <=1) {//对单个单元格合并则跳过 + }else { + sheet.addMergedRegion(new CellRangeAddress(rows[0], + rows[rows.length - 1], columns[0], + columns[columns.length - 1])); + isOK = true; + } + return isOK; + } +} + +//++++ + class MultiLineHeaderRenderer extends JList implements TableCellRenderer { + public MultiLineHeaderRenderer() { + setOpaque(true); + setForeground(UIManager.getColor("TableHeader.foreground")); + setBackground(UIManager.getColor("TableHeader.background")); + setBorder(UIManager.getBorder("TableHeader.cellBorder")); + ListCellRenderer renderer = getCellRenderer(); + ((JLabel) renderer).setHorizontalAlignment(JLabel.CENTER); + setCellRenderer(renderer); + } + + + + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + setFont(table.getFont()); + String str = (value == null) ? "" : value.toString(); + BufferedReader br = new BufferedReader(new StringReader(str)); + String line; + Vector v = new Vector(); + try { + while ((line = br.readLine()) != null) { + v.addElement(line); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + setListData(v); + return this; + } + + } + + //++++ diff --git a/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEAHandler.java b/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEAHandler.java new file mode 100644 index 0000000..c0196cc --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEAHandler.java @@ -0,0 +1,61 @@ +package com.connor.hs2.plm.PFMEA.design; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class DesignPFMEAHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + +// InputStream input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// Properties pro = new Properties(); +// +// try { +// pro.load(input); +// } catch (IOException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } + if(app.getTargetComponent()==null + ||!(app.getTargetComponent() instanceof TCComponentItemRevision) + || !(app.getTargetComponent().getType().toUpperCase().indexOf("PFMEA") >= 0)) { + MessageBox.post("请选中PFMEA版本对象,请重新选择!", "错误", MessageBox.ERROR); + return null; + } + String UID; + UID=app.getTargetComponent().getUid(); + DesignPFMEACommand command = new DesignPFMEACommand(app, + session,UID); + if(UID==null) { + MessageBox.post("请选择对象!", "错误", MessageBox.ERROR); + return null; + } + //MessageBox.post("dakaizhong ", "错误", MessageBox.ERROR); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("填写PFNEA失败!", "错误", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEAOperation.java b/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEAOperation.java new file mode 100644 index 0000000..7a4c476 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEAOperation.java @@ -0,0 +1,224 @@ +package com.connor.hs2.plm.PFMEA.design; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import javax.swing.JFrame; +import javax.swing.JProgressBar; +import javax.swing.plaf.metal.MetalProgressBarUI; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class DesignPFMEAOperation extends AbstractAIFOperation { + + private TCProperty[] properties; + private TCProperty[] itemProperties; + private InterfaceAIFComponent comp; + private PFMEABean pfmeaBean; + private String[][] dataValue; + private List> dataValueList; + private List plmeidList; + private TCSession session; + private TCComponentItemRevision itemRevision; + private TCComponent meprocess; + private List deleteRows; + private boolean isOwning; + private String UID; + + public DesignPFMEAOperation(TCComponentItemRevision itemRevision, + TCComponent meprocess, TCSession session, TCProperty[] properties, + TCProperty[] itemProperties, PFMEABean pfmeaBean, + List> dataValueList,List plmeidList, + List deleteRows, boolean isOwning,InterfaceAIFComponent comp,String UID) { + this.itemRevision = itemRevision; + this.meprocess = meprocess; + this.session = session; + this.properties = properties; + this.itemProperties = itemProperties; + this.pfmeaBean = pfmeaBean; +// this.dataValue = dataValue; + this.dataValueList = dataValueList; + this.plmeidList = plmeidList; + this.deleteRows = deleteRows; + this.isOwning = isOwning; + this.comp=comp; + this.UID=UID; + } + + @Override + public void executeOperation() throws Exception { + //+++添加进度条 + JFrame frame = new JFrame("正在保存..."); + //frame.setUndecorated(true); // 没有标题栏 + frame.setSize(300, 70); + frame.setLocationRelativeTo(null); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.setLayout(new BorderLayout()); + JProgressBar progressBar = new JProgressBar(); + progressBar.setOrientation(JProgressBar.HORIZONTAL); + progressBar.setSize(300, 50); + progressBar.setMinimum(0); + progressBar.setMaximum(100); + progressBar.setBorderPainted(true); + progressBar.setUI(new MetalProgressBarUI()); + progressBar.setBackground(Color.white); + progressBar.setForeground(Color.green); + progressBar.setStringPainted(true); + frame.setAlwaysOnTop(true); + frame.add(progressBar); + frame.setVisible(true); + //+++ + ResultSet rs = null; + InputStream input = null; + try { + if (isOwning) { + // TMomMethodUtil.setByPass(session, true); + this.itemRevision.lock(); + this.properties[0].setStringValue(this.pfmeaBean.getCompanyName()); + this.properties[1].setStringValue(this.pfmeaBean.getProject()); + this.properties[2].setStringValue(this.pfmeaBean.getAddress()); + this.properties[3].setStringValue(this.pfmeaBean.getPfmeaStartDate()); + this.properties[4].setStringValue(this.pfmeaBean.getPfmeaUpdateDate()); + this.properties[5].setStringValue(this.pfmeaBean.getProcessDuty()); + this.properties[6].setStringValue(this.pfmeaBean.getCustomerName()); + this.properties[7].setStringValue(this.pfmeaBean.getSecurityClassification()); + this.properties[8].setStringValue(this.pfmeaBean.getModelPlatform()); + this.properties[9].setStringValue(this.pfmeaBean.getFunctionalTeams()); + this.properties[10].setStringValue(this.pfmeaBean.getProductCode()); + + this.itemRevision.save(); + this.itemRevision.unlock(); +// this.itemRevision.getItem() +// .getRelatedComponent("IMAN_master_form").lock(); +//// for (int i = 0; i < this.itemProperties.length; i++) { +////// this.itemProperties[i] +////// .setStringValueArray(this.dataValue[i]); +//// } +// this.itemRevision.getItem() +// .getRelatedComponent("IMAN_master_form").save(); +// this.itemRevision.getItem() +// .getRelatedComponent("IMAN_master_form").unlock(); + } + progressBar.setValue(1);//++++ + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + // 获取数据库连接 + // 查询工序编号和ID + String selectSQL = String.format( + pro.getProperty("SETPFMEASELECT2"), meprocess.getUid()); + SqlUtilT.getTCConnection(); + rs = SqlUtilT.read(selectSQL); + Map itemIdMap = new HashMap(); + while (rs.next()) { + itemIdMap.put(rs.getString("REQUIREMENT"), + rs.getString("MEOPID")); + } + //System.out.println("opdeleteRows====>"+deleteRows.toString()); + //System.out.println("opdataValueList====>"+dataValueList.toString()); + // 删除行 + for (int i = 0; i < deleteRows.size(); i++) { + String deleteSQL = String.format( + pro.getProperty("SETPFMEADELETE"), deleteRows.get(i)); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + } + progressBar.setValue(10);//++++ + // 获取数据库连接 + //SqlUtilT.getTCConnection(); + // 往数据库中写入数据 + int Speed=1; + int num2=dataValueList.size()/90; + for (int i = 0; i < dataValueList.size(); i++) { + List rowList = dataValueList.get(i); + if (rowList.get(0) != null && !rowList.get(0).equals("") && plmeidList.contains(rowList.get(0))) { + // 获取数据库连接 + String updateSQL = String.format( + pro.getProperty("SETPFMEAUPDATE"), rowList.get(0),UID); + SqlUtilT.getTCConnection(); + SqlUtilT.update( + new String[] { rowList.get(1), rowList.get(2), + rowList.get(3), rowList.get(4), + rowList.get(5), rowList.get(6), + rowList.get(7), rowList.get(8), + rowList.get(9), rowList.get(10), + rowList.get(11), rowList.get(12), + rowList.get(13), rowList.get(14), + rowList.get(15), rowList.get(16), + rowList.get(17), rowList.get(18), + rowList.get(19), rowList.get(20), + rowList.get(21), rowList.get(22), + rowList.get(23), rowList.get(24), + rowList.get(25), rowList.get(26), + rowList.get(30), rowList.get(31), + rowList.get(32), rowList.get(33), + rowList.get(34), rowList.get(35), + rowList.get(36), rowList.get(37)},updateSQL); + } else if(rowList.get(0) != null && !rowList.get(0).equals("")){ + String insertSQL = pro.getProperty("INSERTPFMEA"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(new String[] { + rowList.get(0), + meprocess.getUid(), itemIdMap.get(rowList.get(4)), + rowList.get(1), rowList.get(2), rowList.get(3), + rowList.get(4), rowList.get(5), rowList.get(6), + rowList.get(7), rowList.get(8), rowList.get(9), + rowList.get(10), rowList.get(11), rowList.get(12), + rowList.get(13), rowList.get(14), rowList.get(15), + rowList.get(16), rowList.get(17), rowList.get(18), + rowList.get(19), rowList.get(20), rowList.get(21), + rowList.get(22), rowList.get(23), rowList.get(25), + rowList.get(26), rowList.get(27), rowList.get(24), + rowList.get(28), rowList.get(29), rowList.get(30), + rowList.get(31), rowList.get(32), rowList.get(33), + rowList.get(34), rowList.get(35), rowList.get(36), + rowList.get(37),UID,rowList.get(rowList.size()-1)}, insertSQL); + System.out.println("++++++++"+insertSQL); + } + if(i==num2*(Speed-9)) { + Speed++; + progressBar.setValue(Speed);//++++ + } + } + progressBar.setValue(100); + frame.setTitle("保存完成"); + frame.dispose(); + SqlUtilT.connection.commit(); + //MessageBox.post("保存成功!", "成功", MessageBox.WARNING); + } catch (Exception e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + throw e; + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/PFMEABean.java b/src/com/connor/hs2/plm/PFMEA/design/PFMEABean.java new file mode 100644 index 0000000..d336a89 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/PFMEABean.java @@ -0,0 +1,152 @@ +package com.connor.hs2.plm.PFMEA.design; + +public class PFMEABean { + + private String companyName; // 公司名称 + private String project; // 项目 + private String address;//制造地址 + private String pfmeaNumber;//pfmea号 + private String pfmeaStartDate;// PFMEA开始日期 + private String pfmeaUpdateDate; // PFMEA修订日期 + private String processDuty; // 过程职责 + private String customerName; // 顾客名称 + private String securityClassification;// 保密级别 + private String modelPlatform;// 车型/平台 + private String functionalTeams;// 跨职能团队 + + private String productCode; + + public String getProductCode() { + return productCode; + } + public void setProductCode(String productCode) { + this.productCode = productCode; + } + //数组属性 + private String[] no;//序号 + private String[] meop;//工序 + private String[] newValue;//修改前的值 + private String[] oldValue;//修改后的值 + private String[] alterDatel;//修改时间 + private String[] change;//修改的内容 + private String[] changeUser;//修改责任人 + + private String expiryDate;//逾期日期 + + + public String[] getNo() { + return no; + } + public void setNo(String[] no) { + this.no = no; + } + public String[] getMeop() { + return meop; + } + public void setMeop(String[] meop) { + this.meop = meop; + } + public String[] getNewValue() { + return newValue; + } + public void setNewValue(String[] newValue) { + this.newValue = newValue; + } + public String[] getOldValue() { + return oldValue; + } + public void setOldValue(String[] oldValue) { + this.oldValue = oldValue; + } + public String[] getAlterDatel() { + return alterDatel; + } + public void setAlterDatel(String[] alterDatel) { + this.alterDatel = alterDatel; + } + public String[] getChange() { + return change; + } + public void setChange(String[] change) { + this.change = change; + } + public String[] getChangeUser() { + return changeUser; + } + public void setChangeUser(String[] changeUser) { + this.changeUser = changeUser; + } + public String getPfmeaNumber() { + return pfmeaNumber; + } + public void setPfmeaNumber(String pfmeaNumber) { + this.pfmeaNumber = pfmeaNumber; + } + public String getExpiryDate() { + return expiryDate; + } + public void setExpiryDate(String expiryDate) { + this.expiryDate = expiryDate; + } + public String getCompanyName() { + return companyName; + } + public void setCompanyName(String companyName) { + this.companyName = companyName; + } + public String getProject() { + return project; + } + public void setProject(String project) { + this.project = project; + } + public String getAddress() { + return address; + } + public void setAddress(String address) { + this.address = address; + } + public String getPfmeaStartDate() { + return pfmeaStartDate; + } + public void setPfmeaStartDate(String pfmeaStartDate) { + this.pfmeaStartDate = pfmeaStartDate; + } + public String getPfmeaUpdateDate() { + return pfmeaUpdateDate; + } + public void setPfmeaUpdateDate(String pfmeaUpdateDate) { + this.pfmeaUpdateDate = pfmeaUpdateDate; + } + public String getProcessDuty() { + return processDuty; + } + public void setProcessDuty(String processDuty) { + this.processDuty = processDuty; + } + public String getCustomerName() { + return customerName; + } + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + public String getSecurityClassification() { + return securityClassification; + } + public void setSecurityClassification(String securityClassification) { + this.securityClassification = securityClassification; + } + public String getModelPlatform() { + return modelPlatform; + } + public void setModelPlatform(String modelPlatform) { + this.modelPlatform = modelPlatform; + } + public String getFunctionalTeams() { + return functionalTeams; + } + public void setFunctionalTeams(String functionalTeams) { + this.functionalTeams = functionalTeams; + } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/Result.java b/src/com/connor/hs2/plm/PFMEA/design/Result.java new file mode 100644 index 0000000..ae915e0 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/Result.java @@ -0,0 +1,60 @@ +package com.connor.hs2.plm.PFMEA.design; + +public class Result { + + private int row1; + private int row2; + private int col1; + private int col2; + private boolean bool = false; + + public Result(boolean bool,int row1,int col1,int row2,int col2) { + this.bool = bool; + this.row1 = row1; + this.col1 = col1; + this.row2 = row2; + this.col2 = col2; + } + + public boolean isBool() { + return bool; + } + + public void setBool(boolean bool) { + this.bool = bool; + } + + public int getRow1() { + return row1; + } + + public void setRow1(int row1) { + this.row1 = row1; + } + + public int getRow2() { + return row2; + } + + public void setRow2(int row2) { + this.row2 = row2; + } + + public int getCol1() { + return col1; + } + + public void setCol1(int col1) { + this.col1 = col1; + } + + public int getCol2() { + return col2; + } + + public void setCol2(int col2) { + this.col2 = col2; + } + + +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/SavePfmea.java b/src/com/connor/hs2/plm/PFMEA/design/SavePfmea.java new file mode 100644 index 0000000..20eb854 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/SavePfmea.java @@ -0,0 +1,181 @@ +package com.connor.hs2.plm.PFMEA.design; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import java.util.UUID; + +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCSession; + +/** + * 保存数据到PFMEA表 + * @author Administrator + * + */ +public class SavePfmea { + + private TCSession session; + private TCComponentItem item; + private InterfaceAIFComponent comp; + private List> properties = new ArrayList>(); + private List> dataList = new ArrayList>();// 表格中的数据 + + public SavePfmea(TCSession session,TCComponentItem item,InterfaceAIFComponent comp) { + // TODO Auto-generated constructor stub + this.session = session; + this.item = item; + this.comp=comp; + } + + public void insertData() { + // TODO Auto-generated method stub + ResultSet rs = null; + ResultSet result = null; + ResultSet resultSet = null; + InputStream input = null; + try { + properties = TMomMethodUtil.getPFMEABomPropertys(session, item); + System.out.println("========>获取到的工序数量为:"+properties.size()+";打印:"+properties.toString()); + String itemUid = item.getUid(); + //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List kzjhList = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// kzjhList.add((TCComponentItem)kzjh[i]); +// } +// } + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + // 查询数据库中的数据 + SqlUtilT.getTCConnection(); + String sql = String.format(pro.getProperty("BOMCHECKSAVESELECTPFMEA"), + itemUid, comp.getUid()); + //System.out.println("sql+++++:"+sql); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("MEOPID") == null ? "" : rs.getString("MEOPID")); + rowList.add(rs.getString("STATION")); + dataList.add(rowList); + } + //System.out.println("sql获取的数据dataList为:"+dataList.toString()); + if (dataList == null || dataList.size() == 0) { + for (int j = 0; j < properties.size(); j++) { + // 插入到PFMEA表 + System.out.println("--------->插入数据"+j+"条"); + SqlUtilT.getTCConnection(); + String insertPFMEA = pro.getProperty("INSERTPFMEA"); + // 插入PFMEA表 + SqlUtilT.getTCConnection(); + SqlUtilT.write(new String[] { + UUID.randomUUID().toString().replace("-", ""), + itemUid, properties.get(j).get(0), "","","", + (properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2)), "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "","","","","","","","","" ,comp.getUid(),properties.get(j).get(4)}, + insertPFMEA); + //+++ + } + }else { + + // 添加工序 + // 查询数据库中的数据 + result = SqlUtilT.read(sql); + List indexList = new ArrayList(); + while (result.next()) { + indexList.add(result.getString("MEOPID")); + } + for (int i = 0; i < properties.size(); i++) { + if (!indexList.contains(properties.get(i).get(0))) { + // 插入到PFMEA表 + String insertPFMEA = pro.getProperty("INSERTPFMEA"); + // 插入PFMEA表 +// SqlUtilT.write(new String[] { +// UUID.randomUUID().toString().replace("-", ""), +// itemUid, properties.get(i).get(0), +// properties.get(i).get(1), +// properties.get(i).get(2).indexOf("/") >=0 ? properties.get(i).get(2).replace("/", "\n") : properties.get(i).get(2), "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", "","","","","","","","","",comp.getUid() }, +// insertPFMEA); + //+++ + SqlUtilT.getTCConnection(); + SqlUtilT.write(new String[] { + UUID.randomUUID().toString().replace("-", ""), + itemUid, properties.get(i).get(0), "","", "", + properties.get(i).get(1)+(properties.get(i).get(2).indexOf("/") >=0 ? properties.get(i).get(2).replace("/", "\n") : properties.get(i).get(2)), "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "","","","","","","","","",comp.getUid(),properties.get(i).get(4) }, + insertPFMEA); + //+++ + + } + } + // 删除表中相应的工序 + StringBuffer sb = new StringBuffer(); + sb.append("("); + if(properties.size()>0) { + for (int i = 0; i < properties.size(); i++) { + sb.append("\'" + properties.get(i).get(0) + "\',"); + } + }else { + sb.append("\'" +"0"+ "\',");//如果没一个工序类,就直接全清空 + } + // 获取数据库连接 + SqlUtilT.getTCConnection(); + String selectSql = String + .format(pro.getProperty("BOMCHECKSAVESELECTPFMEA2"), + itemUid, + sb.toString().substring(0, sb.length() - 1) + + ")"); + resultSet = SqlUtilT.read(selectSql); + List deleteList = new ArrayList(); + while (resultSet.next()) { + deleteList.add(resultSet.getString("MEOPID")); + } + if (deleteList != null && deleteList.size() > 0) { + for (int i = 0; i < deleteList.size(); i++) { + SqlUtilT.getTCConnection(); + String deleteSQL = String.format( + pro.getProperty("DELETEPFMEA"), deleteList.get(i), + itemUid); + SqlUtilT.delete(deleteSQL); + } + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (result != null) { + SqlUtilT.free(result); + } + if (resultSet != null) { + SqlUtilT.free(resultSet); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/SqlUtilT.java b/src/com/connor/hs2/plm/PFMEA/design/SqlUtilT.java new file mode 100644 index 0000000..c1a22ab --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/SqlUtilT.java @@ -0,0 +1,708 @@ +package com.connor.hs2.plm.PFMEA.design; + +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 com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +/** + * 防止误继承因此是final类,防止误建对象因此用私有构造方法,为方便使用类名短小, PreparedStatement对象名和ResultSet对象名短小 + * + * @author hub 2015-02-06 + */ +public final class SqlUtilT { + public static Connection connection = null; + public static PreparedStatement ps = null; + public static ResultSet rs = null; + + // private static Registry reg = Registry.getRegistry(SqlUtilT.class); + /** + * 私有构造器不能new对象,防止误用对象 + */ + private SqlUtilT() { + + } + + static { + String driver = "oracle.jdbc.driver.OracleDriver"; // Util.getProperties("DRIVER"); + if (driver == null) { + driver = "oracle.jdbc.driver.OracleDriver"; + } + + System.out.println("driver " + driver); + try { + Class.forName(driver); + } catch (ClassNotFoundException e) { + System.out.println("ORACEL DRIVER IS EXCEPTION"); + e.printStackTrace(); + } + } + + /** + * 链接数据库 + */ + public static Connection getConnectionTC12() { + try { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCPreferenceService service = session.getPreferenceService(); + String[] array = service.getStringArray( + TCPreferenceService.TC_preference_site, "TC12_Oracle_MSG"); + String driver_temp = null; + String url = null; + String dbName = null; + String dbPassword = null; + if (array != null) + for (String str : array) { + System.out.println(" ORACLE = " + str); + if (str != null && str.startsWith("ORACEL_DRIVER=")) { + driver_temp = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null && str.startsWith("ORACEL_URL=")) { + url = str.substring(str.indexOf("=") + 1, str.length()); + } else if (str != null && str.startsWith("ORACEL_NAME=")) { + dbName = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null + && str.startsWith("ORACEL_PASSWORD=")) { + dbPassword = str.substring(str.indexOf("=") + 1, + str.length()); + } + } + // String driver_temp = reg.getString("ORACEL_DRIVER"); + // String url = reg.getString("ORACEL_URL");// getProperties("URL"); + // String dbName = reg.getString("ORACEL_NAME");// + // Util.getProperties("dbName"); + // String dbPassword = reg.getString("ORACEL_PASSWORD");// + // Util.getProperties("dbPassword"); + + if (driver_temp == null || url == null || dbName == null + || dbPassword == null) { + + MessageBox.post("请检查数据库首选项是否配置正确", "错误提示", MessageBox.ERROR); + + } + // else{ + // MessageBox.post(driver_temp+" | "+url+" | "+dbName+" | "+dbPassword,"错误提示",MessageBox.ERROR); + // + // } + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + return null; + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + } + return connection; + } + + /** + * 链接数据库 + */ + public static Connection getConnectionTC() { + try { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCPreferenceService service = session.getPreferenceService(); + String[] array = service.getStringArray( + TCPreferenceService.TC_preference_site, "TC_Oracel_MSG"); + String driver_temp = null; + String url = null; + String dbName = null; + String dbPassword = null; + if (array != null) + for (String str : array) { + System.out.println(" ORACLE = " + str); + if (str != null && str.startsWith("ORACEL_DRIVER=")) { + driver_temp = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null && str.startsWith("ORACEL_URL=")) { + url = str.substring(str.indexOf("=") + 1, str.length()); + } else if (str != null && str.startsWith("ORACEL_NAME=")) { + dbName = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null + && str.startsWith("ORACEL_PASSWORD=")) { + dbPassword = str.substring(str.indexOf("=") + 1, + str.length()); + } + } + // String driver_temp = reg.getString("ORACEL_DRIVER"); + // String url = reg.getString("ORACEL_URL");// getProperties("URL"); + // String dbName = reg.getString("ORACEL_NAME");// + // Util.getProperties("dbName"); + // String dbPassword = reg.getString("ORACEL_PASSWORD");// + // Util.getProperties("dbPassword"); + + if (driver_temp == null || url == null || dbName == null + || dbPassword == null) { + + MessageBox.post("请检查数据库首选项是否配置正确", "错误提示", MessageBox.ERROR); + + } + // else{ + // MessageBox.post(driver_temp+" | "+url+" | "+dbName+" | "+dbPassword,"错误提示",MessageBox.ERROR); + // + // } + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + return null; + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + } + return connection; + } + + /** + * 链接数据库 + */ + public static Connection getConnection() { + try { + String driver_temp = "oracle.jdbc.driver.OracleDriver"; + String url = "jdbc:oracle:thin:@192.168.1.248:1521:TOPPROD";// getProperties("URL"); + String dbName = "jfgroup";// Util.getProperties("dbName"); + String dbPassword = "jfgroup";// Util.getProperties("dbPassword"); + + /* + * if(driver_temp == null ||url==null|| dbName == null ||dbPassword + * == null ){ + * + * MessageBox.post("请检查数据库首选项是否配置正确","错误提示",MessageBox.ERROR); + * + * } + */ + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + return null; + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + } + return connection; + } + + /** + * 链接数据库 + */ + public static Connection getConnection(String url, String dbName, + String dbPassword) { + try { + String driver_temp = "oracle.jdbc.driver.OracleDriver"; + + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + // MessageBox.post("MSG ==>"+url + dbName + dbPassword,"",1); + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + MessageBox.post(" MSG = >" + e.getMessage(), "222", 1); + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + return null; + } + return connection; + } + + /** + * 链接TC数据库 + */ + public static Connection getTCConnection() { + try { + if(connection == null || connection.isClosed()) + { + SqlUtilT.getConnectionTC12(); +// SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10","tc10", "infodba"); + } + } catch (Exception e) { + // MessageBox.post("MSG ==>"+url + dbName + dbPassword,"",1); + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + MessageBox.post(" MSG = >" + e.getMessage(), "222", 1); + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + return null; + } + return connection; + } + + /** + * 拼接SELECT 语句 + * + * @param tableName + * @param selectElement + * @param args + * @return + */ + public static String getSelectSql(String tableName, String[] selectElement, + String... args) { + StringBuffer valuesSB = new StringBuffer("SELECT "); + if (selectElement != null) { + for (String element : selectElement) { + valuesSB.append(element).append(","); + } + valuesSB.delete(valuesSB.length() - 1, valuesSB.length()); + } + valuesSB.append(" FROM "); + valuesSB.append(tableName); + valuesSB.append(" WHERE"); + for (int i = 0; i < args.length; i++) { + valuesSB.append(" "); + valuesSB.append(args[i]); + valuesSB.append("=? "); + valuesSB.append("AND"); + } + + valuesSB.delete(valuesSB.length() - 3, valuesSB.length()); + return valuesSB.toString(); + } + + /** + * 拼接SELECT 语句 + * + * @param tableName + * @param args + * @return + */ + public static String getSelectSql(String tableName, String... args) { + StringBuffer valuesSB = new StringBuffer("SELECT * FROM "); + valuesSB.append(tableName); + valuesSB.append(" WHERE"); + for (int i = 0; i < args.length; i++) { + valuesSB.append(" "); + valuesSB.append(args[i]); + valuesSB.append("=? "); + valuesSB.append("AND"); + } + + valuesSB.delete(valuesSB.length() - 3, valuesSB.length()); + return valuesSB.toString(); + } + + /** + * 拼接更新语句 + * + * @param tableName + * @param args + * @param args2 + * @return + */ + public static String getUpdataSQL(String tableName, String[] args, + String[] args2) { + StringBuffer updateSB = new StringBuffer("UPDATE "); + updateSB.append(tableName); + updateSB.append(" SET "); + // 拼接更新语句 + for (int i = 0; i < args.length; i++) { + if (args[i].toUpperCase().equals("CREATED_DATE") + || args[i].toUpperCase().equals("LAST_UPDATE_DATE")) { + updateSB.append(args[i]).append( + "=to_date(?,'yyyy-MM-dd HH24:mi:ss') ,"); + } else { + updateSB.append(args[i]).append("=? ,"); + } + } + updateSB.delete(updateSB.length() - 2, updateSB.length()); + ; + updateSB.append(" WHERE "); + for (int i = 0; i < args2.length; i++) { + updateSB.append(args2[i]).append("=? AND "); + } + updateSB.delete(updateSB.length() - 4, updateSB.length()); + return updateSB.toString(); + } + + /** + * 拼接SQL的insert语句 + * + * @param tableName + * @param args + * @return + */ + public static String getInsertSql(String tableName, String... args) { + StringBuffer insertSql = new StringBuffer("insert into "); + StringBuffer values = new StringBuffer("values("); + + if (tableName != null && args != null && args.length > 0) { + insertSql.append(tableName); + insertSql.append("("); + for (int i = 0; i < args.length; i++) { + insertSql.append(args[i]); + insertSql.append(", "); + if (args[i].toUpperCase().equals("LAST_UPDATE_DATE") + || args[i].toUpperCase().equals("CREATED_DATE")) { + values.append("to_date(?,'yyyy-MM-dd HH24:mi:ss'), "); + } else { + values.append("?, "); + } + + } + } else { + return null; + } + insertSql.delete(insertSql.length() - 2, insertSql.length()); + values.delete(values.length() - 2, values.length()); + insertSql.append(") ").append(values).append(")"); + return insertSql.toString(); + } + + /** + * 得到创建表格数据库语句 + * + * @param tableName + * @param args + * 参数的名称 + * @param args2 + * 参数的类型 + * @return 拼接后的创建数据库的语句 + */ + public final static String GetCreateTableSQL(String tableName, + String[] args, String[] args2) { + + if (args == null || args2 == null || args.length != args2.length) { + System.out.println("THE INPUT PRAGREMS IS ERROR"); + return null; + } + StringBuffer createSQL = new StringBuffer("create table "); + createSQL.append(tableName); + createSQL.append("("); + for (int i = 0; i < args.length; i++) { + createSQL.append(args[i] + " "); + createSQL.append(args2[i] + ", "); + } + createSQL.delete(createSQL.length() - 2, createSQL.length()); + createSQL.append(")"); + return createSQL.toString(); + } + + /** + * 得到Statement + */ + public final static PreparedStatement getPs(String sql) throws SQLException { + return getPs(sql, null); + } + + /** + * 得到Statement + */ + public final static PreparedStatement getPs(Object[] argments, String sql) + throws SQLException { + return getPs(sql, argments); + } + + /** + * 得到Statement + */ + public final static PreparedStatement getPs(String sql, Object[] argments) + throws SQLException { + SqlUtilT.ps = SqlUtilT.connection.prepareStatement(sql,ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY); + SqlUtilT.ps.setFetchSize(1000); + SqlUtilT.ps.setFetchDirection(ResultSet.FETCH_REVERSE); + + if (argments != null) { + for (int i = 0; i < argments.length; i++) { + SqlUtilT.ps.setObject(i + 1, argments[i]); + } + } + return SqlUtilT.ps; + } + + /** + * 增加 + */ + public final static int write(String sql) { + return write(sql, null); + } + + /** + * 增加 + */ + public final static int write(Object[] argments, String sql) { + return write(sql, argments); + } + + /** + * 增加 + */ + public final static int write2(Object[] argments, String sql) { + return write2(sql, argments); + } + + /** + * 增加 + */ + public final static int write(String sql, Object[] argments) { + + return update(sql, argments); + } + + /** + * 增加 + */ + public final static int write2(String sql, Object[] argments) { + + return update2(sql, argments); + } + + /** + * 删除 + */ + public final static int delete(String sql) { + return delete(sql, null); + } + + /** + * 删除 + */ + public final static int delete(Object[] argments, String sql) { + return delete(sql, argments); + } + + /** + * 删除 + */ + public final static int delete(String sql, Object[] argments) { + return update(sql, argments); + } + + /** + * 删除 + */ + public final static int delete2(String sql) { + int i = -1; + try { + i = SqlUtilT.getPs(null,sql).executeUpdate(); + SqlUtilT.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } + return i; + } + + /** + * 修改 + */ + public final static int update(String sql) { + return update(sql, null); + } + + /** + * 修改 + */ + public final static int update(String[] argments, String sql) { + return update(sql, argments); + } + + /** + * 修改(增删改最终都要调用此方法,此处进行异常处理,关闭除Connection以外的对象),不提交事务 + */ + public final static int update2(String sql, Object[] argments) { + int i = -1; + try { + PreparedStatement statement=null; + while(statement==null) { + statement=SqlUtilT.getPs(argments, sql); + if(statement==null) { + getTCConnection(); + System.out.println("+++++++++++++++++statement为空"); + } + } + i = statement.executeUpdate(); + //i = SqlUtilT.getPs(argments, sql).executeUpdate(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtilT.rs, SqlUtilT.ps); + } + return i; + } + + /** + * 修改(增删改最终都要调用此方法,此处进行异常处理,关闭除Connection以为的对象) + */ + public final static int update(String sql, Object[] argments) { + int i = -1; + try { + PreparedStatement statement=null; + while(statement==null) { + statement=SqlUtilT.getPs(argments, sql); + if(statement==null) { + getTCConnection(); + System.out.println("+++++++++++++++++statement为空"); + } + } + i = statement.executeUpdate(); + //i = SqlUtilT.getPs(argments, sql).executeUpdate(); + SqlUtilT.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtilT.rs, SqlUtilT.ps); + } + return i; + } + + /** + * 查询 + */ + public final static ResultSet read(String sql) throws SQLException { + return read(sql, null); + } + + /** + * 查询 + */ + public final static ResultSet read(Object[] argments, String sql) + throws SQLException { + return read(sql, argments); + } + + /** + * 查询(所有查询最终都要调用此方法,方法里面不处理异常,抛出后由调用者处理,方便在finally语句中释放资源) + * + * @throws SQLException + */ + public final static ResultSet read(String sql, Object[] argments) + throws SQLException { + return SqlUtilT.rs = SqlUtilT.getPs(argments, sql).executeQuery(); + } + + /** + * 创建表 + */ + public final static boolean createTable(String sql) { + return go(sql, null); + } + + /** + * 删除表 + */ + public final static boolean dropTable(String sql) { + return go(sql, null); + } + + /** + * 修改表 + */ + public final static boolean alterTable(String sql) { + return go(sql, null); + } + + /** + * 此方法用来执行DDL语句(创建表,修改表,删除表) + */ + private final static boolean go(String sql, Object[] argments) { + boolean flag = false; + try { + flag = SqlUtilT.getPs(sql, argments).execute(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtilT.rs, SqlUtilT.ps); + } + if (flag) { + try { + SqlUtilT.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return flag; + } + + /** + * 释放资源 + */ + public final static void free(ResultSet resultSet) { + free(resultSet, null, null); + } + + /** + * 释放资源 + */ + public final static void free(Statement statement) { + free(null, statement, null); + } + + /** + * 释放资源 + */ + public final static void free(Connection connection) { + free(null, null, connection); + } + + /** + * 释放资源 + */ + public final static void free(ResultSet resultSet, Statement statement) { + free(resultSet, statement, null); + } + + /** + * 释放资源 + */ + public final static void free(Statement statement, Connection connection) { + free(null, statement, connection); + } + + /** + * 释放资源(不传参数默认部分) + */ + public final static void free() { + free(SqlUtilT.rs, SqlUtilT.ps); + } + + /** + * 释放资源(全部释放) + */ + public final static void freeAll() { + free(SqlUtilT.rs, SqlUtilT.ps, SqlUtilT.connection); + } + + /** + * 释放资源(传满参数也要全部释放) + */ + public final static void free(ResultSet resultSet, Statement statement, + Connection connection) { + try { + if (resultSet != null) { + try { + resultSet.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + try { + if (statement != null) { + try { + statement.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + if (connection != null) { + try { + connection.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + } +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/TMomMethodUtil.java b/src/com/connor/hs2/plm/PFMEA/design/TMomMethodUtil.java new file mode 100644 index 0000000..3a944c1 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/TMomMethodUtil.java @@ -0,0 +1,1197 @@ +package com.connor.hs2.plm.PFMEA.design; + +import java.io.File; +import java.io.IOException; +import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentProcess; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCComponentType; +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.TCQueryClause; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.FileUtility; +import com.teamcenter.rac.util.MessageBox; + +public class TMomMethodUtil { + + private static List> bomPropertyList = new ArrayList>(); + + public static void main(String[] args) { + String str = "123|1234|123124"; + System.out.println(str.split("\\|").length); + } + + /** + * 判断获取的对象是否全部为ITEM + * + * @param comps + * 需要判断的目标对象 + * @param isNotIgor + * 是否需要忽略,如果TRUE 则不能忽略,如果FALSE 则可以忽略 + * + * @param isSameType + * 是否要求是相同的类型,如果TRUE 要求必须是相同的类型 + * @return + */ + public static List getItemList( + InterfaceAIFComponent[] comps, Boolean isNotIgor, Boolean isSameType) { + if (comps == null) { + + return null; + } + List itemList = new ArrayList(); + String type = null; + for (int i = 0; i < comps.length; i++) { + if (comps[i] instanceof TCComponentItem) { + if (isSameType) { + if (type == null) { + type = comps[i].getType(); + } else if (!type.equals(comps[i].getType())) { + return null; + } + } + itemList.add((TCComponentItem) comps[i]); + } else if (isNotIgor) { + return null; + } + } + return itemList; + } + +// /** +// * 获取模板文件 +// * @param session session +// * @param fileName 文件名 +// * @param Filetype 文件类型 +// * @return +// */ + public static File getFile(TCSession session,String fileName,String Filetype) { + // TODO Auto-generated method stub + try { + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues("PROCESS_MODEL_FILE"); + if (modelFiles == null) + { + System.out.println("未找到首选项"); + return null; + } + String puid = ""; + for (int i = 0; i < modelFiles.length; i++) { + if(modelFiles[i].split("-")[0].equals(fileName)) + { + puid = modelFiles[i].split("-")[1]; + } + } + TCComponentItem fileItem = (TCComponentItem)session + .stringToComponent(puid); + TCComponentDataset dat = null; + TCComponentItemRevision fileItemLastRev = fileItem.getLatestItemRevision(); + TCComponent[] comps = fileItemLastRev.getReferenceListProperty("IMAN_specification"); + System.out.println("count =" + comps == null ? "null" + : comps.length); + // 遍历TC_Attaches关系下的所有对象 + for (TCComponent compt : comps) { + // 获取对象类型 + String type = compt.getType(); + System.out.println(" TYPE = " + type); + // 判断类型 + if (type.equals(type)) { + dat = (TCComponentDataset)compt; + } + } + TCComponentTcFile[] tcFile = dat.getTcFiles(); + if(tcFile != null && tcFile.length == 0) + { + System.out.println("未找到配置文件"); + } + else + { + return tcFile[0].getFmsFile(); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } + /** + * 获取最新的已发布的版本 + * @param item + * @return + */ +// public static TCComponentItemRevision getLastItemRevision(TCComponentItem item) { +// // TODO Auto-generated method stub +// try { +// TCComponentItemRevision[] items = item.getReleasedItemRevisions(); +// int revId = 0; +// TCComponentItemRevision itemRevision = null; +// for (int i = 0; i < items.length; i++) { +// String revisionId = items[i].getStringProperty("item_revision_id"); +// if(letterToNumber(revisionId) >= revId ) +// { +// itemRevision = items[i]; +// revId = letterToNumber(revisionId); +// } +// } +// return itemRevision; +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return null; +// } + + public static int letterToNumber(String letter) { + int length = letter.length(); + int num = 0; + int number = 0; + for(int i = 0; i < length; i++) { + char ch = letter.charAt(length - i - 1); + num = (int)(ch - 'A' + 1) ; + num *= Math.pow(26, i); + number += num; + } + return number; + } + + /** + * 获取版本对象 + * + * @param comps + * 需要判断的目标对象 + * @param isNotIgor + * 是否需要忽略,如果TRUE 则不能忽略,如果FALSE 则可以忽略 + * + * @param isSameType + * 是否要求是相同的类型,如果TRUE 要求必须是相同的类型 + * @return + */ + public static List getItemRevList( + InterfaceAIFComponent[] comps, Boolean isNotIgor, Boolean isSameType) { + if (comps == null) { + + return null; + } + List itemList = new ArrayList(); + + String type = null; + for (int i = 0; i < comps.length; i++) { + if (comps[i] instanceof TCComponentItemRevision) { + + if (isSameType) { + if (type == null) { + type = comps[i].getType(); + } else if (!type.equals(comps[i].getType())) { + return null; + } + } + itemList.add((TCComponentItemRevision) comps[i]); + } else if (isNotIgor) { + return null; + } + } + return itemList; + } + + /** + * 获取存放的文件夹 + * + * @param item + * @param name + * @return + */ + public static TCComponentFolder getParentFolder(TCComponentItem item, + String name) { + TCComponentFolder folder = null; + try { + AIFComponentContext[] comtexts = item.whereReferenced(); + if (comtexts != null) { + for (int i = 0; i < comtexts.length; i++) { + if (comtexts[i].getComponent() instanceof TCComponentFolder) { + String nameT = ((TCComponentFolder) comtexts[i] + .getComponent()) + .getStringProperty("object_name"); + if (name.equals("工艺图纸") && nameT.equals("工艺图纸")) { + folder = (TCComponentFolder) comtexts[i] + .getComponent(); + } + else if(nameT.equals(name)) + { + folder = (TCComponentFolder) comtexts[i] + .getComponent(); + } + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return folder; + } + + /** + * 获取存在的ITEM的个数 + * + * @param session + * 会话 + * @param oldItemID + * 旧编码 + * @return + */ + public static Integer getItemCount(TCSession session, String oldItemID) { + Integer count = 0; + InterfaceAIFComponent[] comps = searchComponentsCollection(session, + "Connor_TMom_Query_Item", new String[] { "item_id" }, + new String[] { oldItemID }); + if (comps == null) { + return null; + } + count = comps.length; + return count; + } + + /** + * 工艺生成新的ID + * + * @param oldItemID + * @return + */ + public static String getGyRuleID(TCSession session, String oldItemID) { + DecimalFormat df = new DecimalFormat("000"); + String newID = oldItemID + "_P001"; + Integer count = 0; + // String idTemp = + TCComponentItemType tccomponentitemtype; + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("Item")); + + tccomponentitemtype.getNewID(); + int i = 1; + //setByPass(session,true); + while (tccomponentitemtype.find(newID) != null) { + i++; + newID = oldItemID + "_P" + df.format(i); + } + // setByPass(session,false); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newID; + } + + + /** + * 工序生成新ID + * + * @param oldItemID + * @return + */ + public static String getGxRuleID(TCSession session, String oldItemID) { + TCComponentItemType tccomponentitemtype; + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("MEOP")); + + return tccomponentitemtype.getNewID(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return ""; + } + + /** + * 通过查询,查找符合条件的版本 + * + * @param session + * 会话 + * @param searchName + * 查询名称 + * @param keys + * 查询关键字 + * @param values + * 查询值 + * @return + */ + 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); + if (query == null) { + MessageBox.post("通过查询构建器" + searchName + "不存在", "错误", 1); + return null; + } + 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(); + TCQueryClause[] clauses = query.describe(); + 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) { + e.printStackTrace(); + MessageBox.post("通过查询构建器" + searchName + "查询发生错误.", "错误", 1); + } + + return result; + } + /** + * 自定义文件名下载文件 + * + * @param comps + * @return + * @throws TCException + * @throws IOException + */ + + public static String downLoadFiles(TCComponent comp,String Titles,String URL,Boolean flag) { + if (comp == null) { + return ""; + } + String value = ""; + String tempPath = System.getenv("TEMP"); + // MessageBox.post(" tempPath = + // "+tempPath,"INFO",MessageBox.INFORMATION); + if (tempPath == null) { + tempPath = ""; + } else if (!tempPath.endsWith("\\")) { + tempPath = tempPath + "\\"; + } + + // MessageBox.post(" tempPath = "+tempPath,"INFO",MessageBox.INFORMATION); + // MessageBox.post(" URL = "+URL,"INFO",MessageBox.INFORMATION); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + // for(TCComponent comp : comps){ + try { + if (comp instanceof TCComponentDataset) { + TCComponentTcFile[] tcFiles = ((TCComponentDataset) comp) + .getTcFiles(); + File file = null; + if (tcFiles != null && tcFiles.length != 0) { + file = tcFiles[0].getFmsFile(); + String fileName = file.getName(); + String fileDix = fileName.substring( + fileName.lastIndexOf("."), fileName.length()); + if (flag == true) + { + if ((URL != "")&&(URL != " ")&&(URL != null)) + { + fileName = URL + Titles + fileDix; + } + else + { + fileName = tempPath + Titles + fileDix; + } + } + else + { + fileName = tempPath + sdf.format(new Date()) + fileDix; + } + File dirFile = new File(fileName); + FileUtility.copyFile(file, dirFile); + + return fileName; + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // } + return value; + } + + + + + + /** + * 下载文件 + * + * @param comps + * @return + * @throws TCException + * @throws IOException + */ + public static String downLoadFile(TCComponent comp) { + if (comp == null) { + return ""; + } + String value = ""; + String tempPath = System.getenv("TEMP"); + // MessageBox.post(" tempPath = + // "+tempPath,"INFO",MessageBox.INFORMATION); + if (tempPath == null) { + tempPath = ""; + } else if (!tempPath.endsWith("\\")) { + tempPath = tempPath + "\\"; + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + // for(TCComponent comp : comps){ + try { + if (comp instanceof TCComponentDataset) { + TCComponentTcFile[] tcFiles = ((TCComponentDataset) comp) + .getTcFiles(); + File file = null; + if (tcFiles != null && tcFiles.length != 0) { + file = tcFiles[0].getFmsFile(); + String fileName = file.getName(); + String fileDix = fileName.substring( + fileName.lastIndexOf("."), fileName.length()); + fileName = tempPath + sdf.format(new Date()) + fileDix; + File dirFile = new File(fileName); + FileUtility.copyFile(file, dirFile); + + return fileName; + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // } + return value; + } + + /*** + * 获取首选项 + * + * @param session + * 会话 + * @param preferenceName + * 首选项名称 + * @return + */ + public static String[] getPreferenceValues(String preferenceName) { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + if (preferenceName == null || session == null) { + System.out.println(""); + return null; + } + String[] values = null; + TCPreferenceService service = session.getPreferenceService(); + values = service.getStringArray(TCPreferenceService.TC_preference_site, + preferenceName); + String[] resultValues = new String[values.length]; + for (int i = 0; i < values.length; i++) { + if(values[i].indexOf("\\n") >= 0) + { + resultValues[i] = values[i].replace("\\n", "\n"); + } + else + { + resultValues[i] = values[i]; + } + } + return resultValues; + } + + /** + * 删除文件 + * + * @param filePathList + * 文件地址 + */ + public static void deleteFile(List filePathList) { + for (int i = 0; i < filePathList.size(); i++) { + File file = new File(filePathList.get(i)); + if (file.exists() && file.isFile()) { + if (file.delete()) { + System.out.println("文件" + filePathList.get(i) + "已删除!"); + } + } + } + } + + /** + * 旁路 + * + * @param session + * @param val + * @throws TCException + */ + public static void setByPass(TCSession session, boolean val) + throws TCException { + + TCUserService userservice = session.getUserService(); + + Object[] obj = new Object[1]; + obj[0] = ""; + if (val) { + userservice.call("Connor_set_bypass", obj); + } else { + userservice.call("Connor_close_bypass", obj); + } + } + /** + * 转换合并单元格 + * @param regionCell + * @param row + * @return + */ + public static String getCombineCell(Map regionCell, int row) { + Iterator> it = regionCell.entrySet().iterator(); + StringBuffer sb = new StringBuffer(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + StringBuffer rowSb = new StringBuffer(); + StringBuffer columnSb = new StringBuffer(); + for (int k = 0; k < entry.getKey().length; k++) { + rowSb.append(entry.getKey()[k]); + rowSb.append(","); + } + for (int k = 0; k < entry.getValue().length; k++) { + columnSb.append(entry.getValue()[k]); + columnSb.append(","); + } + if (entry.getKey()[0] == row) { + sb.append(rowSb.substring(0, rowSb.length() - 1)+ "/"+ columnSb.substring(0,columnSb.length() - 1)+"-"); + } + } + if(sb.length() > 0) + { + return sb.toString().substring(0, sb.length()-1); + } + else + { + return ""; + } + } + + /** + * 通知流程 + * + * @param session + * @param val + * @throws TCException + */ + public static void setProcess(TCSession session, + TCComponentProcess process, TCComponentUser user) + throws TCException { + + TCUserService userservice = session.getUserService(); + + Object[] obj = new Object[2]; + obj[0] = process; + obj[1] = user; + userservice.call("TMOM_meop_tongzhi", obj); + } + + /** + * 获取PFMEA BOM属性 + */ + public static List> getPFMEABomPropertys(TCSession session, TCComponentItem item) { + // TODO Auto-generated method stub + //获取BOM + TCComponentBOMWindow bomWindow = null; + bomPropertyList.clear(); + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List itme = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// itme.add((TCComponentItem)kzjh[i]); +// } +// } + getBomPropertys(topBomLine, true); + return bomPropertyList; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } +// public static List> getPFMEABomPropertys(TCSession session, TCComponentItem item) { +// // TODO Auto-generated method stub +// //获取BOM +// TCComponentBOMWindow bomWindow = null; +// try { +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session +// .getTypeComponent("BOMWindow"); +// bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, +// item.getLatestItemRevision(), null, null); +// //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List itme = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// itme.add((TCComponentItem)kzjh[i]); +// } +// } +// // 获取工序对象 +// AIFComponentContext aif[] = topBomLine.getChildren(); +// List> properties = new ArrayList>(); +// for (int i = 0; i < aif.length; i++) { +// TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] +// .getComponent(); +// if(subline.getStringProperty("RB3_is_hide") != null && subline.getStringProperty("RB3_is_hide").equals("true")) +// { +// continue; +// } +// List propertie = new ArrayList(); +// propertie +// .add(subline.getStringProperty("bl_indented_title") +// .split("/")[0]); +// propertie.add(subline.getStringProperty("bl_sequence_no")); +// propertie +// .add(subline +// .getStringProperty("bl_item_object_name") == null ? "" +// : subline +// .getStringProperty("bl_item_object_name")); +// //获取工序下的BOM +// List equipmentNameList = new ArrayList(); +// if(subline.getChildren().length>0) +// { +// for (int j = 0; j < subline.getChildren().length; j++) { +// TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] +// .getComponent(); +// System.out.println(subChildrenline.getType()); +// if(subChildrenline.getType().indexOf("Equipment") >= 0) +// { +// TCComponentICO[] icos = subChildrenline.getItem().getLatestItemRevision() +// .getClassificationObjects(); +// if (icos.length > 0) { +// ICSProperty[] descriptions = icos[0] +// .getICSProperties(true); +// for (int k = 0; k < descriptions.length; k++) { +// if (descriptions[k].getId() == 1004 && descriptions[k].getValue() != null +// && !descriptions[k].getValue().equals("")) { +// System.out.println(equipmentNameList.toString()); +// if(!equipmentNameList.contains(descriptions[k].getValue())) +// { +// equipmentNameList.add(descriptions[k].getValue()); +// } +// System.out.println(equipmentNameList.toString()); +// //sb.append(descriptions[k].getValue()+","); +// +// } +// } +// } +// } +// } +// } +// if(equipmentNameList.size() > 0) +// { +// propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); +// } +// else +// { +// propertie.add(""); +// } +// properties.add(propertie); +// } +// return properties; +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// return null; +// } + + /** + * 获取BOM属性 + */ + public static List> getBomPropertys(TCSession session, TCComponentItem item) { + // TODO Auto-generated method stub + bomPropertyList.clear(); + //获取BOM + TCComponentBOMWindow bomWindow = null; + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + //获取工艺下的控制计划对象 + TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); + List itme = new ArrayList(); + for (int i = 0; i < kzjh.length; i++) { + if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) + { + itme.add((TCComponentItem)kzjh[i]); + } + } + getBomPropertys(topBomLine, false); + return bomPropertyList; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } +// public static List> getBomPropertys(TCSession session, TCComponentItem item) { +// // TODO Auto-generated method stub +// //获取BOM +// TCComponentBOMWindow bomWindow = null; +// try { +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session +// .getTypeComponent("BOMWindow"); +// bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, +// item.getLatestItemRevision(), null, null); +// //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List itme = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// itme.add((TCComponentItem)kzjh[i]); +// } +// } +// // 获取工序对象 +// AIFComponentContext aif[] = topBomLine.getChildren(); +// List> properties = new ArrayList>(); +// for (int i = 0; i < aif.length; i++) { +// TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] +// .getComponent(); +// List propertie = new ArrayList(); +// propertie +// .add(subline.getStringProperty("bl_indented_title") +// .split("/")[0]); +// propertie.add(subline.getStringProperty("bl_sequence_no")); +// propertie +// .add(subline +// .getStringProperty("bl_item_object_name") == null ? "" +// : subline +// .getStringProperty("bl_item_object_name")); +// //获取工序下的BOM +// List equipmentNameList = new ArrayList(); +// if(subline.getChildren().length>0) +// { +// for (int j = 0; j < subline.getChildren().length; j++) { +// TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] +// .getComponent(); +// System.out.println(subChildrenline.getType()); +// if(subChildrenline.getType().indexOf("Equipment") >= 0) +// { +// TCComponentICO[] icos = subChildrenline.getItem().getLatestItemRevision() +// .getClassificationObjects(); +// if (icos.length > 0) { +// ICSProperty[] descriptions = icos[0] +// .getICSProperties(true); +// for (int k = 0; k < descriptions.length; k++) { +// if (descriptions[k].getId() == 1004 && descriptions[k].getValue() != null +// && !descriptions[k].getValue().equals("")) { +// System.out.println(equipmentNameList.toString()); +// if(!equipmentNameList.contains(descriptions[k].getValue())) +// { +// equipmentNameList.add(descriptions[k].getValue()); +// } +// System.out.println(equipmentNameList.toString()); +// //sb.append(descriptions[k].getValue()+","); +// +// } +// } +// } +// } +// } +// } +// if(equipmentNameList.size() > 0) +// { +// propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); +// } +// else +// { +// propertie.add(""); +// } +// properties.add(propertie); +// } +// return properties; +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// return null; +// } + /** + * 获取插入到权限表的BOM行 + * @param session + * @param item + * @return + */ + public static List> getPermissionsBomPropertys(TCSession session, TCComponentItem item) { + // TODO Auto-generated method stub + //获取BOM + TCComponentBOMWindow bomWindow = null; + + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + //获取工艺下的控制计划对象 + TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); + List itme = new ArrayList(); + for (int i = 0; i < kzjh.length; i++) { + if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) + { + itme.add((TCComponentItem)kzjh[i]); + } + } + // 获取工序对象 + AIFComponentContext aif[] = topBomLine.getChildren(); + List> properties = new ArrayList>(); + for (int i = 0; i < aif.length; i++) { + if(((TCComponentBOMLine)aif[i].getComponent()).getItem().getType().equals("MEProcess")) + { + continue; + } + TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] + .getComponent(); + List propertie = new ArrayList(); + propertie + .add(subline.getStringProperty("bl_indented_title") + .split("/")[0]); + propertie.add(subline.getStringProperty("bl_sequence_no")); + + String objectName = subline.getStringProperty("bl_item_object_name") == null ? "" + : subline.getStringProperty("bl_item_object_name"); + if(objectName.indexOf("/") >= 0) + { + propertie.add(objectName.split("/")[0]); + } + else + { + propertie.add(objectName); + } + //+++获取工序号 + propertie.add(subline.getStringProperty("RB3_GXH")); + //+++ + //获取工序下的BOM + List equipmentNameList = new ArrayList(); + if(subline.getChildren().length>0) + { + for (int j = 0; j < subline.getChildren().length; j++) { + TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] + .getComponent(); + System.out.println(subChildrenline.getType()); + //if(subChildrenline.getType().indexOf("Equipment") >= 0) + //{ + equipmentNameList.add(subChildrenline.getItem().getStringProperty("item_id")); +// TCComponentICO[] icos = subChildrenline.getItem().getLatestItemRevision() +// .getClassificationObjects(); +// +// if (icos.length > 0) { +// ICSProperty[] descriptions = icos[0] +// .getICSProperties(true); +// for (int k = 0; k < descriptions.length; k++) { +// if (descriptions[k].getId() == 1004 && descriptions[k].getValue() != null +// && !descriptions[k].getValue().equals("")) { +// System.out.println(equipmentNameList.toString()); +// if(!equipmentNameList.contains(descriptions[k].getValue())) +// { +// equipmentNameList.add(descriptions[k].getValue()); +// } +// System.out.println(equipmentNameList.toString()); +// //sb.append(descriptions[k].getValue()+","); +// +// } +// } +// } + //} + } + } + if(equipmentNameList.size() > 0) + { + propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); + } + else + { + propertie.add(""); + } + properties.add(propertie); + } + return properties; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } + + /** + * 获取BOM信息 + * @param meprocess 工艺BOMLINE + * @param isMeop 是否是PFEMA + * + */ + public static void getBomPropertys(TCComponentBOMLine meprocessBomLine, boolean isPFEMA) + { + try { + //获取工艺下的BOM + AIFComponentContext aif[] = meprocessBomLine.getChildren(); + for (int i = 0; i < aif.length; i++) { + if(aif[i]==null) {//防止 + continue; + } + TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] + .getComponent(); + if(subline==null) { + continue; + } + + TCComponentItem item = subline.getItem(); + + System.out.println("type ==> "+item.getType()); + + //判断是否是工艺 + if(item.getType().equals("HS2_ProductMEP")||item.getType().equals("HS2_AssemblyMEP")|| + item.getType().equals("HS2_SpecialMEP")||item.getType().equals("HS2_ProcessMEP")) //.getType().equals("MEProcess") + { + getBomPropertys(subline, isPFEMA); + } + else if(item.getType().equals("HS2_MEOP")) + { + List propertie = new ArrayList(); + //String ss = subline.getStringProperty("bl_indented_title"); + propertie.add(subline.getStringProperty("bl_indented_title") + .split("/")[0]); + //控制计划中的零件/工艺编号改为工序号 + //propertie.add(subline.getStringProperty("bl_sequence_no")); + propertie.add(subline.getStringProperty("bl_sequence_no")==null ? "": + subline.getStringProperty("bl_sequence_no")); + String bzString = subline.getStringProperty("bl_item_object_name") == null ? "": subline.getStringProperty("bl_item_object_name"); + String processNo = subline.getStringProperty("hs2_ProcessNo") == null ? "": subline.getStringProperty("hs2_ProcessNo"); + propertie.add(processNo+bzString); + + //获取工序下的BOM的资源,机器设备。PFMEA跳过 + if(isPFEMA) + { + propertie.add(""); + }else { + List equipmentNameList = new ArrayList(); + if(subline.getChildren().length>0) + { + for (int j = 0; j < subline.getChildren().length; j++) { + TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] + .getComponent(); + if(subChildrenline.toString().equals("<<无法读取>>")&&subChildrenline!=null) {//防止工艺资源出错,无权限读取 + continue; + } + System.out.println(subChildrenline.getType()); + String ClassID=subChildrenline.getItemRevision().getClassificationClass(); + if(ClassID!=null&&!ClassID.equals("")&&ClassID.length()>2) { + if(ClassID.substring(0,2).equals("15")) { + equipmentNameList.add(subChildrenline.getItem().getStringProperty("object_name")); + } + } + + } + } + if(equipmentNameList.size() > 0) + { + propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); + } + else + { + propertie.add(""); + } + } + propertie.add(String.valueOf(bomPropertyList.size()+1)); + bomPropertyList.add(propertie); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /*** + * 根据正则表达式提取括号中的内容 + * @param value + * @return + */ + public static List getListByRegular(String value) + { + List resultList = new ArrayList(); + Pattern p = Pattern.compile("(\\[[^\\]]*\\])"); + Matcher m = p.matcher(value); + while(m.find()) + { + resultList.add(m.group().substring(1, m.group().length() - 1)); + } + return resultList; + } + + public static int getDays(String dateStr1, String dateStr2, String dateFormat) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat); + Date date1 = null; + Date date2 = null; + try { + date1 = simpleDateFormat.parse(dateStr1); + date2 = simpleDateFormat.parse(dateStr2); + } catch (ParseException e) { + e.printStackTrace(); + } + + String year1 = String.format("%tY", date1); + String mon1 = String.format("%tm", date1); + String day1 = String.format("%td", date1); + int y1 = Integer.valueOf(year1); + int m1 = Integer.valueOf(mon1); + int d1 = Integer.valueOf(day1); + int days1 = getRecentYearDays(y1, m1, d1); + System.out.println(days1); + + String year2 = String.format("%tY", date2); + String mon2 = String.format("%tm", date2); + String day2 = String.format("%td", date2); + int y2 = Integer.valueOf(year2); + int m2 = Integer.valueOf(mon2); + int d2 = Integer.valueOf(day2); + int days2 = getRecentYearDays(y2, m2, d2); + System.out.println(days2); + + int count = 0; + for (int i = y1; i < y2; i++) { + if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0) { + count += 366; + } else { + count += 365; + } + } + count = count + days2 - days1; + + return count; + } + + public static int getRecentYearDays(int y, int m, int d) { + + int count = 0; + + switch (m - 1) { + case 1: + count += 31; + break; + case 2: + count += 31 + 28; + break; + case 3: + count += 31 + 28 + 31; + break; + case 4: + count += 31 + 28 + 31 + 30; + break; + case 5: + count += 31 + 28 + 31 + 30 + 31; + break; + case 6: + count += 31 + 28 + 31 + 30 + 31 + 30; + break; + case 7: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31; + break; + case 8: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31; + break; + case 9: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30; + break; + case 10: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31; + break; + case 11: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30; + break; + } + if (((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) && m > 2) + count++; + return count + d; + } + +// public static ControlPlanComboBoxBean[] getComboxItem(TCSession session,String pernaem) +// { +// ControlPlanComboBoxBean[] comboBoxBeans = null; +// TCPreferenceService pref = session.getPreferenceService(); +// String[] items = pref.getStringValues(pernaem);// 首选项查puid +// comboBoxBeans = new ControlPlanComboBoxBean[items.length]; +// for (int i = 0; i < items.length; i++) { +// if(items[i].indexOf("-")>0) +// { +// ControlPlanComboBoxBean bean = new ControlPlanComboBoxBean(); +// bean.setItemId(items[i].split("-")[0]); +// bean.setItemName(items[i].split("-")[1]); +// comboBoxBeans[i] = bean; +// } +// } +// return comboBoxBeans; +// } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/TableCellTextAreaRenderer.java b/src/com/connor/hs2/plm/PFMEA/design/TableCellTextAreaRenderer.java new file mode 100644 index 0000000..b713e7e --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/TableCellTextAreaRenderer.java @@ -0,0 +1,220 @@ +package com.connor.hs2.plm.PFMEA.design; + +import java.awt.Color; +import java.awt.Component; +import java.util.List; +import java.util.Map; + +import javax.swing.JTable; +import javax.swing.JTextPane; +import javax.swing.table.TableCellRenderer; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +public class TableCellTextAreaRenderer extends JTextPane implements + TableCellRenderer { + private List processRows; + private Map> labelRows;//标注行 + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + public Map> getLabelRows() { + return labelRows; + } + + public void setLabelRows(Map> labelRows) { + this.labelRows = labelRows; + } + + public TableCellTextAreaRenderer() { + // setLineWrap(true);//自动换行 + // setWrapStyleWord(true); + + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + int maxPreferredHeight = 0; + if (table.getColumnName(column).equals("RPN")) { + // 5,9,11 + String yzd = table.getValueAt(row, 6) == null ? "0" : table + .getValueAt(row, 6).toString(); + String pds = table.getValueAt(row, 10) == null ? "0" : table + .getValueAt(row, 10).toString(); + String tcd = table.getValueAt(row, 12) == null ? "0" : table + .getValueAt(row, 12).toString(); + int rpn = Integer.parseInt(yzd) * Integer.parseInt(pds) + * Integer.parseInt(tcd); + if (rpn == 0) { + table.setValueAt("", row, column); + setText(""); + } else { + table.setValueAt(String.valueOf(rpn), row, column); + setText(String.valueOf(rpn)); + } + } else { + setText(value == null ? "" : value.toString()); + } + // //特殊符号 + // if(table.getValueAt(row, table.getColumnCount()-1) != null) + // { + // String special = table.getValueAt(row, + // table.getColumnCount()-1).toString(); + // if(special.indexOf("|") >= 0) + // { + // String[] specials = special.split("\\|"); + // for (int i = 0; i < specials.length; i++) { + // if(specials[i].indexOf("-") >= 0) + // { + // String[] columnName = specials[i].split("-"); + // if(table.getColumnName(column).equals(columnName[0])) + // { + // setTextFont(value.toString(),Integer.parseInt(columnName[1]) + // ,"Y14.5M"); + // } + // } + // } + // } + // else if(special.indexOf("-") >= 0) + // { + // String[] columnName = special.split("-"); + // if(table.getColumnName(column).equals(columnName[0])) + // { + // setTextFont(value.toString(),Integer.parseInt(columnName[1]) + // ,"Y14.5M"); + // } + // } + // } + + for (int i = 0; i < table.getColumnCount(); i++) { + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, + getPreferredSize().height); + } + if (table.getColumnName(column).equals("RPN") && value != null + && !value.equals("") + && Integer.parseInt(value.toString()) >= 100) { + setBackground(Color.RED); + setForeground(Color.black); + } + else if (processRows == null || processRows.size() <= 0 + || !processRows.contains(row)) { + setBackground(new Color(220,220,220)); + setForeground(Color.black); + + } + else { + setBackground(Color.white); + setForeground(Color.black); + } + if (labelRows != null && labelRows.keySet().contains(row)) { + if(labelRows.get(row).contains(((Integer)column).toString())) + { + setBackground(Color.RED); + setForeground(Color.black); + } + } +// else if (row == table.getSelectedRow()) { +// setBackground(Color.GRAY); +// setForeground(Color.black); +// } else if (column == table.getSelectedColumn()) { +// setBackground(Color.GRAY); +// setForeground(Color.black); +// } + + //判断单元格选中并且为可修改状态 + if (isSelected) { + // setBackground(new Color(0, 120, 215)); + setBackground(new Color(184,184,184)); + setForeground(Color.black); + } + if (table.getRowHeight(row) != maxPreferredHeight)// 少了这行则处理器瞎忙 + { + table.setRowHeight(row, maxPreferredHeight); + } + return this; + } + + // 设置字体,如一个字符串中需要包含多个字体样式,可创建多个SimpleAttributeSet,并将字符串拆分开,按顺序使用Document的insertString方法插入 + private void setTextFont(String value, int index, String font) { + // TODO Auto-generated method stub + SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set, font);// 设置字体样式 + SimpleAttributeSet set2 = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set2, "Courier New");// 设置字体样式 + // StyleConstants.setFontSize(set2, 10); + Document doc = this.getStyledDocument(); + try { + // 插入前需要先删除 + doc.remove(0, value.toString().length()); + value = value.replaceAll(" ", ""); + doc.insertString(doc.getLength(), + value.toString().substring(0, index), set2); + doc.insertString(doc.getLength(), + value.toString().substring(index, index + 1), set); + doc.insertString( + doc.getLength(), + value.toString().substring(index + 1, + value.toString().length()), set2); + if (value.toString() + .substring(index + 1, value.toString().length()) == null + || value.toString() + .substring(index + 1, value.toString().length()) + .equals("")) { + doc.insertString(doc.getLength(), " ", set2); + } + } catch (BadLocationException e) { + e.printStackTrace(); + } finally { + set = null; + doc = null; + System.gc(); + } + } + // + // @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; + // } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/TableCellTextAreaRenderer2.java b/src/com/connor/hs2/plm/PFMEA/design/TableCellTextAreaRenderer2.java new file mode 100644 index 0000000..6a11ec6 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/TableCellTextAreaRenderer2.java @@ -0,0 +1,159 @@ +package com.connor.hs2.plm.PFMEA.design; + +import java.awt.Color; +import java.awt.Component; +import java.util.List; + +import javax.swing.JTable; +import javax.swing.JTextPane; +import javax.swing.table.TableCellRenderer; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +import com.teamcenter.rac.util.MessageBox; + +public class TableCellTextAreaRenderer2 extends JTextPane implements + TableCellRenderer { + private List processRows; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + public TableCellTextAreaRenderer2() { + // setLineWrap(true);//自动换行 + // setWrapStyleWord(true); + + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + int maxPreferredHeight = 0; + if (row > 0 && table.getColumnName(column).equals("RPN")) { + // 5,9,11 + String yzd = table.getValueAt(row, 6) == null ? "0" : table + .getValueAt(row, 6).toString(); + String pds = table.getValueAt(row, 10) == null ? "0" : table + .getValueAt(row, 10).toString(); + String tcd = table.getValueAt(row, 12) == null ? "0" : table + .getValueAt(row, 12).toString(); + int rpn = Integer.parseInt(yzd) * Integer.parseInt(pds) + * Integer.parseInt(tcd); + if (rpn == 0) { + table.setValueAt("", row, column); + setText(""); + } else { + table.setValueAt(String.valueOf(rpn), row, column); + setText(String.valueOf(rpn)); + } + } else { + setText(value == null ? "" : value.toString()); + } + + for (int i = 0; i < table.getColumnCount(); i++) { + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, + getPreferredSize().height); + } + if (row > 0 && table.getColumnName(column).equals("RPN") + && value != null && !value.equals("") + && Integer.parseInt(value.toString()) >= 100) { + setBackground(Color.RED); + setForeground(Color.black); + } + else if (isSelected) { + setBackground(Color.GRAY); + setForeground(Color.black); + } else { + setBackground(Color.white); + setForeground(Color.black); + } + if (table.getRowHeight(row) != maxPreferredHeight)// 少了这行则处理器瞎忙 + { + table.setRowHeight(row, maxPreferredHeight); + } + return this; + } + + // 设置字体,如一个字符串中需要包含多个字体样式,可创建多个SimpleAttributeSet,并将字符串拆分开,按顺序使用Document的insertString方法插入 + private void setTextFont(String value, int index, String font) { + // TODO Auto-generated method stub + SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set, font);// 设置字体样式 + SimpleAttributeSet set2 = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set2, "Courier New");// 设置字体样式 + // StyleConstants.setFontSize(set2, 10); + Document doc = this.getStyledDocument(); + try { + // 插入前需要先删除 + doc.remove(0, value.toString().length()); + value = value.replaceAll(" ", ""); + doc.insertString(doc.getLength(), + value.toString().substring(0, index), set2); + doc.insertString(doc.getLength(), + value.toString().substring(index, index + 1), set); + doc.insertString( + doc.getLength(), + value.toString().substring(index + 1, + value.toString().length()), set2); + if (value.toString() + .substring(index + 1, value.toString().length()) == null + || value.toString() + .substring(index + 1, value.toString().length()) + .equals("")) { + doc.insertString(doc.getLength(), " ", set2); + } + } catch (BadLocationException e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } finally { + set = null; + doc = null; + System.gc(); + } + } + // + // @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/hs2/plm/PFMEA/design/TreeBean.java b/src/com/connor/hs2/plm/PFMEA/design/TreeBean.java new file mode 100644 index 0000000..7ae0223 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/TreeBean.java @@ -0,0 +1,77 @@ +package com.connor.hs2.plm.PFMEA.design; +import java.util.List; + + +public class TreeBean { + private String plmeid; + private String id; + private String P1; + private String P2; + private String P3; + private String P4; + private String P5; + private String name; + private String parentId; + private List chidrenBeans; + public String getPlmeid() { + return plmeid; + } + public void setPlmeid(String plmeid) { + this.plmeid = plmeid; + } + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getP1() { + return P1; + } + public void setP1(String P1) { + this.P1 = P1; + } + public String getP2() { + return P2; + } + public void setP2(String P2) { + this.P2 = P2; + } + public String getP3() { + return P3; + } + public void setP3(String P3) { + this.P3 = P3; + } + public String getP4() { + return P4; + } + public void setP4(String P4) { + this.P4 = P4; + } + public String getP5() { + return P5; + } + public void setP5(String P5) { + this.P5 = P5; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getParentId() { + return parentId; + } + public void setParentId(String parentId) { + this.parentId = parentId; + } + public List getChidrenBeans() { + return chidrenBeans; + } + public void setChidrenBeans(List chidrenBeans) { + this.chidrenBeans = chidrenBeans; + } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/sql.properties b/src/com/connor/hs2/plm/PFMEA/design/sql.properties new file mode 100644 index 0000000..bda2428 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/sql.properties @@ -0,0 +1,37 @@ +SETPFMEASELECT=SELECT * FROM AHMC_PFMEA WHERE PROCESSPUID = \'%s\' AND REVISIONID=\'%s\' ORDER BY to_number(NO),to_number(HH) +PFMEALIBRARYSELECT2=SELECT * FROM AHMC_PFMEALIBRARY WHERE PUID = \'%s\' order by NUM + +BOMCHECKSAVESELECTPFMEA=select MEOPID,STATION,gybh,GCMC from AHMC_PFMEA where PROCESSPUID = \'%s\'REVISIONID=\'%s\' + +BOMCHECKSAVESELECTPFMEA2=select * from AHMC_PFMEA where PROCESSPUID = \'%s\' and MEOPID not in %s + +DELETEPFMEA=delete from AHMC_PFMEA where MEOPID = \'%s\' and PROCESSPUID = \'%s\' + +INSERTPFMEA=INSERT INTO AHMC_PFMEA VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + +PFMEALIBRARYSELECT=SELECT * FROM AHMC_PFMEA_NODE WHERE PARENT_ID = \'%s\' order BY ID +SETPFMEASELECT2=SELECT MEOPID,REQUIREMENT from AHMC_PFMEA where PROCESSPUID = \'%s\' group by MEOPID,REQUIREMENT +SETPFMEADELETE=delete from AHMC_PFMEA where PLMEID = \'%s\' + +SETPFMEAUPDATE=update AHMC_PFMEA set GYBH = ?,GCMC = ?,STATION = ?,REQUIREMENT = ?,QZSXMS = ?,QZSXHG = ?,YZD = ?,JB = ?,QZSXQY = ?,XXGCKZYF = ?,PDS = ?,XXGCKZTC = ?,TCD = ?,RPN = ?,JYCS = ?,ZZR = ?,JHWCRQ = ?,CQDCS = ?,NEW_SEV = ?,NEW_OCC = ?,NEW_DET = ?,NEW_RPN = ?,IDEAL_STATE = ?,SPECIAL = ?,HH = ?,HBDYG = ? ,OCCURRRENCE = ?,DETECTION = ?,PRIORITY = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ? where plmeid = \'%s\' AND revisionid=\'%s\' +TM2PFMEATREESELECT=select * from AHMC_PFMEA_TREE ORDER BY PARENT_ID,ID + +CONTROLPLANLIBRARYSELECT=SELECT * FROM AHMC_CONTROLPLAN_NODE WHERE PARENT_ID = \'%s\' order BY ID + +TM2CONTROLPLANTREESELECT=select * from AHMC_CONTROLPLAN_TREE ORDER BY TO_NUMBER(PARENT_ID) + +TM2THESAURUSTREESELECT=select * from AHMC_THESAURUS_TREE ORDER BY TO_NUMBER(PARENT_ID) + +TM2THESAURUSNODESELECT=SELECT * FROM AHMC_THESAURUS_NODE WHERE PARENT_ID = \'%s\' order BY ID + +PFMEALIBRARYUPDATE=update AHMC_PFMEA_NODE set ID = ?, STATION = ?,REQUIREMENT = ?,QZSXMS = ?,QZSXHG = ?,YZD = ?,JB = ?,QZSXQY = ?,XXGCKZYF = ?,PDS = ?,XXGCKZTC = ?,TCD = ?,RPN = ?,JYCS = ?,ZZR = ?,JHWCRQ = ?,CQDCS = ?,NEW_SEV = ?,NEW_OCC = ?,NEW_DET = ?,NEW_RPN = ?,IDEAL_STATE = ?,SPECIAL = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ?,P6 = ?,P7 = ?,P8 = ? where plmeid = \'%s\' + +PFMEALIBRARYDELETE=delete from AHMC_PFMEA_NODE where PLMEID = \'%s\' + +PFMEALIBRARYINSERT=INSERT INTO AHMC_PFMEA_NODE VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + + +SELECTFRAMESIZE=select * from AHMC_PFMEAFRAME_SIZE WHERE USERNAME = \'%s\' AND TYPE = \'%s\' +FRAMESIZEINSERT=INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?) +FRAMESIZEDELETE=DELETE FROM AHMC_PFMEAFRAME_SIZE WHERE USERNAME = \'%s\' AND TYPE = \'%s\' +FRAMESIZEUPDATE=update AHMC_PFMEAFRAME_SIZE set FRAMESIZE = ?, TABLE1SIZE = ?, TABLE2SIZE = ? WHERE USERNAME = \'%s\' AND TYPE = \'%s\' \ No newline at end of file diff --git a/src/com/connor/hs2/plm/PFMEA/design/utils.java b/src/com/connor/hs2/plm/PFMEA/design/utils.java new file mode 100644 index 0000000..97d2ff9 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/utils.java @@ -0,0 +1,307 @@ +package com.connor.hs2.plm.PFMEA.design; + +import java.awt.image.BufferedImage; +import java.io.BufferedInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import javax.imageio.ImageIO; +import javax.swing.JComboBox; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.ClientAnchor; +import org.apache.poi.ss.usermodel.Drawing; +import org.apache.poi.ss.usermodel.Picture; +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.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFClientAnchor; +import org.apache.poi.xssf.usermodel.XSSFShape; + +import com.teamcenter.rac.common.lov.LOVComboBox; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.services.rac.core.LOVService; +import com.teamcenter.services.rac.core._2013_05.LOV.InitialLovData; +import com.teamcenter.services.rac.core._2013_05.LOV.LOVSearchResults; +import com.teamcenter.services.rac.core._2013_05.LOV.LOVValueRow; +import com.teamcenter.services.rac.core._2013_05.LOV.LovFilterData; + +public class utils { + + public static void main(String[] args) { + String value = "12345"; + Integer valueOf = Integer.valueOf(value)*10; + String newName = String.format("%04d", valueOf); + String substring = newName.substring(0,4); + System.out.println(substring); + } + + public static void dymanicLov(TCSession session,TCComponentListOfValues lov,JComboBox lovComboBox) { +// System.out.println("动态lovName=" + lovName); + + LOVService lovService = LOVService.getService(session); + InitialLovData input = new InitialLovData(); + LovFilterData filter = new LovFilterData(); + filter.sortPropertyName = ""; // lov的后台值 + filter.order = 1; + filter.numberToReturn = 10000; + filter.maxResults = 10000; + + input.lov = lov; + input.filterData = filter; + LOVSearchResults result = lovService.getInitialLOVValues(input); +// LOVSearchResults + System.out.println("动态lov数量" + result.lovValues.length); + for (LOVValueRow row : result.lovValues) { + Map map = row.propDisplayValues; + String disval = ""; + String xsVal = ""; + String key1 = "r9_WLZ";// 显示值第一列 + for(String key : map.keySet()) { + lovComboBox.addItem(map.get(key)[0]); +// System.out.println(""); + } + } + } + public static String TCGetPropertyValue(TCComponentBOMLine bomLine,String type,String propertyName,String propertyValue) throws TCException + { + //判断是否包含.号 + if (propertyName.contains(".")) + { + //根据等号拆分条件和值 +// char ** itemPropertyChar = new char *[64]; +// //分割字符串 +// split(propertyName, ".", itemPropertyChar, &itemPropertyCount); + + String[] split = propertyName.split("\\."); + String itemAddress = split[0]; +// char * itemAddress = itemPropertyChar[0]; + + if (type.equals("Bomline")) + { +// tag_t revisions = NULLTAG; + TCComponent item=null; +// AOM_ask_value_tag(item, "bl_line_object", &revisions); + //传进来的是对象 + if (itemAddress.equals("item")) + { +// ITEM_ask_item_of_rev(revisions, &item); + item = bomLine.getItem(); + } + else if (itemAddress.equals("rev")) + { + item = bomLine.getItemRevision(); + } + else if (itemAddress.equals("revMaster")) + { + TCComponentItemRevision revision= bomLine.getItemRevision(); + TCComponent revMaster = revision.getRelatedComponent("IMAN_master_form_rev"); + if(revMaster!=null) { + item=revMaster; + } + }else { + item=bomLine; + } + //判断拆分出的数量是否大于2 + if (split.length > 2) + { + //遍历查找关系对象 + for (int i = 1; i < split.length - 1; i++) + { +// item.get +// AOM_ask_value_tag(item, itemPropertyChar[i], &item); + } + } + if (item == null) + { + propertyValue = ""; + } + else + { + try { + propertyValue = item.getStringProperty(split[split.length-1]); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + } + else + { + propertyValue = propertyName; + } + + return propertyValue; + } + + public static void reSetRowHeight(Workbook wb,Sheet sheet,int startRow,int endRow,int[] columnNum) { + int picWidth = 1856 * 2;//图片宽度 + int picHeight = 710; + int t3 = (int)(picHeight/15);//图片占单元格高度 + + for(int i = startRow;i0) { + tempcolwid /= 2; + int t = (int)(rowHeight/15); + int t2 = (int)(tempcolwid/32); + System.out.println("t="+t); + System.out.println("t2="+t2); + anchor.setCol1(col); + anchor.setCol2(col); + anchor.setRow1(row); + anchor.setRow2(row2); + anchor.setDx1(9525 * t2); + anchor.setDx2(9525 * (t2+t4)); + if(row+1==row2) {//单行 + System.out.println("单行"); +// anchor.setDy1(XSSFShape.EMU_PER_PIXEL * 100); + anchor.setDy1(9525 * (t/2+t7/2)); +// anchor.setDy2(XSSFShape.EMU_PER_PIXEL * 1); + anchor.setDy2(9525 * -1*(t/2-t7/2-t3)); + }else {//多行合并 + System.out.println("多行"); + int tempRow = row; + int row1Height = 0; + row1Height = sheet.getRow(tempRow).getHeight(); + int t9 = (int)(row1Height/15); + do { + if(t9>(t/2+t7/2)||tempRow==row2)break; + tempRow++; + row1Height = sheet.getRow(tempRow).getHeight(); + t9 +=(int)(row1Height/15); + }while(true); + if(tempRow == row2)System.out.println("第"+row+"行,第"+col+"列未找到合适的行!"); + anchor.setRow1(tempRow); + anchor.setRow2(tempRow+1); + System.out.println("临时行:"+tempRow); + System.out.println("临时行高度:"+row1Height/15); +// anchor.setDy1(XSSFShape.EMU_PER_PIXEL * 150); +// anchor.setDy2(XSSFShape.EMU_PER_PIXEL * 500); + anchor.setDy1(9525 * (t9-t/2-t7/2)); + anchor.setDy2(9525 * (t3+t9-t/2-t7/2-row1Height/15)); + } +// anchor.setDy1(XSSFShape.EMU_PER_PIXEL * (t - t2/2)); +// anchor.setDy2(XSSFShape.EMU_PER_PIXEL * (-1*t + t2/2)); + } + System.out.println("y1="+anchor.getDy1()); + System.out.println("y2="+anchor.getDy2()); + + anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE); + Picture picture = drawing.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG)); +// picture.resize(1d); + } + public static Result isMergedRegion(Sheet sheet,int row,int column){ + int sheetMergeCount=sheet.getNumMergedRegions(); + for(int i=0;i=firstRow&&row<=lastRow){ + if(column>=firstColumn&&column<=lastColumn){ + return new Result(true, firstRow, firstColumn, lastRow, lastColumn); + } + } + } + return new Result(false, 0, 0, 0, 0); + + } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/library/LibraryCommand.java b/src/com/connor/hs2/plm/PFMEA/library/LibraryCommand.java new file mode 100644 index 0000000..223539b --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/library/LibraryCommand.java @@ -0,0 +1,320 @@ +package com.connor.hs2.plm.PFMEA.library; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Properties; + +import javax.swing.table.DefaultTableModel; + +import com.connor.hs2.plm.PFMEA.design.SqlUtilT; +import com.connor.hs2.plm.PFMEA.design.TreeBean; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCSession; +public class LibraryCommand extends AbstractAIFCommand { + + private TCSession session; + private AbstractAIFApplication app; + private String commandId; + private String titleName = "PFMEA库"; + private String titleLabel = "潜在失效模式及后果分析"; + private InterfaceAIFComponent comp; + private TCComponent form; + private boolean isOwning = false; + // private List> processRowList = new + // ArrayList>(); + private TCComponentUser user;// 当前登录用户 + private List> dataList = new ArrayList>();// 表格中的数据 + private List beans = new ArrayList(); + private TreeBean bean; + private Properties pro = new Properties(); +// private String[] header = new String[] {"PLMEID","序号", +// "1. 过程项" +// + "系统、子系统、零件要素或过程名称", +// "2. 过程步骤" +// + "工位编号和关注要素名称", +// "3. 过程工作要素 4M法", +// "1.过程项的功能" +// + "系统、子系统、组件要素或过程的功能", +// "2.过程步骤的功能和产品特性" +// + "(量值为可选项)", +// "3.过程工作要素的功能和过程特性", +// "1.对上一较高级别要和/或终端用户失效影响(FE)", +// "失效影响的严重度(S)", +// "2.关注要素的失效模式(FM)", +// "3.工作要素的失效起因(FC)", +// "对失效起因的当前预防控制(PC)", +// "失效起因的频度(O)", +// "对失效起因或失效模式的当前探测控制(DC)", +// "失效起因/失效模式的可探测度(D)", +// "PFMEA措施优先级", +// "产品特性", +// "筛选器代码(可选)", +// "预防措施", +// "探测措施", +// "负责人姓名", +// "目标完成日期", +// "状态", +// "采取基于证据的措施" , +// "完成日期", +// "严重度(S)Severity(S)", +// "频度(O)Occurrence(O)", +// "可探测度(D)Detection(D)", +// "产品特性", +// "PFMEA AP ", +// "备注", "父节点ID"}; + private String[] header = new String[] {"PLMEID","问题" + , "历史/变更授\n权(适用时)", + "1. 过程项", + "2. 过程步骤", + "3. 过程工作要素", + "1.过程项的功能", + "2.过程步骤的功能和产品特性", + "3.过程工作要素的功能和过程特性", + "1.失效影响(FE)", + "严重度(S)", + "2.作业步骤的失效模式(FM)", + "3.工作要素的失效起因(FC)", + "现行预防控制(PC)", + "发生度(O)", + "现行探测控制(DC)", + "探测度(D)", + "AP", + "特殊特性", + "筛选器代码(选填)", + "预防措施", + "探测措施", + "负责人", + "目标完成时间", + "状态", + "采取基于证据的措施" , + "实际完成时间", + "S", + "O", + "D", + "特殊特性", + "AP ", + "备注", "父节点ID"}; + + public LibraryCommand() { + super(); + } + + public LibraryCommand(AbstractAIFApplication app, + TCSession session, String commandId) { + this.session = session; + this.app = app; + this.commandId = commandId; + this.comp = app.getTargetComponent(); + this.user = session.getUser(); + } + + /** + * 获取数据库中的数据 + */ + private void getData() { + // TODO Auto-generated method stub + ResultSet rs = null; + try { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + String sql = String.format(pro + .getProperty("TM2PFMEATREESELECT")); + rs = SqlUtilT.read(sql); + while (rs.next()) { + TreeBean bean = new TreeBean(); + bean.setPlmeid(rs.getString("PLMEID")); + bean.setId(rs.getString("ID")); + bean.setName(rs.getString("NAME")); + bean.setParentId(rs.getString("PARENT_ID")); + beans.add(bean); + } + + Collections.sort(beans, new NaturalOrderComparator<>(true)); + beans.forEach(item -> System.out.println(item)); + //createTabbedPane(beans); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + } + + } + + class NaturalOrderComparator implements Comparator { + + private final boolean caseInsensitive; + + public NaturalOrderComparator(boolean caseInsensitive) { + this.caseInsensitive = caseInsensitive; + } + + private int compareRight(String a, String b) { + int bias = 0; + int ia = 0; + int ib = 0; + for (; ; ia++, ib++) { + char ca = charAt(a, ia); + char cb = charAt(b, ib); + + if (!Character.isDigit(ca) && !Character.isDigit(cb)) { + return bias; + } else if (!Character.isDigit(ca)) { + return -1; + } else if (!Character.isDigit(cb)) { + return +1; + } else if (ca < cb) { + if (bias == 0) { + bias = -1; + } + } else if (ca > cb) { + if (bias == 0) { + bias = +1; + } + } else if (ca == 0 && cb == 0) { + return bias; + } + } + } + + @Override + public int compare(T o1, T o2) { + + TreeBean bean1 = (TreeBean)o1; + TreeBean bean2 = (TreeBean)o2; + + String a = bean1.getId(); + String b = bean2.getId(); + int ia = 0, ib = 0; + int nza = 0, nzb = 0; + char ca, cb; + int result; + while (true) { + nza = nzb = 0; + ca = charAt(a, ia); + cb = charAt(b, ib); + + while (ca == '0') { + nza++; + if (!Character.isDigit(charAt(a, ia + 1))) { + break; + } + ca = charAt(a, ++ia); + } + while (cb == '0') { + nzb++; + if (!Character.isDigit(charAt(b, ib + 1))) { + break; + } + cb = charAt(b, ++ib); + } + + if (Character.isDigit(ca) && Character.isDigit(cb)) { + if ((result = compareRight(a.substring(ia), b.substring(ib))) != 0) { + return result; + } + } + if (ca == 0 && cb == 0) { + return nza - nzb; + } + if (ca < cb) { + return -1; + } else if (ca > cb) { + return +1; + } + ++ia; + ++ib; + } + } + + private char charAt(String s, int i) { + if (i >= s.length()) { + return 0; + } else { + return caseInsensitive ? Character.toUpperCase(s.charAt(i)) : s.charAt(i); + } + } + } + + // Jtable通用方法 + public CTable getNewjTable(CTable partsTable, DefaultTableModel dtm, + Object[] titleNames, int rows) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + CTMap map = new CTMap(rows, titleNames.length); + map.setColumnIdentifiers(titleNames); + map.setEditable(true); + partsTable = new CTable(map); + partsTable.setRowHeight(50); + partsTable.HiddenCell(0); + // 隐藏列 + partsTable.HiddenCell(titleNames.length - 1); + partsTable.HiddenCell(titleNames.length - 2); + // 设置显示器渲染 + // TableCellTextAreaRenderer renderer = new + // TableCellTextAreaRenderer(); + // partsTable.setDefaultRenderer(Object.class, renderer); + // partsTable.setRowHeight(1, 50); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i) + .setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + @Override + public void executeModal() throws Exception { + // 获取版本表单的所有者 + InputStream input = null; + try { + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + pro.load(input); + // 获取树形结构节点 + getData(); + new Thread() { + @Override + public void run() { + LibraryDialog dialog = new LibraryDialog( + app, session, commandId, form, beans, header, + isOwning, titleName, titleLabel); + } + }.start(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + super.executeModal(); + } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/library/LibraryDialog.java b/src/com/connor/hs2/plm/PFMEA/library/LibraryDialog.java new file mode 100644 index 0000000..c3720c1 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/library/LibraryDialog.java @@ -0,0 +1,2519 @@ +package com.connor.hs2.plm.PFMEA.library; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.UUID; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.JTextPane; +import javax.swing.ListSelectionModel; +import javax.swing.RowSorter; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import org.apache.commons.lang.ObjectUtils.Null; + +import com.connor.hs2.plm.PFMEA.design.SqlUtilT; +import com.connor.hs2.plm.PFMEA.design.TableCellTextAreaRenderer2; +import com.connor.hs2.plm.PFMEA.design.TreeBean; +import com.connor.hs2.plm.PFMEA.library.LibraryCommand.NaturalOrderComparator; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.MyTableModel; +import com.connor.hs2.plm.PFMEA.design.TMomMethodUtil; +import com.connor.renben.process.plm.util.TextAreaCellEditor; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class LibraryDialog extends JFrame implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private String titleName; + private String title; + private String commandId; + private String[] header2 = new String[] { "PLMEID", "ID", "名称", "名称" }; + private String[] header; + private List deleteRows = new ArrayList(); + private List beans; + private int index = -1; + private boolean isMeopSave = false; + private SpecialDialog specialDialog; + private String nodeName;// 节点名称 + private String nodeID;// 节点名称 + private int selectRow = -1; + private int selectColumn = -1; +//判断单元格显示框是否获取焦点 + private boolean isFocusOwner = false; +// 界面所需控件 + private JPanel titlePanel;// 标题 + private JLabel titleLabel; + private JTextPane selectCellValuePane; +//单行栏 + private CTable leftTable; + private CTable mainTable; + + private int rowHeightAll = 0; + +//设置frameSize + private int[] SizeLoca = new int[4]; + private int[] table1Size = new int[3]; + private int[] table2Size = new int[30]; + private int initRowHeight = 0; + private String userName = ""; + private String type = ""; + private boolean isFirstOpen = false;// 判断是否是第一次打开,同时如果是第一次打开,当第一次保存后已向数据库插入了数据isFirstOpen会置false,再保存时就只会更新,不会重复插入 + private boolean isReSet = false; + private JScrollPane scrollPane2; + private JButton reSetSize;// 重置界面大小 + private JButton setRowHeightBtn;// 调整行高 + private JTextField setRowHeightTxt;// 调整行高 + +//右键菜单 + private static JPopupMenu mainMenu; + private JMenuItem addItem; + private JMenuItem remItem; + private JMenuItem comBineItem; + private JMenuItem splitItem; + private static JPopupMenu leftMenu; + private JMenuItem addNodeItem; + private JMenuItem remNodeItem; + private JMenuItem updateNodItem; + private JMenuItem shrinkColumnItem; + private JMenuItem celShrinkColumnItem; + private CTMap map; + private Map combineMap = new HashMap();// 存放合并单元格 + + private JPanel rootPanel;// 按钮 + private JButton saveButton;// 保存 +//private JButton addSpecialButton;// 添加特殊符号 + + public LibraryDialog(AbstractAIFApplication app, TCSession session, String commandId, TCComponent form, + List beans, String[] header, boolean isOwning, String titleName, String title) { + super(); + this.beans = beans; + this.app = app; + this.session = session; + this.userName = this.session.getUser().toString(); + this.type = "PFMEAlibraryDialog"; + this.commandId = commandId; + this.titleName = titleName; + this.title = title; + this.header = header; + init(); + } + + public void getFrameSize() { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + ResultSet rs = null; + ResultSet rs0 = null; + InputStream input = null; + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + String sql = String.format("select * from AHMC_PFMEAFRAME_SIZE WHERE USERNAME = '%s' AND TYPE = '%s'", + userName, type); + rs = SqlUtilT.read(sql); + List rowList = new ArrayList(); + while (rs.next()) { + rowList.add(rs.getString("FRAMESIZE"));// 界面大小、位置 + rowList.add(rs.getString("TABLE1SIZE"));// 第一个表格的列宽数据 + rowList.add(rs.getString("TABLE2SIZE"));// 第二格表格的列宽数据 + rowList.add(rs.getString("ROWHEIGHT"));// 第1格表格的行高数据 + break; + } + if (rowList.size() == 4) {// 解析界面大小,位置,表格列宽数据 + analyticSize(rowList); + } else { + String sql0 = String.format("select * from AHMC_PFMEAFRAME_SIZE WHERE USERNAME = '%s' AND TYPE = '%s'", + "iniUser", type); + rs0 = SqlUtilT.read(sql0); + while (rs0.next()) { + rowList.add(rs0.getString("FRAMESIZE"));// 界面大小、位置 + rowList.add(rs0.getString("TABLE1SIZE"));// 第一个表格的列宽数据 + rowList.add(rs0.getString("TABLE2SIZE"));// 第二格表格的列宽数据 + + rowList.add(rs0.getString("ROWHEIGHT"));// 第1格表格的行高数据 + break; + } + if (rowList.size() <= 0) { + MessageBox.post("(数据库)未设置界面最初尺寸,请先配置!", "错误", MessageBox.ERROR); + return; + } else { + isFirstOpen = true; + analyticSize(rowList); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (rs0 != null) { + SqlUtilT.free(rs0); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + +//解析界面数据 + public void analyticSize(List rowList) { + if (rowList.get(0).indexOf("/") > -1) {// 获取界面大小位置 + String[] data = rowList.get(0).split("/"); + for (int i = 0; i < 4; i++) { + SizeLoca[i] = Integer.parseInt(data[i]); + } + } + if (rowList.get(1).indexOf("/") > -1) { + String[] data = rowList.get(1).split("/"); + for (int i = 0; i < 3; i++) { + table1Size[i] = Integer.parseInt(data[i]); + } + } + if (rowList.get(2).indexOf("/") > -1) { + String[] data = rowList.get(2).split("/"); + for (int i = 0; i < 30; i++) { + table2Size[i] = Integer.parseInt(data[i]); + } + } + + if (!rowList.get(3).equals("")) { + initRowHeight = Integer.valueOf(rowList.get(3)); + } + + } + + private void init() { + getFrameSize(); + this.setTitle(this.titleName); + this.setPreferredSize(new Dimension(SizeLoca[0], SizeLoca[1])); + this.setLocation(SizeLoca[2], SizeLoca[3]); + // 获取国际化语言 + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + // 初始化标题部分控件 + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel(this.title); + this.titleLabel.setFont(new Font("宋体", 1, 18)); + this.titlePanel.add(titleLabel); + + this.leftTable = getNewjTable(null, null, header2, beans.size()); + + // 隐藏列 + leftTable.HiddenCell(0); + leftTable.HiddenCell(3); + leftTable.setRowHeight(30); + // 设置列宽 + leftTable.getColumnModel().getColumn(2).setPreferredWidth(200); + // 添加鼠标监听 + leftTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + leftMenu.show(leftTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + for (int i = 0; i < beans.size(); i++) { + this.leftTable.setValueAt(beans.get(i).getPlmeid(), i, 0); + this.leftTable.setValueAt(beans.get(i).getId(), i, 1); + this.leftTable.setValueAt(beans.get(i).getName(), i, 2); + this.leftTable.setValueAt(beans.get(i).getParentId(), i, 3); + } + leftTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent arg0) { + // TODO Auto-generated method stub + System.out.println("======" + addSelected + "isMeopSave" + isMeopSave); + if (index == -1) { + if (addSelected != -1 && isMeopSave) { + System.out.println("okEvent"); + + okEvent(true); + + addSelected = -1; + } else if (!isMeopSave) { + String list1 = String.valueOf(((int) getSize().getWidth())) + "/" + + String.valueOf((int) getSize().getHeight()) + "/" + + String.valueOf(((int) getLocation().getX())) + "/" + + String.valueOf((((int) getLocation().getY()))); + + String list2 = ""; + for (int i = 1; i < 4; i++) { + if (i == 3) { + list2 += String.valueOf(((int) scrollPane2.getWidth())); + } else { + list2 += (String.valueOf(((int) leftTable.getColumnModel().getColumn(i).getWidth())) + + "/"); + } + } + String list3 = ""; + for (int i = 1; i < 31; i++) { + if (i == 30) { + list3 += String.valueOf(((int) mainTable.getColumnModel().getColumn(i).getWidth())); + } else { + list3 += (String.valueOf(((int) mainTable.getColumnModel().getColumn(i).getWidth())) + + "/"); + } + } + SqlUtilT.getTCConnection(); + InputStream input = null; + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + System.out.println(type + "tyye=====>"); + if (isFirstOpen) { + String insertSQL = "INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?,?)"; + SqlUtilT.write(new String[] { UUID.randomUUID().toString().replace("-", ""), userName, type, + list1, list2, list3, String.valueOf(mainTable.getRowHeight()) }, insertSQL); + isFirstOpen = false; + } else if (!isReSet) { + String updateSQL = String.format( + "update AHMC_PFMEAFRAME_SIZE set FRAMESIZE = ?, TABLE1SIZE = ?, TABLE2SIZE = ?,ROWHEIGHT = ? WHERE USERNAME ='%s' AND TYPE = '%s'", + userName, type); + SqlUtilT.update( + new String[] { list1, list2, list3, String.valueOf(mainTable.getRowHeight()) }, + updateSQL); + } + SqlUtilT.freeAll(); + } + refreshPFMEATable(); + index = leftTable.getSelectedRow(); + + } else if (index != -1 && index != leftTable.getSelectedRow()) { + if (mainTable.getSelectedRow() >= 0 && mainTable.getSelectedColumn() >= 0) { + (mainTable.getCellEditor(mainTable.getSelectedRow(), mainTable.getSelectedColumn())) + .stopCellEditing(); + } + if (isMeopSave) { + okEvent(true); + } + refreshPFMEATable(); + index = leftTable.getSelectedRow(); + } + } + }); + this.mainTable = getNewjTable(null, null, header, 0); +// 隐藏列 +//switch (commandId) { +//case "com.connor.renben.process.plm.commands.ControlPlanLibrary": +// mainTable.HiddenCell(0); +// mainTable.HiddenCell(header.length - 1); +// mainTable.HiddenCell(header.length - 2); +// break; +//case "com.connor.renben.process.plm.commands.PFMEALibrary": + mainTable.HiddenCell(0); + mainTable.HiddenCell(header.length - 1); + mainTable.HiddenCell(header.length - 2); +// break; +//case "com.connor.renben.process.plm.commands.Thesaurus": +// mainTable.HiddenCell(0); +// mainTable.HiddenCell(header.length - 1); +// //设置列宽 +// mainTable.getColumnModel().getColumn(2) +// .setPreferredWidth(300); +// break; +//default: +// break; +//} +// 添加鼠标监听 + mainTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + ((CTMap) mainTable.getModel()).setRow(mainTable.getSelectedRow()); + ((CTMap) mainTable.getModel()).setColumn(mainTable.getSelectedColumn()); + + if (isFocusOwner && selectRow != -1 && selectColumn != -1) { + mainTable.setValueAt(selectCellValuePane.getText(), selectRow, selectColumn); + } + + if (mainTable.getValueAt(mainTable.getSelectedRow(), mainTable.getSelectedColumn()) != null) { + selectCellValuePane.setText(""); + selectCellValuePane.setText(mainTable + .getValueAt(mainTable.getSelectedRow(), mainTable.getSelectedColumn()).toString()); + } else { + selectCellValuePane.setText(""); + } + } + selectRow = mainTable.getSelectedRow(); + selectColumn = mainTable.getSelectedColumn(); + isFocusOwner = false; + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + mainMenu.show(mainTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + +//添加键盘监听 + this.mainTable.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent arg0) { + // TODO Auto-generated method stub + + if (arg0.getKeyCode() == 16) {// shift键码16,添加监听 + comBineCell(); + } + if (arg0.getKeyCode() == 20) {// caps_lock键码20,添加监听 + splitCell(); + } + if (arg0.getKeyCode() == KeyEvent.VK_V) { // Copy + System.out.println("here"); + Clipboard localAIFClipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + Transferable localTransferable = localAIFClipboard.getContents(null); + // localTransferable. + String transferData; + try { + transferData = (String) localTransferable.getTransferData(DataFlavor.stringFlavor); + int selectRow = mainTable.getSelectedRow();// 最初选中的行 + int selectRows = mainTable.getSelectedRowCount();// 最初选中的总行数 + int selectColumn = mainTable.getSelectedColumn();// 最初选中的行 + int selectColumns = mainTable.getSelectedColumnCount();// 最初选中的总行数 + + // +++根据复制内容自动增加行 + mainTable.setRowSelectionInterval(selectRow + selectRows - 1, selectRow + selectRows - 1);// 定位到选中的最后一行 + if (transferData.indexOf("$") > -1) { + if (selectRows < transferData.split("\\$").length) { + for (int i1 = 0; i1 < transferData.split("\\$").length - selectRows; i1++) { + map.insertRow(mainTable.getSelectedRow() + 1); + mainTable.setValueAt( + // 复制插入最后一列隐藏列的的值(插入属于哪个节点) + mainTable.getValueAt(mainTable.getSelectedRow(), + mainTable.getColumnCount() - 1), + mainTable.getSelectedRow() + 1, mainTable.getColumnCount() - 1); + } + } + ; + } else { + // 将excel复制的内容转化下,每行用$隔开 + // System.out.println("fuzhidao:"+transferData); + String[] values = transferData.split("\""); + StringBuffer sb = new StringBuffer(); + // 替换Excel中的换行符 + for (int i = 0; i < values.length; i++) { + System.out.println(i + values[i]); + if (i % 2 == 0 && values[i].indexOf("\n") >= 0) { + sb.append(values[i].replace("\n", " $")); + } else { + sb.append(values[i]); + } + } + // System.out.println("sb++++++++"+sb.toString()); + + if (sb.indexOf("$") > -1) { + if (selectRows < sb.toString().split("\\$").length) { + for (int i1 = 0; i1 < sb.toString().split("\\$").length - selectRows; i1++) { + map.insertRow(mainTable.getSelectedRow() + 1); + mainTable.setValueAt( + mainTable.getValueAt(mainTable.getSelectedRow(), + mainTable.getColumnCount() - 1), + mainTable.getSelectedRow() + 1, mainTable.getColumnCount() - 1); + } + } + ; + } + } + mainTable.revalidate(); + mainTable.repaint(); + mainTable.setRowSelectionInterval(selectRow, selectRow);// 定位到选中的第一行 + + // +++根据excel的内容自动合并单元格 + if (localTransferable.isDataFlavorSupported(DataFlavor.fragmentHtmlFlavor)) {// 判断是否是excel的复制内容,是的话则可以打印出xml内容供解析合并信息 + String transferData1 = (String) localTransferable + .getTransferData(DataFlavor.fragmentHtmlFlavor); + // System.out.println("打印excel属性:"+transferData1); + Map widMap = new HashMap(); + String[] widString = transferData1.split(""+s[i]); + if (s[i].indexOf("rowspan") > 0 || s[i].indexOf("colspan") > 0) { + // System.out.println("===>第"+i+"行:"); + String[] ss = s[i].split(" 0 || ss[j].indexOf("colspan") > 0) { + int combineRow = 1; + int combineColumn = 1; + if (getIndex(ss[j], "rowspan") > 0) {// 如果有合并的行数有值则返回合并行数,如合并了两行就返回getIndex为2 + combineRow = getIndex(ss[j], "rowspan"); + // System.out.println("第"+j+"列:"); + // System.out.println("合并行数:"+getIndex(ss[j],"rowspan")); + } + if (getIndex(ss[j], "colspan") > 0) { + combineColumn = getIndex(ss[j], "colspan"); + // System.out.println("合并列数:"+getIndex(ss[j],"colspan")); + } + // combineRow需要减1.因为例如当合并时2行时,combineRow为2,但是只要选中两行,所以要combineRow-1 + // 当没有合并行或列时,1-1为0,相当于就只是选中一行或者一列 + String[] split = ss[j].split(" width="); + if (split.length == 2) { + String[] split2 = split[1].split(" style="); +// if(spl) + Integer integer = 0; + if (widMap.containsKey(split2[0])) { + integer = widMap.get(split2[0]); + } + + mainTable.setRowSelectionInterval(selectRow + i - 1, + selectRow + i - 1 + combineRow - 1); + mainTable.setColumnSelectionInterval(selectColumn - 1 + integer, + selectColumn - 1 + integer + combineColumn - 1); + System.out.println("rowselecttion" + (selectRow + i - 1) + "end" + + (selectRow + i - 1 + combineRow - 1)); + System.out.println(integer + "column select" + + (selectColumn + integer - 1) + "end" + + (selectColumn - 1 + integer + combineColumn - 1)); + if (combineRow > 2) { + as = true; + } + comBineCell(); + } + + } + } +// if(as) { +// index = index+1; +// } + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + // 最后要让选中的行和列回归初始状态以便插入数据 + mainTable.setRowSelectionInterval(selectRow, selectRow + selectRows - 1); + mainTable.setColumnSelectionInterval(selectColumn, selectColumn + selectColumns - 1); + } +// if(localTransferable.isDataFlavorSupported(DataFlavor.fragmentHtmlFlavor)) {//判断是否是excel的复制内容,是的话则可以打印出xml内容供解析合并信息 +// String transferData1 = (String)localTransferable.getTransferData(DataFlavor.fragmentHtmlFlavor); +// //System.out.println("打印excel属性:"+transferData1); +// String[] s=transferData1.split(""+s[i]); +// if(s[i].indexOf("rowspan")>0||s[i].indexOf("colspan")>0){ +// //System.out.println("===>第"+i+"行:"); +// String[] ss=s[i].split("0||ss[j].indexOf("colspan")>0){ +// int combineRow=1; +// int combineColumn=1; +// if(getIndex(ss[j],"rowspan")>0){//如果有合并的行数有值则返回合并行数,如合并了两行就返回getIndex为2 +// combineRow=getIndex(ss[j],"rowspan"); +// // System.out.println("第"+j+"列:"); +// //System.out.println("合并行数:"+getIndex(ss[j],"rowspan")); +// } +// if(getIndex(ss[j],"colspan")>0){ +// combineColumn=getIndex(ss[j],"colspan"); +// //System.out.println("合并列数:"+getIndex(ss[j],"colspan")); +// } +// //combineRow需要减1.因为例如当合并时2行时,combineRow为2,但是只要选中两行,所以要combineRow-1 +// //当没有合并行或列时,1-1为0,相当于就只是选中一行或者一列 +// mainTable.setRowSelectionInterval(selectRow+i-1, selectRow+i-1+combineRow-1); +// mainTable.setColumnSelectionInterval(selectColumn+j-1, selectColumn+j-1+combineColumn-1); +// +// comBineCell(); +// } +// } +// } +// } +// //最后要让选中的行和列回归初始状态以便插入数据 +// mainTable.setRowSelectionInterval(selectRow, selectRow+selectRows-1); +// mainTable.setColumnSelectionInterval(selectColumn, selectColumn+selectColumns-1); +// } + // +++ + // System.out.println(transferData); + } catch (UnsupportedFlavorException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + super.keyPressed(arg0); + } + }); + + mainTable.getModel().addTableModelListener(new TableModelListener() { + + @Override + public void tableChanged(TableModelEvent tablemodelevent) { + // TODO Auto-generated method stub + if (tablemodelevent.getType() == TableModelEvent.UPDATE) { + isMeopSave = true; + } + } + }); + + this.selectCellValuePane = new JTextPane(); + this.selectCellValuePane.addFocusListener(new FocusListener() { + // private int row; + // private int column; + @Override + public void focusLost(FocusEvent focusevent) { + // TODO Auto-generated method stub +// if(selectRow != -1 && selectColumn != -1) +// { +// mainTable.setValueAt(selectCellValuePane.getText(), selectRow, selectColumn); +// } + } + + @Override + public void focusGained(FocusEvent focusevent) { + // TODO Auto-generated method stub + isFocusOwner = true; + // this.row = mainTable.getSelectedRow(); + // this.column = mainTable.getSelectedColumn(); + } + }); + selectCellValuePane.setPreferredSize(new Dimension(700, 40)); + + Adapter adapter = new Adapter(mainTable); + JScrollPane scrollPane = new JScrollPane(mainTable); + scrollPane.getVerticalScrollBar().setUnitIncrement(2); + scrollPane2 = new JScrollPane(leftTable); + scrollPane2.setPreferredSize(new Dimension(table1Size[2], 600)); + scrollPane2.getVerticalScrollBar().setUnitIncrement(2); + +//JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); +//splitPane.setOneTouchExpandable(true);// 让分割线显示出箭头 +//splitPane.setContinuousLayout(true);// 操作箭头,重绘图形 +//splitPane.setTopComponent(new JScrollPane(selectCellValuePane)); +//splitPane.setBottomComponent(scrollPane); + + JSplitPane splitPane2 = new JSplitPane(); + splitPane2.setOneTouchExpandable(true);// 让分割线显示出箭头 + splitPane2.setContinuousLayout(true);// 操作箭头,重绘图形 + splitPane2.setLeftComponent(scrollPane2); + splitPane2.setRightComponent(scrollPane); + + this.mainMenu = new JPopupMenu(); + this.addItem = new JMenuItem(rb.getString("tjh_display.TITLE")); + this.remItem = new JMenuItem(rb.getString("ych12_display.TITLE")); + this.shrinkColumnItem = new JMenuItem(rb.getString("sxxzl_display.TITLE")); + this.celShrinkColumnItem = new JMenuItem(rb.getString("qxsxxzl_display.TITLE")); + this.comBineItem = new JMenuItem("合并单元格"); + this.splitItem = new JMenuItem("拆分单元格"); + this.mainMenu.add(this.addItem); + this.mainMenu.add(this.remItem); + this.mainMenu.add(this.shrinkColumnItem); + this.mainMenu.add(this.celShrinkColumnItem); + this.mainMenu.add(this.comBineItem); + this.mainMenu.add(this.splitItem); + + this.leftMenu = new JPopupMenu(); + this.addNodeItem = new JMenuItem(rb.getString("tjjd12_display.TITLE")); + this.remNodeItem = new JMenuItem(rb.getString("ycjd12_display.TITLE")); + this.updateNodItem = new JMenuItem(rb.getString("gxjd12_display.TITLE")); + this.leftMenu.add(this.addNodeItem); + this.leftMenu.add(this.remNodeItem); + this.leftMenu.add(this.updateNodItem); + + this.rootPanel = new JPanel(new FlowLayout()); +//this.addNodeButton = new JButton("添加节点"); +//this.addButton = new JButton("添加行"); +//this.remButton = new JButton("移除行"); +//this.remNodeButton = new JButton("移除节点"); + this.saveButton = new JButton(rb.getString("bc_display.TITLE")); + this.reSetSize = new JButton("重置界面大小"); + this.setRowHeightBtn = new JButton("设置行高"); + this.setRowHeightTxt = new JTextField(); + this.setRowHeightTxt.setPreferredSize(new Dimension(160, 20)); +//this.addSpecialButton = new JButton("添加特殊符号"); +//this.rootPanel.add(addNodeButton); +//this.rootPanel.add(addButton); +//this.rootPanel.add(remButton); +//this.rootPanel.add(remNodeButton); + this.rootPanel.add(new JScrollPane(selectCellValuePane)); + this.rootPanel.add(saveButton); + this.rootPanel.add(this.reSetSize); + this.rootPanel.add(this.setRowHeightTxt); + this.rootPanel.add(this.setRowHeightBtn); +//this.rootPanel.add(addSpecialButton); + + JPanel centerPanel = new JPanel(new BorderLayout()); + centerPanel.add(titlePanel, BorderLayout.NORTH); + +// 添加鼠标监听 + this.createActionEvent(); + this.setLayout(new BorderLayout()); + this.add(centerPanel, BorderLayout.NORTH); + this.add(splitPane2, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + + } + +//复制excel数据时检查是否有合并的行和列。"rowspan"是合并的行,"colspan"是合并的列。然后返回rowspan(colspan)=的值 + public static int getIndex(String tag1, String tag2) { + int loca = 0; + if (tag1.indexOf(tag2) > 0) { + int l = tag1.indexOf(tag2); + while (!tag1.substring(l, l + 1).equals("=")) { + l++; + } + int start = ++l; + while (!tag1.substring(l, l + 1).equals(" ")) { + l++; + } + loca = Integer.valueOf(tag1.substring(start, l)); + } + return loca; + } + +//private void refreshTable() { +//// TODO Auto-generated method stub +////刷新右侧数据 +//ResultSet rs = null; +//InputStream input = null; +//try { +// +// SqlUtilT.getTCConnection(); +// // 获取SQL语句 +// input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// Properties pro = new Properties(); +// pro.load(input); +// String sql = String.format(pro.getProperty("CONTROLPLANLIBRARYSELECT"), leftTable.getValueAt(leftTable.getSelectedRow(), 1)); +// rs = SqlUtilT.read(sql); +// List> rowList = new ArrayList>(); +// while (rs.next()) { +// List list = new ArrayList(); +// list.add(rs.getString("PLMEID")); +// list.add(rs.getString("ID")); +// list.add(rs.getString("JQSB")); +// list.add(rs.getString("SMJY")); +// list.add(rs.getString("QPTBH")); +// //list.add(rs.getString("CC")); +// //list.add(rs.getString("NO")); +// list.add(rs.getString("CP")); +// list.add(rs.getString("GC")); +// list.add(rs.getString("TSTX")); +// list.add(rs.getString("CPGC")); +// list.add(rs.getString("CLFF")); +// list.add(rs.getString("RL")); +// list.add(rs.getString("PL")); +// //list.add(rs.getString("FZR")); +// list.add(rs.getString("KZFF")); +// //list.add(rs.getString("CZGF")); +// list.add(rs.getString("FYJH")); +// //list.add(rs.getString("SJSJ")); +// //list.add(rs.getString("GCSJ")); +// //list.add(rs.getString("MJSJ")); +// list.add(rs.getString("PARENT_ID")); +// list.add(rs.getString("SPECIAL")); +// rowList.add(list); +// } +// if (rowList.size() > 0) { +// CTMap map = new CTMap(rowList.size(),header.length); +// map.setColumnIdentifiers(header); +// map.setEditable(true); +// mainTable.setModel(map); +// mainTable.getColumnModel().getColumn(2) +// .setPreferredWidth(300); +// for (int j = 0; j < rowList.size(); j++) { +// for (int k = 0; k < rowList.get(j).size(); k++) { +// mainTable.setValueAt(rowList.get(j).get(k), j, k); +// } +// } +// map.addTableModelListener(new TableModelListener() { +// +// @Override +// public void tableChanged(TableModelEvent tablemodelevent) { +// // TODO Auto-generated method stub +// if(tablemodelevent.getType() == TableModelEvent.UPDATE){ +// isMeopSave = true; +// } +// } +// }); +// } else { +// CTMap map = new CTMap(1,header.length); +// map.setColumnIdentifiers(header); +// map.setEditable(true); +// mainTable.setModel(map); +// mainTable.getColumnModel().getColumn(2) +// .setPreferredWidth(300); +// map.setValueAt(leftTable.getValueAt(leftTable.getSelectedRow(), 1), 0, +// mainTable.getColumnCount() - 2); +// map.addTableModelListener(new TableModelListener() { +// +// @Override +// public void tableChanged(TableModelEvent tablemodelevent) { +// // TODO Auto-generated method stub +// if(tablemodelevent.getType() == TableModelEvent.UPDATE){ +// isMeopSave = true; +// } +// } +// }); +// } +// mainTable.HiddenCell(0); +// mainTable.HiddenCell(header.length - 1); +// mainTable.HiddenCell(header.length - 2); +// mainTable.invalidate(); +//} catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +//} finally { +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// if (input != null) { +// try { +// input.close(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// SqlUtilT.freeAll(); +//} +//} + private int addSelected = -1; + + private void refreshPFMEATable(String valueAt) { + // TODO Auto-generated method stub + // 刷新右侧数据 + ResultSet rs = null; + InputStream input = null; + try { + + System.out.println("refresh22"); + SqlUtilT.getTCConnection(); + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("PFMEALIBRARYSELECT"), valueAt); // leftTable.getValueAt(leftTable.getSelectedRow(), + // 1) + rs = SqlUtilT.read(sql); + List> rowList = new ArrayList>(); + while (rs.next()) { + List list = new ArrayList(); + list.add(rs.getString("PLMEID")); + list.add(rs.getString("ID")); + list.add(rs.getString("LSBG")); + list.add(rs.getString("STATION")); + list.add(rs.getString("REQUIREMENT")); + list.add(rs.getString("QZSXMS")); + list.add(rs.getString("QZSXHG")); + list.add(rs.getString("YZD")); + list.add(rs.getString("JB")); + list.add(rs.getString("QZSXQY")); + list.add(rs.getString("XXGCKZYF")); + list.add(rs.getString("PDS")); + list.add(rs.getString("XXGCKZTC")); + list.add(rs.getString("TCD")); + list.add(rs.getString("RPN")); + list.add(rs.getString("JYCS")); + list.add(rs.getString("ZZR")); + list.add(rs.getString("JHWCRQ")); + list.add(rs.getString("CQDCS")); + list.add(rs.getString("NEW_SEV")); + list.add(rs.getString("NEW_OCC")); + list.add(rs.getString("NEW_DET")); + list.add(rs.getString("NEW_RPN")); + list.add(rs.getString("IDEAL_STATE")); + list.add(rs.getString("SPECIAL")); + list.add(rs.getString("P1")); + list.add(rs.getString("P2")); + list.add(rs.getString("P3")); + list.add(rs.getString("P4")); + list.add(rs.getString("P5")); + list.add(rs.getString("P6")); + list.add(rs.getString("P7")); + list.add(rs.getString("P8")); + list.add(rs.getString("PARENT_ID")); + list.add(rs.getString("HBDYG")); + rowList.add(list); + } + if (rowList.size() > 0) { + map = new CTMap(rowList.size(), header.length); + map.setColumnIdentifiers(header); + map.setEditable(true); + mainTable.setModel(map); + // mainTable.getColumnModel().getColumn(2) + // .setPreferredWidth(300); + for (int j = 0; j < rowList.size(); j++) { + for (int k = 0; k < rowList.get(j).size() - 1; k++) { + mainTable.setValueAt(rowList.get(j).get(k), j, k); + } + } + map.addTableModelListener(new TableModelListener() { + + @Override + public void tableChanged(TableModelEvent tablemodelevent) { + // TODO Auto-generated method stub + if (tablemodelevent.getType() == TableModelEvent.UPDATE) { + isMeopSave = true; + } + } + }); + comBine(rowList); + } else { + map = new CTMap(1, header.length); + map.setColumnIdentifiers(header); + map.setEditable(true); + mainTable.setModel(map); + mainTable.getColumnModel().getColumn(2).setPreferredWidth(300); + map.setValueAt(valueAt, 0, mainTable.getColumnCount() - 1); + map.addTableModelListener(new TableModelListener() { + + @Override + public void tableChanged(TableModelEvent tablemodelevent) { + // TODO Auto-generated method stub + if (tablemodelevent.getType() == TableModelEvent.UPDATE) { + isMeopSave = true; + } + } + }); + } + getFrameSize(); + for (int i = 1; i <= 30; i++) { + mainTable.getColumnModel().getColumn(i).setPreferredWidth(table2Size[i - 1]); + } + for (int i = 1; i <= 2; i++) { + leftTable.getColumnModel().getColumn(i).setPreferredWidth(table1Size[i - 1]); + } + if (rowHeightAll != 0) { + mainTable.setRowHeight(rowHeightAll); + } + mainTable.HiddenCell(0); + mainTable.HiddenCell(header.length - 1); + leftTable.setRowHeight(30); + mainTable.invalidate(); + mainTable.revalidate(); + mainTable.repaint(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + private void refreshPFMEATable() { +// TODO Auto-generated method stub +//刷新右侧数据 + ResultSet rs = null; + InputStream input = null; + try { + + System.out.println("refresh11"); + SqlUtilT.getTCConnection(); + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("PFMEALIBRARYSELECT"), + leftTable.getValueAt(leftTable.getSelectedRow(), 1)); + rs = SqlUtilT.read(sql); + List> rowList = new ArrayList>(); + while (rs.next()) { + List list = new ArrayList(); + list.add(rs.getString("PLMEID")); + list.add(rs.getString("ID")); + list.add(rs.getString("LSBG")); + list.add(rs.getString("STATION")); + list.add(rs.getString("REQUIREMENT")); + list.add(rs.getString("QZSXMS")); + list.add(rs.getString("QZSXHG")); + list.add(rs.getString("YZD")); + list.add(rs.getString("JB")); + list.add(rs.getString("QZSXQY")); + list.add(rs.getString("XXGCKZYF")); + list.add(rs.getString("PDS")); + list.add(rs.getString("XXGCKZTC")); + list.add(rs.getString("TCD")); + list.add(rs.getString("RPN")); + list.add(rs.getString("JYCS")); + list.add(rs.getString("ZZR")); + list.add(rs.getString("JHWCRQ")); + list.add(rs.getString("CQDCS")); + list.add(rs.getString("NEW_SEV")); + list.add(rs.getString("NEW_OCC")); + list.add(rs.getString("NEW_DET")); + list.add(rs.getString("NEW_RPN")); + list.add(rs.getString("IDEAL_STATE")); + list.add(rs.getString("SPECIAL")); + list.add(rs.getString("P1")); + list.add(rs.getString("P2")); + list.add(rs.getString("P3")); + list.add(rs.getString("P4")); + list.add(rs.getString("P5")); + list.add(rs.getString("P6")); + list.add(rs.getString("P7")); + list.add(rs.getString("P8")); + list.add(rs.getString("PARENT_ID")); + list.add(rs.getString("HBDYG")); + rowList.add(list); + } + System.out.println(rowList.toString()); + if (rowList.size() > 0) { + map = new CTMap(rowList.size(), header.length); + map.setColumnIdentifiers(header); + map.setEditable(true); + mainTable.setModel(map); + // mainTable.getColumnModel().getColumn(2) + // .setPreferredWidth(300); + for (int j = 0; j < rowList.size(); j++) { + for (int k = 0; k < rowList.get(j).size() - 1; k++) { + mainTable.setValueAt(rowList.get(j).get(k), j, k); + } + } + map.addTableModelListener(new TableModelListener() { + + @Override + public void tableChanged(TableModelEvent tablemodelevent) { + // TODO Auto-generated method stub + if (tablemodelevent.getType() == TableModelEvent.UPDATE) { + isMeopSave = true; + } + } + }); + comBine(rowList); + } else { + map = new CTMap(1, header.length); + map.setColumnIdentifiers(header); + map.setEditable(true); + mainTable.setModel(map); + mainTable.getColumnModel().getColumn(2).setPreferredWidth(300); + map.setValueAt(leftTable.getValueAt(leftTable.getSelectedRow(), 1), 0, mainTable.getColumnCount() - 1); + map.addTableModelListener(new TableModelListener() { + + @Override + public void tableChanged(TableModelEvent tablemodelevent) { + // TODO Auto-generated method stub + if (tablemodelevent.getType() == TableModelEvent.UPDATE) { + System.out.println("isMeopSave" + isMeopSave); + isMeopSave = true; + } + } + }); + } + getFrameSize(); + for (int i = 1; i <= 30; i++) { + mainTable.getColumnModel().getColumn(i).setPreferredWidth(table2Size[i - 1]); + ; + } + for (int i = 1; i <= 2; i++) { + leftTable.getColumnModel().getColumn(i).setPreferredWidth(table1Size[i - 1]); + ; + } + if (rowHeightAll != 0) { + mainTable.setRowHeight(rowHeightAll); + } + mainTable.HiddenCell(0); + mainTable.HiddenCell(header.length - 1); +// leftTable.setRowHeight(30); + mainTable.invalidate(); + mainTable.revalidate(); + mainTable.repaint(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + /** + * 更新左侧数据 + */ + private void refreshLeftTable() { +// TODO Auto-generated method stub +//刷新右侧数据 + ResultSet rs = null; + InputStream input = null; + try { + + SqlUtilT.getTCConnection(); + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("TM2CONTROLPLANTREESELECT")); + rs = SqlUtilT.read(sql); + List bneanList = new ArrayList(); + while (rs.next()) { + TreeBean bean = new TreeBean(); + bean.setPlmeid(rs.getString("PLMEID")); + bean.setId(rs.getString("ID")); + bean.setName(rs.getString("NAME")); + bean.setParentId(rs.getString("PARENT_ID")); + bneanList.add(bean); + } + if (bneanList.size() > 0) { + CTMap map = new CTMap(bneanList.size(), header2.length); + map.setColumnIdentifiers(header2); + // map.setEditable(true); + leftTable.setModel(map); + leftTable.getColumnModel().getColumn(2).setPreferredWidth(200); + for (int i = 0; i < bneanList.size(); i++) { + this.leftTable.setValueAt(bneanList.get(i).getPlmeid(), i, 0); + this.leftTable.setValueAt(bneanList.get(i).getId(), i, 1); + this.leftTable.setValueAt(bneanList.get(i).getName(), i, 2); + this.leftTable.setValueAt(bneanList.get(i).getParentId(), i, 3); + } + } + leftTable.HiddenCell(0); + leftTable.HiddenCell(3); + leftTable.invalidate(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + /** + * 更新左侧数据 + */ + private void refreshPFMEALeftTable() { +// TODO Auto-generated method stub +//刷新右侧数据 + ResultSet rs = null; + InputStream input = null; + try { + + SqlUtilT.getTCConnection(); + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("TM2PFMEATREESELECT")); + rs = SqlUtilT.read(sql); + List bneanList = new ArrayList(); + while (rs.next()) { + TreeBean bean = new TreeBean(); + bean.setPlmeid(rs.getString("PLMEID")); + bean.setId(rs.getString("ID")); + bean.setName(rs.getString("NAME")); + bean.setParentId(rs.getString("PARENT_ID")); + bneanList.add(bean); + } + + Collections.sort(bneanList, new NaturalOrderComparator<>(true)); + bneanList.forEach(item -> System.out.println(item)); + if (bneanList.size() > 0) { + CTMap map = new CTMap(bneanList.size(), header2.length); + map.setColumnIdentifiers(header2); + // map.setEditable(true); + leftTable.setModel(map); + leftTable.getColumnModel().getColumn(2).setPreferredWidth(200); + for (int i = 0; i < bneanList.size(); i++) { + this.leftTable.setValueAt(bneanList.get(i).getPlmeid(), i, 0); + this.leftTable.setValueAt(bneanList.get(i).getId(), i, 1); + this.leftTable.setValueAt(bneanList.get(i).getName(), i, 2); + this.leftTable.setValueAt(bneanList.get(i).getParentId(), i, 3); + } + } + leftTable.HiddenCell(0); + leftTable.HiddenCell(3); + leftTable.invalidate(); + leftTable.revalidate(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + class NaturalOrderComparator implements Comparator { + + private final boolean caseInsensitive; + + public NaturalOrderComparator(boolean caseInsensitive) { + this.caseInsensitive = caseInsensitive; + } + + private int compareRight(String a, String b) { + int bias = 0; + int ia = 0; + int ib = 0; + for (;; ia++, ib++) { + char ca = charAt(a, ia); + char cb = charAt(b, ib); + + if (!Character.isDigit(ca) && !Character.isDigit(cb)) { + return bias; + } else if (!Character.isDigit(ca)) { + return -1; + } else if (!Character.isDigit(cb)) { + return +1; + } else if (ca < cb) { + if (bias == 0) { + bias = -1; + } + } else if (ca > cb) { + if (bias == 0) { + bias = +1; + } + } else if (ca == 0 && cb == 0) { + return bias; + } + } + } + + @Override + public int compare(T o1, T o2) { + + TreeBean bean1 = (TreeBean) o1; + TreeBean bean2 = (TreeBean) o2; + + String a = bean1.getId(); + String b = bean2.getId(); + int ia = 0, ib = 0; + int nza = 0, nzb = 0; + char ca, cb; + int result; + while (true) { + nza = nzb = 0; + ca = charAt(a, ia); + cb = charAt(b, ib); + + while (ca == '0') { + nza++; + if (!Character.isDigit(charAt(a, ia + 1))) { + break; + } + ca = charAt(a, ++ia); + } + while (cb == '0') { + nzb++; + if (!Character.isDigit(charAt(b, ib + 1))) { + break; + } + cb = charAt(b, ++ib); + } + + if (Character.isDigit(ca) && Character.isDigit(cb)) { + if ((result = compareRight(a.substring(ia), b.substring(ib))) != 0) { + return result; + } + } + if (ca == 0 && cb == 0) { + return nza - nzb; + } + if (ca < cb) { + return -1; + } else if (ca > cb) { + return +1; + } + ++ia; + ++ib; + } + } + + private char charAt(String s, int i) { + if (i >= s.length()) { + return 0; + } else { + return caseInsensitive ? Character.toUpperCase(s.charAt(i)) : s.charAt(i); + } + } + } + + private void refreshThesaurusLeftTable() { +// TODO Auto-generated method stub +//刷新右侧数据 + ResultSet rs = null; + InputStream input = null; + try { + + SqlUtilT.getTCConnection(); + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("TM2THESAURUSTREESELECT")); + rs = SqlUtilT.read(sql); + List bneanList = new ArrayList(); + while (rs.next()) { + TreeBean bean = new TreeBean(); + bean.setPlmeid(rs.getString("PLMEID")); + bean.setId(rs.getString("ID")); + bean.setName(rs.getString("NAME")); + bean.setParentId(rs.getString("PARENT_ID")); + bneanList.add(bean); + } + if (bneanList.size() > 0) { + CTMap map = new CTMap(bneanList.size(), header2.length); + map.setColumnIdentifiers(header2); + // map.setEditable(true); + leftTable.setModel(map); + leftTable.getColumnModel().getColumn(2).setPreferredWidth(200); + for (int i = 0; i < bneanList.size(); i++) { + this.leftTable.setValueAt(bneanList.get(i).getPlmeid(), i, 0); + this.leftTable.setValueAt(bneanList.get(i).getId(), i, 1); + this.leftTable.setValueAt(bneanList.get(i).getName(), i, 2); + this.leftTable.setValueAt(bneanList.get(i).getParentId(), i, 3); + } + } + leftTable.HiddenCell(0); + leftTable.HiddenCell(3); + leftTable.invalidate(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + private void refreshThesaurusTable() { +// TODO Auto-generated method stub +//刷新右侧数据 + ResultSet rs = null; + InputStream input = null; + try { + + SqlUtilT.getTCConnection(); + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("TM2THESAURUSNODESELECT"), + leftTable.getValueAt(leftTable.getSelectedRow(), 1)); + rs = SqlUtilT.read(sql); + List> rowList = new ArrayList>(); + while (rs.next()) { + List list = new ArrayList(); + list.add(rs.getString("PLMEID")); + list.add(rs.getString("ID")); + list.add(rs.getString("VALUE")); + // list.add(rs.getString("VALUE2")); + // list.add(rs.getString("EXAMPLE")); + list.add(rs.getString("PARENT_ID")); + rowList.add(list); + } + if (rowList.size() > 0) { + CTMap map = new CTMap(rowList.size(), header.length); + map.setColumnIdentifiers(header); + map.setEditable(true); + mainTable.setModel(map); + mainTable.getColumnModel().getColumn(2).setPreferredWidth(300); + for (int j = 0; j < rowList.size(); j++) { + for (int k = 0; k < rowList.get(j).size(); k++) { + if (k == rowList.get(j).size() - 2) { + mainTable.setValueAt(rowList.get(j).get(k + 1), j, k + 1); + } else if (k == rowList.get(j).size() - 1) { + mainTable.setValueAt(rowList.get(j).get(k - 1), j, k - 1); + } else { + mainTable.setValueAt(rowList.get(j).get(k), j, k); + } + } + } + map.addTableModelListener(new TableModelListener() { + @Override + public void tableChanged(TableModelEvent tablemodelevent) { + // TODO Auto-generated method stub + if (tablemodelevent.getType() == TableModelEvent.UPDATE) { + isMeopSave = true; + } + } + }); + } else { + CTMap map = new CTMap(20, header.length); + map.setColumnIdentifiers(header); + map.setEditable(true); + mainTable.setModel(map); + mainTable.getColumnModel().getColumn(2).setPreferredWidth(300); + map.setValueAt(leftTable.getValueAt(leftTable.getSelectedRow(), 1), 0, mainTable.getColumnCount() - 1); + map.addTableModelListener(new TableModelListener() { + + @Override + public void tableChanged(TableModelEvent tablemodelevent) { + // TODO Auto-generated method stub + if (tablemodelevent.getType() == TableModelEvent.UPDATE) { + isMeopSave = true; + } + } + }); + } + mainTable.HiddenCell(0); + mainTable.HiddenCell(header.length - 1); + leftTable.setRowHeight(30); + mainTable.invalidate(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + +// 添加监听 + public void createActionEvent() { + this.addItem.addActionListener(this); + this.addNodeItem.addActionListener(this); + this.updateNodItem.addActionListener(this); + this.shrinkColumnItem.addActionListener(this); + this.celShrinkColumnItem.addActionListener(this); + this.remItem.addActionListener(this); + this.remNodeItem.addActionListener(this); + this.saveButton.addActionListener(this); + this.comBineItem.addActionListener(this); + this.splitItem.addActionListener(this); + this.reSetSize.addActionListener(this); + this.setRowHeightBtn.addActionListener(this); +//this.addSpecialButton.addActionListener(this); + } + +//加载合并单元格 + public void comBine(List> rowList) { + combineMap.clear(); + if (rowList != null && rowList.size() > 0) { + for (int i = 0; i < rowList.size(); i++) { + if (rowList.get(i).get(34) != null && !rowList.get(i).get(34).equals("")) { + String sombine = rowList.get(i).get(34).toString(); + int rowDif = 0; + String[] sombines; + if (sombine.indexOf("-") >= 0) { + sombines = sombine.split("-"); + } else { + sombines = new String[] { sombine }; + } + for (int j = 0; j < sombines.length; j++) { + if (sombines[j].indexOf("/") >= 0) { + int[] row; + int[] cloumn; + String[] cells = sombines[j].split("/"); + if (cells[0].indexOf(",") >= 0) { + String[] rows = cells[0].split(","); + row = new int[rows.length]; + for (int k = 0; k < rows.length; k++) { + row[k] = Integer.parseInt(rows[k]) + rowDif; + } + } else { + row = new int[] { Integer.parseInt(cells[0]) + rowDif }; + } + if (cells[1].indexOf(",") >= 0) { + String[] cloumns = cells[1].split(","); + cloumn = new int[cloumns.length]; + for (int k = 0; k < cloumns.length; k++) { + cloumn[k] = Integer.parseInt(cloumns[k]); + } + } else { + cloumn = new int[] { Integer.parseInt(cells[1]) }; + } + this.combineMap.put(row, cloumn); + } + } + } + } + } + // TODO Auto-generated method stub + if (combineMap != null && combineMap.size() != 0) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + try { + map.combine(entry.getKey(), entry.getValue()); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + } + } + } + + String selectId; + + /** + * 合并单元格 + */ + private void comBineCell() { + isMeopSave = true; + // TODO Auto-generated method stub + // table.setRowHeight(2, 50); + int[] rows = mainTable.getSelectedRows(); + int[] columns = mainTable.getSelectedColumns(); + if (rows.length <= 0) { + MessageBox.post("请选择要合并的单元格!", "错误", MessageBox.ERROR); + return; + } +// for (int i = 0; i < rows.length; i++) { +// if (this.processRows != null && this.processRows.size() > 0 && !(this.processRows.contains(rows[i]))) { +// MessageBox.post("无权限合并单元格", "错误", MessageBox.ERROR); +// return; +// } +// } + if (combineMap != null && combineMap.size() != 0) { + for (int i = 0; i < rows.length; i++) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + if (keysList.contains(rows[i])) { + for (int j = 0; j < columns.length; j++) { + List valueList = new ArrayList<>(); + for (int k = 0; k < entry.getValue().length; k++) { + valueList.add(entry.getValue()[k]); + } + if (valueList.contains(columns[j])) { + columns = Union(columns, entry.getValue()); + rows = Union(rows, entry.getKey()); + if (combineMap.get(entry.getKey()) != null) { + it.remove(); + } + } + } + } + } + } + combineMap.put(rows, columns); + } else { + combineMap.put(rows, columns); + } + for (int i = 0; i < rows.length; i++) { + for (int j = 0; j < columns.length; j++) { + map.split(rows[i], columns[j]); + } + } + Arrays.sort(rows); + Arrays.sort(columns); + map.combine(rows, columns); + // map.removeRow(table.getSelectedRow()); + mainTable.revalidate(); + mainTable.repaint(); + } + + /** + * 拆分单元格 + */ + private void splitCell() { + isMeopSave = true; + // TODO Auto-generated method stub + int row = mainTable.getSelectedRow(); + int colmn = mainTable.getSelectedColumn(); + if (row < 0) { + MessageBox.post("请选择要拆分的单元格!", "错误", MessageBox.ERROR); + return; + } +// if (this.processRows != null && this.processRows.size() > 0 +// && !(this.processRows.contains(row))) { +// MessageBox.post("无权限拆分单元格!", "错误", MessageBox.ERROR); +// return; +// } + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + List valuesList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + for (int j = 0; j < entry.getValue().length; j++) { + valuesList.add(entry.getValue()[j]); + } + if (keysList.contains(row) && valuesList.contains(colmn)) { + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + } + it.remove(); + } + } + + mainTable.revalidate(); + mainTable.repaint(); + } + +// Jtable通用方法 + public CTable getNewjTable(CTable partsTable, DefaultTableModel dtm, Object[] titleNames, int rows) { + int simpleLen = 100; + int totleLen = 100; + if (partsTable == null) { + + if (rows == 0) { + map = new CTMap(rows + 1, titleNames.length); + } else { + map = new CTMap(rows, titleNames.length); + } + + // CTMap map = new CTMap(rows, titleNames.length); + map.setColumnIdentifiers(titleNames); + map.setEditable(false); + partsTable = new CTable(map); + + if (initRowHeight == 0) { + partsTable.setRowHeight(50); + } else { + partsTable.setRowHeight(initRowHeight); + } + + // partsTable.HiddenCell(0); + // 隐藏列 + // partsTable.HiddenCell(titleNames.length - 1); + // partsTable.HiddenCell(titleNames.length-2); + // partsTable.setRowHeight(1, 50); + TableCellTextAreaRenderer2 renderer = new TableCellTextAreaRenderer2(); + partsTable.setDefaultRenderer(Object.class, renderer); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + @Override + public void actionPerformed(ActionEvent arg0) { + Object source = arg0.getSource(); + if (source.equals(this.addItem)) { +// Component component = tabbedPane.getSelectedComponent(); +// if (component instanceof JScrollPane) { +// JScrollPane scrollPane = (JScrollPane) component; +// Component tableComponent = scrollPane.getViewport().getView(); +// if (tableComponent instanceof CTable) { + CTable table = this.mainTable; + if (table.getSelectedRow() > -1) { +// ((CTMap) table.getModel()).insertRow(table +// .getSelectedRow() + 1); + int selectedRow = table.getSelectedRow(); + Object valueAt = table.getValueAt(table.getSelectedRow(), table.getColumnCount() - 1); + int selectedColumn = table.getSelectedColumn(); + if (selectedColumn > -1) + if (combineMap != null && combineMap.size() != 0) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + int[] key = entry.getKey(); + int[] value = entry.getValue(); + if (value[0] == selectedColumn && key[0] == selectedRow) { + selectedRow = key[key.length - 1]; + } +// combine(entry.getKey(), entry.getValue()); + } + } + + combineMap = map.insertRowComb(selectedRow + 1, combineMap); + + System.out.println("valueAt=======>" + valueAt); +// + table.setValueAt(valueAt, selectedRow + 1, table.getColumnCount() - 1); + table.revalidate(); + table.repaint(); + // this.tabbedPane.updateUI(); + } +// } +// } + } else if (source.equals(this.addNodeItem)) { + // 获取国际化语言 + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + + final JFrame frame = new JFrame(); + frame.setLocationRelativeTo(this); + frame.setSize(new Dimension(400, 200)); + JLabel label = new JLabel(rb.getString("jdmc12_display.TITLE")); + final JTextField field = new JTextField(20); + JLabel idlabel = new JLabel(rb.getString("jdID12_display.TITLE")); + final JTextField idfield = new JTextField(20); + JButton okButton = new JButton(rb.getString("qd_display.TITLE")); + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + nodeName = field.getText(); + nodeID = idfield.getText(); + // node.add(new DefaultMutableTreeNode("烧结")); + String selectSql = ""; + String insterSql = ""; + insterSql = "insert into AHMC_PFMEA_TREE values(?,?,?,?)"; +// } + // String id = ""; + try { + UUID uid = UUID.randomUUID(); + TreeBean bean = new TreeBean(); + bean.setPlmeid(uid.toString().replace("-", "")); + bean.setId(nodeID); + bean.setName(nodeName); + bean.setParentId(""); + // tabbedPane.add(nodeName, new JScrollPane(table)); + // 获取数据库连接 + SqlUtilT.getTCConnection(); + SqlUtilT.write(new String[] { uid.toString().replace("-", ""), nodeID, nodeName, "" }, + insterSql); + refreshPFMEALeftTable(); + frame.dispose(); + int rowCount = leftTable.getRowCount(); + for (int t = 0; t < rowCount; t++) { + String uid111 = (String) leftTable.getValueAt(t, 0); + if (uid111.equals(bean.getPlmeid())) { + leftTable.setRowSelectionInterval(t, t); + System.out.println("-----------------" + t); + addSelected = t; + selectId = bean.getId(); + refreshPFMEATable(bean.getId()); + isMeopSave = true; + combineMap.clear(); + } + } + + // tabbedPane.updateUI(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + SqlUtilT.freeAll(); + } + } + }); + JButton celButton = new JButton("取消"); + celButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + frame.dispose(); + } + }); + JPanel jPanel = new JPanel(new PropertyLayout()); + jPanel.add("1.1.left.top", label); + jPanel.add("1.2.left.top", field); + jPanel.add("2.1.left.top", idlabel); + jPanel.add("2.2.left.top", idfield); + JPanel rootJPanel = new JPanel(new FlowLayout()); + rootJPanel.add(okButton); + rootJPanel.add(celButton); + JPanel panel = new JPanel(new BorderLayout()); + panel.add(new JScrollPane(jPanel), BorderLayout.CENTER); + panel.add(rootJPanel, BorderLayout.SOUTH); + frame.add(panel); + frame.show(); + } else if (source.equals(this.updateNodItem)) { + CTable table = this.leftTable; + final JFrame frame = new JFrame(); + frame.setLocationRelativeTo(this); + frame.setSize(new Dimension(400, 200)); + JLabel label = new JLabel("节点名称"); + final JTextField field = new JTextField(20); + field.setText(table.getValueAt(table.getSelectedRow(), 2) == null ? "" + : table.getValueAt(table.getSelectedRow(), 2).toString()); + JLabel idlabel = new JLabel("节点ID"); + final JTextField idfield = new JTextField(20); + idfield.setText(table.getValueAt(table.getSelectedRow(), 1) == null ? "" + : table.getValueAt(table.getSelectedRow(), 1).toString()); + JButton okButton = new JButton("确定"); + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + nodeName = field.getText() == null ? "" : field.getText(); + nodeID = idfield.getText() == null ? "" : idfield.getText(); +// "select ID from TREE where PLMEID = '"+leftTable.getSelectedRow(), 0).toString()+"'" + String selectSql = String.format("SELECT ID from AHMC_PFMEA_TREE WHERE PLMEID = \'%s\'", + leftTable.getValueAt(leftTable.getSelectedRow(), 0).toString()); + String updateSql = String.format("update AHMC_PFMEA_TREE set NAME = ?,ID = ? where PLMEID = \'%s\'", + leftTable.getValueAt(leftTable.getSelectedRow(), 0).toString()); + String updateSql2 = String.format("update AHMC_PFMEA_NODE set PARENT_ID = ? where PARENT_ID = ?"); + System.out.println(selectSql); + System.out.println(updateSql); + System.out.println(updateSql2); + ResultSet rs = null; + try { + SqlUtilT.getTCConnection(); + rs = SqlUtilT.read(selectSql); + rs.next(); + String oldId = rs.getString(1); + + SqlUtilT.write(new String[] { nodeName, nodeID }, updateSql); + SqlUtilT.write(new String[] { nodeID, oldId }, updateSql2); + + refreshPFMEALeftTable(); + + frame.dispose(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + SqlUtilT.freeAll(); + } + } + }); + // 获取国际化语言 + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + + JButton celButton = new JButton(rb.getString("qx_display.TITLE")); + celButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + frame.dispose(); + } + }); + JPanel jPanel = new JPanel(new PropertyLayout()); + jPanel.add("1.1.left.top", label); + jPanel.add("1.2.left.top", field); + jPanel.add("2.1.left.top", idlabel); + jPanel.add("2.2.left.top", idfield); + JPanel rootJPanel = new JPanel(new FlowLayout()); + rootJPanel.add(okButton); + rootJPanel.add(celButton); + JPanel panel = new JPanel(new BorderLayout()); + panel.add(new JScrollPane(jPanel), BorderLayout.CENTER); + panel.add(rootJPanel, BorderLayout.SOUTH); + frame.add(panel); + frame.show(); + } else if (source.equals(this.remItem)) { +// Component component = tabbedPane.getSelectedComponent(); +// if (component instanceof JScrollPane) { +// JScrollPane scrollPane = (JScrollPane) component; +// Component tableComponent = scrollPane.getViewport().getView(); +// if (tableComponent instanceof CTable) { + int i = JOptionPane.showConfirmDialog(null, "是否删除选中行?", "删除", JOptionPane.YES_NO_OPTION); + if (i != JOptionPane.YES_OPTION) { + return; + } + CTable table = this.mainTable; + + remRow(table); + +// if (table.getSelectedRow() >= 0 +// && table.getSelectedColumn() > 0) { +// (table.getCellEditor(table.getSelectedRow(), +// table.getSelectedColumn())).stopCellEditing(); +// if (((CTMap) table.getModel()).getValueAt( +// table.getSelectedRow(), 0) != null) { +// deleteRows.add(((CTMap) table.getModel()) +// .getValueAt(table.getSelectedRow(), 0) +// .toString()); +// } +//// ((CTMap) table.getModel()).removeRow(table +//// .getSelectedRow()); +// map.removeRow(table.getSelectedRow()); +// table.revalidate(); +// table.repaint(); +// } +// } +// } + } else if (source.equals(this.remNodeItem)) { +// Component component = tabbedPane.getSelectedComponent(); +// if (component instanceof JScrollPane) { +// JScrollPane scrollPane = (JScrollPane) component; +// Component tableComponent = scrollPane.getViewport().getView(); +// if (tableComponent instanceof CTable) { + CTable table = this.mainTable; + String deleteNodeSql = ""; + String deleteTreeSql = ""; +// switch (commandId) { +// case "com.connor.renben.process.plm.commands.ControlPlanLibrary": +// deleteTreeSql = String +// .format("delete from RB3_CONTROLPLAN_TREE where PLMEID = \'%s\'", +// leftTable.getValueAt(leftTable.getSelectedRow(), 0).toString()); +// deleteNodeSql = String +// .format("delete from RB3_CONTROLPLAN_NODE where PARENT_ID = \'%s\'", +// leftTable.getValueAt(leftTable.getSelectedRow(), 1).toString()); +// break; +// case "com.connor.renben.process.plm.commands.PFMEALibrary": + Object nameVal = leftTable.getValueAt(leftTable.getSelectedRow(), 0); + String nameString = ""; + if (nameVal != null) { + nameString = nameVal.toString(); + } + + deleteTreeSql = String.format("delete from AHMC_PFMEA_TREE where PLMEID = \'%s\'", + nameString == null ? "" : nameString); + Object valueAt = leftTable.getValueAt(leftTable.getSelectedRow(), 1); + String idString = ""; + if (valueAt != null) { + idString = valueAt.toString(); + } + + deleteNodeSql = String.format("delete from AHMC_PFMEA_NODE where PARENT_ID = \'%s\'", + idString == null ? "" : idString); +// break; +// case "com.connor.renben.process.plm.commands.Thesaurus": +// deleteTreeSql = String +// .format("delete from RB3_THESAURUS_TREE where PLMEID = \'%s\'", +// leftTable.getValueAt(leftTable.getSelectedRow(), 0).toString()); +// deleteNodeSql = String +// .format("delete from RB3_THESAURUS_NODE where PARENT_ID = \'%s\'", +// leftTable.getValueAt(leftTable.getSelectedRow(), 1).toString()); +// break; +// default: +// break; +// } + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteTreeSql); + SqlUtilT.freeAll(); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteNodeSql); + SqlUtilT.freeAll(); +// switch (commandId) { +// case "com.connor.renben.process.plm.commands.ControlPlanLibrary": +// refreshLeftTable(); +// break; +// case "com.connor.renben.process.plm.commands.PFMEALibrary": + refreshPFMEALeftTable(); +// break; +// case "com.connor.renben.process.plm.commands.Thesaurus": +// refreshThesaurusLeftTable(); +// break; +// default: +// break; +// } + // this.tabbedPane.remove(scrollPane); + // this.tabbedPane.updateUI(); +// } +// } + } else if (source.equals(this.saveButton)) { + okEvent(true); + // this.disposeDialog(); + +// this.dispose(); + } else if (source.equals(shrinkColumnItem)) { + for (int i = 0; i < mainTable.getSelectedColumns().length; i++) { + mainTable.getColumnModel().getColumn(mainTable.getSelectedColumns()[i]).setPreferredWidth(5); + } + mainTable.revalidate(); + mainTable.repaint(); + } else if (source.equals(celShrinkColumnItem)) { + for (int i = 0; i < mainTable.getSelectedColumns().length; i++) { + mainTable.getColumnModel().getColumn(mainTable.getSelectedColumns()[i]).setPreferredWidth(100); + } + mainTable.revalidate(); + mainTable.repaint(); + } else if (source.equals(splitItem)) { + splitCell(); + } else if (source.equals(comBineItem)) { + comBineCell(); + } else if (source.equals(this.reSetSize)) { + int i = JOptionPane.showConfirmDialog(null, "是否重置界面大小,点击“是”将在下次打开界面时生效!", "重置", JOptionPane.YES_NO_OPTION); + if (i == JOptionPane.YES_OPTION) { + SqlUtilT.getTCConnection(); + InputStream input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + String deleteSQL = String.format( + "DELETE FROM AHMC_PFMEAFRAME_SIZE WHERE USERNAME = '%s' AND TYPE = '%s'", userName, type); + SqlUtilT.delete(deleteSQL); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + isReSet = true; + SqlUtilT.freeAll(); + } + } else if (source.equals(setRowHeightBtn)) { + if (!this.setRowHeightTxt.getText().equals("")) { + String text = setRowHeightTxt.getText(); + + Integer valueOf = Integer.valueOf(text); + if (valueOf > 10 || valueOf < 1) { + MessageBox.post("调整行高建议在1-10倍之间", "提示", 2); + } + + mainTable.setRowHeight(valueOf * 40); + rowHeightAll = valueOf * 40; + } else { + + } + } else { + // this.disposeDialog(); + this.dispose(); + // this.setVisible(false); + } + } + + private void remRow(CTable table) { + // TODO Auto-generated method stub +// if (this.tabbedPane.getSelectedIndex() == 1) { +// if (table2.getSelectedRow() > 0 && table2.getSelectedColumn() > 0) { +// (table2.getCellEditor(table2.getSelectedRow(), table2.getSelectedColumn())).stopCellEditing(); +// } +// int[] rows = table2.getSelectedRows(); +// CTMap map = ((CTMap) this.table2.getModel()); +// for (int i = 0; i < rows.length; i++) { +// map.removeRow(table2.getSelectedRow()); +// } +// } else { + if (table.getSelectedRow() > 0 && table.getSelectedColumn() > 0) { + (table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn())).stopCellEditing(); + } + int[] rows = table.getSelectedRows(); + for (int i1 = 0; i1 < rows.length; i1++) { +// if (this.processRows != null && this.processRows.size() > 0 +// && !(this.processRows.contains(table.getSelectedRow()))) { +// MessageBox.post("无权限删除行!", "错误", MessageBox.ERROR); +// return; +// } + Map cellMap = new HashMap(); + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + if (keysList.contains(table.getSelectedRow())) { + int[] newKey = new int[entry.getKey().length - 1]; + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + if (i < newKey.length) { + newKey[i] = entry.getKey()[i]; + } + } + it.remove(); + cellMap.put(newKey, entry.getValue()); + } else if (!keysList.contains(table.getSelectedRow()) + && Integer.parseInt(keysList.get(0).toString()) > table.getSelectedRow()) { + int[] newKey = new int[entry.getKey().length]; + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + newKey[i] = entry.getKey()[i] - 1; + } + it.remove(); + cellMap.put(newKey, entry.getValue()); + } + } + if (map.getValueAt(table.getSelectedRow(), 0) != null) { + deleteRows.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + map.removeRow(table.getSelectedRow()); + // this.processRows = map.getProcessRowList(); + Iterator> cellIt = cellMap.entrySet().iterator(); + while (cellIt.hasNext()) { + Map.Entry entry = cellIt.next(); + if (entry.getKey().length > 0 && entry.getValue().length > 0) { + map.combine(entry.getKey(), entry.getValue()); + combineMap.put(entry.getKey(), entry.getValue()); + } + } + table.revalidate(); + table.repaint(); + } +// } + } + + private void okEvent(boolean isSave) { + // 获取屏幕尺寸和位置+++++ + String list1 = String.valueOf(((int) this.getSize().getWidth())) + "/" + + String.valueOf((int) this.getSize().getHeight()) + "/" + + String.valueOf(((int) this.getLocation().getX())) + "/" + + String.valueOf((((int) this.getLocation().getY()))); + + String list2 = ""; + for (int i = 1; i < 4; i++) { + if (i == 3) { + list2 += String.valueOf(((int) scrollPane2.getWidth())); + } else { + list2 += (String.valueOf(((int) this.leftTable.getColumnModel().getColumn(i).getWidth())) + "/"); + } + } + String list3 = ""; + for (int i = 1; i < 31; i++) { + if (i == 30) { + list3 += String.valueOf(((int) this.mainTable.getColumnModel().getColumn(i).getWidth())); + } else { + list3 += (String.valueOf(((int) this.mainTable.getColumnModel().getColumn(i).getWidth())) + "/"); + } + } + SqlUtilT.getTCConnection(); + InputStream input = null; + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + if (isFirstOpen) { + String insertSQL = "INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?,?)"; + SqlUtilT.write(new String[] { UUID.randomUUID().toString().replace("-", ""), this.userName, this.type, + list1, list2, list3, String.valueOf(mainTable.getRowHeight()) }, insertSQL); + isFirstOpen = false; + } else if (!isReSet) { + String updateSQL = String.format( + "update AHMC_PFMEAFRAME_SIZE set FRAMESIZE = ?, TABLE1SIZE = ?, TABLE2SIZE = ?,ROWHEIGHT = ? WHERE USERNAME ='%s' AND TYPE = '%s'", + userName, type); + SqlUtilT.update(new String[] { list1, list2, list3, String.valueOf(mainTable.getRowHeight()) }, updateSQL); + } + SqlUtilT.freeAll(); + /// ++++++ + + isMeopSave = false; + // TODO Auto-generated method stub + // 将数据保存到表单中 + try { + // 获取JTable中的数据 + List> dataValeList = getTableValue(); + System.out.println(dataValeList.size() + "dataValeList ======>"); + this.rootPanel.setBackground(Color.GREEN); + new Thread() { + @Override + public void run() { + try { + + ResultSet rs = null; + InputStream input = null; + try { + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + // 删除行 + for (int i = 0; i < deleteRows.size(); i++) { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + String deleteSQL = String.format(pro.getProperty("PFMEALIBRARYDELETE"), + deleteRows.get(i)); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + // 查询工序编号和ID + // 往数据库中写入数据 + + for (int i = 0; i < dataValeList.size(); i++) { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + List rowList = dataValeList.get(i); + if (rowList.get(0) != null && !rowList.get(0).equals("")) { + // 获取数据库连接 + String updateSQL = String.format(pro.getProperty("PFMEALIBRARYUPDATE"), + rowList.get(0)); + SqlUtilT.update(new String[] { rowList.get(1), rowList.get(2), rowList.get(3), + rowList.get(4), rowList.get(5), rowList.get(6), rowList.get(7), + rowList.get(8), rowList.get(9), rowList.get(10), rowList.get(11), + rowList.get(12), rowList.get(13), rowList.get(14), rowList.get(15), + rowList.get(16), rowList.get(17), rowList.get(18), rowList.get(19), + rowList.get(20), rowList.get(21), rowList.get(22), rowList.get(23), + rowList.get(24), rowList.get(25), rowList.get(26), rowList.get(27), + rowList.get(28), rowList.get(29), rowList.get(30), rowList.get(31), + rowList.get(32), rowList.get(34), rowList.get(35) }, updateSQL); + } else { + + String insertSQL = pro.getProperty("PFMEALIBRARYINSERT"); + SqlUtilT.write(new String[] { UUID.randomUUID().toString().replace("-", ""), + rowList.get(3), rowList.get(4), rowList.get(5), rowList.get(6), + rowList.get(7), rowList.get(8), rowList.get(9), rowList.get(10), + rowList.get(11), rowList.get(12), rowList.get(13), rowList.get(14), + rowList.get(15), rowList.get(16), rowList.get(17), rowList.get(18), + rowList.get(19), rowList.get(20), rowList.get(21), rowList.get(22), + rowList.get(23), rowList.get(33), rowList.get(24), rowList.get(1), + rowList.get(25), rowList.get(26), rowList.get(27), rowList.get(28), + rowList.get(29), rowList.get(30), rowList.get(31), rowList.get(32), + rowList.get(34), rowList.get(2), rowList.get(35) }, insertSQL); + } + SqlUtilT.freeAll(); + } + if (leftTable.getSelectedRow() > -1) { + System.out.println(leftTable.getSelectedRow() + "leftTable.getSelectedRow()"); + refreshPFMEATable(); + } else if (selectId != null && !selectId.equals("")) { + System.out.println("selectId == >" + selectId); + refreshPFMEATable(selectId); + } + // MessageBox.post("保存成功!", "成功", MessageBox.WARNING); + } catch (Exception e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); +// throw e; + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + this.sleep(1000); + rootPanel.setBackground(Color.WHITE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }.start(); + } catch (Exception e) { + // TODO Auto-generated catch block + this.rootPanel.setBackground(Color.RED); + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } + } + + private List> getTableValue() { +// TODO Auto-generated method stub + List> dataList = new ArrayList>(); +//Component[] components = tabbedPane.getComponents(); +//for (int i = 0; i < components.length; i++) { +// if (components[i] instanceof JScrollPane) { +// JScrollPane scrollPane = (JScrollPane) components[i]; +// Component tableComponent = scrollPane.getViewport().getView(); +// if (tableComponent instanceof CTable) { + CTable table = this.mainTable; + // 移除焦点 + if (table.getSelectedRow() >= 0 && table.getSelectedColumn() >= 0) { + (table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn())).stopCellEditing(); + } + System.out.println("table.getRowCount() ====>" + table.getRowCount()); + for (int j = 0; j < table.getRowCount(); j++) { + List rowValue = new ArrayList(); + for (int j2 = 0; j2 < table.getColumnCount(); j2++) { + if (j2 == 1) { + if (table.getValueAt(j, j2) != null)// isStr2Num(table.getValueAt(j, j2).toString()) + { + rowValue.add(table.getValueAt(j, j2).toString()); + + } else { + rowValue.add(""); + } + + } else { + rowValue.add(table.getValueAt(j, j2) == null ? "" : table.getValueAt(j, j2).toString()); + } + } + rowValue.add(TMomMethodUtil.getCombineCell(combineMap, j)); + System.out.println("j======>行" + j + "rowValue" + rowValue.toString()); + + rowValue.add(String.valueOf(j + 2)); + dataList.add(rowValue); + } + return dataList; + } + + private int[] Union(int[] a1, int[] a2) { + List list1 = new ArrayList(); + List list2 = new ArrayList(); + for (int i : a1) { + list1.add(i); + } + for (int i : a2) { + list2.add(i); + } + list1.removeAll(list2); + list2.addAll(list1); + int[] result = new int[list2.size()]; + for (int i = 0; i < list2.size(); i++) { + result[i] = list2.get(i); + } + return result; + } + + /** + * 查看一个字符串是否可以转换为数字 + * + * @param str 字符串 + * @return true 可以; false 不可以 + */ + public boolean isStr2Num(String str) { + try { + Integer.parseInt(str); + return true; + } catch (NumberFormatException e) { + return false; + } + } + + private class SpecialDialog extends AbstractAIFDialog implements ActionListener { + private JPanel tablePanel;// 表格控件 + private JTable table; + + private JPanel rootPanel;// 按钮 + private JButton okButton;// 确定 + private JButton celButton;// 取消 + + public SpecialDialog() { + // TODO Auto-generated constructor stub + super(); + init(); + } + + private void init() { + // 获取国际化语言 + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + // TODO Auto-generated method stub + this.setTitle(rb.getString("xztsfh12_display.TITLE")); + this.table = getjTable(this.table, null, new Object[] { 1, 2, 3, 4, 5, 6, 7, 8 }, + new Object[][] { { 1, 2, 3, 4, 5, 6, 7, 8 }, { 9, 0, "q", "w", "e", "r", "t", "y" } }); + this.setLocationRelativeTo(this); + this.table.setRowHeight(30); + this.table.getTableHeader().setVisible(false); + this.table.setFont(new Font("Y14.5M", 0, 15)); + this.tablePanel = new JPanel(new BorderLayout()); + this.tablePanel.add(this.table); + + this.okButton = new JButton(rb.getString("qd_display.TITLE")); + this.okButton.addActionListener(this); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.celButton.addActionListener(this); + this.rootPanel = new JPanel(new FlowLayout()); + this.rootPanel.add(this.okButton); + this.rootPanel.add(this.celButton); + + this.add(this.tablePanel, BorderLayout.CENTER); + this.add(this.rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + +// Jtable通用方法 + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(this.getTableModel(dtm, titleNames, values)); + partsTable.setCellSelectionEnabled(true); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + public DefaultTableModel getTableModel(DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + MyTableModel tableModel = null; + if (dtm == null) { + tableModel = new MyTableModel(values, titleNames); + } + return tableModel; + } + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + Object source = actionevent.getSource(); + if (source.equals(this.okButton)) { + // DefaultMutableTreeNode node = (DefaultMutableTreeNode) + // TMom012ControlPlanLibraryDialog.tree.getSelectionPath().getLastPathComponent(); + // node.add(new DefaultMutableTreeNode("烧结")); +// Component component = tabbedPane.getSelectedComponent(); +// if (component instanceof JScrollPane) { +// JScrollPane scrollPane = (JScrollPane) component; +// Component tableComponent = scrollPane.getViewport() +// .getView(); +// if (tableComponent instanceof CTable) { + CTable table = mainTable; + int row = table.getSelectedRow(); + int column = table.getSelectedColumn(); + // 保存特殊符号位置 + String columnName = table.getColumnName(table.getSelectedColumn()); + + int cursorIndex = ((TextAreaCellEditor) (table.getCellEditor(row, column))).getIndex(); + System.out.println("index+" + cursorIndex); + (table.getCellEditor(row, column)).stopCellEditing(); + // TMom010SetPFMEADialog.table.getDefaultEditor(Object.class).stopCellEditing(); + StringBuilder sb = new StringBuilder(table.getValueAt(row, column).toString()); + + // 定义循环,如果index的位置不是-1,就一直查找 + Integer index = 0; + while ((index = sb.toString().indexOf("\n", index)) != -1) { + + // 每循环一次就要明确下一次查找的位置 + index = index + "\n".length(); + // 每查找一次计数器自增 + cursorIndex++; + } + // 特殊符号 + Object special = table.getValueAt(row, table.getColumnCount() - 1); + if (special == null || special.toString() == "") { + table.setValueAt(columnName + "-" + cursorIndex, row, table.getColumnCount() - 1); + } else { + table.setValueAt(special + "|" + columnName + "-" + cursorIndex, row, table.getColumnCount() - 1); + } + System.out.println(sb.length()); + String s = sb + .insert(cursorIndex, this.table + .getValueAt(this.table.getSelectedRow(), this.table.getSelectedColumn()).toString()) + .toString(); + table.setValueAt(s, table.getSelectedRow(), table.getSelectedColumn()); + System.out.println(table.getValueAt(row, column).toString()); +// } +// } + } else { + this.dispose(); + } + } + } +} diff --git a/src/com/connor/hs2/plm/PFMEA/library/LibraryHandler.java b/src/com/connor/hs2/plm/PFMEA/library/LibraryHandler.java new file mode 100644 index 0000000..089b3e7 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/library/LibraryHandler.java @@ -0,0 +1,43 @@ +package com.connor.hs2.plm.PFMEA.library; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class LibraryHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + String commandId = arg0.getCommand().getId(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + LibraryCommand command = new LibraryCommand( + app, session, commandId); + try { + TCPreferenceService service = session.getPreferenceService(); + String[] options = service.getStringArray(TCPreferenceService.TC_preference_site, "Cust_PFMEALibrary_Privilege"); + boolean hasPrivilege = false; + for(String option : options){ + if(option.equals(session.getUserName())){ + command.executeModal(); + hasPrivilege = true; + } + } + if(!hasPrivilege){ + MessageBox.post("无管理权限!请联系系统管理员。", "错误", MessageBox.ERROR); + } + //command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("填写PFMEA库失败!", "错误", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/library/LibraryOperation.java b/src/com/connor/hs2/plm/PFMEA/library/LibraryOperation.java new file mode 100644 index 0000000..4a7c73d --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/library/LibraryOperation.java @@ -0,0 +1,37 @@ +package com.connor.hs2.plm.PFMEA.library; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; + +import com.connor.hs2.plm.PFMEA.design.SqlUtilT; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class LibraryOperation extends AbstractAIFOperation { + + private List> dataValueList; + private TCSession session; + private List deleteRows; + + public LibraryOperation(TCSession session, + List> dataValueList, List deleteRows) { + this.session = session; + this.dataValueList = dataValueList; + this.deleteRows = deleteRows; + } + + @Override + public void executeOperation() throws Exception { + + } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/library/sql.properties b/src/com/connor/hs2/plm/PFMEA/library/sql.properties new file mode 100644 index 0000000..f88d458 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/library/sql.properties @@ -0,0 +1,37 @@ +SETPFMEASELECT=SELECT * FROM AHMC_PFMEA WHERE PROCESSPUID = \'%s\' AND REVISIONID=\'%s\' ORDER BY to_number(NO),to_number(HH) +PFMEALIBRARYSELECT2=SELECT * FROM AHMC_PFMEALIBRARY WHERE PUID = \'%s\' order by NUM + +BOMCHECKSAVESELECTPFMEA=select MEOPID,STATION,gybh,GCMC from AHMC_PFMEA where PROCESSPUID = \'%s\' + +BOMCHECKSAVESELECTPFMEA2=select * from AHMC_PFMEA where PROCESSPUID = \'%s\' and MEOPID not in %s + +DELETEPFMEA=delete from AHMC_PFMEA where MEOPID = \'%s\' and PROCESSPUID = \'%s\' + +INSERTPFMEA=INSERT INTO AHMC_PFMEA VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + +PFMEALIBRARYSELECT=SELECT * FROM AHMC_PFMEA_NODE WHERE PARENT_ID = \'%s\' order BY ID +SETPFMEASELECT2=SELECT MEOPID,REQUIREMENT from AHMC_PFMEA where PROCESSPUID = \'%s\' group by MEOPID,REQUIREMENT +SETPFMEADELETE=delete from AHMC_PFMEA where PLMEID = \'%s\' + +SETPFMEAUPDATE=update AHMC_PFMEA set GYBH = ?,GCMC = ?,STATION = ?,REQUIREMENT = ?,QZSXMS = ?,QZSXHG = ?,YZD = ?,JB = ?,QZSXQY = ?,XXGCKZYF = ?,PDS = ?,XXGCKZTC = ?,TCD = ?,RPN = ?,JYCS = ?,ZZR = ?,JHWCRQ = ?,CQDCS = ?,NEW_SEV = ?,NEW_OCC = ?,NEW_DET = ?,NEW_RPN = ?,IDEAL_STATE = ?,SPECIAL = ?,HH = ?,HBDYG = ? ,OCCURRRENCE = ?,DETECTION = ?,PRIORITY = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ? where plmeid = \'%s\' AND revisionid=\'%s\' +TM2PFMEATREESELECT=select * from AHMC_PFMEA_TREE ORDER BY PARENT_ID,ID + +CONTROLPLANLIBRARYSELECT=SELECT * FROM AHMC_CONTROLPLAN_NODE WHERE PARENT_ID = \'%s\' order BY ID + +TM2CONTROLPLANTREESELECT=select * from AHMC_CONTROLPLAN_TREE ORDER BY TO_NUMBER(PARENT_ID) + +TM2THESAURUSTREESELECT=select * from AHMC_THESAURUS_TREE ORDER BY TO_NUMBER(PARENT_ID) + +TM2THESAURUSNODESELECT=SELECT * FROM AHMC_THESAURUS_NODE WHERE PARENT_ID = \'%s\' order BY ID + +PFMEALIBRARYUPDATE=update AHMC_PFMEA_NODE set ID = ?, STATION = ?,REQUIREMENT = ?,QZSXMS = ?,QZSXHG = ?,YZD = ?,JB = ?,QZSXQY = ?,XXGCKZYF = ?,PDS = ?,XXGCKZTC = ?,TCD = ?,RPN = ?,JYCS = ?,ZZR = ?,JHWCRQ = ?,CQDCS = ?,NEW_SEV = ?,NEW_OCC = ?,NEW_DET = ?,NEW_RPN = ?,IDEAL_STATE = ?,SPECIAL = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ?,P6 = ?,P7 = ?,P8 = ? where plmeid = \'%s\' + +PFMEALIBRARYDELETE=delete from AHMC_PFMEA_NODE where PLMEID = \'%s\' + +PFMEALIBRARYINSERT=INSERT INTO AHMC_PFMEA_NODE VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + + +SELECTFRAMESIZE=select * from AHMC_PFMEAFRAME_SIZE WHERE USERNAME = \'%s\' AND TYPE = \'%s\' +FRAMESIZEINSERT=INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?) +FRAMESIZEDELETE=DELETE FROM AHMC_PFMEAFRAME_SIZE WHERE USERNAME = \'%s\' AND TYPE = \'%s\' +FRAMESIZEUPDATE=update AHMC_PFMEAFRAME_SIZE set FRAMESIZE = ?, TABLE1SIZE = ?, TABLE2SIZE = ? WHERE USERNAME = \'%s\' AND TYPE = \'%s\' \ No newline at end of file diff --git a/src/com/connor/hs2/plm/gybb/ProcessOutPutDialog.java b/src/com/connor/hs2/plm/gybb/ProcessOutPutDialog.java new file mode 100644 index 0000000..bf8b23b --- /dev/null +++ b/src/com/connor/hs2/plm/gybb/ProcessOutPutDialog.java @@ -0,0 +1,140 @@ +package com.connor.hs2.plm.gybb; + +import java.awt.Dimension; +import java.awt.Label; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.util.List; + +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class ProcessOutPutDialog extends AbstractAIFDialog{ + + private TCSession session; + + private List revsionList; + + private JButton jButton; + private JFileChooser jFileChooser; +// private JLabel jLabel; +// private TCComponentItemRevision itemRevision; + public ProcessOutPutDialog(List revsionList, TCSession session) { + // TODO Auto-generated constructor stub + this.session=session; + this.revsionList=revsionList; + init(); + } + + private void init() { + // TODO Auto-generated method stub + + this.setTitle("选择数据保存路径"); + this.setLayout(new PropertyLayout()); + + this.setPreferredSize(new Dimension(550, 150)); +// jLabel = new JLabel("文件路径:"); + jButton = new JButton("浏览"); + jFileChooser = new JFileChooser(); + + + JPanel panel = new JPanel(); + panel.setLayout(new PropertyLayout()); + + panel.add("1.1.left.top",new Label("名称")); + panel.add("1.2.left.top",jtf2); +// panel.add("1.3.left.top",grBtn); + + panel.add("2.1.left.top",new Label("文件路径")); + panel.add("2.2.left.top",jtf); + jtf.setEditable(false); + panel.add("2.3.left.top",jButton); + + JButton okBtn = new JButton("导出"); + JButton disBtn = new JButton("取消"); + panel.add("3.1.left.top",okBtn); + panel.add("3.2.left.top",disBtn); + disBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + dispose(); + } + }); + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + this.jFileChooser.setCurrentDirectory(new File(deskPath)); + this.jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + + jButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub +// 选择模板文件 + selectFile = selectFileButtonEvent(); + + } + }); + + okBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String fileName = jtf2.getText(); + String filePath = jtf.getText(); +// for(TCComponentItemRevision revision : revsionList) { + ProcessOutputOperation operation = new ProcessOutputOperation(revsionList,session,fileName,filePath); + try { + operation.executeOperation(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } +// } + + + dispose(); + } + }); + this.add("1.1.left.top",panel); + + this.setResizable(true); + this.pack(); + this.setVisible(true); + + this.centerToScreen(); + this.showDialog(); + + } + private File selectFile; + private JTextField jtf = new JTextField(20); + private JTextField jtf2 = new JTextField(20); + public File selectFileButtonEvent(){ + int state = jFileChooser.showOpenDialog(null); + if(state == 1) { + return null; + }else{ + File f = jFileChooser.getSelectedFile(); + jtf.setText(f.getAbsolutePath()); + return f; + } + } + + +} diff --git a/src/com/connor/hs2/plm/gybb/ProcessOutputHandler.java b/src/com/connor/hs2/plm/gybb/ProcessOutputHandler.java new file mode 100644 index 0000000..d085116 --- /dev/null +++ b/src/com/connor/hs2/plm/gybb/ProcessOutputHandler.java @@ -0,0 +1,142 @@ +package com.connor.hs2.plm.gybb; + +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 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.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class ProcessOutputHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent comp = app.getTargetComponent(); + if(comp instanceof TCComponentItemRevision) { + TCComponentItemRevision itemRevision = (TCComponentItemRevision) comp; + + + + String type = itemRevision.getType(); + + if(type.equals("HS2_ProcessMEPRevision")) { + + + new Thread() { + @Override + public void run() { + revsionList.add(itemRevision); + ProcessOutPutDialog dialogBopLine=new ProcessOutPutDialog(revsionList,session); + + } + }.start(); + +// try { +// +// ProcessOutputOperation operation = new ProcessOutputOperation(itemRevision,session); +// +// operation.executeOperation(); +// +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + + }else if (type.equals("Part Revision")) { + + try { + + TCComponentBOMWindowType windowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + TCComponentBOMWindow bomWindow = windowType.create(null); + TCComponentBOMLine topLine = bomWindow.setWindowTopLine(itemRevision.getItem(), itemRevision, null, null); + + getMEProcessByItem(topLine); + + new Thread() { + @Override + public void run() { + ProcessOutPutDialog dialogBopLine=new ProcessOutPutDialog(revsionList,session); + + } + }.start(); + +// for( TCComponentItemRevision revision : revsionList) { +// +// ProcessOutputOperation operation = new ProcessOutputOperation(revision,session); +// try { +// operation.executeOperation(); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + +// + +// try { +// operation.executeOperation(); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + + } + } + + + + return null; + } + private List revsionList =new ArrayList(); + private void getMEProcessByItem(TCComponentBOMLine topLine) throws TCException { + // TODO Auto-generated method stub + + AIFComponentContext[] whereReferenced = topLine.getItemRevision().whereReferenced(); + + for(AIFComponentContext whereContext : whereReferenced ) { + InterfaceAIFComponent component = whereContext.getComponent(); + if(component instanceof TCComponentItemRevision) { + TCComponentItemRevision revision = (TCComponentItemRevision)component; + if(revision.getType().equals("HS2_ProcessMEPRevision")) { + revsionList.add(revision); + } +// revision. + } + } + + AIFComponentContext[] children = topLine.getChildren(); + + for(AIFComponentContext context : children) { + TCComponentBOMLine childLine = (TCComponentBOMLine) context.getComponent(); + String type = childLine.getItemRevision().getType(); + + if(type.equals("Part Revision")) { + getMEProcessByItem(childLine); + + } + + } + + + } + +} diff --git a/src/com/connor/hs2/plm/gybb/ProcessOutputOperation.java b/src/com/connor/hs2/plm/gybb/ProcessOutputOperation.java new file mode 100644 index 0000000..02396d7 --- /dev/null +++ b/src/com/connor/hs2/plm/gybb/ProcessOutputOperation.java @@ -0,0 +1,167 @@ +package com.connor.hs2.plm.gybb; + +import java.io.File; +import java.io.FileInputStream; +import java.util.ArrayList; +import java.util.List; + +import com.connor.hs2.plm.PFMEA.GXZDS.MethodUtil; +import com.spire.xls.Workbook; +import com.spire.xls.Worksheet; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.soa.client.model.strong.Message; + +public class ProcessOutputOperation extends AbstractAIFOperation{ + +// private TCComponentItemRevision itemRevision; + private TCSession session; + private File file; + private String nameString; + private String outPathString; + private List gyRevList; + public ProcessOutputOperation(List itemRevision,TCSession session, String fileName, String filePath) { + // TODO Auto-generated constructor stub + + this.session=session; + + this.gyRevList=itemRevision; + + this.file = MethodUtil.getFile(session, "工艺路线信息", "MSExcelX"); + + this.nameString = fileName; + + this.outPathString=filePath+"\\"; + + } +// private List revsionList =new ArrayList(); +// private String outPathString =System.getenv("TEMP") + "\\";//导出路径 + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + try { + int index=0; + Workbook wb = new Workbook(); +// File file1 = null; +// file1=MethodUtil.getFile(session, "工序作业指导书", "MSExcelX"); + FileInputStream input1 = new FileInputStream(this.file); + wb.loadFromHtml(input1); + //加载一个测试文档 + //wb.loadFromFile("C:\\美菱导出测试\\作业指导书.xlsx"); + //MessageBox.post(outPathString,"错误",MessageBox.ERROR); + //获取第一个工作表 + Worksheet sheet = wb.getWorksheets().get(0); + + System.out.println("生产工艺"+gyRevList.size()); + + for(TCComponentItemRevision itemRevision : gyRevList) { + TCComponentBOMWindowType windowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + TCComponentBOMWindow bomWindow = windowType.create(null); + TCComponentBOMLine topLine = bomWindow.setWindowTopLine(itemRevision.getItem(), itemRevision, null, null); + List revsionList =new ArrayList(); + AIFComponentContext[] children = topLine.getChildren(); + for(int t=0;t fuboBox; + private JComboBox comboBox; + + private Map> mbMap=new HashMap<>(); + private Map> mbUidMap=new HashMap<>(); + private List fuList = new ArrayList(); + private Map fuMap=new HashMap<>(); + public AddProcessCardDialog(AbstractAIFApplication app,TCComponentItemRevision rev) { + super(); + this.app = app; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.rev = rev; + } + public void run(){ + String folderUID = service.getStringValue("HS_MMPTEMPLATE"); + if(folderUID == null || "".equals(folderUID)) { + MessageBox.post(this,"首选项BH_TechDoc_template配置有误,请联系管理员检查!!", + "提示", MessageBox.INFORMATION); + return; + } + try { + TCComponent folder = session.stringToComponent(folderUID); + TCComponent[] folders = folder.getReferenceListProperty("contents"); + for (int i = 0; i < folders.length; i++) { + String fName = folders[i].getStringProperty("object_name"); + fuList.add(fName); + fuMap.put(fName, folders[i]); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + initUI(); + } + private void getMB(TCComponent folder,List mbList,Map map) { + // TODO Auto-generated method stub + try { + TCComponent[] items = folder.getReferenceListProperty("contents"); + for (int i = 0; i < items.length; i++) { + String id = items[i].getStringProperty("item_id"); + String mbName = items[i].getStringProperty("object_name"); + if(items[i] instanceof TCComponentFolder) { + TCComponentFolder f = (TCComponentFolder) items[i]; + getMB(f,mbList,map); + }else { + if(items[i] instanceof TCComponentItem) { + mbList.add(mbName); + System.out.println("进入获取模板对象"); + TCComponentItem item = (TCComponentItem) items[i]; + TCComponentItemRevision latestItemRev = item.getLatestItemRevision(); + TCComponent[] datasets = latestItemRev.getReferenceListProperty("IMAN_specification"); + if(datasets != null && datasets.length > 0) { + String uid = datasets[0].getUid(); + map.put(mbName, uid); + } + } + } + } + } catch (Exception e) { + // TODO: handle exception + } + } + public void initUI(){ + this.setLayout(new PropertyLayout()); + this.setTitle("添加工序卡片"); + this.setPreferredSize(new Dimension(300, 280)); + this.setResizable(false);// 不可变动窗口大小 + JPanel centerPanel = new JPanel(new PropertyLayout()); + centerPanel.setPreferredSize(new Dimension(280, 160)); + JLabel fuLable = new JLabel(" 模板分类:"); + fuLable.setFont(new Font("黑体", Font.PLAIN, 15)); + fuboBox = new JComboBox(); + fuboBox.addItem(" "); + for (int i = 0; i < fuList.size(); i++) { + fuboBox.addItem(fuList.get(i)); + } + + fuboBox.addItemListener(this); + JLabel mbLable = new JLabel(" 工艺卡:"); + mbLable.setFont(new Font("黑体", Font.PLAIN, 15)); + comboBox = new JComboBox(); + //comboBox.addItem(" "); +// List ziList = mbMap.get(fuList.get(0)); +// for (int i = 0; i < ziList.size(); i++) { +// comboBox.addItem(ziList.get(i)); +// } + centerPanel.add("1.1.center.top",fuLable); + centerPanel.add("1.2.center.top",fuboBox); + centerPanel.add("2.1.center.top",new JLabel(" ")); + centerPanel.add("3.1.center.top",mbLable); + centerPanel.add("3.2.center.top",comboBox); + centerPanel.add("4.1.center.top",new JLabel(" ")); + + JPanel southPanel = new JPanel(new FlowLayout()); + southPanel.setPreferredSize(new Dimension(280, 100)); + JButton okBtn = new JButton("确定"); + okBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + String fuName = (String) fuboBox.getSelectedItem(); + String mbName = (String) comboBox.getSelectedItem(); + if("".equals(mbName.trim())) { + MessageBox.post("请选择需要的模板!!","提示", MessageBox.INFORMATION); + return; + } + Map uidMap = mbUidMap.get(fuName); + String uid = uidMap.get(mbName); + System.out.println("1==========================="+uid); + AddProcessCardOperation operation = new AddProcessCardOperation(session,rev,uid,mbName); + session.queueOperation(operation); + disposeDialog(); + } + }); + JButton celBtn = new JButton("取消"); + celBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + southPanel.add(okBtn); + southPanel.add(celBtn); + this.add("1.1.center.top",new JLabel(" ")); + this.add("2.1.center.top",centerPanel); + this.add("3.1.center.top",southPanel); + this.setBounds(5, 5, 5, 5); + this.centerToScreen(); + this.setAlwaysOnTop(true); + this.showDialog(); + } + @SuppressWarnings("unchecked") + @Override + public void itemStateChanged(ItemEvent e) { + // TODO Auto-generated method stub + JComboBox source = (JComboBox)e.getSource(); + String fuName = (String) source.getSelectedItem(); + comboBox.removeAllItems(); + //comboBox = new JComboBox(); + //comboBox.addItem(" "); + System.out.println("fuName==="+fuName); + if(!"".equals(fuName.trim())) { + if(!mbUidMap.containsKey(fuName)) { + System.out.println("11"); + List mbList = new ArrayList(); + TCComponent comp = fuMap.get(fuName); + Map map=new HashMap<>(); + getMB(comp,mbList,map); + mbMap.put(fuName,mbList); + mbUidMap.put(fuName, map); + for (int i = 0; i < mbList.size(); i++) { + comboBox.addItem(mbList.get(i)); + } + }else { + System.out.println("22"); + List ziList = mbMap.get(fuName); + for (int i = 0; i < ziList.size(); i++) { + comboBox.addItem(ziList.get(i)); + } + } + } + } +} diff --git a/src/com/connor/hs2/plm/gyh/addProcessCard/AddProcessCardDialog2.java b/src/com/connor/hs2/plm/gyh/addProcessCard/AddProcessCardDialog2.java new file mode 100644 index 0000000..d68b0bf --- /dev/null +++ b/src/com/connor/hs2/plm/gyh/addProcessCard/AddProcessCardDialog2.java @@ -0,0 +1,100 @@ +package com.connor.hs2.plm.gyh.addProcessCard; + +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.PropertyLayout; + +public class AddProcessCardDialog2 extends AbstractAIFDialog{ + /** + * + */ + private static final long serialVersionUID = 1L; + private AbstractAIFApplication app; + private TCComponentItemRevision rev; + private TCSession session; + private TCPreferenceService service; + private JComboBox comboBox; + private Map map=new HashMap<>(); + + public AddProcessCardDialog2(AbstractAIFApplication app,TCComponentItemRevision rev) { + this.app = app; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.rev = rev; + } + public void run(){ + initUI(); + } + public void initUI(){ + this.setLayout(new PropertyLayout()); + this.setTitle("添加工序卡片"); + this.setPreferredSize(new Dimension(300, 150)); + this.setResizable(false);// 不可变动窗口大小 + JPanel centerPanel = new JPanel(new PropertyLayout()); + centerPanel.setPreferredSize(new Dimension(280, 60)); + JLabel nameLable = new JLabel(" 工艺卡:"); + nameLable.setFont(new Font("", Font.PLAIN, 15)); + comboBox = new JComboBox(); + + String[] names = service.getStringValues("HS_MMPTEMPLATE"); + map = new HashMap(); + for (int i = 0; i < names.length; i++) { + if(names[i].contains(":")) { + String[] vals = names[i].split(":"); + map.put(vals[0], vals[1]); + comboBox.addItem(vals[0]); + }else if(names[i].contains(":")) { + String[] vals = names[i].split(":"); + map.put(vals[0], vals[1]); + comboBox.addItem(vals[0]); + } + } + + centerPanel.add("1.1.center.top",nameLable); + centerPanel.add("1.2.center.top",comboBox); + JPanel southPanel = new JPanel(new FlowLayout()); + southPanel.setPreferredSize(new Dimension(280, 80)); + JButton okBtn = new JButton("确定"); + okBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + String mbName = (String) comboBox.getSelectedItem(); + String mbUID = map.get(mbName); + AddProcessCardOperation operation = new AddProcessCardOperation(session,rev,mbUID,mbName); + session.queueOperation(operation); + disposeDialog(); + } + }); + JButton celBtn = new JButton("取消"); + celBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + southPanel.add(okBtn); + southPanel.add(celBtn); + this.add("1.1.center.top",new JLabel(" ")); + this.add("2.1.center.top",centerPanel); + this.add("3.1.center.top",southPanel); + this.setBounds(5, 5, 5, 5); + this.centerToScreen(); + this.showDialog(); + } +} diff --git a/src/com/connor/hs2/plm/gyh/addProcessCard/AddProcessCardHandler.java b/src/com/connor/hs2/plm/gyh/addProcessCard/AddProcessCardHandler.java new file mode 100644 index 0000000..a592269 --- /dev/null +++ b/src/com/connor/hs2/plm/gyh/addProcessCard/AddProcessCardHandler.java @@ -0,0 +1,58 @@ +package com.connor.hs2.plm.gyh.addProcessCard; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class AddProcessCardHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent comp = app.getTargetComponent(); + TCComponentItemRevision rev = null; + if(comp instanceof TCComponentItemRevision) { + rev = (TCComponentItemRevision) comp; + }else if(comp instanceof TCComponentBOMLine){ + System.out.println("bomline"); + TCComponentBOMLine line = (TCComponentBOMLine) comp; + try { + rev = line.getItemRevision(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else { + MessageBox.post("请选中版本对象或者BOMLine添加工序卡片!!!!","提示",MessageBox.INFORMATION); + return null; + } + if(rev != null) { + String type = rev.getType(); + System.out.println("选中的类型为: "+type); + if("HS2_PartMEPRevision".equals(type)) { + try { + AddProcessCardDialog dialog = new AddProcessCardDialog(app,rev); + new Thread(dialog).start(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else { + MessageBox.post("选中的不是工序版本对象,请检查后再添加工序卡片!!!!","提示",MessageBox.INFORMATION); + return null; + } + } + return null; + } + +} diff --git a/src/com/connor/hs2/plm/gyh/addProcessCard/AddProcessCardOperation.java b/src/com/connor/hs2/plm/gyh/addProcessCard/AddProcessCardOperation.java new file mode 100644 index 0000000..8fc6fce --- /dev/null +++ b/src/com/connor/hs2/plm/gyh/addProcessCard/AddProcessCardOperation.java @@ -0,0 +1,108 @@ +package com.connor.hs2.plm.gyh.addProcessCard; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +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.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +public class AddProcessCardOperation extends AbstractAIFOperation{ + private TCSession session; + private TCComponentItemRevision rev; + private String uid; + private String mbName; + public AddProcessCardOperation(TCSession session, TCComponentItemRevision rev, String mbUID,String mbName) { + // TODO Auto-generated constructor stub + this.rev = rev; + this.session = session; + this.uid = mbUID; + this.mbName = mbName; + } + + @Override + public void executeOperation() throws Exception { + try { + + + TCComponentItemType tcComponentItemType = (TCComponentItemType) session.getTypeComponent("HS2_ProcessCard"); + String newID = tcComponentItemType.getNewID(); + String newRev = tcComponentItemType.getNewRev(null); + TCComponentItem item = tcComponentItemType.create(newID, newRev, "HS2_ProcessCard",rev.getStringProperty("object_name")+"-工艺卡", "", null); + rev.getItem().add("IMAN_reference", item); + TCComponentDataset mbDataset = createDataset(uid,newID,rev); +// TCComponentTcFile[] tcFiles = mbDataset.getTcFiles(); +// tcFiles[0].setStringProperty("original_file_name", rev.getStringProperty("object_name")+"-工艺卡"); + item.getLatestItemRevision().add("IMAN_specification",mbDataset);//数据集关系 + MessageBox.post("工艺卡片添加成功","提示",MessageBox.INFORMATION); + } catch (Exception e) { + MessageBox.post("工艺卡片添加失败\n"+e.getLocalizedMessage(),"错误",MessageBox.ERROR); + e.printStackTrace(); + } + } + /** + * 方法描述 + * 根据参数创建模板文件数据集。 + * @param + * uid :需要上传的模板数据集uid + * newRev : 新版本对象 + * 返回值描述 + * 返回创建的模板数据集对象 + */ + private TCComponentDataset createDataset( + String uid,String idString,TCComponentItemRevision rev) { + TCComponentDataset mbDataset = null; + System.out.println("==================="+uid); + try { + TCComponentDataset comp = (TCComponentDataset) session.stringToComponent(uid); + String name = idString +"-"+ rev +"-"+ mbName; + mbDataset=comp.saveAs(name); + //ref_list + TCComponent[] comps = mbDataset.getRelatedComponents("ref_list"); + String oldName = comps[0].getStringProperty("original_file_name"); + StringBuilder sb = new StringBuilder(name); + sb.append(oldName.substring(oldName.lastIndexOf("."))); + String newName = sb.toString(); + newName = newName.replace("?", " "); + newName = newName.replace("、", " "); + newName = newName.replace("\\", " "); + newName = newName.replace("/", " "); + newName = newName.replace("*", " "); + newName = newName.replace("“", " "); + newName = newName.replace("”", " "); + newName = newName.replace("<", " "); + newName = newName.replace(">", " "); + newName = newName.replace("|", " "); + System.out.println("newName===="+newName); + comps[0].lock(); + comps[0].setStringProperty("original_file_name", newName); + comps[0].save(); + comps[0].unlock(); + } catch (TCException e) { + e.printStackTrace(); + } + return mbDataset; + } +// public static void main(String[] args) { +// String name = "123123-1/-*-"; +// String oldName ="D区.E区/-*-.xls"; +// oldName = oldName.replace("/", " "); +// StringBuilder sb = new StringBuilder(name); +// sb.append(oldName.substring(oldName.lastIndexOf("."))); +// String newName = sb.toString(); +// newName = newName.replace("?", " "); +// newName = newName.replace("、", " "); +// newName = newName.replace("\\", " "); +// newName = newName.replace("/", " "); +// newName = newName.replace("*", " "); +// newName = newName.replace("“", " "); +// newName = newName.replace("”", " "); +// newName = newName.replace("<", " "); +// newName = newName.replace(">", " "); +// newName = newName.replace("|", " "); +// System.out.println("newName===="+newName); +// } +} diff --git a/src/com/connor/hs2/plm/historyFolder/HistoryFolderDialog.java b/src/com/connor/hs2/plm/historyFolder/HistoryFolderDialog.java new file mode 100644 index 0000000..528bdc5 --- /dev/null +++ b/src/com/connor/hs2/plm/historyFolder/HistoryFolderDialog.java @@ -0,0 +1,185 @@ +package com.connor.hs2.plm.historyFolder; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Label; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.util.List; + +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTextField; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class HistoryFolderDialog extends AbstractAIFDialog{ + private AbstractAIFApplication app; + private TCSession session; + + + private JButton jButton; + private JFileChooser jFileChooser; + private JLabel jLabel; + private TCComponentFolder folder; + + public HistoryFolderDialog(TCSession session,TCComponentFolder folder) { + this.session=session; + this.folder=folder; + } + + private File selectFile; + @Override + public void run() { + //显示窗口 + init(); + //启用查询按钮 +// qryBtn.setEnabled(true); + } + + private JRadioButton grBtn; + private JRadioButton projectBtn; + private void init() { + // TODO Auto-generated method stub + this.setTitle("选择数据上传路径"); + this.setLayout(new PropertyLayout()); + + this.setPreferredSize(new Dimension(550, 150)); + jLabel = new JLabel("选择导入文件:"); + jButton = new JButton("浏览"); + jFileChooser = new JFileChooser(); + + + JPanel panel = new JPanel(); + panel.setLayout(new PropertyLayout()); + projectBtn = new JRadioButton("项目文件夹"); + grBtn = new JRadioButton("个人文件夹"); + ButtonGroup bg=new ButtonGroup(); + bg.add(projectBtn); + bg.add(grBtn); + projectBtn.setSelected(true); + panel.add("1.1.left.top",new Label("文件夹类型")); + panel.add("1.2.left.top",projectBtn); + panel.add("1.3.left.top",grBtn); + + panel.add("2.1.left.top",new Label("文件路径")); + panel.add("2.2.left.top",jtf); + jtf.setEditable(false); + panel.add("2.3.left.top",jButton); + + JButton okBtn = new JButton("上传"); + JButton disBtn = new JButton("取消"); + panel.add("3.1.left.top",okBtn); + panel.add("3.2.left.top",disBtn); + disBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + dispose(); + } + }); + okBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if(jtf.getText().trim().equals("")&&selectFile==null){ + MessageBox.post("请选择文件夹路径,或者文件","提示",2); + return; + }else { + if(selectFile.isDirectory()) { + System.out.println("选中的是文件夹路径,创建文件夹"); + if(projectBtn.isSelected()) { + HistoryFolderOperation operation=new HistoryFolderOperation(selectFile,session,folder,true); + try { + operation.executeOperation(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }else { + HistoryFolderOperation operation=new HistoryFolderOperation(selectFile,session,folder,false); + try { + operation.executeOperation(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + + MessageBox.post("上传完成","提示",2); + }else if(selectFile.isFile()){ + System.out.println("选中的是文件,直接上传文件,创建数据集"); + + String name = selectFile.getPath(); + String[] split = name.split("\\."); + String fileType = split[split.length-1]; + + System.out.println(fileType); + + List datasetType = Utils.getDatasetType(fileType); + + try { + Utils.importDataset(session, folder, "contents", selectFile, datasetType.get(0), datasetType.get(1)); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + MessageBox.post("上传完成","提示",2); + }else { + System.out.println("????"); + } + } + } + }); +// this.jFileChooser.setCurrentDirectory(new File()); + this.jFileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); + + jButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub +// 选择模板文件 + selectFile = selectFileButtonEvent(); + + } + }); + + + this.add("1.1.left.top",panel); + + this.setResizable(true); + this.pack(); + this.setVisible(true); + + this.centerToScreen(); + this.showDialog(); + + } + private JTextField jtf = new JTextField(20); + public File selectFileButtonEvent(){ + int state = jFileChooser.showOpenDialog(null); + if(state == 1) { + return null; + }else{ + File f = jFileChooser.getSelectedFile(); + jtf.setText(f.getPath()); + return f; + } + } + + +} diff --git a/src/com/connor/hs2/plm/historyFolder/HistoryFolderHandler.java b/src/com/connor/hs2/plm/historyFolder/HistoryFolderHandler.java new file mode 100644 index 0000000..36141fd --- /dev/null +++ b/src/com/connor/hs2/plm/historyFolder/HistoryFolderHandler.java @@ -0,0 +1,50 @@ +package com.connor.hs2.plm.historyFolder; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + + + +public class HistoryFolderHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + +// InputStream input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// Properties pro = new Properties(); +// +// try { +// pro.load(input); +// } catch (IOException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if(targetComponent==null + ||!(targetComponent instanceof TCComponentFolder)) { + MessageBox.post("请选中文件夹,请重新选择!", "错误", MessageBox.ERROR); + return null; + } + + TCComponentFolder folder=(TCComponentFolder)targetComponent; + HistoryFolderDialog dialog=new HistoryFolderDialog(session,folder); + new Thread(dialog).start(); + + return null; + } + +} diff --git a/src/com/connor/hs2/plm/historyFolder/HistoryFolderOperation.java b/src/com/connor/hs2/plm/historyFolder/HistoryFolderOperation.java new file mode 100644 index 0000000..21f4d06 --- /dev/null +++ b/src/com/connor/hs2/plm/historyFolder/HistoryFolderOperation.java @@ -0,0 +1,39 @@ +package com.connor.hs2.plm.historyFolder; + +import java.io.File; +import java.util.List; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCSession; + +public class HistoryFolderOperation extends AbstractAIFOperation { + private TCSession session; + private TCComponentFolder folder; + private File selectFile; +// private List datasetType; + private boolean flag; + public HistoryFolderOperation(File selectFile2, TCSession session2, TCComponentFolder folder2, + boolean b) { + // TODO Auto-generated constructor stub +// this.datasetType=b; + this.selectFile=selectFile2; + this.session=session2; + this.flag=b; + this.folder=folder2; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + try { + + Utils.createFolder(selectFile,session,folder,flag); +// Utils.importDataset(session, folder, "contents", selectFile, datasetType.get(0), datasetType.get(1)); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + +} diff --git a/src/com/connor/hs2/plm/historyFolder/Utils.java b/src/com/connor/hs2/plm/historyFolder/Utils.java new file mode 100644 index 0000000..2dc783a --- /dev/null +++ b/src/com/connor/hs2/plm/historyFolder/Utils.java @@ -0,0 +1,260 @@ +package com.connor.hs2.plm.historyFolder; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; +import com.teamcenter.services.rac.core.DataManagementService; +import com.teamcenter.services.rac.core._2008_06.DataManagement; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse; + +public class Utils { + + + public static void importDataset(TCSession session, TCComponent parent, String rel, File f, String dsType, + String refName) throws Exception { + if (f != null && f.exists() && !isEmpty(dsType) && !isEmpty(refName)) { + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent(dsType); + TCComponentDataset dataset = datasetType.create(f.getName(), "", dsType); + String[] paths = new String[]{f.getAbsolutePath()}; + String[] refs = new String[]{refName}; + dataset.setFiles(paths, refs); + if (parent != null && !isEmpty(rel)) { + parent.add(rel, dataset); + }else { + System.out.println("添加失败?"); + } + + } + } + public static boolean isEmpty(String str) { + return str == null || "".equals(str.trim()); + } + public static void createFolder(File dirFile,TCSession session,TCComponentFolder folder,boolean flag) {// 删除目录(文件夹)以及目录下的文件 + + boolean isLast=true; + + List fileList=new ArrayList(); + + List dicList=new ArrayList(); + +// = new File(dirPath); + // 如果dir对应的文件不存在,或者不是一个目录,则退出 + if (!dirFile.exists() || !dirFile.isDirectory()) { + return; + } + File[] files = dirFile.listFiles();// 获得传入路径下的所有文件 + for (int i = 0; i < files.length; i++) {// 循环遍历删除文件夹下的所有文件(包括子目录) + if (files[i].isFile()) { + + fileList.add(files[i]); + + + } else if(files[i].isDirectory()){ + + + dicList.add(files[i]); + isLast=false; + + } + } + + if(isLast) { +// System.out.println("创建当前文件夹 类型HS2_Folder"+flag); + try { + String folderType="Folder"; + if(flag) { + folderType="HS2_ProjectFolder"; + } + TCComponentFolder createFolderBySOA = createFolderBySOA(session,folderType,dirFile.getName()); + folder.add("contents", createFolderBySOA); + + for(File f:fileList) { + String[] split = f.getPath().split("\\."); + List datasetType = getDatasetType(split[split.length-1]); + System.out.println("11111111"); + +// HS2_ProjectFolderRelation + if(createFolderBySOA.getType().equals("HS2_ProjectFolder")) { + importDataset(session,createFolderBySOA,"HS2_ProjectFolderRelation",f,datasetType.get(0),datasetType.get(1)); + }else { + importDataset(session,createFolderBySOA,"contents",f,datasetType.get(0),datasetType.get(1)); + } + } + +// File[] filess = dirFile.listFiles(); + +// createFolder(dirFile,session,createFolderBySOA,flag); + + + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + }else { + TCComponentFolder createFolderBySOA=null; + try { + createFolderBySOA = createFolderBySOA(session,"Folder",dirFile.getName()); + folder.add("contents", createFolderBySOA); + + for(File f:fileList) { + String[] split = f.getName().split("\\."); + List datasetType = getDatasetType(split[split.length-1]); + importDataset(session,createFolderBySOA,"contents",f,datasetType.get(0),datasetType.get(1)); + } +// createFolder(dirFile,session,createFolderBySOA,flag); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + for(File f:dicList) { + createFolder(f,session,createFolderBySOA,flag); + } + } + + + } + + +// Text Text +// XMLRenderingStylesheet XMLRendering +// Zip ZIPFILE +// Image Image +// DirectModel JTPART +// MSWord word MSWorX word +// MSPowerPointX powerpoint +// MSExcel excel MSExcelX excel + + public static List getDatasetType(String ext) { + String datasetType=""; + String refName=""; + switch (ext) { + case "doc": + datasetType="MSWord"; + refName="word"; + break; + case "docx": + datasetType="MSWordX"; + refName="word"; + break; + case "txt": + datasetType="Text"; + refName="Text"; + break; + case "xls": + datasetType="MSExcel"; + refName="excel"; + break; + case "xlsx": + datasetType="MSExcelX"; + refName="excel"; + break; + case "png": + datasetType="Image"; + refName="Image"; + break; + case "zip": + datasetType="Zip"; + refName="ZIPFILE"; + break; + case "jt": + datasetType="DirectModel"; + refName="JTPART"; + break; + case "xml": + datasetType="XMLRenderingStylesheet"; + refName="XMLRendering"; + break; + case "pdf": + datasetType="PDF"; + refName="PDF_Reference"; + break; + case "CATPart": + datasetType="CATPart"; + refName="catpart"; + break; + case "dwg": + datasetType="HS2_CAD"; + refName="HS2_CAD_reference"; + break; + case "CATDrawing": + datasetType="CATDrawing"; + refName="catdrawing"; + break; + case "CATProduct": + datasetType="CATProduct"; + refName="catproduct"; + break; + case "jpg": + datasetType="JPEG"; + refName="JPEG_Reference"; + break; +// case "jpeg": +// datasetType="JPEG"; +// refName="JPEG_Reference"; +// break; + case "tif": + datasetType="TIF"; + refName="TIF_Reference"; + break; +// case "rar": +// datasetType="Zip"; +// refName="ZIPFILE"; +// break; + default: + datasetType="CAEAnalysisDS"; + refName="CAEAnalysisData"; + break; + } + List list=new ArrayList(); + list.add(datasetType); + list.add(refName); + return list; + } + + + public static TCComponentFolder createFolderBySOA(TCSession session,String tyeString,String name) throws ServiceException { + + DataManagementService service = DataManagementService.getService(session); + CreateIn[] input=new CreateIn[1]; + input[0]=new CreateIn(); + input[0].clientId="Test"; + DataManagement.CreateInput createInput=new DataManagement.CreateInput(); + + Map stringProps = new HashMap(); + + stringProps.put("object_name", name); + stringProps.put("object_desc", name+"描述"); + createInput.boName=tyeString; + createInput.stringProps=stringProps; + + input[0].data=createInput; + + CreateResponse createObjects = service.createObjects(input); + com.teamcenter.rac.kernel.ServiceData serviceData = createObjects.serviceData; + if(serviceData.sizeOfPartialErrors()>0) { + System.out.println(serviceData.getPartialError(0).getMessages()[0]); + } + + if(serviceData.sizeOfCreatedObjects()>0) { + TCComponent createdObject = serviceData.getCreatedObject(0); + return (TCComponentFolder)createdObject; + } + + + + return null; + } +} diff --git a/src/com/connor/hs2/plm/projectmanage/assigntask/AssignPersonAction.java b/src/com/connor/hs2/plm/projectmanage/assigntask/AssignPersonAction.java new file mode 100644 index 0000000..ac78dd2 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/assigntask/AssignPersonAction.java @@ -0,0 +1,28 @@ +package com.connor.hs2.plm.projectmanage.assigntask; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonHandler; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +public class AssignPersonAction extends AbstractAIFAction { + private AbstractAIFApplication app; + + public AssignPersonAction(AbstractAIFApplication app, String arg1) { + super(app, arg1); + // TODO Auto-generated constructor stub + this.app = app; + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + AssignPersonCommand command = new AssignPersonCommand(app); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/assigntask/AssignPersonCommand.java b/src/com/connor/hs2/plm/projectmanage/assigntask/AssignPersonCommand.java new file mode 100644 index 0000000..e28ff94 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/assigntask/AssignPersonCommand.java @@ -0,0 +1,26 @@ +package com.connor.hs2.plm.projectmanage.assigntask; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.kernel.TCSession; + +public class AssignPersonCommand extends AbstractAIFCommand { + private AbstractAIFApplication app; + + public AssignPersonCommand(AbstractAIFApplication app) { + super(); + this.app = app; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + super.executeModal(); + TCSession session = (TCSession) app.getSession(); + AssignPersonOpeartion operation = new AssignPersonOpeartion(session, app); + session.queueOperation(operation); + + } + + +} diff --git a/src/com/connor/hs2/plm/projectmanage/assigntask/AssignPersonHandler.java b/src/com/connor/hs2/plm/projectmanage/assigntask/AssignPersonHandler.java new file mode 100644 index 0000000..5c1c52c --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/assigntask/AssignPersonHandler.java @@ -0,0 +1,75 @@ +package com.connor.hs2.plm.projectmanage.assigntask; + +import java.util.List; + +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.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentGroupMember; +import com.teamcenter.rac.kernel.TCComponentGroupType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentRole; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +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.MessageBox; + +/** + * 时间表任务指派责任人 + * + * @author conner.mcc + * + */ +public class AssignPersonHandler extends AbstractHandler { + + private TCSession session ; + private TCComponentScheduleTask schedule; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + if (app == null) { + MessageBox.post("请选择时间表", "提示", MessageBox.INFORMATION); + return null; + } + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + // session = (TCSession) app.getSession(); + + if (targetComponent instanceof TCComponentSchedule) { + // schedule = (TCComponentSchedule) targetComponent; + AssignPersonAction action = new AssignPersonAction(app, null); + new Thread(action).start(); + // setTaskPerson(schedule); + } else if (targetComponent instanceof TCComponentScheduleTask) { + + schedule = (TCComponentScheduleTask) targetComponent; + try { + if (schedule.getIntProperty("task_type") == 6) { + AssignPersonAction action = new AssignPersonAction(app, null); + new Thread(action).start(); + }else + { + MessageBox.post("请选择时间表", "提示", MessageBox.INFORMATION); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else { + MessageBox.post("请选择时间表", "提示", MessageBox.INFORMATION); + } + + return null; + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/assigntask/AssignPersonOpeartion.java b/src/com/connor/hs2/plm/projectmanage/assigntask/AssignPersonOpeartion.java new file mode 100644 index 0000000..0dc2dfb --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/assigntask/AssignPersonOpeartion.java @@ -0,0 +1,344 @@ +package com.connor.hs2.plm.projectmanage.assigntask; + +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.connor.hs2.plm.projectmanage.utils.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.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentGroupMember; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentResourceAssignment; +import com.teamcenter.rac.kernel.TCComponentRole; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCComponentUserType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.schedule.commands.assigntotask.ResourceAssignmentProxy; +import com.teamcenter.rac.schedule.commands.assigntotask.UIAssignmentCache; +import com.teamcenter.rac.schedule.project.common.dataModel.ScheduleTask; +import com.teamcenter.rac.schedule.project.server.RACInterface.RACInterface; +import com.teamcenter.rac.schedule.project.server.RACInterface.RACInterfaceFactory; +import com.teamcenter.rac.schedule.soainterface.AssignResourcesRunner; +import com.teamcenter.rac.schedule.soainterface.DeleteAssignmentsRunner; +import com.teamcenter.rac.schedule.soainterface.SOAExecutor; +import com.teamcenter.rac.schedule.soainterface.UpdateAssignmentsRunner; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.services.rac.projectmanagement._2015_07.ScheduleManagement.AssignmentCreateContainer; +public class AssignPersonOpeartion extends AbstractAIFOperation { + + private TCSession session; + private TCComponentProject project; + private TCComponentSchedule schedule; + //private Set unAssignedSet; + private AbstractAIFApplication app; + private RACInterface rIfc; + + //private UIAssignmentCache assignmentCache; + private ProgressBarThread wait; + //private List problemTasks; + private List list = new ArrayList<>(); + //protected Map scheduleMap = new HashMap<>(); + private Map> problemScheduleTask; + public AssignPersonOpeartion(TCSession session, AbstractAIFApplication app) { + super(); + this.session = session; + this.app = app; + //problemTasks = new ArrayList(); + problemScheduleTask = new LinkedHashMap>(); + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if (targetComponent instanceof TCComponentSchedule) { + schedule = (TCComponentSchedule) targetComponent; + }else if (targetComponent instanceof TCComponentScheduleTask) { + schedule = (TCComponentSchedule) ((TCComponentScheduleTask)targetComponent).getReferenceProperty("schedule_tag"); + } + + if(schedule.getChildren("project_list").length ==0){ + MessageBox.post("请为时间表指派项目", "警告", MessageBox.WARNING); + return; + } + setTaskPerson(schedule); + + } + + private void setTaskPerson(TCComponentSchedule schedule) { + // 获得项目 + try { + wait = new ProgressBarThread("任务指派", "任务指派中,请稍等..."); + wait.start();// 开启进度条 + project = (TCComponentProject) schedule.getChildren("project_list")[0].getComponent(); + if (project!=null) { + + TCComponent[] allTasks = schedule.getAllTasks(); + rIfc = RACInterfaceFactory.singleton().getRACInterface(session, schedule); + for (TCComponent task : allTasks) { + if (task.getProperty("task_type").equals("0")) { + //是时间表的子任务 + //list.add(createAssignmentCreateContainer(session.getUser(), (TCComponentScheduleTask) task)); + if (!taskISRun((TCComponentScheduleTask) task)) { + //已开始的时间表任务指派 + setTaskMap((TCComponentScheduleTask) task); + } + + } + //System.out.println("task="+tcComponent); + } + + + if (list.size() >0) { + assign(); + } + + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + + } +// session.getUserService().call("create_schedule_task_resource_assignment", +// new Object[] { schedule, null, session.getUser() }); +// if (problemTasks.size() == 0) { +// MessageBox.post("指派成功!!","提示",2); +// } +// if (problemTasks !=null && problemTasks.size() >0) { +// new Thread(new ShowProblemTaskDialog(problemTasks)).start(); +// } + if (problemScheduleTask.size() == 0) { + MessageBox.post("指派成功!!","提示",2); + } + if (problemScheduleTask !=null && problemScheduleTask.size() >0) { + try { + new ShowProblemTaskDialog(problemScheduleTask,schedule); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + e.printStackTrace(); + } + } + + +// public void selectScheduleAssign(TCComponent childTask) throws Exception { +// AIFComponentContext[] clids = childTask.getChildren("child_task_taglist"); +// if (clids != null && clids.length > 0) { +// for (int i = 0; i < clids.length; ++i) { +// AIFComponentContext clid = clids[i]; +// TCComponentScheduleTask cldTask = (TCComponentScheduleTask) clid.getComponent(); +// selectScheduleAssign(cldTask); +// } +// } else { +// scheduleMap.put(childTask, ""); +// } +// } + + /** + * @param user + * @param scheduleTask + * @return + */ + private AssignmentCreateContainer createAssignmentCreateContainer(TCComponent user, TCComponentScheduleTask scheduleTask) { + AssignmentCreateContainer assignmentcreatecontainer = new AssignmentCreateContainer(); + assignmentcreatecontainer.resource = user; + assignmentcreatecontainer.task = scheduleTask; + assignmentcreatecontainer.assignedPercent = 100; + assignmentcreatecontainer.isPlaceHolder = false; + return assignmentcreatecontainer; + } + private void assign() { + AssignResourcesRunner assignresourcesrunner = new AssignResourcesRunner(schedule, list.toArray(new AssignmentCreateContainer[list.size()])); + assignresourcesrunner.execute(); + } + + public boolean taskISRun(TCComponentScheduleTask scheduleTask){ + boolean flag = true; + try { + String status = scheduleTask.getProperty("fnd0status"); + //System.out.println("时间表任务状态:"+status); + if(status.equals("未开始")){ + return false; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + + return flag; + } + + private void setTaskMap(TCComponentScheduleTask scheduleTask) { + try { + String js = scheduleTask.getProperty("hs2_HeadRole"); + TCComponent team; + try { + team = project.getReferenceProperty("project_team"); + TCComponent[] members = team.getReferenceListProperty("project_members"); + List roleList = new ArrayList(); + List userList = new ArrayList(); + for (TCComponent member : members) { +// System.out.println("member.type="+member.getType()); +// System.out.println("member="+member); + if (member instanceof TCComponentGroupMember) { + TCComponentGroupMember member2 = (TCComponentGroupMember)member; + + TCComponentGroup group = member2.getGroup(); + TCComponentRole role = member2.getRole(); + + //System.out.println("roleName="+role.getRoleName()+" 角色--"+js); + String roleName = role.getProperty("object_name"); + //System.out.println("roleName="+property+" 角色--"+js); + if(roleName.equals(js)) { + //角色相同 加入角色集合 + roleList.add(role); + TCComponentUser[] users = role.getUsers(group); + for (TCComponentUser user : users) { + if (member2.getUser().getUserId().equals(user.getUserId())) { + userList.add(user); + } + } + } + }else if (member instanceof TCComponentGroup) { + TCComponentGroup group = (TCComponentGroup) member; + TCComponentRole[] roles = group.getRoles(); + for (int i = 0; i < roles.length; i++) { + TCComponentRole role = roles[i]; + TCComponentGroupMember[] groupMembers = role.getGroupMembers(group); + for (int j = 0; j < groupMembers.length; j++) { + TCComponentRole role2 = groupMembers[j].getRole(); + //System.out.println("roleName="+role.getRoleName()+" 角色--"+js); + String roleName2 = role2.getProperty("object_name"); + //System.out.println("roleName="+property+" 角色--"+js); + if(roleName2.equals(js)) { + //角色相同 加入角色集合 + roleList.add(role2); + TCComponentUser[] users2 = role.getUsers(group); + for (TCComponentUser user : users2) { + if (groupMembers[j].getUser().getUserId().equals(user.getUserId())) { + userList.add(user); + } + } + } + } + + + + } + } + + } + roleList = new ArrayList(new HashSet(roleList)); + userList = new ArrayList(new HashSet(userList)); + System.out.println("时间表任务="+scheduleTask+"roleList="+roleList+"userList="+userList); + if (!js.equals("")){ + if (userList.size()==1) { + //roleMap.put(arg0, arg1) + System.out.println("时间表任务:"+scheduleTask+";角色:"+js); + if (!scheduleTask.getProperty("ResourceAssignment").equals("")) { + deleteAssign(scheduleTask); + Thread.sleep(500); + scheduleTask.refresh(); + } +// deleteAssign(scheduleTask); +// Thread.sleep(1000);//单位:毫秒 +// scheduleTask.refresh(); + list.add(createAssignmentCreateContainer(userList.get(0), scheduleTask)); + }else { + System.out.println(); + if (scheduleTask.getProperty("ResourceAssignment").equals("")) { + System.out.println("时间表任务:" + scheduleTask+"未成功指派"); + //problemTasks.add(scheduleTask); + problemScheduleTask.put(scheduleTask, userList) ; + } + + } + }else { + //problemTasks.add(scheduleTask); +// if (userList.size()==0) { +// System.out.println("时间表任务:" + scheduleTask+"没有找到用户"); +// +// } + if (scheduleTask.getProperty("ResourceAssignment").equals("")) { + System.out.println("时间表任务:" + scheduleTask+"未成功指派"); + //problemTasks.add(scheduleTask); + problemScheduleTask.put(scheduleTask, userList) ; + } + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + +// if (js != null && !js.equals("")) { +// System.out.println("时间表任务:"+scheduleTask+";角色:"+js); +// //js = specialRole(js); +// System.out.println("js=>" + js); +// if (roleMap.containsKey(js) && roleMap.get(js) != null) { +// // if (!isExisting(scheduleTask, roleMap.get(js))) { +// // 改 +//// if (roleMap.get(arg0)) { +//// +//// } +// //list.add(createAssignmentCreateContainer(roleMap.get(js), scheduleTask)); +// // } +// } +// //System.out.println("角色:" + js); +// } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void deleteAssign(TCComponent scheduleTask) { + Set deleteSet = new HashSet(); + Collection collection = rIfc.getInternalAssignments(scheduleTask); + for (Iterator iterator2 = collection.iterator(); iterator2.hasNext();) { + deleteSet.add(iterator2.next()); + } + //System.out.println("deleteSet.size="+deleteSet.size()); + if (deleteSet != null && deleteSet.size() > 0) { + Iterator iterator = deleteSet.iterator(); + //System.out.println("deleteSet=>" + deleteSet.size()); + TCComponentResourceAssignment[] atccomponentresourceassignment = new TCComponentResourceAssignment[deleteSet.size()]; + int index = 0; + while (iterator.hasNext()) { + TCComponentResourceAssignment resourceAssignment = (TCComponentResourceAssignment) iterator.next(); + atccomponentresourceassignment[index++] = resourceAssignment; + //System.out.println("时间表任务"+scheduleTask +"------删除=>" + index); + } + DeleteAssignmentsRunner deleteassignmentsrunner = new DeleteAssignmentsRunner(schedule, atccomponentresourceassignment); + SOAExecutor soaexecutor = new SOAExecutor(deleteassignmentsrunner); + soaexecutor.executeSOA(); + + } + + } +} diff --git a/src/com/connor/hs2/plm/projectmanage/assigntask/AssignUnsuccessPersonOpeartion.java b/src/com/connor/hs2/plm/projectmanage/assigntask/AssignUnsuccessPersonOpeartion.java new file mode 100644 index 0000000..303b340 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/assigntask/AssignUnsuccessPersonOpeartion.java @@ -0,0 +1,131 @@ +package com.connor.hs2.plm.projectmanage.assigntask; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import javax.swing.JTable; + +import com.connor.hs2.plm.projectmanage.utils.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentResourceAssignment; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCComponentUserType; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.schedule.project.server.RACInterface.RACInterface; +import com.teamcenter.rac.schedule.project.server.RACInterface.RACInterfaceFactory; +import com.teamcenter.rac.schedule.soainterface.AssignResourcesRunner; +import com.teamcenter.rac.schedule.soainterface.DeleteAssignmentsRunner; +import com.teamcenter.rac.schedule.soainterface.SOAExecutor; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.services.rac.projectmanagement._2015_07.ScheduleManagement.AssignmentCreateContainer; + +public class AssignUnsuccessPersonOpeartion extends AbstractAIFOperation { + private TCSession session; + private AbstractAIFUIApplication app; + private JTable table; + private ProgressBarThread wait; + private List list = new ArrayList<>(); + private TCComponentSchedule schedule; + private RACInterface rIfc; + public AssignUnsuccessPersonOpeartion(TCSession session, AbstractAIFUIApplication app, JTable table, TCComponentSchedule schedule) { + // TODO Auto-generated constructor stub + this.session = session; + this.app = app; + this.schedule = schedule; + this.table = table; + } + + @Override + public void executeOperation() { + // TODO Auto-generated method stub + try { + wait = new ProgressBarThread("任务指派", "任务指派中,请稍等..."); + wait.start();// 开启进度条 + int rowCount = table.getRowCount(); + rIfc = RACInterfaceFactory.singleton().getRACInterface(session, schedule); + TCComponentUserType type = (TCComponentUserType) session.getTypeComponent("User"); + TCComponentUser userObj; + for (int i = 0; i < rowCount; i++) { + TCComponentScheduleTask task = (TCComponentScheduleTask)table.getValueAt(i, 0); + String user = (String) table.getValueAt(i, 3); + if (user!=null && user.length()>0) { + String[] user_name_id = user.split(","); + for (String userdisName : user_name_id) { + String userId =userdisName.substring(userdisName.indexOf("(")+1,userdisName.indexOf(")")); + userObj = type.find(userId); + if (userObj!=null) { + if (!task.getProperty("ResourceAssignment").equals("")) { + deleteAssign(task); + Thread.sleep(500); + task.refresh(); + } + list.add(createAssignmentCreateContainer(userObj, task)); + } + } + + } + } + + if (list.size() >0) { + assign(); + } + + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + } catch (Exception e) { + // TODO: handle exception + + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + e.printStackTrace(); + + } + + } + + private void assign() { + AssignResourcesRunner assignresourcesrunner = new AssignResourcesRunner(schedule, list.toArray(new AssignmentCreateContainer[list.size()])); + assignresourcesrunner.execute(); + } + + private AssignmentCreateContainer createAssignmentCreateContainer(TCComponent user, TCComponentScheduleTask scheduleTask) { + AssignmentCreateContainer assignmentcreatecontainer = new AssignmentCreateContainer(); + assignmentcreatecontainer.resource = user; + assignmentcreatecontainer.task = scheduleTask; + assignmentcreatecontainer.assignedPercent = 100; + assignmentcreatecontainer.isPlaceHolder = false; + return assignmentcreatecontainer; + } + private void deleteAssign(TCComponent scheduleTask) { + Set deleteSet = new HashSet(); + Collection collection = rIfc.getInternalAssignments(scheduleTask); + for (Iterator iterator2 = collection.iterator(); iterator2.hasNext();) { + deleteSet.add(iterator2.next()); + } + //System.out.println("deleteSet.size="+deleteSet.size()); + if (deleteSet != null && deleteSet.size() > 0) { + Iterator iterator = deleteSet.iterator(); + //System.out.println("deleteSet=>" + deleteSet.size()); + TCComponentResourceAssignment[] atccomponentresourceassignment = new TCComponentResourceAssignment[deleteSet.size()]; + int index = 0; + while (iterator.hasNext()) { + TCComponentResourceAssignment resourceAssignment = (TCComponentResourceAssignment) iterator.next(); + atccomponentresourceassignment[index++] = resourceAssignment; + //System.out.println("时间表任务"+scheduleTask +"------删除=>" + index); + } + DeleteAssignmentsRunner deleteassignmentsrunner = new DeleteAssignmentsRunner(schedule, atccomponentresourceassignment); + SOAExecutor soaexecutor = new SOAExecutor(deleteassignmentsrunner); + soaexecutor.executeSOA(); + + } + + } +} diff --git a/src/com/connor/hs2/plm/projectmanage/assigntask/MyButton.java b/src/com/connor/hs2/plm/projectmanage/assigntask/MyButton.java new file mode 100644 index 0000000..8cd74d1 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/assigntask/MyButton.java @@ -0,0 +1,35 @@ +package com.connor.hs2.plm.projectmanage.assigntask; + +import javax.swing.JButton; + +public class MyButton extends JButton{ + + private int row; + + private int column; + + public int getRow() { + return row; + } + + public void setRow(int row) { + this.row = row; + } + + public int getColumn() { + return column; + } + + public void setColumn(int column) { + this.column = column; + } + + public MyButton() { + + } + + public MyButton(String name) { + super(name); + } + +} \ No newline at end of file diff --git a/src/com/connor/hs2/plm/projectmanage/assigntask/SearchUserRender.java b/src/com/connor/hs2/plm/projectmanage/assigntask/SearchUserRender.java new file mode 100644 index 0000000..a09ff1f --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/assigntask/SearchUserRender.java @@ -0,0 +1,83 @@ +package com.connor.hs2.plm.projectmanage.assigntask; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; +import java.util.Map; + +import javax.swing.AbstractCellEditor; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JOptionPane; +import javax.swing.JTable; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; + +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.schedule.soainterface.AssignResourcesRunner; +import com.teamcenter.services.rac.projectmanagement._2015_07.ScheduleManagement.AssignmentCreateContainer; +public class SearchUserRender extends AbstractCellEditor implements TableCellRenderer,ActionListener, TableCellEditor{ + private static final long serialVersionUID = 1L; + private MyButton button =null; + private JTable table; + private ShowProblemTaskDialog showProblemTaskDialog; + private Map> problemScheduleTask; + public SearchUserRender(ShowProblemTaskDialog showProblemTaskDialog, JTable table, Map> problemScheduleTask){ + button = new MyButton("搜索"); + this.problemScheduleTask = problemScheduleTask; + this.showProblemTaskDialog =showProblemTaskDialog; + button.addActionListener(this); + this.table = table; + } +@Override + public Object getCellEditorValue() { + // TODO Auto-generated method stub + return null; + } + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + return button; + } +@Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + //JOptionPane.showMessageDialog(null, "渲染器学期", "消息", JOptionPane.OK_OPTION); +// System.out.println("button row="+button.getRow()); +// System.out.println("button column="+button.getColumn()); + System.out.println("搜索用户-----------------"); + TCComponentScheduleTask task = (TCComponentScheduleTask) table.getValueAt(button.getRow(), 0); + List users = problemScheduleTask.get(task); + new Thread(new searchUserDiglog(showProblemTaskDialog,table,task,users,button.getRow())).start(); + // Object valueAt = table.getValueAt(button.getRow(), 0); +// Object valueAt2 = table.getComponentAt(button.getRow(), button.getColumn()-1); +// Object valueAt3 = table.getValueAt(button.getRow(), button.getColumn()); + // Object valueAt4 = table.getValueAt(button.getRow(), button.getColumn()-1); +// +// System.out.println("value1="+valueAt); +// System.out.println("value2="+valueAt2); +// System.out.println("value4="+valueAt4); +// System.out.println("valueAt="+valueAt); + + +// if (valueAt4!=null && !valueAt4.equals("")) { +// System.out.println("user!=null"); +// +// }else { +// System.out.println("user==null 弹出界面进行选择"); +// +// } + } +@Override + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, int row, int column) { + // TODO Auto-generated method stub + button.setRow(row); + button.setColumn(column); + return button; + } + +} \ No newline at end of file diff --git a/src/com/connor/hs2/plm/projectmanage/assigntask/SelectUserRender.java b/src/com/connor/hs2/plm/projectmanage/assigntask/SelectUserRender.java new file mode 100644 index 0000000..339f994 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/assigntask/SelectUserRender.java @@ -0,0 +1,81 @@ +package com.connor.hs2.plm.projectmanage.assigntask; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; +import java.util.Map; + +import javax.swing.AbstractCellEditor; +import javax.swing.JTable; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; + +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCComponentUser; + +public class SelectUserRender extends AbstractCellEditor implements TableCellRenderer, ActionListener, TableCellEditor { + private static final long serialVersionUID = 1L; + private MyButton button = null; + private JTable table; + private Map> problemScheduleTask; + private TCComponentSchedule schedule; + + public SelectUserRender(JTable table, Map> problemScheduleTask) { + button = new MyButton("选择"); + this.problemScheduleTask = problemScheduleTask; + this.schedule = schedule; + button.addActionListener(this); + this.table = table; + } + + @Override + public Object getCellEditorValue() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, + int row, int column) { + // TODO Auto-generated method stub + Object valueAt = table.getValueAt(row, 0); + if (valueAt instanceof TCComponentScheduleTask) { + TCComponentScheduleTask task = (TCComponentScheduleTask) table.getValueAt(row, 0); + if (problemScheduleTask.get(task).size() == 0) { + return null; + } + } + return button; + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + // JOptionPane.showMessageDialog(null, "渲染器学期", "消息", JOptionPane.OK_OPTION); +// System.out.println("button row="+button.getRow()); +// System.out.println("button column="+button.getColumn()); + System.out.println("选择用户-----------------"); + TCComponentScheduleTask task = (TCComponentScheduleTask) table.getValueAt(button.getRow(), 0); + List users = problemScheduleTask.get(task); + new Thread(new selectUserDiglog(table, task, users, button.getRow())).start(); + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + // TODO Auto-generated method stub + button.setRow(row); + button.setColumn(column); + System.out.println("getTableCellEditorComponent"); + Object valueAt = table.getValueAt(row, 0); + if (valueAt instanceof TCComponentScheduleTask) { + TCComponentScheduleTask task = (TCComponentScheduleTask) table.getValueAt(row, 0); + if (problemScheduleTask.get(task).size() == 0) { + return null; + } + } + return button; + } + +} \ No newline at end of file diff --git a/src/com/connor/hs2/plm/projectmanage/assigntask/ShowProblemTaskDialog.java b/src/com/connor/hs2/plm/projectmanage/assigntask/ShowProblemTaskDialog.java new file mode 100644 index 0000000..0b6e553 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/assigntask/ShowProblemTaskDialog.java @@ -0,0 +1,222 @@ +package com.connor.hs2.plm.projectmanage.assigntask; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Vector; + +import javax.swing.DefaultCellEditor; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumn; + +import com.connor.hs2.plm.projectmanage.utils.JTableUtil; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +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 ShowProblemTaskDialog extends JFrame implements ActionListener { + private JPanel rootPanel; + //private List tasks; + private Map> problemScheduleTask; + private JTable table; + private DefaultTableModel model; + private JButton okButton; + private JButton cancelButton; + private TCComponentSchedule schedule; + ShowProblemTaskDialog(Map> problemScheduleTask2, TCComponentSchedule schedule) throws Exception{ + //this.tasks = problemScheduleTask; + this.problemScheduleTask = problemScheduleTask2; + this.schedule = schedule; + init(); + }; + +// @Override +// public void run() { +// try { +// init(); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } + + public void init() throws Exception { + + if (problemScheduleTask ==null || problemScheduleTask.size() == 0) { + this.dispose(); + return ; + } + this.setTitle("提示"); + rootPanel = new JPanel(new BorderLayout()); + Font font= new Font("微软雅黑",Font.BOLD,12); + + JLabel label = new JLabel("以下任务没有成功指派,请手动进行指派!"); + label.setFont(font); + initTable(); + JScrollPane tablePane = new JScrollPane(table) { + @Override + public Dimension getPreferredSize() { + // TODO Auto-generated method stub + return new Dimension(1200,500); + } + }; + JPanel buttonPanel = new JPanel(); + //buttonPanel.setPreferredSize(new Dimension(900,200)); + okButton = new JButton("指派"); + okButton.setPreferredSize(new Dimension(80,40)); + + cancelButton = new JButton("取消"); + cancelButton.setPreferredSize(new Dimension(80,40)); + + okButton.addActionListener(this); + cancelButton.addActionListener(this); + //buttonPanel.add("1.1.center.top", new JLabel(" ")); +// buttonPanel.add("1.2.center.top", okButton); +// buttonPanel.add("1.3.center.top", cancelButton); + buttonPanel.add(okButton,BorderLayout.WEST); + buttonPanel.add(cancelButton,BorderLayout.EAST); + rootPanel.add(label,BorderLayout.NORTH); + rootPanel.add(tablePane,BorderLayout.CENTER); + rootPanel.add(buttonPanel,BorderLayout.SOUTH); + + //this.setAlwaysOnTop(true); + this.add(rootPanel, BorderLayout.CENTER); + this.setPreferredSize(new Dimension(1250,700)); + this.setAlwaysOnTop(true); + + //this.setLocationRelativeTo(null); + this.pack(); + this.setVisible(true); + this.setLocationRelativeTo(null); + //this.setResizable(false);// 不可变动窗口大小 +} + /** + * 初始化table + */ + private void initTable() { + try { + //表头数组 + String[] headArray = new String[] {"任务名称","开始日期","完成日期","指派用户","选择用户","搜索用户"}; + Vector headVector = new Vector(); + for (int i = 0; i < headArray.length; i++) { + headVector.add(headArray[i]); + } + + Vector dataVector = new Vector(); + + for (TCComponentScheduleTask task : problemScheduleTask.keySet()) { + //String name = task.getProperty("object_name"); + String startDate = task.getProperty("start_date"); + String finishDate = task.getProperty("finish_date"); + //userColumn.setCellEditor(new DefaultCellEditor(comboBox)); + //List userList = problemScheduleTask.get(task); +// JComboBox userBox = new JComboBox(); +// for (TCComponentUser user : userList) { +// userBox.addItem(user); +// } + Vector rowVector = new Vector(); + rowVector.add(task); + rowVector.add(startDate); + rowVector.add(finishDate); + + //rowVector.add(""); + dataVector.add(rowVector); + } + + + model = new javax.swing.table.DefaultTableModel(dataVector, headVector); + table = new JTable(model) { + public boolean isCellEditable(int row, int column) { + if (column == 4 || column == 5) { + return true; + }else{ + return false; + } + } + }; + + + //table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); + //table.setRowSelectionAllowed(false); + + //设置表格的渲染器 //设置表格的编辑器 + table.getColumnModel().getColumn(4).setCellRenderer(new SelectUserRender(table,problemScheduleTask)); + table.getColumnModel().getColumn(4).setCellEditor(new SelectUserRender(table,problemScheduleTask)); + table.getColumnModel().getColumn(5).setCellRenderer(new SearchUserRender(this,table,problemScheduleTask)); + table.getColumnModel().getColumn(5).setCellEditor(new SearchUserRender(this,table,problemScheduleTask)); + table.setRowHeight(24); + table.getColumnModel().getColumn(0).setPreferredWidth(400); + table.getColumnModel().getColumn(1).setPreferredWidth(200); + table.getColumnModel().getColumn(2).setPreferredWidth(200); + table.getColumnModel().getColumn(3).setPreferredWidth(200); + table.getColumnModel().getColumn(4).setPreferredWidth(100); + table.getColumnModel().getColumn(5).setPreferredWidth(100); + //table.setCellRendererAndEditor(3); + //table.getColumnModel().getColumn(3).setCellEditor(new DefaultCellEditor(new MultiComboBox(new String[] {"一级","二级"}))); + // table.getColumnModel().getColumn(3).setCellRenderer(new DefaultTableCellRenderer()); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if (e.getSource().equals(okButton)) { + System.out.println("确定以当前表格进行指派"); + int r=JOptionPane.showConfirmDialog(this,"确认以当前表格用户进行指派吗?","确认指派",JOptionPane.YES_NO_CANCEL_OPTION); + if(r==JOptionPane.YES_OPTION){ + System.out.println("确认"); + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + AssignUnsuccessPersonOpeartion operation = new AssignUnsuccessPersonOpeartion(session, app,table,schedule); + session.queueOperation(operation); + this.setAlwaysOnTop(false); + MessageBox.post("指派成功","提示",2); + this.dispose(); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + this.setAlwaysOnTop(false); + MessageBox.post("指派失败","请联系管理员!!",MessageBox.WARNING); + this.dispose(); + } + + }else{ + System.out.println("不确认"); + } + + }else if (e.getSource().equals(cancelButton)) { + this.dispose(); + } + } +} diff --git a/src/com/connor/hs2/plm/projectmanage/assigntask/searchUserDiglog.java b/src/com/connor/hs2/plm/projectmanage/assigntask/searchUserDiglog.java new file mode 100644 index 0000000..e996f96 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/assigntask/searchUserDiglog.java @@ -0,0 +1,300 @@ +package com.connor.hs2.plm.projectmanage.assigntask; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.util.List; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.DefaultTableModel; + +import org.eclipse.swt.events.MouseListener; + +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.common.organization.OrgObject; +import com.teamcenter.rac.common.organization.OrgTreePanel; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class searchUserDiglog extends JDialog implements Runnable,ActionListener { + + private TCSession session; + private InterfaceAIFComponent targetComponent; + public TCUserService userservice; + public OrgTreePanel organizationPanel; + private JPanel rootPanel; + private JPanel buttonPanel1; + private JPanel buttonPanel2; + private TCComponentUser user; + private JButton addButton; + private JButton delButton; + private JButton QRButton; + private JButton QXButton; + private JTable paramTable; + private JTable table; + private DefaultTableModel model ; + private JPanel tablePanel; + private TCComponentScheduleTask task; + private List users; + private int row; + private ShowProblemTaskDialog showProblemTaskDialog; + public searchUserDiglog(ShowProblemTaskDialog showProblemTaskDialog, JTable table, TCComponentScheduleTask task, List users, int row) { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + this.session = (TCSession) app.getSession(); + this.showProblemTaskDialog = showProblemTaskDialog; + this.targetComponent = app.getTargetComponent(); + this.paramTable = table; + this.task = task; + this.users = users; + this.row = row; + } + + @Override + public void run() { + try { + init(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void init() throws Exception { + + this.setTitle("任务:"+task.toString()); + rootPanel = new JPanel(new PropertyLayout()); + //选人页面 + SelectUserPanel(); + + //添加 移除按钮 + addButton = new JButton(" +"); + addButton.addActionListener(this); + delButton = new JButton(" - "); + delButton.addActionListener(this); + buttonPanel1 = new JPanel(new PropertyLayout()); + buttonPanel1.add("1.1.left.top", new JLabel("")); + buttonPanel1.add("2.1.left.top", new JLabel("")); + buttonPanel1.add("3.1.left.top", new JLabel("")); + buttonPanel1.add("4.1.left.top", new JLabel("")); + buttonPanel1.add("5.1.left.top", new JLabel("")); + buttonPanel1.add("6.1.left.top", new JLabel("")); + buttonPanel1.add("7.1.left.top", new JLabel("")); + buttonPanel1.add("8.1.left.top", new JLabel("")); + buttonPanel1.add("9.1.left.top", new JLabel("")); + buttonPanel1.add("10.1.left.top", new JLabel("")); + buttonPanel1.add("11.1.left.top", new JLabel("")); + buttonPanel1.add("12.1.left.top", new JLabel("")); + buttonPanel1.add("13.1.left.top", new JLabel("")); + buttonPanel1.add("14.1.left.top", new JLabel("")); + buttonPanel1.add("15.1.left.top", new JLabel("")); + buttonPanel1.add("16.1.left.top", new JLabel("")); + buttonPanel1.add("17.1.left.top", addButton); + buttonPanel1.add("18.1.left.top", delButton); + + //参与人员表格 + table = createTable(new String[] {"用户"}); + tablePanel = new JPanel(); + JScrollPane tablePane = new JScrollPane(table) { + @Override + public Dimension getPreferredSize() { + // TODO Auto-generated method stub + return new Dimension(300, 400); + } + }; + tablePanel.add(tablePane); + //确认 取消按钮 + QRButton = new JButton("确认"); + QRButton.addActionListener(this); + QXButton = new JButton("取消"); + QXButton.addActionListener(this); + buttonPanel2 = new JPanel(new PropertyLayout()); + buttonPanel2.add("1.1.left.top", QRButton); + buttonPanel2.add("1.2.left.top", QXButton); + + rootPanel.add("1.1.left.top", organizationPanel); + rootPanel.add("1.2.left.top", buttonPanel1); + rootPanel.add("1.3.left.top", tablePanel); + rootPanel.add("2.1.center.top", new JLabel(" ")); + rootPanel.add("2.2.center.top", buttonPanel2); + //this.setAlwaysOnTop(true); + this.setAlwaysOnTop(true); + this.add(rootPanel, BorderLayout.CENTER); + this.pack(); +// this.centerToScreen(); +// this.showDialog(); + this.setResizable(false);// 不可变动窗口大小 + this.setLocationRelativeTo(null); + this.setVisible(true); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if (e.getSource().equals(addButton)) { + //System.out.println("点击添加按钮"); + if (user!=null) { + boolean flag = true; + DefaultTableModel dtm = (DefaultTableModel) table.getModel(); + int rowCount = dtm.getRowCount(); + for (int i = 0; i < rowCount; i++) { + String exist_user = (String) dtm.getValueAt(i, 0); + if (user.toString().equals(exist_user)) { +// this.showProblemTaskDialog.setAlwaysOnTop(false); +// this.setAlwaysOnTop(false); +// System.out.println("已经添加的user="+user); +// MessageBox.post("该用户已添加,请勿重复添加", "提示", 2); + flag = false; + } + } + if (flag) { + DefaultTableModel tm = (DefaultTableModel) table.getModel(); + if (!user.toString().trim().equals("")) { + Object[] data = { user.toString() }; + tm.addRow(data); + table.updateUI(); + organizationPanel.getOrgTree().updateUI(); + organizationPanel.updateUI(); + } + } + } + }else if(e.getSource().equals(delButton)) { + //System.out.println("点击移除按钮"); + if (table.getSelectedRow() != -1) { + DefaultTableModel dtm = (DefaultTableModel) table.getModel(); + dtm.removeRow(table.getSelectedRow()); + }; + }else if(e.getSource().equals(QRButton)) { + System.out.println("搜索用户---点击确认按钮"); + StringBuilder sb = new StringBuilder(); + String value = ""; + for (int i = 0; i < table.getRowCount(); i++) { + sb.append(table.getValueAt(i, 0).toString()+","); + } + + if (sb.length() == 0) { + paramTable.setValueAt("",row,3); +// this.setAlwaysOnTop(false); +// MessageBox.post("请选择要添加的用户", "提示", 2); + } + if (sb.length() > 0) { + value = sb.substring(0, sb.length() - 1); + paramTable.setValueAt(value,row,3); + + } + this.dispose(); + //System.out.println("table.colCount="+table.getColumnCount()); + + }else if(e.getSource().equals(QXButton)) { + this.dispose(); + } + } + + public void SelectUserPanel() { + + organizationPanel = new OrgTreePanel(session); + organizationPanel.setSize(300, 400); + organizationPanel.getOrgTree().addMouseListener(new java.awt.event.MouseListener() { + + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + OrgObject selectedObject = organizationPanel.getOrgTree().getSelectedObject(); + if (selectedObject != null) { + + user = selectedObject.getUser(); + System.out.println("鼠标点击的user="+user); + } +// if (e.getClickCount() == 1) { +// OrgObject selectedObject = organizationPanel.getOrgTree().getSelectedObject(); +// if (selectedObject != null) { +// +// user = selectedObject.getUser(); +// System.out.println("鼠标点击的user="+user); +// } +// } + } + + @Override + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + OrgObject selectedObject = organizationPanel.getOrgTree().getSelectedObject(); + if (selectedObject != null) { + + user = selectedObject.getUser(); + //System.out.println("鼠标摁下的user="+user); + } + } + + @Override + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + + } + }); + } + + public JTable createTable(String[] str) { + Vector headVector = new Vector(); + for (int i = 0; i < str.length; i++) { + headVector.add(str[i]); + } + + Vector dataVector = new Vector(); + + + //表格初始化 + Object selectedUsers = paramTable.getValueAt(row, 3); + String[] selects = null; + if (selectedUsers!=null && selectedUsers instanceof String) { + String selectedUsers_str = (String)selectedUsers; + selects = selectedUsers_str.split(","); + if (selects!=null && selects.length > 0) { + for (int i = 0; i < selects.length; i++) { + if (!selects[i].toString().trim().equals("")) { + Vector rowVector = new Vector(); + rowVector.add(selects[i]); + dataVector.add(rowVector); } + + } + + } + } + + model = new javax.swing.table.DefaultTableModel(dataVector, headVector); + table = new JTable(model) { + public boolean isCellEditable(int row, int column) { + return false; + } + }; + + return table; + } +} diff --git a/src/com/connor/hs2/plm/projectmanage/assigntask/selectUserDiglog.java b/src/com/connor/hs2/plm/projectmanage/assigntask/selectUserDiglog.java new file mode 100644 index 0000000..3c4482e --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/assigntask/selectUserDiglog.java @@ -0,0 +1,152 @@ +package com.connor.hs2.plm.projectmanage.assigntask; + +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.List; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.ScrollPaneConstants; + +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class selectUserDiglog extends JDialog implements Runnable, ActionListener { + + private JTable table; + private TCComponentScheduleTask task; + private List users; + private int row; + private JButton okButton; + private JButton cancelButton; + private JPanel usersPanel; + + public selectUserDiglog(JTable table, TCComponentScheduleTask task, List users, int row) { + // TODO Auto-generated constructor stub + // super(false); + this.table = table; + this.task = task; + this.users = users; + this.row = row; + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + init(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void init() { + // TODO Auto-generated method stub + this.setTitle("任务:" + task.toString()); + // this.setPreferredSize(new Dimension(200,170)); + JPanel rootPanel = new JPanel(new PropertyLayout()); + usersPanel = new JPanel(new PropertyLayout()); + JPanel buttonPanel = new JPanel(new PropertyLayout()); + Object selectedUsers = table.getValueAt(row, 3); + String[] selects = null; + if (selectedUsers != null && selectedUsers instanceof String) { + String selectedUsers_str = (String) selectedUsers; + selects = selectedUsers_str.split(","); + } + for (int i = 0; i < users.size(); i++) { + JCheckBox checkBox = new JCheckBox(users.get(i).toString()); + if (selects != null && selects.length > 0) { + if (checkIsSelected(selects, users.get(i).toString()) == true) { + checkBox.setSelected(true); + } + } + usersPanel.add(i + 1 + "" + ".1.left.top", checkBox); + } + + JScrollPane usersPane = new JScrollPane(usersPanel) { + @Override + public Dimension getPreferredSize() { + // TODO Auto-generated method stub + return new Dimension(195, 105); + } + }; + usersPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + // propertyPane.add(propertyPanel); + usersPane.setBorder(null); + okButton = new JButton("确认"); + cancelButton = new JButton("取消"); + okButton.addActionListener(this); + cancelButton.addActionListener(this); + buttonPanel.add("1.1.center.top", okButton); + buttonPanel.add("1.2.center.top", cancelButton); + + rootPanel.add("1.1.left.top", usersPane); + rootPanel.add("2.1.cente.top", buttonPanel); + + this.setAlwaysOnTop(true); + this.add(rootPanel, BorderLayout.CENTER); + this.pack(); +// this.centerToScreen(); +// this.showDialog(); + this.setResizable(false);// 不可变动窗口大小 + this.setLocationRelativeTo(null); + this.setVisible(true); + + } + + private boolean checkIsSelected(String[] selects, String string) { + // TODO Auto-generated method stub + for (int i = 0; i < selects.length; i++) { + if (selects[i].equals(string)) { + return true; + } + } + return false; + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if (e.getSource().equals(okButton)) { + System.out.println("确认选择的用户"); + int userCount = usersPanel.getComponentCount(); + System.out.println("usercount=" + userCount); + // List userStrings = new ArrayList(); + StringBuilder sb = new StringBuilder(); + if (userCount > 0) { + for (int i = 0; i < userCount; i++) { + Component component = usersPanel.getComponent(i); + if (component instanceof JCheckBox) { + // System.out.println("是复选框"); + JCheckBox checkBox = (JCheckBox) component; + if (checkBox.isSelected()) { + sb.append(checkBox.getText()); + sb.append(","); + } + } + } + } + if (sb.length() == 0) { + this.setAlwaysOnTop(false); + MessageBox.post("请选择要指派的用户", "提示", 2); + } else { + String userString = sb.deleteCharAt(sb.length() - 1).toString(); + table.setValueAt(userString, row, 3); + this.dispose(); + } + } else if (e.getSource().equals(cancelButton)) { + this.dispose(); + } + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/ggfxd/GGFXDAction.java b/src/com/connor/hs2/plm/projectmanage/change/ggfxd/GGFXDAction.java new file mode 100644 index 0000000..1f5a9ec --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/ggfxd/GGFXDAction.java @@ -0,0 +1,28 @@ +package com.connor.hs2.plm.projectmanage.change.ggfxd; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +public class GGFXDAction extends AbstractAIFAction{ + private AbstractAIFApplication app; + + public GGFXDAction(AbstractAIFApplication app, String arg1) { + super(app, arg1); + // TODO Auto-generated constructor stub + this.app = app; + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + GGFXDCommad command = new GGFXDCommad(app); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/ggfxd/GGFXDCommad.java b/src/com/connor/hs2/plm/projectmanage/change/ggfxd/GGFXDCommad.java new file mode 100644 index 0000000..99c24dd --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/ggfxd/GGFXDCommad.java @@ -0,0 +1,66 @@ +package com.connor.hs2.plm.projectmanage.change.ggfxd; + +import java.util.HashMap; +import java.util.Map; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonOpeartion; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; + +public class GGFXDCommad extends AbstractAIFCommand{ + private AbstractAIFApplication app; + + public GGFXDCommad(AbstractAIFApplication app) { + super(); + this.app = app; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + super.executeModal(); + Map map=new HashMap(); + if (app.getTargetComponent()!=null && (app.getTargetComponent().getType().equals("HS2_GGSQRevision") + || app.getTargetComponent().getType().equals("HS2_GGTZRevision") + || app.getTargetComponent().getType().equals("HS2_KXXFXBGPGRevision") + || app.getTargetComponent().getType().equals("HS2_GGRWDItemRevision") + || app.getTargetComponent().getType().equals("HS2_YZBGItemRevision") + || app.getTargetComponent().getType().equals("HS2_RequestRevision") + || app.getTargetComponent().getType().equals("HS2_NoticeRevision") + || app.getTargetComponent().getType().equals("HS2_FeasibilityARevision") + || app.getTargetComponent().getType().equals("HS2_ChangeTaskRevision") + || app.getTargetComponent().getType().equals("HS2_VerifyRevision") + )) { + TCComponentItemRevision target = (TCComponentItemRevision) app.getTargetComponent(); + String id = target.getProperty("item_id"); + String name = target.getProperty("object_name"); + map.put("item_id", id); + map.put("object_name", name); + String name1; + TCProperty[] allTCProperties = target.getAllTCProperties(); + for (int i = 0; i < allTCProperties.length; i++) { + TCProperty tcProperty = allTCProperties[i]; + name1 = tcProperty.getPropertyName(); + + if (name1.startsWith("hs2_")) { + map.put(name1, tcProperty.getPropertyValue()); + } + + if (name1.equals("hs2_changewilling") || name1.equals("hs2_projectstage") || name1.equals("hs2_changetype")) { + map.put(name1, tcProperty.getDisplayValue()); + } + if (name1.equals("hs2_stock")) { + map.put(name1, tcProperty.getBoolValue()); + } + } + } + GGFXDDialog dialog = new GGFXDDialog(app,map); + new Thread(dialog).start(); + + } + + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/ggfxd/GGFXDDialog.java b/src/com/connor/hs2/plm/projectmanage/change/ggfxd/GGFXDDialog.java new file mode 100644 index 0000000..4dec622 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/ggfxd/GGFXDDialog.java @@ -0,0 +1,535 @@ +package com.connor.hs2.plm.projectmanage.change.ggfxd; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.ScrollPaneConstants; + +import org.eclipse.swt.layout.GridLayout; +import org.jdesktop.swingx.JXDatePicker; + +import com.connor.hs2.plm.projectmanage.utils.LovUtils; +import com.connor.hs2.plm.projectmanage.utils.SXXUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +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.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class GGFXDDialog extends AbstractAIFDialog implements ActionListener{ + + private AbstractAIFApplication app; + private TCSession session; + private JTextField idText; + private JButton idButton; + private TCComponentItemType type; + private JTextField nameText; + //private JButton nameButton; + private JTextField zccpmcText; + private JTextField zccpljhText; + private JTextField ggljmcText; + private JTextField ggljhText; + private JTextField gcggsqdhText; + private JTextField khgghText; + private JTextField sqrText; + private JTextField khmcText; + private JComboBox ggyyBox; + private JComboBox xmjdBox; + private JButton createButton; + private JButton cancelButton; + private JButton modifyButton; + private Map propertyMap; + public GGFXDDialog(AbstractAIFApplication app, Map map) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + this.propertyMap = map; + } + + @Override + public void run() { + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void init() throws TCException { + //System.out.println("ggfxd----init"); +JPanel rootPanel = new JPanel(new PropertyLayout()); + System.out.println("init()----------------HS2_FeasibilityA"); + JPanel propertyPanel = new JPanel(new PropertyLayout()); + //propertyPanel.setSize(new Dimension(400,450)); + //propertyPanel.setPreferredSize(new Dimension(500,650)); + JPanel buttomPanel = new JPanel(new PropertyLayout()); + type = (TCComponentItemType) session.getTypeComponent("HS2_FeasibilityA"); + String hs2_ggyy = (propertyMap.get("hs2_changewilling") == null) ? "" : (String) propertyMap.get("hs2_changewilling"); + String hs2_xmjd = (propertyMap.get("hs2_projectstage") == null) ? "" : (String) propertyMap.get("hs2_projectstage"); + JLabel lable1 = new JLabel("ID:"); + idText = new JTextField(13); + if (propertyMap.get("item_id")!=null && !propertyMap.get("item_id").equals("")) { + idText.setText((String) propertyMap.get("item_id")); + }else { + idText.setText(type.getNewID()); + } + idButton = new JButton("指派"); + idButton.addActionListener(this); + + + JLabel lable2 = new JLabel("名称:"); + nameText = new JTextField(13); + //nameButton = new JButton("指派"); + if (propertyMap.get("object_name")!=null && !propertyMap.get("object_name").equals("")) { + nameText.setText((String) propertyMap.get("object_name")); + }else { + nameText.setText("风险评估及可行性分析报告"); + } + if (app.getTargetComponent()!=null && !app.getTargetComponent().getType().equals("HS2_FeasibilityARevision")) { + //对象不一样 id设为空 名称默认 + System.out.println("对象类型不一致"); + idText.setText(type.getNewID()); + nameText.setText("风险评估及可行性分析报告"); + } + + JLabel lable3 = new JLabel("总成产品名称:"); + zccpmcText = new JTextField(13); + if (propertyMap.get("hs2_assemblyproname")!=null && !propertyMap.get("hs2_assemblyproname").equals("")) { + zccpmcText.setText((String) propertyMap.get("hs2_assemblyproname")); + } + //rootPanel.add("2.3.left.top",nameButton); + JLabel lable4 = new JLabel("总成产品零件号:"); + zccpljhText = new JTextField(13); + if (propertyMap.get("hs2_assemblypartname")!=null && !propertyMap.get("hs2_assemblypartname").equals("")) { + zccpljhText.setText((String) propertyMap.get("hs2_assemblypartname")); + } + JLabel lable5 = new JLabel("更改零件名称:"); + ggljmcText = new JTextField(13); + if (propertyMap.get("hs2_changepartname")!=null && !propertyMap.get("hs2_changepartname").equals("")) { + ggljmcText.setText((String) propertyMap.get("hs2_changepartname")); + } + JLabel lable6 = new JLabel("更改零件号:"); + ggljhText = new JTextField(13); + if (propertyMap.get("hs2_changepartnumber")!=null && !propertyMap.get("hs2_changepartnumber").equals("")) { + ggljhText.setText((String) propertyMap.get("hs2_changepartnumber")); + } + JLabel lable7 = new JLabel("工程变更申请单号:"); + gcggsqdhText = new JTextField(13); + if (propertyMap.get("hs2_changeno")!=null && !propertyMap.get("hs2_changeno").equals("")) { + gcggsqdhText.setText((String) propertyMap.get("hs2_changeno")); + } + + JLabel lable8 = new JLabel("客户更改号:"); + khgghText = new JTextField(13); + if (propertyMap.get("hs2_customernumber")!=null && !propertyMap.get("hs2_customernumber").equals("")) { + khgghText.setText((String) propertyMap.get("hs2_customernumber")); + } + JLabel lable9 = new JLabel("客户名称:"); + khmcText = new JTextField(13); + if (propertyMap.get("hs2_customername")!=null && !propertyMap.get("hs2_customername").equals("")) { + khmcText.setText((String) propertyMap.get("hs2_customername")); + } + + JLabel lable10 = new JLabel("申请人/发起人:"); + sqrText = new JTextField(13); + if (propertyMap.get("hs2_applicant")!=null && !propertyMap.get("hs2_applicant").equals("")) { + sqrText.setText((String) propertyMap.get("hs2_applicant")); + } + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + + JLabel lable11 = new JLabel("更改意愿:"); + ggyyBox = new JComboBox(); + LovUtils.addLovToBox("HS2_ChangeWilling", ggyyBox); + ggyyBox.setSelectedIndex(-1); + for (int i = 0; i < ggyyBox.getItemCount(); i++) { + if (ggyyBox.getItemAt(i).equals(hs2_ggyy)) { + ggyyBox.setSelectedIndex(i); + } + } + JLabel lable12 = new JLabel("项目阶段:"); + xmjdBox = new JComboBox(); + LovUtils.addLovToBox("HS2_ProjectStage", xmjdBox); + xmjdBox.setSelectedIndex(-1); + for (int i = 0; i < xmjdBox.getItemCount(); i++) { + if (xmjdBox.getItemAt(i).equals(hs2_xmjd)) { + xmjdBox.setSelectedIndex(i); + } + } + + propertyPanel.add("1.1.left.top",lable1); + propertyPanel.add("1.2.left.top",idText); + propertyPanel.add("1.3.left.top",idButton); + propertyPanel.add("2.1.left.top",lable2); + propertyPanel.add("2.2.left.top",nameText); + propertyPanel.add("3.1.left.top",lable3); + propertyPanel.add("3.2.left.top",zccpmcText); + propertyPanel.add("4.1.left.top",lable4); + propertyPanel.add("4.2.left.top",zccpljhText); + propertyPanel.add("5.1.left.top",lable5); + propertyPanel.add("5.2.left.top",ggljmcText); + propertyPanel.add("6.1.left.top",lable6); + propertyPanel.add("6.2.left.top",ggljhText); + propertyPanel.add("7.1.left.top",lable7); + propertyPanel.add("7.2.left.top",gcggsqdhText); + propertyPanel.add("8.1.left.top",lable8); + propertyPanel.add("8.2.left.top",khgghText); + propertyPanel.add("9.1.left.top",lable9); + propertyPanel.add("9.2.left.top",khmcText); + propertyPanel.add("10.1.left.top",lable10); + propertyPanel.add("10.2.left.top",sqrText); + propertyPanel.add("11.1.left.top",lable11); + propertyPanel.add("11.2.left.top",ggyyBox); + propertyPanel.add("12.1.left.top",lable12); + propertyPanel.add("12.2.left.top",xmjdBox); + + createButton = new JButton("创建"); + cancelButton = new JButton("取消"); + modifyButton = new JButton("修改"); + if (app.getTargetComponent()!=null && app.getTargetComponent().getType().equals("HS2_FeasibilityARevision")) { + modifyButton.setEnabled(true); + }else { + modifyButton.setEnabled(false); + } + createButton.addActionListener(this); + cancelButton.addActionListener(this); + modifyButton.addActionListener(this); + buttomPanel.add("1.1.center.left",createButton); + buttomPanel.add("1.2.center.left",modifyButton); + buttomPanel.add("1.3.center.left",cancelButton); + + + JScrollPane propertyPane = new JScrollPane(propertyPanel); + propertyPane.setPreferredSize(new Dimension(480,440)); + //propertyPane.add(propertyPanel); + propertyPane.setBorder(null); + + propertyPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + //propertyPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + rootPanel.add("1.1.left.top",propertyPane); + rootPanel.add("2.1.center.left",buttomPanel); + this.setTitle("工程更改风险评估及可行性分析报告单"); + this.setLayout(new BorderLayout(10, 0)); + this.setPreferredSize(new Dimension(520,510)); + //panel.add(panel1, BorderLayout.WEST); + //panel.add(panel6, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.CENTER); + this.pack(); + this.setVisible(true); + this.setLocationRelativeTo(null); + this.setResizable(false);//不可变动窗口大小 + } + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if (e.getSource().equals(idButton)) { + try { + String id = type.getNewID(); + this.idText.setText(id); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }else if (e.getSource().equals(cancelButton)) { + this.dispose(); + } + else if (e.getSource().equals(createButton)) { + //this.dispose(); + try { + if (idText.getText().trim().equals("") || nameText.getText().trim().equals("")) { + MessageBox.post("请填写ID和名称!!","提示",2); + return ; + } + + String id = idText.getText(); + String name = nameText.getText(); + + if (type.find(id) != null) { + MessageBox.post("ID重复,请重新输入!!","提示",2); + return ; + } + System.out.println("根据首选项找找模板----------"); + System.out.println("HS2_FeasibilityARevision-------------"); + File file = SXXUtil.getSXX(session, "HS2_FeasibilityARevision"); + if (file == null) { + return ; + } + + + String newRev = type.getNewRev(null); + TCComponentItem item = type.create(id, newRev, "HS2_FeasibilityA", name, "", null); + if (item!=null) { + TCComponentItemRevision revision = item.getLatestItemRevision(); + Map propMap = new HashMap(); + if (nameText.getText().toString().length() != 0) { + propMap.put("object_name", nameText.getText().toString()); + } + if (zccpmcText.getText().toString().length() != 0) { + propMap.put("hs2_assemblyproname", zccpmcText.getText().toString()); + } + if (zccpljhText.getText().toString().length() != 0) { + propMap.put("hs2_assemblypartname", zccpljhText.getText().toString()); + } + if (ggljmcText.getText().toString().length() != 0) { + propMap.put("hs2_changepartname", ggljmcText.getText().toString()); + } + if (ggljhText.getText().toString().length() != 0) { + propMap.put("hs2_changepartnumber", ggljhText.getText().toString()); + } + + if (khgghText.getText().toString().length() != 0) { + propMap.put("hs2_customernumber", khgghText.getText().toString()); + } + if (sqrText.getText().toString().length() != 0) { + propMap.put("hs2_applicant", sqrText.getText().toString()); + } + if (khmcText.getText().toString().length() != 0) { + propMap.put("hs2_customername", khmcText.getText().toString()); + } + + if (gcggsqdhText.getText().toString().length() != 0) { + propMap.put("hs2_changeno", gcggsqdhText.getText().toString()); + } + //System.out.println("map="+propMap); + revision.setProperties(propMap); + if (ggyyBox.getSelectedItem()!=null && ggyyBox.getSelectedItem().toString().length() != 0) { + //System.out.println("设置更改意愿"); + LovUtils.setLovProperty(revision, "hs2_changewilling", ggyyBox.getSelectedItem().toString()); + } + if (xmjdBox.getSelectedItem()!=null && xmjdBox.getSelectedItem().toString().length() != 0) { + LovUtils.setLovProperty(revision, "hs2_projectstage", xmjdBox.getSelectedItem().toString()); + } + + + String absolutePath = file.getAbsolutePath(); + int num = absolutePath.lastIndexOf("."); + String temp = absolutePath.substring(0, num); + temp = temp + "导出.xlsx"; +// String substring = absolutePath.substring(0, absolutePath.lastIndexOf("\\")); +// String pathString = substring + "\\" + titleName + ".xlsx"; + File outFile = new File(temp); + if (outFile.exists()) { + outFile.delete(); + System.out.println("删除temp成功"); + } + POIExcel poiExcel = new POIExcel(); + poiExcel.writerExcel(file, revision, temp); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("MSExcelX"); + TCComponentDataset dataset = datasetType.create("工程更改风险评估及可行性分析报告单", "", "MSExcelX"); + String[] as1 = new String[] { temp }; + String[] as2 = new String[] { "excel" }; + dataset.setFiles(as1, as2); + revision.add("IMAN_specification", dataset); + //docRevision.add("TC_Attaches ", dataset); + + File f = new File(absolutePath); + if (f.exists() && f.isFile()) { + f.delete(); + System.out.println("删除成功"); + } + + if (outFile.exists() && outFile.isFile()) { + + outFile.delete(); + System.out.println("删除成功"); + } + + if (app.getTargetComponent() !=null && app.getTargetComponent().getType().equals("ProjectSmartFolder")) { + TCComponent ref = ((TCComponent) app.getTargetComponent()).getReferenceProperty("owning_project"); + if (ref!=null) { + TCComponentProject pro = (TCComponentProject) ref; + pro.assignToProject(new TCComponent[] {item}); + } + }else + if (app.getTargetComponent() !=null && app.getTargetComponent() instanceof TCComponentFolder) { + ((TCComponentFolder)app.getTargetComponent()).add("contents", item); + }else if(app.getTargetComponent() !=null && app.getTargetComponent() instanceof TCComponentProject) + { + TCComponentProject pro = (TCComponentProject) app.getTargetComponent(); + pro.assignToProject(new TCComponent[] {item}); + }else { + session.getUser().getNewStuffFolder().add("contents", item); + } + + //添加关系 + if (app.getTargetComponent()!=null && !app.getTargetComponent().getType().equals(revision.getType())) { + //选中对象不为空 并且类型不一样 添加到对应的关系 + //选中更改申请版本 创建更改风险单 添加关系 + if (app.getTargetComponent().getType().equals("HS2_RequestRevision")) { + System.out.println("选中更改申请版本 创建更改风险单"); + TCComponentItemRevision targetRevision = (TCComponentItemRevision) app.getTargetComponent(); + targetRevision.add("HS2_RiskAssessment", item); + } + } + + //如果选中的对象版本被指派到项目 那么创建出来的也要指派到项目 + if (app.getTargetComponent()!=null && (app.getTargetComponent() instanceof TCComponentItemRevision || app.getTargetComponent() instanceof TCComponentItem)) { + System.out.println("判断是否被指派到项目"); + TCComponent[] refs = ((TCComponent) app.getTargetComponent()).getReferenceListProperty("project_list"); + //System.out.println("ref="+refs); + if (refs!=null && refs.length>0) { + for (TCComponent component : refs) { + TCComponentProject project = (TCComponentProject)component; + project.assignToProject(new TCComponent[] {item}); + } + } + } + MessageBox.post("创建成功!!","提示",2); + this.dispose(); + }else { + MessageBox.post("创建失败,请联系管理员!!","提示",2); + } + } catch (Exception e1) { + // TODO: handle exception + e1.printStackTrace(); + } + } + else if (e.getSource().equals(modifyButton)) { + //设置属性 + if (app.getTargetComponent()==null) { + MessageBox.post("请选中工程更改风险评估及可行性分析报告版本进行修改!!","提示",2); + return ; + } +// if (!app.getTargetComponent().getType().equals("HS2_GGSQRevision")) { +// MessageBox.post("请选中变更申请单版本进行修改!!","提示",2); +// return ; +// } + + + try { + + TCComponentItemRevision revision = (TCComponentItemRevision) app.getTargetComponent(); + if (!idText.getText().trim().equals(revision.getProperty("item_id"))) { + MessageBox.post("ID不允许修改!!","提示",2); + return ; + } + + + Map propMap = new HashMap(); + if (nameText.getText().toString().length() != 0) { + propMap.put("object_name", nameText.getText().toString()); + } + if (zccpmcText.getText().toString().length() != 0) { + propMap.put("hs2_assemblyproname", zccpmcText.getText().toString()); + } + if (zccpljhText.getText().toString().length() != 0) { + propMap.put("hs2_assemblypartname", zccpljhText.getText().toString()); + } + if (ggljmcText.getText().toString().length() != 0) { + propMap.put("hs2_changepartname", ggljmcText.getText().toString()); + } + if (ggljhText.getText().toString().length() != 0) { + propMap.put("hs2_changepartnumber", ggljhText.getText().toString()); + } + + if (khgghText.getText().toString().length() != 0) { + propMap.put("hs2_customernumber", khgghText.getText().toString()); + } + if (sqrText.getText().toString().length() != 0) { + propMap.put("hs2_applicant", sqrText.getText().toString()); + } + if (khmcText.getText().toString().length() != 0) { + propMap.put("hs2_customername", khmcText.getText().toString()); + } + + //System.out.println("map="+propMap); + revision.setProperties(propMap); + revision.getItem().setProperty("object_name", nameText.getText()); + if (ggyyBox.getSelectedItem()!=null && ggyyBox.getSelectedItem().toString().length() != 0) { + //System.out.println("设置更改意愿"); + LovUtils.setLovProperty(revision, "hs2_changewilling", ggyyBox.getSelectedItem().toString()); + } + if (xmjdBox.getSelectedItem()!=null && xmjdBox.getSelectedItem().toString().length() != 0) { + LovUtils.setLovProperty(revision, "hs2_projectstage", xmjdBox.getSelectedItem().toString()); + } + + //写入excel + TCComponent[] referenceListProperty = revision.getReferenceListProperty("IMAN_specification"); + //移除之前的数据集 + for (TCComponent attche : referenceListProperty) { + if (attche instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) attche; +// System.out.println("dateset.type="+dataset.getType()); +// System.out.println("dataset.name="+dataset.getProperty("object_name")); + + if (dataset.getType().equals("MSExcelX") && dataset.getProperty("object_name").equals("工程更改风险评估及可行性分析报告单")) { + System.out.println("移除工程更改风险评估及可行性分析报告单"); + revision.remove("IMAN_specification", dataset); + } + } + } + + //创建数据集 + File file = SXXUtil.getSXX(session, "HS2_FeasibilityARevision"); + if (file == null) { + return ; + } + String absolutePath = file.getAbsolutePath(); + int num = absolutePath.lastIndexOf("."); + String temp = absolutePath.substring(0, num); + temp = temp + "导出.xlsx"; +// String substring = absolutePath.substring(0, absolutePath.lastIndexOf("\\")); +// String pathString = substring + "\\" + titleName + ".xlsx"; + File outFile = new File(temp); + if (outFile.exists()) { + outFile.delete(); + System.out.println("删除temp成功"); + } + POIExcel poiExcel = new POIExcel(); + poiExcel.writerExcel(file, revision, temp); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("MSExcelX"); + TCComponentDataset dataset = datasetType.create("工程更改风险评估及可行性分析报告单", "", "MSExcelX"); + String[] as1 = new String[] { temp }; + String[] as2 = new String[] { "excel" }; + dataset.setFiles(as1, as2); + revision.add("IMAN_specification", dataset); + //docRevision.add("TC_Attaches ", dataset); + + File f = new File(absolutePath); + if (f.exists() && f.isFile()) { + f.delete(); + System.out.println("删除成功"); + } + + if (outFile.exists() && outFile.isFile()) { + + outFile.delete(); + System.out.println("删除成功"); + } + MessageBox.post("修改成功!!","提示",2); + this.dispose(); + } catch (Exception e2) { + // TODO: handle exception + MessageBox.post("修改失败,请联系管理员!!","提示",2); + e2.printStackTrace(); + } + + } + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/ggfxd/GGFXDHandler.java b/src/com/connor/hs2/plm/projectmanage/change/ggfxd/GGFXDHandler.java new file mode 100644 index 0000000..8a33add --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/ggfxd/GGFXDHandler.java @@ -0,0 +1,28 @@ +package com.connor.hs2.plm.projectmanage.change.ggfxd; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonAction; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class GGFXDHandler extends AbstractHandler{ + + private TCSession session ; + private TCComponentScheduleTask schedule; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + GGFXDAction action = new GGFXDAction(app, null); + new Thread(action).start(); + return null; + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/ggfxd/POIExcel.java b/src/com/connor/hs2/plm/projectmanage/change/ggfxd/POIExcel.java new file mode 100644 index 0000000..00e23cb --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/ggfxd/POIExcel.java @@ -0,0 +1,200 @@ +package com.connor.hs2.plm.projectmanage.change.ggfxd; + +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 org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; + +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCException; + +/* + * POI写入Excel + * */ +public class POIExcel { + + /* + * Excel写操作 + */ + public void writerExcel(File file, TCComponentItemRevision revision, String outPath) { + // TODO Auto-generated method stub + // 文件流的初始化 + Workbook wb = null; + FileInputStream fis = null; + FileOutputStream out = null; + try { + fis = new FileInputStream(file); + wb = WorkbookFactory.create(fis); + File exportFile = new File(outPath); + if (!exportFile.exists()) { + exportFile.createNewFile(); + } + out = new FileOutputStream(exportFile); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + Sheet sheet = wb.getSheetAt(0); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + // 第三行 + +// Cell cpxhCell = row0.getCell(43); +// Cell cpjhCell = row0.getCell(60); + try { + Row row4 = sheet.getRow(3); + row4.getCell(5).setCellValue(revision.getProperty("hs2_assemblyproname")); + row4.getCell(17).setCellValue(revision.getProperty("hs2_assemblypartname")); + + Row row5 = sheet.getRow(4); + row5.getCell(5).setCellValue(revision.getProperty("hs2_changepartname")); + row5.getCell(17).setCellValue(revision.getProperty("hs2_changepartnumber")); + + Row row6 = sheet.getRow(5); + row6.getCell(5).setCellValue(revision.getProperty("hs2_changeno")); + row6.getCell(17).setCellValue(revision.getProperty("hs2_customernumber")); + + Row row7 = sheet.getRow(6); + row7.getCell(5).setCellValue(revision.getProperty("hs2_customername")); + row7.getCell(17).setCellValue(revision.getProperty("hs2_applicant")); + + Row row8 = sheet.getRow(7); + Cell ggyyCell = row8.getCell(5); + TCComponentListOfValues lov = revision.getTCProperty("hs2_changewilling").getLOV(); + StringBuilder ggyy = new StringBuilder(); + if (lov != null) { + if (lov.getListOfValues() != null) { + String[] strs = lov.getListOfValues().getStringListOfValues();// 所有真实值 + for (String s1 : strs) { + String a1 = lov.getListOfValues().getDisplayableValue(s1);// 真实值对应的显示值 + // System.out.println("s1="+s1); + if (a1.equals(revision.getProperty("hs2_changewilling"))) { + ggyy.append(" √" + a1 + " "); + } else { + ggyy.append(" " + a1 + " "); + } + } + + } + } + ggyyCell.setCellValue(ggyy.toString()); + + Cell xmjdCell = row8.getCell(17); + TCComponentListOfValues ymjdLov = revision.getTCProperty("hs2_projectstage").getLOV(); + StringBuilder xmjd = new StringBuilder(); + if (ymjdLov != null) { + if (ymjdLov.getListOfValues() != null) { + String[] strs = ymjdLov.getListOfValues().getStringListOfValues();// 所有真实值 + + for (String s1 : strs) { + String a1 = ymjdLov.getListOfValues().getDisplayableValue(s1);// 真实值对应的显示值 + // System.out.println("s1="+s1); + if (a1.equals(revision.getProperty("hs2_projectstage"))) { + xmjd.append(" √" + a1 + " "); + } else { + xmjd.append(" " + a1 + " "); + } + } + + } + } + xmjdCell.setCellValue(xmjd.toString()); + + Row row42 = sheet.getRow(41); + row42.getCell(5).setCellValue(revision.getProperty("hs2_assemblyproname")); + row42.getCell(17).setCellValue(revision.getProperty("hs2_assemblypartname")); + + Row row43 = sheet.getRow(42); + row43.getCell(5).setCellValue(revision.getProperty("hs2_changepartname")); + row43.getCell(17).setCellValue(revision.getProperty("hs2_changepartnumber")); + + Row row44 = sheet.getRow(43); + row44.getCell(5).setCellValue(revision.getProperty("hs2_changeno")); + row44.getCell(17).setCellValue(revision.getProperty("hs2_customernumber")); + + Row row45 = sheet.getRow(44); + row45.getCell(5).setCellValue(revision.getProperty("hs2_customername")); + row45.getCell(17).setCellValue(revision.getProperty("hs2_applicant")); + + Row row46 = sheet.getRow(45); + Cell ggyyCell2 = row46.getCell(5); + TCComponentListOfValues lov1 = revision.getTCProperty("hs2_changewilling").getLOV(); + StringBuilder ggyy1 = new StringBuilder(); + if (lov1 != null) { + if (lov1.getListOfValues() != null) { + String[] strs = lov1.getListOfValues().getStringListOfValues();// 所有真实值 + for (String s1 : strs) { + String a1 = lov1.getListOfValues().getDisplayableValue(s1);// 真实值对应的显示值 + // System.out.println("s1="+s1); + if (a1.equals(revision.getProperty("hs2_changewilling"))) { + ggyy1.append(" √" + a1 + " "); + } else { + ggyy1.append(" " + a1 + " "); + } + } + + } + } + ggyyCell2.setCellValue(ggyy1.toString()); + + Cell xmjdCell2 = row46.getCell(17); + TCComponentListOfValues ymjdLov1 = revision.getTCProperty("hs2_projectstage").getLOV(); + StringBuilder xmjd1 = new StringBuilder(); + if (ymjdLov1 != null) { + if (ymjdLov1.getListOfValues() != null) { + String[] strs = ymjdLov1.getListOfValues().getStringListOfValues();// 所有真实值 + + for (String s1 : strs) { + String a1 = ymjdLov.getListOfValues().getDisplayableValue(s1);// 真实值对应的显示值 + // System.out.println("s1="+s1); + if (a1.equals(revision.getProperty("hs2_projectstage"))) { + xmjd1.append(" √" + a1 + " "); + } else { + xmjd1.append(" " + a1 + " "); + } + } + + } + } + xmjdCell2.setCellValue(xmjd.toString()); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + ; + + try { + fis.close(); + wb.write(out); + out.flush(); + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + +// public static Workbook create(InputStream in) throws IOException, InvalidFormatException { +// if (!in.markSupported()) { +// in = new PushbackInputStream(in, 8); +// } +// if (POIFSFileSystem.hasPOIFSHeader(in)) { +// return new HSSFWorkbook(in); +// } +// if (POIXMLDocument.hasOOXMLHeader(in)) { +// return new XSSFWorkbook(OPCPackage.open(in)); +// } +// throw new IllegalArgumentException("你的excel版本目前poi解析不了"); +// +// } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/ggrwd/GGRWDAction.java b/src/com/connor/hs2/plm/projectmanage/change/ggrwd/GGRWDAction.java new file mode 100644 index 0000000..da6ccbf --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/ggrwd/GGRWDAction.java @@ -0,0 +1,28 @@ +package com.connor.hs2.plm.projectmanage.change.ggrwd; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +public class GGRWDAction extends AbstractAIFAction{ + private AbstractAIFApplication app; + + public GGRWDAction(AbstractAIFApplication app, String arg1) { + super(app, arg1); + // TODO Auto-generated constructor stub + this.app = app; + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + GGRWDCommad command = new GGRWDCommad(app); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/ggrwd/GGRWDCommad.java b/src/com/connor/hs2/plm/projectmanage/change/ggrwd/GGRWDCommad.java new file mode 100644 index 0000000..a35ee96 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/ggrwd/GGRWDCommad.java @@ -0,0 +1,59 @@ +package com.connor.hs2.plm.projectmanage.change.ggrwd; + +import java.util.HashMap; +import java.util.Map; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonOpeartion; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; + +public class GGRWDCommad extends AbstractAIFCommand{ + private AbstractAIFApplication app; + + public GGRWDCommad(AbstractAIFApplication app) { + super(); + this.app = app; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + super.executeModal(); + Map map=new HashMap(); + if (app.getTargetComponent()!=null && (app.getTargetComponent().getType().equals("HS2_GGSQRevision") + || app.getTargetComponent().getType().equals("HS2_GGTZRevision") + || app.getTargetComponent().getType().equals("HS2_KXXFXBGPGRevision") + || app.getTargetComponent().getType().equals("HS2_GGRWDItemRevision") + || app.getTargetComponent().getType().equals("HS2_YZBGItemRevision") + || app.getTargetComponent().getType().equals("HS2_RequestRevision") + || app.getTargetComponent().getType().equals("HS2_NoticeRevision") + || app.getTargetComponent().getType().equals("HS2_FeasibilityARevision") + || app.getTargetComponent().getType().equals("HS2_ChangeTaskRevision") + || app.getTargetComponent().getType().equals("HS2_VerifyRevision") + )) { + TCComponentItemRevision target = (TCComponentItemRevision) app.getTargetComponent(); + String id = target.getProperty("item_id"); + String name = target.getProperty("object_name"); + map.put("item_id", id); + map.put("object_name", name); + String name1; + TCProperty[] allTCProperties = target.getAllTCProperties(); + for (int i = 0; i < allTCProperties.length; i++) { + TCProperty tcProperty = allTCProperties[i]; + name1 = tcProperty.getPropertyName(); + + if (name1.startsWith("hs2_")) { + map.put(name1, tcProperty.getPropertyValue()); + } + } + } + GGRWDDialog dialog = new GGRWDDialog(app,map); + new Thread(dialog).start(); + + } + + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/ggrwd/GGRWDDialog.java b/src/com/connor/hs2/plm/projectmanage/change/ggrwd/GGRWDDialog.java new file mode 100644 index 0000000..27d9002 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/ggrwd/GGRWDDialog.java @@ -0,0 +1,465 @@ +package com.connor.hs2.plm.projectmanage.change.ggrwd; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.ScrollPaneConstants; + +import org.jdesktop.swingx.JXDatePicker; + +import com.connor.hs2.plm.projectmanage.utils.LovUtils; +import com.connor.hs2.plm.projectmanage.utils.SXXUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +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.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class GGRWDDialog extends AbstractAIFDialog implements ActionListener{ + + private AbstractAIFApplication app; + private TCSession session; + private JTextField idText; + private JButton idButton; + private TCComponentItemType type; + private JTextField nameText; + //private JButton nameButton; + private JTextField zccpmcText; + private JTextField zccpljhText; + private JTextField ggljmcText; + private JTextField ggljhText; +// private JTextField sqbmText; + private JTextField khgghText; + private JTextField khmcText; + private JButton createButton; + private JButton cancelButton; + private JButton modifyButton; + private Map propertyMap; + public GGRWDDialog(AbstractAIFApplication app, Map map) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + this.propertyMap = map; + } + + @Override + public void run() { + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void init() throws TCException { +JPanel rootPanel = new JPanel(new PropertyLayout()); + + JPanel propertyPanel = new JPanel(new PropertyLayout()); + //propertyPanel.setSize(new Dimension(400,450)); + //propertyPanel.setPreferredSize(new Dimension(500,650)); + JPanel buttomPanel = new JPanel(new PropertyLayout()); + type = (TCComponentItemType) session.getTypeComponent("HS2_ChangeTask"); + + JLabel lable1 = new JLabel("ID:"); + idText = new JTextField(13); + if (propertyMap.get("item_id")!=null && !propertyMap.get("item_id").equals("")) { + idText.setText((String) propertyMap.get("item_id")); + }else { + idText.setText(type.getNewID()); + } + idButton = new JButton("指派"); + idButton.addActionListener(this); + + + JLabel lable2 = new JLabel("名称:"); + nameText = new JTextField(13); + if (propertyMap.get("object_name")!=null && !propertyMap.get("object_name").equals("")) { + nameText.setText((String) propertyMap.get("object_name")); + }else { + nameText.setText("更改任务单"); + } + //nameButton = new JButton("指派"); + + if (app.getTargetComponent()!=null && !app.getTargetComponent().getType().equals("HS2_ChangeTaskRevision")) { + //对象不一样 id设为空 名称默认 + System.out.println("对象类型不一致"); + idText.setText(type.getNewID()); + nameText.setText("更改任务单"); + } + JLabel lable3 = new JLabel("客户更改号:"); + khgghText = new JTextField(13); + if (propertyMap.get("hs2_customernumber")!=null && !propertyMap.get("hs2_customernumber").equals("")) { + khgghText.setText((String) propertyMap.get("hs2_customernumber")); + } + + JLabel lable4 = new JLabel("客户名称:"); + khmcText = new JTextField(13); + if (propertyMap.get("hs2_customername")!=null && !propertyMap.get("hs2_customername").equals("")) { + khmcText.setText((String) propertyMap.get("hs2_customername")); + } + + JLabel lable5 = new JLabel("更改零件名称:"); + ggljmcText = new JTextField(13); + if (propertyMap.get("hs2_changepartname")!=null && !propertyMap.get("hs2_changepartname").equals("")) { + ggljmcText.setText((String) propertyMap.get("hs2_changepartname")); + } + + JLabel lable6 = new JLabel("更改零件号:"); + ggljhText = new JTextField(13); + if (propertyMap.get("hs2_changepartnumber")!=null && !propertyMap.get("hs2_changepartnumber").equals("")) { + ggljhText.setText((String) propertyMap.get("hs2_changepartnumber")); + } + JLabel lable7 = new JLabel("总成产品名称:"); + zccpmcText = new JTextField(13); + if (propertyMap.get("hs2_assemblyproname")!=null && !propertyMap.get("hs2_assemblyproname").equals("")) { + zccpmcText.setText((String) propertyMap.get("hs2_assemblyproname")); + } + + //rootPanel.add("2.3.left.top",nameButton); + JLabel lable8 = new JLabel("总成产品零件号:"); + zccpljhText = new JTextField(13); + if (propertyMap.get("hs2_assemblypartname")!=null && !propertyMap.get("hs2_assemblypartname").equals("")) { + zccpljhText.setText((String) propertyMap.get("hs2_assemblypartname")); + } + + propertyPanel.add("1.1.left.top",lable1); + propertyPanel.add("1.2.left.top",idText); + propertyPanel.add("1.3.left.top",idButton); + propertyPanel.add("2.1.left.top",lable2); + propertyPanel.add("2.2.left.top",nameText); + propertyPanel.add("3.1.left.top",lable3); + propertyPanel.add("3.2.left.top",khgghText); + propertyPanel.add("4.1.left.top",lable4); + propertyPanel.add("4.2.left.top",khmcText); + propertyPanel.add("5.1.left.top",lable5); + propertyPanel.add("5.2.left.top",ggljmcText); + propertyPanel.add("6.1.left.top",lable6); + propertyPanel.add("6.2.left.top",ggljhText); + propertyPanel.add("7.1.left.top",lable7); + propertyPanel.add("7.2.left.top",zccpmcText); + propertyPanel.add("8.1.left.top",lable8); + propertyPanel.add("8.2.left.top",zccpljhText); + + createButton = new JButton("创建"); + cancelButton = new JButton("取消"); + modifyButton = new JButton("修改"); + if (app.getTargetComponent()!=null && app.getTargetComponent().getType().equals("HS2_ChangeTaskRevision")) { + modifyButton.setEnabled(true); + }else { + modifyButton.setEnabled(false); + } + createButton.addActionListener(this); + cancelButton.addActionListener(this); + modifyButton.addActionListener(this); + buttomPanel.add("1.1.center.left",createButton); + buttomPanel.add("1.2.center.left",modifyButton); + buttomPanel.add("1.3.center.left",cancelButton); + + JScrollPane propertyPane = new JScrollPane(propertyPanel); + propertyPane.setPreferredSize(new Dimension(480,400)); + //propertyPane.add(propertyPanel); + propertyPane.setBorder(null); + + propertyPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + //propertyPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + rootPanel.add("1.1.left.top",propertyPane); + rootPanel.add("2.1.center.left",buttomPanel); + this.setTitle("更改任务单"); + this.setLayout(new BorderLayout(10, 0)); + this.setPreferredSize(new Dimension(520,470)); + //panel.add(panel1, BorderLayout.WEST); + //panel.add(panel6, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.CENTER); + this.pack(); + this.setVisible(true); + this.setLocationRelativeTo(null); + this.setResizable(false);//不可变动窗口大小 + } + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + // TODO Auto-generated method stub + if (e.getSource().equals(idButton)) { + try { + String id = type.getNewID(); + this.idText.setText(id); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }else if (e.getSource().equals(cancelButton)) { + this.dispose(); + } + else if (e.getSource().equals(createButton)) { + //this.dispose(); + try { + if (idText.getText().trim().equals("") || nameText.getText().trim().equals("")) { + MessageBox.post("请填写ID和名称!!","提示",2); + return ; + } + + String id = idText.getText(); + String name = nameText.getText(); + + if (type.find(id) != null) { + MessageBox.post("ID重复,请重新输入!!","提示",2); + return ; + } + File file = SXXUtil.getSXX(session, "HS2_ChangeTaskRevision"); + if (file == null) { + return ; + } + + + String newRev = type.getNewRev(null); + TCComponentItem item = type.create(id, newRev, "HS2_ChangeTask", name, "", null); + if (item!=null) { + TCComponentItemRevision revision = item.getLatestItemRevision(); + Map propMap = new HashMap(); + if (nameText.getText().toString().length() != 0) { + propMap.put("object_name", nameText.getText().toString()); + } + if (zccpmcText.getText().toString().length() != 0) { + propMap.put("hs2_assemblyproname", zccpmcText.getText().toString()); + } + if (zccpljhText.getText().toString().length() != 0) { + propMap.put("hs2_assemblypartname", zccpljhText.getText().toString()); + } + if (ggljmcText.getText().toString().length() != 0) { + propMap.put("hs2_changepartname", ggljmcText.getText().toString()); + } + if (ggljhText.getText().toString().length() != 0) { + propMap.put("hs2_changepartnumber", ggljhText.getText().toString()); + } + + if (khmcText.getText().toString().length() != 0) { + propMap.put("hs2_customername", khmcText.getText().toString()); + } + + if (khgghText.getText().toString().length() != 0) { + propMap.put("hs2_customernumber", khgghText.getText().toString()); + } + //System.out.println("map="+propMap); + revision.setProperties(propMap); + + String absolutePath = file.getAbsolutePath(); + int num = absolutePath.lastIndexOf("."); + String temp = absolutePath.substring(0, num); + temp = temp + "导出.xlsx"; +// String substring = absolutePath.substring(0, absolutePath.lastIndexOf("\\")); +// String pathString = substring + "\\" + titleName + ".xlsx"; + File outFile = new File(temp); + if (outFile.exists()) { + outFile.delete(); + System.out.println("删除temp成功"); + } + POIExcel poiExcel = new POIExcel(); + poiExcel.writerExcel(file, revision, temp); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("MSExcelX"); + TCComponentDataset dataset = datasetType.create("工程更改任务单", "", "MSExcelX"); + String[] as1 = new String[] { temp }; + String[] as2 = new String[] { "excel" }; + dataset.setFiles(as1, as2); + revision.add("IMAN_specification", dataset); + //docRevision.add("IMAN_specification ", dataset); + + File f = new File(absolutePath); + if (f.exists() && f.isFile()) { + f.delete(); + System.out.println("删除成功"); + } + + if (outFile.exists() && outFile.isFile()) { + + outFile.delete(); + System.out.println("删除成功"); + } + + if (app.getTargetComponent() !=null && app.getTargetComponent().getType().equals("ProjectSmartFolder")) { + TCComponent ref = ((TCComponent) app.getTargetComponent()).getReferenceProperty("owning_project"); + if (ref!=null) { + TCComponentProject pro = (TCComponentProject) ref; + pro.assignToProject(new TCComponent[] {item}); + } + }else + if (app.getTargetComponent() !=null && app.getTargetComponent() instanceof TCComponentFolder) { + ((TCComponentFolder)app.getTargetComponent()).add("contents", item); + }else if(app.getTargetComponent() !=null && app.getTargetComponent() instanceof TCComponentProject) + { + TCComponentProject pro = (TCComponentProject) app.getTargetComponent(); + pro.assignToProject(new TCComponent[] {item}); + }else { + session.getUser().getNewStuffFolder().add("contents", item); + } + + //添加关系 + if (app.getTargetComponent()!=null && !app.getTargetComponent().getType().equals(revision.getType())) { + //选中对象不为空 并且类型不一样 添加到对应的关系 + //选中更改通知版本 创建更改任务 添加关系 + if (app.getTargetComponent().getType().equals("HS2_NoticeRevision")) { + System.out.println("选中更改通知版本 创建更改任务单"); + TCComponentItemRevision targetRevision = (TCComponentItemRevision) app.getTargetComponent(); + targetRevision.add("HS2_TaskList", item); + } + } + + //如果选中的对象版本被指派到项目 那么创建出来的也要指派到项目 + if (app.getTargetComponent()!=null && (app.getTargetComponent() instanceof TCComponentItemRevision || app.getTargetComponent() instanceof TCComponentItem)) { + System.out.println("判断是否被指派到项目"); + TCComponent[] refs = ((TCComponent) app.getTargetComponent()).getReferenceListProperty("project_list"); + //System.out.println("ref="+refs); + if (refs!=null && refs.length>0) { + for (TCComponent component : refs) { + TCComponentProject project = (TCComponentProject)component; + project.assignToProject(new TCComponent[] {item}); + } + } + } + MessageBox.post("创建成功!!","提示",2); + this.dispose(); + }else { + MessageBox.post("创建失败,请联系管理员!!","提示",2); + } + } catch (Exception e1) { + // TODO: handle exception + e1.printStackTrace(); + } + } + else if (e.getSource().equals(modifyButton)) { + //设置属性 + if (app.getTargetComponent()==null) { + MessageBox.post("请选中更改任务单版本进行修改!!","提示",2); + return ; + } +// if (!app.getTargetComponent().getType().equals("HS2_GGSQRevision")) { +// MessageBox.post("请选中变更申请单版本进行修改!!","提示",2); +// return ; +// } + + + try { + + TCComponentItemRevision revision = (TCComponentItemRevision) app.getTargetComponent(); + if (!idText.getText().trim().equals(revision.getProperty("item_id"))) { + MessageBox.post("ID不允许修改!!","提示",2); + return ; + } + + + Map propMap = new HashMap(); + if (nameText.getText().toString().length() != 0) { + propMap.put("object_name", nameText.getText().toString()); + } + if (zccpmcText.getText().toString().length() != 0) { + propMap.put("hs2_assemblyproname", zccpmcText.getText().toString()); + } + if (zccpljhText.getText().toString().length() != 0) { + propMap.put("hs2_assemblypartname", zccpljhText.getText().toString()); + } + if (ggljmcText.getText().toString().length() != 0) { + propMap.put("hs2_changepartnumber", ggljmcText.getText().toString()); + } + if (ggljhText.getText().toString().length() != 0) { + propMap.put("hs2_changepartnumber", ggljhText.getText().toString()); + } + if (khgghText.getText().toString().length() != 0) { + propMap.put("hs2_customernumber", khgghText.getText().toString()); + } + if (khmcText.getText().toString().length() != 0) { + propMap.put("hs2_customername", khmcText.getText().toString()); + } + + //System.out.println("map="+propMap); + revision.setProperties(propMap); + System.out.println("更改对象名称"); + revision.getItem().setProperty("object_name", nameText.getText()); + + //写入excel + TCComponent[] referenceListProperty = revision.getReferenceListProperty("IMAN_specification"); + //移除之前的数据集 + for (TCComponent attche : referenceListProperty) { + if (attche instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) attche; +// System.out.println("dateset.type="+dataset.getType()); +// System.out.println("dataset.name="+dataset.getProperty("object_name")); + + if (dataset.getType().equals("MSExcelX") && dataset.getProperty("object_name").equals("工程更改任务单")) { + System.out.println("移除更改任务单"); + revision.remove("IMAN_specification", dataset); + } + } + } + + //创建数据集 + File file = SXXUtil.getSXX(session, "HS2_ChangeTaskRevision"); + if (file == null) { + return ; + } + String absolutePath = file.getAbsolutePath(); + int num = absolutePath.lastIndexOf("."); + String temp = absolutePath.substring(0, num); + temp = temp + "导出.xlsx"; +// String substring = absolutePath.substring(0, absolutePath.lastIndexOf("\\")); +// String pathString = substring + "\\" + titleName + ".xlsx"; + File outFile = new File(temp); + if (outFile.exists()) { + outFile.delete(); + System.out.println("删除temp成功"); + } + POIExcel poiExcel = new POIExcel(); + poiExcel.writerExcel(file, revision, temp); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("MSExcelX"); + TCComponentDataset dataset = datasetType.create("工程更改任务单", "", "MSExcelX"); + String[] as1 = new String[] { temp }; + String[] as2 = new String[] { "excel" }; + dataset.setFiles(as1, as2); + revision.add("IMAN_specification", dataset); + //docRevision.add("IMAN_specification ", dataset); + + File f = new File(absolutePath); + if (f.exists() && f.isFile()) { + f.delete(); + System.out.println("删除成功"); + } + + if (outFile.exists() && outFile.isFile()) { + + outFile.delete(); + System.out.println("删除成功"); + } + MessageBox.post("修改成功!!","提示",2); + this.dispose(); + } catch (Exception e2) { + // TODO: handle exception + MessageBox.post("修改失败,请联系管理员!!","提示",2); + e2.printStackTrace(); + } + + } + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/ggrwd/GGRWDHandler.java b/src/com/connor/hs2/plm/projectmanage/change/ggrwd/GGRWDHandler.java new file mode 100644 index 0000000..3969262 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/ggrwd/GGRWDHandler.java @@ -0,0 +1,28 @@ +package com.connor.hs2.plm.projectmanage.change.ggrwd; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonAction; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class GGRWDHandler extends AbstractHandler{ + + private TCSession session ; + private TCComponentScheduleTask schedule; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + GGRWDAction action = new GGRWDAction(app, null); + new Thread(action).start(); + return null; + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/ggrwd/POIExcel.java b/src/com/connor/hs2/plm/projectmanage/change/ggrwd/POIExcel.java new file mode 100644 index 0000000..6ea912f --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/ggrwd/POIExcel.java @@ -0,0 +1,94 @@ +package com.connor.hs2.plm.projectmanage.change.ggrwd; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; + +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.ss.usermodel.WorkbookFactory; + +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; + +/* + * POI写入Excel + * */ +public class POIExcel { + + /* + * Excel写操作 + */ + public void writerExcel(File file, TCComponentItemRevision revision, String outPath) { + // TODO Auto-generated method stub + // 文件流的初始化 + Workbook wb = null; + FileInputStream fis = null; + FileOutputStream out = null; + try { + fis = new FileInputStream(file); + wb = WorkbookFactory.create(fis); + File exportFile = new File(outPath); + if (!exportFile.exists()) { + exportFile.createNewFile(); + } + out = new FileOutputStream(exportFile); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + Sheet sheet = wb.getSheetAt(0); + // 第三行 + +// Cell cpxhCell = row0.getCell(43); +// Cell cpjhCell = row0.getCell(60); + try { + Row row2 = sheet.getRow(1); + row2.getCell(8).setCellValue(revision.getProperty("hs2_customernumber")); + // hs2_ZCCPMC hs2_ZCCPLJH + + Row row3 = sheet.getRow(2); + row3.getCell(8).setCellValue(revision.getProperty("hs2_customername")); + + Row row5 = sheet.getRow(4); + row5.getCell(1).setCellValue(revision.getProperty("hs2_changepartname")); + row5.getCell(4).setCellValue(revision.getProperty("hs2_changepartnumber")); + row5.getCell(6).setCellValue(revision.getProperty("hs2_assemblyproname")); + row5.getCell(8).setCellValue(revision.getProperty("hs2_assemblypartname")); + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + ; + + try { + fis.close(); + wb.write(out); + out.flush(); + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + +// public static Workbook create(InputStream in) throws IOException, InvalidFormatException { +// if (!in.markSupported()) { +// in = new PushbackInputStream(in, 8); +// } +// if (POIFSFileSystem.hasPOIFSHeader(in)) { +// return new HSSFWorkbook(in); +// } +// if (POIXMLDocument.hasOOXMLHeader(in)) { +// return new XSSFWorkbook(OPCPackage.open(in)); +// } +// throw new IllegalArgumentException("你的excel版本目前poi解析不了"); +// +// } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/ggsqd/GGSQDAction.java b/src/com/connor/hs2/plm/projectmanage/change/ggsqd/GGSQDAction.java new file mode 100644 index 0000000..dc87d16 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/ggsqd/GGSQDAction.java @@ -0,0 +1,28 @@ +package com.connor.hs2.plm.projectmanage.change.ggsqd; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +public class GGSQDAction extends AbstractAIFAction{ + private AbstractAIFApplication app; + + public GGSQDAction(AbstractAIFApplication app, String arg1) { + super(app, arg1); + // TODO Auto-generated constructor stub + this.app = app; + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + GGSQDCommad command = new GGSQDCommad(app); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/ggsqd/GGSQDCommad.java b/src/com/connor/hs2/plm/projectmanage/change/ggsqd/GGSQDCommad.java new file mode 100644 index 0000000..0253b6a --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/ggsqd/GGSQDCommad.java @@ -0,0 +1,66 @@ +package com.connor.hs2.plm.projectmanage.change.ggsqd; + +import java.util.HashMap; +import java.util.Map; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonOpeartion; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; + +public class GGSQDCommad extends AbstractAIFCommand{ + private AbstractAIFApplication app; + + public GGSQDCommad(AbstractAIFApplication app) { + super(); + this.app = app; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + super.executeModal(); + Map map=new HashMap(); + if (app.getTargetComponent()!=null && (app.getTargetComponent().getType().equals("HS2_GGSQRevision") + || app.getTargetComponent().getType().equals("HS2_GGTZRevision") + || app.getTargetComponent().getType().equals("HS2_KXXFXBGPGRevision") + || app.getTargetComponent().getType().equals("HS2_GGRWDItemRevision") + || app.getTargetComponent().getType().equals("HS2_YZBGItemRevision") + || app.getTargetComponent().getType().equals("HS2_RequestRevision") + || app.getTargetComponent().getType().equals("HS2_NoticeRevision") + || app.getTargetComponent().getType().equals("HS2_FeasibilityARevision") + || app.getTargetComponent().getType().equals("HS2_ChangeTaskRevision") + || app.getTargetComponent().getType().equals("HS2_VerifyRevision") + )) { + TCComponentItemRevision target = (TCComponentItemRevision) app.getTargetComponent(); + String id = target.getProperty("item_id"); + String name = target.getProperty("object_name"); + map.put("item_id", id); + map.put("object_name", name); + String name1; + TCProperty[] allTCProperties = target.getAllTCProperties(); + for (int i = 0; i < allTCProperties.length; i++) { + TCProperty tcProperty = allTCProperties[i]; + name1 = tcProperty.getPropertyName(); + + if (name1.startsWith("hs2_")) { + map.put(name1, tcProperty.getPropertyValue()); + } + + if (name1.equals("hs2_changewilling") || name1.equals("hs2_projectstage") || name1.equals("hs2_changetype")) { + map.put(name1, tcProperty.getDisplayValue()); + } + if (name1.equals("hs2_stock")) { + map.put(name1, tcProperty.getBoolValue()); + } + } + } + GGSQDDialog dialog = new GGSQDDialog(app,map); + new Thread(dialog).start(); + + } + + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/ggsqd/GGSQDDialog.java b/src/com/connor/hs2/plm/projectmanage/change/ggsqd/GGSQDDialog.java new file mode 100644 index 0000000..f39e9d4 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/ggsqd/GGSQDDialog.java @@ -0,0 +1,708 @@ +package com.connor.hs2.plm.projectmanage.change.ggsqd; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollBar; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.ScrollPaneConstants; + +import org.jdesktop.swingx.JXDatePicker; + +import com.connor.hs2.plm.projectmanage.utils.LovUtils; +import com.connor.hs2.plm.projectmanage.utils.SXXUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.common.propertyicon.binding.PropertyMap; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +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.TCComponentType; +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 GGSQDDialog extends AbstractAIFDialog implements ActionListener{ + + private AbstractAIFApplication app; + private TCSession session; + private JTextField idText; + private JButton idButton; + private TCComponentItemType type; + private JTextField nameText; + //private JButton nameButton; + private JTextField zccpmcText; + private JTextField zccpljhText; + private JTextField ggljmcText; + private JTextField ggljhText; + private JTextField sqbmText; + private JTextField khggheText; + private JTextField sqrText; + private JXDatePicker sqDatePicker; + private JTextField khmcText; + private JComboBox ggyyBox; + private JComboBox xmjdBox; + private JTextField ggyyText; + private JComboBox gglxBox; + private JTextField yxText; + private JTextField cpxhText; + private JRadioButton yesStock; + private JRadioButton noStock; + private ButtonGroup stockGroup; + private JXDatePicker gcggDatePicker; +// private JTextArea pzyjArea; + private JButton createButton; + private JButton cancelButton; + private JButton modifyButton; + private Map propertyMap; + public GGSQDDialog(AbstractAIFApplication app, Map map) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + this.propertyMap = map; + + } + + @Override + public void run() { + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void init() throws TCException { + + JPanel rootPanel = new JPanel(new PropertyLayout()); + + JPanel propertyPanel = new JPanel(new PropertyLayout()); + //propertyPanel.setSize(new Dimension(400,450)); + //propertyPanel.setPreferredSize(new Dimension(500,650)); + JPanel buttomPanel = new JPanel(new PropertyLayout()); + type = (TCComponentItemType) session.getTypeComponent("HS2_Request"); + if (type == null) { + type = (TCComponentItemType) session.getTypeComponent("HS2_GGSQ"); + } + + String hs2_ggyy = (propertyMap.get("hs2_changewilling") == null) ? "" : (String) propertyMap.get("hs2_changewilling"); + String hs2_xmjd = (propertyMap.get("hs2_projectstage") == null) ? "" : (String) propertyMap.get("hs2_projectstage"); + String hs2_changeType = (propertyMap.get("hs2_changetype") == null) ? "" : (String) propertyMap.get("hs2_changetype"); +// System.out.println("hs2_ggyy="+hs2_ggyy); +// System.out.println("hs2_xmjd="+hs2_xmjd); +// System.out.println("hs2_changeType="+hs2_changeType); + JLabel lable1 = new JLabel("ID:"); + idText = new JTextField(13); + if (propertyMap.get("item_id")!=null && !propertyMap.get("item_id").equals("")) { + idText.setText((String) propertyMap.get("item_id")); + }else { + idText.setText(type.getNewID()); + } + idButton = new JButton("指派"); + idButton.addActionListener(this); + + + JLabel lable2 = new JLabel("名称:"); + nameText = new JTextField(13); + //nameButton = new JButton("指派"); + if (propertyMap.get("object_name")!=null && !propertyMap.get("object_name").equals("")) { + nameText.setText((String) propertyMap.get("object_name")); + }else { + nameText.setText("更改申请单"); + } + + if (app.getTargetComponent()!=null && !app.getTargetComponent().getType().equals("HS2_RequestRevision")) { + //对象不一样 id设为空 名称默认 + System.out.println("对象类型不一致"); + idText.setText(type.getNewID()); + nameText.setText("更改申请单"); + } + JLabel lable3 = new JLabel("总成产品名称:"); + zccpmcText = new JTextField(13); + + if (propertyMap.get("hs2_assemblyproname")!=null && !propertyMap.get("hs2_assemblyproname").equals("")) { + zccpmcText.setText((String) propertyMap.get("hs2_assemblyproname")); + } + //rootPanel.add("2.3.left.top",nameButton); + JLabel lable4 = new JLabel("总成产品零件号:"); + zccpljhText = new JTextField(13); + + if (propertyMap.get("hs2_assemblypartname")!=null && !propertyMap.get("hs2_assemblypartname").equals("")) { + zccpljhText.setText((String) propertyMap.get("hs2_assemblypartname")); + } + + JLabel lable5 = new JLabel("更改零件名称:"); + ggljmcText = new JTextField(13); + + if (propertyMap.get("hs2_changepartname")!=null && !propertyMap.get("hs2_changepartname").equals("")) { + ggljmcText.setText((String) propertyMap.get("hs2_changepartname")); + } + + JLabel lable6 = new JLabel("更改零件号:"); + ggljhText = new JTextField(13); + + if (propertyMap.get("hs2_changepartnumber")!=null && !propertyMap.get("hs2_changepartnumber").equals("")) { + ggljhText.setText((String) propertyMap.get("hs2_changepartnumber")); + } + + JLabel lable7 = new JLabel("申请部门:"); + sqbmText = new JTextField(13); + if (propertyMap.get("hs2_applydept")!=null && !propertyMap.get("hs2_applydept").equals("")) { + sqbmText.setText((String) propertyMap.get("hs2_applydept")); + } + + JLabel lable8 = new JLabel("客户更改号:"); + khggheText = new JTextField(13); + if (propertyMap.get("hs2_customernumber")!=null && !propertyMap.get("hs2_customernumber").equals("")) { + khggheText.setText((String) propertyMap.get("hs2_customernumber")); + } + + JLabel lable9 = new JLabel("申请人/发起人:"); + sqrText = new JTextField(13); + if (propertyMap.get("hs2_applicant")!=null && !propertyMap.get("hs2_applicant").equals("")) { + sqrText.setText((String) propertyMap.get("hs2_applicant")); + } + + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + + JLabel lable10 = new JLabel("申请日期:"); + sqDatePicker = new JXDatePicker(); + sqDatePicker.setFormats(format); + if (propertyMap.get("hs2_applyDate")!=null && !propertyMap.get("hs2_applyDate").equals("")) { + sqDatePicker.setDate((Date) propertyMap.get("hs2_applyDate")); + } + + JLabel lable11 = new JLabel("客户名称:"); + khmcText = new JTextField(13); + if (propertyMap.get("hs2_customername")!=null && !propertyMap.get("hs2_customername").equals("")) { + khmcText.setText((String) propertyMap.get("hs2_customername")); + } + + JLabel lable12 = new JLabel("更改意愿:"); + ggyyBox = new JComboBox(); + LovUtils.addLovToBox("HS2_ChangeWilling", ggyyBox); + ggyyBox.setSelectedIndex(-1); + for (int i = 0; i < ggyyBox.getItemCount(); i++) { + if (ggyyBox.getItemAt(i).equals(hs2_ggyy)) { + ggyyBox.setSelectedIndex(i); + } + } + JLabel lable13 = new JLabel("项目阶段:"); + xmjdBox = new JComboBox(); + LovUtils.addLovToBox("HS2_ProjectStage", xmjdBox); + xmjdBox.setSelectedIndex(-1); + for (int i = 0; i < xmjdBox.getItemCount(); i++) { + if (xmjdBox.getItemAt(i).equals(hs2_xmjd)) { + xmjdBox.setSelectedIndex(i); + } + } + JLabel lable14 = new JLabel("更改原因:"); + ggyyText = new JTextField(13); + if (propertyMap.get("hs2_reasonchange")!=null && !propertyMap.get("hs2_reasonchange").equals("")) { + ggyyText.setText((String) propertyMap.get("hs2_reasonchange")); + } + + JLabel lable15 = new JLabel("更改类型:"); + gglxBox = new JComboBox(); + //hs2_changeType + LovUtils.addLovToBox("HS2_ChangeType",gglxBox); + gglxBox.setSelectedIndex(-1); + for (int i = 0; i < gglxBox.getItemCount(); i++) { + if (gglxBox.getItemAt(i).equals(hs2_changeType)) { + gglxBox.setSelectedIndex(i); + } + } + JLabel lable16 = new JLabel("对过往产品及原材料的影响:"); + yxText = new JTextField(13); + if (propertyMap.get("hs2_influence")!=null && !propertyMap.get("hs2_influence").equals("")) { + yxText.setText((String) propertyMap.get("hs2_influence")); + } + + JLabel lable17 = new JLabel("其他所涉及到的产品型号:"); + cpxhText = new JTextField(13); + if (propertyMap.get("hs2_productmodel")!=null && !propertyMap.get("hs2_productmodel").equals("")) { + cpxhText.setText((String) propertyMap.get("hs2_productmodel")); + } + + JLabel lable18 = new JLabel("是否有库存产品:"); + stockGroup = new ButtonGroup(); + yesStock = new JRadioButton("是"); + noStock = new JRadioButton("否"); + if (propertyMap.get("hs2_stock")!=null) { + boolean sfykc = (boolean) propertyMap.get("hs2_stock"); + if (sfykc == true) { + yesStock.setSelected(true); + } + if (sfykc == false) { + noStock.setSelected(true); + } + } + stockGroup.add(yesStock); + stockGroup.add(noStock); + + JLabel lable19 = new JLabel("工程更改申请时间:"); + gcggDatePicker = new JXDatePicker(); + gcggDatePicker.setFormats(format); + if (propertyMap.get("hs2_changeDate")!=null && !propertyMap.get("hs2_changeDate").equals("")) { + gcggDatePicker.setDate((Date) propertyMap.get("hs2_changeDate")); + } + +// JLabel lable120 = new JLabel("批准意见:"); +// pzyjArea = new JTextArea(5,13); +// pzyjArea.setLineWrap(true); //设置文本域中的文本为自动换行 +// pzyjArea.setForeground(Color.BLACK); //设置组件的背景色 +// //pzyjArea.setFont(new Font("宋体",Font.PLAIN,16)); //修改字体样式 +// pzyjArea.setBackground(Color.WHITE); //设置按钮背景色 +// if (propertyMap.get("hs2_appview")!=null && !propertyMap.get("hs2_appview").equals("")) { +// pzyjArea.setText((String) propertyMap.get("hs2_appview")); +// } +// JScrollPane jsp_pzyj = new JScrollPane(pzyjArea); //将文本域放入滚动窗口 + propertyPanel.add("1.1.left.top",lable1); + propertyPanel.add("1.2.left.top",idText); + propertyPanel.add("1.3.left.top",idButton); + propertyPanel.add("2.1.left.top",lable2); + propertyPanel.add("2.2.left.top",nameText); + propertyPanel.add("3.1.left.top",lable3); + propertyPanel.add("3.2.left.top",zccpmcText); + propertyPanel.add("4.1.left.top",lable4); + propertyPanel.add("4.2.left.top",zccpljhText); + propertyPanel.add("5.1.left.top",lable5); + propertyPanel.add("5.2.left.top",ggljmcText); + propertyPanel.add("6.1.left.top",lable6); + propertyPanel.add("6.2.left.top",ggljhText); + propertyPanel.add("7.1.left.top",lable7); + propertyPanel.add("7.2.left.top",sqbmText); + propertyPanel.add("8.1.left.top",lable8); + propertyPanel.add("8.2.left.top",khggheText); + propertyPanel.add("9.1.left.top",lable9); + propertyPanel.add("9.2.left.top",sqrText); + propertyPanel.add("10.1.left.top",lable10); + propertyPanel.add("10.2.left.top",sqDatePicker); + propertyPanel.add("11.1.left.top",lable11); + propertyPanel.add("11.2.left.top",khmcText); + propertyPanel.add("12.1.left.top",lable12); + propertyPanel.add("12.2.left.top",ggyyBox); + propertyPanel.add("13.1.left.top",lable13); + propertyPanel.add("13.2.left.top",xmjdBox); + propertyPanel.add("14.1.left.top",lable14); + propertyPanel.add("14.2.left.top",ggyyText); + propertyPanel.add("15.1.left.top",lable15); + propertyPanel.add("15.2.left.top",gglxBox); + propertyPanel.add("16.1.left.top",lable16); + propertyPanel.add("16.2.left.top",yxText); + propertyPanel.add("17.1.left.top",lable17); + propertyPanel.add("17.2.left.top",cpxhText); + propertyPanel.add("18.1.left.top",lable18); + propertyPanel.add("18.2.left.top",yesStock); + propertyPanel.add("18.3.left.top",noStock); + propertyPanel.add("19.1.left.top",lable19); + propertyPanel.add("19.2.left.top",gcggDatePicker); +// propertyPanel.add("20.1.left.top",lable120); +// propertyPanel.add("20.2.left.top",jsp_pzyj); + createButton = new JButton("创建"); + cancelButton = new JButton("取消"); + modifyButton = new JButton("修改"); + if (app.getTargetComponent()!=null && app.getTargetComponent().getType().equals("HS2_RequestRevision")) { + modifyButton.setEnabled(true); + }else { + modifyButton.setEnabled(false); + } + createButton.addActionListener(this); + cancelButton.addActionListener(this); + modifyButton.addActionListener(this); + buttomPanel.add("1.1.center.left",createButton); + buttomPanel.add("1.2.center.left",modifyButton); + buttomPanel.add("1.3.center.left",cancelButton); + + JScrollPane propertyPane = new JScrollPane(propertyPanel); + propertyPane.setPreferredSize(new Dimension(480,650)); + //propertyPane.add(propertyPanel); + propertyPane.setBorder(null); + + propertyPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + //propertyPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + rootPanel.add("1.1.left.top",propertyPane); + rootPanel.add("2.1.center.left",buttomPanel); + this.setTitle("更改申请单"); + this.setLayout(new BorderLayout(10, 0)); + this.setPreferredSize(new Dimension(520,720)); + //panel.add(panel1, BorderLayout.WEST); + //panel.add(panel6, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.CENTER); + this.pack(); + this.setVisible(true); + this.setLocationRelativeTo(null); + this.setResizable(false);//不可变动窗口大小 + } + @SuppressWarnings("deprecation") + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if (e.getSource().equals(idButton)) { + try { + String id = type.getNewID(); + this.idText.setText(id); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }else if (e.getSource().equals(cancelButton)) { + this.dispose(); + } + else if (e.getSource().equals(createButton)) { + //this.dispose(); + try { + if (idText.getText().trim().equals("") || nameText.getText().trim().equals("")) { + MessageBox.post("请填写ID和名称!!","提示",2); + return ; + } + + String id = idText.getText(); + String name = nameText.getText(); + + if (type.find(id) != null) { + MessageBox.post("ID重复,请重新输入!!","提示",2); + return ; + } + File file = SXXUtil.getSXX(session, "HS2_RequestRevision"); + if (file == null) { + return ; + } + + + String newRev = type.getNewRev(null); + TCComponentItem item = type.create(id, newRev, "HS2_Request", name, "", null); + if (item!=null) { + TCComponentItemRevision revision = item.getLatestItemRevision(); + Map propMap = new HashMap(); + if (nameText.getText().toString().length() != 0) { + propMap.put("object_name", nameText.getText().toString()); + } + if (zccpmcText.getText().toString().length() != 0) { + propMap.put("hs2_assemblyproname", zccpmcText.getText().toString()); + } + if (zccpljhText.getText().toString().length() != 0) { + propMap.put("hs2_assemblypartname", zccpljhText.getText().toString()); + } + if (ggljmcText.getText().toString().length() != 0) { + propMap.put("hs2_changepartname", ggljmcText.getText().toString()); + } + if (ggljhText.getText().toString().length() != 0) { + propMap.put("hs2_changepartnumber", ggljhText.getText().toString()); + } + if (sqbmText.getText().toString().length() != 0) { + propMap.put("hs2_applydept", sqbmText.getText().toString()); + } + if (khggheText.getText().toString().length() != 0) { + propMap.put("hs2_customernumber", khggheText.getText().toString()); + } + if (sqrText.getText().toString().length() != 0) { + propMap.put("hs2_applicant", sqrText.getText().toString()); + } + if (khmcText.getText().toString().length() != 0) { + propMap.put("hs2_customername", khmcText.getText().toString()); + } + if (ggyyText.getText().toString().length() != 0) { + propMap.put("hs2_reasonchange", ggyyText.getText().toString()); + } + if (yxText.getText().toString().length() != 0) { + propMap.put("hs2_influence", yxText.getText().toString()); + } + if (cpxhText.getText().toString().length() != 0) { + propMap.put("hs2_productmodel", cpxhText.getText().toString()); + } +// if (pzyjArea.getText().toString().length() != 0) { +// propMap.put("hs2_appview", pzyjArea.getText().toString()); +// } + //System.out.println("map="+propMap); + revision.setProperties(propMap); + if (ggyyBox.getSelectedItem()!=null && ggyyBox.getSelectedItem().toString().length() != 0) { + //System.out.println("设置更改意愿"); + LovUtils.setLovProperty(revision, "hs2_changewilling", ggyyBox.getSelectedItem().toString()); + } + if (xmjdBox.getSelectedItem()!=null && xmjdBox.getSelectedItem().toString().length() != 0) { + LovUtils.setLovProperty(revision, "hs2_projectstage", xmjdBox.getSelectedItem().toString()); + } + if (gglxBox.getSelectedItem()!=null && gglxBox.getSelectedItem().toString().length() != 0) { + LovUtils.setLovProperty(revision, "hs2_changetype", gglxBox.getSelectedItem().toString()); + } + if (sqDatePicker.getDate()!=null) { + revision.setDateProperty("hs2_applyDate", sqDatePicker.getDate()); + } + if (gcggDatePicker.getDate()!=null) { + revision.setDateProperty("hs2_changeDate", gcggDatePicker.getDate()); + } + + if (yesStock.isSelected()) { + //System.out.println("设置是否有库存"); + revision.setLogicalProperty("hs2_stock", true); + }else if (noStock.isSelected()){ + revision.setLogicalProperty("hs2_stock", false); + } + String absolutePath = file.getAbsolutePath(); + int num = absolutePath.lastIndexOf("."); + String temp = absolutePath.substring(0, num); + temp = temp + "导出.xlsx"; +// String substring = absolutePath.substring(0, absolutePath.lastIndexOf("\\")); +// String pathString = substring + "\\" + titleName + ".xlsx"; + File outFile = new File(temp); + if (outFile.exists()) { + outFile.delete(); + System.out.println("删除temp成功"); + } + POIExcel poiExcel = new POIExcel(); + poiExcel.writerExcel(file, revision, temp); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("MSExcelX"); + TCComponentDataset dataset = datasetType.create("工程更改申请单", "", "MSExcelX"); + String[] as1 = new String[] { temp }; + String[] as2 = new String[] { "excel" }; + dataset.setFiles(as1, as2); + revision.add("IMAN_specification", dataset); + //docRevision.add("IMAN_specification ", dataset); + + File f = new File(absolutePath); + if (f.exists() && f.isFile()) { + f.delete(); + System.out.println("删除成功"); + } + + if (outFile.exists() && outFile.isFile()) { + + outFile.delete(); + System.out.println("删除成功"); + } + + if (app.getTargetComponent() !=null && app.getTargetComponent().getType().equals("ProjectSmartFolder")) { + TCComponent ref = ((TCComponent) app.getTargetComponent()).getReferenceProperty("owning_project"); + if (ref!=null) { + TCComponentProject pro = (TCComponentProject) ref; + pro.assignToProject(new TCComponent[] {item}); + } + }else + if (app.getTargetComponent() !=null && app.getTargetComponent() instanceof TCComponentFolder) { + ((TCComponentFolder)app.getTargetComponent()).add("contents", item); + }else if(app.getTargetComponent() !=null && app.getTargetComponent() instanceof TCComponentProject) + { + TCComponentProject pro = (TCComponentProject) app.getTargetComponent(); + pro.assignToProject(new TCComponent[] {item}); + }else { + session.getUser().getNewStuffFolder().add("contents", item); + } + + //添加关系 + if (app.getTargetComponent()!=null && !app.getTargetComponent().getType().equals(revision.getType())) { + //选中对象不为空 并且类型不一样 添加到对应的关系 + //选中问题版本或更改通知版本 创建变更申请单 添加关系 + if (app.getTargetComponent().getType().equals("HS2_PRRevision") + || app.getTargetComponent().getType().equals("HS2_NoticeRevision")) { + System.out.println("选中问题版本或更改通知版本 创建变更申请单"); + TCComponentItemRevision targetRevision = (TCComponentItemRevision) app.getTargetComponent(); + targetRevision.add("HS2_ChangeForm", item); + if (app.getTargetComponent().getType().equals("HS2_PRRevision")) { + item.getLatestItemRevision().add("HS2_ProblemReport", targetRevision.getItem()); + }else if (app.getTargetComponent().getType().equals("HS2_NoticeRevision")) { + item.getLatestItemRevision().add("HS2_NoticeForm", targetRevision.getItem()); + } + } + } + + //如果选中的对象版本被指派到项目 那么创建出来的也要指派到项目 + if (app.getTargetComponent()!=null && (app.getTargetComponent() instanceof TCComponentItemRevision || app.getTargetComponent() instanceof TCComponentItem)) { + System.out.println("判断是否被指派到项目"); + TCComponent[] refs = ((TCComponent) app.getTargetComponent()).getReferenceListProperty("project_list"); + //System.out.println("ref="+refs); + if (refs!=null && refs.length>0) { + for (TCComponent component : refs) { + TCComponentProject project = (TCComponentProject)component; + project.assignToProject(new TCComponent[] {item}); + } + } + } + MessageBox.post("创建成功!!","提示",2); + this.dispose(); + }else { + MessageBox.post("创建失败,请联系管理员!!","提示",2); + } + } catch (Exception e1) { + // TODO: handle exception + e1.printStackTrace(); + } + } + else if (e.getSource().equals(modifyButton)) { + //设置属性 + if (app.getTargetComponent()==null) { + MessageBox.post("请选中变更申请单版本进行修改!!","提示",2); + return ; + } +// if (!app.getTargetComponent().getType().equals("HS2_GGSQRevision")) { +// MessageBox.post("请选中变更申请单版本进行修改!!","提示",2); +// return ; +// } + + + try { + + TCComponentItemRevision revision = (TCComponentItemRevision) app.getTargetComponent(); + if (!idText.getText().trim().equals(revision.getProperty("item_id"))) { + MessageBox.post("ID不允许修改!!","提示",2); + return ; + } + + + Map propMap = new HashMap(); + if (nameText.getText().toString().length() != 0) { + propMap.put("object_name", nameText.getText().toString()); + } + if (zccpmcText.getText().toString().length() != 0) { + propMap.put("hs2_assemblyproname", zccpmcText.getText().toString()); + } + if (zccpljhText.getText().toString().length() != 0) { + propMap.put("hs2_assemblypartname", zccpljhText.getText().toString()); + } + if (ggljmcText.getText().toString().length() != 0) { + propMap.put("hs2_changepartname", ggljmcText.getText().toString()); + } + if (ggljhText.getText().toString().length() != 0) { + propMap.put("hs2_changepartnumber", ggljhText.getText().toString()); + } + if (sqbmText.getText().toString().length() != 0) { + propMap.put("hs2_applydept", sqbmText.getText().toString()); + } + if (khggheText.getText().toString().length() != 0) { + propMap.put("hs2_customernumber", khggheText.getText().toString()); + } + if (sqrText.getText().toString().length() != 0) { + propMap.put("hs2_applicant", sqrText.getText().toString()); + } + if (khmcText.getText().toString().length() != 0) { + propMap.put("hs2_customername", khmcText.getText().toString()); + } + if (ggyyText.getText().toString().length() != 0) { + propMap.put("hs2_reasonchange", ggyyText.getText().toString()); + } + if (yxText.getText().toString().length() != 0) { + propMap.put("hs2_influence", yxText.getText().toString()); + } + if (cpxhText.getText().toString().length() != 0) { + propMap.put("hs2_productmodel", cpxhText.getText().toString()); + } +// if (pzyjArea.getText().toString().length() != 0) { +// propMap.put("hs2_appview", pzyjArea.getText().toString()); +// } + //System.out.println("map="+propMap); + revision.setProperties(propMap); + revision.getItem().setProperty("object_name", nameText.getText()); + if (ggyyBox.getSelectedItem()!=null && ggyyBox.getSelectedItem().toString().length() != 0) { + //System.out.println("设置更改意愿"); + LovUtils.setLovProperty(revision, "hs2_changewilling", ggyyBox.getSelectedItem().toString()); + } + if (xmjdBox.getSelectedItem()!=null && xmjdBox.getSelectedItem().toString().length() != 0) { + LovUtils.setLovProperty(revision, "hs2_projectstage", xmjdBox.getSelectedItem().toString()); + } + if (gglxBox.getSelectedItem()!=null && gglxBox.getSelectedItem().toString().length() != 0) { + LovUtils.setLovProperty(revision, "hs2_changetype", gglxBox.getSelectedItem().toString()); + } + if (sqDatePicker.getDate()!=null) { + revision.setDateProperty("hs2_applyDate", sqDatePicker.getDate()); + } + if (gcggDatePicker.getDate()!=null) { + revision.setDateProperty("hs2_changeDate", gcggDatePicker.getDate()); + } + + if (yesStock.isSelected()) { + //System.out.println("设置是否有库存"); + revision.setLogicalProperty("hs2_stock", true); + }else if (noStock.isSelected()){ + revision.setLogicalProperty("hs2_stock", false); + } + + //写入excel + TCComponent[] referenceListProperty = revision.getReferenceListProperty("IMAN_specification"); + //移除之前的数据集 + for (TCComponent attche : referenceListProperty) { + if (attche instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) attche; +// System.out.println("dateset.type="+dataset.getType()); +// System.out.println("dataset.name="+dataset.getProperty("object_name")); + + if (dataset.getType().equals("MSExcelX") && dataset.getProperty("object_name").equals("工程更改申请单")) { + System.out.println("移除更改申请单"); + revision.remove("IMAN_specification", dataset); + } + } + } + + //创建数据集 + File file = SXXUtil.getSXX(session, "HS2_RequestRevision"); + if (file == null) { + return ; + } + String absolutePath = file.getAbsolutePath(); + int num = absolutePath.lastIndexOf("."); + String temp = absolutePath.substring(0, num); + temp = temp + "导出.xlsx"; +// String substring = absolutePath.substring(0, absolutePath.lastIndexOf("\\")); +// String pathString = substring + "\\" + titleName + ".xlsx"; + File outFile = new File(temp); + if (outFile.exists()) { + outFile.delete(); + System.out.println("删除temp成功"); + } + POIExcel poiExcel = new POIExcel(); + poiExcel.writerExcel(file, revision, temp); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("MSExcelX"); + TCComponentDataset dataset = datasetType.create("工程更改申请单", "", "MSExcelX"); + String[] as1 = new String[] { temp }; + String[] as2 = new String[] { "excel" }; + dataset.setFiles(as1, as2); + revision.add("IMAN_specification", dataset); + //docRevision.add("IMAN_specification ", dataset); + + File f = new File(absolutePath); + if (f.exists() && f.isFile()) { + f.delete(); + System.out.println("删除成功"); + } + + if (outFile.exists() && outFile.isFile()) { + + outFile.delete(); + System.out.println("删除成功"); + } + MessageBox.post("修改成功!!","提示",2); + this.dispose(); + } catch (Exception e2) { + // TODO: handle exception + MessageBox.post("修改失败,请联系管理员!!","提示",2); + e2.printStackTrace(); + } + + } + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/ggsqd/GGSQDHandler.java b/src/com/connor/hs2/plm/projectmanage/change/ggsqd/GGSQDHandler.java new file mode 100644 index 0000000..6e5cc33 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/ggsqd/GGSQDHandler.java @@ -0,0 +1,28 @@ +package com.connor.hs2.plm.projectmanage.change.ggsqd; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonAction; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class GGSQDHandler extends AbstractHandler{ + + private TCSession session ; + private TCComponentScheduleTask schedule; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + GGSQDAction action = new GGSQDAction(app, null); + new Thread(action).start(); + return null; + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/ggsqd/POIExcel.java b/src/com/connor/hs2/plm/projectmanage/change/ggsqd/POIExcel.java new file mode 100644 index 0000000..e5c980f --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/ggsqd/POIExcel.java @@ -0,0 +1,231 @@ +package com.connor.hs2.plm.projectmanage.change.ggsqd; + +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 org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; + +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCException; + +/* + * POI写入Excel + * */ +public class POIExcel { + + /* + * Excel写操作 + */ + public void writerExcel(File file, TCComponentItemRevision revision, String outPath) { + // TODO Auto-generated method stub + // 文件流的初始化 + Workbook wb = null; + FileInputStream fis = null; + FileOutputStream out = null; + try { + fis = new FileInputStream(file); + wb = WorkbookFactory.create(fis); + File exportFile = new File(outPath); + if (!exportFile.exists()) { + exportFile.createNewFile(); + } + out = new FileOutputStream(exportFile); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + Sheet sheet = wb.getSheetAt(0); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + // 第三行 + +// Cell cpxhCell = row0.getCell(43); +// Cell cpjhCell = row0.getCell(60); + try { + Row row3 = sheet.getRow(2); + row3.getCell(5).setCellValue(revision.getProperty("hs2_assemblyproname")); + row3.getCell(21).setCellValue(revision.getProperty("hs2_assemblypartname")); + + Row row4 = sheet.getRow(3); + row4.getCell(5).setCellValue(revision.getProperty("hs2_changepartname")); + row4.getCell(21).setCellValue(revision.getProperty("hs2_changepartnumber")); + + Row row5 = sheet.getRow(4); + row5.getCell(5).setCellValue(revision.getProperty("hs2_applydept")); + row5.getCell(21).setCellValue(revision.getProperty("hs2_customernumber")); + + Row row6 = sheet.getRow(5); + row6.getCell(5).setCellValue(revision.getProperty("hs2_applydept")); + if (revision.getProperty("hs2_applyDate") != null && !revision.getProperty("hs2_applyDate").equals("")) { + row6.getCell(21).setCellValue(format.format(revision.getDateProperty("hs2_applyDate"))); + } + + Row row7 = sheet.getRow(6); + row7.getCell(5).setCellValue(revision.getProperty("hs2_customername")); + + Row row8 = sheet.getRow(7); + Cell ggyyCell = row8.getCell(5); + TCComponentListOfValues lov = revision.getTCProperty("hs2_changewilling").getLOV(); + StringBuilder ggyy = new StringBuilder(); + if (lov != null) { + if (lov.getListOfValues() != null) { + String[] strs = lov.getListOfValues().getStringListOfValues();// 所有真实值 + for (String s1 : strs) { + String a1 = lov.getListOfValues().getDisplayableValue(s1);// 真实值对应的显示值 + // System.out.println("s1="+s1); + if (a1.equals(revision.getProperty("hs2_changewilling"))) { + ggyy.append(" √" + a1 + " "); + } else { + ggyy.append(" " + a1 + " "); + } + } + + } + } + ggyyCell.setCellValue(ggyy.toString()); + + Cell xmjdCell = row8.getCell(21); + TCComponentListOfValues ymjdLov = revision.getTCProperty("hs2_projectstage").getLOV(); + StringBuilder xmjd = new StringBuilder(); + if (ymjdLov != null) { + if (ymjdLov.getListOfValues() != null) { + String[] strs = ymjdLov.getListOfValues().getStringListOfValues();// 所有真实值 + + for (String s1 : strs) { + String a1 = ymjdLov.getListOfValues().getDisplayableValue(s1);// 真实值对应的显示值 + // System.out.println("s1="+s1); + if (a1.equals(revision.getProperty("hs2_projectstage"))) { + xmjd.append(" √" + a1 + " "); + } else { + xmjd.append(" " + a1 + " "); + } + } + + } + } + xmjdCell.setCellValue(xmjd.toString()); + + Row row9 = sheet.getRow(8); + row9.getCell(3).setCellValue(revision.getProperty("hs2_reasonchange")); + + Row row11 = sheet.getRow(10); + Row row12 = sheet.getRow(11); + Cell Acell = row11.getCell(3); + Cell Bcell = row11.getCell(16); + Cell Ccell = row12.getCell(3); + Cell Dcell = row12.getCell(16); +// TCComponentListOfValues gglxLov = revision.getTCProperty("hs2_changeType").getLOV(); + // System.out.println("更改类型--"+ revision.getProperty("hs2_changeType")); + if (revision.getProperty("hs2_changetype").contains("零配件")) { + Bcell.setCellValue(" √" + " 材料、零配件发生更改;"); + } + if (revision.getProperty("hs2_changetype").contains("关键工序")) { + Acell.setCellValue(" √" + " 关键工序人员更换;"); + } + if (revision.getProperty("hs2_changetype").contains("设备")) { + Ccell.setCellValue(" √" + " 设备/模具/工装/检具/夹具等更改;"); + } + + if (revision.getProperty("hs2_changetype").contains("作业条件")) { + Dcell.setCellValue(" √" + " 方法、工艺、作业条件发生更改。"); + } +// if (gglxLov!=null) { +// if (gglxLov.getListOfValues()!=null) { +// String[] strs = ymjdLov.getListOfValues().getStringListOfValues();// 所有真实值 +// +// for (String s1 : strs) { +// if (s1.equals("A")) { +// Acell.setCellValue("√"+" 关键工序人员更换;"); +// } +// if (s1.equals("B")) { +// Bcell.setCellValue("√"+" 材料、零配件发生更改;"); +// } +// if (s1.equals("C")) { +// Ccell.setCellValue("√"+" 设备/模具/工装/检具/夹具等更改;"); +// } +// if (s1.equals("D")) { +// Dcell.setCellValue("√"+" 方法、工艺、作业条件发生更改。"); +// } +// } +// +// } +// } + Row row19 = sheet.getRow(18); + row19.getCell(3).setCellValue(revision.getProperty("hs2_influence")); + row19.getCell(20).setCellValue(revision.getProperty("hs2_productmodel")); + + Row row20 = sheet.getRow(19); + Cell stockCell = row20.getCell(0); + if (revision.getProperty("hs2_stock") != null) { + if (revision.getLogicalProperty("hs2_stock")) { + stockCell.setCellValue("是否有库存产品? √是 否 (包括总成零件、半成品、供方零件和原材料)"); + } else { + stockCell.setCellValue("是否有库存产品? 是 √否 (包括总成零件、半成品、供方零件和原材料)"); + } + } + + Row row26 = sheet.getRow(25); + Cell gcggDate = row26.getCell(0); + if (revision.getDateProperty("hs2_changeDate") != null + && !revision.getDateProperty("hs2_changeDate").equals("") + && (revision.getStringProperty("hs2_PZYJ") == null + || revision.getStringProperty("hs2_PZYJ").equals(""))) { + + gcggDate.setCellValue("工程更改申请时间:" + format.format(revision.getDateProperty("hs2_changeDate")) + + " 批准意见"); + } + if (revision.getDateProperty("hs2_changeDate") == null && (revision.getStringProperty("hs2_appview") != null + && !revision.getStringProperty("hs2_appview").equals(""))) { + gcggDate.setCellValue("工程更改申请时间: 批准意见:" + + revision.getStringProperty("hs2_appview")); + } + + if (revision.getDateProperty("hs2_changeDate") != null + && !revision.getDateProperty("hs2_changeDate").equals("") + && (revision.getStringProperty("hs2_appview") != null + && !revision.getStringProperty("hs2_appview").equals(""))) { + gcggDate.setCellValue("工程更改申请时间:" + format.format(revision.getDateProperty("hs2_changeDate")) + + " 批准意见:" + revision.getStringProperty("hs2_appview")); + } + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + ; + + try { + fis.close(); + wb.write(out); + out.flush(); + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + +// public static Workbook create(InputStream in) throws IOException, InvalidFormatException { +// if (!in.markSupported()) { +// in = new PushbackInputStream(in, 8); +// } +// if (POIFSFileSystem.hasPOIFSHeader(in)) { +// return new HSSFWorkbook(in); +// } +// if (POIXMLDocument.hasOOXMLHeader(in)) { +// return new XSSFWorkbook(OPCPackage.open(in)); +// } +// throw new IllegalArgumentException("你的excel版本目前poi解析不了"); +// +// } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/ggtzd/GGTZDAction.java b/src/com/connor/hs2/plm/projectmanage/change/ggtzd/GGTZDAction.java new file mode 100644 index 0000000..2dec3ee --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/ggtzd/GGTZDAction.java @@ -0,0 +1,28 @@ +package com.connor.hs2.plm.projectmanage.change.ggtzd; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +public class GGTZDAction extends AbstractAIFAction{ + private AbstractAIFApplication app; + + public GGTZDAction(AbstractAIFApplication app, String arg1) { + super(app, arg1); + // TODO Auto-generated constructor stub + this.app = app; + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + GGTZDCommad command = new GGTZDCommad(app); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/ggtzd/GGTZDCommad.java b/src/com/connor/hs2/plm/projectmanage/change/ggtzd/GGTZDCommad.java new file mode 100644 index 0000000..b319a81 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/ggtzd/GGTZDCommad.java @@ -0,0 +1,66 @@ +package com.connor.hs2.plm.projectmanage.change.ggtzd; + +import java.util.HashMap; +import java.util.Map; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonOpeartion; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; + +public class GGTZDCommad extends AbstractAIFCommand{ + private AbstractAIFApplication app; + + public GGTZDCommad(AbstractAIFApplication app) { + super(); + this.app = app; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + super.executeModal(); + Map map=new HashMap(); + if (app.getTargetComponent()!=null && (app.getTargetComponent().getType().equals("HS2_GGSQRevision") + || app.getTargetComponent().getType().equals("HS2_GGTZRevision") + || app.getTargetComponent().getType().equals("HS2_KXXFXBGPGRevision") + || app.getTargetComponent().getType().equals("HS2_GGRWDItemRevision") + || app.getTargetComponent().getType().equals("HS2_YZBGItemRevision") + || app.getTargetComponent().getType().equals("HS2_RequestRevision") + || app.getTargetComponent().getType().equals("HS2_NoticeRevision") + || app.getTargetComponent().getType().equals("HS2_FeasibilityARevision") + || app.getTargetComponent().getType().equals("HS2_ChangeTaskRevision") + || app.getTargetComponent().getType().equals("HS2_VerifyRevision") + )) { + TCComponentItemRevision target = (TCComponentItemRevision) app.getTargetComponent(); + String id = target.getProperty("item_id"); + String name = target.getProperty("object_name"); + map.put("item_id", id); + map.put("object_name", name); + String name1; + TCProperty[] allTCProperties = target.getAllTCProperties(); + for (int i = 0; i < allTCProperties.length; i++) { + TCProperty tcProperty = allTCProperties[i]; + name1 = tcProperty.getPropertyName(); + + if (name1.startsWith("hs2_")) { + map.put(name1, tcProperty.getPropertyValue()); + } + + if (name1.equals("hs2_productstage")) { + map.put(name1, tcProperty.getDisplayValue()); + } + if (name1.equals("hs2_stock")) { + map.put(name1, tcProperty.getBoolValue()); + } + } + } + GGTZDDialog dialog = new GGTZDDialog(app,map); + new Thread(dialog).start(); + + } + + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/ggtzd/GGTZDDialog.java b/src/com/connor/hs2/plm/projectmanage/change/ggtzd/GGTZDDialog.java new file mode 100644 index 0000000..ce11650 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/ggtzd/GGTZDDialog.java @@ -0,0 +1,634 @@ +package com.connor.hs2.plm.projectmanage.change.ggtzd; + +import java.awt.BorderLayout; +import java.awt.Dimension; +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.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.ScrollPaneConstants; + +import org.jdesktop.swingx.JXDatePicker; + +import com.connor.hs2.plm.projectmanage.utils.LovUtils; +import com.connor.hs2.plm.projectmanage.utils.SXXUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +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.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class GGTZDDialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private JTextField idText; + private JButton idButton; + private TCComponentItemType type; + private JTextField nameText; + // private JButton nameButton; + private JTextField zccpmcText; + private JTextField zccpljhText; + private JTextField ggljmcText; + private JTextField ggljhText; +// private JTextField sqbmText; + private JTextField khgghText; + private JTextField sqrText; + private JXDatePicker ggssDatePicker; + private JTextField khmcText; + private JTextField ggyyText; + private JComboBox ggqcpzt; + private JRadioButton yesStock; + private JRadioButton noStock; + private ButtonGroup stockGroup; + + private JTextField zckcText; + private JTextField bcpkcText; + private JTextField gfljkckcText; + private JTextField gfyclkcText; + private JTextField kctsText; + private JButton createButton; + private JButton cancelButton; + private JButton modifyButton; + private Map propertyMap; + + public GGTZDDialog(AbstractAIFApplication app, Map map) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + this.propertyMap = map; + } + + @Override + public void run() { + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void init() throws TCException { + // System.out.println("ggtzd----init"); + JPanel rootPanel = new JPanel(new PropertyLayout()); + + JPanel propertyPanel = new JPanel(new PropertyLayout()); + // propertyPanel.setSize(new Dimension(400,450)); + // propertyPanel.setPreferredSize(new Dimension(500,650)); + JPanel buttomPanel = new JPanel(new PropertyLayout()); + type = (TCComponentItemType) session.getTypeComponent("HS2_Notice"); + String hs2_GGQCPZT = (propertyMap.get("hs2_productstage") == null) ? "" + : (String) propertyMap.get("hs2_productstage"); + JLabel lable1 = new JLabel("ID:"); + idText = new JTextField(13); + if (propertyMap.get("item_id") != null && !propertyMap.get("item_id").equals("")) { + idText.setText((String) propertyMap.get("item_id")); + } else { + idText.setText(type.getNewID()); + } + idButton = new JButton("指派"); + idButton.addActionListener(this); + + JLabel lable2 = new JLabel("名称:"); + nameText = new JTextField(13); + // nameButton = new JButton("指派"); + if (propertyMap.get("object_name") != null && !propertyMap.get("object_name").equals("")) { + nameText.setText((String) propertyMap.get("object_name")); + } else { + nameText.setText("更改通知单"); + } + + if (app.getTargetComponent() != null && !app.getTargetComponent().getType().equals("HS2_NoticeRevision")) { + // 对象不一样 id设为空 名称默认 + System.out.println("对象类型不一致"); + System.out.println("type.getNewID()=" + type.getNewID()); + idText.setText(type.getNewID()); + nameText.setText("更改通知单"); + } + JLabel lable3 = new JLabel("总成产品名称:"); + zccpmcText = new JTextField(13); + if (propertyMap.get("hs2_assemblyproname") != null && !propertyMap.get("hs2_assemblyproname").equals("")) { + zccpmcText.setText((String) propertyMap.get("hs2_assemblyproname")); + } + // rootPanel.add("2.3.left.top",nameButton); + JLabel lable4 = new JLabel("总成产品零件号:"); + zccpljhText = new JTextField(13); + if (propertyMap.get("hs2_assemblypartname") != null && !propertyMap.get("hs2_assemblypartname").equals("")) { + zccpljhText.setText((String) propertyMap.get("hs2_assemblypartname")); + } + JLabel lable5 = new JLabel("更改零件名称:"); + ggljmcText = new JTextField(13); + if (propertyMap.get("hs2_changepartname") != null && !propertyMap.get("hs2_changepartname").equals("")) { + ggljmcText.setText((String) propertyMap.get("hs2_changepartname")); + } + JLabel lable6 = new JLabel("更改零件号:"); + ggljhText = new JTextField(13); + if (propertyMap.get("hs2_changepartnumber") != null && !propertyMap.get("hs2_changepartnumber").equals("")) { + ggljhText.setText((String) propertyMap.get("hs2_changepartnumber")); + } + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + JLabel lable7 = new JLabel("更改实施日期:"); + ggssDatePicker = new JXDatePicker(); + ggssDatePicker.setFormats(format); + if (propertyMap.get("hs2_implementation") != null && !propertyMap.get("hs2_implementation").equals("")) { + ggssDatePicker.setDate((Date) propertyMap.get("hs2_implementation")); + } + JLabel lable8 = new JLabel("客户更改号:"); + khgghText = new JTextField(13); + if (propertyMap.get("hs2_customernumber") != null && !propertyMap.get("hs2_customernumber").equals("")) { + khgghText.setText((String) propertyMap.get("hs2_customernumber")); + } + JLabel lable9 = new JLabel("客户名称:"); + khmcText = new JTextField(13); + if (propertyMap.get("hs2_customername") != null && !propertyMap.get("hs2_customername").equals("")) { + khmcText.setText((String) propertyMap.get("hs2_customername")); + } + JLabel lable10 = new JLabel("申请人/发起人:"); + sqrText = new JTextField(13); + if (propertyMap.get("hs2_applicant") != null && !propertyMap.get("hs2_applicant").equals("")) { + sqrText.setText((String) propertyMap.get("hs2_applicant")); + } + + JLabel lable11 = new JLabel("更改原因:"); + ggyyText = new JTextField(13); + if (propertyMap.get("hs2_reasonchange") != null && !propertyMap.get("hs2_reasonchange").equals("")) { + ggyyText.setText((String) propertyMap.get("hs2_reasonchange")); + } + JLabel lable12 = new JLabel("是否有库存产品:"); + stockGroup = new ButtonGroup(); + yesStock = new JRadioButton("是"); + noStock = new JRadioButton("否"); + if (propertyMap.get("hs2_stock") != null) { + boolean sfykc = (boolean) propertyMap.get("hs2_stock"); + if (sfykc == true) { + yesStock.setSelected(true); + } + if (sfykc == false) { + noStock.setSelected(true); + } + } + stockGroup.add(yesStock); + stockGroup.add(noStock); + + JLabel lable13 = new JLabel("更改前产品状态:"); + ggqcpzt = new JComboBox(); + LovUtils.addLovToBox("HS2_ProductStage", ggqcpzt); + ggqcpzt.setSelectedIndex(-1); + for (int i = 0; i < ggqcpzt.getItemCount(); i++) { + if (ggqcpzt.getItemAt(i).equals(hs2_GGQCPZT)) { + ggqcpzt.setSelectedIndex(i); + } + } + JLabel lable14 = new JLabel("涉及总成的库存数量:"); + zckcText = new JTextField(13); + if (propertyMap.get("hs2_assembliesnum") != null && !propertyMap.get("hs2_assembliesnum").equals("")) { + zckcText.setText((String) propertyMap.get("hs2_assembliesnum")); + } + JLabel lable15 = new JLabel("涉及半成品的库存数量:"); + bcpkcText = new JTextField(13); + if (propertyMap.get("hs2_halfproductnum") != null && !propertyMap.get("hs2_halfproductnum").equals("")) { + bcpkcText.setText((String) propertyMap.get("hs2_halfproductnum")); + } + JLabel lable16 = new JLabel("涉及供方零件的库存数量:"); + gfljkckcText = new JTextField(13); + if (propertyMap.get("hs2_partnumber") != null && !propertyMap.get("hs2_partnumber").equals("")) { + gfljkckcText.setText((String) propertyMap.get("hs2_partnumber")); + } + JLabel lable17 = new JLabel("涉及供方原材料的库存数量:"); + gfyclkcText = new JTextField(13); + if (propertyMap.get("hs2_materialsnum") != null && !propertyMap.get("hs2_materialsnum").equals("")) { + gfyclkcText.setText((String) propertyMap.get("hs2_materialsnum")); + } + JLabel lable18 = new JLabel("库存数量估计消耗天数:"); + kctsText = new JTextField(13); + if (propertyMap.get("hs2_consumptionday") != null && !propertyMap.get("hs2_consumptionday").equals("")) { + kctsText.setText((String) propertyMap.get("hs2_consumptionday")); + } + propertyPanel.add("1.1.left.top", lable1); + propertyPanel.add("1.2.left.top", idText); + propertyPanel.add("1.3.left.top", idButton); + propertyPanel.add("2.1.left.top", lable2); + propertyPanel.add("2.2.left.top", nameText); + propertyPanel.add("3.1.left.top", lable3); + propertyPanel.add("3.2.left.top", zccpmcText); + propertyPanel.add("4.1.left.top", lable4); + propertyPanel.add("4.2.left.top", zccpljhText); + propertyPanel.add("5.1.left.top", lable5); + propertyPanel.add("5.2.left.top", ggljmcText); + propertyPanel.add("6.1.left.top", lable6); + propertyPanel.add("6.2.left.top", ggljhText); + propertyPanel.add("7.1.left.top", lable7); + propertyPanel.add("7.2.left.top", ggssDatePicker); + propertyPanel.add("8.1.left.top", lable8); + propertyPanel.add("8.2.left.top", khgghText); + propertyPanel.add("9.1.left.top", lable9); + propertyPanel.add("9.2.left.top", khmcText); + propertyPanel.add("10.1.left.top", lable10); + propertyPanel.add("10.2.left.top", sqrText); + propertyPanel.add("11.1.left.top", lable11); + propertyPanel.add("11.2.left.top", ggyyText); + propertyPanel.add("12.1.left.top", lable12); + propertyPanel.add("12.2.left.top", yesStock); + propertyPanel.add("12.3.left.top", noStock); + propertyPanel.add("13.1.left.top", lable13); + propertyPanel.add("13.2.left.top", ggqcpzt); + propertyPanel.add("14.1.left.top", lable14); + propertyPanel.add("14.2.left.top", zckcText); + propertyPanel.add("15.1.left.top", lable15); + propertyPanel.add("15.2.left.top", bcpkcText); + propertyPanel.add("16.1.left.top", lable16); + propertyPanel.add("16.2.left.top", gfljkckcText); + propertyPanel.add("17.1.left.top", lable17); + propertyPanel.add("17.2.left.top", gfyclkcText); + propertyPanel.add("18.1.left.top", lable18); + propertyPanel.add("18.2.left.top", kctsText); + + createButton = new JButton("创建"); + cancelButton = new JButton("取消"); + modifyButton = new JButton("修改"); + if (app.getTargetComponent() != null && app.getTargetComponent().getType().equals("HS2_NoticeRevision")) { + modifyButton.setEnabled(true); + } else { + modifyButton.setEnabled(false); + } + createButton.addActionListener(this); + cancelButton.addActionListener(this); + modifyButton.addActionListener(this); + buttomPanel.add("1.1.center.left", createButton); + buttomPanel.add("1.2.center.left", modifyButton); + buttomPanel.add("1.3.center.left", cancelButton); + + JScrollPane propertyPane = new JScrollPane(propertyPanel); + propertyPane.setPreferredSize(new Dimension(480, 520)); + // propertyPane.add(propertyPanel); + propertyPane.setBorder(null); + + propertyPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + // propertyPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + rootPanel.add("1.1.left.top", propertyPane); + rootPanel.add("2.1.center.left", buttomPanel); + this.setTitle("更改通知单"); + this.setLayout(new BorderLayout(10, 0)); + this.setPreferredSize(new Dimension(520, 590)); + // panel.add(panel1, BorderLayout.WEST); + // panel.add(panel6, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.CENTER); + this.pack(); + this.setVisible(true); + this.setLocationRelativeTo(null); + this.setResizable(false);// 不可变动窗口大小 + + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if (e.getSource().equals(idButton)) { + try { + String id = type.getNewID(); + this.idText.setText(id); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else if (e.getSource().equals(cancelButton)) { + this.dispose(); + } else if (e.getSource().equals(createButton)) { + // this.dispose(); + try { + if (idText.getText().trim().equals("") || nameText.getText().trim().equals("")) { + MessageBox.post("请填写ID和名称!!", "提示", 2); + return; + } + + String id = idText.getText(); + String name = nameText.getText(); + + if (type.find(id) != null) { + MessageBox.post("ID重复,请重新输入!!", "提示", 2); + return; + } + File file = SXXUtil.getSXX(session, "HS2_NoticeRevision"); + if (file == null) { + return; + } + + String newRev = type.getNewRev(null); + TCComponentItem item = type.create(id, newRev, "HS2_Notice", name, "", null); + if (item != null) { + TCComponentItemRevision revision = item.getLatestItemRevision(); + Map propMap = new HashMap(); + if (nameText.getText().toString().length() != 0) { + propMap.put("object_name", nameText.getText().toString()); + } + if (zccpmcText.getText().toString().length() != 0) { + propMap.put("hs2_assemblyproname", zccpmcText.getText().toString()); + } + if (zccpljhText.getText().toString().length() != 0) { + propMap.put("hs2_assemblypartname", zccpljhText.getText().toString()); + } + if (ggljmcText.getText().toString().length() != 0) { + propMap.put("hs2_changepartname", ggljmcText.getText().toString()); + } + if (ggljhText.getText().toString().length() != 0) { + propMap.put("hs2_changepartnumber", ggljhText.getText().toString()); + } + if (sqrText.getText().toString().length() != 0) { + propMap.put("hs2_applicant", sqrText.getText().toString()); + } + if (khmcText.getText().toString().length() != 0) { + propMap.put("hs2_customername", khmcText.getText().toString()); + } + if (ggyyText.getText().toString().length() != 0) { + propMap.put("hs2_reasonchange", ggyyText.getText().toString()); + } + if (khgghText.getText().toString().length() != 0) { + propMap.put("hs2_customernumber", khgghText.getText().toString()); + } + if (zckcText.getText().toString().length() != 0) { + propMap.put("hs2_assembliesnum", zckcText.getText().toString()); + } + if (bcpkcText.getText().toString().length() != 0) { + propMap.put("hs2_halfproductnum", bcpkcText.getText().toString()); + } + if (gfljkckcText.getText().toString().length() != 0) { + propMap.put("hs2_partnumber", gfljkckcText.getText().toString()); + } + if (gfyclkcText.getText().toString().length() != 0) { + propMap.put("hs2_materialsnum", gfyclkcText.getText().toString()); + } + if (kctsText.getText().toString().length() != 0) { + propMap.put("hs2_consumptionday", kctsText.getText().toString()); + } + // System.out.println("map="+propMap); + revision.setProperties(propMap); + if (ggssDatePicker.getDate() != null) { + revision.setDateProperty("hs2_implementation", ggssDatePicker.getDate()); + } + if (ggqcpzt.getSelectedItem() != null && ggqcpzt.getSelectedItem().toString().length() != 0) { + // System.out.println("设置更改意愿"); + System.out.println("ggqcpzt=" + revision.getTCProperty("hs2_productstage")); + LovUtils.setLovProperty(revision, "hs2_productstage", ggqcpzt.getSelectedItem().toString()); + } + + if (yesStock.isSelected()) { + // System.out.println("设置是否有库存"); + revision.setLogicalProperty("hs2_stock", true); + } else if (noStock.isSelected()) { + revision.setLogicalProperty("hs2_stock", false); + } + String absolutePath = file.getAbsolutePath(); + int num = absolutePath.lastIndexOf("."); + String temp = absolutePath.substring(0, num); + temp = temp + "导出.xlsx"; +// String substring = absolutePath.substring(0, absolutePath.lastIndexOf("\\")); +// String pathString = substring + "\\" + titleName + ".xlsx"; + File outFile = new File(temp); + if (outFile.exists()) { + outFile.delete(); + System.out.println("删除temp成功"); + } + POIExcel poiExcel = new POIExcel(); + poiExcel.writerExcel(file, revision, temp); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("MSExcelX"); + TCComponentDataset dataset = datasetType.create("工程更改通知单", "", "MSExcelX"); + String[] as1 = new String[] { temp }; + String[] as2 = new String[] { "excel" }; + dataset.setFiles(as1, as2); + revision.add("IMAN_specification", dataset); + // docRevision.add("IMAN_specification ", dataset); + + File f = new File(absolutePath); + if (f.exists() && f.isFile()) { + f.delete(); + System.out.println("删除成功"); + } + + if (outFile.exists() && outFile.isFile()) { + + outFile.delete(); + System.out.println("删除成功"); + } + + if (app.getTargetComponent() != null + && app.getTargetComponent().getType().equals("ProjectSmartFolder")) { + TCComponent ref = ((TCComponent) app.getTargetComponent()) + .getReferenceProperty("owning_project"); + if (ref != null) { + TCComponentProject pro = (TCComponentProject) ref; + pro.assignToProject(new TCComponent[] { item }); + } + } else if (app.getTargetComponent() != null + && app.getTargetComponent() instanceof TCComponentFolder) { + ((TCComponentFolder) app.getTargetComponent()).add("contents", item); + } else if (app.getTargetComponent() != null + && app.getTargetComponent() instanceof TCComponentProject) { + TCComponentProject pro = (TCComponentProject) app.getTargetComponent(); + pro.assignToProject(new TCComponent[] { item }); + } else { + session.getUser().getNewStuffFolder().add("contents", item); + } + + // 添加关系 + if (app.getTargetComponent() != null + && !app.getTargetComponent().getType().equals(revision.getType())) { + // 选中对象不为空 并且类型不一样 添加到对应的关系 + // 选中更改申请版本 创建更改风险单 添加关系 + if (app.getTargetComponent().getType().equals("HS2_RequestRevision")) { + System.out.println("选中更改申请版本 创建更改通知单"); + TCComponentItemRevision targetRevision = (TCComponentItemRevision) app.getTargetComponent(); + targetRevision.add("HS2_NoticeForm", item); + item.getLatestItemRevision().add("HS2_ChangeForm", targetRevision.getItem()); + } + } + + // 如果选中的对象版本被指派到项目 那么创建出来的也要指派到项目 + if (app.getTargetComponent() != null && (app.getTargetComponent() instanceof TCComponentItemRevision + || app.getTargetComponent() instanceof TCComponentItem)) { + System.out.println("判断是否被指派到项目"); + TCComponent[] refs = ((TCComponent) app.getTargetComponent()) + .getReferenceListProperty("project_list"); + // System.out.println("ref="+refs); + if (refs != null && refs.length > 0) { + for (TCComponent component : refs) { + TCComponentProject project = (TCComponentProject) component; + project.assignToProject(new TCComponent[] { item }); + } + } + } + MessageBox.post("创建成功!!", "提示", 2); + this.dispose(); + } else { + MessageBox.post("创建失败,请联系管理员!!", "提示", 2); + } + } catch (Exception e1) { + // TODO: handle exception + e1.printStackTrace(); + } + } else if (e.getSource().equals(modifyButton)) { + // 设置属性 + if (app.getTargetComponent() == null) { + MessageBox.post("请选中变更申请单版本进行修改!!", "提示", 2); + return; + } +// if (!app.getTargetComponent().getType().equals("HS2_GGSQRevision")) { +// MessageBox.post("请选中变更申请单版本进行修改!!","提示",2); +// return ; +// } + + try { + + TCComponentItemRevision revision = (TCComponentItemRevision) app.getTargetComponent(); + if (!idText.getText().trim().equals(revision.getProperty("item_id"))) { + MessageBox.post("ID不允许修改!!", "提示", 2); + return; + } + + Map propMap = new HashMap(); + if (nameText.getText().toString().length() != 0) { + propMap.put("object_name", nameText.getText().toString()); + } + if (zccpmcText.getText().toString().length() != 0) { + propMap.put("hs2_assemblyproname", zccpmcText.getText().toString()); + } + if (zccpljhText.getText().toString().length() != 0) { + propMap.put("hs2_assemblypartname", zccpljhText.getText().toString()); + } + if (ggljmcText.getText().toString().length() != 0) { + propMap.put("hs2_changepartname", ggljmcText.getText().toString()); + } + if (ggljhText.getText().toString().length() != 0) { + propMap.put("hs2_changepartnumber", ggljhText.getText().toString()); + } + if (sqrText.getText().toString().length() != 0) { + propMap.put("hs2_applicant", sqrText.getText().toString()); + } + if (khmcText.getText().toString().length() != 0) { + propMap.put("hs2_customername", khmcText.getText().toString()); + } + if (ggyyText.getText().toString().length() != 0) { + propMap.put("hs2_reasonchange", ggyyText.getText().toString()); + } + if (khgghText.getText().toString().length() != 0) { + propMap.put("hs2_customernumber", khgghText.getText().toString()); + } + if (zckcText.getText().toString().length() != 0) { + propMap.put("hs2_assembliesnum", zckcText.getText().toString()); + } + if (bcpkcText.getText().toString().length() != 0) { + propMap.put("hs2_halfproductnum", bcpkcText.getText().toString()); + } + if (gfljkckcText.getText().toString().length() != 0) { + propMap.put("hs2_partnumber", gfljkckcText.getText().toString()); + } + if (gfyclkcText.getText().toString().length() != 0) { + propMap.put("hs2_materialsnum", gfyclkcText.getText().toString()); + } + if (kctsText.getText().toString().length() != 0) { + propMap.put("hs2_consumptionday", kctsText.getText().toString()); + } + // System.out.println("map="+propMap); + revision.setProperties(propMap); + revision.getItem().setProperty("object_name", nameText.getText()); + if (ggssDatePicker.getDate() != null) { + revision.setDateProperty("hs2_implementation", ggssDatePicker.getDate()); + } + if (ggqcpzt.getSelectedItem() != null && ggqcpzt.getSelectedItem().toString().length() != 0) { + LovUtils.setLovProperty(revision, "hs2_productstage", ggqcpzt.getSelectedItem().toString()); + } + + if (yesStock.isSelected()) { + // System.out.println("设置是否有库存"); + revision.setLogicalProperty("hs2_stock", true); + } else if (noStock.isSelected()) { + revision.setLogicalProperty("hs2_stock", false); + } + + // 写入excel + TCComponent[] referenceListProperty = revision.getReferenceListProperty("IMAN_specification"); + // 移除之前的数据集 + for (TCComponent attche : referenceListProperty) { + if (attche instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) attche; +// System.out.println("dateset.type="+dataset.getType()); +// System.out.println("dataset.name="+dataset.getProperty("object_name")); + + if (dataset.getType().equals("MSExcelX") + && dataset.getProperty("object_name").equals("工程更改通知单")) { + System.out.println("移除更改通知单"); + revision.remove("IMAN_specification", dataset); + } + } + } + + // 创建数据集 + File file = SXXUtil.getSXX(session, "HS2_NoticeRevision"); + if (file == null) { + return; + } + String absolutePath = file.getAbsolutePath(); + int num = absolutePath.lastIndexOf("."); + String temp = absolutePath.substring(0, num); + temp = temp + "导出.xlsx"; +// String substring = absolutePath.substring(0, absolutePath.lastIndexOf("\\")); +// String pathString = substring + "\\" + titleName + ".xlsx"; + File outFile = new File(temp); + if (outFile.exists()) { + outFile.delete(); + System.out.println("删除temp成功"); + } + POIExcel poiExcel = new POIExcel(); + poiExcel.writerExcel(file, revision, temp); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("MSExcelX"); + TCComponentDataset dataset = datasetType.create("工程更改通知单", "", "MSExcelX"); + String[] as1 = new String[] { temp }; + String[] as2 = new String[] { "excel" }; + dataset.setFiles(as1, as2); + revision.add("IMAN_specification", dataset); + // docRevision.add("IMAN_specification ", dataset); + + File f = new File(absolutePath); + if (f.exists() && f.isFile()) { + f.delete(); + System.out.println("删除成功"); + } + + if (outFile.exists() && outFile.isFile()) { + + outFile.delete(); + System.out.println("删除成功"); + } + MessageBox.post("修改成功!!", "提示", 2); + this.dispose(); + } catch (Exception e2) { + // TODO: handle exception + MessageBox.post("修改失败,请联系管理员!!", "提示", 2); + e2.printStackTrace(); + } + + } + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/ggtzd/GGTZDHandler.java b/src/com/connor/hs2/plm/projectmanage/change/ggtzd/GGTZDHandler.java new file mode 100644 index 0000000..0ec91df --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/ggtzd/GGTZDHandler.java @@ -0,0 +1,28 @@ +package com.connor.hs2.plm.projectmanage.change.ggtzd; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonAction; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class GGTZDHandler extends AbstractHandler{ + + private TCSession session ; + private TCComponentScheduleTask schedule; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + GGTZDAction action = new GGTZDAction(app, null); + new Thread(action).start(); + return null; + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/ggtzd/POIExcel.java b/src/com/connor/hs2/plm/projectmanage/change/ggtzd/POIExcel.java new file mode 100644 index 0000000..ff3ee32 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/ggtzd/POIExcel.java @@ -0,0 +1,149 @@ +package com.connor.hs2.plm.projectmanage.change.ggtzd; + +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 org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; + +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; + +/* + * POI写入Excel + * */ +public class POIExcel { + + /* + * Excel写操作 + */ + public void writerExcel(File file, TCComponentItemRevision revision, String outPath) { + // TODO Auto-generated method stub + // 文件流的初始化 + Workbook wb = null; + FileInputStream fis = null; + FileOutputStream out = null; + try { + fis = new FileInputStream(file); + wb = WorkbookFactory.create(fis); + File exportFile = new File(outPath); + if (!exportFile.exists()) { + exportFile.createNewFile(); + } + out = new FileOutputStream(exportFile); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + Sheet sheet = wb.getSheetAt(0); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + // 第三行 + +// Cell cpxhCell = row0.getCell(43); +// Cell cpjhCell = row0.getCell(60); + try { + Row row4 = sheet.getRow(3); + row4.getCell(4).setCellValue(revision.getProperty("hs2_assemblyproname")); + row4.getCell(17).setCellValue(revision.getProperty("hs2_assemblypartname")); + + Row row5 = sheet.getRow(4); + row5.getCell(4).setCellValue(revision.getProperty("hs2_changepartname")); + row5.getCell(17).setCellValue(revision.getProperty("hs2_changepartnumber")); + + Row row6 = sheet.getRow(5); + if (revision.getProperty("hs2_implementation") != null + && !revision.getProperty("hs2_implementation").equals("")) { + row6.getCell(4).setCellValue(format.format(revision.getDateProperty("hs2_implementation"))); + } + row6.getCell(17).setCellValue(revision.getProperty("hs2_customernumber")); + + Row row7 = sheet.getRow(6); + row7.getCell(4).setCellValue(revision.getProperty("hs2_customername")); + row7.getCell(17).setCellValue(revision.getProperty("hs2_applicant")); + + Row row8 = sheet.getRow(7); + Cell ggyyCell = row8.getCell(4); + ggyyCell.setCellValue(revision.getProperty("hs2_reasonchange")); + + Row row16 = sheet.getRow(15); + Cell stockCell = row16.getCell(0); + if (revision.getProperty("hs2_stock") != null) { + if (revision.getLogicalProperty("hs2_stock")) { + stockCell.setCellValue("是否有库存产品? √是 否 (包括总成零件、半成品、供方零件和原材料)"); + } else { + stockCell.setCellValue("是否有库存产品? 是 √否 (包括总成零件、半成品、供方零件和原材料)"); + } + } + + Row row18 = sheet.getRow(17); + Cell zcsyCell = row18.getCell(0); + Cell bhgCell = row18.getCell(15); + System.out.println("hs2_productstage=" + revision.getProperty("hs2_productstage")); + if (revision.getProperty("hs2_productstage") != null) { + if (revision.getProperty("hs2_productstage").equals("A") + || revision.getProperty("hs2_productstage").contains("正常")) { + zcsyCell.setCellValue("√ 正常使用"); + } else if (revision.getProperty("hs2_productstage").equals("B") + || revision.getProperty("hs2_productstage").contains("不合格")) { + bhgCell.setCellValue("√ 按不合格品处理"); + } + } + + Row row19 = sheet.getRow(18); + row19.getCell(15).setCellValue(revision.getProperty("hs2_assembliesnum")); + + Row row20 = sheet.getRow(19); + row20.getCell(15).setCellValue(revision.getProperty("hs2_halfproductnum")); + ; + + Row row21 = sheet.getRow(20); + row21.getCell(15).setCellValue(revision.getProperty("hs2_partnumber")); + ; + + Row row22 = sheet.getRow(21); + row22.getCell(15).setCellValue(revision.getProperty("hs2_materialsnum")); + ; + + Row row23 = sheet.getRow(22); + row23.getCell(15).setCellValue(revision.getProperty("hs2_consumptionday")); + ; + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + ; + + try { + fis.close(); + wb.write(out); + out.flush(); + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + +// public static Workbook create(InputStream in) throws IOException, InvalidFormatException { +// if (!in.markSupported()) { +// in = new PushbackInputStream(in, 8); +// } +// if (POIFSFileSystem.hasPOIFSHeader(in)) { +// return new HSSFWorkbook(in); +// } +// if (POIXMLDocument.hasOOXMLHeader(in)) { +// return new XSSFWorkbook(OPCPackage.open(in)); +// } +// throw new IllegalArgumentException("你的excel版本目前poi解析不了"); +// +// } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/wtd/WTDAction.java b/src/com/connor/hs2/plm/projectmanage/change/wtd/WTDAction.java new file mode 100644 index 0000000..b33fd16 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/wtd/WTDAction.java @@ -0,0 +1,28 @@ +package com.connor.hs2.plm.projectmanage.change.wtd; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +public class WTDAction extends AbstractAIFAction{ + private AbstractAIFApplication app; + + public WTDAction(AbstractAIFApplication app, String arg1) { + super(app, arg1); + // TODO Auto-generated constructor stub + this.app = app; + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + WTDCommad command = new WTDCommad(app); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/wtd/WTDCommad.java b/src/com/connor/hs2/plm/projectmanage/change/wtd/WTDCommad.java new file mode 100644 index 0000000..ab570b9 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/wtd/WTDCommad.java @@ -0,0 +1,54 @@ +package com.connor.hs2.plm.projectmanage.change.wtd; + +import java.util.HashMap; +import java.util.Map; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonOpeartion; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; + +public class WTDCommad extends AbstractAIFCommand{ + private AbstractAIFApplication app; + + public WTDCommad(AbstractAIFApplication app) { + super(); + this.app = app; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + super.executeModal(); + Map map=new HashMap(); + if (app.getTargetComponent()!=null && (app.getTargetComponent().getType().equals("HS2_PRRevision") + )) { + TCComponentItemRevision target = (TCComponentItemRevision) app.getTargetComponent(); + String id = target.getProperty("item_id"); + String name = target.getProperty("object_name"); + map.put("item_id", id); + map.put("object_name", name); + String name1; + TCProperty[] allTCProperties = target.getAllTCProperties(); + for (int i = 0; i < allTCProperties.length; i++) { + TCProperty tcProperty = allTCProperties[i]; + name1 = tcProperty.getPropertyName(); + + if (name1.startsWith("hs2_")) { + map.put(name1, tcProperty.getPropertyValue()); + } + + if (name1.equals("hs2_problemlevel")) { + map.put(name1, tcProperty.getDisplayValue()); + } + } + } + WTDDialog dialog = new WTDDialog(app,map); + new Thread(dialog).start(); + + } + + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/wtd/WTDDialog.java b/src/com/connor/hs2/plm/projectmanage/change/wtd/WTDDialog.java new file mode 100644 index 0000000..db2e146 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/wtd/WTDDialog.java @@ -0,0 +1,490 @@ +package com.connor.hs2.plm.projectmanage.change.wtd; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +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.JTextField; +import javax.swing.ScrollPaneConstants; + +import org.jdesktop.swingx.JXDatePicker; + +import com.connor.hs2.plm.projectmanage.utils.LovUtils; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +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.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class WTDDialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private JTextField idText; + private JButton idButton; + private TCComponentItemType type; + private JTextField nameText; + // private JButton nameButton; + private JTextField wtdText; + private JTextField cxText; + private JTextField tcrText; + private JTextField xmmcText; + + private JTextField gbyyText; + private JTextField zgcsText; + private JTextField fzrText; + private JTextField ztText; + // private JTextField wtdjText; + private JComboBox wtdjBox; + private JXDatePicker mbwcDatePicker; + private JXDatePicker sjwcDatePicker; + private JXDatePicker ksDatePicker; + private JXDatePicker scgxDatePicker; + private JButton createButton; + private JButton cancelButton; + private JButton modifyButton; + private Map propertyMap; + + public WTDDialog(AbstractAIFApplication app, Map map) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + this.propertyMap = map; + } + + @Override + public void run() { + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void init() throws TCException { + // System.out.println("yzbgd----init"); + JPanel rootPanel = new JPanel(new PropertyLayout()); + + JPanel propertyPanel = new JPanel(new PropertyLayout()); + // propertyPanel.setSize(new Dimension(400,450)); + // propertyPanel.setPreferredSize(new Dimension(500,650)); + JPanel buttomPanel = new JPanel(new PropertyLayout()); + type = (TCComponentItemType) session.getTypeComponent("HS2_PR"); + String hs2_wtdj = (propertyMap.get("hs2_problemlevel") == null) ? "" + : (String) propertyMap.get("hs2_problemlevel"); + JLabel lable1 = new JLabel("ID:"); + idText = new JTextField(13); + if (propertyMap.get("item_id") != null && !propertyMap.get("item_id").equals("")) { + idText.setText((String) propertyMap.get("item_id")); + } else { + idText.setText(type.getNewID()); + } + + idButton = new JButton("指派"); + idButton.addActionListener(this); + + JLabel lable2 = new JLabel("名称:"); + nameText = new JTextField(13); + // nameButton = new JButton("指派"); + if (propertyMap.get("object_name") != null && !propertyMap.get("object_name").equals("")) { + nameText.setText((String) propertyMap.get("object_name")); + } else { + nameText.setText("问题报告"); + } + + JLabel lable3 = new JLabel("问题点:"); + wtdText = new JTextField(13); + if (propertyMap.get("hs2_troublespots") != null && !propertyMap.get("hs2_troublespots").equals("")) { + wtdText.setText((String) propertyMap.get("hs2_troublespots")); + } + // rootPanel.add("2.3.left.top",nameButton); + JLabel lable4 = new JLabel("车型:"); + cxText = new JTextField(13); + if (propertyMap.get("hs2_models") != null && !propertyMap.get("hs2_models").equals("")) { + cxText.setText((String) propertyMap.get("hs2_models")); + } + JLabel lable5 = new JLabel("提出人:"); + tcrText = new JTextField(13); + if (propertyMap.get("hs2_introducer") != null && !propertyMap.get("hs2_introducer").equals("")) { + tcrText.setText((String) propertyMap.get("hs2_introducer")); + } + JLabel lable6 = new JLabel("项目名称:"); + xmmcText = new JTextField(13); + if (propertyMap.get("hs2_projectname") != null && !propertyMap.get("hs2_projectname").equals("")) { + xmmcText.setText((String) propertyMap.get("hs2_projectname")); + } + + JLabel lable7 = new JLabel("根本原因:"); + gbyyText = new JTextField(13); + if (propertyMap.get("hs2_rootcause") != null && !propertyMap.get("hs2_rootcause").equals("")) { + gbyyText.setText((String) propertyMap.get("hs2_rootcause")); + } + + JLabel lable8 = new JLabel("整改措施:"); + zgcsText = new JTextField(13); + if (propertyMap.get("hs2_correctiveactions") != null && !propertyMap.get("hs2_correctiveactions").equals("")) { + zgcsText.setText((String) propertyMap.get("hs2_correctiveactions")); + } + + JLabel lable9 = new JLabel("负责人:"); + fzrText = new JTextField(13); + if (propertyMap.get("hs2_head") != null && !propertyMap.get("hs2_head").equals("")) { + fzrText.setText((String) propertyMap.get("hs2_head")); + } + + JLabel lable10 = new JLabel("状态:"); + ztText = new JTextField(13); + if (propertyMap.get("hs2_state") != null && !propertyMap.get("hs2_state").equals("")) { + ztText.setText((String) propertyMap.get("hs2_state")); + } + + JLabel lable11 = new JLabel("问题等级:"); + wtdjBox = new JComboBox(); + LovUtils.addLovToBox("HS2_ProblemLevel_LOV", wtdjBox); + wtdjBox.setSelectedIndex(-1); + for (int i = 0; i < wtdjBox.getItemCount(); i++) { + if (wtdjBox.getItemAt(i).equals(hs2_wtdj)) { + wtdjBox.setSelectedIndex(i); + } + } + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + + JLabel lable12 = new JLabel("开始日期:"); + ksDatePicker = new JXDatePicker(); + ksDatePicker.setFormats(format); + if (propertyMap.get("hs2_startdate") != null && !propertyMap.get("hs2_startdate").equals("")) { + ksDatePicker.setDate((Date) propertyMap.get("hs2_startdate")); + } + JLabel lable13 = new JLabel("目标完成日期:"); + mbwcDatePicker = new JXDatePicker(); + mbwcDatePicker.setFormats(format); + if (propertyMap.get("hs2_targetcompletion") != null && !propertyMap.get("hs2_targetcompletion").equals("")) { + mbwcDatePicker.setDate((Date) propertyMap.get("hs2_targetcompletion")); + } + + JLabel lable14 = new JLabel("实际完成日期:"); + sjwcDatePicker = new JXDatePicker(); + sjwcDatePicker.setFormats(format); + if (propertyMap.get("hs2_actualcompletion") != null && !propertyMap.get("hs2_actualcompletion").equals("")) { + sjwcDatePicker.setDate((Date) propertyMap.get("hs2_actualcompletion")); + } + + JLabel lable15 = new JLabel("上次更新时间:"); + scgxDatePicker = new JXDatePicker(); + scgxDatePicker.setFormats(format); + if (propertyMap.get("hs2_lastupdate") != null && !propertyMap.get("hs2_lastupdate").equals("")) { + scgxDatePicker.setDate((Date) propertyMap.get("hs2_lastupdate")); + } + propertyPanel.add("1.1.left.top", lable1); + propertyPanel.add("1.2.left.top", idText); + propertyPanel.add("1.3.left.top", idButton); + propertyPanel.add("2.1.left.top", lable2); + propertyPanel.add("2.2.left.top", nameText); + propertyPanel.add("3.1.left.top", lable3); + propertyPanel.add("3.2.left.top", wtdText); + propertyPanel.add("4.1.left.top", lable4); + propertyPanel.add("4.2.left.top", cxText); + propertyPanel.add("5.1.left.top", lable5); + propertyPanel.add("5.2.left.top", tcrText); + propertyPanel.add("6.1.left.top", lable6); + propertyPanel.add("6.2.left.top", xmmcText); + propertyPanel.add("7.1.left.top", lable7); + propertyPanel.add("7.2.left.top", gbyyText); + propertyPanel.add("8.1.left.top", lable8); + propertyPanel.add("8.2.left.top", zgcsText); + propertyPanel.add("9.1.left.top", lable9); + propertyPanel.add("9.2.left.top", fzrText); + propertyPanel.add("10.1.left.top", lable10); + propertyPanel.add("10.2.left.top", ztText); + propertyPanel.add("11.1.left.top", lable11); + propertyPanel.add("11.2.left.top", wtdjBox); + propertyPanel.add("12.1.left.top", lable12); + propertyPanel.add("12.2.left.top", ksDatePicker); + propertyPanel.add("13.1.left.top", lable13); + propertyPanel.add("13.2.left.top", mbwcDatePicker); + propertyPanel.add("14.1.left.top", lable14); + propertyPanel.add("14.2.left.top", sjwcDatePicker); + propertyPanel.add("15.1.left.top", lable15); + propertyPanel.add("15.2.left.top", scgxDatePicker); + createButton = new JButton("创建"); + cancelButton = new JButton("取消"); + modifyButton = new JButton("修改"); + // System.out.println("type="+app.getTargetComponent().getType()); + if (app.getTargetComponent() != null && app.getTargetComponent().getType().equals("HS2_PRRevision")) { + modifyButton.setEnabled(true); + } else { + modifyButton.setEnabled(false); + } + createButton.addActionListener(this); + cancelButton.addActionListener(this); + modifyButton.addActionListener(this); + buttomPanel.add("1.1.center.left", createButton); + buttomPanel.add("1.2.center.left", modifyButton); + buttomPanel.add("1.3.center.left", cancelButton); + + JScrollPane propertyPane = new JScrollPane(propertyPanel); + propertyPane.setPreferredSize(new Dimension(480, 500)); + // propertyPane.add(propertyPanel); + propertyPane.setBorder(null); + + propertyPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + // propertyPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + rootPanel.add("1.1.left.top", propertyPane); + rootPanel.add("2.1.center.left", buttomPanel); + this.setTitle("问题点"); + this.setLayout(new BorderLayout(10, 0)); + this.setPreferredSize(new Dimension(520, 570)); + // panel.add(panel1, BorderLayout.WEST); + // panel.add(panel6, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.CENTER); + this.pack(); + this.setVisible(true); + this.setLocationRelativeTo(null); + this.setResizable(false);// 不可变动窗口大小 + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if (e.getSource().equals(idButton)) { + try { + String id = type.getNewID(); + this.idText.setText(id); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else if (e.getSource().equals(cancelButton)) { + this.dispose(); + } else if (e.getSource().equals(createButton)) { + // this.dispose(); + try { + if (idText.getText().trim().equals("") || nameText.getText().trim().equals("")) { + MessageBox.post("请填写ID和名称!!", "提示", 2); + return; + } + + String id = idText.getText(); + String name = nameText.getText(); + + if (type.find(id) != null) { + MessageBox.post("ID重复,请重新输入!!", "提示", 2); + return; + } + + String newRev = type.getNewRev(null); + TCComponentItem item = type.create(id, newRev, "HS2_PR", name, "", null); + if (item != null) { + TCComponentItemRevision revision = item.getLatestItemRevision(); + Map propMap = new HashMap(); + if (nameText.getText().toString().length() != 0) { + propMap.put("object_name", nameText.getText().toString()); + } + if (wtdText.getText().toString().length() != 0) { + propMap.put("hs2_troublespots", wtdText.getText().toString()); + } + if (cxText.getText().toString().length() != 0) { + propMap.put("hs2_models", cxText.getText().toString()); + } + if (tcrText.getText().toString().length() != 0) { + propMap.put("hs2_introducer", tcrText.getText().toString()); + } + if (xmmcText.getText().toString().length() != 0) { + propMap.put("hs2_projectname", xmmcText.getText().toString()); + } + + if (gbyyText.getText().toString().length() != 0) { + propMap.put("hs2_rootcause", gbyyText.getText().toString()); + } + + if (zgcsText.getText().toString().length() != 0) { + propMap.put("hs2_correctiveactions", zgcsText.getText().toString()); + } + + if (fzrText.getText().toString().length() != 0) { + propMap.put("hs2_head", fzrText.getText().toString()); + } + + if (ztText.getText().toString().length() != 0) { + propMap.put("hs2_state", ztText.getText().toString()); + } + +// if (wtdjText.getText().toString().length() != 0) { +// propMap.put("hs2_problemlevel", wtdjText.getText().toString()); +// } + // System.out.println("map="+propMap); + revision.setProperties(propMap); + if (wtdjBox.getSelectedItem() != null && wtdjBox.getSelectedItem().toString().length() != 0) { + LovUtils.setLovProperty(revision, "hs2_problemlevel", wtdjBox.getSelectedItem().toString()); + } + if (ksDatePicker.getDate() != null) { + revision.setDateProperty("hs2_startdate", ksDatePicker.getDate()); + } + if (mbwcDatePicker.getDate() != null) { + revision.setDateProperty("hs2_targetcompletion", mbwcDatePicker.getDate()); + } + if (sjwcDatePicker.getDate() != null) { + revision.setDateProperty("hs2_actualcompletion", sjwcDatePicker.getDate()); + } + + if (scgxDatePicker.getDate() != null) { + revision.setDateProperty("hs2_lastupdate", scgxDatePicker.getDate()); + } + MessageBox.post("创建成功!!", "提示", 2); + if (app.getTargetComponent() != null + && app.getTargetComponent().getType().equals("ProjectSmartFolder")) { + TCComponent ref = ((TCComponent) app.getTargetComponent()) + .getReferenceProperty("owning_project"); + if (ref != null) { + TCComponentProject pro = (TCComponentProject) ref; + pro.assignToProject(new TCComponent[] { item }); + } + } else if (app.getTargetComponent() != null + && app.getTargetComponent() instanceof TCComponentFolder) { + ((TCComponentFolder) app.getTargetComponent()).add("contents", item); + } else if (app.getTargetComponent() != null + && app.getTargetComponent() instanceof TCComponentProject) { + TCComponentProject pro = (TCComponentProject) app.getTargetComponent(); + pro.assignToProject(new TCComponent[] { item }); + } else { + session.getUser().getNewStuffFolder().add("contents", item); + } + + // 添加关系 + if (app.getTargetComponent() != null + && !app.getTargetComponent().getType().equals(revision.getType())) { + // 选中对象不为空 并且类型不一样 添加到对应的关系 + // 选中更改申请版本 创建更改风险单 添加关系 + if (app.getTargetComponent().getType().equals("HS2_RequestRevision")) { + System.out.println("选中更改申请版本 创建问题报告"); + TCComponentItemRevision targetRevision = (TCComponentItemRevision) app.getTargetComponent(); + targetRevision.add("HS2_ProblemReport", item); + item.getLatestItemRevision().add("HS2_ChangeForm", targetRevision.getItem()); + } + } + + // 如果选中的对象版本被指派到项目 那么创建出来的也要指派到项目 + if (app.getTargetComponent() != null && (app.getTargetComponent() instanceof TCComponentItemRevision + || app.getTargetComponent() instanceof TCComponentItem)) { + System.out.println("判断是否被指派到项目"); + TCComponent[] refs = ((TCComponent) app.getTargetComponent()) + .getReferenceListProperty("project_list"); + // System.out.println("ref="+refs); + if (refs != null && refs.length > 0) { + for (TCComponent component : refs) { + TCComponentProject project = (TCComponentProject) component; + project.assignToProject(new TCComponent[] { item }); + } + } + } + } else { + MessageBox.post("创建失败,请联系管理员!!", "提示", 2); + } + this.dispose(); + } catch (Exception e1) { + // TODO: handle exception + e1.printStackTrace(); + this.dispose(); + } + } else if (e.getSource().equals(modifyButton)) { + System.out.println("点击修改按钮-----"); + // 设置属性 + if (app.getTargetComponent() == null) { + MessageBox.post("请选中问题版本进行修改!!", "提示", 2); + return; + } +// if (!app.getTargetComponent().getType().equals("HS2_GGSQRevision")) { +// MessageBox.post("请选中变更申请单版本进行修改!!","提示",2); +// return ; +// } + + try { + + TCComponentItemRevision revision = (TCComponentItemRevision) app.getTargetComponent(); + if (!idText.getText().trim().equals(revision.getProperty("item_id"))) { + MessageBox.post("ID不允许修改!!", "提示", 2); + return; + } + + Map propMap = new HashMap(); + if (nameText.getText().toString().length() != 0) { + propMap.put("object_name", nameText.getText().toString()); + } + if (wtdText.getText().toString().length() != 0) { + propMap.put("hs2_troublespots", wtdText.getText().toString()); + } + if (cxText.getText().toString().length() != 0) { + propMap.put("hs2_models", cxText.getText().toString()); + } + if (tcrText.getText().toString().length() != 0) { + propMap.put("hs2_introducer", tcrText.getText().toString()); + } + if (xmmcText.getText().toString().length() != 0) { + propMap.put("hs2_projectname", xmmcText.getText().toString()); + } + + if (gbyyText.getText().toString().length() != 0) { + propMap.put("hs2_rootcause", gbyyText.getText().toString()); + } + + if (zgcsText.getText().toString().length() != 0) { + propMap.put("hs2_correctiveactions", zgcsText.getText().toString()); + } + + if (fzrText.getText().toString().length() != 0) { + propMap.put("hs2_head", fzrText.getText().toString()); + } + + if (ztText.getText().toString().length() != 0) { + propMap.put("hs2_state", ztText.getText().toString()); + } + + // System.out.println("map="+propMap); + revision.setProperties(propMap); + if (wtdjBox.getSelectedItem() != null && wtdjBox.getSelectedItem().toString().length() != 0) { + LovUtils.setLovProperty(revision, "hs2_problemlevel", wtdjBox.getSelectedItem().toString()); + } + if (ksDatePicker.getDate() != null) { + revision.setDateProperty("hs2_startdate", ksDatePicker.getDate()); + } + if (mbwcDatePicker.getDate() != null) { + revision.setDateProperty("hs2_targetcompletion", mbwcDatePicker.getDate()); + } + if (sjwcDatePicker.getDate() != null) { + revision.setDateProperty("hs2_actualcompletion", sjwcDatePicker.getDate()); + } + + if (scgxDatePicker.getDate() != null) { + revision.setDateProperty("hs2_lastupdate", scgxDatePicker.getDate()); + } + + MessageBox.post("修改成功!!", "提示", 2); + this.dispose(); + } catch (Exception e2) { + // TODO: handle exception + MessageBox.post("修改失败,请联系管理员!!", "提示", 2); + this.dispose(); + e2.printStackTrace(); + } + + } + } +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/wtd/WTDHandler.java b/src/com/connor/hs2/plm/projectmanage/change/wtd/WTDHandler.java new file mode 100644 index 0000000..f341e8f --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/wtd/WTDHandler.java @@ -0,0 +1,28 @@ +package com.connor.hs2.plm.projectmanage.change.wtd; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonAction; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class WTDHandler extends AbstractHandler{ + + private TCSession session ; + private TCComponentScheduleTask schedule; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + WTDAction action = new WTDAction(app, null); + new Thread(action).start(); + return null; + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/wthz/ProblemBean.java b/src/com/connor/hs2/plm/projectmanage/change/wthz/ProblemBean.java new file mode 100644 index 0000000..8b8838c --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/wthz/ProblemBean.java @@ -0,0 +1,107 @@ +package com.connor.hs2.plm.projectmanage.change.wthz; + +import java.util.Date; + +public class ProblemBean { + private String wtd; + private String cx; + private String tcr; + private String projectName; + private String gbyy; + private String zgcs; + private String fzr; + private String startDate; + private String mbwcDate; + private String sjwcDate; + private String scwcDate; + private String zt; + private String wtdj; + public String getWtd() { + return wtd; + } + public void setWtd(String wtd) { + this.wtd = wtd; + } + public String getCx() { + return cx; + } + public void setCx(String cx) { + this.cx = cx; + } + public String getTcr() { + return tcr; + } + public void setTcr(String tcr) { + this.tcr = tcr; + } + public String getProjectName() { + return projectName; + } + public void setProjectName(String projectName) { + this.projectName = projectName; + } + public String getGbyy() { + return gbyy; + } + public void setGbyy(String gbyy) { + this.gbyy = gbyy; + } + public String getZgcs() { + return zgcs; + } + public void setZgcs(String zgcs) { + this.zgcs = zgcs; + } + public String getFzr() { + return fzr; + } + public void setFzr(String fzr) { + this.fzr = fzr; + } + public String getStartDate() { + return startDate; + } + public void setStartDate(String startDate) { + this.startDate = startDate; + } + public String getMbwcDate() { + return mbwcDate; + } + public void setMbwcDate(String mbwcDate) { + this.mbwcDate = mbwcDate; + } + public String getSjwcDate() { + return sjwcDate; + } + public void setSjwcDate(String sjwcDate) { + this.sjwcDate = sjwcDate; + } + public String getScwcDate() { + return scwcDate; + } + public void setScwcDate(String scwcDate) { + this.scwcDate = scwcDate; + } + public String getZt() { + return zt; + } + public void setZt(String zt) { + this.zt = zt; + } + public String getWtdj() { + return wtdj; + } + public void setWtdj(String wtdj) { + this.wtdj = wtdj; + } + @Override + public String toString() { + return "ProblemBean [wtd=" + wtd + ", cx=" + cx + ", tcr=" + tcr + ", projectName=" + projectName + ", gbyy=" + + gbyy + ", zgcs=" + zgcs + ", fzr=" + fzr + ", startDate=" + startDate + ", mbwcDate=" + mbwcDate + + ", sjwcDate=" + sjwcDate + ", scwcDate=" + scwcDate + ", zt=" + zt + ", wtdj=" + wtdj + "]"; + } + + + + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/wthz/ProblemPOIExcel.java b/src/com/connor/hs2/plm/projectmanage/change/wthz/ProblemPOIExcel.java new file mode 100644 index 0000000..e4cd5ce --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/wthz/ProblemPOIExcel.java @@ -0,0 +1,255 @@ +package com.connor.hs2.plm.projectmanage.change.wthz; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.List; + +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.Row; + +/* + * POI写入Excel + * */ +public class ProblemPOIExcel { + + /* + * Excel写操作 + */ + public void writerExcel(List wtList, File file, String outPath) { + // TODO Auto-generated method stub + // 文件流的初始化 + HSSFWorkbook wb = null; + FileInputStream fis = null; + FileOutputStream out = null; + try { + fis = new FileInputStream(file); + wb = new HSSFWorkbook(fis); + File exportFile = new File(outPath); + if (!exportFile.exists()) { + exportFile.createNewFile(); + } + out = new FileOutputStream(exportFile); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + // sworkbook = new SXSSFWorkbook(new XSSFWorkbook(fileIn), 100); + HSSFSheet sheet = wb.getSheetAt(0); + sheet.getRow(3).getCell(8).setCellValue(wtList.size()); + sheet.getRow(3).getCell(10).setCellValue(wtList.size()); + if (wtList.size() <= 40) { + writeDirect(wtList, sheet); + } else { + writeShift(wtList, sheet); + } + + try { + fis.close(); + wb.write(out); + out.flush(); + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + +// public static Workbook create(InputStream in) throws IOException, InvalidFormatException { +// if (!in.markSupported()) { +// in = new PushbackInputStream(in, 8); +// } +// if (POIFSFileSystem.hasPOIFSHeader(in)) { +// return new HSSFWorkbook(in); +// } +// if (POIXMLDocument.hasOOXMLHeader(in)) { +// return new XSSFWorkbook(OPCPackage.open(in)); +// } +// throw new IllegalArgumentException("你的excel版本目前poi解析不了"); +// +// } + + private static void writeDirect(List wtList, HSSFSheet sheet) { + for (int i = 0; i < wtList.size(); i++) { + // 从第一行开始写入 + ProblemBean wt = wtList.get(i); + // 创建每个单元格Cell,即列的数据 + Row row = sheet.getRow(i + 6); + if (row == null) { + row = sheet.createRow(i + 6); + } + Cell cell = null; + for (int j = 0; j < 13; j++) { + cell = row.getCell(j); + if (row.getCell(j) == null) { + + cell = row.createCell(j); + // cell.setCellStyle(sheet.getRow(7).getCell(2).getCellStyle()); + } + switch (j) { + case 0: + cell.setCellValue(i + 1 + ""); + break; + case 1: + cell.setCellValue(wt.getWtd()); + break; + case 2: + cell.setCellValue(wt.getCx()); + break; + case 3: + cell.setCellValue(wt.getTcr()); + break; + case 4: + cell.setCellValue(wt.getProjectName()); + break; + case 5: + cell.setCellValue(wt.getGbyy()); + break; + case 6: + cell.setCellValue(wt.getZgcs()); + break; + case 7: + cell.setCellValue(wt.getFzr()); + break; + case 8: + cell.setCellValue(wt.getStartDate()); + break; + case 9: + cell.setCellValue(wt.getMbwcDate()); + break; + case 10: + cell.setCellValue(wt.getSjwcDate()); + break; + case 11: + cell.setCellValue(wt.getScwcDate()); + break; + case 12: + cell.setCellValue(wt.getZt()); + break; + } + } + } + } + + private void writeShift(List wtList, HSSFSheet sheet) { + // TODO Auto-generated method stub + for (int i = 0; i < 40; i++) { + // 从第一行开始写入 + ProblemBean wt = wtList.get(i); + // 创建每个单元格Cell,即列的数据 + Row row = sheet.getRow(i + 6); + if (row == null) { + row = sheet.createRow(i + 6); + } + Cell cell = null; + for (int j = 0; j < 13; j++) { + cell = row.getCell(j); + if (row.getCell(j) == null) { + + cell = row.createCell(j); + // cell.setCellStyle(sheet.getRow(7).getCell(2).getCellStyle()); + } + switch (j) { + case 0: + cell.setCellValue(i + 1 + ""); + break; + case 1: + cell.setCellValue(wt.getWtd()); + break; + case 2: + cell.setCellValue(wt.getCx()); + break; + case 3: + cell.setCellValue(wt.getTcr()); + break; + case 4: + cell.setCellValue(wt.getProjectName()); + break; + case 5: + cell.setCellValue(wt.getGbyy()); + break; + case 6: + cell.setCellValue(wt.getZgcs()); + break; + case 7: + cell.setCellValue(wt.getFzr()); + break; + case 8: + cell.setCellValue(wt.getStartDate()); + break; + case 9: + cell.setCellValue(wt.getMbwcDate()); + break; + case 10: + cell.setCellValue(wt.getSjwcDate()); + break; + case 11: + cell.setCellValue(wt.getScwcDate()); + break; + case 12: + cell.setCellValue(wt.getZt()); + break; + } + } + } + + sheet.shiftRows(46, wtList.size() + 49, wtList.size() - 40); + for (int i = 46; i < wtList.size() + 6; i++) { + ProblemBean wt = wtList.get(i - 6); + + // 创建每个单元格Cell,即列的数据 + Row row = sheet.createRow(i); + Cell cell = null; + for (int j = 0; j < 13; j++) { + cell = row.createCell(j); + switch (j) { + case 0: + cell.setCellValue(i + 1 + ""); + break; + case 1: + cell.setCellValue(wt.getWtd()); + break; + case 2: + cell.setCellValue(wt.getCx()); + break; + case 3: + cell.setCellValue(wt.getTcr()); + break; + case 4: + cell.setCellValue(wt.getProjectName()); + break; + case 5: + cell.setCellValue(wt.getGbyy()); + break; + case 6: + cell.setCellValue(wt.getZgcs()); + break; + case 7: + cell.setCellValue(wt.getFzr()); + break; + case 8: + cell.setCellValue(wt.getStartDate()); + break; + case 9: + cell.setCellValue(wt.getMbwcDate()); + break; + case 10: + cell.setCellValue(wt.getSjwcDate()); + break; + case 11: + cell.setCellValue(wt.getScwcDate()); + break; + case 12: + cell.setCellValue(wt.getZt()); + break; + } + } + } + + } +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/wthz/WTHZAction.java b/src/com/connor/hs2/plm/projectmanage/change/wthz/WTHZAction.java new file mode 100644 index 0000000..2ce9425 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/wthz/WTHZAction.java @@ -0,0 +1,28 @@ +package com.connor.hs2.plm.projectmanage.change.wthz; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +public class WTHZAction extends AbstractAIFAction{ + private AbstractAIFApplication app; + + public WTHZAction(AbstractAIFApplication app, String arg1) { + super(app, arg1); + // TODO Auto-generated constructor stub + this.app = app; + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + WTHZCommad command = new WTHZCommad(app); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/wthz/WTHZCommad.java b/src/com/connor/hs2/plm/projectmanage/change/wthz/WTHZCommad.java new file mode 100644 index 0000000..e1f66f2 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/wthz/WTHZCommad.java @@ -0,0 +1,36 @@ +package com.connor.hs2.plm.projectmanage.change.wthz; + +import java.util.HashMap; +import java.util.Map; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonOpeartion; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class WTHZCommad extends AbstractAIFCommand{ + private AbstractAIFApplication app; + + public WTHZCommad(AbstractAIFApplication app) { + super(); + this.app = app; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + super.executeModal(); + if (app.getTargetComponent()!=null && app.getTargetComponent() instanceof TCComponentProject) { + WTHZDialog dialog = new WTHZDialog(app); + new Thread(dialog).start(); + }else { + MessageBox.post("请选中项目创建问题报告汇总清单","提示",2); + } + } + + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/wthz/WTHZDialog.java b/src/com/connor/hs2/plm/projectmanage/change/wthz/WTHZDialog.java new file mode 100644 index 0000000..6205d3a --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/wthz/WTHZDialog.java @@ -0,0 +1,266 @@ +package com.connor.hs2.plm.projectmanage.change.wthz; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentProject; +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 WTHZDialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private TCComponentItemType type; + private JButton createButton; + private JButton cancelButton; + private JComboBox xmjdBox; + + public WTHZDialog(AbstractAIFApplication app) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + } + + @Override + public void run() { + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void init() throws TCException { + // System.out.println("ggfxd----init"); + JPanel rootPanel = new JPanel(new PropertyLayout()); + rootPanel.setPreferredSize(new Dimension(220, 60)); + JPanel projectStagePanel = new JPanel(new PropertyLayout()); + // projectStagePanel.setPreferredSize(new Dimension(150,30)); + JPanel buttomPanel = new JPanel(new PropertyLayout()); + // buttomPanel.setPreferredSize(new Dimension(150,30)); + type = (TCComponentItemType) session.getTypeComponent("HS2_ProblemDoc"); + + JLabel lable = new JLabel(" 项目阶段:"); + xmjdBox = new JComboBox(); + // LovUtils.addLovToBox("HS2_ProjectStage", xmjdBox); + xmjdBox.addItem("第一阶段"); + xmjdBox.addItem("第二阶段"); + xmjdBox.addItem("第三阶段"); + xmjdBox.addItem("第四阶段"); + xmjdBox.addItem("第五阶段"); + xmjdBox.setSelectedIndex(0); + projectStagePanel.add("1.1.center.right", lable); + projectStagePanel.add("1.2.center.right", xmjdBox); + + createButton = new JButton("创建"); + cancelButton = new JButton("取消"); + + createButton.addActionListener(this); + cancelButton.addActionListener(this); + buttomPanel.add("1.1.center.right", new JLabel(" ")); + buttomPanel.add("1.2.center.right", createButton); + buttomPanel.add("1.3.center.right", cancelButton); + +// rootPanel.add(projectStagePanel,BorderLayout.NORTH); +// rootPanel.add(buttomPanel,BorderLayout.CENTER); + rootPanel.add("1.1.center.right", projectStagePanel); + rootPanel.add("2.1.center.right", buttomPanel); + + this.setTitle("项目问题汇总清单"); + this.setLayout(new BorderLayout(10, 30)); + // this.setPreferredSize(new Dimension(170,100)); + this.setAlwaysOnTop(true); + this.add(rootPanel, BorderLayout.CENTER); + this.pack(); + this.setVisible(true); + this.setLocationRelativeTo(null); + this.setResizable(false);// 不可变动窗口大小 + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + if (e.getSource().equals(cancelButton)) { + this.dispose(); + } else if (e.getSource().equals(createButton)) { + // this.dispose(); + try { + + String xmjd = (String) xmjdBox.getSelectedItem(); + List problems = new ArrayList(); + System.out.println("创建项目问题汇总清单"); + TCComponentProject project = (TCComponentProject) app.getTargetComponent(); + TCComponent[] project_data = project.getReferenceListProperty("project_data"); + for (int i = 0; i < project_data.length; i++) { + // System.out.println("project_data="+project_data[i] + // +"type="+project_data[i].getType()); + // 测试代码文件夹名 客户资料 正式代码改为变更管理 + if (project_data[i].getType().equals("ProjectSmartFolder") + && project_data[i].getProperty("folder_name").equals("变更管理")) { + System.out.println("找到变更管理文件夹"); + TCComponent[] changeAndProblem = project_data[i].getReferenceListProperty("project_data"); + for (int j = 0; j < changeAndProblem.length; j++) { + if (changeAndProblem[j].getType().equals("HS2_PR")) { + System.out.println("pr=" + changeAndProblem[j]); + ProblemBean bean = new ProblemBean(); + TCComponentItem item = (TCComponentItem) changeAndProblem[j]; + TCComponentItemRevision revision = item.getLatestItemRevision(); + String cx = revision.getProperty("hs2_models"); + String fzr = revision.getProperty("hs2_head"); + String wtd = revision.getProperty("hs2_troublespots"); + String tcr = revision.getProperty("hs2_introducer"); + String projectName = revision.getProperty("hs2_projectname"); + String gbyy = revision.getProperty("hs2_rootcause"); + String zgcs = revision.getProperty("hs2_correctiveactions"); + String startDate = revision.getProperty("hs2_startdate"); + String mbwcDate = revision.getProperty("hs2_targetcompletion"); + String sjwcDate = revision.getProperty("hs2_actualcompletion"); + String scwcDate = revision.getProperty("hs2_lastupdate"); + String zt = revision.getProperty("hs2_state"); + String wtdj = revision.getProperty("hs2_problemlevel"); + + bean.setCx(cx); + bean.setFzr(fzr); + bean.setWtd(wtd); + bean.setTcr(tcr); + bean.setProjectName(projectName); + bean.setGbyy(gbyy); + bean.setZgcs(zgcs); + bean.setStartDate(startDate); + bean.setMbwcDate(mbwcDate); + bean.setSjwcDate(sjwcDate); + bean.setScwcDate(scwcDate); + bean.setZt(zt); + bean.setWtdj(wtdj); + problems.add(bean); + // 初始化问题对象 放入list集合 + } + } + } + + } + File file = getSXX(); + if (file == null) { + return; + } + if (problems.size() > 0) { + System.out.println("问题数量大于0,创建汇总对象"); + String id = type.getNewID(); + String name = xmjd + "问题报告汇总清单"; + String newRev = type.getNewRev(null); + TCComponentItem item = type.create(id, newRev, "HS2_ProblemDoc", name, "", null); + writeExcelToRevision(item.getLatestItemRevision(), problems, file); + // session.getUser().getNewStuffFolder().add("contents", item); + project.assignToProject(new TCComponent[] { item }); + project.refresh(); + this.dispose(); + MessageBox.post("创建成功!!", "提示", 2); + } else { + this.setAlwaysOnTop(false); + MessageBox.post("当前项目无问题对象,请查看!!", "提示", 2); + } + + } catch (Exception e1) { + // TODO: handle exception + e1.printStackTrace(); + } + } + } + + private void writeExcelToRevision(TCComponentItemRevision revision, List problems, File file) { + // TODO Auto-generated method stub + try { + String name = xmjdBox.getSelectedItem() + "问题报告汇总清单.xls"; + String absolutePath = file.getAbsolutePath(); +// int num = absolutePath.lastIndexOf("."); + + // temp = temp + ".xls"; + String substring = absolutePath.substring(0, absolutePath.lastIndexOf("\\")); + String temp = substring + "\\" + name; + File outFile = new File(temp); + if (outFile.exists()) { + outFile.delete(); + System.out.println("删除temp成功"); + } + ProblemPOIExcel poiExcel = new ProblemPOIExcel(); + poiExcel.writerExcel(problems, file, temp); + + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("MSExcel"); + TCComponentDataset dataset = datasetType.create(name, "", "MSExcel"); + String[] as1 = new String[] { temp }; + String[] as2 = new String[] { "excel" }; + dataset.setFiles(as1, as2); + revision.add("IMAN_specification", dataset); + + File f = new File(file.getAbsolutePath()); + if (f.exists() && f.isFile()) { + f.delete(); + // System.out.println("删除成功"); + } + + if (outFile.exists() && outFile.isFile()) { + + outFile.delete(); + // System.out.println("删除成功"); + } + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } + + public File getSXX() { + TCPreferenceService pref = session.getPreferenceService(); + // String puid = pref.getStringValue("QDXQS_MB");// 首选项查puid + String puid = null; + puid = pref.getStringValue("HS2_WTBGMB"); + + if (puid != null) { + try { + TCComponentDataset dataset = (TCComponentDataset) session.stringToComponent(puid); + if (dataset == null) { + return null; + } + File[] files = dataset.getFiles(""); + if (files.length == 0 || files.length != 1) { + MessageBox.post("数据集没有命名引用的文件或文件过多,请检查!", "WARNING", MessageBox.WARNING); + return null; + } else { + File file = files[0]; + return file; + } + } catch (TCException e) { + e.printStackTrace(); + } + } else { + MessageBox.post("未找到首选项[HS2_WTBGMB]或首选项配置错误", "错误", MessageBox.ERROR); + return null; + } + return null; + } +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/wthz/WTHZHandler.java b/src/com/connor/hs2/plm/projectmanage/change/wthz/WTHZHandler.java new file mode 100644 index 0000000..f8cc307 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/wthz/WTHZHandler.java @@ -0,0 +1,28 @@ +package com.connor.hs2.plm.projectmanage.change.wthz; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonAction; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class WTHZHandler extends AbstractHandler{ + + private TCSession session ; + private TCComponentScheduleTask schedule; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + WTHZAction action = new WTHZAction(app, null); + new Thread(action).start(); + return null; + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/yzbgd/POIExcel.java b/src/com/connor/hs2/plm/projectmanage/change/yzbgd/POIExcel.java new file mode 100644 index 0000000..53a513b --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/yzbgd/POIExcel.java @@ -0,0 +1,101 @@ +package com.connor.hs2.plm.projectmanage.change.yzbgd; + +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 org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; + +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; + +/* + * POI写入Excel + * */ +public class POIExcel { + + /* + * Excel写操作 + */ + public void writerExcel(File file, TCComponentItemRevision revision, String outPath) { + // TODO Auto-generated method stub + // 文件流的初始化 + Workbook wb = null; + FileInputStream fis = null; + FileOutputStream out = null; + try { + fis = new FileInputStream(file); + wb = WorkbookFactory.create(fis); + File exportFile = new File(outPath); + if (!exportFile.exists()) { + exportFile.createNewFile(); + } + out = new FileOutputStream(exportFile); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + Sheet sheet = wb.getSheetAt(0); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + // 第三行 + +// Cell cpxhCell = row0.getCell(43); +// Cell cpjhCell = row0.getCell(60); + try { + Row row4 = sheet.getRow(3); + row4.getCell(4).setCellValue(revision.getProperty("hs2_assemblyproname")); + row4.getCell(19).setCellValue(revision.getProperty("hs2_assemblypartname")); + + Row row5 = sheet.getRow(4); + row5.getCell(4).setCellValue(revision.getProperty("hs2_changepartname")); + row5.getCell(19).setCellValue(revision.getProperty("hs2_changepartnumber")); + + Row row6 = sheet.getRow(5); + + if (revision.getProperty("hs2_verificationDate") != null + && !revision.getProperty("hs2_verificationDate").equals("")) { + row6.getCell(4).setCellValue(format.format(revision.getDateProperty("hs2_verificationDate"))); + } + if (revision.getProperty("hs2_implementation") != null + && !revision.getProperty("hs2_implementation").equals("")) { + row6.getCell(19).setCellValue(format.format(revision.getDateProperty("hs2_implementation"))); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + ; + + try { + fis.close(); + wb.write(out); + out.flush(); + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + +// public static Workbook create(InputStream in) throws IOException, InvalidFormatException { +// if (!in.markSupported()) { +// in = new PushbackInputStream(in, 8); +// } +// if (POIFSFileSystem.hasPOIFSHeader(in)) { +// return new HSSFWorkbook(in); +// } +// if (POIXMLDocument.hasOOXMLHeader(in)) { +// return new XSSFWorkbook(OPCPackage.open(in)); +// } +// throw new IllegalArgumentException("你的excel版本目前poi解析不了"); +// +// } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/yzbgd/YZBGDAction.java b/src/com/connor/hs2/plm/projectmanage/change/yzbgd/YZBGDAction.java new file mode 100644 index 0000000..6b33ec0 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/yzbgd/YZBGDAction.java @@ -0,0 +1,28 @@ +package com.connor.hs2.plm.projectmanage.change.yzbgd; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +public class YZBGDAction extends AbstractAIFAction{ + private AbstractAIFApplication app; + + public YZBGDAction(AbstractAIFApplication app, String arg1) { + super(app, arg1); + // TODO Auto-generated constructor stub + this.app = app; + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + YZBGDCommad command = new YZBGDCommad(app); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/yzbgd/YZBGDCommad.java b/src/com/connor/hs2/plm/projectmanage/change/yzbgd/YZBGDCommad.java new file mode 100644 index 0000000..4ff870c --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/yzbgd/YZBGDCommad.java @@ -0,0 +1,59 @@ +package com.connor.hs2.plm.projectmanage.change.yzbgd; + +import java.util.HashMap; +import java.util.Map; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonOpeartion; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; + +public class YZBGDCommad extends AbstractAIFCommand{ + private AbstractAIFApplication app; + + public YZBGDCommad(AbstractAIFApplication app) { + super(); + this.app = app; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + super.executeModal(); + Map map=new HashMap(); + if (app.getTargetComponent()!=null && (app.getTargetComponent().getType().equals("HS2_GGSQRevision") + || app.getTargetComponent().getType().equals("HS2_GGTZRevision") + || app.getTargetComponent().getType().equals("HS2_KXXFXBGPGRevision") + || app.getTargetComponent().getType().equals("HS2_GGRWDItemRevision") + || app.getTargetComponent().getType().equals("HS2_YZBGItemRevision") + || app.getTargetComponent().getType().equals("HS2_RequestRevision") + || app.getTargetComponent().getType().equals("HS2_NoticeRevision") + || app.getTargetComponent().getType().equals("HS2_FeasibilityARevision") + || app.getTargetComponent().getType().equals("HS2_ChangeTaskRevision") + || app.getTargetComponent().getType().equals("HS2_VerifyRevision") + )) { + TCComponentItemRevision target = (TCComponentItemRevision) app.getTargetComponent(); + String id = target.getProperty("item_id"); + String name = target.getProperty("object_name"); + map.put("item_id", id); + map.put("object_name", name); + String name1; + TCProperty[] allTCProperties = target.getAllTCProperties(); + for (int i = 0; i < allTCProperties.length; i++) { + TCProperty tcProperty = allTCProperties[i]; + name1 = tcProperty.getPropertyName(); + + if (name1.startsWith("hs2_")) { + map.put(name1, tcProperty.getPropertyValue()); + } + } + } + YZBGDDialog dialog = new YZBGDDialog(app,map); + new Thread(dialog).start(); + + } + + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/yzbgd/YZBGDDialog.java b/src/com/connor/hs2/plm/projectmanage/change/yzbgd/YZBGDDialog.java new file mode 100644 index 0000000..cb2963f --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/yzbgd/YZBGDDialog.java @@ -0,0 +1,474 @@ +package com.connor.hs2.plm.projectmanage.change.yzbgd; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +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.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.ScrollPaneConstants; + +import org.jdesktop.swingx.JXDatePicker; + +import com.connor.hs2.plm.projectmanage.utils.LovUtils; +import com.connor.hs2.plm.projectmanage.utils.SXXUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +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.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class YZBGDDialog extends AbstractAIFDialog implements ActionListener{ + + private AbstractAIFApplication app; + private TCSession session; + private JTextField idText; + private JButton idButton; + private TCComponentItemType type; + private JTextField nameText; + //private JButton nameButton; + private JTextField zccpmcText; + private JTextField zccpljhText; + private JTextField ggljmcText; + private JTextField ggljhText; + + private JXDatePicker ggyzDatePicker; + private JXDatePicker bghssDatePicker; + private JButton createButton; + private JButton cancelButton; + private JButton modifyButton; + private Map propertyMap; + public YZBGDDialog(AbstractAIFApplication app, Map map) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + this.propertyMap = map; + } + + @Override + public void run() { + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void init() throws TCException { + //System.out.println("yzbgd----init"); + JPanel rootPanel = new JPanel(new PropertyLayout()); + + JPanel propertyPanel = new JPanel(new PropertyLayout()); + //propertyPanel.setSize(new Dimension(400,450)); + //propertyPanel.setPreferredSize(new Dimension(500,650)); + JPanel buttomPanel = new JPanel(new PropertyLayout()); + type = (TCComponentItemType) session.getTypeComponent("HS2_Verify"); + + JLabel lable1 = new JLabel("ID:"); + idText = new JTextField(13); + if (propertyMap.get("item_id")!=null && !propertyMap.get("item_id").equals("")) { + idText.setText((String) propertyMap.get("item_id")); + }else { + idText.setText(type.getNewID()); + } + idButton = new JButton("指派"); + idButton.addActionListener(this); + + + JLabel lable2 = new JLabel("名称:"); + nameText = new JTextField(13); + //nameButton = new JButton("指派"); + if (propertyMap.get("object_name")!=null && !propertyMap.get("object_name").equals("")) { + nameText.setText((String) propertyMap.get("object_name")); + }else { + nameText.setText("验证报告单"); + } + + if (app.getTargetComponent()!=null && !app.getTargetComponent().getType().equals("HS2_VerifyRevision")) { + //对象不一样 id设为空 名称默认 + System.out.println("对象类型不一致"); + idText.setText(type.getNewID()); + nameText.setText("验证报告单"); + } + JLabel lable3 = new JLabel("总成产品名称:"); + zccpmcText = new JTextField(13); + if (propertyMap.get("hs2_assemblyproname")!=null && !propertyMap.get("hs2_assemblyproname").equals("")) { + zccpmcText.setText((String) propertyMap.get("hs2_assemblyproname")); + } + //rootPanel.add("2.3.left.top",nameButton); + JLabel lable4 = new JLabel("总成产品零件号:"); + zccpljhText = new JTextField(13); + if (propertyMap.get("hs2_assemblypartname")!=null && !propertyMap.get("hs2_assemblypartname").equals("")) { + zccpljhText.setText((String) propertyMap.get("hs2_assemblypartname")); + } + JLabel lable5 = new JLabel("更改零件名称:"); + ggljmcText = new JTextField(13); + if (propertyMap.get("hs2_changepartname")!=null && !propertyMap.get("hs2_changepartname").equals("")) { + ggljmcText.setText((String) propertyMap.get("hs2_changepartname")); + } + JLabel lable6 = new JLabel("更改零件号:"); + ggljhText = new JTextField(13); + if (propertyMap.get("hs2_changepartnumber")!=null && !propertyMap.get("hs2_changepartnumber").equals("")) { + ggljhText.setText((String) propertyMap.get("hs2_changepartnumber")); + } + + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + + JLabel lable7 = new JLabel("更改验证日期:"); + ggyzDatePicker = new JXDatePicker(); + ggyzDatePicker.setFormats(format); + if (propertyMap.get("hs2_verificationDate")!=null && !propertyMap.get("hs2_verificationDate").equals("")) { + ggyzDatePicker.setDate((Date) propertyMap.get("hs2_verificationDate")); + } + JLabel lable8 = new JLabel("变更后开始实施日期或批次:"); + bghssDatePicker = new JXDatePicker(); + bghssDatePicker.setFormats(format); + if (propertyMap.get("hs2_implementation")!=null && !propertyMap.get("hs2_implementation").equals("")) { + bghssDatePicker.setDate((Date) propertyMap.get("hs2_implementation")); + } + propertyPanel.add("1.1.left.top",lable1); + propertyPanel.add("1.2.left.top",idText); + propertyPanel.add("1.3.left.top",idButton); + propertyPanel.add("2.1.left.top",lable2); + propertyPanel.add("2.2.left.top",nameText); + propertyPanel.add("3.1.left.top",lable3); + propertyPanel.add("3.2.left.top",zccpmcText); + propertyPanel.add("4.1.left.top",lable4); + propertyPanel.add("4.2.left.top",zccpljhText); + propertyPanel.add("5.1.left.top",lable5); + propertyPanel.add("5.2.left.top",ggljmcText); + propertyPanel.add("6.1.left.top",lable6); + propertyPanel.add("6.2.left.top",ggljhText); + propertyPanel.add("7.1.left.top",lable7); + propertyPanel.add("7.2.left.top",ggyzDatePicker); + propertyPanel.add("8.1.left.top",lable8); + propertyPanel.add("8.2.left.top",bghssDatePicker); + + createButton = new JButton("创建"); + cancelButton = new JButton("取消"); + modifyButton = new JButton("修改"); + //System.out.println("="+app.getTargetComponent().getType()); + if (app.getTargetComponent()!=null && app.getTargetComponent().getType().equals("HS2_VerifyRevision")) { + modifyButton.setEnabled(true); + }else { + modifyButton.setEnabled(false); + } + createButton.addActionListener(this); + cancelButton.addActionListener(this); + modifyButton.addActionListener(this); + buttomPanel.add("1.1.center.left",createButton); + buttomPanel.add("1.2.center.left",modifyButton); + buttomPanel.add("1.3.center.left",cancelButton); + + JScrollPane propertyPane = new JScrollPane(propertyPanel); + propertyPane.setPreferredSize(new Dimension(480,400)); + //propertyPane.add(propertyPanel); + propertyPane.setBorder(null); + + propertyPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + //propertyPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + rootPanel.add("1.1.left.top",propertyPane); + rootPanel.add("2.1.center.left",buttomPanel); + this.setTitle("验证报告单"); + this.setLayout(new BorderLayout(10, 0)); + this.setPreferredSize(new Dimension(520,470)); + //panel.add(panel1, BorderLayout.WEST); + //panel.add(panel6, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.CENTER); + this.pack(); + this.setVisible(true); + this.setLocationRelativeTo(null); + this.setResizable(false);//不可变动窗口大小 + } + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if (e.getSource().equals(idButton)) { + try { + String id = type.getNewID(); + this.idText.setText(id); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }else if (e.getSource().equals(cancelButton)) { + this.dispose(); + } + else if (e.getSource().equals(createButton)) { + //this.dispose(); + try { + if (idText.getText().trim().equals("") || nameText.getText().trim().equals("")) { + MessageBox.post("请填写ID和名称!!","提示",2); + return ; + } + + String id = idText.getText(); + String name = nameText.getText(); + + if (type.find(id) != null) { + MessageBox.post("ID重复,请重新输入!!","提示",2); + return ; + + } + File file = SXXUtil.getSXX(session, "HS2_VerifyRevision"); + if (file == null) { + return ; + } + + + String newRev = type.getNewRev(null); + TCComponentItem item = type.create(id, newRev, "HS2_Verify", name, "", null); + if (item!=null) { + TCComponentItemRevision revision = item.getLatestItemRevision(); + Map propMap = new HashMap(); + if (nameText.getText().toString().length() != 0) { + propMap.put("object_name", nameText.getText().toString()); + } + if (zccpmcText.getText().toString().length() != 0) { + propMap.put("hs2_assemblyproname", zccpmcText.getText().toString()); + } + if (zccpljhText.getText().toString().length() != 0) { + propMap.put("hs2_assemblypartname", zccpljhText.getText().toString()); + } + if (ggljmcText.getText().toString().length() != 0) { + propMap.put("hs2_changepartname", ggljmcText.getText().toString()); + } + if (ggljhText.getText().toString().length() != 0) { + propMap.put("hs2_changepartnumber", ggljhText.getText().toString()); + } + + //System.out.println("map="+propMap); + revision.setProperties(propMap); + if (ggyzDatePicker.getDate()!=null) { + revision.setDateProperty("hs2_verificationDate", ggyzDatePicker.getDate()); + } + if (bghssDatePicker.getDate()!=null) { + revision.setDateProperty("hs2_implementation", bghssDatePicker.getDate()); + } + + String absolutePath = file.getAbsolutePath(); + int num = absolutePath.lastIndexOf("."); + String temp = absolutePath.substring(0, num); + temp = temp + "导出.xlsx"; +// String substring = absolutePath.substring(0, absolutePath.lastIndexOf("\\")); +// String pathString = substring + "\\" + titleName + ".xlsx"; + File outFile = new File(temp); + if (outFile.exists()) { + outFile.delete(); + System.out.println("删除temp成功"); + } + POIExcel poiExcel = new POIExcel(); + poiExcel.writerExcel(file, revision, temp); + + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("MSExcelX"); + TCComponentDataset dataset = datasetType.create("验证报告单", "", "MSExcelX"); + String[] as1 = new String[] { temp }; + String[] as2 = new String[] { "excel" }; + dataset.setFiles(as1, as2); + revision.add("IMAN_specification", dataset); + //docRevision.add("IMAN_specification ", dataset); + + File f = new File(absolutePath); + if (f.exists() && f.isFile()) { + f.delete(); + System.out.println("删除成功"); + } + + if (outFile.exists() && outFile.isFile()) { + + outFile.delete(); + System.out.println("删除成功"); + } + + if (app.getTargetComponent() !=null && app.getTargetComponent().getType().equals("ProjectSmartFolder")) { + TCComponent ref = ((TCComponent) app.getTargetComponent()).getReferenceProperty("owning_project"); + if (ref!=null) { + TCComponentProject pro = (TCComponentProject) ref; + pro.assignToProject(new TCComponent[] {item}); + } + }else + if (app.getTargetComponent() !=null && app.getTargetComponent() instanceof TCComponentFolder) { + ((TCComponentFolder)app.getTargetComponent()).add("contents", item); + }else if(app.getTargetComponent() !=null && app.getTargetComponent() instanceof TCComponentProject) + { + TCComponentProject pro = (TCComponentProject) app.getTargetComponent(); + pro.assignToProject(new TCComponent[] {item}); + }else { + session.getUser().getNewStuffFolder().add("contents", item); + } + + //添加关系 + if (app.getTargetComponent()!=null && !app.getTargetComponent().getType().equals(revision.getType())) { + //选中对象不为空 并且类型不一样 添加到对应的关系 + //选中更改申请版本、更改通知版本 创建更改风险单 添加关系 + if (app.getTargetComponent().getType().equals("HS2_RequestRevision") + || app.getTargetComponent().getType().equals("HS2_NoticeRevision")) { + System.out.println("选中更改申请版本、更改通知版本 创建验证报告"); + TCComponentItemRevision targetRevision = (TCComponentItemRevision) app.getTargetComponent(); + targetRevision.add("HS2_ValidationReport", item); + } + } + + //如果选中的对象版本被指派到项目 那么创建出来的也要指派到项目 + if (app.getTargetComponent()!=null && (app.getTargetComponent() instanceof TCComponentItemRevision || app.getTargetComponent() instanceof TCComponentItem)) { + System.out.println("判断是否被指派到项目"); + TCComponent[] refs = ((TCComponent) app.getTargetComponent()).getReferenceListProperty("project_list"); + //System.out.println("ref="+refs); + if (refs!=null && refs.length>0) { + for (TCComponent component : refs) { + TCComponentProject project = (TCComponentProject)component; + project.assignToProject(new TCComponent[] {item}); + } + } + } + MessageBox.post("创建成功!!","提示",2); + this.dispose(); + }else { + MessageBox.post("创建失败,请联系管理员!!","提示",2); + } + } catch (Exception e1) { + // TODO: handle exception + e1.printStackTrace(); + } + } + else if (e.getSource().equals(modifyButton)) { + System.out.println("点击修改按钮-----"); + //设置属性 + if (app.getTargetComponent()==null) { + MessageBox.post("请选中验证报告版本进行修改!!","提示",2); + return ; + } +// if (!app.getTargetComponent().getType().equals("HS2_GGSQRevision")) { +// MessageBox.post("请选中变更申请单版本进行修改!!","提示",2); +// return ; +// } + + + try { + + TCComponentItemRevision revision = (TCComponentItemRevision) app.getTargetComponent(); + if (!idText.getText().trim().equals(revision.getProperty("item_id"))) { + MessageBox.post("ID不允许修改!!","提示",2); + return ; + } + + + Map propMap = new HashMap(); + if (nameText.getText().toString().length() != 0) { + propMap.put("object_name", nameText.getText().toString()); + } + if (zccpmcText.getText().toString().length() != 0) { + propMap.put("hs2_assemblyproname", zccpmcText.getText().toString()); + } + if (zccpljhText.getText().toString().length() != 0) { + propMap.put("hs2_assemblypartname", zccpljhText.getText().toString()); + } + if (ggljmcText.getText().toString().length() != 0) { + propMap.put("hs2_changepartname", ggljmcText.getText().toString()); + } + if (ggljhText.getText().toString().length() != 0) { + propMap.put("hs2_changepartnumber", ggljhText.getText().toString()); + } + + + //System.out.println("map="+propMap); + revision.setProperties(propMap); + System.out.println(revision.getItem()+"验证报告设置对象名称-----"+nameText.getText()); + TCComponentItem item = revision.getItem(); + item.setProperty("object_name", nameText.getText()); + if (ggyzDatePicker.getDate()!=null) { + revision.setDateProperty("hs2_verificationDate", ggyzDatePicker.getDate()); + } + System.out.println("bghssDatePicker.getDate()="+bghssDatePicker.getDate()); + if (bghssDatePicker.getDate()!=null) { + revision.setDateProperty("hs2_implementation", bghssDatePicker.getDate()); + } + //写入excel + TCComponent[] referenceListProperty = revision.getReferenceListProperty("IMAN_specification"); + //移除之前的数据集 + for (TCComponent attche : referenceListProperty) { + if (attche instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) attche; +// System.out.println("dateset.type="+dataset.getType()); +// System.out.println("dataset.name="+dataset.getProperty("object_name")); + + if (dataset.getType().equals("MSExcelX") && dataset.getProperty("object_name").equals("验证报告单")) { + System.out.println("移除验证报告单"); + revision.remove("IMAN_specification", dataset); + } + } + } + + //创建数据集 + File file = SXXUtil.getSXX(session, "HS2_VerifyRevision"); + if (file == null) { + return ; + } + String absolutePath = file.getAbsolutePath(); + int num = absolutePath.lastIndexOf("."); + String temp = absolutePath.substring(0, num); + temp = temp + "导出.xlsx"; +// String substring = absolutePath.substring(0, absolutePath.lastIndexOf("\\")); +// String pathString = substring + "\\" + titleName + ".xlsx"; + File outFile = new File(temp); + if (outFile.exists()) { + outFile.delete(); + System.out.println("删除temp成功"); + } + POIExcel poiExcel = new POIExcel(); + poiExcel.writerExcel(file, revision, temp); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("MSExcelX"); + TCComponentDataset dataset = datasetType.create("验证报告单", "", "MSExcelX"); + String[] as1 = new String[] { temp }; + String[] as2 = new String[] { "excel" }; + dataset.setFiles(as1, as2); + revision.add("IMAN_specification", dataset); + //docRevision.add("IMAN_specification ", dataset); + + File f = new File(absolutePath); + if (f.exists() && f.isFile()) { + f.delete(); + System.out.println("删除成功"); + } + + if (outFile.exists() && outFile.isFile()) { + + outFile.delete(); + System.out.println("删除成功"); + } + MessageBox.post("修改成功!!","提示",2); + this.dispose(); + } catch (Exception e2) { + // TODO: handle exception + MessageBox.post("修改失败,请联系管理员!!","提示",2); + e2.printStackTrace(); + } + + } + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/change/yzbgd/YZBGDHandler.java b/src/com/connor/hs2/plm/projectmanage/change/yzbgd/YZBGDHandler.java new file mode 100644 index 0000000..6d1f55c --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/change/yzbgd/YZBGDHandler.java @@ -0,0 +1,28 @@ +package com.connor.hs2.plm.projectmanage.change.yzbgd; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonAction; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class YZBGDHandler extends AbstractHandler{ + + private TCSession session ; + private TCComponentScheduleTask schedule; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + YZBGDAction action = new YZBGDAction(app, null); + new Thread(action).start(); + return null; + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/cpwlqd/CPWLQDAction.java b/src/com/connor/hs2/plm/projectmanage/cpwlqd/CPWLQDAction.java new file mode 100644 index 0000000..e7ce7dc --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/cpwlqd/CPWLQDAction.java @@ -0,0 +1,28 @@ +package com.connor.hs2.plm.projectmanage.cpwlqd; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +public class CPWLQDAction extends AbstractAIFAction{ + private AbstractAIFApplication app; + + public CPWLQDAction(AbstractAIFApplication app, String arg1) { + super(app, arg1); + // TODO Auto-generated constructor stub + this.app = app; + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + CPWLQDCommad command = new CPWLQDCommad(app); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/cpwlqd/CPWLQDCommad.java b/src/com/connor/hs2/plm/projectmanage/cpwlqd/CPWLQDCommad.java new file mode 100644 index 0000000..beaa744 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/cpwlqd/CPWLQDCommad.java @@ -0,0 +1,51 @@ +package com.connor.hs2.plm.projectmanage.cpwlqd; + +import java.util.HashMap; +import java.util.Map; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonOpeartion; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CPWLQDCommad extends AbstractAIFCommand{ + private AbstractAIFApplication app; + + public CPWLQDCommad(AbstractAIFApplication app) { + super(); + this.app = app; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + super.executeModal(); + TCComponentItemRevision revision; + if (app.getTargetComponent().getType().equals("HS2_ProductPartRevision")){ + revision = (TCComponentItemRevision)app.getTargetComponent(); + CPWLQDDialog dialog = new CPWLQDDialog(app,revision); + new Thread(dialog).start(); + }else if (app.getTargetComponent() instanceof TCComponentBOMLine) + { + TCComponentBOMLine line = (TCComponentBOMLine)app.getTargetComponent(); + if (line.getItemRevision().getType().equals("HS2_ProductPartRevision")) { + revision = line.getItemRevision(); + CPWLQDDialog dialog = new CPWLQDDialog(app,revision); + new Thread(dialog).start(); + }else { + MessageBox.post("请选中产品零部件版本生成产品物料清单","提示",2); + } + + }else { + MessageBox.post("请选中产品零部件版本生成产品物料清单","提示",2); + } + + + } + + +} diff --git a/src/com/connor/hs2/plm/projectmanage/cpwlqd/CPWLQDDialog.java b/src/com/connor/hs2/plm/projectmanage/cpwlqd/CPWLQDDialog.java new file mode 100644 index 0000000..8a5c55d --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/cpwlqd/CPWLQDDialog.java @@ -0,0 +1,279 @@ +package com.connor.hs2.plm.projectmanage.cpwlqd; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; + +import javax.swing.Box; +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.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentRevisionRule; +import com.teamcenter.rac.kernel.TCComponentRevisionRuleType; +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 CPWLQDDialog extends AbstractAIFDialog implements ActionListener{ + + private AbstractAIFApplication app; + private TCSession session; + private JTextField fileNameText; + //private JButton nameButton; + public JLabel label; + public JLabel label2; + public JTextField jtf ; + public JButton button; + private JButton DCButton; + private JButton QXButton; + File tempFile; + private JComboBox productComboBox; + TCComponentItemRevision topDesignRevision; + public CPWLQDDialog(AbstractAIFApplication app,TCComponentItemRevision topDesignRevision) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + this.topDesignRevision = topDesignRevision; + } + + @Override + public void run() { + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void init() throws TCException { + //System.out.println("ggfxd----init"); + try { + tempFile = getSXX(); + if (tempFile==null) { + return ; + } + System.out.println("init()----------------CPWLQDDialog"); + JLabel wlLabel = new JLabel("物料编码"); + productComboBox = new JComboBox(); + TCComponent[] representations = topDesignRevision.getReferenceListProperty("representation_for"); + if (representations.length == 0) { + MessageBox.post("该图纸下没有物料,请检查!","提示",2); + return ; + }else { + for (int i = 0; i < representations.length; i++) { + if (representations[i] instanceof TCComponentItemRevision) { + productComboBox.addItem((TCComponentItemRevision)representations[i]); + } + + } + } + this.setTitle("选择数据保存位置"); + this.setLayout(new PropertyLayout()); + //Component verticalStrut = Box.createVerticalStrut(10); + //this.setTitle("选择数据保存位置"); + //JPanel rootPanel = new JPanel(new PropertyLayout()); + Box vBox = Box.createVerticalBox();//垂直box + + //文件名称box + Box fileNameBox = Box.createHorizontalBox(); + JLabel nameLabel = new JLabel("文件名称"); + fileNameText = new JTextField(20); + String fileName = topDesignRevision.getProperty("item_id")+"-"+topDesignRevision.getProperty("object_name"); + fileNameText.setText(fileName); + //Component hStrut = Box.createHorizontalStrut(3); + + fileNameBox.add(nameLabel); + fileNameBox.add(Box.createHorizontalStrut(10)); + //fileNameBox.add(hStrut); + fileNameBox.add(fileNameText); + //文件选择界面 + label=new JLabel("文件位置"); + label2 = new JLabel("",JLabel.CENTER); + jtf = new JTextField(20); + File desktopDir = FileSystemView.getFileSystemView().getHomeDirectory(); + String desktopPath = desktopDir.getAbsolutePath(); + jtf.setText(desktopPath); + jtf.setEditable(false); + button=new JButton("浏览"); + button.addActionListener(new MyActionListener()); + Box fileBox = Box.createHorizontalBox(); + fileBox.add(label); + fileBox.add(Box.createHorizontalStrut(10)); + fileBox.add(jtf); + fileBox.add(Box.createHorizontalStrut(5)); + fileBox.add(button); + + + Box selectProductBox = Box.createHorizontalBox(); + + + //vBox.add(verticalStrut); + selectProductBox.add(wlLabel); + selectProductBox.add(Box.createHorizontalStrut(10)); + selectProductBox.add(productComboBox); + + vBox.add(fileNameBox); + //vBox.add(verticalStrut); + vBox.add(Box.createVerticalStrut(10)); + vBox.add(fileBox); + vBox.add(Box.createVerticalStrut(10)); + vBox.add(selectProductBox); + vBox.add(Box.createVerticalStrut(10)); + // 底层按钮 + JPanel buttonJPanel = new JPanel(new PropertyLayout()); + DCButton = new JButton("导出"); + DCButton.addActionListener(this); + QXButton = new JButton("取消"); + QXButton.addActionListener(this); + buttonJPanel.add("1.1.left.top", DCButton); + buttonJPanel.add("1.2.left.top", QXButton); + //panel.add(panel1, BorderLayout.WEST); + //panel.add(panel6, BorderLayout.CENTER); + + //选择物料 + this.add("1.1.left.top",vBox); + this.add("2.1.center.left",buttonJPanel); + this.pack(); + this.setVisible(true); + this.setLocationRelativeTo(null); + this.setResizable(false);//不可变动窗口大小 + }catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if (e.getSource().equals(DCButton)) { + // System.out.println("点击导出按钮"); + if (isValidFileName(fileNameText.getText())==false) { + this.setAlwaysOnTop(false); + MessageBox.post("文件名称不合法,请检查后重新输入", "提示", MessageBox.INFORMATION); + } + if (jtf.getText().equals("") || jtf.getText().equals("未选择文件位置")) { + this.setAlwaysOnTop(false); + MessageBox.post("请选择导出文件路径", "提示", MessageBox.INFORMATION); + + }else{ + System.out.println("进行导出-----------"); + String outPath = jtf.getText()+"/"+fileNameText.getText()+".xlsx"; + TCComponentBOMLine designTopLine = sendToStructureManager(topDesignRevision); + TCComponentItemRevision wlRevision = (TCComponentItemRevision)productComboBox.getSelectedItem(); + TCComponentBOMLine wlTopLine = sendToStructureManager(wlRevision); + CPWLQDOpeartion operation = new CPWLQDOpeartion(session, app,designTopLine,wlTopLine,tempFile,outPath); + session.queueOperation(operation); + this.dispose(); + +// List list = new ArrayList(); +// recursionLine(designTopLine, list); + } + }else if (e.getSource().equals(QXButton)) { + this.dispose(); + } + } + class MyActionListener implements ActionListener{ + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + File desktopDir = FileSystemView.getFileSystemView().getHomeDirectory(); + String desktopPath = desktopDir.getAbsolutePath(); + JFileChooser fc=new JFileChooser(desktopPath); + + fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); //只可以选择文件夹 + + //int val=fc.showOpenDialog(null); //文件打开对话框 + + int val=fc.showSaveDialog(null); //弹出保存文件对话框。 + //jtf.setText(desktopPath); + if(val==fc.APPROVE_OPTION){ + + //正常选择文件 + + jtf.setText(fc.getSelectedFile().toString()); + jtf.setEditable(false); + //label2.setText("选择了文件:【"+fc.getSelectedFile().getAbsolutePath()+"】"); + + }else{ + + //未正常选择文件,如选择取消按钮 + jtf.setText("未选择文件位置"); + jtf.setEditable(false); + } + + } +} + public File getSXX() { + TCPreferenceService pref = session.getPreferenceService(); + //String puid = pref.getStringValue("QDXQS_MB");// 首选项查puid + String puid = null; + puid = pref.getStringValue("HS_CPWLQDMB"); + + if (puid != null) { + try { + TCComponentDataset dataset = (TCComponentDataset) session.stringToComponent(puid); + if (dataset == null) { + return null; + } + File[] files = dataset.getFiles(""); + if (files.length == 0 || files.length != 1) { + MessageBox.post("数据集没有命名引用的文件或文件过多,请检查!", "WARNING", MessageBox.WARNING); + return null; + } else { + File file = files[0]; + return file; + } + } catch (TCException e) { + e.printStackTrace(); + } + } else { + MessageBox.post("未找到首选项[HS_CPWLQDMB]或首选项配置错误", "错误", MessageBox.ERROR); + return null; + } + return null; + } + + + /** + * 发送到结构管理器 + * + * @param tcComponentItem + * @return + */ + public TCComponentBOMLine sendToStructureManager(TCComponentItemRevision tcComponentItemRev) { + try { + TCComponentRevisionRuleType ruleType = (TCComponentRevisionRuleType) session + .getTypeComponent("RevisionRule"); + TCComponentRevisionRule revRule = ruleType.getDefaultRule(); + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow bomWindow = bomWindowType.create(revRule); + return bomWindow.setWindowTopLine(null, tcComponentItemRev, null, null); + } catch (TCException e) { + e.printStackTrace(); + return null; + } + } + + //检验用户输入的文件名是否合法 + public static boolean isValidFileName(String fileName) { + if (fileName == null || fileName.length() > 255) + return false; + else return fileName.matches("[^\\s\\\\/:\\*\\?\\\"<>\\|](\\x20|[^\\s\\\\/:\\*\\?\\\"<>\\|])*[^\\s\\\\/:\\*\\?\\\"<>\\|\\.]$"); } +} diff --git a/src/com/connor/hs2/plm/projectmanage/cpwlqd/CPWLQDHandler.java b/src/com/connor/hs2/plm/projectmanage/cpwlqd/CPWLQDHandler.java new file mode 100644 index 0000000..93d7c31 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/cpwlqd/CPWLQDHandler.java @@ -0,0 +1,28 @@ +package com.connor.hs2.plm.projectmanage.cpwlqd; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonAction; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CPWLQDHandler extends AbstractHandler{ + + private TCSession session ; + private TCComponentScheduleTask schedule; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + CPWLQDAction action = new CPWLQDAction(app, null); + new Thread(action).start(); + return null; + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/cpwlqd/CPWLQDOpeartion.java b/src/com/connor/hs2/plm/projectmanage/cpwlqd/CPWLQDOpeartion.java new file mode 100644 index 0000000..e12d439 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/cpwlqd/CPWLQDOpeartion.java @@ -0,0 +1,335 @@ + +package com.connor.hs2.plm.projectmanage.cpwlqd; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import com.connor.hs2.plm.projectmanage.utils.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +public class CPWLQDOpeartion extends AbstractAIFOperation { + + private TCSession session; + private AbstractAIFApplication app; + private ProgressBarThread wait; + private TCComponentBOMLine designTopLine; + private File tempFile; + private String outPath; + //图纸map key--图号(item_id) value--图纸的BOMLine对象 + private Map designMap; + //物料map key--图号 value--物料bean对象 + private Map > wlMap; + private TCComponentBOMLine wlTopLine; + private int maxLevel= 5;//最大层级 excel模板中默认是5 用于动态增加excel的层级列 + public CPWLQDOpeartion(TCSession session, AbstractAIFApplication app,TCComponentBOMLine designTopLine, TCComponentBOMLine wlTopLine, File tempFile, String outPath) { + super(); + this.session = session; + this.app = app; + this.designTopLine = designTopLine; + this.tempFile = tempFile; + this.outPath = outPath; + this.wlTopLine = wlTopLine; + } + + @Override + public void executeOperation() throws Exception { + try { + wait = new ProgressBarThread("报表导出", "报表生成中,请稍等..."); + wait.start();// 开启进度条 + //List list = new ArrayList(); + designMap = new LinkedHashMap(); + //顶层对象存入map + designMap.put(designTopLine.getProperty("bl_item_item_id"), designTopLine); + recursionDesignLine(designTopLine); + wlMap = new HashMap>(); +// if (wlTopLine.getItemRevision().getProperty("hs2_partscode")!=null && !wlTopLine.getItemRevision().getProperty("hs2_partscode").equals("")) { +// List list = new ArrayList(); +// WLBean bean = new WLBean(); +// bean.setLevel("0"); +// bean.setProductCode(wlTopLine.getProperty("bl_item_item_id")); +// bean.setColor(wlTopLine.getItemRevision().getProperty("hs2_materialcolor")); +// bean.setQuantity(wlTopLine.getProperty("bl_quantity")); +// list.add(bean); +// wlMap.put(wlTopLine.getItemRevision().getProperty("hs2_partscode"), list); +// } + + //顶层物料如果没有匹配图纸 写入日志 匹配到存入物料map集合 + String partCode = wlTopLine.getItemRevision().getProperty("hs2_partscode"); + if (partCode!=null && !partCode.equals("")) { + //物料上有零件代号 + if (wlMap.containsKey(partCode)) { + //物料map中有重复零件代号 + List WLList = wlMap.get(partCode); + WLBean bean = getWLLineProp(wlTopLine); + WLList.add(bean); + wlMap.replace(partCode, WLList); + }else { + List wlList = new ArrayList(); + WLBean bean = getWLLineProp(wlTopLine); + wlList.add(bean); + wlMap.put(partCode, wlList); + } + + if (designMap.get(partCode)==null) { + //在图纸map中没有匹配到的物料写入日志 + LogUtil.writeLog(wlTopLine.getItemRevision().getProperty("object_string")+"物料未匹配图纸\r\n"); + } + }else { + //未匹配图纸的物料写入日志 + LogUtil.writeLog(wlTopLine.getItemRevision().getProperty("object_string")+"物料未匹配图纸\r\n"); + } + //wlMap.put(arg0, arg1) + recursionWLLine(wlTopLine); + + System.out.println("designMap="+designMap); + System.out.println("wlMap="+wlMap); + //处理图纸map和物料map 输出一个存放PartBean的list集合写入excel + List totalList = resolveMap(designMap,wlMap); + totalList.forEach(bean-> System.out.println(bean)); + ExcelWriter writer = new ExcelWriter(); + writer.writerExcel(tempFile, totalList,designTopLine,maxLevel, outPath); + MessageBox.post("导出成功","提示",MessageBox.INFORMATION); + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post("导出异常,请联系管理员!!","警告",MessageBox.WARNING); + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + e.printStackTrace(); + } + } + +private List resolveMap(Map designMap, Map> wlMap) throws TCException { + // TODO Auto-generated method stub + try { + + } catch (Exception e) { + // TODO: handle exception + } + List list = new ArrayList(); + //System.out.println("通过Map.entrySet遍历key和value"); + for (Entry DesignEntry : designMap.entrySet()) { +// System.out.println("key= " + DesignEntry.getKey() + " and value= " + DesignEntry.getValue()); + TCComponentBOMLine designLine = DesignEntry.getValue(); + String level_str = designLine.getProperty("bl_level_starting_0"); + int level = Integer.parseInt(level_str)+1; + maxLevel = (level > maxLevel?level:maxLevel); + if (wlMap.get(DesignEntry.getKey()) == null || wlMap.get(DesignEntry.getKey()).size() == 0) { + //图纸没有对应的物料 直接把图纸相关属性封装进PartBean 存入list集合 + PartBean bean = getDesignLineProp(designLine); + list.add(bean); + }else if (wlMap.get(DesignEntry.getKey()).size() == 1){ + //图纸有一个物料对应 封装图纸相关属性和物料相关属性 存入list集合 + PartBean bean = getDesignLineProp(designLine); + WLBean wlBean = wlMap.get(DesignEntry.getKey()).get(0); + bean.setWlBean(wlBean); + list.add(bean); + }else if (wlMap.get(DesignEntry.getKey()).size() >1 ) { + //图纸有多个物料对应 要把图纸进行拆分(有几个物料就拆分几个) 数量为物料对应数量 封装PartBean 存入list集合 + for (int i = 0; i < (wlMap.get(DesignEntry.getKey()).size()); i++) { + PartBean bean = getDesignLineProp(designLine); + WLBean wlBean = wlMap.get(DesignEntry.getKey()).get(i); + bean.setWlBean(wlBean); + bean.setQuantity(wlBean.getQuantity()); + list.add(bean); + } + } + } + System.out.println("maxlevel="+maxLevel); + return list; + } + + // /** +// * 递归遍历bom数据 +// * @param topline2 +// * @param topitem +// */ +// private void recursionLine(TCComponentBOMLine line,List list) { +// // TODO Auto-generated method stub +// try { +// +// AIFComponentContext[] children = line.getChildren(); +// if (children!=null&&children.length>0) { +// //Map map = new HashMap(); +// for (int i = 0; i < children.length; i++) { +// +// TCComponentBOMLine chiline=(TCComponentBOMLine) children[i].getComponent(); +// PartBean bean = getLineProp(chiline); +// list.add(bean); +// recursionLine(chiline,list); +// } +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } + /** + * 递归遍历bom数据 + * @param topline2 + * @param topitem + */ + private void recursionDesignLine(TCComponentBOMLine line) { + // TODO Auto-generated method stub + try { + + AIFComponentContext[] children = line.getChildren(); + if (children!=null&&children.length>0) { + //Map map = new HashMap(); + for (int i = 0; i < children.length; i++) { + + TCComponentBOMLine chiline=(TCComponentBOMLine) children[i].getComponent(); + designMap.put(chiline.getProperty("bl_item_item_id"), chiline); + //PartBean bean = getLineProp(chiline); + //list.add(bean); + recursionDesignLine(chiline); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 递归遍历bom数据 + * @param topline2 + * @param topitem + */ + private void recursionWLLine(TCComponentBOMLine line) { + // TODO Auto-generated method stub + try { + + AIFComponentContext[] children = line.getChildren(); + if (children!=null&&children.length>0) { + //Map map = new HashMap(); + for (int i = 0; i < children.length; i++) { + + TCComponentBOMLine chiline=(TCComponentBOMLine) children[i].getComponent(); + + //物料版本上的零件代号为图纸号 + String partCode = chiline.getItemRevision().getProperty("hs2_partscode"); + if (partCode!=null && !partCode.equals("")) { + //物料上有零件代号 + if (wlMap.containsKey(partCode)) { + //物料map中有重复零件代号 + List WLList = wlMap.get(partCode); + WLBean bean = getWLLineProp(chiline); + WLList.add(bean); + wlMap.replace(partCode, WLList); + }else { + List wlList = new ArrayList(); + WLBean bean = getWLLineProp(chiline); + wlList.add(bean); + //System.out.println("wlbean="+bean+"存入map"); + wlMap.put(partCode, wlList); + } + + if (designMap.get(partCode)==null) { + //在图纸map中没有匹配到的物料写入日志 + LogUtil.writeLog(wlTopLine.getItemRevision().getProperty("object_string")+"物料下的"+chiline.getItemRevision().getProperty("object_string")+"物料未匹配图纸\n"); + } + }else { + //未匹配图纸的物料写入日志 + LogUtil.writeLog(wlTopLine.getItemRevision().getProperty("object_string")+"物料下的"+chiline.getItemRevision().getProperty("object_string")+"物料未匹配图纸\n"); + } + recursionWLLine(chiline); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 获得属性(物料对象) + * @param line + * @return + */ + private WLBean getWLLineProp(TCComponentBOMLine line) { + // TODO Auto-generated method stub + + try { + TCComponentItemRevision itemRevision = line.getItemRevision(); + String level_str = line.getProperty("bl_level_starting_0"); + int level = Integer.parseInt(level_str)+1; + String quantity = line.getProperty("bl_quantity"); + String color = itemRevision.getProperty("hs2_materialcolor"); + if (quantity.equals("")) { + quantity="1"; + } + + WLBean WlBean = new WLBean(); + WlBean.setLevel(String.valueOf(level)); + WlBean.setProductCode(itemRevision.getProperty("item_id")); + WlBean.setQuantity(quantity); + WlBean.setColor(color); + System.out.println("----" + WlBean); + return WlBean; + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return null; + } + + /** + * 获得属性(图纸对象) + * @param line + * @return + */ + private PartBean getDesignLineProp(TCComponentBOMLine line) { + // TODO Auto-generated method stub + + try { + TCComponentItemRevision itemRevision = line.getItemRevision(); + String level_str = line.getProperty("bl_level_starting_0"); + int level = Integer.parseInt(level_str)+1; + String hsName = itemRevision.getProperty("object_name"); + String gkName = itemRevision.getProperty("hs2_cusName"); + String partNum = itemRevision.getProperty("item_id"); + String gkNum = itemRevision.getProperty("hs2_cusPartNumber"); + String material = itemRevision.getProperty("hs2_material"); + //String color = ""; + String quantity = line.getProperty("bl_quantity"); + String weight = itemRevision.getProperty("hs2_weight"); + if (quantity.equals("")) { + quantity="1"; + } + + PartBean bean = new PartBean(); + bean.setLevel(String.valueOf(level)); + bean.setHsName(hsName); + bean.setGkName(gkName); + bean.setPartNum(partNum); + bean.setGkNum(gkNum); + bean.setMaterial(material); + bean.setQuantity(quantity); + //bean.setColor(color); + bean.setWeight(weight); + //System.out.println("----" + bean); + return bean; + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return null; + } +} diff --git a/src/com/connor/hs2/plm/projectmanage/cpwlqd/ExcelWriter.java b/src/com/connor/hs2/plm/projectmanage/cpwlqd/ExcelWriter.java new file mode 100644 index 0000000..05570e7 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/cpwlqd/ExcelWriter.java @@ -0,0 +1,966 @@ + package com.connor.hs2.plm.projectmanage.cpwlqd; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.List; +import org.apache.poi.openxml4j.exceptions.InvalidFormatException; +import org.apache.poi.ss.usermodel.BorderStyle; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +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.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFFont; +import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.MessageBox; + +/* + * POI写入Excel + * */ +public class ExcelWriter { + + /* + * Excel写操作 + * */ + public void writerExcel(File file,List list,TCComponentBOMLine designTopLine,int maxLevel, String outPath) throws InvalidFormatException { + // TODO Auto-generated method stub + // 文件流的初始化 + Workbook wb = null; + FileInputStream fis =null; + FileOutputStream out = null; + try { + fis = new FileInputStream(file); + + wb = WorkbookFactory.create(fis); + //wb = getWorkbook(fis, "xlsx"); + File exportFile = new File(outPath); +// if (!exportFile.exists()) { +// exportFile.createNewFile(); +// } + out = new FileOutputStream(exportFile); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + Sheet sheet = wb.getSheetAt(2); + try { + String designId = designTopLine.getItemRevision().getProperty("item_id"); + String designName = designTopLine.getItemRevision().getProperty("object_name"); + wb.setSheetName(2, designId); + sheet.getRow(2).getCell(8).setCellValue("零件名称:"+designName); + sheet.getRow(2).getCell(14).setCellValue("零件号:"+designId); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + //零件名称 + + if (list.size() <= 10) { + writeDirect(list,maxLevel,sheet); + }else if (list.size() > 10) { + //单元格向下移动 创建单元格后写入 + writeShift(list,maxLevel,sheet); + } +// for (int i = 0; i < list.size(); i++) { +// PartBean bean = list.get(i); +// } + //SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + //第三行 + +// Cell cpxhCell = row0.getCell(43); +// Cell cpjhCell = row0.getCell(60); +// try { +// +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// }; + + + try { + fis.close(); + wb.write(out); + out.flush(); + out.close(); + } catch (IOException e) { + e.printStackTrace(); + MessageBox.post("导出失败","提示",2); + return ; + } + } + + + private void writeShift(List list,int maxLevel, Sheet sheet) { + // TODO Auto-generated method stub + int count = 1; + int lastFilledColumn = getLastFilledColumn(sheet); + //取消加粗的字体 + XSSFFont unBondFont = (XSSFFont) sheet.getWorkbook().createFont(); + unBondFont.setBold(false); + unBondFont.setFontHeightInPoints((short)10); //字体大小只能是整数 + unBondFont.setFontName("宋体"); //字体 + //加粗的字体 + XSSFFont BondFont = (XSSFFont) sheet.getWorkbook().createFont(); + BondFont.setBold(true); + BondFont.setFontHeightInPoints((short)10); //字体大小只能是整数 + BondFont.setFontName("宋体"); //字体 +// int startRow = 6; + for (int i = 0; i < 10; i++) { + // 从第一行开始写入 + PartBean bean = list.get(i); + + int FirstRow = 2*i+6; + int secondRow = 2*i+7; + // 创建每个单元格Cell,即列的数据 + Row row = sheet.getRow(FirstRow); + if (row == null) { + row = sheet.createRow(FirstRow); + } + //System.out.println("startrow="+FirstRow); + Cell cell = null; + for (int j = 0; j < 22; j++) { + cell = row.getCell(j); + if (row.getCell(j) == null) { + + cell = row.createCell(j); + cell.setCellStyle(sheet.getRow(6).getCell(2).getCellStyle()); + } + switch (j) { + case 0: + cell.getCellStyle().setFont(unBondFont); + cell.setCellValue(count++); + + break; +// case 1: +// cell.setCellValue(wt.getLb2_jd()); +// break; + case 2: + if (bean.getLevel().equals("1")) { + cell.setCellValue("1"); + } + break; + case 3: + if (bean.getLevel().equals("2")) { + cell.setCellValue("2"); + } + break; + case 4: + if (bean.getLevel().equals("3")) { + cell.setCellValue("3"); + } + break; + case 5: + if (bean.getLevel().equals("4")) { + cell.setCellValue("4"); + } + break; + case 6: + if (bean.getLevel().equals("5")) { + cell.setCellValue("5"); + } + break; + case 7: + cell.setCellValue(bean.getHsName()); + break; + case 8: + cell.setCellValue(bean.getPartNum()); + break; + case 9: + cell.setCellValue(bean.getMaterial()); + break; + case 10: + //颜色 + if (bean.getWlBean()!=null) { + cell.setCellValue(bean.getWlBean().getColor()); + } + break; +// case 11: +// cell.setCellValue(wt.getCscs()); +// break; +// case 12: +// cell.setCellValue(wt.getLb2_sjjjgc()); +// break; + case 13: + cell.setCellValue(bean.getQuantity()); + break; + case 14: + cell.setCellValue(bean.getWeight()); + break; + case 20: + //批产物料编码 + if (bean.getWlBean()!=null) { + cell.setCellValue(bean.getWlBean().getProductCode()); + } + break; + + } + } + //System.out.println("奇数写excel-----------"+i); + //startRow = 2*i + 7; + //row = sheet.getRow((2*i)+6); + Row row2 = sheet.getRow(secondRow); + if (row2 == null) { + row2 = sheet.createRow(secondRow); + } + //System.out.println("secondrow="+secondRow); + Cell cell2 = null; + for (int j = 0; j < 24; j++) { + cell2 = row2.getCell(j); + if (row2.getCell(j) == null) { + + cell2 = row2.createCell(j); + cell2.setCellStyle(sheet.getRow(6).getCell(2).getCellStyle()); + } + switch (j) { + case 7: + cell2.setCellValue(bean.getGkName()); + break; + case 8: + cell2.setCellValue(bean.getGkNum()); + break; + + } + } + } + + //int shiftEndRow = 24+(2*list.size()-20); + int shiftRowCount = 2*list.size()-20; + //System.out.println("shiftEndRow="+shiftEndRow); + //System.out.println("shiftRowCount="+shiftRowCount); + sheet.shiftRows(26,sheet.getLastRowNum(),shiftRowCount); + for (int i = 10; i < list.size(); i++) { + PartBean bean = list.get(i); + + int FirstRow = 2*i+6; + int secondRow = 2*i+7; + // 创建每个单元格Cell,即列的数据 + Row row = sheet.getRow(FirstRow); + if (row == null) { + row = sheet.createRow(FirstRow); + } + + Cell cell = null; + for (int j = 0; j < 24; j++) { + cell = row.getCell(j); + if (row.getCell(j) == null) { + + cell = row.createCell(j); + cell.setCellStyle(sheet.getRow(6).getCell(2).getCellStyle()); + } + switch (j) { + case 0: + //cell.getCellStyle().setFont(BondFont); + cell.setCellValue(count++); + break; +// case 1: +// cell.setCellValue(wt.getLb2_jd()); +// break; + case 2: + if (bean.getLevel().equals("1")) { + cell.setCellValue("1"); + } + break; + case 3: + if (bean.getLevel().equals("2")) { + cell.setCellValue("2"); + } + break; + case 4: + if (bean.getLevel().equals("3")) { + cell.setCellValue("3"); + } + break; + case 5: + if (bean.getLevel().equals("4")) { + cell.setCellValue("4"); + } + break; + case 6: + if (bean.getLevel().equals("5")) { + cell.setCellValue("5"); + } + break; + case 7: + cell.setCellValue(bean.getHsName()); + //cell.getCellStyle().setFont(unBondFont); + break; + case 8: + cell.setCellValue(bean.getPartNum()); + //cell.getCellStyle().setFont(unBondFont); + break; + case 9: + cell.setCellValue(bean.getMaterial()); + //cell.getCellStyle().setFont(unBondFont); + break; + case 10: + //颜色 + if (bean.getWlBean()!=null) { + cell.setCellValue(bean.getWlBean().getColor()); + //cell.getCellStyle().setFont(unBondFont); + } + break; +// case 11: +// cell.setCellValue(wt.getCscs()); +// break; +// case 12: +// cell.setCellValue(wt.getLb2_sjjjgc()); +// break; + case 13: + cell.setCellValue(bean.getQuantity()); + //cell.getCellStyle().setFont(unBondFont); + break; + case 14: + cell.setCellValue(bean.getWeight()); + //cell.getCellStyle().setFont(unBondFont); + break; + case 20: + //批产物料编码 + if (bean.getWlBean()!=null) { + cell.setCellValue(bean.getWlBean().getProductCode()); + //cell.getCellStyle().setFont(unBondFont); + } + break; + + } + } + //System.out.println("奇数写excel-----------"+i); + //startRow = 2*i + 7; + //row = sheet.getRow((2*i)+6); + Row row2 = sheet.getRow(secondRow); + if (row2 == null) { + row2 = sheet.createRow(secondRow); + } + //System.out.println("secondrow="+secondRow); + Cell cell2 = null; + for (int j = 0; j < 24; j++) { + cell2 = row2.getCell(j); + if (row2.getCell(j) == null) { + + cell2 = row2.createCell(j); + cell2.setCellStyle(sheet.getRow(6).getCell(2).getCellStyle()); + } + switch (j) { + case 7: + cell2.setCellValue(bean.getGkName()); + //cell.getCellStyle().setFont(unBondFont); + break; + case 8: + cell2.setCellValue(bean.getGkNum()); + //cell.getCellStyle().setFont(unBondFont); + break; + + } + } + } + //System.out.println("count="+count); + //System.out.println("最后一行="+sheet.getLastRowNum()); + sheet.getRow(sheet.getLastRowNum()-1).setHeight((short) (25 * 25)); + sheet.getRow(sheet.getLastRowNum()).setHeight((short) (25 * 30)); + + //插入的行合并单元格 +// sheet.getRow(26).setHeight((short) (25 * 30)); +// sheet.getRow(27).setHeight((short) (25 * 30)); +// CellRangeAddress cellRange = new CellRangeAddress(26,26+1,0,0); +// sheet.addMergedRegion(cellRange); + for (int i = 26; i < sheet.getLastRowNum()-1; i=i+2) { + sheet.getRow(i).setHeight((short) (25 * 30)); + sheet.getRow(i+1).setHeight((short) (25 * 30)); + for (int j = 0; j < 24; j++) { + if (j==0) { + sheet.getRow(i).getCell(j).getCellStyle().setFont(BondFont); + //System.out.println("i---"+i+"---j"+j+"--设置加粗"); + CellRangeAddress cellRange = new CellRangeAddress(i,i+1,j,j); + sheet.addMergedRegion(cellRange); + + }else { + sheet.getRow(i).getCell(j).getCellStyle().setFont(unBondFont); + if (j == 7 || j==8) { + //第7、8列不需要合并 + continue; + }else { + + CellRangeAddress cellRange = new CellRangeAddress(i,i+1,j,j); + sheet.addMergedRegion(cellRange); + } + + } + + + } + } + resoleAddColumns(list, maxLevel, sheet, lastFilledColumn, unBondFont); + } + + + private static void writeDirect(List list, int maxLevel, Sheet sheet) { + int count = 1; +// int startRow = 6; + int lastFilledColumn = getLastFilledColumn(sheet); + //加粗的字体 + XSSFFont BondFont = (XSSFFont) sheet.getWorkbook().createFont(); + BondFont.setBold(true); + BondFont.setFontHeightInPoints((short)10); //字体大小只能是整数 + BondFont.setFontName("宋体"); //字体 + //removeColumn(sheet, 1); + //System.out.println("lastcolumn="+lastFilledColumn); + // sheet.shiftColumns(7, 8, 1); + + for (int i = 0; i < list.size(); i++) { + // 从第一行开始写入 + PartBean bean = list.get(i); + + int FirstRow = 2*i+6; + int secondRow = 2*i+7; + + // 创建每个单元格Cell,即列的数据 + Row row = sheet.getRow(FirstRow); + + if (row == null) { + row = sheet.createRow(FirstRow); + } +// int lastFilledColumn = getLastFilledColumn(sheet); + //System.out.println("lastFilledColumn="+lastFilledColumn); + + //System.out.println("startrow="+FirstRow); + Cell cell = null; + for (int j = 0; j < 22; j++) { + cell = row.getCell(j); +// Cell createCell = row.createCell(7); +// createCell.setCellValue("6"); + + if (row.getCell(j) == null) { + + cell = row.createCell(j); + cell.setCellStyle(sheet.getRow(6).getCell(2).getCellStyle()); + } + switch (j) { + case 0: + cell.setCellValue(count++); + + break; +// case 1: +// cell.setCellValue(wt.getLb2_jd()); +// break; + case 2: + if (bean.getLevel().equals("1")) { + cell.setCellValue("1"); + } + break; + case 3: + if (bean.getLevel().equals("2")) { + cell.setCellValue("2"); + } + break; + case 4: + if (bean.getLevel().equals("3")) { + cell.setCellValue("3"); + } + break; + case 5: + if (bean.getLevel().equals("4")) { + cell.setCellValue("4"); + } + break; + case 6: + if (bean.getLevel().equals("5")) { + cell.setCellValue("5"); + } + break; + case 7: + cell.setCellValue(bean.getHsName()); + + + break; + case 8: + cell.setCellValue(bean.getPartNum()); + break; + case 9: + cell.setCellValue(bean.getMaterial()); + break; + case 10: + //颜色 + if (bean.getWlBean()!=null) { + cell.setCellValue(bean.getWlBean().getColor()); + } + break; +// case 11: +// cell.setCellValue(wt.getCscs()); +// break; +// case 12: +// cell.setCellValue(wt.getLb2_sjjjgc()); +// break; + case 13: + cell.setCellValue(bean.getQuantity()); + break; + case 14: + cell.setCellValue(bean.getWeight()); + break; + case 20: + //批产物料编码 + if (bean.getWlBean()!=null) { + cell.setCellValue(bean.getWlBean().getProductCode()); + } + break; + + } + } + //System.out.println("奇数写excel-----------"+i); + //startRow = 2*i + 7; + //row = sheet.getRow((2*i)+6); + Row row2 = sheet.getRow(secondRow); + if (row2 == null) { + row2 = sheet.createRow(secondRow); + } + //System.out.println("secondrow="+secondRow); + Cell cell2 = null; + for (int j = 0; j < 22; j++) { + cell2 = row2.getCell(j); + if (row2.getCell(j) == null) { + + cell2 = row2.createCell(j); + cell2.setCellStyle(sheet.getRow(6).getCell(2).getCellStyle()); + } + switch (j) { + case 0: + //cell.setCellValue(i); + break; +// case 1: +// cell.setCellValue(wt.getLb2_jd()); +// break; +// case 2: +// if (bean.getLevel().equals("1")) { +// cell.setCellValue("1"); +// } +// break; +// case 3: +// if (bean.getLevel().equals("2")) { +// cell.setCellValue("2"); +// } +// break; +// case 4: +// if (bean.getLevel().equals("3")) { +// cell.setCellValue("3"); +// } +// break; +// case 5: +// if (bean.getLevel().equals("4")) { +// cell.setCellValue("4"); +// } +// break; +// case 6: +// if (bean.getLevel().equals("5")) { +// cell.setCellValue("5"); +// } +// break; + case 7: + cell2.setCellValue(bean.getGkName()); + break; + case 8: + cell2.setCellValue(bean.getGkNum()); + break; +// case 9: +// cell.setCellValue(bean.getMaterial()); +// break; +// case 10: +// //颜色 +// if (bean.getWlBean()!=null) { +// cell.setCellValue(bean.getWlBean().getColor()); +// } + // break; +// case 11: +// cell.setCellValue(wt.getCscs()); +// break; +// case 12: +// cell.setCellValue(wt.getLb2_sjjjgc()); +// break; +// case 13: +// cell.setCellValue(bean.getQuantity()); +// break; +// case 14: +// cell.setCellValue(bean.getWeight()); +// break; +// case 20: +// //批产物料编码 +// if (bean.getWlBean()!=null) { +// cell.setCellValue(bean.getWlBean().getProductCode()); +// } +// break; + + } + } + } + resoleAddColumns(list, maxLevel, sheet, lastFilledColumn, BondFont); + + //System.out.println("count="+count); + } +// private static void writeShift(List list, Sheet sheet, Map styleMap) { +// // TODO Auto-generated method stub +// for (int i = 0; i < 10; i++) { +// // 从第一行开始写入 +// PartBean wt = list.get(i); +// +// // 创建每个单元格Cell,即列的数据 +// Row row = sheet.getRow(i + 6); +// if (row == null) { +// row = sheet.createRow(i + 6); +// } +// Cell cell = null; +// for (int j = 2; j < 22; j++) { +// cell = row.getCell(j); +// if (row.getCell(j) == null) { +// +// cell = row.createCell(j); +// cell.setCellStyle(sheet.getRow(6).getCell(2).getCellStyle()); +// } +// switch (j - 2) { +// case 0: +// cell.setCellValue(wt.getLb2_tcsj()); +// break; +// case 1: +// cell.setCellValue(wt.getLb2_jd()); +// break; +// case 2: +// cell.setCellValue(wt.getLb2_tcr()); +// break; +// case 3: +// cell.setCellValue(wt.getLb2_wtms()); +// break; +// case 4: +// break; +// case 5: +// cell.setCellValue(wt.getLb2_yzcd()); +// break; +// case 6: +// cell.setCellValue(wt.getLb2_wtlb()); +// break; +// case 7: +// cell.setCellValue(wt.getZrr()); +// break; +// case 8: +// cell.setCellValue(wt.getZrbm()); +// break; +// case 9: +// cell.setCellValue(wt.getYyfx()); +// break; +// case 10: +// cell.setCellValue(wt.getLscs()); +// break; +// case 11: +// cell.setCellValue(wt.getCscs()); +// break; +// case 12: +// cell.setCellValue(wt.getLb2_sjjjgc()); +// break; +// case 13: +// cell.setCellValue(wt.getLb2_jg()); +// break; +// case 14: +// break; +// case 15: +// cell.setCellValue(wt.getJhjjsj()); +// break; +// case 16: +// cell.setCellValue(wt.getSjjjsj()); +// break; +// case 17: +// cell.setCellValue(wt.getLb2_zt()); +// break; +// case 18: +// cell.setCellValue(wt.getLb2_yzsm()); +// break; +// case 19: +// cell.setCellValue(wt.getLb2_bz()); +// break; +// } +// } +// } +// sheet.shiftRows(18 ,list.size()+26,list.size() - 10); +// for (int i = 2; i < list.size()+7; i++) { +// PartBean wt = list.get(i-7); +// +// // 创建每个单元格Cell,即列的数据 +// Row row = sheet.createRow(i); +// Cell cell = null; +// for (int j = 1; j <= 21; j++) { +// cell = row.createCell(j); +// switch (j) { +// case 1: +// cell.setCellStyle(styleMap.get("xhStyle")); +// cell.setCellValue(i-6+""); +// break; +// case 2: +// cell.setCellStyle(styleMap.get("fxrqStyle")); +// cell.setCellValue(wt.getLb2_tcsj()); +// break; +// case 3: +// cell.setCellStyle(styleMap.get("xmjdStyle")); +// cell.setCellValue(wt.getLb2_jd()); +// break; +// case 4: +// cell.setCellStyle(styleMap.get("tcrStyle")); +// cell.setCellValue(wt.getLb2_tcr()); +// break; +// case 5: +// cell.setCellStyle(styleMap.get("wtmsStyle")); +// cell.setCellValue(wt.getLb2_wtms()); +// break; +// case 6: +// cell.setCellStyle(styleMap.get("tpkStyle")); +// break; +// case 7: +// cell.setCellStyle(styleMap.get("yzcdStyle")); +// cell.setCellValue(wt.getLb2_yzcd()); +// break; +// case 8: +// cell.setCellStyle(styleMap.get("wtlbStyle")); +// cell.setCellValue(wt.getLb2_wtlb()); +// break; +// case 9: +// cell.setCellStyle(styleMap.get("zrrStyle")); +// cell.setCellValue(wt.getZrr()); +// break; +// case 10: +// cell.setCellStyle(styleMap.get("zrbmStyle")); +// cell.setCellValue(wt.getZrbm()); +// break; +// case 11: +// cell.setCellStyle(styleMap.get("yyfxStyle")); +// cell.setCellValue(wt.getYyfx()); +// break; +// case 12: +// cell.setCellStyle(styleMap.get("lscsStyle")); +// cell.setCellValue(wt.getLscs()); +// break; +// case 13: +// cell.setCellStyle(styleMap.get("cxcsStyle")); +// cell.setCellValue(wt.getCscs()); +// break; +// case 14: +// cell.setCellStyle(styleMap.get("sjjjgcStyle")); +// cell.setCellValue(wt.getLb2_sjjjgc()); +// break; +// case 15: +// cell.setCellStyle(styleMap.get("jgStyle")); +// cell.setCellValue(wt.getLb2_jg()); +// break; +// case 16: +// cell.setCellStyle(styleMap.get("xgbgwjStyle")); +// break; +// case 17: +// cell.setCellStyle(styleMap.get("jhjjsjStyle")); +// cell.setCellValue(wt.getJhjjsj()); +// break; +// case 18: +// cell.setCellStyle(styleMap.get("sjjjsjStyle")); +// cell.setCellValue(wt.getSjjjsj()); +// break; +// case 19: +// cell.setCellStyle(styleMap.get("ztStyle")); +// cell.setCellValue(wt.getLb2_zt()); +// break; +// case 20: +// cell.setCellStyle(styleMap.get("yzrqzStyle")); +// cell.setCellValue(wt.getLb2_yzsm()); +// break; +// case 21: +// cell.setCellStyle(styleMap.get("bzStyle")); +// cell.setCellValue(wt.getLb2_bz()); +// break; +// } +// } +// } +// } + + + private static void resoleAddColumns(List list, int maxLevel, Sheet sheet, int lastFilledColumn, + XSSFFont BondFont) { + //层级大于5时动态处理 excel列 + CellStyle thinStyle = sheet.getWorkbook().createCellStyle(); + //水平居中 + thinStyle.setAlignment(HorizontalAlignment.CENTER); + thinStyle.setVerticalAlignment(VerticalAlignment.CENTER); + thinStyle.setBorderBottom(BorderStyle.THIN); //下边框 + thinStyle.setBorderLeft(BorderStyle.THIN); //左边框 + thinStyle.setBorderRight(BorderStyle.THIN); //右边框 + thinStyle.setBorderTop(BorderStyle.THIN); //上边框 + CellStyle boldStyle = sheet.getWorkbook().createCellStyle(); + boldStyle.setVerticalAlignment(VerticalAlignment.CENTER); + boldStyle.setAlignment(HorizontalAlignment.CENTER); + boldStyle.setBorderBottom(BorderStyle.MEDIUM); //下边框 + boldStyle.setBorderLeft(BorderStyle.THIN); //左边框 + boldStyle.setBorderRight(BorderStyle.THIN); //右边框 + boldStyle.setBorderTop(BorderStyle.MEDIUM); //上边框 + + if (maxLevel > 5) { + System.out.println("层级超过5动态处理-----------"); + sheet.shiftColumns(7, lastFilledColumn, maxLevel - 5); + + for (int i = 0; i < sheet.getPhysicalNumberOfRows(); i++) { + Row row = sheet.getRow(i); + + for (int j = 7; j < maxLevel + 2; j++) { + sheet.setColumnWidth(j,(short) (25 * 21)); + if (row.getCell(j) == null) { + + //移动后的列新建单元格 + if (i==0 || i==1 || i==2 || i==3) { + Cell createCell = row.createCell(j); + System.out.println("新建单元格设置样式bold"+"----"+i+"-----"+j); + createCell.setCellStyle(boldStyle); + }else{ + Cell createCell = row.createCell(j); + System.out.println("新建单元格设置样式thin"+"----"+i+"-----"+j); + createCell.setCellStyle(thinStyle); + } + + } + } + } + + sheet.setColumnWidth(maxLevel + 2, 25 * 100); + sheet.setColumnWidth(maxLevel + 3, 25 * 120); + sheet.setColumnWidth(maxLevel + 4, 25 * 90); + for (int i = 0; i < list.size(); i++) { + // 从第一行开始写入 + PartBean bean = list.get(i); + + int FirstRow = 2*i+6; + + + // 创建每个单元格Cell,即列的数据 + Row row = sheet.getRow(FirstRow); + + if (row == null) { + row = sheet.createRow(FirstRow); + } + Cell cell = null; + + for (int j = 7; j < maxLevel + 2; j++) { + cell = row.getCell(j); + if (cell == null) { + + cell = row.createCell(j); + cell.setCellStyle(thinStyle); + //cell.setCellStyle(sheet.getRow(FirstRow).getCell(2).getCellStyle()); + } +// Cell createCell = row.createCell(7); +// createCell.setCellValue("6"); + //System.out.println("bean--"+bean +" level"+bean.getLevel()); + if (bean.getLevel().equals(Integer.toString(j-1))) { + cell.setCellValue(bean.getLevel()); + //CellStyle cellStyle = cell.getCellStyle(); + thinStyle.setFont(BondFont); + cell.setCellStyle(thinStyle); + //cell.getCellStyle().setFont(); + } + } + } + + + for (int i = 4; i < sheet.getLastRowNum()-2; i=i+2) { + for (int j = 7; j < maxLevel + 2; j++) { + //System.out.println("合并层级列-----"+"i="+i+"j="+j); + CellRangeAddress cellRange = new CellRangeAddress(i,i+1,j,j); + sheet.addMergedRegion(cellRange); + } + } + + + removeMergedRegion(sheet, 2); + removeMergedRegion(sheet, 3); + removeMergedRegion(sheet, 4,2); + removeMergedRegion(sheet, sheet.getLastRowNum()-1,0); + removeMergedRegion(sheet, sheet.getLastRowNum(),2); + for (int i = 7; i <= maxLevel + 1 ; i++) { + removeMergedRegion(sheet, 4,i); + removeMergedRegion(sheet, 5,i); + } + + // removeMergedRegion + CellRangeAddress cellRange = new CellRangeAddress(2,3,0,maxLevel+2); + CellRangeAddress cellRange2 = new CellRangeAddress(2,3,maxLevel+3,maxLevel+8); + CellRangeAddress cellRange3 = new CellRangeAddress(2,3,maxLevel+9,maxLevel+18); + + CellRangeAddress cellRange4 = new CellRangeAddress(4,5,2,maxLevel+1); + CellRangeAddress cellRange5 = new CellRangeAddress(sheet.getLastRowNum()-1,sheet.getLastRowNum()-1,0,maxLevel+1); + CellRangeAddress cellRange6 = new CellRangeAddress(sheet.getLastRowNum(),sheet.getLastRowNum(),2,maxLevel+1); + sheet.addMergedRegion(cellRange); + sheet.addMergedRegion(cellRange2); + sheet.addMergedRegion(cellRange3); + sheet.addMergedRegion(cellRange4); + sheet.addMergedRegion(cellRange5); + sheet.addMergedRegion(cellRange6); + } + } + + + private static int getLastFilledColumn(Sheet sheet) { + int result = 0; + for (Row row : sheet) { + if (row.getLastCellNum() > result) result = row.getLastCellNum(); + } + return result; + } +//public static Workbook create(InputStream in) throws IOException, InvalidFormatException { +// if (!in.markSupported()) { +// in = new PushbackInputStream(in, 8); +// } +//// if (POIFSFileSystem.hasPOIFSHeader(in)) { +//// return new HSSFWorkbook(in); +//// } +// if (POIXMLDocument.hasOOXMLHeader(in)) { +// return new XSSFWorkbook(OPCPackage.open(in)); +// } +// throw new IllegalArgumentException("你的excel版本目前poi解析不了"); +// +//} + private static void removeMergedRegion(Sheet sheet,int rowIndex) + { + int MergedCount = sheet.getNumMergedRegions(); + for (int i = MergedCount - 1; i >= 0; i--) + { +/** +CellRangeAddress对象属性有:FirstColumn,FirstRow,LastColumn,LastRow 进行操作 取消合并单元格 +**/ CellRangeAddress mergedRegion = sheet.getMergedRegion(i); + + if (mergedRegion.getFirstRow() == rowIndex) + { + sheet.removeMergedRegion(i); + } + } + +} +private static void removeMergedRegion(Sheet sheet,int rowIndex,int columnIndex) + { + int MergedCount = sheet.getNumMergedRegions(); + for (int i = MergedCount - 1; i >= 0; i--) + { +/** +CellRangeAddress对象属性有:FirstColumn,FirstRow,LastColumn,LastRow 进行操作 取消合并单元格 +**/ CellRangeAddress mergedRegion = sheet.getMergedRegion(i); + + if (mergedRegion.getFirstRow() == rowIndex && mergedRegion.getFirstColumn() == columnIndex) + { + sheet.removeMergedRegion(i); + } + } + +} +} diff --git a/src/com/connor/hs2/plm/projectmanage/cpwlqd/LogUtil.java b/src/com/connor/hs2/plm/projectmanage/cpwlqd/LogUtil.java new file mode 100644 index 0000000..aff1860 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/cpwlqd/LogUtil.java @@ -0,0 +1,61 @@ +package com.connor.hs2.plm.projectmanage.cpwlqd; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class LogUtil +{ + /** + * 将信息写入到日志 + * @throws IOException + */ + public static boolean writeLog(String info) throws IOException{ + String content=info(info); + File fileName = new File(System.getProperty("java.io.tmpdir")+"/cpwlqd/log.log"); + if (!fileName.exists()) { + if (!fileName.getParentFile().exists()) { + fileName.getParentFile().mkdirs(); + } + fileName.createNewFile(); + } + RandomAccessFile mm = null; + boolean flag = false; + FileOutputStream o = null; + try { + o = new FileOutputStream(fileName,true); + o.write(content.getBytes("utf-8")); + o.close(); + flag = true; + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (mm != null) { + try { + mm.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + } + return flag; + } + + public static String info(String info){ + StringBuffer buffer=new StringBuffer(); + Date date = new Date(); + SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String d = sd.format(date)+"\r\n"; + buffer.append(d); + + //buffer.append(info).append("\r\n"); + buffer.append(info).append("\n"); +// buffer.append("错误内容为:").append(ErrorContent).append("\r\n"); + buffer.append("\r\n"); + return buffer.toString(); + } +} \ No newline at end of file diff --git a/src/com/connor/hs2/plm/projectmanage/cpwlqd/PartBean.java b/src/com/connor/hs2/plm/projectmanage/cpwlqd/PartBean.java new file mode 100644 index 0000000..2801e04 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/cpwlqd/PartBean.java @@ -0,0 +1,80 @@ +package com.connor.hs2.plm.projectmanage.cpwlqd; + +import java.util.List; + +public class PartBean { + private String partNum; + private String level; + private String hsName; + private String gkName; + private String gkNum; + private String material; + private String quantity; + private String weight; + private WLBean wlBean; + public String getLevel() { + return level; + } + public void setLevel(String level) { + this.level = level; + } + public WLBean getWlBean() { + return wlBean; + } + public void setWlBean(WLBean wlBean) { + this.wlBean = wlBean; + } + public String getHsName() { + return hsName; + } + public void setHsName(String hsName) { + this.hsName = hsName; + } + public String getGkName() { + return gkName; + } + public void setGkName(String gkName) { + this.gkName = gkName; + } + public String getPartNum() { + return partNum; + } + public void setPartNum(String partNum) { + this.partNum = partNum; + } + public String getGkNum() { + return gkNum; + } + public void setGkNum(String gkNum) { + this.gkNum = gkNum; + } + public String getMaterial() { + return material; + } + public void setMaterial(String material) { + this.material = material; + } + public String getQuantity() { + return quantity; + } + public void setQuantity(String quantity) { + this.quantity = quantity; + } + public String getWeight() { + return weight; + } + public void setWeight(String weight) { + this.weight = weight; + } + @Override + public String toString() { + return "PartBean [partNum=" + partNum + ", level=" + level + ", hsName=" + hsName + ", gkName=" + gkName + + ", gkNum=" + gkNum + ", material=" + material + ", quantity=" + quantity + ", weight=" + weight + + ", wlBean=" + wlBean + "]"; + } + + + + + +} diff --git a/src/com/connor/hs2/plm/projectmanage/cpwlqd/WLBean.java b/src/com/connor/hs2/plm/projectmanage/cpwlqd/WLBean.java new file mode 100644 index 0000000..57414d0 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/cpwlqd/WLBean.java @@ -0,0 +1,41 @@ +package com.connor.hs2.plm.projectmanage.cpwlqd; + +public class WLBean { + private String productCode; + private String color; + private String level; + private String quantity; + public String getProductCode() { + return productCode; + } + public void setProductCode(String productCode) { + this.productCode = productCode; + } + + public String getColor() { + return color; + } + public void setColor(String color) { + this.color = color; + } + public String getLevel() { + return level; + } + public void setLevel(String level) { + this.level = level; + } + public String getQuantity() { + return quantity; + } + public void setQuantity(String quantity) { + this.quantity = quantity; + } + @Override + public String toString() { + return "WLBean [productCode=" + productCode + ", color=" + color + ", level=" + level + ", quantity=" + quantity + + "]"; + } + + + +} diff --git a/src/com/connor/hs2/plm/projectmanage/handlers/SampleHandler.java b/src/com/connor/hs2/plm/projectmanage/handlers/SampleHandler.java new file mode 100644 index 0000000..f1b418a --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/handlers/SampleHandler.java @@ -0,0 +1,21 @@ +package com.connor.hs2.plm.projectmanage.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.handlers.HandlerUtil; +import org.eclipse.jface.dialogs.MessageDialog; + +public class SampleHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); + MessageDialog.openInformation( + window.getShell(), + "Projectmanage", + "Hello, Eclipse world"); + return null; + } +} diff --git a/src/com/connor/hs2/plm/projectmanage/khzl/KHZLAction.java b/src/com/connor/hs2/plm/projectmanage/khzl/KHZLAction.java new file mode 100644 index 0000000..d9f359c --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/khzl/KHZLAction.java @@ -0,0 +1,28 @@ +package com.connor.hs2.plm.projectmanage.khzl; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +public class KHZLAction extends AbstractAIFAction{ + private AbstractAIFApplication app; + + public KHZLAction(AbstractAIFApplication app, String arg1) { + super(app, arg1); + // TODO Auto-generated constructor stub + this.app = app; + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + KHZLCommad command = new KHZLCommad(app); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/khzl/KHZLCommad.java b/src/com/connor/hs2/plm/projectmanage/khzl/KHZLCommad.java new file mode 100644 index 0000000..a506bd9 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/khzl/KHZLCommad.java @@ -0,0 +1,66 @@ +package com.connor.hs2.plm.projectmanage.khzl; + +import java.util.HashMap; +import java.util.Map; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonOpeartion; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; + +public class KHZLCommad extends AbstractAIFCommand{ + private AbstractAIFApplication app; + + public KHZLCommad(AbstractAIFApplication app) { + super(); + this.app = app; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + super.executeModal(); + Map map=new HashMap(); + if (app.getTargetComponent()!=null && (app.getTargetComponent().getType().equals("HS2_GGSQRevision") + || app.getTargetComponent().getType().equals("HS2_GGTZRevision") + || app.getTargetComponent().getType().equals("HS2_KXXFXBGPGRevision") + || app.getTargetComponent().getType().equals("HS2_GGRWDItemRevision") + || app.getTargetComponent().getType().equals("HS2_YZBGItemRevision") + || app.getTargetComponent().getType().equals("HS2_RequestRevision") + || app.getTargetComponent().getType().equals("HS2_NoticeRevision") + || app.getTargetComponent().getType().equals("HS2_FeasibilityARevision") + || app.getTargetComponent().getType().equals("HS2_ChangeTaskRevision") + || app.getTargetComponent().getType().equals("HS2_VerifyRevision") + )) { + TCComponentItemRevision target = (TCComponentItemRevision) app.getTargetComponent(); + String id = target.getProperty("item_id"); + String name = target.getProperty("object_name"); + map.put("item_id", id); + map.put("object_name", name); + String name1; + TCProperty[] allTCProperties = target.getAllTCProperties(); + for (int i = 0; i < allTCProperties.length; i++) { + TCProperty tcProperty = allTCProperties[i]; + name1 = tcProperty.getPropertyName(); + + if (name1.startsWith("hs2_")) { + map.put(name1, tcProperty.getPropertyValue()); + } + + if (name1.equals("hs2_changewilling") || name1.equals("hs2_projectstage") || name1.equals("hs2_changetype")) { + map.put(name1, tcProperty.getDisplayValue()); + } + if (name1.equals("hs2_stock")) { + map.put(name1, tcProperty.getBoolValue()); + } + } + } + KHZLDialog dialog = new KHZLDialog(app,map); + new Thread(dialog).start(); + + } + + +} diff --git a/src/com/connor/hs2/plm/projectmanage/khzl/KHZLDialog.java b/src/com/connor/hs2/plm/projectmanage/khzl/KHZLDialog.java new file mode 100644 index 0000000..44a4937 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/khzl/KHZLDialog.java @@ -0,0 +1,147 @@ +package com.connor.hs2.plm.projectmanage.khzl; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentPseudoFolder; +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 KHZLDialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private JTextField nameText; + private JButton createButton; + private JButton cancelButton; + + public KHZLDialog(AbstractAIFApplication app, Map map) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + } + + @Override + public void run() { + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void init() throws TCException { + + JPanel rootPanel = new JPanel(new PropertyLayout()); + JPanel namePanel = new JPanel(new PropertyLayout()); + JLabel label = new JLabel("文件名称"); + nameText = new JTextField(11); + nameText.setText("客户资料"); + namePanel.add("1.1.left.top", label); + namePanel.add("1.2.left.top", nameText); + createButton = new JButton("创建"); + createButton.addActionListener(this); + cancelButton = new JButton("取消"); + cancelButton.addActionListener(this); + JPanel buttomPanel = new JPanel(new PropertyLayout()); + buttomPanel.add("1.1.center.left", createButton); + buttomPanel.add("1.2.center.left", cancelButton); + + rootPanel.add("1.1.left.top", namePanel); + rootPanel.add("2.1.left.top", new JLabel("")); + rootPanel.add("3.1.center.left", buttomPanel); + this.setTitle("新建客户资料"); + this.setLayout(new BorderLayout(10, 0)); + this.setPreferredSize(new Dimension(200, 100)); + // panel.add(panel1, BorderLayout.WEST); + // panel.add(panel6, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.CENTER); + this.pack(); + this.setVisible(true); + this.setLocationRelativeTo(null); + this.setResizable(false);// 不可变动窗口大小 + + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if (e.getSource().equals(cancelButton)) { + this.dispose(); + } else if (e.getSource().equals(createButton)) { + + try { + if (nameText.getText().trim().equals("")) { + MessageBox.post("文件名称为空!!", "提示", 2); + return; + } + TCComponentItemType type = (TCComponentItemType) session.getTypeComponent("HS2_CustomerInfo"); + String newID = type.getNewID(); + String newRev = type.getNewRev(null); + String name = nameText.getText(); + TCComponentItem item = type.create(newID, newRev, "HS2_CustomerInfo", name, "", null); + + if (item != null) { + if (app.getTargetComponent() != null + && app.getTargetComponent().getType().equals("ProjectSmartFolder")) { + TCComponent ref = ((TCComponent) app.getTargetComponent()) + .getReferenceProperty("owning_project"); + if (ref != null) { + TCComponentProject pro = (TCComponentProject) ref; + pro.assignToProject(new TCComponent[] { item }); + } + } else if (app.getTargetComponent() != null + && app.getTargetComponent() instanceof TCComponentFolder) { + ((TCComponentFolder) app.getTargetComponent()).add("contents", item); + } else if (app.getTargetComponent() != null + && app.getTargetComponent() instanceof TCComponentProject) { + TCComponentProject pro = (TCComponentProject) app.getTargetComponent(); + pro.assignToProject(new TCComponent[] { item }); + }else if (app.getTargetComponent().getType().equals("PseudoFolder")) { +// String type1=comp.getType(); +// System.out.println(type1); +// if(type1.equals("PseudoFolder")) { + TCComponentPseudoFolder folder=(TCComponentPseudoFolder)app.getTargetComponent(); + TCComponent owningComponent = folder.getOwningComponent(); +// String stringProperty = folder.getStringProperty("object_string"); + String stringProperty2 = folder.getStringProperty("property_name"); + System.out.println("stringProperty2"+stringProperty2); + owningComponent.add(stringProperty2, item); + + +// } + } + else { + session.getUser().getNewStuffFolder().add("contents", item); + } + + MessageBox.post("客户资料对象创建完成!", "提示", 2); + this.dispose(); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + MessageBox.post("创建失败,请联系管理员!", "警告", MessageBox.WARNING); + e1.printStackTrace(); + } + } + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/khzl/KHZLHandler.java b/src/com/connor/hs2/plm/projectmanage/khzl/KHZLHandler.java new file mode 100644 index 0000000..8b3e68c --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/khzl/KHZLHandler.java @@ -0,0 +1,28 @@ +package com.connor.hs2.plm.projectmanage.khzl; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.hs2.plm.projectmanage.assigntask.AssignPersonAction; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class KHZLHandler extends AbstractHandler{ + + private TCSession session ; + private TCComponentScheduleTask schedule; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + KHZLAction action = new KHZLAction(app, null); + new Thread(action).start(); + return null; + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/problemstructured/ProblemBean.java b/src/com/connor/hs2/plm/projectmanage/problemstructured/ProblemBean.java new file mode 100644 index 0000000..19512b0 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/problemstructured/ProblemBean.java @@ -0,0 +1,123 @@ +package com.connor.hs2.plm.projectmanage.problemstructured; + +import java.util.Date; + +public class ProblemBean { + private String wtd; + private String cx; + private String tcr; + private String projectName; + private String gbyy; + private String zgcs; + private String fzr; + private String startDate; + private String mbwcDate; + private String sjwcDate; + private String scwcDate; + private String zt; + private String wtdj; + private String khmc; + private String xmh; + + + public String getKhmc() { + return khmc; + } + public void setKhmc(String khmc) { + this.khmc = khmc; + } + public String getXmh() { + return xmh; + } + public void setXmh(String xmh) { + this.xmh = xmh; + } + public String getWtd() { + return wtd; + } + public void setWtd(String wtd) { + this.wtd = wtd; + } + public String getCx() { + return cx; + } + public void setCx(String cx) { + this.cx = cx; + } + public String getTcr() { + return tcr; + } + public void setTcr(String tcr) { + this.tcr = tcr; + } + public String getProjectName() { + return projectName; + } + public void setProjectName(String projectName) { + this.projectName = projectName; + } + public String getGbyy() { + return gbyy; + } + public void setGbyy(String gbyy) { + this.gbyy = gbyy; + } + public String getZgcs() { + return zgcs; + } + public void setZgcs(String zgcs) { + this.zgcs = zgcs; + } + public String getFzr() { + return fzr; + } + public void setFzr(String fzr) { + this.fzr = fzr; + } + public String getStartDate() { + return startDate; + } + public void setStartDate(String startDate) { + this.startDate = startDate; + } + public String getMbwcDate() { + return mbwcDate; + } + public void setMbwcDate(String mbwcDate) { + this.mbwcDate = mbwcDate; + } + public String getSjwcDate() { + return sjwcDate; + } + public void setSjwcDate(String sjwcDate) { + this.sjwcDate = sjwcDate; + } + public String getScwcDate() { + return scwcDate; + } + public void setScwcDate(String scwcDate) { + this.scwcDate = scwcDate; + } + public String getZt() { + return zt; + } + public void setZt(String zt) { + this.zt = zt; + } + public String getWtdj() { + return wtdj; + } + public void setWtdj(String wtdj) { + this.wtdj = wtdj; + } + @Override + public String toString() { + return "ProblemBean [wtd=" + wtd + ", cx=" + cx + ", tcr=" + tcr + ", projectName=" + projectName + ", gbyy=" + + gbyy + ", zgcs=" + zgcs + ", fzr=" + fzr + ", startDate=" + startDate + ", mbwcDate=" + mbwcDate + + ", sjwcDate=" + sjwcDate + ", scwcDate=" + scwcDate + ", zt=" + zt + ", wtdj=" + wtdj + "]"; + } + + + + +} diff --git a/src/com/connor/hs2/plm/projectmanage/problemstructured/ProblemDialog.java b/src/com/connor/hs2/plm/projectmanage/problemstructured/ProblemDialog.java new file mode 100644 index 0000000..25b2a8b --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/problemstructured/ProblemDialog.java @@ -0,0 +1,1351 @@ +package com.connor.hs2.plm.projectmanage.problemstructured; + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FileDialog; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.Label; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.ScrollPaneConstants; +import javax.swing.border.Border; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +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.sl.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +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.jdesktop.swingx.JXDatePicker; + +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.RCPPortal; +import com.teamcenter.rac.common.actions.NewAddressListAction; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +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.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +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.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +import com.connor.hs2.plm.projectmanage.utils.*; + +public class ProblemDialog extends AbstractAIFDialog { + private AbstractAIFApplication app; + private TCSession session; + //private JTextField showDate1; + private JTextField showDate2; + private TablePageController pageController; + private JTextField projectNameText; + private JTextField wtdText; + private JTextField cxText; + private JTextField tcrText; + private JTextField fzrText; + private JTextField ztText; + + private JTextField khmcText; + private JTextField xmhText; + + //private JTextField wtdjText; + private JXDatePicker startDatePicker; + private JXDatePicker mbwcsjDatePicker; + private JXDatePicker sjwcrqDatePicker; + private JXDatePicker scgxsjDatePicker; + private DefaultTableModel model; + private JTable table; + private List wtList; + private JComboBox wtdjBox; + public ProblemDialog(AbstractAIFApplication app) { + // TODO Auto-generated constructor stub + super(); + this.app = app; + this.session = (TCSession) app.getSession(); + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + init(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void init() throws TCException { +// ProblemDialog dialog = this; + this.setLayout(new BorderLayout()); + JFrame frame = new JFrame(); + //frame.setPreferredSize(new Dimension(1020,660)); + //frame.setSize(980,600); + JPanel rootPanel = new JPanel(new BorderLayout(5,5)); + //rootPanel.setPreferredSize(new Dimension(980,500)); + JPanel searchConditionPanel = new JPanel(new GridLayout(3,8,5,5)); + searchConditionPanel.setPreferredSize(new Dimension(980,100)); + JLabel label1 = new JLabel("项目名称 "); + JLabel label2 = new JLabel("问题点"); + JLabel label3 = new JLabel("车型 "); + JLabel label4 = new JLabel("提出人 "); + JLabel label5 = new JLabel("负责人"); + JLabel label6 = new JLabel("开始日期"); + JLabel label7 = new JLabel("目标完成日期"); + JLabel label8 = new JLabel("实际完成日期 "); + JLabel label9 = new JLabel("上次更新时间"); + JLabel label10 = new JLabel("状态"); + JLabel label11 = new JLabel("问题等级"); + JLabel label12 = new JLabel("客户名称"); + JLabel label13 = new JLabel("项目号"); + + projectNameText = new JTextField(10); + wtdText = new JTextField(10); + cxText = new JTextField(10); + tcrText = new JTextField(10); + fzrText = new JTextField(10); + ztText = new JTextField(10); + khmcText = new JTextField(10); + xmhText = new JTextField(10); + //wtdjText = new JTextField(10); + wtdjBox = new JComboBox(); + LovUtils.addLovToBox("HS2_ProblemLevel_LOV", wtdjBox); + wtdjBox.setSelectedIndex(-1); + startDatePicker = new JXDatePicker(); + startDatePicker.setFormats(new String[] {"yyyy-MM-dd"}); + mbwcsjDatePicker = new JXDatePicker(); + mbwcsjDatePicker.setFormats(new String[] {"yyyy-MM-dd"}); + sjwcrqDatePicker = new JXDatePicker(); + sjwcrqDatePicker.setFormats(new String[] {"yyyy-MM-dd"}); + scgxsjDatePicker = new JXDatePicker(); + scgxsjDatePicker.setFormats(new String[] {"yyyy-MM-dd"}); + + JButton search = new JButton("查询"); + JButton export = new JButton("导出"); + //JPanel searchConditionPanel1 = new JPanel(new GridLayout(1,8,5,5)); + searchConditionPanel.add(label1); + searchConditionPanel.add(projectNameText); + searchConditionPanel.add(label2); + searchConditionPanel.add(wtdText); + searchConditionPanel.add(label3); + searchConditionPanel.add(cxText); + searchConditionPanel.add(label4); + searchConditionPanel.add(tcrText); + + searchConditionPanel.add(label5); + searchConditionPanel.add(fzrText); + searchConditionPanel.add(label6); + searchConditionPanel.add(startDatePicker); + searchConditionPanel.add(label7); + searchConditionPanel.add(mbwcsjDatePicker); + searchConditionPanel.add(label8); + searchConditionPanel.add(sjwcrqDatePicker); + + searchConditionPanel.add(label9); + searchConditionPanel.add(scgxsjDatePicker); + searchConditionPanel.add(label10); + searchConditionPanel.add(ztText); + searchConditionPanel.add(label11); + searchConditionPanel.add(wtdjBox); + + searchConditionPanel.add(label12); + searchConditionPanel.add(khmcText); + searchConditionPanel.add(label13); + searchConditionPanel.add(xmhText); + + searchConditionPanel.add(search); + searchConditionPanel.add(export); +// +// searchConditionPanel.add(searchConditionPanel1,BorderLayout.NORTH); +// searchConditionPanel.add(searchConditionPanel2,BorderLayout.CENTER); +// searchConditionPanel.add(searchConditionPanel3,BorderLayout.SOUTH); +// JPanel panel1 = new JPanel(new GridLayout(18, 1, 10, 2)); +// JPanel panel2 = new JPanel(); +// JPanel panel4 = new JPanel(); +// +// 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(10); +// showDate2 = new JTextField(10); +// dateChooser1.register(showDate1); +// dateChooser2.register(showDate2); +// +// panel1.add(new Label("创建日期")); +// panel2.add(new Label("起始日期:")); +// panel2.add(showDate1); +// panel4.add(new Label("截止日期:")); +// panel4.add(showDate2); +// panel1.add(panel2); +// panel1.add(panel4); +// +// panel1.add(new Label("产品分类")); +// JComboBox cpflBox = setLOV("Fnd0ProjectCategories"); +// panel1.add(cpflBox); +// panel1.add(new Label("项目阶段")); +// JComboBox xmjdB = setLOV("SB6_XMJD"); +// panel1.add(xmjdB); +// panel1.add(new Label("产品状态")); +// JComboBox cpztBox = setLOV("SB6_CPZT"); +// panel1.add(cpztBox); +// panel1.add(new Label("问题类型")); +// JComboBox wtlxBox = setLOV("SB6_WTLX"); +// panel1.add(wtlxBox); +// panel1.add(new Label("问题等级")); +// JComboBox wtdjBox = setLOV("SB6_WTDJ"); +// panel1.add(wtdjBox); +// +// panel1.add(new Label("项目ID")); +// JTextField projectId = new JTextField(); +// panel1.add(projectId); +// +// panel1.add(new Label("是否发布")); +// JComboBox isTrue = new JComboBox<>(); +// isTrue.addItem(""); +// isTrue.addItem("Y"); +// isTrue.addItem("N"); +// panel1.add(isTrue); +// +// +// +// JPanel panel3 = new JPanel(new FlowLayout()); +// panel3.add(search); +// panel3.add(export); +// panel1.add(panel3); + + //String[] property = new String[] { "问题点", "车型", "提出人", "项目名称", "根本原因", "整改措施", "负责人", "开始日期", "目标完成日期", "实际完成日期", +// "实际完成日期","上次更新时间", "状态", "问题等级"}; + + String[] property = new String[] { "问题点", "车型", "客户名称","项目号","提出人", "项目名称", "根本原因", "整改措施", "负责人", + "开始日期", "目标完成日期", "实际完成日期","上次更新时间", "状态","问题等级"}; + String[][] data = new String[][] {}; + + model = new DefaultTableModel(data, property); + table = new JTable(model) { + public boolean isCellEditable(int row, int column) { + return false;// 表格不允许被编辑 + } + }; +// // 设置表头颜色 +// DefaultTableCellRenderer cellRenderer = new DefaultTableCellRenderer(); +// cellRenderer.setBackground(Color.lightGray); +// table.getTableHeader().setResizingAllowed(true); + //table.getTableHeader().setPreferredSize(new Dimension(980, 30)); + + table.getTableHeader().setBackground(Color.lightGray); +// Font font = new Font(Font.DIALOG, Font.PLAIN, 30); +// table.getTableHeader().setFont(font); + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer();// 自动换行 + table.setDefaultRenderer(Object.class, renderer); + +// /** +// * 循环修改表头列 +// */ +// for (int i = 0; i < 28; i++) { +// +// // i是表头的列 +// TableColumn column = table.getTableHeader().getColumnModel().getColumn(i); +// column.setHeaderRenderer(cellRenderer); +// +// // 表头文字居中 +// cellRenderer.setHorizontalAlignment(cellRenderer.CENTER); +// +// } + table.setRowHeight(25); + table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); + table.getColumnModel().getColumn(9).setPreferredWidth(105); + table.getColumnModel().getColumn(10).setPreferredWidth(105); + table.getColumnModel().getColumn(11).setPreferredWidth(105); + table.getColumnModel().getColumn(12).setPreferredWidth(105); + JPanel tablePanel = new JPanel(new BorderLayout()); + + JScrollPane scrollPane = new JScrollPane(table); + tablePanel.add(scrollPane,BorderLayout.CENTER); + //scrollPane.setViewportView(table); + //scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + +// Button firstPage = new Button("首页"); +// JButton prePage = new JButton("上一页"); +// JButton nextPage = new JButton("下一页"); +// Button lastPage = new Button("尾页"); +// JTextField nowPage = new JTextField(2); +// JLabel totalPageLabel = new JLabel(); + + search.addActionListener(new ActionListener() { + + + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + try { + for (int i = table.getRowCount() - 1; i > -1; i--) { + model.removeRow(i); + } + System.out.println("开始查询"); + TCComponent[] components = searchProb(projectNameText, wtdText, cxText, tcrText, fzrText, startDatePicker, + mbwcsjDatePicker, sjwcrqDatePicker, scgxsjDatePicker,ztText,wtdjBox,khmcText,xmhText); + if (components == null ) { + //System.out.println("没有找到对象"); + MessageBox.post("未查询到信息!!","提示",2); + return ; + } + for (TCComponent component : components) { + System.out.println("查到的对象:" + component.toString()); + } + String[][] datas = reloadData(components); + System.out.println("查到的数据:"); + int i = 1; + for (String[] data : datas) { + System.out.println("===============第" + i + "行数据=================="); + for (String d : data) { + System.out.println("[" + d + "]"); + } + i++; + } +// System.out.println("数据刷新"); + wtList = reloadTable(table, datas); +// String nowPageStr = nowPage.getText() != null ? nowPage.getText() : ""; +// if (nowPageStr.length() > 0) { +// pageController.setTablePage(Integer.parseInt(nowPageStr)); +// } +// nowPage.setText(pageController.getTablePage() + 1 + ""); +// totalPageLabel.setText("/" + pageController.getTotalTablePage() + "页"); +// System.out.println("数据刷新完成"); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + + }); + + export.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + + // TODO Auto-generated method stub + //jButtonActionPerformed(e, table, frame); + if (wtList!=null && wtList.size()>0) { + boolean isTrue = export(wtList); + if (isTrue) { + MessageBox.post("导出成功!!","提示",2); + }else { + MessageBox.post("导出失败!!","提示",MessageBox.WARNING); + } + }else { + MessageBox.post("导出的信息为空,请重新查询!!","提示",2); + return ; + } + } + + + }); + +// firstPage.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// pageController.setTablePage(0); +// nowPage.setText(pageController.getTablePage() + 1 + ""); +// updateTabUI(table); +// } +// }); +// lastPage.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// pageController.setTablePage(pageController.getTotalTablePage() - 1); +// nowPage.setText(pageController.getTablePage() + 1 + ""); +// updateTabUI(table); +// } +// }); +// prePage.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// if (pageController.getTablePage() > 0) { +// pageController.setTablePage(pageController.getTablePage() - 1); +// nowPage.setText(pageController.getTablePage() + 1 + ""); +// updateTabUI(table); +// } +// } +// }); +// nextPage.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// if (pageController!=null) { +// if (pageController.getTablePage() < pageController.getTotalTablePage() - 1) { +// pageController.setTablePage(pageController.getTablePage() + 1); +// nowPage.setText(pageController.getTablePage() + 1 + ""); +// updateTabUI(table); +// } +// } +// } +// }); +// JPanel panel5 = new JPanel(new FlowLayout(FlowLayout.CENTER)); +// panel5.add(firstPage); +// panel5.add(prePage); +// panel5.add(nowPage); +// panel5.add(totalPageLabel); +// panel5.add(nextPage); +// panel5.add(lastPage); +// JPanel panel6 = new JPanel(new BorderLayout()); +// panel6.add(scrollPane, BorderLayout.CENTER); +// panel6.add(panel5, BorderLayout.SOUTH); + + rootPanel.add(searchConditionPanel,BorderLayout.NORTH); + rootPanel.add(tablePanel,BorderLayout.CENTER); + frame.setTitle("问题结构化管理"); + frame.setLayout(new BorderLayout(10, 0)); + frame.setSize(1000, 450); + //panel.add(panel1, BorderLayout.WEST); + //panel.add(panel6, BorderLayout.CENTER); + frame.add(rootPanel, BorderLayout.CENTER); + //frame.pack(); + frame.setVisible(true); + frame.setLocationRelativeTo(null); + this.setResizable(false);//不可变动窗口大小 +// this.centerToScreen(); + } + + protected boolean export(List wtList) { + // TODO Auto-generated method stub + File tempFile = getSXX(); + if (tempFile==null) { + return false; + } + File reportFile_Sub = null; + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int returnVal = fileChooser.showOpenDialog(fileChooser); + if (returnVal == JFileChooser.APPROVE_OPTION) { + String dir = fileChooser.getSelectedFile().getAbsolutePath();// 这个就是你选择的文件夹的路径 + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = sdf.format(date); + reportFile_Sub = new File(dir + "\\" + "问题综合看板" + time + ".xls"); + reportFile_Sub.delete(); + tempFile.renameTo(reportFile_Sub); + } + if (reportFile_Sub == null) { + return false; + } + final File reportFile = reportFile_Sub; + + FileInputStream fileIn = null; + FileOutputStream fileOut = null; + try { + fileIn = new FileInputStream(reportFile); + HSSFWorkbook sworkbook = new HSSFWorkbook(fileIn); + //sworkbook = new SXSSFWorkbook(new XSSFWorkbook(fileIn), 100); + HSSFSheet sheet = sworkbook.getSheetAt(0); + + HSSFRow row3 = sheet.getRow(3); + if(row3.getCell(10) == null) { + + Cell cell8 = row3.createCell(10); + cell8.setCellValue(wtList.size()); + + }else { + row3.getCell(10).setCellValue(wtList.size()); + } + + + if(row3.getCell(12) == null) { + + Cell cell10 = row3.createCell(12); + cell10.setCellValue(wtList.size()); + + }else { + row3.getCell(12).setCellValue(wtList.size()); + } + + + + if (wtList.size() <= 40) { + writeDirect(wtList, sheet); + }else { + writeShift(wtList, sheet); + } + + fileOut = new FileOutputStream(reportFile.getPath()); + sworkbook.write(fileOut); + fileOut.flush(); + + return true; + } + catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + return false; + }finally { + if (fileOut != null) { + try { + fileOut.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (fileIn != null) { + try { + fileIn.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + private void writeShift(List wtList, HSSFSheet sheet) { + // TODO Auto-generated method stub + for (int i = 0; i < 40; i++) { + // 从第一行开始写入 + ProblemBean wt = wtList.get(i); + // 创建每个单元格Cell,即列的数据 + Row row = sheet.getRow(i + 6); + if (row == null) { + row = sheet.createRow(i + 6); + } + Cell cell = null; + for (int j = 0; j < 15; j++) { + if(j == 14) { + cell = row.getCell(16); + if (row.getCell(16) == null) { + + cell = row.createCell(16); + //cell.setCellStyle(sheet.getRow(7).getCell(2).getCellStyle()); + } + }else { + cell = row.getCell(j); + if (row.getCell(j) == null) { + + cell = row.createCell(j); + //cell.setCellStyle(sheet.getRow(7).getCell(2).getCellStyle()); + } + } + switch (j) { + case 0: + cell.setCellValue(i+1+""); + break; + case 1: + cell.setCellValue(wt.getWtd()); + break; + case 2: + cell.setCellValue(wt.getCx()); + break; + case 3: + cell.setCellValue(wt.getKhmc()); + break; + case 4: + cell.setCellValue(wt.getXmh()); + break; + case 5: + cell.setCellValue(wt.getTcr()); + break; + case 6: + cell.setCellValue(wt.getProjectName()); + break; + case 7: + cell.setCellValue(wt.getGbyy()); + break; + case 8: + cell.setCellValue(wt.getZgcs()); + break; + case 9: + cell.setCellValue(wt.getFzr()); + break; + case 10: + cell.setCellValue(wt.getStartDate()); + break; + case 11: + cell.setCellValue(wt.getMbwcDate()); + break; + case 12: + cell.setCellValue(wt.getSjwcDate()); + break; + case 13: + cell.setCellValue(wt.getScwcDate()); + break; + case 14: + cell.setCellValue(wt.getZt()); + break; + } + } + } + + sheet.shiftRows(46 ,wtList.size()+49,wtList.size() - 40); + for (int i = 46; i < wtList.size()+6; i++) { + ProblemBean wt = wtList.get(i-6); + + // 创建每个单元格Cell,即列的数据 + Row row = sheet.createRow(i); + Cell cell = null; + for (int j = 0; j < 15; j++) { + if(j == 14) { + cell = row.createCell(16); + }else { + cell = row.createCell(j); + } + switch (j) { + case 0: + cell.setCellValue(i+1+""); + break; + case 1: + cell.setCellValue(wt.getWtd()); + break; + case 2: + cell.setCellValue(wt.getCx()); + break; + case 3: + cell.setCellValue(wt.getKhmc()); + break; + case 4: + cell.setCellValue(wt.getXmh()); + break; + case 5: + cell.setCellValue(wt.getTcr()); + break; + case 6: + cell.setCellValue(wt.getProjectName()); + break; + case 7: + cell.setCellValue(wt.getGbyy()); + break; + case 8: + cell.setCellValue(wt.getZgcs()); + break; + case 9: + cell.setCellValue(wt.getFzr()); + break; + case 10: + cell.setCellValue(wt.getStartDate()); + break; + case 11: + cell.setCellValue(wt.getMbwcDate()); + break; + case 12: + cell.setCellValue(wt.getSjwcDate()); + break; + case 13: + cell.setCellValue(wt.getScwcDate()); + break; + case 14: + cell.setCellValue(wt.getZt()); + break; + } + } + } + + } + + /** + * 查询问题报告 + * + */ + private TCComponent[] searchProb(JTextField projectNameText, JTextField wtdText, JTextField cxText,JTextField tcrText, + JTextField fzrText, JXDatePicker startDatePicker, JXDatePicker mbwcDatePicker, JXDatePicker sjwcDatePicker, + JXDatePicker scgxDatePicker, JTextField ztText,JComboBox wtdjBox,JTextField khmcJTextField,JTextField xmhJTextField) { + try { + TCComponent[] components = null; + List list1 = new ArrayList(); + List list2 = new ArrayList(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + if (projectNameText.getText().toString().length() != 0) { + System.out.println("projectNameText=" + projectNameText.getText().toString()); + list1.add(projectNameText.getText().toString()); + list2.add(new String("项目名称")); + } + if (wtdText.getText().toString().length() != 0) { + System.out.println("wtdText=" + wtdText.getText().toString()); + list1.add(wtdText.getText().toString()); + list2.add(new String("问题点")); + } + if (cxText.getText().toString().length() != 0) { + System.out.println("cxText=" + cxText.getText().toString()); + list1.add(cxText.getText().toString()); + list2.add(new String("车型")); + } + if (tcrText.getText().toString().length() != 0) { + System.out.println("tcrText=" + tcrText.getText().toString()); + list1.add(tcrText.getText().toString()); + list2.add(new String("提出人")); + } + if (fzrText.getText().toString().length() != 0) { + System.out.println("fzrText=" + fzrText.getText().toString()); + list1.add(fzrText.getText().toString()); + list2.add(new String("负责人")); + } + if (startDatePicker.getDate() != null) { + String startDate = sdf.format(startDatePicker.getDate()); + System.out.println("startDate=" + startDate); + //list1.add(startDatePicker.getDate().toString()); + list1.add(startDate); + list2.add(new String("开始日期")); + } + if (mbwcDatePicker.getDate() != null) { + String mbwcDate = sdf.format(mbwcDatePicker.getDate()); + System.out.println("mbwcDate=" + mbwcDate); + list1.add(mbwcDate); + list2.add(new String("目标完成日期")); + } + if (sjwcDatePicker.getDate() != null) { + String sjwcDate = sdf.format(sjwcDatePicker.getDate()); + System.out.println("sjwcDate=" + sjwcDate); + list1.add(sjwcDate); + list2.add(new String("实际完成日期")); + } + if (scgxDatePicker.getDate() != null) { + String schgxDate = sdf.format(scgxDatePicker.getDate()); + System.out.println("schgxDate=" + schgxDate); + list1.add(schgxDate); + list2.add(new String("上次更新时间")); + } + if (ztText.getText().toString().length() != 0) { + System.out.println("ztText=" + ztText.getText().toString()); + list1.add(ztText.getText().toString()); + list2.add(new String("状态")); + } +// if (wtdjText.getText().toString().length() != 0) { +// System.out.println("wtdjText=" + wtdjText.getText().toString()); +// list1.add(wtdjText.getText().toString()); +// list2.add(new String("问题等级")); +//// } +// if (wtdjText.getText().toString().length() != 0) { +// +// } + if (wtdjBox.getSelectedItem()!=null && wtdjBox.getSelectedItem().toString().length() != 0) { + System.out.println("wtdj=" + wtdjBox.getSelectedItem().toString()); + list1.add(wtdjBox.getSelectedItem().toString()); + list2.add(new String("问题等级")); + } + + if (khmcJTextField.getText().toString().length() != 0) { + System.out.println("khmcJTextField=" + khmcJTextField.getText().toString()); + list1.add(khmcJTextField.getText().toString()); + list2.add(new String("客户名称")); + } + + + if (xmhJTextField.getText().toString().length() != 0) { + System.out.println("xmhJTextField=" + xmhJTextField.getText().toString()); + list1.add(xmhJTextField.getText().toString()); + list2.add(new String("项目号")); + } + + + +// if (showDate1.getText().toString().length() != 0) { +// System.out.println("data1=" + showDate1.getText().toString()); +// list1.add(showDate1.getText().toString()); +// list2.add(new String("创建日期晚于")); +// } +// if (showDate2.getText().toString().length() != 0) { +// System.out.println("data2=" + showDate1.getText().toString()); +// list1.add(showDate2.getText().toString()); +// list2.add(new String("创建日期早于")); +// } +// if (cpflBox.getSelectedItem().toString().length() != 0) { +// list1.add((String) cpflBox.getSelectedItem()); +// list2.add(new String("产品分类")); +// } +// if (xmjdB.getSelectedItem().toString().length() != 0) { +// list1.add((String) xmjdB.getSelectedItem()); +// list2.add(new String("项目阶段")); +// } +// if (cpztBox.getSelectedItem().toString().length() != 0) { +// list1.add((String) cpztBox.getSelectedItem()); +// list2.add(new String("产品状态")); +// } +// if (wtlxBox.getSelectedItem().toString().length() != 0) { +// list1.add((String) wtlxBox.getSelectedItem()); +// list2.add(new String("问题类型")); +// } +// if (wtdjBox.getSelectedItem().toString().length() != 0) { +// list1.add((String) wtdjBox.getSelectedItem()); +// list2.add(new String("问题等级")); +// } +// if (projectId.getText().length() != 0) { +// list1.add(projectId.getText()); +// list2.add(new String("项目ID")); +// } + + + + if (list1.size() != 0) { + String[] searchVal = list1.toArray(new String[list1.size()]); + String[] searchCon = list2.toArray(new String[list2.size()]); + System.out.println("有查询条件查询"); + System.out.println("searchCon="+searchCon); + System.out.println("searchVal="+searchVal); + components = session.search("问题点查询", searchCon, searchVal); + + } else { + System.out.println("无查询条件查询"); + TCComponent[] search = session.search("零组件...", new String[] { "类型" }, new String[] { "问题报告" }); + if (search.length == 0) { + search = session.search("零组件...", new String[] { "类型" }, new String[] { "HS2_PR" }); + } + List wtRevs = new ArrayList(); + for (TCComponent wtitem : search) { + TCComponentItem item = (TCComponentItem)wtitem; + TCComponentItemRevision wtRevision = item.getLatestItemRevision(); + wtRevs.add(wtRevision); + } + components = wtRevs.toArray(new TCComponentItemRevision[wtRevs.size()]); + + } +// List list = new ArrayList(); +// for (int i = 0; i < components.length; i++) { +// if (components[i] instanceof TCComponentItem) { +// TCComponentItem item = (TCComponentItem) components[i]; +// String itemType = item.getType(); +// if (itemType.equals("HS2_WTBGRevision")) { +// list.add(item); +// } +// } +// } +// TCComponent[] resut = list.toArray(new TCComponent[list.size()]); +// list.clear(); +// if (resut.length != 0) { +// for (int i = 0; i < resut.length; i++) { +// if (resut[i] instanceof TCComponentItemRevision) { +// TCComponentItem itemrev = (TCComponentItem) resut[i]; +//// TCComponent[] revisions = item.getReferenceListProperty("revision_list"); +//// TCComponent[] fbztComp = revisions[0].getReferenceListProperty("release_status_list"); +//// if (isTrue.getSelectedItem().toString().length() == 0 +//// || isTrue.getSelectedItem().toString() == "Y" && fbztComp.length != 0 +//// || isTrue.getSelectedItem().toString() == "N" && fbztComp.length == 0) {// 判断对象发布状态 +// list.add(itemrev); +//// } +// } +// } +// } +// resut = list.toArray(new TCComponent[list.size()]); + return components; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + + } + +// private String intToDateString(JComboBox fromYear, JComboBox fromMonth, JComboBox fromDay) +// throws ParseException { +// if (fromYear.getSelectedItem().toString().length() != 0 && fromMonth.getSelectedItem().toString().length() != 0 +// && fromDay.getSelectedItem().toString().length() != 0) { +// String stry = fromYear.getSelectedItem().toString(); +// String strm = fromMonth.getSelectedItem().toString(); +// String strd = fromDay.getSelectedItem().toString(); +// String str = stry + "-" + strm + "-" + strd; +// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); +// Date date = dateFormat.parse(str); +// SimpleDateFormat dateFormat4 = new SimpleDateFormat("yyyy-M-d HH:mm"); +// str = dateFormat4.format(date); +// System.out.println("date:" + str); +// return str; +// } +// return ""; +// } + +// private void updateTabUI(JTable table) { +// table.setModel(new DefaultTableModel(pageController.getDatas().get(pageController.getTablePage()), +// new String[] { "问题编号", "产品分类", "顾客名称", "车型", "项目ID", "项目", "项目阶段", "产品状态", "发生日期", "问题来源", "提出人", +// "提出日期", "问题等级", "问题类型", "问题描述", "数量", "原因分析", "验证措施", "验证记录", "问题处理状态", "最终改进措施", "计划关闭日期", +// "责任部门", "责任人", "技术文件更新", "流程文件及更新完成时间", "问题关闭日期", "备注" })); +// table.getTableHeader().setBackground(Color.lightGray); +// Font font = new Font(Font.DIALOG, Font.PLAIN, 30); +// table.getTableHeader().setFont(font); +// } + + private List reloadTable(JTable table, String[][] datas) { + // TODO Auto-generated method stub + List wtList = new ArrayList(); + for (int i = 0; i < datas.length; i++) { + ProblemBean problemBean = new ProblemBean(); + for (int j = 0; j < datas[i].length; j++) { + switch (j) { + case 0: + problemBean.setWtd(datas[i][j]); + break; + case 1: + problemBean.setCx(datas[i][j]); + break; + case 2: + problemBean.setKhmc(datas[i][j]); + break; + case 3: + problemBean.setXmh(datas[i][j]); + break; + case 4: + problemBean.setTcr(datas[i][j]); + break; + case 5: + problemBean.setProjectName(datas[i][j]); + break; + case 6: + problemBean.setGbyy(datas[i][j]); + break; + case 7: + problemBean.setZgcs(datas[i][j]); + break; + case 8: + problemBean.setFzr(datas[i][j]); + break; + case 9: + problemBean.setStartDate(datas[i][j]); + break; + case 10: + problemBean.setMbwcDate(datas[i][j]); + break; + case 11: + problemBean.setSjwcDate(datas[i][j]); + break; + case 12: + problemBean.setScwcDate(datas[i][j]); + break; + case 13: + problemBean.setZt(datas[i][j]); + break; + case 14: + problemBean.setWtdj(datas[i][j]); + break; + + } + + } + wtList.add(problemBean); + model.addRow(datas[i]); + } + table.setModel(model); +// /** +// * 循环修改表头列 +// */ +// for (int i = 0; i < 28; i++) { +// +// // i是表头的列 +// TableColumn column = table.getTableHeader().getColumnModel().getColumn(i); +// column.setHeaderRenderer(cellRenderer); +// +// // 表头文字居中 +// cellRenderer.setHorizontalAlignment(cellRenderer.CENTER); +// +// } + return wtList; + } + + /** + * 创建tabledata + * + * @param components + * @return + * @throws TCException + */ + private String[][] reloadData(TCComponent[] components) throws TCException { + String[][] datas = new String[components.length][28]; + if (components.length != 0) { + for (int i = 0; i < components.length; i++) { + if (components[i] instanceof TCComponentItemRevision) { + TCComponentItemRevision revision = (TCComponentItemRevision) components[i]; +// TCComponent[] revision = item.getReferenceListProperty("revision_list"); +// TCComponent[] fbztComp = revisions[0].getReferenceListProperty("release_status_list"); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + datas[i][0] = revision.getStringProperty("hs2_troublespots"); + //TCComponent[] forms = revisions[0].getReferenceListProperty("IMAN_master_form_rev"); + + datas[i][1] = revision.getStringProperty("hs2_models"); + + + + TCComponent[] projectList = revision.getRelatedComponents("project_list"); + System.out.println("projectList======================="+projectList.length); + if(projectList.length > 0) { + String projectId = projectList[0].getProperty("project_id"); + String hs2_cusName = projectList[0].getProperty("hs2_cusName"); + + datas[i][2] = hs2_cusName; + datas[i][3] = projectId; + + }else { + datas[i][2] = ""; + datas[i][3] = ""; + } + + + + + + + + // datas[i][1] = forms[0].getStringProperty("sb6_cpfl"); +// datas[i][1] = forms[0].getTCProperty("sb6_cpfl").getLOV().getListOfValues().getDisplayableValue(forms[0].getStringProperty("sb6_cpfl")); + datas[i][4] = revision.getStringProperty("hs2_introducer"); + datas[i][5] = revision.getStringProperty("hs2_projectname"); + datas[i][6] = revision.getStringProperty("hs2_rootcause"); + datas[i][7] = revision.getStringProperty("hs2_correctiveactions"); +// TCComponent[] projectsIds = revisions[0].getReferenceListProperty("project_ids"); +// if (projectsIds.length > 0) { +// StringBuffer buf = new StringBuffer(); +// for(int j = 0;j < projectsIds.length; j++) { +// buf.append(projectsIds[j].getStringProperty("object_name")); +// if(j != projectsIds.length - 1) { +// buf.append(","); +// } +// } +// datas[i][4] = buf.toString(); +// } else { +// datas[i][4] = ""; +// } +// TCComponent[] projects = revisions[0].getReferenceListProperty("project_list"); +// if (projects.length > 0) { +// StringBuffer buf = new StringBuffer(); +// for (int j = 0; j < projects.length; j++) { +// buf.append(projects[j].getStringProperty("object_name")); +// if (j != projects.length - 1) { +// buf.append(","); +// } +// } +// datas[i][5] = buf.toString(); +// } else { +// datas[i][5] = ""; +// } + datas[i][8] = revision.getStringProperty("hs2_head"); + //datas[i][7] = forms[0].getStringProperty("sb6_cpzt"); +// datas[i][6] = forms[0].getTCProperty("sb6_xmjd").getLOV().getListOfValues().getDisplayableValue(forms[0].getStringProperty("sb6_xmjd")); +// datas[i][7] = forms[0].getTCProperty("sb6_cpzt").getLOV().getListOfValues().getDisplayableValue(forms[0].getStringProperty("sb6_cpzt")); + if (revision.getDateProperty("hs2_startdate") != null) { + datas[i][9] = df.format(revision.getDateProperty("hs2_startdate")); + } else { + datas[i][9] = ""; + } + if (revision.getDateProperty("hs2_targetcompletion") != null) { + datas[i][10] = df.format(revision.getDateProperty("hs2_targetcompletion")); + } else { + datas[i][10] = ""; + } + if (revision.getDateProperty("hs2_actualcompletion") != null) { + datas[i][11] = df.format(revision.getDateProperty("hs2_actualcompletion")); + } else { + datas[i][11] = ""; + } + if (revision.getDateProperty("hs2_lastupdate") != null) { + datas[i][12] = df.format(revision.getDateProperty("hs2_lastupdate")); + } else { + datas[i][12] = ""; + } + datas[i][13] = revision.getStringProperty("hs2_state"); + datas[i][14] = revision.getStringProperty("hs2_problemlevel"); + + +// if (revision.getStringProperty("hs2_ZT") != null) { +// datas[i][11] = df.format(revision.getStringProperty("hs2_ZT")); +// } else { +// datas[i][11] = ""; +// } +// datas[i][12] = forms[0].getStringProperty("sb6_wtdj"); +// datas[i][13] = forms[0].getStringProperty("sb6_wtlx"); +//// datas[i][12] = forms[0].getTCProperty("sb6_wtdj").getLOV().getListOfValues().getDisplayableValue(forms[0].getStringProperty("sb6_wtdj")); +//// datas[i][13] = forms[0].getTCProperty("sb6_wtlx").getLOV().getListOfValues().getDisplayableValue(forms[0].getStringProperty("sb6_wtlx")); +// datas[i][14] = forms[0].getStringProperty("sb6_wtms"); +// datas[i][15] = forms[0].getStringProperty("sb6_sl"); +// datas[i][16] = forms[0].getStringProperty("sb6_yyfx"); +// datas[i][17] = forms[0].getStringProperty("sb6_yzcs"); +// datas[i][18] = forms[0].getStringProperty("sb6_yzjl"); +// datas[i][19] = forms[0].getStringProperty("sb6_wtcljd"); +//// datas[i][19] = forms[0].getTCProperty("sb6_wtcljd").getLOV().getListOfValues().getDisplayableValue(forms[0].getStringProperty("sb6_wtcljd")); +// datas[i][20] = forms[0].getStringProperty("sb6_zzgjcs"); +// if (forms[0].getDateProperty("sb6_PRRM08") != null) { +// datas[i][21] = df.format(forms[0].getDateProperty("sb6_PRRM08")); +// } else { +// datas[i][21] = ""; +// } +// datas[i][22] = forms[0].getStringProperty("sb6_zrbm"); +// datas[i][23] = forms[0].getStringProperty("sb6_zrr"); +// datas[i][24] = forms[0].getStringProperty("sb6_jswjgx"); +// datas[i][25] = forms[0].getStringProperty("sb6_lcwjjsj"); +//// if (forms[0].getDateProperty("sb6_lcwjjsj") != null) { +//// datas[i][25] = df.format(forms[0].getDateProperty("sb6_lcwjjsj")); +//// } else { +//// datas[i][25] = ""; +//// } +// if (forms[0].getDateProperty("sb6_PRRM09") != null) { +// datas[i][26] = df.format(forms[0].getDateProperty("sb6_PRRM09")); +// } else { +// datas[i][26] = ""; +// } +// datas[i][27] = forms[0].getStringProperty("sb6_wtbz"); + + } + } + } + return datas; + } + + /** + * + * 通过lov名称获取lov创建下拉框 + * + * @param s + * @return JComboBox + * @throws TCException + */ + private JComboBox setLOV(String s) throws TCException { + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + JComboBox jComboBox = new JAutoCompleteComboBox(); + jComboBox.addItem(new String("")); +// TCComponentListOfValues[] lov = lovType.find(s); +// if (lov.length > 0) { +// ListOfValuesInfo value = lov[0].getListOfValues(); +// String[] realValues = value.getStringListOfValues(); +// for (int i = 0; i < realValues.length; i++) { +// jComboBox.addItem(value.getDisplayableValue(realValues[i])); +// } +// } + return jComboBox; + } + + /** + * 导出table到excel + * + * @param table + * @param file + * @throws IOException + */ + private void exportTable(JTable table, File file) throws IOException { + try { + 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(); + TableModel model = table.getModel(); + for (int i = 0; i < model.getRowCount(); i++) { +// if(i==0) { + XSSFRow row = sheet.getRow(i); + if (row == null) { + row = sheet.createRow(i); + } + row.setHeight(h); + for (int j = 0; j < model.getColumnCount(); j++) { + XSSFCell cell = row.getCell(j); + if (cell == null) { + cell = row.createCell(j); + cell.setCellStyle(cellStyle); + cell.setCellValue(model.getValueAt(i, j) != null ? model.getValueAt(i, j).toString() : ""); + } + } +// }else { + +// } + + } + FileOutputStream output = new FileOutputStream(file); + wb.write(output); + output.close(); + is.close(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } + +// private String jButtonActionPerformed(java.awt.event.ActionEvent evt, JTable salTable, JFrame jFrame) { +// // TODO add your handling code here +// FileDialog fd = new FileDialog(jFrame, "BOMExcel信息", FileDialog.SAVE); +// fd.setLocation(500, 350); +// fd.setVisible(true); +// String stringfile = fd.getDirectory() + fd.getFile() + ".xls"; +// try { +// exportTable(salTable, new File(stringfile)); +// +// } catch (IOException ex) { +// ex.printStackTrace(); +// } +// return stringfile; +// } + + /** + * get String array [start, end] + */ + private String[] getModel(int start, int end) { + String[] m = new String[end - start + 2]; + m[0] = ""; + for (int i = 1; i < m.length; i++) { + m[i] = String.valueOf(i + start - 1); + } + return m; + } + public File getSXX() { + TCPreferenceService pref = session.getPreferenceService(); + //String puid = pref.getStringValue("QDXQS_MB");// 首选项查puid + String puid = null; + puid = pref.getStringValue("HS2_WTBGMB"); + + if (puid != null) { + try { + TCComponentDataset dataset = (TCComponentDataset) session.stringToComponent(puid); + if (dataset == null) { + return null; + } + File[] files = dataset.getFiles(""); + if (files.length == 0 || files.length != 1) { + MessageBox.post("数据集没有命名引用的文件或文件过多,请检查!", "WARNING", MessageBox.WARNING); + return null; + } else { + File file = files[0]; + return file; + } + } catch (TCException e) { + e.printStackTrace(); + } + } else { + MessageBox.post("未找到首选项[HS2_WTBGMB]或首选项配置错误", "错误", MessageBox.ERROR); + return null; + } + return null; + } + + private static void writeDirect(List wtList, HSSFSheet sheet) { + for (int i = 0; i < wtList.size(); i++) { + // 从第一行开始写入 + ProblemBean wt = wtList.get(i); + // 创建每个单元格Cell,即列的数据 + Row row = sheet.getRow(i + 6); + if (row == null) { + row = sheet.createRow(i + 6); + } + Cell cell = null; + for (int j = 0; j < 15; j++) { + if(j == 14) { + cell = row.getCell(16); + if (row.getCell(16) == null) { + + cell = row.createCell(16); + //cell.setCellStyle(sheet.getRow(7).getCell(2).getCellStyle()); + } + }else { + cell = row.getCell(j); + if (row.getCell(j) == null) { + + cell = row.createCell(j); + //cell.setCellStyle(sheet.getRow(7).getCell(2).getCellStyle()); + } + } + + + switch (j) { + case 0: + cell.setCellValue(i+1+""); + break; + case 1: + cell.setCellValue(wt.getWtd()); + break; + case 2: + cell.setCellValue(wt.getCx()); + break; + case 3: + cell.setCellValue(wt.getKhmc()); + break; + case 4: + cell.setCellValue(wt.getXmh()); + break; + case 5: + cell.setCellValue(wt.getTcr()); + break; + case 6: + cell.setCellValue(wt.getProjectName()); + break; + case 7: + cell.setCellValue(wt.getGbyy()); + break; + case 8: + cell.setCellValue(wt.getZgcs()); + break; + case 9: + cell.setCellValue(wt.getFzr()); + break; + case 10: + cell.setCellValue(wt.getStartDate()); + break; + case 11: + cell.setCellValue(wt.getMbwcDate()); + break; + case 12: + cell.setCellValue(wt.getSjwcDate()); + break; + case 13: + cell.setCellValue(wt.getScwcDate()); + break; + case 14: + cell.setCellValue(wt.getZt()); + break; + } + } + } + } +} diff --git a/src/com/connor/hs2/plm/projectmanage/problemstructured/ProblemHandler.java b/src/com/connor/hs2/plm/projectmanage/problemstructured/ProblemHandler.java new file mode 100644 index 0000000..fb066eb --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/problemstructured/ProblemHandler.java @@ -0,0 +1,19 @@ +package com.connor.hs2.plm.projectmanage.problemstructured; + +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 ProblemHandler extends AbstractHandler{ + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + ProblemDialog dialog = new ProblemDialog(app); + new Thread(dialog).start(); + return null; + } +} diff --git a/src/com/connor/hs2/plm/projectmanage/utils/AutoCompleter.java b/src/com/connor/hs2/plm/projectmanage/utils/AutoCompleter.java new file mode 100644 index 0000000..dc38fd8 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/utils/AutoCompleter.java @@ -0,0 +1,115 @@ +package com.connor.hs2.plm.projectmanage.utils; + +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.List; +import java.util.Vector; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.JTextField; + +public class AutoCompleter implements KeyListener, ItemListener { + + private JComboBox owner = null; + private JTextField editor = null; + private ComboBoxModel model = null; + + public AutoCompleter(JComboBox comboBox) { + owner = comboBox; + editor = (JTextField) comboBox.getEditor().getEditorComponent(); + editor.addKeyListener(this); + model = comboBox.getModel(); + + owner.addItemListener(this); + } + + public void keyTyped(KeyEvent e) { + } + + public void keyPressed(KeyEvent e) { + } + + public void keyReleased(KeyEvent e) { + char ch = e.getKeyChar(); + if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch) + || ch == KeyEvent.VK_DELETE) + return; + + int caretPosition = editor.getCaretPosition(); + String str = editor.getText(); + if (str.length() == 0) + return; + autoComplete(str, caretPosition); + } + + /** + * 自动完成。根据输入的内容,在列表中找到相似的项目. + */ + protected void autoComplete(String strf, int caretPosition) { + Object[] opts; + opts = getMatchingOptions(strf.substring(0, caretPosition)); + if (owner != null) { + model = new DefaultComboBoxModel(opts); + owner.setModel(model); + } + if (opts.length > 0) { + String str = opts[0].toString(); + editor.setCaretPosition(caretPosition); + if (owner != null) { + try { + owner.showPopup(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + } + + /** + * + * 找到相似的项目, 并且将之排列到数组的最前面。 + * + * @param str + * @return 返回所有项目的列表。 + */ + protected Object[] getMatchingOptions(String str) { + List v = new Vector(); + List v1 = new Vector(); + + for (int k = 0; k < model.getSize(); k++) { + Object itemObj = model.getElementAt(k); + if (itemObj != null) { + String item = itemObj.toString().toLowerCase(); + if (item.startsWith(str.toLowerCase())) + v.add(model.getElementAt(k)); + else + v1.add(model.getElementAt(k)); + } else + v1.add(model.getElementAt(k)); + } + for (int i = 0; i < v1.size(); i++) { + v.add(v1.get(i)); + } + if (v.isEmpty()) + v.add(str); + return v.toArray(); + } + + public void itemStateChanged(ItemEvent event) { + if (event.getStateChange() == ItemEvent.SELECTED) { + int caretPosition = editor.getCaretPosition(); + if (caretPosition != -1) { + try { + editor.moveCaretPosition(caretPosition); + } catch (IllegalArgumentException ex) { + ex.printStackTrace(); + } + } + } + } + } + diff --git a/src/com/connor/hs2/plm/projectmanage/utils/DateChooser.java b/src/com/connor/hs2/plm/projectmanage/utils/DateChooser.java new file mode 100644 index 0000000..a5db7eb --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/utils/DateChooser.java @@ -0,0 +1,1391 @@ +package com.connor.hs2.plm.projectmanage.utils; + +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/hs2/plm/projectmanage/utils/JAutoCompleteComboBox.java b/src/com/connor/hs2/plm/projectmanage/utils/JAutoCompleteComboBox.java new file mode 100644 index 0000000..5a9fa16 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/utils/JAutoCompleteComboBox.java @@ -0,0 +1,60 @@ +package com.connor.hs2.plm.projectmanage.utils; + +import java.util.List; + +import java.util.Vector; +import javax.swing.ComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.JTextField; + +public class JAutoCompleteComboBox extends JComboBox { + + private AutoCompleter completer; + + public JAutoCompleteComboBox() { + super(); + addCompleter(); + } + + public JAutoCompleteComboBox(ComboBoxModel cm) { + super(cm); + addCompleter(); + } + + public JAutoCompleteComboBox(Object[] items) { + super(items); + addCompleter(); + } + + public JAutoCompleteComboBox(List v) { + super((Vector) v); + addCompleter(); + } + + private void addCompleter() { + setEditable(true); + completer = new AutoCompleter(this); + } + + public void autoComplete(String str) { + this.completer.autoComplete(str, str.length()); + } + + public String getText() { + return ((JTextField) getEditor().getEditorComponent()).getText(); + } + + public void setText(String text) { + ((JTextField) getEditor().getEditorComponent()).setText(text); + } + + public boolean containsItem(String itemString) { + for (int i = 0; i < this.getModel().getSize(); i++) { + String _item = " " + this.getModel().getElementAt(i); + if (_item.equals(itemString)) + return true; + } + return false; + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/utils/JTableUtil.java b/src/com/connor/hs2/plm/projectmanage/utils/JTableUtil.java new file mode 100644 index 0000000..18e857b --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/utils/JTableUtil.java @@ -0,0 +1,39 @@ +package com.connor.hs2.plm.projectmanage.utils; + +import java.util.Enumeration; + +import javax.swing.JTable; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableColumn; + +public class JTableUtil { + + //自动设置列宽 + public static void fitTableColumns(JTable table) { + JTableHeader header = table.getTableHeader(); + int rowCount = table.getRowCount(); + Enumeration columns = table.getColumnModel().getColumns(); + while (columns.hasMoreElements()) { + TableColumn column = (TableColumn) columns.nextElement(); + int col = header.getColumnModel().getColumnIndex(column.getIdentifier()); + int width = (int) table.getTableHeader().getDefaultRenderer() + .getTableCellRendererComponent(table,column.getIdentifier(), false, false, -1, col).getPreferredSize().getWidth(); + for (int row = 0; row < rowCount; row++) { + int preferedWidth = (int) table.getCellRenderer(row, col) + .getTableCellRendererComponent(table, + table.getValueAt(row, col), false, false, row,col).getPreferredSize().getWidth(); + width = Math.max(width, preferedWidth); + } + header.setResizingColumn(column); // 此行很重要 + column.setWidth(width + table.getIntercellSpacing().width); + } + } + + //手动设置列宽 + public static void fitTableColumns(JTable table, int[] columnWidths) { + for (int i = 0; i < columnWidths.length; i++) { + table.getColumnModel().getColumn(i).setPreferredWidth( + columnWidths[i]); + } + } +} diff --git a/src/com/connor/hs2/plm/projectmanage/utils/LovUtils.java b/src/com/connor/hs2/plm/projectmanage/utils/LovUtils.java new file mode 100644 index 0000000..62e77e1 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/utils/LovUtils.java @@ -0,0 +1,55 @@ +package com.connor.hs2.plm.projectmanage.utils; + +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JComboBox; + +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCException; + +public class LovUtils { + + public static void addLovToBox(String lovname,JComboBox box) { + + try { + TCComponentListOfValues listValues = TCComponentListOfValuesType.findLOVByName(lovname); + String[] lovStrs = listValues.getListOfValues().getLOVDisplayValues(); + String[] lovRealStrs = listValues.getListOfValues().getStringListOfValues(); + for (int j = 0; j < lovRealStrs.length; j++) { + box.addItem(lovStrs[j]); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + }; + + public static void setLovProperty(TCComponentItemRevision rev ,String propertyKey,String propertyValue) throws TCException { + if (propertyValue == null || propertyValue.equals("")) { + rev.setProperty(propertyKey,""); + } + TCComponentListOfValues lov = rev.getTCProperty(propertyKey).getLOV(); + if (lov!=null) { + if (lov.getListOfValues()!=null) { + String[] strs = lov.getListOfValues().getStringListOfValues();// 所有真实值 + Map Map = new HashMap(); + for (String s1 : strs) { + String a1 = lov.getListOfValues().getDisplayableValue(s1);// 真实值对应的显示值 + // System.out.println("s1="+s1); + Map.put(a1, s1); + } + for (String key : Map.keySet()) { + if (key.equals(propertyValue)) { + rev.setProperty(propertyKey, Map.get(key)); + } + } + } + } + + } +} diff --git a/src/com/connor/hs2/plm/projectmanage/utils/ProgressBar.java b/src/com/connor/hs2/plm/projectmanage/utils/ProgressBar.java new file mode 100644 index 0000000..3af83a0 --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/utils/ProgressBar.java @@ -0,0 +1,175 @@ +/** + * @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.hs2.plm.projectmanage.utils; + +import java.awt.Container; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.Timer; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Registry; + +/** + * @class ProgressBar + * @brief Create progress bar + * @author Yanghui + */ +public class ProgressBar extends AbstractAIFDialog implements ActionListener { + /** + * @var ProgressBar.progressbar + * @brief JProgressBar + */ + private JProgressBar progressbar; + + /** + * @var ProgressBar.label + * @brief label used to tips + */ + private JLabel label; + + /** + * @var ProgressBar.timer + * @brief timer used to timing operation + */ + private Timer timer; + + /** + * @var ProgressBar.bool + * @brief bool used to flag thread return + */ + private boolean bool = false; + + /** + * @var Progressbar.registry + * @brief Registry + */ + private Registry registry; + + /** + * @fn public ProgressBar() + * @brief constructor + * @param[in] null + */ + private String showLable = null ; + public ProgressBar(String showlable) { + super(true); + showLable = showlable; + this.setAlwaysOnTop(true); + } + + /** + * @fn public void setBool(boolean bool) + * @brief set bool value + * @param[in] bool + * @param[out] null + */ + public void setBool(boolean bool) { + this.bool = bool; + } + + /** + * @fn private void initUI() + * @brief createDialog method + * @param[in] null + * @param[out] null + */ + public void initUI() { + Container container = getContentPane(); + JPanel mainPanel = new JPanel(new PropertyLayout()); + this.label = new JLabel(showLable, JLabel.CENTER); + this.progressbar = new JProgressBar(); + this.progressbar.setOrientation(JProgressBar.HORIZONTAL); + this.progressbar.setMinimum(0); + this.progressbar.setMaximum(100); + this.progressbar.setValue(0); + this.progressbar.setPreferredSize(new Dimension(200, 15)); + this.progressbar.setBorderPainted(true); + this.timer = new Timer(50, (ActionListener) this); + this.timer.setRepeats(false); + mainPanel.add("1.1.center", new JLabel(" ")); + mainPanel.add("2.1.center", label); + mainPanel.add("3.1.center", progressbar); + mainPanel.add("4.1.center", new JLabel(" ")); + container.add(mainPanel); + pack(); + setLocation(500, 200); + TaskThread thread = new TaskThread(this); + thread.start(); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + bool = true; + } + }); + this.setVisible(true); + } + + /** + * @class TaskThread + * @brief Create progressbar + * + */ + class TaskThread extends Thread { + private ProgressBar bar; + + public TaskThread(ProgressBar bar) { + this.bar = bar; + } + + public void run() { + if (bool == false) { + // Set Status is running. + // session.setStatus(registry.getString("export Running")); + } + for (int i = 0; i < i + 1; i++) { + timer.start(); + int value = progressbar.getValue(); + if (value < 100) { + value = value + 5; + progressbar.setValue(value); + } else { + timer.stop(); + progressbar.setValue(0); + } + try { + sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (bool == true) { + this.bar.setVisible(false); + this.bar.disposeDialog(); + this.bar.dispose(); + this.interrupt(); + return; + + } + + } + } + } + + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + + } +} diff --git a/src/com/connor/hs2/plm/projectmanage/utils/ProgressBarThread.java b/src/com/connor/hs2/plm/projectmanage/utils/ProgressBarThread.java new file mode 100644 index 0000000..5d8a4bb --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/utils/ProgressBarThread.java @@ -0,0 +1,42 @@ +/** + * @file ProgressBarThread.java + * + * @brief control progressBar. + * + * @author Yanghui + * + * @history + * ================================================================ + * Date Name Description of Change + * 08-Auguest-2008 Yanghui this class is used to control + * progress bar. + */ +package com.connor.hs2.plm.projectmanage.utils; + +/** + * @class ProgressBarThread + * @brief Create progress bar thread + * @author Yanghui + */ +public class ProgressBarThread extends Thread { + + private ProgressBar bar; + + private String title; + + public ProgressBarThread(String title,String showLable) { + this.title = title; + bar = new ProgressBar(showLable); + } + + public void run() { + bar.setTitle(title); + bar.initUI(); + } + + public void setBool(boolean bool) { + bar.setBool(true); + bar.setAlwaysOnTop(false); + } + +} diff --git a/src/com/connor/hs2/plm/projectmanage/utils/SXXUtil.java b/src/com/connor/hs2/plm/projectmanage/utils/SXXUtil.java new file mode 100644 index 0000000..97fc0dd --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/utils/SXXUtil.java @@ -0,0 +1,48 @@ +package com.connor.hs2.plm.projectmanage.utils; + +import java.io.File; + +import com.teamcenter.rac.kernel.TCComponentDataset; +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 SXXUtil { + public static File getSXX(TCSession session,String type) { + TCPreferenceService pref = session.getPreferenceService(); + //String puid = pref.getStringValue("QDXQS_MB");// 首选项查puid + String puid = null; + //puid = pref.getStringValue("HS2_WTBGMB"); + String[] puids = pref.getStringValues("HS2_BGDMB"); + for (String value : puids) { + if (value.contains("=")) { + if (value.split("=")[0].equals(type)) { + puid = value.split("=")[1]; + } + } + } + if (puid != null) { + try { + TCComponentDataset dataset = (TCComponentDataset) session.stringToComponent(puid); + if (dataset == null) { + return null; + } + File[] files = dataset.getFiles(""); + if (files.length == 0 || files.length != 1) { + MessageBox.post("数据集没有命名引用的文件或文件过多,请检查!", "WARNING", MessageBox.WARNING); + return null; + } else { + File file = files[0]; + return file; + } + } catch (TCException e) { + e.printStackTrace(); + } + } else { + MessageBox.post("未找到首选项[HS2_WTBGMB]或首选项配置错误", "错误", MessageBox.ERROR); + return null; + } + return null; + } +} diff --git a/src/com/connor/hs2/plm/projectmanage/utils/TableCellTextAreaRenderer.java b/src/com/connor/hs2/plm/projectmanage/utils/TableCellTextAreaRenderer.java new file mode 100644 index 0000000..f1859da --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/utils/TableCellTextAreaRenderer.java @@ -0,0 +1,53 @@ +package com.connor.hs2.plm.projectmanage.utils; + +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) { + +// 计算当下行的最佳高度 + +int maxPreferredHeight = 30; + +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; + +} + +} \ No newline at end of file diff --git a/src/com/connor/hs2/plm/projectmanage/utils/TablePageController.java b/src/com/connor/hs2/plm/projectmanage/utils/TablePageController.java new file mode 100644 index 0000000..d891cbc --- /dev/null +++ b/src/com/connor/hs2/plm/projectmanage/utils/TablePageController.java @@ -0,0 +1,127 @@ +package com.connor.hs2.plm.projectmanage.utils; + +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JTable; +import javax.swing.table.TableModel; + +public class TablePageController { + + private JTable table; + private int tablePage; + private int totalTablePage; + private final int maxCount = 1; + private int totalCount; + private int count; + private List datas; + + public TablePageController() { + + } + + public TablePageController(JTable table) { + this.table = table; + TableModel model = this.table.getModel(); + int rowCount = model.getRowCount(); + this.totalCount = rowCount; + if (totalCount % maxCount == 0) { + this.totalTablePage = totalCount / maxCount; + } else { + this.totalTablePage = totalCount / maxCount + 1; + } + this.tablePage = 0; + this.count = this.totalCount; + datas = new ArrayList(); + loadData(); + } + + private void loadData() { + int rowCount = table.getModel().getRowCount(); + int k = 0; + while (count > 0) { + String data[][] = null; + int columnCount = table.getModel().getColumnCount(); + System.out.println("获取到"+columnCount+"列"); + if (count > maxCount) { + data = new String[maxCount][columnCount]; + } else { + data = new String[count][columnCount]; + } + System.out.println("获取到"+data.length+"行"); + System.out.println("获取到"+data[0].length+"列"); + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < data[i].length; j++) { + if (k < rowCount) { + data[i][j] = table.getModel().getValueAt(k, j)!=null?table.getModel().getValueAt(k, j).toString():""; + System.out.println("获取到第"+k+"行第"+j+"列数据:"+data[i][j]); + } + } + k++; + } + System.out.println("count ="+count); + this.datas.add(data); + this.count -= this.maxCount; + } + } + + public JTable getTable() { + return table; + } + + public void setTable(JTable table) { + this.table = table; + } + + public int getTablePage() { + return tablePage; + } + + public void setTablePage(int tablePage) { + this.tablePage = tablePage; + } + + public int getTotalTablePage() { + return totalTablePage; + } + + public void setTotalTablePage(int totalTablePage) { + this.totalTablePage = totalTablePage; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public List getDatas() { + return datas; + } + + public void setDatas(List datas) { + this.datas = datas; + } + + public int getMaxCount() { + return maxCount; + } + + @Override + public String toString() { + return "TablePageController [table=" + table + ", tablePage=" + tablePage + ", totalTablePage=" + totalTablePage + + ", maxCount=" + maxCount + ", totalCount=" + totalCount + ", count=" + count + ", datas=" + datas + + "]"; + } + +} diff --git a/src/com/connor/hs2/plm/updateGXno/UpdateGXDialog.java b/src/com/connor/hs2/plm/updateGXno/UpdateGXDialog.java new file mode 100644 index 0000000..8c09f82 --- /dev/null +++ b/src/com/connor/hs2/plm/updateGXno/UpdateGXDialog.java @@ -0,0 +1,97 @@ +package com.connor.hs2.plm.updateGXno; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.PropertyLayout; + +public class UpdateGXDialog extends AbstractAIFDialog{ + + private TCSession session; +// private TCComponentBOMLine bomLine; + private TCComponentItemRevision bomLine; + + public UpdateGXDialog(TCSession session, TCComponentItemRevision revision) { + this.session = session; +// this.bomLine = bomLine; + this.bomLine = revision; + init(); + + } + private JRadioButton grBtn; + private JRadioButton projectBtn; + private void init() { + // TODO Auto-generated method stub + this.setTitle("选择更新的属性"); + this.setLayout(new PropertyLayout()); + + this.setPreferredSize(new Dimension(250, 150)); + + projectBtn = new JRadioButton("查找编号"); + grBtn = new JRadioButton("更新工艺号"); +// ButtonGroup bg=new ButtonGroup(); +// bg.add(projectBtn); +// bg.add(grBtn); +// + + this.add("1.1.left.top",projectBtn); + this.add("1.2.left.top",grBtn); + + JButton okBtn = new JButton("确认"); + JButton disBtn = new JButton("取消"); + disBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + dispose(); + } + }); + okBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + dispose(); + setBomlinesProp(); + + } + }); + this.add("2.1.left.top",okBtn); + this.add("2.2.left.top",disBtn); + + this.setResizable(true); + this.pack(); + this.setVisible(true); + + this.centerToScreen(); + this.showDialog(); + } + protected void setBomlinesProp() { + // TODO Auto-generated method stub + boolean bl_seq = projectBtn.isSelected(); + boolean gyxh = grBtn.isSelected(); + + UpdateGXOperation operation = new UpdateGXOperation(session,bomLine,gyxh,bl_seq); + + session.queueOperation(operation); + + +// bl_occ_hs2_gxbh + + } + + +} diff --git a/src/com/connor/hs2/plm/updateGXno/UpdateGXHandler.java b/src/com/connor/hs2/plm/updateGXno/UpdateGXHandler.java new file mode 100644 index 0000000..0aabced --- /dev/null +++ b/src/com/connor/hs2/plm/updateGXno/UpdateGXHandler.java @@ -0,0 +1,58 @@ +package com.connor.hs2.plm.updateGXno; + +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 com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + + +public class UpdateGXHandler extends AbstractHandler{ + private AbstractAIFApplication app; + private TCSession session=null; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + AIFDesktop aifdesktop = AIFDesktop.getActiveDesktop() + .getDesktopManager().getActiveDesktop(); + app = aifdesktop.getCurrentApplication(); +// frame=aifdesktop.getFrame(); + session = (TCSession) app.getSession(); + + + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if(targetComponent instanceof TCComponentBOMLine) { + TCComponentBOMLine bomLine = (TCComponentBOMLine) targetComponent; + try { + TCComponentItemRevision itemRevision = bomLine.getItemRevision(); + if(itemRevision.getItem().getType().endsWith("HS2_ProductMEP") || itemRevision instanceof TCComponentMEProcessRevision) { + Thread t=new Thread(new Runnable(){ + public void run(){ + + UpdateGXDialog dialog = new UpdateGXDialog(session,itemRevision); + + } + }); + t.start(); + + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + + return null; + } + +} diff --git a/src/com/connor/hs2/plm/updateGXno/UpdateGXOperation.java b/src/com/connor/hs2/plm/updateGXno/UpdateGXOperation.java new file mode 100644 index 0000000..53ca618 --- /dev/null +++ b/src/com/connor/hs2/plm/updateGXno/UpdateGXOperation.java @@ -0,0 +1,159 @@ +package com.connor.hs2.plm.updateGXno; + +import java.io.File; + +import com.connor.hs2.plm.projectmanage.utils.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.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class UpdateGXOperation extends AbstractAIFOperation { + private TCSession session; +// private TCComponentItemRevision revision; + private TCComponentBOMLine topLine; + private boolean gyxh; + private boolean bl_seq; + private int zxgyNo = 10; + private ProgressBarThread wait; + public UpdateGXOperation(TCSession session, TCComponentItemRevision revision,boolean gyxh,boolean bl_seq) { + // TODO Auto-generated constructor stub +// this.datasetType=b; +// this.revision=revision; + this.session=session; + this.bl_seq=bl_seq; + this.gyxh=gyxh; + + try { + TCComponentBOMWindowType bopWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow bopWindow = bopWindowType.create(null); + TCComponentBOMLine topBopline = bopWindow.setWindowTopLine(revision.getItem(), revision, null, null); + this.topLine=topBopline; + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + startSet(); + + + } + private void startSet() { + // TODO Auto-generated method stub + try { + wait = new ProgressBarThread("更新工序号", "更新工序号中,请稍等..."); + wait.start();// 开启进度条 + if(bl_seq) { + AIFComponentContext[] children = topLine.getChildren(); + int index = 10; + for(AIFComponentContext context:children) { + TCComponentBOMLine component = (TCComponentBOMLine) context.getComponent(); +// if(component.getItem().getType().equals("HS2_SpecialMEP")) { + component.setStringProperty("bl_sequence_no", String.valueOf(index)); + setAllBomline(component); + index = index +10; +// } + } + + + topLine.refresh(); + } + if(gyxh) { + int t=66; + AIFComponentContext[] children = topLine.getChildren(); + for(AIFComponentContext context : children) { + + if(t<=90) { + + TCComponentBOMLine component = (TCComponentBOMLine) context.getComponent(); + if(component.getItem().getType().equals("HS2_SpecialMEP")) { + component.setStringProperty("hs2_ProcessNo", "A"); + AIFComponentContext[] children2 = component.getChildren(); + for(AIFComponentContext con:children2) { + TCComponentBOMLine component2 = (TCComponentBOMLine) con.getComponent(); + String bl_sequence_no = component2.getStringProperty("bl_sequence_no"); + component2.setStringProperty( "hs2_ProcessNo", "A"+ bl_sequence_no); + } + }else { + char x = (char)t; + component.setStringProperty("hs2_ProcessNo",String.valueOf(x)); + + AIFComponentContext[] children2 = component.getChildren(); + for(AIFComponentContext con:children2) { + TCComponentBOMLine component2 = (TCComponentBOMLine) con.getComponent(); + String bl_sequence_no = component2.getStringProperty("bl_sequence_no"); + component2.setStringProperty("hs2_ProcessNo", String.valueOf(x) + bl_sequence_no); + } + + t=t+1; + } + + } + + } + TCComponentBOMWindow window = topLine.window(); + topLine.save(); + topLine.refresh(); + window.save(); + window.close(); + } + + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + + MessageBox.post("更新完成","提示",2); + } catch (Exception e) { + // TODO: handle exception + wait.setBool(true);// 关闭进度条 + wait.interrupt(); + e.printStackTrace(); + } + } + private void setAllBomline(TCComponentBOMLine topLine) { + // TODO Auto-generated method stub + + try { + AIFComponentContext[] children = topLine.getChildren(); + int index=10; + for(AIFComponentContext context : children ) { + TCComponentBOMLine component =(TCComponentBOMLine) context.getComponent(); + + TCComponentItem item = topLine.getItem(); + if(item.getType().equals("HS2_SpecialMEP")) { + System.out.println("----父级是HS2_SpecialMEP----"+this.zxgyNo); + component.setStringProperty("bl_sequence_no", String.valueOf(zxgyNo)); + zxgyNo = zxgyNo +10; + }else { + component.setStringProperty("bl_sequence_no", String.valueOf(index)); + index = index +10; + setAllBomline(component); + } + + + } + + + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } +} diff --git a/src/com/connor/hs2/plm/updateGXno/test.java b/src/com/connor/hs2/plm/updateGXno/test.java new file mode 100644 index 0000000..cfa6c55 --- /dev/null +++ b/src/com/connor/hs2/plm/updateGXno/test.java @@ -0,0 +1,14 @@ +package com.connor.hs2.plm.updateGXno; + +public class test { + + public static void main(String[] args) { + int ascii = 90; + + char s=(char)ascii; + System.out.println(s); + System.out.println(String.valueOf(s)); + + } + +} diff --git a/src/com/connor/nbhs/plm/gyh/SendToEmail/SendToEmail.java b/src/com/connor/nbhs/plm/gyh/SendToEmail/SendToEmail.java new file mode 100644 index 0000000..3f631df --- /dev/null +++ b/src/com/connor/nbhs/plm/gyh/SendToEmail/SendToEmail.java @@ -0,0 +1,14 @@ +package com.connor.nbhs.plm.gyh.SendToEmail; + +public class SendToEmail { + public static void main(String[] args) { + System.out.println("handler传递过来的数据长度:" + args.length); + + System.out.println("数组内的值" + args[0] + args[1] + args[2] + args[3]); + try { + SoaServerUtil.sendToClass(args[0], args[1], args[2], args[3]); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/com/connor/nbhs/plm/gyh/SendToEmail/SoaServerUtil.java b/src/com/connor/nbhs/plm/gyh/SendToEmail/SoaServerUtil.java new file mode 100644 index 0000000..842f6bc --- /dev/null +++ b/src/com/connor/nbhs/plm/gyh/SendToEmail/SoaServerUtil.java @@ -0,0 +1,63 @@ +package com.connor.nbhs.plm.gyh.SendToEmail; + +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; + +/** + * 发送分类Util类 + * + * @author 61666 + * + */ +public class SoaServerUtil { + + public static void sendToClass(String theme, String user_mail, String job_name, 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("SendToEmail"); + sc.setOptions(opts); + + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("SendToEmail", omNs); + OMElement value = fac.createOMElement("theme", omNs); // 主题 + value.setText(theme); + OMElement value1 = fac.createOMElement("user_mail", omNs); // 地址 + value1.setText(user_mail); + OMElement value2 = fac.createOMElement("job_name", omNs);// 内容 + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + value2.setText(job_name); + + 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(); + } + + } + +} diff --git a/src/com/connor/nbhs/plm/gyh/hs028/hsdownload.java b/src/com/connor/nbhs/plm/gyh/hs028/hsdownload.java new file mode 100644 index 0000000..7f09afe --- /dev/null +++ b/src/com/connor/nbhs/plm/gyh/hs028/hsdownload.java @@ -0,0 +1,1534 @@ +package com.connor.nbhs.plm.gyh.hs028; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Desktop; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; + +import com.connor.hs2.plm.projectmanage.cpwlqd.CPWLQDCommad; +import com.connor.hs2.plm.projectmanage.cpwlqd.CPWLQDDialog; +import com.connor.hs2.plm.projectmanage.cpwlqd.CPWLQDOpeartion; +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.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentRevisionRule; +import com.teamcenter.rac.kernel.TCComponentRevisionRuleType; +import com.teamcenter.rac.kernel.TCComponentTask; +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; +import com.teamcenter.rac.util.PropertyLayout; + +public class hsdownload 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 ArrayList fmsFilelist = new ArrayList<>(); + private ArrayList hzmlist = new ArrayList<>(); + private ArrayList namelist = new ArrayList<>(); + private FileInputStream fis; + private FileOutputStream fos; + private JPanel btnPanel1; + private JPanel btnPanel2; + private JPanel btnPanel3; + private JPanel btnPanel4; + private JPanel btnPanel5; + private String hzm; + private int iDataset = 0; + private String datasetDir; + private Boolean outPartBool = false; + private JProgressBar bar; + private long fileSize = 0; + private Boolean allCheck = false; + private List noFileList = new ArrayList(); + private List datasetList = new ArrayList(); + private Map pathMap = new HashMap(); + private String pathString; + private Boolean isCarryRev = true; + private List carryRevList; + private JComboBox productComboBox; + File tempFile; + ExecutorService pool = Executors.newCachedThreadPool(); + + public hsdownload(AbstractAIFApplication arg0) { + this.app = arg0; + this.session = (TCSession) app.getSession(); + this.targets = app.getTargetComponents(); + } + @Override + public void run() { + // 显示窗口 + init(); + // 启用查询按钮 + } + // 获取下载文件列表 + private void getload(TCComponentDataset dataset, String path, List list, String itemid) { + + try { + TCComponentTcFile[] file = dataset.getTcFiles(); + // 如果没有文件 + if (file == null || file.length == 0) { + if (itemid.equals("sjj")) { + String noFileString = path + "_" + dataset.getStringProperty("object_name"); + noFileList.add(noFileString); + } + // 如果itemid不为“sjj” + else { + AIFComponentContext[] itemRev = dataset.whereReferenced(); + String items = ""; + for (AIFComponentContext context : itemRev) { + if (context.getComponent() instanceof TCComponentItemRevision) { + TCComponentItemRevision revision = (TCComponentItemRevision) context.getComponent(); + items = revision.getStringProperty("item_id") + "_" + + revision.getStringProperty("current_revision_id"); + } + } + String noFileString = items + "_" + dataset.getStringProperty("object_name"); + noFileList.add(noFileString); + } + return; + } + // 如果有文件 + else { + for (int i = 0; i < file.length; i++) { + if (!file[i].getType().equals("ImanFile")) { + continue; + } + // 获取后缀名 + hzm = file[i].getTCProperty("file_ext").getStringValue(); + // 获取文件名(带后缀) + if (list.contains(hzm)) { + String name = null; + // 根据数据集获取版本数组 + AIFComponentContext[] itemRev = dataset.whereReferenced(); + for (AIFComponentContext context : itemRev) { + // 遍历版本数组获取版本 + if(context.getComponent() instanceof TCComponentItemRevision) { + TCComponentItemRevision revision = (TCComponentItemRevision) context.getComponent(); + String itemString = revision.getProperty("item_id"); + String revidString = revision.getProperty("item_revision_id"); + String objectString = revision.getProperty("object_name"); + System.out.println("4.27-itemString:" + itemString); + System.out.println("4.27-revidString:" + revidString); + System.out.println("4.27-objectString:" + objectString); + // 获取版本类型 + if ("HS2_DesignRevision".equals(revision.getType()) + || "Part Revision".equals(revision.getType())) { + System.out.println("3.23-isCarryRevs:" + isCarryRev); + + // 如果是设计版本,则直接获取属性,则先获取设计版本,再获取属性 + + if ("HS2_DesignRevision".equals(revision.getType())) { + name =itemString+"-"+revidString+"-"+objectString; + System.out.println("4.26-14-36-datasetname:" + name); + } + // 如果是零件版本,则先获取设计版本,再获取属性,则直接获取属性 + else if ("Part Revision".equals(revision.getType())) { + name =itemString+"-"+revidString+"-"+objectString; + } + } + // 如果都不是,是其他的版本 + else { + name =itemString+"-"+revidString+"-"+objectString; + } + } + } + if(name==null || itemRev.length==0) { + name = dataset.getStringProperty("object_name"); + } + if (name.contains(".")) { + // 获取文件名(不带后缀) + name = name.substring(0, name.lastIndexOf(".")); + } + String replace = name.replace("/", "-").replace("<", "-").replace(">", "-").replace(":", "-") + .replace("|", "-").replace("\\", "-").replace("*", "-").replace("?", "-"); +// int t=1; +// while(namelist.contains(path + File.separator + replace)) { +// System.out.println("有重复的 "+replace); +// replace = replace + "("+String.valueOf(t)+")"; +// t=t+1; +// } + // 获取文件用户下载 + File fmsFile = file[i].getFmsFile(); + hzmlist.add(hzm); + namelist.add(path + File.separator + replace); + System.out.println("4.26-namelist:" + path + "replace" + replace); + fmsFilelist.add(fmsFile); + fileSize = fileSize + fmsFile.length(); + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("发生错误:" + e.getMessage(), "错误", MessageBox.ERROR); + } + } + + // 文件下载到指定路径 + private void downloadfile(String fpath) { + try { + long hasReadByte = 0L;// 已经读取的字节个数 + float result; + int progressSize = 0; + System.out.println("hzmlist.size()=4.25:" +hzmlist.size()); + for (int i = 0; i < hzmlist.size(); i++) { + // 拼接输出文件名 + String filename = namelist.get(i) + "." + hzmlist.get(i); + // 拼接输出带路径全文件名 + System.out.println("fpath=4.25:" +fpath); + System.out.println("filename=4.25:" +filename); + String path = fpath + File.separator + filename; + System.out.println("path=8.3:" + path); + File fileout = new File(path); + fis = new FileInputStream(fmsFilelist.get(i)); + fos = new FileOutputStream(fileout); + byte[] bs = new byte[1024]; + int len = 0; + while ((len = fis.read(bs)) != -1) { + fos.write(bs, 0, len); + hasReadByte = hasReadByte + len; + result = (float) ((double) hasReadByte / fileSize); + progressSize = Math.round(result * 100); + updateProgress(bar, progressSize); + } + if (progressSize < 100) { + updateProgress(bar, progressSize); + } + if (progressSize == 100) { + bar.setForeground(Color.blue); + } + if (fos != null) + fos.close(); + if (fis != null) + fis.close(); + } + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post("下载失败:" + e.getMessage(), "错误", MessageBox.ERROR); + } finally { + try { + fos.close(); + fis.close(); + MessageBox.post("下载完成", "2", 2); + this.dispose(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + // 弹出下载路径选择框 + public void selectFileButtonEvent() { + int state = jFileChooser.showOpenDialog(null); + if (state == 1) { + return; + } else { + File f = jFileChooser.getSelectedFile(); + jtf.setText(f.getAbsolutePath()); + } + } + + // 界面初始化 + private void init() { + this.setLayout(new PropertyLayout()); + this.setPreferredSize(new Dimension(650, 300)); + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + // 第一行:图纸类型 + btnPanel1 = new JPanel(); + JLabel drawingtype = new JLabel("图纸类型:"); + JCheckBox checkBox1 = new JCheckBox("Word"); + JCheckBox checkBox2 = new JCheckBox("Excel");// new + JCheckBox checkBox3 = new JCheckBox("PDF"); + btnPanel1.add("1.1.left.top", drawingtype); + btnPanel1.add("1.2.left.top", checkBox1); + btnPanel1.add("1.3.left.top", checkBox2); + btnPanel1.add("1.4.left.top", checkBox3); + checkBox3.setSelected(true); + // 第二行:零件类型 + btnPanel2 = new JPanel(); + // 第三行附加条件 + btnPanel3 = new JPanel(); + JLabel additional = new JLabel("附加筛选:"); + JCheckBox checkBox22 = new JCheckBox("仅下载已发布图纸"); + btnPanel3.add("1.1.left.top", additional); + btnPanel3.add("1.3.left.top", checkBox22); + // 第四行行选项 + btnPanel4 = new JPanel(); + JCheckBox bt4op1 = new JCheckBox("图纸"); + bt4op1.setSelected(true); + JCheckBox bt4op2 = new JCheckBox("其他"); + + + btnPanel4.add("1.1.left.top", bt4op1); + btnPanel4.add("1.2.left.top", bt4op2); + btnPanel5 = new JPanel(); + JCheckBox bt4op3 = new JCheckBox("生成产品物料清单"); + bt4op3.setSelected(true); + btnPanel5.add("1.1.left.top", bt4op3); + // 第五行下载选项 + jLabel = new JLabel("下载路径:"); + jtf.setText(deskPath); + jButton = new JButton("浏览"); + jFileChooser = new JFileChooser(); + this.jFileChooser.setCurrentDirectory(new File(deskPath)); + this.jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + JPanel panel = new JPanel(); + panel.add("1.1.left.top", jLabel); + panel.add("1.2.left.top", jtf); + panel.add("1.3.left.top", jButton); + panel.add("2.1.left.top", okBut); + panel.add("2.2.left.top", celBut); + this.add("1.1.left.top", btnPanel1); + this.add("2.1.left.top", btnPanel2); + this.add("3.1.left.top", btnPanel3); + this.add("4.1.left.top", btnPanel4); + this.add("5.1.left.top", btnPanel5); + this.add("6.1.left.top", panel); + this.setResizable(false); + this.setBounds(5, 5, 5, 5); + this.centerToScreen(); + this.showDialog(); + jButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + selectFileButtonEvent(); + } + }); + okBut.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + carryRevList = getIscarryRev(); + if (null == carryRevList || carryRevList.size() == 0) { + isCarryRev = true; + } else if (carryRevList.size() == 2) { + isCarryRev = true; + } else if (carryRevList.contains("其他")) { + isCarryRev = true; + } else { + isCarryRev = false; + } + datasetList.add("MSExcelX"); + datasetList.add("MSExcel"); + datasetList.add("MSWordX"); + datasetList.add("MSWord"); + datasetList.add("PDF"); + Component[] jcbs = btnPanel2.getComponents();// 将勾选的内容存入数组 + Boolean btnpa2 = false; + for (Component component : jcbs) { + if (component instanceof JCheckBox) { + JCheckBox checkBox = (JCheckBox) component; + if (checkBox.isSelected()) { + btnpa2 = true; + } + } + } + Component[] jcbs2 = btnPanel1.getComponents();// 将勾选的内容存入数组 + Boolean btnpa1 = false; + for (Component component : jcbs2) { + if (component instanceof JCheckBox) { + JCheckBox checkBox = (JCheckBox) component; + if (checkBox.isSelected()) { + btnpa1 = true; + } + } + } + if (!btnpa1) { + MessageBox.post("请选择图纸类型", "提示", 2); + } + Boolean ljlxno = false; + + for (int t = 0; t < targets.length; t++) { + if (targets[t] instanceof TCComponentDataset) { + } else { + ljlxno = true; + } + } + if ((!btnpa2 || !ljlxno) && btnpa1) { + getTypes(); + if (fmsFilelist.size() != 0) { + System.out.print("开始下载"); + final String fpath = jtf.getText(); + if (fpath != null && (!fpath.trim().equals(""))) { + new Thread(new Runnable() { + @Override + public void run() { + JDialog dialog = new JDialog(); + bar = new JProgressBar(0, 100); + Container contentPane = dialog.getContentPane(); + contentPane.setLayout(new GridLayout(2, 1)); + JTextField text = new JTextField("下载中"); + contentPane.add("1.1.center.top", text); + contentPane.add("2.1.center.top", bar); + dialog.setSize(300, 100); + dialog.setVisible(true); + dialog.setLocationRelativeTo(dialog.getParent()); + downloadfile(fpath); + dialog.setVisible(false); + } + }).start(); + + } else { + MessageBox.post("文件路径不能为空!", "警告", MessageBox.INFORMATION); + } + } else { + MessageBox.post("没有找到符合条件的数据集", "提示", 2); + } + if (noFileList.size() != 0) { + OutputStreamWriter outputStreamWriter; + try { + outputStreamWriter = new OutputStreamWriter( + new FileOutputStream(pathString + File.separator + "部分数据集没有命名的引用.txt")); + BufferedWriter bWriter = new BufferedWriter(outputStreamWriter); + for (String liString : noFileList) { + bWriter.write(liString); + bWriter.newLine(); + } + bWriter.close(); + outputStreamWriter.close(); + + if (Desktop.isDesktopSupported()) { + File worksheet = new File(pathString + File.separator + "部分数据集没有命名的引用.txt"); + Desktop.getDesktop().open(worksheet); // or Desktop.getDesktop().edit(worksheet); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + //获取生产清单的值 + Component[] scqd = btnPanel4.getComponents(); + Boolean btnpa5 = false; + TCComponentItemRevision revision = null; + if(bt4op3.isSelected()==true) { + btnpa5 = true; + } + System.out.println("4.29-btnpa5="+btnpa5); + if (btnpa5) { + try { + System.out.println("进行导出-----------"); + String outPath = jtf.getText(); + if (app.getTargetComponent().getType().equals("HS2_ProductPartRevision")){ + revision = (TCComponentItemRevision)app.getTargetComponent(); + + }else if (app.getTargetComponent() instanceof TCComponentBOMLine) + { + TCComponentBOMLine line = (TCComponentBOMLine)app.getTargetComponent(); + if (line.getItemRevision().getType().equals("HS2_ProductPartRevision")) { + revision = line.getItemRevision(); + } + } + productComboBox = new JComboBox(); + TCComponent[] representations = revision.getReferenceListProperty("representation_for"); + if (representations.length == 0) { + MessageBox.post("该图纸下没有物料,请检查!","提示",2); + return ; + }else { + for (int i = 0; i < representations.length; i++) { + if (representations[i] instanceof TCComponentItemRevision) { + productComboBox.addItem((TCComponentItemRevision)representations[i]); + } + } + } + tempFile = getSXX(); + if (tempFile==null) { + return ; + } + TCComponentBOMLine designTopLine = sendToStructureManager(revision); + TCComponentItemRevision wlRevision = (TCComponentItemRevision)productComboBox.getSelectedItem(); + TCComponentBOMLine wlTopLine = sendToStructureManager(wlRevision); + CPWLQDOpeartion operation = new CPWLQDOpeartion(session, app,designTopLine,wlTopLine,tempFile,outPath); + session.queueOperation(operation); + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + }); + celBut.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + setVisible(false); + } + }); + this.pack(); + this.setResizable(false); + this.centerToScreen(); + this.showDialog(); + } + + // 获取图纸类型 + public void getTypes() { + List list = new ArrayList(); + Component[] jcbs = btnPanel1.getComponents();// 将勾选的内容存入数组 + for (Component component : jcbs) { + if (component instanceof JCheckBox) { + JCheckBox jcb = (JCheckBox) component; + if (jcb.isSelected()) { + list.add(jcb.getText()); + if ("Word".equals(jcb.getText())) { + list.add("doc"); + list.add("docx"); + } else if ("Excel".equals(jcb.getText())) { + list.add("xls"); + list.add("xlsx"); + } else if ("PDF".equals(jcb.getText())) { + list.add("pdf"); + list.add("PDF"); + } + } + } + } + try { + System.out.println("4.29-选中的个数:"+ targets.length); + for (int i = 0; i < targets.length; i++) { + // 如果选中的对象为版本 + if (targets[i] instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) targets[i]; + String revtype = rev.getType(); + // 如果是设计版本 + if ("HS2_ProductPartRevision".equals(revtype)) { + String objName = rev.getStringProperty("object_name"); + String replace = objName.replace("/", "-").replace("<", "-").replace(">", "-").replace(":", "-") + .replace("|", "-").replace("\\", "-").replace("*", "-").replace("?", "-"); + + String dataDir = jtf.getText() + File.separator + rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace;// 创建版本文件夹 + File csFile = new File(dataDir); + // 数据版本创建自己的文件夹 + String dataName = rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace;// 文件名 + String dataName2 = ""; + pathString = dataDir; + + if (!csFile.exists()) { + csFile.mkdir(); + } + // 遍历视图 去找符合条件的 文件夹已经创建 + TCComponent[] comps = rev.getReferenceListProperty("HS2_Standard"); + downloadStandard(comps,dataName,list,dataName); + getOutPart(rev, dataName, list); + dataName2 = dataName + File.separator + rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace;// 文件名 + TCComponent[] datasets = rev.getReferenceListProperty("IMAN_specification"); + TCComponent[] datasets2 = rev.getReferenceListProperty("IMAN_Rendering"); + for (int j = 0; j < datasets.length; j++) { + + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets[j] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets[j]; + } else { + continue; + } + // 执行获取后缀名的方法 + String type = dataset02.getType(); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets[j]; + System.out.println("下载文件"); + getload(dataset, dataName, list, rev.getStringProperty("item_id")); + } + + } + for (int j = 0; j < datasets2.length; j++) { + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets2[j] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets2[j]; + } else { + continue; + } + // 执行获取后缀名的方法 +// gethzm(dataset02); + String type = dataset02.getType(); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets2[j]; + getload(dataset, dataName, list, rev.getStringProperty("item_id")); + } + } + } + // 如果是零件版本 + else if ("Part Revision".equals(revtype)) { + TCComponentItemRevision lastrev = null; + TCComponent[] design = rev.getReferenceListProperty("TC_Is_Represented_By"); + for (int j = 0; j < design.length; j++) { + TCComponentItemRevision designrev = null; + if (design[j] instanceof TCComponentItemRevision) { + designrev = (TCComponentItemRevision) design[j]; + TCComponentItem designitem = designrev.getItem(); + lastrev = designitem.getLatestItemRevision(); + } + } + String objName = rev.getStringProperty("object_name"); + String replace = objName.replace("/", "-").replace("<", "-").replace(">", "-").replace(":", "-") + .replace("|", "-").replace("\\", "-").replace("*", "-").replace("?", "-"); + String dataDir = jtf.getText() + File.separator + rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace;// 创建版本文件夹 + File csFile = new File(dataDir); + // 数据版本创建自己的文件夹 + String dataName = rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace;// 文件名 + String dataName2 = ""; + pathString = dataDir; + if (!csFile.exists()) { + csFile.mkdir(); + } + // 遍历视图 去找符合条件的 文件夹已经创建 + getOutPart(rev, dataName, list); + dataName2 = dataName + File.separator + rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace;// 文件名 + TCComponent[] datasets = lastrev.getReferenceListProperty("IMAN_specification"); + TCComponent[] datasets2 = lastrev.getReferenceListProperty("IMAN_Rendering"); + for (int j = 0; j < datasets.length; j++) { + + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets[j] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets[j]; + } else { + continue; + } + // 执行获取后缀名的方法 +// gethzm(dataset02); + String type = dataset02.getType(); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets[j]; + System.out.println("下载文件"); + getload(dataset, dataName, list, lastrev.getStringProperty("item_id")); + } + + } + for (int j = 0; j < datasets2.length; j++) { + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets2[j] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets2[j]; + } else { + continue; + } + // 执行获取后缀名的方法 +// gethzm(dataset02); + String type = dataset02.getType(); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets2[j]; + getload(dataset, dataName, list, lastrev.getStringProperty("item_id")); + } + } + } + // 如果是其他版本 + else { + String objName = rev.getStringProperty("object_name"); + String replace = objName.replace("/", "-").replace("<", "-").replace(">", "-").replace(":", "-") + .replace("|", "-").replace("\\", "-").replace("*", "-").replace("?", "-"); + String dataDir = jtf.getText() + File.separator + rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace;// 创建版本文件夹 + File csFile = new File(dataDir); + // 数据版本创建自己的文件夹 + String dataName = rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace;// 文件名 + String dataName2 = ""; + pathString = dataDir; + if (!csFile.exists()) { + csFile.mkdir(); + } + // 遍历视图 去找符合条件的 文件夹已经创建 + getOutPart(rev, dataName, list); + dataName2 = dataName + File.separator + rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace;// 文件名 + TCComponent[] datasets = rev.getReferenceListProperty("IMAN_specification"); + TCComponent[] datasets2 = rev.getReferenceListProperty("IMAN_Rendering"); + TCComponent[] datasets3 = rev.getReferenceListProperty("TC_Attaches"); + for (int j = 0; j < datasets.length; j++) { + + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets[j] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets[j]; + } else { + continue; + } + // 执行获取后缀名的方法 + String type = dataset02.getType(); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets[j]; + System.out.println("下载文件"); + getload(dataset, dataName, list, rev.getStringProperty("item_id")); + } + } + for (int j = 0; j < datasets2.length; j++) { + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets2[j] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets2[j]; + } else { + continue; + } + // 执行获取后缀名的方法 + String type = dataset02.getType(); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets2[j]; + getload(dataset, dataName, list, rev.getStringProperty("item_id")); + } + } + for (int j = 0; j < datasets3.length; j++) { + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets3[j] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets3[j]; + } else { + continue; + } + // 执行获取后缀名的方法 + String type = dataset02.getType(); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets3[j]; + getload(dataset, dataName, list, rev.getStringProperty("item_id")); + } + } + } + } + // 如果选中的对象为数据集 + else if (targets[i] instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) targets[i]; + String dataName = ""; + String objName = dataset.getStringProperty("object_name"); + String replaceName = objName.replace("/", "-").replace("<", "-").replace(">", "-").replace(":", "-") + .replace("|", "-").replace("\\", "-").replace("*", "-").replace("?", "-"); + if (iDataset == 0) { + dataName = jtf.getText() + File.separator + replaceName; + datasetDir = replaceName; + pathString = dataName; + File csFile = new File(dataName); + if (!csFile.exists()) { + csFile.mkdir(); + } + } + iDataset = 1; + String type = dataset.getType(); + if (datasetList.contains(type)) { + getload(dataset, datasetDir, list, "sjj"); + } + } + // 如果选中的是数据集 + else if (targets[i] instanceof TCComponentTask) { + TCComponentTask task = (TCComponentTask) targets[0]; + TCComponent[] tars = task.getReferenceListProperty("root_target_attachments"); + for (int j = 0; j < tars.length; j++) { + if (tars[j] instanceof TCComponentItemRevision) { + TCComponentItemRevision taskrev = (TCComponentItemRevision) tars[j]; + String taskrevtype = taskrev.getType(); + if ("HS2_ProductPartRevision".equals(taskrevtype)) { + String objName = taskrev.getStringProperty("object_name"); + String replace = objName.replace("/", "-").replace("<", "-").replace(">", "-") + .replace(":", "-").replace("|", "-").replace("\\", "-").replace("*", "-") + .replace("?", "-"); + String dataDir = jtf.getText() + File.separator + taskrev.getStringProperty("item_id") + + "_" + taskrev.getStringProperty("current_revision_id") + "_" + replace;// 创建版本文件夹 + + File csFile = new File(dataDir); + // 数据版本创建自己的文件夹 + String dataName = taskrev.getStringProperty("item_id") + "_" + + taskrev.getStringProperty("current_revision_id") + "_" + replace;// 文件名 + String dataName2 = ""; + pathString = dataDir; + if (!csFile.exists()) { + csFile.mkdir(); + } + // 遍历视图 去找符合条件的 文件夹已经创建 + getOutPart(taskrev, dataName, list); + dataName2 = dataName + File.separator + taskrev.getStringProperty("item_id") + "_" + + taskrev.getStringProperty("current_revision_id") + "_" + replace;// 文件名 + TCComponent[] datasets = taskrev.getReferenceListProperty("IMAN_specification"); + TCComponent[] datasets2 = taskrev.getReferenceListProperty("IMAN_Rendering"); + for (int k = 0; k < datasets.length; k++) { + + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets[j] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets[j]; + } else { + continue; + } + // 执行获取后缀名的方法 + String type = dataset02.getType(); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets[j]; + System.out.println("下载文件"); + getload(dataset, dataName, list, taskrev.getStringProperty("item_id")); + } + + } + for (int k = 0; k < datasets2.length; k++) { + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets2[j] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets2[j]; + } else { + continue; + } + // 执行获取后缀名的方法 + String type = dataset02.getType(); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets2[j]; + getload(dataset, dataName, list, taskrev.getStringProperty("item_id")); + } + } + } else if ("Part Revision".equals(taskrevtype)) { + TCComponent[] design = taskrev.getReferenceListProperty("TC_Is_Represented_By"); + TCComponentItemRevision lastrev = null; + for (int k = 0; k < design.length; k++) { + TCComponentItemRevision designrev = null; + if (design[j] instanceof TCComponentItemRevision) { + designrev = (TCComponentItemRevision) design[j]; + TCComponentItem designitem = designrev.getItem(); + lastrev = designitem.getLatestItemRevision(); + } + } + String objName = taskrev.getStringProperty("object_name"); + String replace = objName.replace("/", "-").replace("<", "-").replace(">", "-") + .replace(":", "-").replace("|", "-").replace("\\", "-").replace("*", "-") + .replace("?", "-"); + String dataDir = jtf.getText() + File.separator + taskrev.getStringProperty("item_id") + + "_" + taskrev.getStringProperty("current_revision_id") + "_" + replace;// 创建版本文件夹 + + File csFile = new File(dataDir); + // 数据版本创建自己的文件夹 + String dataName = taskrev.getStringProperty("item_id") + "_" + + taskrev.getStringProperty("current_revision_id") + "_" + replace;// 文件名 + String dataName2 = ""; + pathString = dataDir; + if (!csFile.exists()) { + csFile.mkdir(); + } + // 遍历视图 去找符合条件的 文件夹已经创建 + getOutPart(lastrev, dataName, list); + dataName2 = dataName + File.separator + taskrev.getStringProperty("item_id") + "_" + + taskrev.getStringProperty("current_revision_id") + "_" + replace;// 文件名 + TCComponent[] datasets = lastrev.getReferenceListProperty("IMAN_specification"); + TCComponent[] datasets2 = lastrev.getReferenceListProperty("IMAN_Rendering"); + for (int k = 0; k < datasets.length; k++) { + + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets[k] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets[k]; + } else { + continue; + } + // 执行获取后缀名的方法 +// gethzm(dataset02); + String type = dataset02.getType(); + System.out.println("3.24-type:" + type); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets[k]; + System.out.println("下载文件"); + getload(dataset, dataName, list, lastrev.getStringProperty("item_id")); + } + } + for (int k = 0; k < datasets2.length; k++) { + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets2[k] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets2[k]; + } else { + continue; + } + // 执行获取后缀名的方法 +// gethzm(dataset02); + String type = dataset02.getType(); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets2[k]; + getload(dataset, dataName, list, lastrev.getStringProperty("item_id")); + } + } + } else { + String objName = taskrev.getStringProperty("object_name"); + String replace = objName.replace("/", "-").replace("<", "-").replace(">", "-") + .replace(":", "-").replace("|", "-").replace("\\", "-").replace("*", "-") + .replace("?", "-"); + String dataDir = jtf.getText() + File.separator + taskrev.getStringProperty("item_id") + + "_" + taskrev.getStringProperty("current_revision_id") + "_" + replace;// 创建版本文件夹 + File csFile = new File(dataDir); + // 数据版本创建自己的文件夹 + String dataName = taskrev.getStringProperty("item_id") + "_" + + taskrev.getStringProperty("current_revision_id") + "_" + replace;// 文件名 + String dataName2 = ""; + pathString = dataDir; + if (!csFile.exists()) { + csFile.mkdir(); + } + // 遍历视图 去找符合条件的 文件夹已经创建 + getOutPart(taskrev, dataName, list); + dataName2 = dataName + File.separator + taskrev.getStringProperty("item_id") + "_" + + taskrev.getStringProperty("current_revision_id") + "_" + replace;// 文件名 + TCComponent[] datasets = taskrev.getReferenceListProperty("IMAN_specification"); + TCComponent[] datasets2 = taskrev.getReferenceListProperty("IMAN_Rendering"); + TCComponent[] datasets3 = taskrev.getReferenceListProperty("TC_Attaches"); + for (int k = 0; k < datasets.length; k++) { + + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets[k] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets[k]; + } else { + continue; + } + // 执行获取后缀名的方法 + String type = dataset02.getType(); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets[k]; + System.out.println("下载文件"); + getload(dataset, dataName, list, taskrev.getStringProperty("item_id")); + } + } + for (int k = 0; k < datasets2.length; k++) { + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets2[k] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets2[k]; + } else { + continue; + } + // 执行获取后缀名的方法 +// gethzm(dataset02); + String type = dataset02.getType(); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets2[k]; + getload(dataset, dataName, list, taskrev.getStringProperty("item_id")); + } + } + for (int k = 0; k < datasets3.length; k++) { + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets3[k] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets3[k]; + } else { + continue; + } + // 执行获取后缀名的方法 +// gethzm(dataset02); + String type = dataset02.getType(); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets3[k]; + getload(dataset, dataName, list, taskrev.getStringProperty("item_id")); + } + } + + } + } + } + }else if (targets[i] instanceof TCComponentFolder) { + TCComponentFolder folder = (TCComponentFolder)targets[i]; + String separator = folder.getStringProperty("object_name").replace("/", "-").replace("<", "-").replace(">", "-").replace(":", "-") + .replace("|", "-").replace("\\", "-").replace("*", "-").replace("?", "-"); + if (separator.contains(".")) { + // 获取文件名(不带后缀) + separator = separator.substring(0, separator.lastIndexOf(".")); + } + File csFile2 = new File(jtf.getText() + File.separator + separator); + if (!csFile2.exists()) { + csFile2.mkdir(); + } + String relateString = "contents"; +// System.out.println("component"+component.getType()); + if(folder.getType().equals("HS2_ProjectFolder")) { + relateString = "HS2_ProjectFolderRelation"; + } + TCComponent[] contents = folder.getReferenceListProperty(relateString); + loadInFolder(contents,separator,list,folder); + } + else { + MessageBox.post("选中的不是版本对象或者任务对象或者数据集对象", "error", MessageBox.ERROR); + return; + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } + + + public void loadInFolder(TCComponent[] contents, String separator, List list, TCComponentFolder folder) throws TCException { + for(TCComponent component : contents) { + String relateString = "contents"; +// System.out.println("component"+component.getType()); + if(component.getType().equals("HS2_ProjectFolder")) { + relateString = "HS2_ProjectFolderRelation"; + } + if(component instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) component; + String dataName = ""; + String objName = dataset.getStringProperty("object_name"); + String replaceName = objName.replace("/", "-").replace("<", "-").replace(">", "-").replace(":", "-") + .replace("|", "-").replace("\\", "-").replace("*", "-").replace("?", "-"); + if (iDataset == 0) { + dataName = jtf.getText() + File.separator + folder.getStringProperty("object_name"); + datasetDir = separator; + pathString = dataName; + File csFile = new File(dataName); + if (!csFile.exists()) { + csFile.mkdir(); + } + } + iDataset = 1; + String type = dataset.getType(); + if (datasetList.contains(type)) { + getload(dataset, datasetDir, list, "sjj"); + } + }else if (component instanceof TCComponentItem) { + TCComponentItemRevision taskrev = ( (TCComponentItem)component).getLatestItemRevision() ; + String taskrevtype = taskrev.getType(); + System.out.println("taskrevtype"+taskrevtype); + if ("HS2_ProductPartRevision".equals(taskrevtype)) { + String objName = taskrev.getStringProperty("object_name"); + String replace = objName.replace("/", "-").replace("<", "-").replace(">", "-") + .replace(":", "-").replace("|", "-").replace("\\", "-").replace("*", "-") + .replace("?", "-"); + String dataDir = jtf.getText() + File.separator +separator;// 创建版本文件夹 + + File csFile = new File(dataDir); + // 数据版本创建自己的文件夹 + String dataName = separator;// 文件名 + String dataName2 = ""; + pathString = dataDir; + if (!csFile.exists()) { + csFile.mkdir(); + } + // 遍历视图 去找符合条件的 文件夹已经创建 + getOutPart(taskrev, dataName, list); + dataName2 = dataName + File.separator + taskrev.getStringProperty("item_id") + "_" + + taskrev.getStringProperty("current_revision_id") + "_" + replace;// 文件名 + TCComponent[] datasets = taskrev.getReferenceListProperty("IMAN_specification"); + TCComponent[] datasets2 = taskrev.getReferenceListProperty("IMAN_Rendering"); + for (int k = 0; k < datasets.length; k++) { + + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets[k] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets[k]; + } else { + continue; + } + // 执行获取后缀名的方法 + String type = dataset02.getType(); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets[k]; + System.out.println("下载文件"); + getload(dataset, dataName, list, taskrev.getStringProperty("item_id")); + } + + } + for (int k = 0; k < datasets2.length; k++) { + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets2[k] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets2[k]; + } else { + continue; + } + // 执行获取后缀名的方法 + String type = dataset02.getType(); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets2[k]; + getload(dataset, dataName, list, taskrev.getStringProperty("item_id")); + } + } + } else if ("Part Revision".equals(taskrevtype)) { + TCComponent[] design = taskrev.getReferenceListProperty("TC_Is_Represented_By"); + TCComponentItemRevision lastrev = null; + for (int k = 0; k < design.length; k++) { + TCComponentItemRevision designrev = null; + if (design[k] instanceof TCComponentItemRevision) { + designrev = (TCComponentItemRevision) design[k]; + TCComponentItem designitem = designrev.getItem(); + lastrev = designitem.getLatestItemRevision(); + } + } + String objName = taskrev.getStringProperty("object_name"); + String replace = objName.replace("/", "-").replace("<", "-").replace(">", "-") + .replace(":", "-").replace("|", "-").replace("\\", "-").replace("*", "-") + .replace("?", "-"); + String dataDir = jtf.getText() + File.separator +separator ;// 创建版本文件夹 + + File csFile = new File(dataDir); + // 数据版本创建自己的文件夹 + String dataName = separator ;// 文件名 +// + File.separator +taskrev.getStringProperty("item_id") + "_" +// + taskrev.getStringProperty("current_revision_id") + "_" + replace + String dataName2 = ""; + pathString = dataDir; + if (!csFile.exists()) { + csFile.mkdir(); + } + // 遍历视图 去找符合条件的 文件夹已经创建 + getOutPart(lastrev, dataName, list); + dataName2 = dataName + File.separator + taskrev.getStringProperty("item_id") + "_" + + taskrev.getStringProperty("current_revision_id") + "_" + replace;// 文件名 + TCComponent[] datasets = lastrev.getReferenceListProperty("IMAN_specification"); + TCComponent[] datasets2 = lastrev.getReferenceListProperty("IMAN_Rendering"); + for (int k = 0; k < datasets.length; k++) { + + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets[k] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets[k]; + } else { + continue; + } + // 执行获取后缀名的方法 +// gethzm(dataset02); + String type = dataset02.getType(); + System.out.println("3.24-type:" + type); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets[k]; + System.out.println("下载文件"); + getload(dataset, dataName, list, lastrev.getStringProperty("item_id")); + } + } + for (int k = 0; k < datasets2.length; k++) { + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets2[k] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets2[k]; + } else { + continue; + } + // 执行获取后缀名的方法 +// gethzm(dataset02); + String type = dataset02.getType(); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets2[k]; + getload(dataset, dataName, list, lastrev.getStringProperty("item_id")); + } + } + } else { + String objName = taskrev.getStringProperty("object_name"); + String replace = objName.replace("/", "-").replace("<", "-").replace(">", "-") + .replace(":", "-").replace("|", "-").replace("\\", "-").replace("*", "-") + .replace("?", "-"); + String dataDir = jtf.getText() + File.separator +separator;// 创建版本文件夹 + File csFile = new File(dataDir); + // 数据版本创建自己的文件夹 + String dataName = separator ;// 文件名 + String dataName2 = ""; + pathString = dataDir; + if (!csFile.exists()) { + csFile.mkdir(); + } + // 遍历视图 去找符合条件的 文件夹已经创建 + getOutPart(taskrev, dataName, list); +// dataName2 = dataName + File.separator + taskrev.getStringProperty("item_id") + "_" +// + taskrev.getStringProperty("current_revision_id") + "_" + replace;// 文件名 + TCComponent[] datasets = taskrev.getReferenceListProperty("IMAN_specification"); + TCComponent[] datasets2 = taskrev.getReferenceListProperty("IMAN_Rendering"); + TCComponent[] datasets3 = taskrev.getReferenceListProperty("TC_Attaches"); + System.out.println("itemRevision"+taskrev.getStringProperty("object_name")+datasets.length); + for (int k = 0; k < datasets.length; k++) { + + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets[k] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets[k]; + } else { + continue; + } + // 执行获取后缀名的方法 + String type = dataset02.getType(); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets[k]; + System.out.println("下载文件"); + getload(dataset, dataName, list, taskrev.getStringProperty("item_id")); + } + } + for (int k = 0; k < datasets2.length; k++) { + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets2[k] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets2[k]; + } else { + continue; + } + // 执行获取后缀名的方法 +// gethzm(dataset02); + String type = dataset02.getType(); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets2[k]; + getload(dataset, dataName, list, taskrev.getStringProperty("item_id")); + } + } + for (int k = 0; k < datasets3.length; k++) { + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets3[k] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets3[k]; + } else { + continue; + } + // 执行获取后缀名的方法 +// gethzm(dataset02); + String type = dataset02.getType(); + // 判断零件类型 + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets3[k]; + getload(dataset, dataName, list, taskrev.getStringProperty("item_id")); + } + } + + } + }else if (component instanceof TCComponentFolder) { + TCComponent[] content = component.getReferenceListProperty(relateString); + loadInFolder(content,separator,list,folder); + } + } + } + + // 获取零件类型 + public List getitemType() { + List itemlist = new ArrayList(); + itemlist.add("Part Revision"); + return itemlist; + } + + /* + * 版本 + * 目录 + * 后缀名 + */ + + public void getOutPart(TCComponentItemRevision rev, String dir, List list) throws TCException { + + TCComponentItem item = rev.getItem(); + + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeService() + .getTypeComponent("BOMWindow"); + TCComponentBOMWindow window = winType.create(null); + window.lock(); + String revString = rev.getProperty("object_name"); + TCComponentBOMLine topLine = window.setWindowTopLine(item, rev, null, null); + AIFComponentContext[] children2 = new AIFComponentContext[4096]; + children2 = topLine.getChildren(); + for (int i = 0; i < children2.length; i++) { + TCComponentBOMLine line = (TCComponentBOMLine) children2[i].getComponent(); + getOutPartInBom(line, 0, dir, list, 0, dir); + } + window.save(); + window.unlock(); + window.close(); + } + + // 遍历bom视图 + public void getOutPartInBom(TCComponentBOMLine bomLine, int i, String dir, List list, int bomNum, + String dirFs) throws TCException { + TCComponentItemRevision rev = bomLine.getItemRevision(); + String revname = rev.getProperty("item_id"); + + if (i == 0) { + pathMap.put("1", dir); + if (bomLine.getChildren().length != 0) { + + } + } + i++; + //} + TCComponent[] datasets = rev.getReferenceListProperty("IMAN_specification"); + TCComponent[] datasets2 = rev.getReferenceListProperty("IMAN_Rendering"); + if("HS2_ProductPartRevision".equals(rev.getType())) { + TCComponent[] comps = rev.getReferenceListProperty("HS2_Standard"); + downloadStandard(comps,dir,list,dirFs); + } + for (int j = 0; j < datasets.length; j++) { + // 获取数据集数组 + TCComponentDataset dataset01 = null; + if (datasets[j] instanceof TCComponentDataset) { + dataset01 = (TCComponentDataset) datasets[j]; + } else { + continue; + } + + String type = dataset01.getStringProperty("object_type"); + String name = dataset01.getStringProperty("current_name"); + getload(dataset01, dirFs, list, rev.getStringProperty("item_id")); + + // 判断list包含hzm字符串的值 且 itemlist包含revtype的值 + if (datasetList.contains(type)) { + // 获取数据集数据 + TCComponentDataset dataset02 = null; + if (datasets[j] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets[j]; + } else { + continue; + } + // 执行getload方法 + getload(dataset02, dir, list, rev.getStringProperty("item_id")); + // 复制一份到父级 + if (!dir.equals(dirFs)) { + getload(dataset01, dirFs, list, rev.getStringProperty("item_id")); + } + if (!dir.equals(pathMap.get("1")) && pathMap.get("1") != null) { + getload(dataset02, pathMap.get("1"), list, rev.getStringProperty("item_id")); + } + } + } + for (int j = 0; j < datasets2.length; j++) { + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets2[j] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets2[j]; + } else { + continue; + } + // 执行获取后缀名的方法 + // 判断是否为所需要的零件类型 + String type = dataset02.getStringProperty("object_type"); + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets2[j]; + getload(dataset, dir, list, rev.getStringProperty("item_id")); + if (!dir.equals(dirFs)) { + getload(dataset, dirFs, list, rev.getStringProperty("item_id")); + } + if (!dir.equals(pathMap.get("1"))) { + getload(dataset02, pathMap.get("1"), list, rev.getStringProperty("item_id")); + } + } + + } + AIFComponentContext[] children = bomLine.getChildren(); + for (AIFComponentContext context : children) { + TCComponentBOMLine line = (TCComponentBOMLine) context.getComponent(); + getOutPartInBom(line, i, dir, list, 1, dirFs); + } + } + + private void downloadStandard(TCComponent[] comps, String dir, List list, String dirFs) { + // TODO Auto-generated method stub + try { + for (int i = 0; i < comps.length; i++) { + String s_type = comps[i].getType(); + if("HS2_ProductPart".equals(s_type)) { + TCComponentItem item = (TCComponentItem) comps[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 dataset01 = null; + if (datasets[j] instanceof TCComponentDataset) { + dataset01 = (TCComponentDataset) datasets[j]; + } else { + continue; + } + + String type = dataset01.getStringProperty("object_type"); + String name = dataset01.getStringProperty("current_name"); + getload(dataset01, dirFs, list, rev.getStringProperty("item_id")); + + // 判断list包含hzm字符串的值 且 itemlist包含revtype的值 + if (datasetList.contains(type)) { + // 获取数据集数据 + TCComponentDataset dataset02 = null; + if (datasets[j] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets[j]; + } else { + continue; + } + // 执行getload方法 + getload(dataset02, dir, list, rev.getStringProperty("item_id")); + // 复制一份到父级 + if (!dir.equals(dirFs)) { + getload(dataset01, dirFs, list, rev.getStringProperty("item_id")); + } + if (!dir.equals(pathMap.get("1")) && pathMap.get("1") != null) { + getload(dataset02, pathMap.get("1"), list, rev.getStringProperty("item_id")); + } + } + } + for (int j = 0; j < datasets2.length; j++) { + // 获取数据集数组 + TCComponentDataset dataset02 = null; + if (datasets2[j] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets2[j]; + } else { + continue; + } + // 执行获取后缀名的方法 + // 判断是否为所需要的零件类型 + String type = dataset02.getStringProperty("object_type"); + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets2[j]; + getload(dataset, dir, list, rev.getStringProperty("item_id")); + } + } + } + } + } catch (Exception e) { + // TODO: handle exception + } + + + } + private static void updateProgress(JProgressBar copyProgressBar, int progressSize) { + copyProgressBar.setString(progressSize + "%"); + copyProgressBar.setValue(progressSize); + } + + public Boolean getSxTj() { + List tjlist = new ArrayList(); + Boolean statusBool = false; + Component[] jcbs = btnPanel3.getComponents(); + for (Component component : jcbs) { + if (component instanceof JCheckBox) { + JCheckBox jcb = (JCheckBox) component; + if (jcb.isSelected()) { + tjlist.add(jcb.getText()); + } + } + } + for (String s : tjlist) { + if (s.equals("仅下载已发布图纸")) { + statusBool = true; + } + if (s.equals("外协件/外购件打包下载")) { + outPartBool = true; + } + } + return statusBool; + } + + public List getIscarryRev() { + List tjlist = new ArrayList(); + Boolean statusBool = false; + Component[] jcbs = btnPanel4.getComponents(); + for (Component component : jcbs) { + if (component instanceof JCheckBox) { + JCheckBox jcb = (JCheckBox) component; + if (jcb.isSelected()) { + tjlist.add(jcb.getText()); + } + } + } + + return tjlist; + } + /** + * 发送到结构管理器 + * + * @param tcComponentItem + * @return + */ + public TCComponentBOMLine sendToStructureManager(TCComponentItemRevision tcComponentItemRev) { + try { + TCComponentRevisionRuleType ruleType = (TCComponentRevisionRuleType) session + .getTypeComponent("RevisionRule"); + TCComponentRevisionRule revRule = ruleType.getDefaultRule(); + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow bomWindow = bomWindowType.create(revRule); + return bomWindow.setWindowTopLine(null, tcComponentItemRev, null, null); + } catch (TCException e) { + e.printStackTrace(); + return null; + } + } + //获取模板 + public File getSXX() { + TCPreferenceService pref = session.getPreferenceService(); + //String puid = pref.getStringValue("QDXQS_MB");// 首选项查puid + String puid = null; + puid = pref.getStringValue("HS_CPWLQDMB"); + + if (puid != null) { + try { + TCComponentDataset dataset = (TCComponentDataset) session.stringToComponent(puid); + if (dataset == null) { + return null; + } + File[] files = dataset.getFiles(""); + if (files.length == 0 || files.length != 1) { + MessageBox.post("数据集没有命名引用的文件或文件过多,请检查!", "WARNING", MessageBox.WARNING); + return null; + } else { + File file = files[0]; + return file; + } + } catch (TCException e) { + e.printStackTrace(); + } + } else { + MessageBox.post("未找到首选项[HS_CPWLQDMB]或首选项配置错误", "错误", MessageBox.ERROR); + return null; + } + return null; + } + +} diff --git a/src/com/connor/nbhs/plm/gyh/hs028/hsdownloadhandler.java b/src/com/connor/nbhs/plm/gyh/hs028/hsdownloadhandler.java new file mode 100644 index 0000000..c967996 --- /dev/null +++ b/src/com/connor/nbhs/plm/gyh/hs028/hsdownloadhandler.java @@ -0,0 +1,21 @@ +package com.connor.nbhs.plm.gyh.hs028; + +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 hsdownloadhandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + hsdownload dialog = new hsdownload(app); + new Thread(dialog).start(); + return null; + } + +} diff --git a/src/com/connor/nbhs/plm/gyh/hs029/hsProcessFollowUpAction.java b/src/com/connor/nbhs/plm/gyh/hs029/hsProcessFollowUpAction.java new file mode 100644 index 0000000..49a51df --- /dev/null +++ b/src/com/connor/nbhs/plm/gyh/hs029/hsProcessFollowUpAction.java @@ -0,0 +1,22 @@ +package com.connor.nbhs.plm.gyh.hs029; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +public class hsProcessFollowUpAction extends AbstractAIFAction { + private AbstractAIFUIApplication app; + + public hsProcessFollowUpAction(AbstractAIFUIApplication app, String string) { + super(app, string); + this.app = app; + } + + @Override + public void run() { + try { + new hsProcessFollowUpCommand(app).executeModal(); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/com/connor/nbhs/plm/gyh/hs029/hsProcessFollowUpCommand.java b/src/com/connor/nbhs/plm/gyh/hs029/hsProcessFollowUpCommand.java new file mode 100644 index 0000000..cb7e5aa --- /dev/null +++ b/src/com/connor/nbhs/plm/gyh/hs029/hsProcessFollowUpCommand.java @@ -0,0 +1,21 @@ +package com.connor.nbhs.plm.gyh.hs029; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCSession; + +public class hsProcessFollowUpCommand extends AbstractAIFCommand { + private TCSession session; + private AbstractAIFUIApplication app; + + public hsProcessFollowUpCommand(AbstractAIFUIApplication app) { + this.app = app; + this.session = (TCSession) app.getSession(); + } + + @Override + public void executeModal() throws Exception { + new Thread(new hsProcessFollowUpDialog(session, app)).start(); + } + +} diff --git a/src/com/connor/nbhs/plm/gyh/hs029/hsProcessFollowUpDialog.java b/src/com/connor/nbhs/plm/gyh/hs029/hsProcessFollowUpDialog.java new file mode 100644 index 0000000..2a352e1 --- /dev/null +++ b/src/com/connor/nbhs/plm/gyh/hs029/hsProcessFollowUpDialog.java @@ -0,0 +1,393 @@ +package com.connor.nbhs.plm.gyh.hs029; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.io.IOException; +import java.util.List; + +import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + +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.common.organization.OrgObject; +import com.teamcenter.rac.common.organization.OrgTreePanel; +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.PropertyLayout; + +public class hsProcessFollowUpDialog extends AbstractAIFDialog implements ListSelectionListener { + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent[] targets; + private TCPreferenceService service; + public OrgTreePanel organizationPanel; + private TCComponentUser user; + + private JList list; // 设置list + private DefaultListModel listModel; // 设置list模式 + + private JList listadd; // 设置list + private DefaultListModel listModeladd; // 设置list模式 + + private JTextField employeeName; + private JButton removebutton;// 移除按钮 + private JButton addbutton; + + public hsProcessFollowUpDialog(TCSession session, AbstractAIFUIApplication app) { + super(false); + this.app = app; + this.session = session; + this.service = session.getPreferenceService(); + } + + @Override + public void run() { + // 显示窗口 + try { + initUI(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // 启用查询按钮 +// qryBtn.setEnabled(true); + } + + @SuppressWarnings("serial") + private void initUI() throws TCException { + // 设置界面基本属性 + this.setTitle("流程跟催"); + this.setResizable(false); + this.setVisible(true); + this.setLayout(null); + this.setPreferredSize(new Dimension(600, 550)); + this.setLocation(2, 5); + + hsProcessFollowUpOperation Operation = new hsProcessFollowUpOperation(app, session); + + // 选人页面 + SelectUserPanel(); + organizationPanel.setBounds(350, 50, 200, 400); + // 设置JPanel + JPanel Panel = new JPanel(new PropertyLayout()); + // 设置第一个jlist + listModel = new DefaultListModel(); + // 获取当前任务节点指派人 + String Assignor = Operation.getAssignor(); // 被指派者 + String Tasktype = Operation.getTasktype(); // 类型 + + // 写入list中 + if (Tasktype.equals("EPMPerformSignoffTask")) { + List Issue = Operation.getIssue(); // 签发对象 + for (int i = 0; i < Issue.size(); i++) { + String add = Issue.get(i).toString(); + listModel.addElement(add); + } + } else { + if (Assignor != null) { + listModel.addElement(Assignor); + } + } + + list = new JList(listModel); + list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + list.setSelectedIndex(0); + + list.addListSelectionListener(this); + list.setVisibleRowCount(5); + // list.setBounds(100,200,50,50); + JScrollPane listScrollPane = new JScrollPane(list); + listScrollPane.setBounds(20, 100, 200, 100); + + // 设置第二个jlist + listModeladd = new DefaultListModel(); + + listadd = new JList(listModeladd); + listadd.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + listadd.setSelectedIndex(0); + listadd.addListSelectionListener(this); + listadd.setVisibleRowCount(5); + + JScrollPane listScrollPane2 = new JScrollPane(listadd); + listScrollPane2.setBounds(20, 200, 200, 200); + + // 设置文本内容 + JLabel idLabel = new JLabel("待通知用户清单"); + + idLabel.setBounds(70, 50, 200, 20); + // 添加按钮设置事件 + addbutton = new JButton("添加"); + HireListener hireListener = new HireListener(addbutton); + addbutton.addActionListener(hireListener); + addbutton.setActionCommand("添加"); + addbutton.setEnabled(false); + addbutton.setBounds(250, 200, 75, 30); + // 移除按钮设置事件 + removebutton = new JButton("移除"); + removebutton.setActionCommand("移除"); + if (listModel.size() == 1) { + removebutton.setEnabled(false); + list.setEnabled(false); + + removebutton.addActionListener(new FireListener()); + } + removebutton.setBounds(250, 300, 75, 30); + // 设置文本框属性 + employeeName = new JTextField(10); + employeeName.addActionListener(hireListener); + employeeName.getDocument().addDocumentListener(hireListener); + // String name = listModel.getElementAt(list.getSelectedIndex()).toString(); + + JButton okbutton = new JButton("确认"); + okbutton.setBounds(350, 465, 75, 30); + JButton celbutton = new JButton("取消"); + celbutton.setBounds(450, 465, 75, 30); + + okbutton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + try { + Operation.SendToEmail(Assignor, list); + Operation.SendToEmailAll(Assignor, listadd); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + disposeDialog(); + } + }); + celbutton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + + this.add(idLabel); + this.add(listScrollPane); + this.add(listScrollPane2); + this.add(addbutton); + this.add(removebutton); + this.add(okbutton); + this.add(celbutton); + + this.add(organizationPanel); + + this.pack(); + this.setResizable(false); + this.centerToScreen(); + this.showDialog(); + } + + // 设置添加事件类 + class HireListener implements ActionListener, DocumentListener { + private boolean alreadyEnabled = false; + private JButton button; + + public HireListener(JButton button) { + this.button = button; + } + + // Required by ActionListener. + public void actionPerformed(ActionEvent e) { + try { + String name = user.getStringProperty("user_name"); + System.out.println("4.11-name--" + name); + if (name.equals("")) { + return; + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + // User didn't type in a unique name... +// if (name.equals("") || alreadyInList(name)) { +// Toolkit.getDefaultToolkit().beep(); +// employeeName.requestFocusInWindow(); +// employeeName.selectAll(); +// return; +// } + int index = listadd.getSelectedIndex(); // get selected index + if (index == -1) { // no selection, so insert at beginning + index = 0; + } else { // add after the selected item + index++; + } + try { + listModeladd.insertElementAt(user.getStringProperty("user_name"), index); + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + // If we just wanted to add to the end, we'd do this: + // listModel.addElement(employeeName.getText()); + // Reset the text field. +// employeeName.requestFocusInWindow(); +// employeeName.setText(""); + // Select the new item and make it visible. + listadd.setSelectedIndex(index); + listadd.ensureIndexIsVisible(index); + } + + protected boolean alreadyInList(String name) { + return listModeladd.contains(name); + } + + // Required by DocumentListener. + public void insertUpdate(DocumentEvent e) { + enableButton(); + } + + // Required by DocumentListener. + public void removeUpdate(DocumentEvent e) { + handleEmptyTextField(e); + } + + // Required by DocumentListener. + public void changedUpdate(DocumentEvent e) { + if (!handleEmptyTextField(e)) { + enableButton(); + } + } + + private void enableButton() { + if (!alreadyEnabled) { + button.setEnabled(true); + } + } + + private boolean handleEmptyTextField(DocumentEvent e) { + if (e.getDocument().getLength() <= 0) { + button.setEnabled(false); + alreadyEnabled = false; + return true; + } + return false; + } + } + + // 设置移除按钮事件 + class FireListener implements ActionListener { + + public void actionPerformed(ActionEvent e) { + // This method can be called only if + // there's a valid selection + // so go ahead and remove whatever's selected. + int index = listadd.getSelectedIndex(); + System.out.println("4.11-index:" + index); + listModeladd.remove(index); + int size = listModeladd.getSize(); + System.out.println("4.11-size:" + size); + if (size == 0) { // Nobody's left, disable firing. + removebutton.setEnabled(false); + } else { // Select an index. + if (index == listModeladd.getSize()) { + // removed item in last position + index--; + } + listadd.setSelectedIndex(index); + listadd.ensureIndexIsVisible(index); + } + } + } + + // 设置组织界面 + public void SelectUserPanel() { + + organizationPanel = new OrgTreePanel(session); + organizationPanel.setSize(300, 400); + organizationPanel.getOrgTree().addMouseListener(new java.awt.event.MouseListener() { + + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + OrgObject selectedObject = organizationPanel.getOrgTree().getSelectedObject(); + if (selectedObject != null) { + + user = selectedObject.getUser(); + System.out.println("鼠标点击的user=" + user); + addbutton.setEnabled(true); + System.out.println("按钮变亮"); + } +// if (e.getClickCount() == 1) { +// OrgObject selectedObject = organizationPanel.getOrgTree().getSelectedObject(); +// if (selectedObject != null) { +// +// user = selectedObject.getUser(); +// System.out.println("鼠标点击的user="+user); +// } +// } + } + + @Override + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + OrgObject selectedObject = organizationPanel.getOrgTree().getSelectedObject(); + if (selectedObject != null) { + + user = selectedObject.getUser(); + // System.out.println("鼠标摁下的user="+user); + } + } + + @Override + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + + } + }); + } + + @Override + public void valueChanged(ListSelectionEvent e) { + // TODO Auto-generated method stub + if (e.getValueIsAdjusting() == false) { + + if (list.getSelectedIndex() == -1) { + + // No selection, disable fire button. + + removebutton.setEnabled(false); + + } else { + + // Selection, enable the fire button. + + removebutton.setEnabled(true); + + } + + } + } +} diff --git a/src/com/connor/nbhs/plm/gyh/hs029/hsProcessFollowUpOperation.java b/src/com/connor/nbhs/plm/gyh/hs029/hsProcessFollowUpOperation.java new file mode 100644 index 0000000..42cd834 --- /dev/null +++ b/src/com/connor/nbhs/plm/gyh/hs029/hsProcessFollowUpOperation.java @@ -0,0 +1,347 @@ +package com.connor.nbhs.plm.gyh.hs029; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JList; + + +import com.connor.nbhs.plm.gyh.SendToEmail.SoaServerUtil; +import com.connor.nbhs.plm.shentu.utils.DataBaseControl; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class hsProcessFollowUpOperation extends AbstractAIFOperation { + private AbstractAIFApplication app; + private TCSession session; + + private String owing_user = null; + private String object_name = null; + + public hsProcessFollowUpOperation() { + + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + } + + public hsProcessFollowUpOperation(AbstractAIFApplication app, TCSession session) { + super(); + this.app = app; + this.session = session; + } + + // 获取被指派者属性 + public String getAssignor() { + // TODO Auto-generated method stub + InterfaceAIFComponent[] comp = app.getTargetComponents(); + String Assignor = null; + + try { + if (comp[0] instanceof TCComponentTask) { + TCComponentTask task = (TCComponentTask) comp[0]; + TCComponent comps = (TCComponent) task; + Assignor = task.getStringProperty("resp_party"); + owing_user = comps.getTCProperty("owning_user").getReferenceValueInString(); + object_name = task.getStringProperty("job_name"); + System.out.println("4.11--Assignor=====" + Assignor); + + } else { + MessageBox.post("请选择工作流程任务", "提示", MessageBox.INFORMATION); + return null; + } + } catch (Exception e) { + MessageBox.post("获取工作流程任务属性失败getAssignor", "提示", MessageBox.INFORMATION); + return null; + } + + return Assignor; + } + + // 获取任务类型属性 + public String getTasktype() { + // TODO Auto-generated method stub + InterfaceAIFComponent[] comp = app.getTargetComponents(); + String Tasktype = null; + try { + if (comp[0] instanceof TCComponentTask) { + TCComponentTask task = (TCComponentTask) comp[0]; + TCComponent comps = (TCComponent) task; + Tasktype = task.getStringProperty("object_type"); + + System.out.println("4.13--Tasktype=====" + Tasktype); + + } else { + MessageBox.post("请选择工作流程任务", "提示", MessageBox.INFORMATION); + return null; + } + } catch (Exception e) { + MessageBox.post("获取工作流程任务属性失败getTasktype", "提示", MessageBox.INFORMATION); + return null; + } + return Tasktype; + } + + // 获取签发人员属性,并处理 + public List getIssue() { + InterfaceAIFComponent[] comp = app.getTargetComponents(); + String Issue = null; + String singleIssue = null; + List list = new ArrayList(); + try { + if (comp[0] instanceof TCComponentTask) { + TCComponentTask task = (TCComponentTask) comp[0]; + TCComponent comps = (TCComponent) task; + // Issue = + // comps.getTCProperty("signoff_attachments").getReferenceValueInString(); + TCProperty Validissuance = comps.getTCProperty("valid_signoffs"); + TCComponent[] Valids = Validissuance.getReferenceValueArray(); + for (int i = 0; i < Valids.length; i++) { + TCComponent Valid = Valids[i]; + + String state = Valid.getStringProperty("fnd0Status"); + System.out.println("4.13--state=====" + state); + if (state.equals("不作决定")) { + Issue = Valid.getStringProperty("object_string"); + System.out.println("4.13--Issue=====" + Issue); + String[] chuli = Issue.split(" "); + singleIssue = chuli[0]; + System.out.println("4.13--singleIssue:" + singleIssue); + list.add(singleIssue); + } + } + } else { + MessageBox.post("请选择工作流程任务", "提示", MessageBox.INFORMATION); + return null; + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post("获取工作流程任务属性失败getIssue", "提示", MessageBox.INFORMATION); + return null; + } + System.out.println("4.13--AllIssue:" + list.size()); + return list; + } + + public List getSignoff() { + InterfaceAIFComponent[] comp = app.getTargetComponents(); + String Issue = null; + String singleIssue = null; + List list = new ArrayList(); + try { + if (comp[0] instanceof TCComponentTask) { + TCComponentTask task = (TCComponentTask) comp[0]; + TCComponent comps = (TCComponent) task; + + TCProperty Validissuance = comps.getTCProperty("valid_signoffs"); + TCComponent[] Valids = Validissuance.getReferenceValueArray(); + for (int i = 0; i < Valids.length; i++) { + TCComponent Valid = Valids[i]; + String state = Valid.getStringProperty("fnd0Status"); + System.out.println("4.13--state=====" + state); + if (state.equals("不作决定")) { + Issue = comps.getTCProperty("signoff_attachments").getReferenceValueInString(); + // Issue = Valid.getStringProperty("object_string"); + System.out.println("4.13--Issue=====" + Issue); + String[] chuli = Issue.split(" "); + singleIssue = chuli[0]; + System.out.println("4.13--singleIssue:" + singleIssue); + list.add(singleIssue); + } + } + } else { + MessageBox.post("请选择工作流程任务", "提示", MessageBox.INFORMATION); + return null; + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post("获取工作流程任务属性失败getIssue", "提示", MessageBox.INFORMATION); + return null; + } + System.out.println("4.13--AllIssue:" + list.size()); + return list; + } + + // 被指派人发送邮件的方法 + public void SendToEmail(String Assignor, JList list) throws IOException { + + // TODO Auto-generated method stub + InterfaceAIFComponent[] comp = app.getTargetComponents(); + // 定义任务名称 + String job_name = null; + String Email = null; + try { + if (comp[0] instanceof TCComponentTask) { + TCComponentTask task = (TCComponentTask) comp[0]; + job_name = task.getStringProperty("job_name"); + System.out.println("4.11--job_name=====" + job_name); + } else { + MessageBox.post("请选择工作流程任务", "提示", MessageBox.INFORMATION); + return; + } + } catch (Exception e) { + MessageBox.post("获取工作流程任务属性失败SendToEmail", "提示", MessageBox.INFORMATION); + return; + } + + // 获取首选项值 + String[] stringArray = ((TCSession) app.getSession()).getPreferenceService() + .getStringValues("Autocode_SendEmailServer_URL"); + String url = stringArray[0]; + System.out.println("4.12--url:" + url); + + // 处理jlist + int size = list.getModel().getSize(); + String content = ""; + String EmailAll = ""; + for (int i = 0; i < size; i++) { + + Object item = list.getModel().getElementAt(i); + String name = (String) item; + + System.out.println("4.12--name:" + name); + try { + DataBaseControl dataBaseControl = new DataBaseControl(session); + Email = dataBaseControl.getEmail(name); + System.out.println("4.12---Email:" + Email); + SoaServerUtil soaServerUtil = new SoaServerUtil(); + System.out.println("4.12--owing_user:" + owing_user); + System.out.println("4.12--object_name:" + object_name); + System.out.println("4.12--内容:" + owing_user + "-" + object_name + "-" + "请尽快审批"); + content = owing_user + "-" + object_name + "-" + "请尽快审批"; + content = content.replaceAll(" ", "");// 将空格替换为null,有空格影响邮件内容 + content = content.replace("&", "^&"); + content = content.replace(">", "^>"); + content = content.replace("<", "^<"); + content = content.replace("/", "^/"); + System.out.println("4.20--content:" + content); + if(i==size-1) { + EmailAll =EmailAll+Email; + }else { + EmailAll =Email+ ","+EmailAll; + } + System.out.println("4.27执行人--EmailAll:" + EmailAll); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + + } +// String cmds = "java -jar D:\\Siemens\\Teamcenter12\\portal\\plugins\\SendToEmail.jar "+"您有一个逾期任务请尽快审批。 "+EmailAll+" "+content+" "+url; +// System.out.println("4.27-cmds:"+cmds); +// //执行命令 +// Process p = Runtime.getRuntime().exec(cmds); +// InputStream fis = p.getInputStream(); +// InputStreamReader isr = new InputStreamReader(fis,"GBK"); +// BufferedReader br = new BufferedReader(isr); +// String line = null; +// while ((line = br.readLine())!=null) { +// System.out.println(line); +// } + SoaServerUtil.sendToClass("您有一个逾期任务请尽快审批。", EmailAll, content, url); + + } + + // 被选中人执行的方法 + public void SendToEmailAll(String Assignor, JList list) throws IOException { + // TODO Auto-generated method stub + InterfaceAIFComponent[] comp = app.getTargetComponents(); + // 定义任务名称 + String job_name = null; + String Email = null; + // + // 添加未完成任务的人的名称 + List ArrayList = new ArrayList(); + ArrayList = getIssue(); + if (ArrayList.size() > 0) { + Assignor = ""; + for (int k = 0; k < ArrayList.size(); k++) { + String add = ArrayList.get(k).toString(); + Assignor = Assignor + add + ","; + } + } else { + System.out.println("4.14--====未批准的人数量为:" + ArrayList.size()); + } + + try { + if (comp[0] instanceof TCComponentTask) { + TCComponentTask task = (TCComponentTask) comp[0]; + job_name = task.getStringProperty("job_name"); + System.out.println("4.11--job_name=====" + job_name); + } else { + MessageBox.post("请选择工作流程任务", "提示", MessageBox.INFORMATION); + return; + } + } catch (Exception e) { + MessageBox.post("获取工作流程任务属性失败SendToEmailAll", "提示", MessageBox.INFORMATION); + return; + } + // 获取"HS_DRAW_URL"首选项值,获取url + String[] stringArray = ((TCSession) app.getSession()).getPreferenceService() + .getStringValues("Autocode_SendEmailServer_URL"); + String url = stringArray[0]; + // 处理jlist + String content = ""; + String EmailAll = ""; + int size = list.getModel().getSize(); + for (int i = 0; i < size; i++) { + Object item = list.getModel().getElementAt(i); + String name = (String) item; + System.out.println("4.12--name:" + name); + try { + DataBaseControl dataBaseControl = new DataBaseControl(session); + Email = dataBaseControl.getEmail(name); + System.out.println("4.12---Email:" + Email); + SoaServerUtil soaServerUtil = new SoaServerUtil(); + System.out.println("4.12--内容:" + owing_user + "-" + object_name + "-" + "请协助催促" + Assignor + "审批"); + content = owing_user + "-" + object_name + "-" + "请协助催促" + Assignor + "审批"; + content = content.replaceAll(" ", ""); + content = content.replace("&", "^&"); + content = content.replace(">", "^>"); + content = content.replace("<", "^<"); + content = content.replace("/", "^/"); + System.out.println("4.20--content:" + content); + if(i==size-1) { + EmailAll =EmailAll+Email; + }else { + EmailAll =Email+ ","+EmailAll; + } + System.out.println("4.27被选中人--EmailAll:" + EmailAll); + + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +// String cmds = "java -jar D:\\Siemens\\Teamcenter12\\portal\\plugins\\SendToEmail.jar "+"您有一个提醒任务请提醒责任人完成工作。 "+EmailAll+" "+content+" "+url; +// System.out.println("4.27-cmds:"+cmds); + //执行命令 +// Process p = Runtime.getRuntime().exec(cmds); +// InputStream fis = p.getInputStream(); +// InputStreamReader isr = new InputStreamReader(fis,"GBK"); +// BufferedReader br = new BufferedReader(isr); +// String line = null; +// while ((line = br.readLine())!=null) { +// System.out.println(line); +// } + + SoaServerUtil.sendToClass("您有一个提醒任务请提醒责任人完成工作。", EmailAll, content, url); + } + +} diff --git a/src/com/connor/nbhs/plm/gyh/hs029/hsProcessFollowUphandler.java b/src/com/connor/nbhs/plm/gyh/hs029/hsProcessFollowUphandler.java new file mode 100644 index 0000000..cc41a72 --- /dev/null +++ b/src/com/connor/nbhs/plm/gyh/hs029/hsProcessFollowUphandler.java @@ -0,0 +1,19 @@ +package com.connor.nbhs.plm.gyh.hs029; + +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 hsProcessFollowUphandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + new Thread(new hsProcessFollowUpAction(app, "")).start(); + return null; + } +} diff --git a/src/com/connor/nbhs/plm/hs001.7z b/src/com/connor/nbhs/plm/hs001.7z new file mode 100644 index 0000000..34832bc Binary files /dev/null and b/src/com/connor/nbhs/plm/hs001.7z differ diff --git a/src/com/connor/nbhs/plm/hs001/AttrFrame.java b/src/com/connor/nbhs/plm/hs001/AttrFrame.java new file mode 100644 index 0000000..9d369d5 --- /dev/null +++ b/src/com/connor/nbhs/plm/hs001/AttrFrame.java @@ -0,0 +1,477 @@ +package com.connor.nbhs.plm.hs001; + +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +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.JTextField; + +import com.connor.nbhs.plm.shentu.utils.ClassProperty; +import com.connor.nbhs.plm.shentu.utils.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFDialog; +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.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.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSSearchResult; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.services.strong.classification.ClassificationService; +import com.teamcenter.services.strong.classification._2007_01.Classification.ClassificationObject; +//import com.teamcenter.services.rac.classification.ClassificationService; +//import com.teamcenter.services.rac.classification._2007_01.Classification.ClassificationObject; +//import com.teamcenter.services.rac.classification._2007_01.Classification.ClassificationProperty; +//import com.teamcenter.services.rac.classification._2007_01.Classification.ClassificationPropertyValue; +//import com.teamcenter.services.rac.classification._2007_01.Classification.CreateClassificationObjectsResponse; +//import com.teamcenter.services.rac.classification._2007_01.Classification.UpdateClassificationObjectsResponse; +import com.teamcenter.services.strong.classification._2007_01.Classification.ClassificationProperty; +import com.teamcenter.services.strong.classification._2007_01.Classification.ClassificationPropertyValue; +import com.teamcenter.services.strong.classification._2007_01.Classification.CreateClassificationObjectsResponse; +import com.teamcenter.services.strong.classification._2007_01.Classification.UpdateClassificationObjectsResponse; +import com.teamcenter.services.strong.core.DataManagementService; +import com.teamcenter.soa.client.model.ServiceData; +import com.teamcenter.soa.client.model.strong.ItemRevision; + + +public class AttrFrame extends AbstractAIFDialog { + private TCComponentItemRevision rev; + private List list = new ArrayList(); + private TCSession session; + private TCPreferenceService service; + private String url = ""; + private List> values; + private Map map2; + private JTable qryTable1; + private int row; + private List revNameList; + private List revAttrList; + private int unit_num = 0; + private List revValueList = new ArrayList(); + + private TCClassificationService classificationService; + + public AttrFrame() { + super(); + } + + public AttrFrame(TCComponentItemRevision rev, List list, TCSession session, JTable qryTable1, + int row, List revNameList, List revAttrList,TCClassificationService classificationService) { + // TODO Auto-generated constructor stub + this.rev = rev; + if (list != null) { + this.list = list; + } + this.session = session; + this.qryTable1 = qryTable1; + this.row = row; + this.service = session.getPreferenceService(); + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + this.values = new ArrayList>(); + this.revNameList = revNameList; + this.revAttrList = revAttrList; + this.classificationService=classificationService; + init(); + } + + public void init() { + // TODO Auto-generated method stub + System.out.println("开始绘制编辑界面"); + this.setTitle("分类属性编辑"); + // this.setLayout(new PropertyLayout()); + this.setLayout(new FlowLayout(FlowLayout.CENTER, 2, 3)); + this.setLocation(2, 5); + this.setPreferredSize(new Dimension(300, 470)); + JPanel p1 = new JPanel(new PropertyLayout()); // 面板1 + JScrollPane scr1 = new JScrollPane(p1); + scr1.setPreferredSize(new Dimension(300, 380)); + JPanel p2 = new JPanel(new FlowLayout()); + p2.setPreferredSize(new Dimension(300, 70)); + // JPanel panel=new JPanel(new BorderLayout()); //卡片式布局的面板 + // panel.setPreferredSize(new Dimension(300,480)); + JButton okBtn = new JButton("提交"); + JButton celBtn = new JButton("取消"); + p2.add(okBtn); + p2.add(celBtn); + celBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + okBtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + System.out.println("准备提交分类属性"); + boolean flag = session.getTCAccessControlService().checkPrivilege(rev, "WRITE"); + System.out.println("flag====" + flag); + if (!flag) { + MessageBox.post(AttrFrame.this, "当前用户没有编辑权限,请联系管理员!!!!", "提示", MessageBox.INFORMATION); + return; + } + List vals = new ArrayList(); + for (Map value : values) { + for (Map.Entry entry : value.entrySet()) { + String type = entry.getKey(); + if (type.equals("JComboBox")) { + JComboBox comb1 = (JComboBox) entry.getValue(); + String val = (String) comb1.getSelectedItem(); + vals.add(val); + } else { + JTextField field1 = (JTextField) entry.getValue(); + String val = field1.getText(); + vals.add(val); + } + } + } + String unit = ""; + TCComponentICO[] icos = rev.getClassificationObjects(); + String className = rev.getClassificationClass(); + String icoPUID = icos[0].getUid(); + Integer[] classKeys = new Integer[list.size()]; + String[] classVals = new String[list.size()]; + int prop_nums = 0; + for (int i = 0; i < list.size(); i++) { + String val = vals.get(i); + ClassPropBean classBean = list.get(i); + if (val == null || "".equals(val.trim())) { + + val=""; + } + String val2 = ""; + if (classBean.isLov) { + HashMap lovMap = classBean.lovMapping; + for (Entry entry : lovMap.entrySet()) { + if (val.equals(entry.getValue())) { + val2 = entry.getKey(); + if ("单位".equals(classBean.propDisName)) { + unit = val2; + } + break; + } + } + } else { + val2 = val; + + } + classKeys[i] = classBean.propID; + classVals[i] = val2; + prop_nums++; + } + // boolean valFlag = true; + // for (int i = 0; i < classVals.length; i++) { + // if(!("".equals(classVals[i].trim()))) { + // valFlag = false; + // break; + // } + // } + // if(valFlag) { + // MessageBox.post(AttrFrame.this,"当前物料没有填写分类属性值,请填写!!!!", "提示", + // MessageBox.INFORMATION); + // return; + // } +// boolean isMod = false; +// for (int i = 0; i < vals.size(); i++) { +// String tableVal = (String) qryTable1.getModel().getValueAt(row, i + revNameList.size() + 3); +// if(!(tableVal.equals(vals.get(i)))) { +// isMod = true; +// break; +// } +// } +// if(isMod) { + +// ICSAdminClass c = classificationService.newICSAdminClass(); +// c.load(className); +// ICSProperty[] props = new ICSProperty[prop_nums]; +// for (int i = 0; i < props.length; i++) { +// if (classVals[i] != null) { +// props[i] = new ICSProperty(classKeys[i], classVals[i]); +// } +// } +// // int searchs = c.search(props); +// SoaServerUtil.openByPass(session); +//// TCClassificationService classificationService = session.getClassificationService(); +// ICSSearchResult[] results = classificationService.searchICOs(className, props, 0); +// +// SoaServerUtil.closeByPass(session); +//// classificationService=null; +//// classificationService.re +// // DataBaseControl control = new DataBaseControl(session); +// // boolean checkVal = control.checkValue(classVals); +// if (results == null || results.length == 0) { +// System.out.println(" 搜索得到的结果为0"); +// } else { +// System.out.println(" 搜索得到的结果为:" + results.length); +// // StringBuffer sb = new StringBuffer(); +// // sb.append("存在以下对象具有相同的分类属性:\n"); +// +// for (int i = 0; i < results.length; i++) { +// String icoUID = results[i].getIcoUid(); +// TCComponentICO ico = (TCComponentICO) session.stringToComponent(icoUID); +// ICSProperty[] icsProps = ico.getICSProperties(true); +// HashMap icsPropsMap = new HashMap<>(); +// for (int w = 0; w < icsProps.length; w++) { +// icsPropsMap.put(icsProps[w].getId(), icsProps[w].getValue()); +// } +// boolean isAll = true; +// for (int w = 0; w < props.length; w++) { +// String value1 = props[w].getValue(); +// if (value1 == null) { +// value1 = ""; +// } +// String value = icsPropsMap.get(props[w].getId()); +// if (value == null) { +// value = ""; +// } +// if (!value1.equals(value)) { +// isAll = false; +// } +// } +// if (isAll) { +// String id = rev.getStringProperty("item_id"); +// String icoId = results[i].getIcoId(); +// if (icoId.contains(id)) { +// continue; +// } else { +// MessageBox.post(AttrFrame.this, "分类库中有相同属性的物料,请确定后重新修改!!!!", "提示", +// MessageBox.INFORMATION); +// return; +// } +// } +// } +// } + +// SoaServerUtil.deleteClass(icoPUID, url);// 删除分类 +// Thread.sleep(800); + String string = sendObjToClassficationByWebService(icoPUID,className, rev, classKeys, classVals);// 发送分类 +// classificationOperate(className, rev, classKeys, classVals); + + if(string.contains("相同属性")) { + MessageBox.post(AttrFrame.this, "分类库中有相同属性的物料,请确定后重新修改!!!!", "提示", + MessageBox.ERROR); + return; + } + for (int i = 0; i < vals.size(); i++) { + qryTable1.getModel().setValueAt(vals.get(i), row, i + revValueList.size() + 3); + } +// } +// boolean isModRev = false; +// for (int i = 0; i < revValueList.size(); i++) { +// JTextField field = revValueList.get(i); +// String tableVal = (String) qryTable1.getModel().getValueAt(row, i + 3); +// if(!(tableVal.equals(field.getText()))) { +// isModRev = true; +// break; +// } +// } +// if(isModRev) { + rev.lock(); + for (int i = 0; i < revValueList.size(); i++) { + JTextField field = revValueList.get(i); + qryTable1.getModel().setValueAt(field.getText(), row, i + 3); + rev.setStringProperty(revAttrList.get(i), field.getText()); + } + System.out.println("unit===" + unit); + if (!("".equals(unit))) { + rev.setStringProperty("hs2_unit", unit); + if(unit_num != 0) { + qryTable1.getModel().setValueAt(unit, row, unit_num + 3); + } + + } + rev.save(); + rev.unlock(); +// } +// if(!isModRev && !isMod) { +// MessageBox.post(AttrFrame.this,"属性未修改,不需要保存!!!!", "提示", MessageBox.INFORMATION); +// }else { + MessageBox.post(AttrFrame.this, "属性修改完成,请再次查看!!!!", "提示", MessageBox.INFORMATION); + rev.refresh(); +// } + disposeDialog(); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + MessageBox.post(AttrFrame.this, "属性修改失败!!!!", "提示", MessageBox.INFORMATION); + disposeDialog(); + } + + } + }); + // System.out.println("开始绘制版本属性"); + for (int i = 0; i < revNameList.size(); i++) { + System.out.println("====" + revNameList.get(i)); + if ("单位".equals(revNameList.get(i))) { + unit_num = i; + } + p1.add((i + 1) + ".1.center.center", new JLabel(" " + revNameList.get(i) + " : ")); + JTextField field = new JTextField(12); + p1.add((i + 1) + ".2.center.center", field); + revValueList.add(field); + field.setText((String) qryTable1.getModel().getValueAt(row, i + 3)); + } + // /+ revNameList.size() + System.out.println("开始绘制分类属性"); + for (int i = 0; i < list.size(); i++) { + ClassPropBean bean = list.get(i); + System.out.println("分类属性名称===" + bean.propDisName); + p1.add((i + revNameList.size() + 1) + ".1.center.center", new JLabel(" " + bean.propDisName + " : ")); + if (bean.isLov) { + JComboBox box = new JComboBox(); + box.addItem((String) qryTable1.getModel().getValueAt(row, i + revNameList.size() + 3)); + HashMap lovMap = bean.lovMapping; + for (Entry entry : lovMap.entrySet()) { + System.out.println("key = " + entry.getKey() + ", value = " + entry.getValue()); + box.addItem(entry.getValue()); + } + map2 = new HashMap(); + map2.put("JComboBox", box); + values.add(map2); + p1.add((i + revNameList.size() + 1) + ".2.center.center", box); + } else { + JTextField field = new JTextField(12); + field.setText((String) qryTable1.getModel().getValueAt(row, i + revNameList.size() + 3)); + map2 = new HashMap(); + map2.put("JTextField", field); + values.add(map2); + p1.add((i + revNameList.size() + 1) + ".2.center.center", field); + } + } + + this.add("1.1.center.top", new JLabel(" ")); + this.add("2.1.center.top", scr1); + this.add("3.1.center.top", p2); + // panel.add(scr1,BorderLayout.WEST); + // panel.add(p2,BorderLayout.SOUTH); + // panel.add("1.1.center.center",scr1); + // panel.add("2.1.center.center",p2); + // this.add(panel); + this.setResizable(false); + this.setAlwaysOnTop(true); + this.showDialog(); + } + + // + // /** + // * 发送分类 + // */ + public String sendObjToClassficationByWebService(String icoPUID,String class_id, TCComponentItemRevision rev, Integer[] keys, + String[] vals) { + String updateToClass=""; + try { + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList(); + + for (int i = 0; i < keys.length; i++) { + + if(keys[i]!=null && vals[i]!=null) { + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// 分类属性 + propList.add(prop); + } + } + + String json = SoaServerUtil.objectToJson(propList);// 将Java对象转换为json对象 + SoaServerUtil.grantWritePrivilege(session, rev);// 赋予写权限 + updateToClass = SoaServerUtil.updateToClass(rev.getUid(), class_id, json, url,icoPUID);// 发送到分类 +// SoaServerUtil.deleteAndSendToClass(icoPUID,rev.getUid(), class_id, json, url);// 发送到分类 + + SoaServerUtil.grantReadPrivilege(session, rev);// 赋予读权限 + } + + } catch (Exception e) { + e.printStackTrace(); + } + + return updateToClass; + } + + public void classificationOperate(String classId,TCComponent item,Integer[] keys,String[] vals) throws TCException{ + String uid = item.getUid(); + DataManagementService dmService = DataManagementService.getService(session.getSoaConnection()); + ServiceData resultDate = dmService.loadObjects(new String[]{uid}); + ItemRevision itemRevision=(ItemRevision)resultDate.getPlainObject(0); +// item.get_IMAN_classification() + System.out.println("开始发送到分类"); + SoaServerUtil.openByPass(this.session); + List propList = new ArrayList<>(); + for (int i=0;i 0) { + co.properties = propList.toArray(new ClassificationProperty[] {}); + } +// Classification.ClassificationProperty ico_props = new Classification.ClassificationProperty(); + co.classId = classId; +// co.instanceId = "AngularVelocity_nm_degrees"; +// co.properties = new Classification.ClassificationProperty[] { ico_props }; + co.unitBase = "METRIC"; + co.wsoId = itemRevision; + + + try { + TCComponent[] referenceListProperty = item.getReferenceListProperty("IMAN_classification"); +// refreshAndGetProperties(item,"IMAN_classification"); + if(referenceListProperty.length==0){ + CreateClassificationObjectsResponse classificationObjects = service.createClassificationObjects(new ClassificationObject[]{co}); + + if (classificationObjects.data.sizeOfPartialErrors() > 0) + { + for (int i = 0; i < classificationObjects.data + .sizeOfPartialErrors(); i++) + { + System.out.println("Save class Partial Error -- "+classificationObjects.data + .getPartialError(i).getMessages()[0]); + } + + } + }else { + co.clsObjTag=referenceListProperty[0]; + UpdateClassificationObjectsResponse update= service.updateClassificationObjects(new ClassificationObject[]{co}); + if (update.data.sizeOfPartialErrors() > 0) + { + for (int i = 0; i < update.data + .sizeOfPartialErrors(); i++) + { + System.out.println("Save class Partial Error -- "+update.data + .getPartialError(i).getMessages()[0]); + } + + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + SoaServerUtil.closeByPass(this.session); + } + + +} diff --git a/src/com/connor/nbhs/plm/hs001/ClassPropBean.java b/src/com/connor/nbhs/plm/hs001/ClassPropBean.java new file mode 100644 index 0000000..b0d2347 --- /dev/null +++ b/src/com/connor/nbhs/plm/hs001/ClassPropBean.java @@ -0,0 +1,64 @@ +package com.connor.nbhs.plm.hs001; + +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/nbhs/plm/hs001/Hs001Dialog.java b/src/com/connor/nbhs/plm/hs001/Hs001Dialog.java new file mode 100644 index 0000000..7208871 --- /dev/null +++ b/src/com/connor/nbhs/plm/hs001/Hs001Dialog.java @@ -0,0 +1,419 @@ +package com.connor.nbhs.plm.hs001; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JComponent; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +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.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; + +public class Hs001Dialog 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 AbstractAIFUIApplication app; + private Map> revListMap = new HashMap>(); + private Map> attrMap = new HashMap>(); + private List targetList; + private TCComponentItemRevision targetRev; + private JTable qryTable1; + private List revAttrList = new ArrayList(); + private List revNameList = new ArrayList(); + + // private Map attrIDMap = new HashMap(); + public Hs001Dialog(AbstractAIFUIApplication app) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + } + + @Override + public void run() { + String[] revAttrs = session.getPreferenceService().getStringValues("HS2_PartRevisionToClass"); + if (revAttrs != null) { + for (int i = 0; i < revAttrs.length; i++) { + if (revAttrs[i].contains("=")) { + String[] attrs = revAttrs[i].split("="); + revNameList.add(attrs[0]); + revAttrList.add(attrs[1]); + } + } + } else { + MessageBox.post("首选项HS2_PartRevisionToClass配置错误,请联系管理员!", "错误", MessageBox.ERROR); + } + InterfaceAIFComponent[] comps = app.getTargetComponents(); + List idList = new ArrayList(); + StringBuilder sb = new StringBuilder(); + try { + for (int i = 0; i < comps.length; i++) { + if (comps[i] instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) comps[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); + } + } else { + MessageBox.post(sb.toString() + "请选择版本对象进行操作!!!", "提示", MessageBox.INFORMATION); + return; + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + 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(); + } + private TCClassificationService classificationService ; + + @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; + } + 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, className)); + // 添加选项卡选中状态改变的监听器 + 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, ICSAdminClassAttribute[] icsAttrS) { + + // 封装结果集 + 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"); + for (int j = 0; j < revAttrList.size(); j++) { + String value = record.getStringProperty(revAttrList.get(j)); + res[i][j + 3] = value; + } + + // 获取分类属性 + TCComponentICO[] icos = record.getClassificationObjects(); + + if (icos != null && icos.length > 0) { + ICSProperty[] icss = icos[0].getICSProperties(true); + System.out.println("icss======" + icss.length); + System.out.println("classPropList=====" + classPropList.size()); + int k = 0; + for (int j = 0; j < icss.length; j++) { + ICSAdminClassAttribute attr = icsAttrS[j]; + if (attr.isReferenceAttribute()) { + continue; + } + if (attr.isReference()) { + continue; + } + ClassPropBean bean = classPropList.get(k); + String value = icss[j].getValue(); + if (bean.isLov) { + value = bean.lovMapping.get(value); + } + res[i][k + 3 + revAttrList.size()] = value; + k++; + } + } + 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) { + // 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) qryTable1.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); + try { + if ((comp instanceof TCComponentItem)) { + TCComponentItem item = (TCComponentItem) comp; + targetRev = item.getLatestItemRevision(); + String className = targetRev.getClassificationClass(); + targetList = attrMap.get(className); + AttrFrame frame = new AttrFrame(targetRev, targetList, session, qryTable1, row, revNameList, + revAttrList,classificationService); + // new Thread(frame).start(); + } + } catch (Exception e) { + // TODO: handle exception + } + // } + // }); + // 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, + String className) { + System.out.println("进入绘制Jtable"); + + 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); + } + } + attrMap.put(className, classPropList); + String[] columnNames = new String[classPropList.size() + 3 + revNameList.size()]; + columnNames[0] = "序号"; + columnNames[1] = "零件代号"; + columnNames[2] = "零件名称"; + for (int i = 0; i < revNameList.size(); i++) { + columnNames[i + 3] = revNameList.get(i); + } + for (int i = 0; i < classPropList.size(); i++) { + columnNames[i + 3 + revNameList.size()] = classPropList.get(i).propDisName; + } + + 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()); + 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); + + } + } + } + }); + Object[][] cellData = getRecords(revList, columnNames, classPropList, icsAttrS); + + TableRowSorter sorter = new TableRowSorter(model); + qryTable.setRowSorter(sorter); // 为JTable设置排序器 + model.setDataVector(cellData, columnNames); + + qryTable.getColumnModel().getColumn(0).setPreferredWidth(10); + qryTable.getColumnModel().getColumn(1).setPreferredWidth(120); + qryTable.getColumnModel().getColumn(2).setPreferredWidth(120); + qryTable.getColumnModel().getColumn(3).setPreferredWidth(120); + 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/nbhs/plm/hs001/Hs001Handler.java b/src/com/connor/nbhs/plm/hs001/Hs001Handler.java new file mode 100644 index 0000000..32ab0f0 --- /dev/null +++ b/src/com/connor/nbhs/plm/hs001/Hs001Handler.java @@ -0,0 +1,19 @@ +package com.connor.nbhs.plm.hs001; + +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 Hs001Handler extends AbstractHandler { + private AbstractAIFUIApplication app; + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + new Thread(new Hs001Dialog(app)).start(); + return null; + } + +} diff --git a/src/com/connor/nbhs/plm/hs002/Hs002Handler.java b/src/com/connor/nbhs/plm/hs002/Hs002Handler.java new file mode 100644 index 0000000..c19a31c --- /dev/null +++ b/src/com/connor/nbhs/plm/hs002/Hs002Handler.java @@ -0,0 +1,23 @@ +package com.connor.nbhs.plm.hs002; + +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 Hs002Handler extends AbstractHandler { + private AbstractAIFUIApplication app; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Hs002Operation operation = new Hs002Operation(app); + session.queueOperation(operation); + return null; + } + +} diff --git a/src/com/connor/nbhs/plm/hs002/Hs002Operation.java b/src/com/connor/nbhs/plm/hs002/Hs002Operation.java new file mode 100644 index 0000000..c2f1c45 --- /dev/null +++ b/src/com/connor/nbhs/plm/hs002/Hs002Operation.java @@ -0,0 +1,139 @@ +package com.connor.nbhs.plm.hs002; + +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; +import java.util.List; +import java.util.MissingResourceException; + +import com.connor.nbhs.plm.shentu.utils.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +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.TCComponent; +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.util.MessageBox; +import com.teamcenter.rac.util.Registry; + +public class Hs002Operation extends AbstractAIFOperation { + private AbstractAIFUIApplication app; + private TCSession session; + + public Hs002Operation(AbstractAIFUIApplication app) { + this.app = app; + this.session = (TCSession) app.getSession(); + } + + @Override + public void executeOperation() throws Exception { + InterfaceAIFComponent target = app.getTargetComponent(); + if (target instanceof TCComponent) { + TCComponent comp = (TCComponent) target; + String type = comp.getType(); + String projectID = ""; + System.out.println("type===========" + type); + if ("ScheduleTask".equals(type)) { + projectID = comp.getStringProperty("item_id"); + } else if ("EPMDoTask".equals(type)) { + TCComponent[] comps = comp.getRelatedComponents("fnd0RootScheduleTask"); + if (comps != null && comps.length > 0) { + projectID = comps[0].getStringProperty("item_id"); + System.out.println("projectID==========" + projectID); + } + } else { + MessageBox.post("请选择该时间表任务或流程任务对象再执行操作!!!", "提示", MessageBox.INFORMATION); + return; + } + + if ("".equals(projectID.trim()) || "null".equals(projectID)) { + MessageBox.post("该时间表没有发送到项目,请确认后再执行!!!", "提示", MessageBox.INFORMATION); + } else { + SoaServerUtil.setByPass(true, session); + createPopupMenu(projectID); + SoaServerUtil.setByPass(false, session); + } + } + + } + + /** + * 通过查询构建器查询项目对象 + * + * @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(String projectID) { + // 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("proId==============" + projectID); + String[] keys = new String[] { "ID" }; + String[] values = new String[] { projectID }; + List compList = queryObject("通过时间表任务查询项目", 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); + } +} diff --git a/src/com/connor/nbhs/plm/shentu/BOMTransform/BomJTreeTable.java b/src/com/connor/nbhs/plm/shentu/BOMTransform/BomJTreeTable.java new file mode 100644 index 0000000..230952e --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/BOMTransform/BomJTreeTable.java @@ -0,0 +1,701 @@ +package com.connor.nbhs.plm.shentu.BOMTransform; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.swing.JTable; +import javax.swing.JTree; +import javax.swing.RowSorter; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; +import javax.swing.tree.DefaultMutableTreeNode; + +import org.apache.commons.collections.CollectionUtils; + +import com.connor.nbhs.plm.shentu.utils.MethodUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +/** + * 这个类的作用是将拥有bom视图的ItemRev对象内的数据封装到JTree和JTable中 + * 然后把这个类的对象当成一个数据包,传到Dialog中,供Dialog使用 + * + * @author heal'style + * + */ +public class BomJTreeTable { + + private JTree tree; + + private JTable table; + // 树节点所在的行数,从0开始,每次发生选择物料操作以后都会定位到指定行数 + private int position; + + private TCComponentItemRevision target; + + private AbstractAIFApplication app; + + private TCComponentBOMLine topLine; + + private DefaultMutableTreeNode top; + + private List bomlineList = new ArrayList(); + + private List bomlineStringList = new ArrayList(); + + private List designList = new ArrayList(); + // 用于存放图纸和物料一对一指派后的物料 + private List materialList = new ArrayList(); + + private List> materialsList = new ArrayList(); + + private List rowRangeList = new ArrayList(); + +// private Map> designMaterialMap = new HashMap(); + + public BomJTreeTable() { + } + + public BomJTreeTable(TCComponentItemRevision target, AbstractAIFApplication app) { + this.target = target; + this.app = app; + init(); + } + + public int getPosition() { + return position; + } + + public void setPosition(int position) { + this.position = position; + } + + public JTree getTree() { + return tree; + } + + private void setTree(JTree tree) { + this.tree = tree; + } + + public JTable getTable() { + return table; + } + + private void setTable(JTable table) { + this.table = table; + } + + public TCComponentItemRevision getTarget() { + return target; + } + + public void setTarget(TCComponentItemRevision target) { + this.target = target; + } + + public List getDesignList() { + return designList; + } + + public void setDesignList(List designList) { + this.designList = designList; + } + + public List getMaterialList() { + return materialList; + } + + public void setMaterialList(List materialList) { + this.materialList = materialList; + } + + public List> getMaterialsList() { + return materialsList; + } + + public void setMaterialsList(List> materialsList) { + this.materialsList = materialsList; + } + + public TCComponentBOMLine getTopLine() { + return topLine; + } + + public void setTopLine(TCComponentBOMLine topLine) { + this.topLine = topLine; + } + + public List getBomlineList() { + return bomlineList; + } + + public void setBomlineList(List bomlineList) { + this.bomlineList = bomlineList; + } + + /** + * 初始化JTree 数据,用itemRev的数据创建一个JTree + */ + public void init() { + TCSession session = (TCSession) app.getSession(); + try { + TCComponentBOMWindowType bwType = (TCComponentBOMWindowType) session.getTypeService() + .getTypeComponent("BOMWindow"); + TCComponentBOMWindow bw = bwType.create(null); + topLine = bw.setWindowTopLine(target.getItem(), target, null, null); + designList.add(topLine.getItemRevision()); + bomlineList.add(topLine); + if (position != 0) { + position = 0; + } + top = new DefaultMutableTreeNode(new ItemRevInfo(target, position)); + position++; +// System.out.println("top---row----" + position); + addTreeNode(topLine, top); + this.tree = new JTree(top); + this.tree.setRowHeight(30); + tree.setCellRenderer(new MyRenderer(designList, materialsList)); + this.rowRangeList = getTheSameBomlineRowRange(); + + this.table = createTable(); + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 初始化一个JTable + * + * @return + */ + + public static DefaultTableModel getTableModel(DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + DefaultTableModel tableModel = null; + if (dtm == null) { + tableModel = new DefaultTableModel(values, titleNames) { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + } + + return tableModel; + } + + + + + public static JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(getTableModel(dtm, titleNames, values)); + partsTable.setRowHeight(20); + RowSorter sorter = new TableRowSorter(partsTable.getModel()); + partsTable.setRowSorter(sorter); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + private JTable createTable() { + + String[] columnNames = { "物料编码" }; + Object[][] celldata = new Object[bomlineList.size()][1]; + table = getjTable(null,null, columnNames,celldata); + table.setRowHeight(30); + + position = 0; +// boolean isReleasedflag = false; + initTable(topLine); + System.out.println(materialList); + fillTableByExistedBomView(0); + checkRelease(); + +// for (int i = 0; i < materialList.size(); i++) { +// // 获取物料对应的BOM视图版本 +// TCComponentItemRevision materialRev = materialList.get(i); +// if (materialRev != null) { +// checkRelease(materialRev, i); +// } +// } + return table; + } + + /** + * 给Jtable赋值 将bomLine对应的物料值赋值给Jtable,然后递归 递归逻辑:bomLine有没有ziLine,如果没有就停止,如果有就继续递归 + * + * @param bomLine + * @param isReleasedflag 初始化完成后,选择物料,给Jtable重新赋值时,用于判断物料是否已发布 + */ + public void initTable(TCComponentBOMLine bomLine) { + try { + TCComponentItemRevision designRev = bomLine.getItemRevision(); +// designList.add(designRev); + List materialRevs = new ArrayList(); + TCComponent[] materials = designRev.getTCProperty("representation_for").getReferenceValueArray(); + // System.out.println(j + "=====" + materials.length); + if (materials != null && materials.length > 0) { + for (int i = 0; i < materials.length; i++) { + if (materials[i] instanceof TCComponentItemRevision) { + TCComponentItemRevision materialRev = (TCComponentItemRevision) materials[i]; + // System.out.println(materialRev.getStringProperty("item_id")); + chooseAndAddLatestMaterialRev(materialRevs, materialRev); + } + } + } + if (materialRevs.size() == 1) { + table.setValueAt(MethodUtil.getRevTableValue(materialRevs.get(0)), position, 0); + System.out.println(materialRevs.get(0).getStringProperty("item_id") + "------" + position); +// if (materialList.size() == bomlineList.size()) { +// materialList.set(position, materialRevs.get(0)); +// } else { +// materialList.add(materialRevs.get(0)); +// } + if (materialList.size() != bomlineList.size()) { + materialList.add(materialRevs.get(0)); + } + + // System.out.println(j + "----" + celldata[j]); + } else { + if (materialList.size() == bomlineList.size()) { + table.setValueAt(null, position, 0); + materialList.set(position, null); + } else if (materialList.size() != bomlineList.size()) { + materialList.add(null); + } +// table.setValueAt(null, position, 0); + } + if (materialsList.size() == bomlineList.size()) { + materialsList.set(position, materialRevs); + } else { + materialsList.add(materialRevs); + } + position++; + + AIFComponentContext[] ziLines = bomLine.getChildren(); + if (ziLines != null && ziLines.length > 0) { + for (int j = 0; j < ziLines.length; j++) { + TCComponentBOMLine ziLine = (TCComponentBOMLine) ziLines[j].getComponent(); + initTable(ziLine); + } + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 从指定位置开始遍历materialList,如果不为空就查看是否已经有bom视图,如果有就将已存在的bom视图中的物料属性填写到table中 + * 跳过填写的位置,继续遍历materialList + * + * @param startIndex + */ + public void fillTableByExistedBomView(int startIndex) { + System.out.println("开始bom视图检测,起始位置为" + startIndex); + position = startIndex; + try { + for (int i = position; i < materialList.size(); i++) { +// TCComponentItemRevision materialRev = materialList.get(i); +// if (materialRev != null) { +// TCComponent[] bomViews = materialRev.getTCProperty("structure_revisions").getReferenceValueArray(); +// if (bomViews != null && bomViews.length > 0) { +// // 获取存在Bom视图的物料版本 下的revList +// +// List materialRevs = MethodUtil.getAllBomItemByItemRev(materialRev,top); +// System.out.println("Bom视图下的物料版本为:" + materialRevs); +// if(materialRevs.size()==0) { +// break; +// } +// // 从已发布版本的子物料开始给table赋值 +// for (int j = 1; j < materialRevs.size(); j++) { +// +// if((table.getRowCount()-1) 0) { + // 获取存在Bom视图的物料版本 下的revList + List materialRevs = MethodUtil.getAllBomItemByItemRev(materialRev); + System.out.println(materialRevs); + // 从已发布版本的子物料开始给table赋值 + for (int j = 1; j < materialRevs.size(); j++) { + table.setValueAt(MethodUtil.getRevTableValue(materialRevs.get(j)), startIndex + j, 0); + System.out.println("根据bom视图,填写table的row为" + (startIndex + j)); + materialList.set(startIndex + j, materialRevs.get(j)); + } + + } + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * rowRangeList存放着在JTree中相同图纸及其子图纸所在行数的数组 子图纸的选择改变,连带具有相同父图纸,且相同父物料的子图纸发生改变 + * + * @param index + */ + public void reFillTableByTheSameBomlineChooseChange(int index) { + System.out.println("由于选择改变,开始连带检测"); + for (int i = 0; i < rowRangeList.size(); i++) { + Integer[] range = rowRangeList.get(i); + for (int j = 1; j < range.length; j++) { + if (range[j].equals(index)) { + int parentRow = range[0]; + System.out.println("父节点为" + parentRow); + String sameBomlineString = bomlineStringList.get(parentRow); + if (table.getValueAt(parentRow, 0) != null) { + System.out.println(table.getValueAt(parentRow, 0)); + for (int t = 0; t < bomlineStringList.size(); t++) { + + if (sameBomlineString.equals(bomlineStringList.get(t)) && t != parentRow) { + System.out.println(table.getValueAt(t, 0)); + } + if (sameBomlineString.equals(bomlineStringList.get(t)) && t != parentRow + && table.getValueAt(parentRow, 0).equals(table.getValueAt(t, 0))) { + TCComponentItemRevision materialRev = materialList.get(index); + int mirrorRow = t + (index - parentRow); + System.out.println("连带变换的row为" + mirrorRow); + + position = mirrorRow; + initTable(bomlineList.get(mirrorRow)); + table.setValueAt(table.getValueAt(index, 0), mirrorRow, 0); + materialList.set(mirrorRow, materialRev); + reFillTableByChooseChange(mirrorRow); + } + } + return; + } + + } + } + } + } + + /** + * 检测已经填写到table中的物料版本及物料视图是否已发布,如果已发布就将子节点图纸对应的物料定下来,数量为1 + * 以便实现在发布状态下有多个物料的图纸在Jtree中不是以红色显示 + */ + public void checkRelease() { + System.out.println("开始发布状态检测"); + try { + for (int i = 0; i < materialList.size(); i++) { + TCComponentItemRevision materialRev = materialList.get(i); + if (materialRev != null) { + TCComponent[] bomViews = materialRev.getTCProperty("structure_revisions").getReferenceValueArray(); + if (bomViews != null && bomViews.length > 0 && isCompReleased(bomViews[0]) + && isCompReleased(materialRev)) { + System.out.println("通过是否已发布判断"); + // 获取已将Bom视图发布了的物料版本 下的revList + List materialRevs = MethodUtil.getAllBomItemByItemRev(materialRev,top); + for (int j = 1; j < materialRevs.size(); j++) { + + if(materialsList.size()-1 materials = materialsList.get(i + j); + if (materials.size() > 1) { + materials.clear(); + materials.add(materialRevs.get(j)); + } + } + + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 将最新版的materialRev放在list中 + * + * @param materialRevs + * @param materialRev + */ + private void chooseAndAddLatestMaterialRev(List materialRevs, + TCComponentItemRevision materialRev) { + try { + // 运算逻辑,如果list中含有item_id对应的版本,比较版本后添加(覆盖)最新的版本进list + // 如果不含有,就直接添加进list + // flag用于判断是否含有相同的item_id + boolean flag = false; + for (int i = 0; i < materialRevs.size(); i++) { + String item_id = materialRevs.get(i).getStringProperty("item_id"); +// System.out.println(i + "----------" + materialRevs.get(i)); +// System.out.println("item_id" + item_id); +// TCComponentItemRevision materialRev = latestMaterialRevsMap.get(item_id); +// System.out.println("新添加的item_id" + materialRev.getStringProperty("item_id")); + if (item_id.equals(materialRev.getStringProperty("item_id"))) { +// System.out.println("有相同的item_id" + materialRev); + flag = true; + // 比较版本号,将最新的版本添加到list中 + String item_revision_id_i = materialRevs.get(i).getStringProperty("item_revision_id"); + String item_revision_id = materialRev.getStringProperty("item_revision_id"); + if (item_revision_id.compareTo(item_revision_id_i) == 1) { + materialRevs.set(i, materialRev); +// System.out.println("替换完成"); + } + } + } + if (!flag) { + materialRevs.add(materialRev); +// System.out.println("添加一个具有不同item_id" + materialRev); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /** + * 检测物料和物料版本Bom视图是否已经发布,如果已经发布就把对应的物料编码及子物料编码在table中定下来, + * 且将图纸对应的物料也定下来,以便实现有多个物料的图纸在Jtree中不是以红色显示 + * + * @param position 重填table数据的起始位置 + * @param materialRev + */ + public void reFillTable(int position) { + +// for (int i = 0; i < materialList.size(); i++) { + // 获取物料对应的BOM视图版本 + TCComponentItemRevision materialRev = materialList.get(position); + if (materialRev != null) { + try { + TCComponent[] bomViews = materialRev.getTCProperty("structure_revisions").getReferenceValueArray(); + if (bomViews != null && bomViews.length > 0) { + boolean isReleased = isCompReleased(bomViews[0]); + System.out.println("是否已发布判断结果为" + isReleased); +// table.setValueAt(materialRev.getStringProperty("item_id"), i, i); + // 获取物料bom视图下的revList + List materialRevs = MethodUtil.getAllBomItemByItemRev(materialRev); + // 从已发布版本的子物料开始给table赋值 + for (int j = 1; j < materialRevs.size(); j++) { + table.setValueAt(MethodUtil.getRevTableValue(materialRevs.get(j)), position + j, 0); + materialList.set(position + j, materialRevs.get(j)); + List materials = materialsList.get(position + j); + // 如果物料视图已发布,将图纸对应的物料定下来,且数量为1 + // 以便实现在发布状态下有多个物料的图纸在Jtree中不是以红色显示 + if (materials.size() > 1 && isReleased) { + materials.clear(); + materials.add(materialRevs.get(j)); + } + } + +// i = i + materialRevs.size() - 1; +// System.out.println("i----------" + i); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + System.out.println(materialList); +// } +// try { +// TCComponent[] bomViews = materialRev.getTCProperty("structure_revisions").getReferenceValueArray(); +// if (bomViews != null && bomViews.length > 0 && isCompReleased(bomViews[0]) && isCompReleased(materialRev)) { +// System.out.println("通过是否已发布判断"); +//// table.setValueAt(materialRev.getStringProperty("item_id"), i, i); +// // 获取已将Bom视图发布了的物料版本 下的revList +// List materialRevs = MethodUtil.getAllBomItemByItemRev(materialRev); +// // 从已发布版本的子物料开始给table赋值 +// for (int j = 1; j < materialRevs.size(); j++) { +// table.setValueAt(materialRevs.get(j).getStringProperty("item_id"), position + j, 0); +// materialList.set(position + j, materialRevs.get(j)); +//// List materials = materialsList.get(position + j); +//// if (materials.size() > 1) { +//// materials.clear(); +//// materials.add(materialRevs.get(j)); +//// } +// } +// } +// } catch (TCException e) { +// e.printStackTrace(); +// } + } + + /** + * 使用递归添加树节点 基本逻辑是判断有没有 子line,如果有就添加为树节点并继续递归,如果没有就结束 + * + * @param line + * @param treeNode + */ + private void addTreeNode(TCComponentBOMLine line, DefaultMutableTreeNode treeNode) { + + try { + AIFComponentContext[] zilines = line.getChildren(); + if (zilines != null && zilines.length > 0) { + for (int i = 0; i < zilines.length; i++) { + TCComponentBOMLine ziline = (TCComponentBOMLine) zilines[i].getComponent(); +// System.out.println(ziline); + TCComponentItemRevision itemRevision = ziline.getItemRevision(); + designList.add(itemRevision); + bomlineList.add(ziline); + DefaultMutableTreeNode branchNode = new DefaultMutableTreeNode( + new ItemRevInfo(itemRevision, position)); + position++; +// System.out.println(itemRevision.getStringProperty("item_id") + "-----------" + position); + treeNode.add(branchNode); + addTreeNode(ziline, branchNode); + } + } else { + return; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 获取在JTree中相同图纸及其子图纸所在行数的数组,并存在到rowRangeList中 为了防止重复,没有 孙图纸的行数 + * + * @return + * @throws TCException + */ + public List getTheSameBomlineRowRange() throws TCException { + + List list = new ArrayList<>(); + bomlineStringList = MethodUtil.getStringList(bomlineList); + Set bomlineStringSet = new HashSet(bomlineStringList); + Collection rs = CollectionUtils.disjunction(bomlineStringList, bomlineStringSet); + Set sameBomlineStringSet = new HashSet<>(rs); + System.out.println(sameBomlineStringSet); + for (String blString : sameBomlineStringSet) { + TCComponentBOMLine bl = bomlineList.get(bomlineStringList.indexOf(blString)); + int childrenCount = bl.getChildrenCount(); + if (childrenCount > 0) { + System.out.println("相同的bomline为:" + bl); + for (int i = 0; i < bomlineStringList.size(); i++) { + if (blString.equals(bomlineStringList.get(i))) { + System.out.println("找到相同的bomline行数为" + i); + Integer[] arr = new Integer[childrenCount + 1]; + arr[0] = i; + bl = bomlineList.get(i); + AIFComponentContext[] childs = bl.getChildren(); + for (int j = 0; j < childs.length; j++) { + TCComponentBOMLine child = (TCComponentBOMLine) childs[j].getComponent(); + arr[j + 1] = bomlineList.indexOf(child); + System.out.println("相同bomLine的行数为:" + arr[j + 1]); + } + list.add(arr); + } + } + } + + } + return list; + + } + + /** + * 检查对象是否已经发布 + * + * @param comp + * @return + * @throws TCException + */ + public boolean isCompReleased(TCComponent comp) throws TCException { + TCComponent[] comps = comp.getRelatedComponents("release_status_list"); + if (comps != null && comps.length > 0) { + return true; + } + return false; + } + + public boolean isCompReleased(List compList) throws TCException { + for (TCComponent comp : compList) { + if (!isCompReleased(comp)) { + return false; + } + } + return true; + } + +// @Override +// public void focusGained(FocusEvent e) { +// e.getComponent().repaint(); +// +// } +// +// @Override +// public void focusLost(FocusEvent e) { +// e.getComponent().repaint(); +// +// } + +// /** +// * 将itemRev转换为字符串,用于添加到JTree上 +// * @param itemRev +// * @return +// * @throws TCException +// */ +// public String getStringName(TCComponentItemRevision itemRev) throws TCException { +// return itemRev.getItem().getStringProperty("item_id")+"/"+itemRev.getStringProperty("item_revision_id")+"/"+itemRev.getStringProperty("object_name"); +// } + +} diff --git a/src/com/connor/nbhs/plm/shentu/BOMTransform/BomTransformDialog.java b/src/com/connor/nbhs/plm/shentu/BOMTransform/BomTransformDialog.java new file mode 100644 index 0000000..ccfca06 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/BOMTransform/BomTransformDialog.java @@ -0,0 +1,357 @@ +package com.connor.nbhs.plm.shentu.BOMTransform; + +import java.awt.Color; +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.List; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTable; +import javax.swing.JTree; +import javax.swing.WindowConstants; +import javax.swing.tree.DefaultMutableTreeNode; + +import com.connor.nbhs.plm.shentu.utils.MethodUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class BomTransformDialog extends AbstractAIFDialog { + + private AbstractAIFApplication app; + + private TCSession session; + + private TCTypeService service; + + private BomJTreeTable bomJTreetable; + + private JTree designTree; + // 这个变量主要是为了解决 bom视图的分支上可能存在两个相同的ItemRev的问题 + private int indexRow = 0; + + public BomTransformDialog(AbstractAIFApplication app, BomJTreeTable bomJTreetable) { + super(AIFUtility.getActiveDesktop()); + this.app = app; + this.session = (TCSession) app.getSession(); + this.service = session.getTypeService(); + this.bomJTreetable = bomJTreetable; + initUI(); + } + + private void initUI() { + // TODO Auto-generated method stub + this.setTitle("设计BOM转EBOM"); +// this.setSize(new Dimension(600, 400)); + this.setResizable(false); + this.setVisible(true); + this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + JPanel contentPanel = new JPanel(new PropertyLayout(5, 5, 20, 15, 5, 10)); + contentPanel.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, new Color(255, 255, 255))); + this.setContentPane(contentPanel); + + JButton button = new JButton("图纸BOM转物料BOM"); + button.setBorder(BorderFactory.createRaisedBevelBorder()); + button.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + List materialList = bomJTreetable.getMaterialList(); + +// System.out.println(materialList); + // 判断是否有图纸未指派物料且是否外购 + if (materialList.contains(null) && !checkBought(materialList)) { + return; +// MessageBox.post("还有图纸未指派物料,请指派后再试", "提示", MessageBox.INFORMATION); + } + TCComponentBOMLine designTopLine = bomJTreetable.getTopLine(); + TCComponentItemRevision resultMaterial = createEBom(designTopLine); + System.out.println("图纸转换后的" + materialList); + System.out.println("图纸转换后得到的的" + MethodUtil.getAllBomItemByItemRev(resultMaterial)); + + new Thread(new TransformSuccessDialog(bomJTreetable, resultMaterial)).start(); +// MessageBox.post("转换bom成功", "提示", MessageBox.INFORMATION); + dispose(); + + } + + }); + JPanel secondPanel = new JPanel(new PropertyLayout(550, 10)); + JLabel label1 = new JLabel("设计BOM:"); + JLabel label2 = new JLabel("物料id-名称-颜色:"); + label1.setBorder(BorderFactory.createLoweredBevelBorder()); + label2.setBorder(BorderFactory.createLoweredBevelBorder()); + secondPanel.add("1.1.left.center", label1); +// secondPanel.add("1.2.center.center",new JPanel()); + secondPanel.add("1.2.right.center", label2); + + JPanel centerPanel = new JPanel(new PropertyLayout()); + centerPanel.setBorder(BorderFactory.createLineBorder(Color.black, 3)); + JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); +// splitPane.setPreferredSize(new Dimension(500, 200)); + + JSplitPane childSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); + + designTree = bomJTreetable.getTree(); +// JScrollPane tree = new JScrollPane(jTree); + JButton jButton = new JButton("选择物料"); + jButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode) designTree.getLastSelectedPathComponent(); +// System.out.println("被选中的图纸row为:"); + ItemRevInfo revInfo = (ItemRevInfo) node.getUserObject(); +// System.out.println("被选中的图纸row为:" + revInfo.getPosition()); + TCComponentItemRevision targetItemRev = revInfo.getItemRev(); +// System.out.println(targetItemRev); + List> materialsList = bomJTreetable.getMaterialsList(); + if (materialsList.get(revInfo.getPosition()).size() <= 1) { + MessageBox.post("该图纸下不存在物料或仅存有一个物料,无需选择", "提示", MessageBox.INFORMATION); + return; + } + new Thread(new ChooseMaterialDialog(bomJTreetable, revInfo)).start(); + + } + }); +// JScrollPane table = new JScrollPane(jTable); + childSplitPane.setLeftComponent(designTree); + childSplitPane.setRightComponent(jButton); + childSplitPane.setDividerLocation(600); + + JTable jTable = bomJTreetable.getTable(); + + splitPane.setLeftComponent(childSplitPane); + splitPane.setRightComponent(jTable); + splitPane.setDividerLocation(750); + JScrollPane scrollPane = new JScrollPane(splitPane); + + scrollPane.setPreferredSize(new Dimension(1000, 600)); + centerPanel.add("1.1.center.top", scrollPane); + + contentPanel.add("1.1.center.center", button); + contentPanel.add("2.1.center.center", secondPanel); + contentPanel.add("3.1.center.center", centerPanel); + + this.pack(); +// this.setAlwaysOnTop(true); + this.centerToScreen(); + + } + + /** + * 判断是否外购 + * + * @param materialList + * @return + */ + + private boolean checkBought(List materialList) { + // 遍历图纸集合,找到外购的行范围 + try { + List designList = bomJTreetable.getDesignList(); + List boughtRowRangeList = new ArrayList(); + for (int i = 0; i < designList.size(); i++) { + TCComponentItemRevision designRev = designList.get(i); + String source = designRev.getStringProperty("hs2_source"); + if ("外购".equals(source)) { + List childRevList = MethodUtil.getAllBomItemByItemRev(designRev); + int size = childRevList.size(); + if (size > 0) { + Integer[] rowRange = new Integer[2]; + rowRange[0] = i; + rowRange[1] = i + size; + boughtRowRangeList.add(rowRange); + System.out.println("外购图纸列表范围" + Arrays.toString(rowRange)); + } + } + } + + // 判断null的物料是否在外购范围 + for (int j = 0; j < materialList.size(); j++) { + boolean isBought = false; + if (materialList.get(j) == null) { + for (Integer[] rowRange : boughtRowRangeList) { + if (j > rowRange[0] && j <= rowRange[1]) { + isBought = true; + } + } + // 只要有一个不在外购范围就提示 + if (!isBought) { + MessageBox.post("还有非外购图纸未指派物料,请指派后再试", "提示", MessageBox.INFORMATION); + return false; + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return true; + + } + public boolean isCompReleased(TCComponent comp) throws TCException { + TCComponent[] comps = comp.getRelatedComponents("release_status_list"); + if (comps != null && comps.length > 0) { + return true; + } + return false; + } + /** + * 根据图纸bom创建物料bom + * + * @param designTopLine + */ + private TCComponentItemRevision createEBom(TCComponentBOMLine designTopLine) { + TCComponentItemRevision materialRev = null; + try { + TCComponentItemRevision designItemRevision = designTopLine.getItemRevision(); + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + TCComponentBOMWindow materialBomW = bomWindowType.create(null); + materialRev = getMaterialRev(indexRow); + materialBomW.lock(); + TCComponentBOMLine materialTopLine = materialBomW.setWindowTopLine(materialRev.getItem(), materialRev, null, + null); + indexRow = 0; + if(!isCompReleased(materialRev)) { + addmaterialChildLine(designTopLine, materialTopLine); + } + + // 将bomLine所在的行数归0; + + materialBomW.save(); + materialBomW.unlock(); + materialBomW.close(); + return materialRev; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return materialRev; + } + + /** + * 递归逻辑:是否有childline,如果有就添加,并继续递归,如果没有就返回 + * + * @param designLine + * @param materialLine + * @throws TCException + */ + public void addmaterialChildLine(TCComponentBOMLine designLine, TCComponentBOMLine materialLine) + throws TCException { + + // 获取物料视图,如果有判断是否有写权限 + TCComponentItemRevision materialRev = materialLine.getItemRevision(); + TCComponent[] valueArray = materialRev.getTCProperty("structure_revisions").getReferenceValueArray(); + if (valueArray != null && valueArray.length > 1) { + if (!session.getTCAccessControlService().checkPrivilege(valueArray[1], "WRITE")) { + MessageBox.post("当前用户没有对该物料视图的编辑权限,请联系管理员", "提示", MessageBox.INFORMATION); + return; + } else if (!session.getTCAccessControlService().checkPrivilege(materialRev, "WRITE")) { + MessageBox.post("当前用户没有对该物料的编辑权限,请联系管理员", "提示", MessageBox.INFORMATION); + return; + } + } + AIFComponentContext[] materialchildren = materialLine.getChildren(); + // 移出所有的子bomline + if (materialchildren.length != 0) { + for (AIFComponentContext child : materialchildren) { + materialLine.lock(); + materialLine.remove("", (TCComponent) child.getComponent()); + materialLine.save(); + materialLine.unlock(); + } + } + // 物料line 继承图纸line的数量和查找编号:注意顶层bomLine无法赋值 + AIFComponentContext[] contexts = designLine.getChildren(); + if (contexts != null && contexts.length > 0) { + for (int i = 0; i < contexts.length; i++) { + TCComponentBOMLine designChildLine = (TCComponentBOMLine) contexts[i].getComponent(); + indexRow++; + TCComponentItemRevision mateRev = getMaterialRev(indexRow); + System.out.println("position:" + indexRow + "----rev:" + mateRev); + // 如果有外购物料为空就跳过 + if (mateRev == null) { + continue; + } + materialLine.lock(); + TCComponentBOMLine materialChildLine = materialLine.add(mateRev.getItem(), mateRev, null, false, ""); + + materialLine.save(); + materialLine.unlock(); + + materialChildLine.lock(); + String stringProperty = designChildLine.getStringProperty("bl_quantity"); + materialChildLine.setStringProperty("bl_occ_hs2_QtyD", "1"); + materialChildLine.setStringProperty("bl_quantity", stringProperty); + materialChildLine.setStringProperty("bl_sequence_no", + designChildLine.getStringProperty("bl_sequence_no")); + + materialChildLine.save(); + materialChildLine.unlock(); + + if(isCompReleased(mateRev)) { + continue; + } + addmaterialChildLine(designChildLine, materialChildLine); + } + } else { + return; + } + } + + public TCComponentItemRevision getMaterialRev(int indexRow) { +// int indexOf = bomJTreetable.getDesignList().indexOf(designItemRevision); + return bomJTreetable.getMaterialList().get(indexRow); + } + +// private JTree createJTree() { +// DefaultMutableTreeNode top = new DefaultMutableTreeNode("aaaaaaaaaaaaaaaaaaaa"); +// DefaultMutableTreeNode category = null; +// DefaultMutableTreeNode book = null; +// JTree jTree = new JTree(top); +// category = new DefaultMutableTreeNode("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); +// top.add(category); +// for (int i =0 ;i < 20; i++) { +// book = new DefaultMutableTreeNode("bb"+i); +// category.add(book); +// } +// return jTree; +// +// +// } + + private JTable createJtbale() { + // TODO Auto-generated method stub + String[][] cellData = null; + String[] columnNames = { "物料编码" }; +// TCComponentBOMLine line = (TCComponentBOMLine) app.getTargetComponent(); + + cellData = new String[30][1]; + for (int i = 0; i < 30; i++) { + cellData[i] = new String[] { i + "" }; + } + JTable jtable = new JTable(cellData, columnNames); + return jtable; + } + +} diff --git a/src/com/connor/nbhs/plm/shentu/BOMTransform/BomTransformHandler.java b/src/com/connor/nbhs/plm/shentu/BOMTransform/BomTransformHandler.java new file mode 100644 index 0000000..578f810 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/BOMTransform/BomTransformHandler.java @@ -0,0 +1,28 @@ +package com.connor.nbhs.plm.shentu.BOMTransform; + +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.connor.nbhs.plm.shentu.createDelivery.CreateDeliveryOperation; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +/** + * BOM转EBOM + * @author heal'style + * + */ + +public class BomTransformHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + BomTransformOperation operation = new BomTransformOperation(app); + app.getSession().queueOperation(operation); + return null; + } + +} diff --git a/src/com/connor/nbhs/plm/shentu/BOMTransform/BomTransformOperation.java b/src/com/connor/nbhs/plm/shentu/BOMTransform/BomTransformOperation.java new file mode 100644 index 0000000..da87040 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/BOMTransform/BomTransformOperation.java @@ -0,0 +1,65 @@ +package com.connor.nbhs.plm.shentu.BOMTransform; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class BomTransformOperation extends AbstractAIFOperation { + + private AbstractAIFApplication app; + + private TCSession session; + // 被选中的目标对象 + private InterfaceAIFComponent target; + + public BomTransformOperation(AbstractAIFApplication app) { + this.app = app; + this.session = (TCSession) app.getSession(); + this.target = app.getTargetComponent(); + } + + @Override + public void executeOperation() throws Exception { + // 在进行转换操作前先判断 有没有选中转换对象 和 是否要转换 并进行相应提示 + if (before()) { + TCComponentItemRevision rev = (TCComponentItemRevision) target; + // 如果不对目标对象刷新一下,新修订的版本读取不到 + rev.refresh(); + BomJTreeTable bomJTreetable = new BomJTreeTable(rev, app); + // 弹出转换界面窗口 + new Thread(new BomTransformDialog(app, bomJTreetable)).start(); +// new BomTransformDialog(app, bomJTreetable); + } + + } + + private boolean before() { + // 是否指定要设计图纸版本对象 HS2_ProductPartRevision 已指定 (HS2_DesignRevision) + if (target instanceof TCComponentItemRevision && "HS2_ProductPartRevision".equals(target.getType())) { + TCComponentItemRevision rev = (TCComponentItemRevision) target; + try { + TCComponent[] valueArray = rev.getTCProperty("structure_revisions").getReferenceValueArray(); + if (valueArray == null || valueArray.length <= 0) { +// System.out.println(valueArray.length); + MessageBox.post("当前图纸没有BOM结构,无需转换", "提示", MessageBox.INFORMATION); + return false; + } + return true; + } catch (TCException e) { + e.printStackTrace(); + return false; + } + + } else { + MessageBox.post("请选择要进行转换的图纸版本", "提示", MessageBox.INFORMATION); + return false; + } + + } + +} diff --git a/src/com/connor/nbhs/plm/shentu/BOMTransform/ChooseMaterialDialog.java b/src/com/connor/nbhs/plm/shentu/BOMTransform/ChooseMaterialDialog.java new file mode 100644 index 0000000..18d0710 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/BOMTransform/ChooseMaterialDialog.java @@ -0,0 +1,201 @@ +package com.connor.nbhs.plm.shentu.BOMTransform; + +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.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.WindowConstants; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.PropertyLayout; + +public class ChooseMaterialDialog extends AbstractAIFDialog { + + private List> materialsList; + + private List materials; + +// private List designList; + + private BomJTreeTable bomJTreetable; + +// private TCComponentItemRevision targetItemRev; + + private ItemRevInfo revInfo; + + private List radioList = new ArrayList(); + + public ChooseMaterialDialog(BomJTreeTable bomJTreetable, ItemRevInfo revInfo) { + this.bomJTreetable = bomJTreetable; + this.revInfo = revInfo; +// Map> designMaterialMap = bomJTreetable +// .getDesignMaterialMap(); +// designList = bomJTreetable.getDesignList(); + materialsList = bomJTreetable.getMaterialsList(); +// this.materialList = materialList; + } + + @Override + public void run() { + this.setTitle("选择物料"); + this.setResizable(false); + this.setVisible(true); +// this.setSize(200, 150); + this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + this.setLayout(new PropertyLayout(10, 30)); + + JTextField field = new JTextField(12); + field.setText(revInfo.toString()); + field.setEditable(false); + this.add("1.1.center.center", field); + + JPanel panel = new JPanel(new PropertyLayout(10, 10, 100, 50, 0, 0)); + JScrollPane scrollPane = new JScrollPane(panel); + scrollPane.setPreferredSize(new Dimension(400, 150)); + this.add("2.1.center.center", scrollPane); + + ButtonGroup buttonGroup = new ButtonGroup(); + int row = revInfo.getPosition(); +// JPanel radioPanel = new JPanel(new PropertyLayout()); + materials = materialsList.get(row); +// Map latestMaterialRevsMap = chooseLatestMaterialRevs(); +// Set keySet = latestMaterialRevsMap.keySet(); +// int i = 0; +// for (String key : keySet) { +// TCComponentItemRevision materialItemRev = latestMaterialRevsMap.get(key); +// try { +//// System.out.println("被选中的图纸item_id为:" + revInfo.getItemRev().getStringProperty("item_id")); +// String materialShowName = materialItemRev.getStringProperty("item_id") + "-" +// + materialItemRev.getStringProperty("object_name") + "-" +// + materialItemRev.getStringProperty("hs2_materialcolor"); +// JRadioButton radioButton = new JRadioButton(materialShowName); +// panel.add(i++ + 1 + ".1.left.top", radioButton); +// buttonGroup.add(radioButton); +// radioList.add(radioButton); +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// } + for (int i = 0; i < materials.size(); i++) { + TCComponentItemRevision materialItemRev = materials.get(i); + + try { +// System.out.println("被选中的图纸item_id为:" + revInfo.getItemRev().getStringProperty("item_id")); + String materialShowName = materialItemRev.getStringProperty("item_id") + "-" + + materialItemRev.getStringProperty("object_name") + "-" + + materialItemRev.getStringProperty("hs2_materialcolor"); + JRadioButton radioButton = new JRadioButton(materialShowName); + panel.add(i + 1 + ".1.left.top", radioButton); + buttonGroup.add(radioButton); + radioList.add(radioButton); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + JButton button = new JButton("确定"); + button.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + JTable table = bomJTreetable.getTable(); + int indexOf = revInfo.getPosition(); +// System.out.println("indexof:" + indexOf); + for (int i = 0; i < radioList.size(); i++) { + if (radioList.get(i).isSelected()) { + TCComponentBOMLine bomLine = bomJTreetable.getBomlineList().get(indexOf); + TCComponentItemRevision lastSelectedmaterial = bomJTreetable.getMaterialList().get(indexOf); + + boolean isReleasedflag = false; + if (lastSelectedmaterial != null) { + try { + TCComponent[] bomViews = lastSelectedmaterial.getTCProperty("structure_revisions") + .getReferenceValueArray(); + isReleasedflag = bomViews != null && bomViews.length > 0 + && bomJTreetable.isCompReleased(bomViews[0]); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + bomJTreetable.setPosition(indexOf); + System.out.println("改变后的position值为" + bomJTreetable.getPosition()); + bomJTreetable.initTable(bomLine); + + String value = radioList.get(i).getText(); +// int endIndex = value.indexOf("-"); +// String num = value.substring(0, endIndex); + table.setValueAt(value, indexOf, 0); + // 将被选中的物料添加到 物料指派集合列表中 + TCComponentItemRevision mateRev = materials.get(i); + bomJTreetable.getMaterialList().set(indexOf, mateRev); + + bomJTreetable.reFillTableByChooseChange(indexOf); +// System.out.println("重填完table后的position值为" + bomJTreetable.getPosition()); + bomJTreetable.reFillTableByTheSameBomlineChooseChange(indexOf); + bomJTreetable.checkRelease(); + +// System.out.println(materials.get(0)); + break; + } + } + bomJTreetable.getTree().setCellRenderer(new MyRenderer(bomJTreetable.getDesignList(), materialsList)); + disposeDialog(); + } + }); + + this.add("3.1.center.center", button); + + this.pack(); + this.setAlwaysOnTop(true); + this.centerToScreen(); + + } + + /** + * 选出相同Item中的最新版本 + * + * @return + */ +// private Map chooseLatestMaterialRevs() { +// Map latestMaterialRevsMap = new HashMap<>(); +// try { +// // 运算逻辑,如果map中含有item_id对应的版本,比较版本后添加(覆盖)最新的版本进map +// // 如果不含有,就直接添加进map +// for (int i = 0; i < materials.size(); i++) { +// String item_id = materials.get(i).getStringProperty("item_id"); +// TCComponentItemRevision materialRev = latestMaterialRevsMap.get(item_id); +// if (materialRev != null) { +// // 比较版本号,将最新的版本添加到map中 +// String item_revision_id_i = materials.get(i).getStringProperty("item_revision_id"); +// String item_revision_id = materialRev.getStringProperty("item_revision_id"); +// if (item_revision_id_i.compareTo(item_revision_id) == 1) { +// latestMaterialRevsMap.put(item_id, materials.get(i)); +// } +// } else { +// latestMaterialRevsMap.put(item_id, materials.get(i)); +// } +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return latestMaterialRevsMap; +// } + +} diff --git a/src/com/connor/nbhs/plm/shentu/BOMTransform/ItemRevInfo.java b/src/com/connor/nbhs/plm/shentu/BOMTransform/ItemRevInfo.java new file mode 100644 index 0000000..8da40b4 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/BOMTransform/ItemRevInfo.java @@ -0,0 +1,54 @@ +package com.connor.nbhs.plm.shentu.BOMTransform; + +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; + +public class ItemRevInfo { + + private TCComponentItemRevision itemRev; + + private int position; + + public ItemRevInfo(TCComponentItemRevision itemRev, int position) { + this.itemRev = itemRev; + this.position = position; + } + +// public String getName() { +// return name; +// } +// +// public void setName(String name) { +// this.name = name; +// } + + public TCComponentItemRevision getItemRev() { + return itemRev; + } + + public void setItemRev(TCComponentItemRevision itemRev) { + this.itemRev = itemRev; + } + + public int getPosition() { + return position; + } + + public void setPosition(int position) { + this.position = position; + } + + @Override + public String toString() { + String name = ""; + try { + name = itemRev.getItem().getStringProperty("item_id") + "/" + itemRev.getStringProperty("item_revision_id") + + "/" + itemRev.getStringProperty("object_name"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return name; + } + +} diff --git a/src/com/connor/nbhs/plm/shentu/BOMTransform/MyRenderer.java b/src/com/connor/nbhs/plm/shentu/BOMTransform/MyRenderer.java new file mode 100644 index 0000000..9003d97 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/BOMTransform/MyRenderer.java @@ -0,0 +1,85 @@ +package com.connor.nbhs.plm.shentu.BOMTransform; + +import java.awt.Color; +import java.awt.Component; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JComponent; +import javax.swing.JTree; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; + +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; + +public class MyRenderer extends DefaultTreeCellRenderer { + + private List designList = new ArrayList(); + + private List> materialsList = new ArrayList(); + + public MyRenderer(List designList, List> materialsList) { + this.designList = designList; + this.materialsList = materialsList; + } + + public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, + int row, boolean hasFocus) { + + JComponent c = (JComponent) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); + DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; + ItemRevInfo revInfo = (ItemRevInfo) node.getUserObject(); + int position = revInfo.getPosition(); + Map result = search(); +// if (result.containsKey(node.toString())) { +// setForeground(Color.RED); +// } +// c.setOpaque(true); + if (result.containsKey(position)) { + c.setForeground(Color.RED); + } + // 展开全部节点 + if (!leaf) { + tree.expandRow(row); + } +// if (leaf) { +// c.setBackground(new Color(135, 206, 250)); +// } else { +// c.setBackground(Color.GRAY); +// } + + return c; + } + + /** + * 查找存在多个物料,且都没有发布的图纸 + * + * @return + */ + public Map search() { +// List list = new ArrayList<>(); + Map map = new HashMap(); + try { + for (int i = 0; i < materialsList.size(); i++) { + List materials = materialsList.get(i); + if (materials != null && materials.size() > 1) { + map.put(i, getStringName(designList.get(i))); + } + + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return map; + } + + public String getStringName(TCComponentItemRevision itemRev) throws TCException { + return itemRev.getItem().getStringProperty("item_id") + "/" + itemRev.getStringProperty("item_revision_id") + + "/" + itemRev.getStringProperty("object_name"); + } + +} diff --git a/src/com/connor/nbhs/plm/shentu/BOMTransform/TransformSuccessDialog.java b/src/com/connor/nbhs/plm/shentu/BOMTransform/TransformSuccessDialog.java new file mode 100644 index 0000000..9d80e36 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/BOMTransform/TransformSuccessDialog.java @@ -0,0 +1,145 @@ +package com.connor.nbhs.plm.shentu.BOMTransform; + +import java.awt.Button; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.WindowConstants; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.common.Activator; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.PropertyLayout; + +public class TransformSuccessDialog extends AbstractAIFDialog { + + private AbstractAIFApplication app; + + private TCSession session; + + private BomJTreeTable bomJTreeTable; + private TCComponentItemRevision resultMaterial; + + public TransformSuccessDialog(BomJTreeTable bomJTreeTable, TCComponentItemRevision resultMaterial) { + this.bomJTreeTable = bomJTreeTable; + this.resultMaterial = resultMaterial; + initUI(); + } + + private void initUI() { + this.setTitle("设计BOM转EBOM"); + this.setSize(new Dimension(400, 200)); + this.setResizable(false); + this.setVisible(true); + this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + JPanel contentPanel = new JPanel(new PropertyLayout(5, 5, 50, 50, 50, 50)); + this.setContentPane(contentPanel); + JTextField jTextField = new JTextField(bomJTreeTable.getTarget().toString() + "图纸BOM已经搭建完成,是否发送至结构管理器进行查看?"); + + Button deliver = new Button("发送"); + deliver.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + +// ProgressBarThread wait = new ProgressBarThread(" ", "执行中,请稍等..."); +// wait.start(); + Activator.getDefault().openPerspective("com.teamcenter.rac.pse.PSEPerspective"); + Activator.getDefault().openComponents("com.teamcenter.rac.pse.PSEPerspective", + new InterfaceAIFComponent[] { resultMaterial }); + +// new Thread() { +// @Override +// public void run() { +// com.teamcenter.rac.common.Activator.getDefault() +// .openPerspective("com.teamcenter.rac.pse.PSEPerspective"); +// com.teamcenter.rac.common.Activator.getDefault().openComponents( +// "com.teamcenter.rac.pse.PSEPerspective", +// new InterfaceAIFComponent[] { resultMaterial }); +// } +// }.start(); +// +// try { +// Thread.sleep(1000); +// } catch (InterruptedException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } + +// wait.setBool(true); +// wait.interrupt(); + dispose(); + System.out.println("发送完成"); + } + }); + Button close = new Button("确定"); + close.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + dispose(); + + } + }); + JPanel bottomPanel = new JPanel(new PropertyLayout(100, 10)); + bottomPanel.add("1.1.center.center", deliver); + bottomPanel.add("1.2.center.center", close); + + contentPanel.add("1.1.center.center", jTextField); + contentPanel.add("2.1.center.center", bottomPanel); + this.pack(); + this.setAlwaysOnTop(true); + this.centerToScreen(); + + } + +// class WaitingDialog extends AbstractAIFDialog { +// // private static final long serialVersionUID = 1L; +// public JPanel panel; +// public JProgressBar progressBar = null; +// +// public WaitingDialog() { +// initUI(); +// } +// +// public void initUI() { +// this.setTitle("请稍等......"); +// this.setModal(false); +// this.setVisible(true); +// this.setAlwaysOnTop(true); +// +// panel = new JPanel(new BorderLayout()); +// +// progressBar = new JProgressBar(SwingConstants.HORIZONTAL); +// progressBar.setVisible(true); +// progressBar.setIndeterminate(true); +// +//// panel.add(BorderLayout.CENTER, new JLabel(message)); +// panel.add(BorderLayout.SOUTH, progressBar); +// +// panel.setPreferredSize(new Dimension(350, 60)); +// +// this.getContentPane().add(panel); +// +// centerToScreen(); +// +// pack(); +// } +// +// public void close() { +// this.setVisible(false); +// this.dispose(); +// } +// +// } + +// public void run() { +// +// } +} diff --git a/src/com/connor/nbhs/plm/shentu/createDelivery/CreateDeliveryDialog.java b/src/com/connor/nbhs/plm/shentu/createDelivery/CreateDeliveryDialog.java new file mode 100644 index 0000000..831c9ae --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/createDelivery/CreateDeliveryDialog.java @@ -0,0 +1,216 @@ +package com.connor.nbhs.plm.shentu.createDelivery; + +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTextField; + +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.TCComponentDataset; +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.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; + +/** + * + *

+ * Title: CreateDeliveryDialog + *

+ *

+ * Description: + *

+ * + * @author shentu + * @date 2022年3月4日 + */ +public class CreateDeliveryDialog extends AbstractAIFDialog { + + private AbstractAIFApplication app; + + private TCSession session; + + private String objectType; + + private String dname; + + private JTextField field; + + private JRadioButton yb; + + private JRadioButton nb; + + private InterfaceAIFComponent target; + + public CreateDeliveryDialog(AbstractAIFApplication app, String value, InterfaceAIFComponent target) { + this.app = app; + this.session = (TCSession) app.getSession(); + this.objectType = value.substring(value.indexOf("=") + 1); + this.dname = value.substring(0, value.indexOf("=")); + this.target = target; + } + + public void run() { + + this.setLayout(new PropertyLayout()); + this.setTitle("新建交付物"); + this.setResizable(false); + + JPanel northPanel = new JPanel(new PropertyLayout()); + JLabel nameLabel = new JLabel(" 文件名称"); + field = new JTextField(dname, 18); + northPanel.add("1.1.center.top", nameLabel); + northPanel.add("1.2.center.top", field); + + JPanel centerPanel = new JPanel(new PropertyLayout()); + JLabel checkLabel = new JLabel("是否自动创建模板"); + ButtonGroup group = new ButtonGroup(); + yb = new JRadioButton("是", true); + nb = new JRadioButton("否"); + group.add(yb); + group.add(nb); + centerPanel.add("1.1.center.top", checkLabel); + centerPanel.add("1.2.center.top", yb); + centerPanel.add("1.3.center.top", nb); + + JPanel southPanel = new JPanel(new FlowLayout()); + southPanel.setPreferredSize(new Dimension(250, 80)); + JButton okBtn = new JButton("确定"); + okBtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + String dname = field.getText(); + boolean flag = true; + if (nb.isSelected()) { + flag = false; + } + createDelivery(dname, flag); + disposeDialog(); + } + + }); + JButton celBtn = new JButton("取消"); + celBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + southPanel.add(okBtn); + southPanel.add(celBtn); + + this.add("1.1.center.top", northPanel); + this.add("2.1.center.top", centerPanel); + this.add("3.1.center.top", southPanel); + + this.centerToScreen(); + this.pack(); + this.showDialog(); + + } + + // 点击确定按钮的触发事件,创建一个交付物对象并添加到目标文件夹下 + private void createDelivery(String dname, boolean flag) { + try { + // 创建交付物对象 + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent(objectType); + if (typeComponent == null) { + MessageBox.post("系統中不存在该交付物对应的对象类型" + objectType + "请在BMIDE中创建后再尝试", "提示", MessageBox.INFORMATION); + disposeDialog(); + } + String newID = typeComponent.getNewID(); + String newRev = typeComponent.getNewRev(null); + TCComponentItem item = typeComponent.create(newID, newRev, objectType, dname, null, null); + // 根据复选框的选择,添加模板到新建对象下 + if (flag) { + // 获取首选项的值 + TCPreferenceService service2 = session.getPreferenceService(); + String[] values = service2.getStringValues("Connor_CreateDel_Template"); + if (values == null) { + MessageBox.post("请先创建首选项'Connor_CreateDel_Template'", "提示", MessageBox.INFORMATION); + disposeDialog(); + } + String uids = null; + String[] uid_arr = null; + for (int i = 0; i < values.length; i++) { + if (values[i].contains(objectType)) { + uids = values[i].substring(values[i].indexOf("=") + 1); + uid_arr = uids.split(";"); + break; + } + } + if (uids == null) { + MessageBox.post("在首选项中,未找到该交付物对象对应的模板", "提示", MessageBox.INFORMATION); + disposeDialog(); + } + for (int i = 0; i < uid_arr.length; i++) { + String uid = uid_arr[i]; + System.out.println(uid); + TCComponent comp = session.stringToComponent(uid); + if (comp == null) { + MessageBox.post("未找到该UID:" + uid + "对应的模板", "提示", MessageBox.INFORMATION); + disposeDialog(); + } +// System.out.println(comp.getStringProperty("object_type")); + TCComponentDataset dataset = (TCComponentDataset) comp; +// String name = dataset.getStringProperty("object_name"); + String datasetName = dataset.getStringProperty("object_name"); + TCComponentDataset newDataset = dataset.saveAs(datasetName); + TCComponentItemRevision itemRevision = item.getLatestItemRevision(); + itemRevision.add("IMAN_specification", newDataset); + } + } + if (target instanceof TCComponentFolder) { + TCComponentFolder targetFolder = (TCComponentFolder) target; + if(targetFolder.getType().equals("HS2_ProjectFolder")) { + targetFolder.add("HS2_ProjectFolderRelation", item); + }else { + targetFolder.add("contents", item); + } + + targetFolder.refresh(); + } else { + TCComponentProject project = (TCComponentProject) target; + try { + project.assignToProject(new TCComponent[] { item }); + } catch (TCException e) { + // TODO: handle exception + String message = e.getMessage(); + if(message.contains("特权用户")) { + MessageBox.post(message+",请联系项目管理员添加为特权用户","提示",2); + } + } + + project.refresh(); +// System.out.println("项目" + project + "刷新成功"); +//// item.refresh(); +// TCComponent[] comps = project.getTCProperty("project_data").getReferenceValueArray(); +// String smartFolderName = comps[0].getStringProperty("folder_name"); +// comps[0].refresh(); +// System.out.println("智能文件夹" + smartFolderName + "刷新成功"); + + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + +} diff --git a/src/com/connor/nbhs/plm/shentu/createDelivery/CreateDeliveryHandler.java b/src/com/connor/nbhs/plm/shentu/createDelivery/CreateDeliveryHandler.java new file mode 100644 index 0000000..56a82d8 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/createDelivery/CreateDeliveryHandler.java @@ -0,0 +1,29 @@ +package com.connor.nbhs.plm.shentu.createDelivery; + +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; + +public class CreateDeliveryHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + // 获取commandName,与交付物相对应 + String cname = ""; + try { + cname = event.getCommand().getName(); + System.out.println("按钮的名称为:" + cname); + } catch (NotDefinedException e) { + e.printStackTrace(); + } + CreateDeliveryOperation operation = new CreateDeliveryOperation(app, cname); + app.getSession().queueOperation(operation); + return null; + } + +} diff --git a/src/com/connor/nbhs/plm/shentu/createDelivery/CreateDeliveryOperation.java b/src/com/connor/nbhs/plm/shentu/createDelivery/CreateDeliveryOperation.java new file mode 100644 index 0000000..bb88a8a --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/createDelivery/CreateDeliveryOperation.java @@ -0,0 +1,64 @@ +package com.connor.nbhs.plm.shentu.createDelivery; + +import java.util.Arrays; +import java.util.List; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CreateDeliveryOperation extends AbstractAIFOperation { + + private AbstractAIFApplication app; + private TCSession session; + private String cname; + + public CreateDeliveryOperation(AbstractAIFApplication app, String cname) { + this.app = app; + this.cname = cname; + this.session = (TCSession) app.getSession(); + } + + @Override + public void executeOperation() throws Exception { + // 先判断是否选中文件夹 + InterfaceAIFComponent target = app.getTargetComponent(); + + if (target != null) { + if (target instanceof TCComponentFolder || target instanceof TCComponentProject) { + // 获取首选项的值 + TCPreferenceService service2 = session.getPreferenceService(); + String[] values = service2.getStringValues("Connor_Deliverables_ObjectType"); + if (values == null) { + MessageBox.post("请先创建首选项'Connor_Deliverables_ObjectType'并为其赋值", "提示", MessageBox.INFORMATION); + return; + } + List valueList = Arrays.asList(values); + for (String value : valueList) { + String deliveryName = value.substring(0, value.indexOf("=")); + if (cname.equals(deliveryName)) { +// String ObjectType = value.substring(value.indexOf("=") + 1); + // 弹出窗口 + CreateDeliveryDialog cdd = new CreateDeliveryDialog(app, value, target); + new Thread(cdd).start(); + return; + } + } + MessageBox.post("在首选项中未找到该交付物的对象类型", "提示", MessageBox.INFORMATION); + } else { + MessageBox.post("您选中的对象不是文件夹或项目,请确认后再试", "提示", MessageBox.INFORMATION); + return; + } + } else { + MessageBox.post("请先选中存放交付物对象的文件夹或项目", "提示", MessageBox.INFORMATION); + return; + } + + } + +} diff --git a/src/com/connor/nbhs/plm/shentu/handlers/CreateMaterialsBomDialog.java b/src/com/connor/nbhs/plm/shentu/handlers/CreateMaterialsBomDialog.java new file mode 100644 index 0000000..112470b --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/handlers/CreateMaterialsBomDialog.java @@ -0,0 +1,398 @@ +package com.connor.nbhs.plm.shentu.handlers; + +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.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentPart; +import com.teamcenter.rac.kernel.TCException; +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.soaictstubs.booleanSeq_tHolder; + +public class CreateMaterialsBomDialog extends AbstractAIFDialog{ + + private AbstractAIFApplication app; + private Map> maps; + private TCComponentBOMWindow win; + private List bomlines; + private List jComboBoxs; + private List> listMaps; + + + public CreateMaterialsBomDialog(AbstractAIFApplication app,Map> maps,List bomlines) { + this.app = app; + this.maps = maps; + this.bomlines = bomlines; + initUI(); + this.win = createWindow(); + } + + private JLabel label=null; + private TCComponentBOMWindow createWindow() { + TCComponentBOMWindow window=null; + try { + TCSession session = (TCSession) app.getSession(); + TCTypeService service = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + window = winType.create(null); + } catch (TCException e) { + e.printStackTrace(); + } + return window; + } + public void initUI() { + this.setTitle("图纸BOM转物料BOM"); + this.setAutoRequestFocus(true); + this.setSize(new Dimension(650, 320)); + this.setResizable(false); + JPanel bigJPanel = new JPanel(new BorderLayout()); + bigJPanel.setPreferredSize(new Dimension(650, 320)); + JPanel panel = new JPanel(null); + //下拉框集合 + jComboBoxs = new ArrayList(); + int count = 1; + //下拉框里的数据集键值对 + listMaps = new ArrayList>(); + + for(Entry> map:maps.entrySet()) { + System.out.println("start========================================================="); + System.out.println(map.getValue().size()); + if(map.getValue().size()>=1) { + System.out.println("start1========================================================="); + try { + label = new JLabel(map.getKey().getProperty("object_string")); + label.setBounds(200, 40*count, 100, 25); + TCComponentItemRevision[] itemRevs = new TCComponentItemRevision[map.getValue().size()]; + for(int listlength=0;listlength itemRevMaps = new HashMap(); + for(int i=0;i map) { + final JComboBox cbox = new JComboBox(); + for (String objectName : map.keySet()) { + cbox.addItem(objectName); + } + return cbox; + } + + public TCComponentItemRevision getItemRev(JComboBox cbox,Map map) { + TCComponentItemRevision itemRev = null; + String objectName = (String) cbox.getSelectedItem(); + itemRev = map.get(objectName); + return itemRev; + } + + public TCComponentItemRevision getWuLiaoRev(TCComponentItemRevision tuZhiChildRev,List jComboBoxs,List> listMaps) { + TCComponentItemRevision wuLiaoRev=null; + try { + TCComponent[] components = tuZhiChildRev.getTCProperty("representation_for").getReferenceValueArray(); + List productList = new ArrayList(); + for(int leng=0;leng1) { + for(int j=0;j=0) { + wuLiaoRev = productList.get(find); + break; + } + } + } + } catch (Exception e) { + System.out.println(e.getMessage()); + } + return wuLiaoRev; + } + /** + * 创建物料BOM + * @param bomlines + * @param jComboBoxs + * @param listMaps + * @return + */ + public boolean createBOM(List bomlines,List jComboBoxs,List> listMaps) { + try { + Map lineMap = new HashMap(); + win.lock(); + for(int i=0;i jComboBoxs,List> listMaps) { + try { + Map lineMap = new HashMap(); + TCComponentItemRevision tuZhiRev = line.getItemRevision(); +// TCComponent[] com = tuZhiRev.getTCProperty("IMAN_master_form_rev").getReferenceValueArray(); +// String isChange = com[0].getProperty("sb6_DRM10"); +// System.out.println("对象"+tuZhiRev.getProperty("object_name")+"的sb6_DRM10内容:"+isChange); + + TCComponentBOMLine topLine = win.setWindowTopLine(line.getItem(), line.getItemRevision(), null, null); + AIFComponentContext[] children = topLine.getChildren(); + +// if("是".equals(isChange)||"true".equals(isChange)||"".equals(isChange)||"Y".equals(isChange)) { + //获得图纸对应的物料 + TCComponentItemRevision wuLiaoRev = getWuLiaoRev(tuZhiRev, jComboBoxs, listMaps); + if(wuLiaoRev!=null) { + TCComponentBOMWindow window = createWindow(); + TCComponentBOMLine wuLiaoLine = window.setWindowTopLine(wuLiaoRev.getItem(), wuLiaoRev, null, null); + AIFComponentContext[] wuLiaochildren = wuLiaoLine.getChildren(); + System.out.println(wuLiaoLine.getProperty("bl_item_item_id")+"清除子集"); + // 移出所有的子bomline + if (wuLiaochildren != null) { + if(wuLiaochildren.length > 0) { + for (AIFComponentContext child : wuLiaochildren) { + wuLiaoLine.lock(); + wuLiaoLine.remove("", (TCComponent) child.getComponent()); + wuLiaoLine.save(); + wuLiaoLine.unlock(); + } + } + }else { + System.out.println(wuLiaoLine.getProperty("bl_item_item_id")+"已是叶子"); + } + if(children!=null) { + if(children.length>0) { + System.out.println("子集数量:"+children.length); + for(AIFComponentContext child : children) { + TCComponentBOMLine lin = (TCComponentBOMLine) child.getComponent(); + lin.unpack(); + } + AIFComponentContext[] children2 = topLine.getChildren(); + System.out.println("子集数量2:"+children2.length); + for(AIFComponentContext child : children2) { + TCComponentBOMLine lin = (TCComponentBOMLine) child.getComponent(); + String bl_quantity = lin.getProperty("bl_quantity"); + TCComponentItemRevision tuZhiChildRev= lin.getItemRevision(); + TCComponentItemRevision wuLiaoChildRev = null; + if(tuZhiChildRev.isTypeOf("Part Revision")) { + wuLiaoChildRev = tuZhiChildRev; + //System.out.println("bom行是物料"); + }else { + wuLiaoChildRev = getWuLiaoRev(tuZhiChildRev, jComboBoxs, listMaps); + } + if(wuLiaoChildRev!=null) { + System.out.println("图纸孩子名称:"+tuZhiChildRev.getProperty("object_name")+",物料孩子名称:"+wuLiaoChildRev.getProperty("object_name")+" 数量"+bl_quantity); + wuLiaoLine.lock(); + AIFComponentContext[] children3 = wuLiaoLine.getChildren(); + TCComponentBOMLine wuLiaoChildLine = wuLiaoLine.add(wuLiaoChildRev.getItem(),wuLiaoChildRev,null,false,""); + boolean needPack = false; + String seqNo = null; + if (children3 != null) { + if(children3.length > 0) { + for(AIFComponentContext child3:children3) { + TCComponentBOMLine childLine = (TCComponentBOMLine)child3.getComponent(); + if(childLine.getItemRevision().getStringProperty("item_id").equals(wuLiaoChildRev.getStringProperty("item_id"))) { + needPack = true; + seqNo = childLine.getStringProperty("bl_sequence_no"); + break; + } + } + } + } + if(needPack) { + wuLiaoChildLine.setStringProperty("bl_sequence_no", seqNo); + } +// wuLiaoChildLine.setStringProperty("bl_quantity", bl_quantity); + wuLiaoChildLine.pack(); + wuLiaoChildLine.save(); + wuLiaoLine.save(); + wuLiaoLine.unlock(); + } + } + }else { + System.out.println(topLine.getProperty("bl_item_item_id")+"已是图纸叶子2"); + } + }else { + System.out.println(topLine.getProperty("bl_item_item_id")+"已是图纸叶子"); + } + window.save(); + window.close(); + } +// TCComponentBOMLine topLine = win.setWindowTopLine(line.getItem(), line.getItemRevision(), null, null); +// AIFComponentContext[] children = topLine.getChildren(); + if (children!=null) { + if(children.length > 0) { + for (AIFComponentContext child : children) { + TCComponentBOMLine lin = (TCComponentBOMLine) child.getComponent(); + if(lin!=null) { + creatBOM2SB(lin,jComboBoxs,listMaps); + } + } + } + } +// } + return true; + + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } +} diff --git a/src/com/connor/nbhs/plm/shentu/handlers/CreateMaterialsBomHandler.java b/src/com/connor/nbhs/plm/shentu/handlers/CreateMaterialsBomHandler.java new file mode 100644 index 0000000..b4e2b7f --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/handlers/CreateMaterialsBomHandler.java @@ -0,0 +1,113 @@ +package com.connor.nbhs.plm.shentu.handlers; + +import java.awt.Component; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +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.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CreateMaterialsBomHandler extends AbstractHandler{ + + private TCComponentBOMWindow win; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent component = app.getTargetComponent(); + if(component instanceof TCComponentItemRevision) { + try { + TCComponentType componentType = session.getTypeComponent(component.getType()); + //System.out.println("父类:"+componentType.getParent().getTypeName()); + TCComponentItemRevision itemRevision = (TCComponentItemRevision) component; + TCComponentBOMWindowType type = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + win = type.create(null); + TCComponentBOMLine line = win.setWindowTopLine(itemRevision.getItem(), itemRevision, null, null); + List bomlines = new ArrayList(); + FindBom(line, bomlines); + win.close(); + System.out.println("BOM长度"+bomlines.size()); + if(bomlines.size()==1) { + MessageBox.post("未找到BOM视图","提示",4); + return null; + } + TCComponentItemRevision zcRevision = bomlines.get(0).getItemRevision(); + TCComponent[] com = zcRevision.getTCProperty("IMAN_master_form_rev").getReferenceValueArray(); + String isChange = com[0].getProperty("sb6_DRM10"); + if("N".equals(isChange)) { + System.out.println("总成图的子件转换的值为N,不创建BOM"); + MessageBox.post("总成图的子件转换的值为N,不创建BOM","提示",4); + return null; + } + //图纸对象,和其版本下关系文件夹中的物料 + Map> maps = new HashMap>(); + for(int j=0;j productList = new ArrayList(); + Boolean isfind = false; + for(int i=0;i bomLine) { + try { + if(lin.getItemRevision().isTypeOf("Design Revision")) { + bomLine.add(lin); + } + //System.out.println(lin.getItemRevision().getProperty("object_string")); + AIFComponentContext[] children = lin.getChildren(); + if (children.length != 0) { + for (AIFComponentContext child : children) { + lin = (TCComponentBOMLine) child.getComponent(); + FindBom(lin, bomLine); + } + } + } catch (Exception e) { + System.out.println(e.getMessage()); + } + } + +} diff --git a/src/com/connor/nbhs/plm/shentu/handlers/SampleHandler.java b/src/com/connor/nbhs/plm/shentu/handlers/SampleHandler.java new file mode 100644 index 0000000..43bf2b1 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/handlers/SampleHandler.java @@ -0,0 +1,21 @@ +package com.connor.nbhs.plm.shentu.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.handlers.HandlerUtil; +import org.eclipse.jface.dialogs.MessageDialog; + +public class SampleHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); + MessageDialog.openInformation( + window.getShell(), + "Plm", + "Hello, Eclipse world"); + return null; + } +} diff --git a/src/com/connor/nbhs/plm/shentu/hs008ResumeFormChange/CreateResumeFormChangeHandler.java b/src/com/connor/nbhs/plm/shentu/hs008ResumeFormChange/CreateResumeFormChangeHandler.java new file mode 100644 index 0000000..73e29fe --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/hs008ResumeFormChange/CreateResumeFormChangeHandler.java @@ -0,0 +1,19 @@ +package com.connor.nbhs.plm.shentu.hs008ResumeFormChange; + +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 CreateResumeFormChangeHandler extends AbstractHandler { + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + CreateResumeFormOperation operation = new CreateResumeFormOperation(app); + app.getSession().queueOperation(operation); + return null; + } + +} diff --git a/src/com/connor/nbhs/plm/shentu/hs008ResumeFormChange/CreateResumeFormOperation.java b/src/com/connor/nbhs/plm/shentu/hs008ResumeFormChange/CreateResumeFormOperation.java new file mode 100644 index 0000000..056280d --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/hs008ResumeFormChange/CreateResumeFormOperation.java @@ -0,0 +1,296 @@ +package com.connor.nbhs.plm.shentu.hs008ResumeFormChange; + +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 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.nbhs.plm.shentu.utils.MethodUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CreateResumeFormOperation extends AbstractAIFOperation { + + private AbstractAIFApplication app; + + private TCSession session; + + private InterfaceAIFComponent target; + + private TCComponentProject project; + + private List changeNoticeList = new ArrayList<>(); + + private SimpleDateFormat dateFormate = new SimpleDateFormat("yyyy/MM/dd"); + + public CreateResumeFormOperation(AbstractAIFApplication app) { + super(); + this.app = app; + this.session = (TCSession) app.getSession(); + this.target = app.getTargetComponent(); + } + + @Override + public void executeOperation() throws Exception { + try { + if (target != null) { + if (target instanceof TCComponentProject) { + project = (TCComponentProject) target; + // HS2_GGRWDItem + TCComponent[] comps = project.getTCProperty("project_data").getReferenceValueArray(); + for (int i = 0; i < comps.length; i++) { + System.out.println(comps[i].getStringProperty("folder_name")); + if ("变更管理".equals(comps[i].getStringProperty("folder_name"))) { + TCComponent[] valueArray = comps[i].getTCProperty("project_data").getReferenceValueArray(); + for (int j = 0; j < valueArray.length; j++) { + System.out.println(valueArray[j].getStringProperty("object_name")); + if (valueArray[j] instanceof TCComponentItem + && "HS2_Notice".equals(valueArray[j].getStringProperty("object_type"))) { + TCComponentItem changeTask = (TCComponentItem) valueArray[j]; + TCComponentItemRevision changeNoticeRev = changeTask.getLatestItemRevision(); + changeNoticeList.add(changeNoticeRev); + System.out.println(changeNoticeList); + } + } + createResumeForm(); + } + } + } else { + MessageBox.post("选中的不是项目对象", "提示", MessageBox.INFORMATION); + } + } else { + MessageBox.post("请先选中要生成变更履历表的项目", "提示", MessageBox.INFORMATION); + return; + } + } catch (Exception e) { + e.printStackTrace(); + } + + } + + private void createResumeForm() { + String[] values = MethodUtil.getPrefStrArray("HS2_GCGGLLB"); + if (values == null || values.length == 0) { + MessageBox.post("请联系管理员创建首选项HS2_GCGGLLB或为该首选项赋值", "提示", MessageBox.INFORMATION); + return; + } + + String uid = values[0]; + System.out.println(uid); + TCComponent comp = null; + try { + comp = session.stringToComponent(uid); + if (comp == null) { + MessageBox.post("未找到该UID:" + uid + "对应的点检模板,请联系管理员配置", "提示", MessageBox.INFORMATION); + return; + } + // 根据不同阶段得到对应的点检模板,修改模板excel,保存到新建的点检结果中 + if (comp instanceof TCComponentDataset) { + TCComponentDataset changeResumeModel = (TCComponentDataset) comp; + File[] files = changeResumeModel.getFiles(""); + // 缓存文件的绝对路径 + String absolutePath = files[0].getAbsolutePath(); + System.out.println(absolutePath); + SimpleDateFormat sf = new SimpleDateFormat("yyyyMMDDHHmmss"); + String time = sf.format(new Date()); + String path = files[0].getParent() + File.separator + "工程更改履历表" + time + ".xlsx"; + System.out.println(path); + if (files[0] != null) { + createAndFillExcel(files[0], path); + } else { + MessageBox.post("点检模板下未关联对应的Excel模板", "提示", MessageBox.INFORMATION); + return; + } + TCComponentItem resultItem = MethodUtil.createItem("HS2_EngineeringR", "工程更改履历表"); + // 修改数据集在服务器上的引用文件 + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset"); + TCComponentDataset newDataset = datasetType.create("工程更改履历表", "", "MSExcelX"); + newDataset.setFiles(new String[] { path }, new String[] { "excel" }); + resultItem.getLatestItemRevision().add("IMAN_specification", newDataset); + // 将点检结果保存在NewStuffFolder中,并且指派到项目中 + TCComponentFolder newStuffFolder = session.getUser().getNewStuffFolder(); + newStuffFolder.add("contents", resultItem); + project.assignToProject(new TCComponent[] { resultItem }); + project.refresh(); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /** + * 根据工程更改履历表模板创建一个新的更改履历表Excel并填写数据 + * + * @param file + * @param path 新的更改履历表的存放路径 + */ + private void createAndFillExcel(File file, String path) { + FileInputStream fis = null; + FileOutputStream fos = null; + XSSFWorkbook workbook = null; + try { + fis = new FileInputStream(file); + workbook = new XSSFWorkbook(fis); + fis.close(); + XSSFSheet sheet = workbook.getSheetAt(0); + XSSFRow row = sheet.getRow(3); + if (changeNoticeList != null && changeNoticeList.size() > 0) { +// row.getCell(0).setCellValue("\t\t\t" + "总成产品名称:" + changeTaskList.get(0).getStringProperty("hs2_ZCCPMC") +// + "\t\t\t\t总成产品零件号:" + changeTaskList.get(0).getStringProperty("hs2_ZCCPLJH")); + row.getCell(1).setCellValue("总成产品名称:"); + row.getCell(2).setCellValue(changeNoticeList.get(0).getStringProperty("hs2_assemblyproname")); + row.getCell(5).setCellValue("总成产品零件号:"); + row.getCell(6).setCellValue(changeNoticeList.get(0).getStringProperty("hs2_assemblypartname")); + for (int j = 0; j < changeNoticeList.size(); j++) { + row = sheet.getRow(5 + j); + List values = getCellValueList(changeNoticeList.get(j)); + if (row != null) { + row.getCell(0).setCellValue(j + 1); + for (int i = 0; i < values.size(); i++) { + System.out.println(values.get(i)); + XSSFCell cell = row.getCell(i + 1); + cell.setCellValue(values.get(i)); +// row.getCell(i + 1).setCellValue(values.get(i)); + } + } else { + row = sheet.createRow(5 + j); + row.createCell(0).setCellValue(j + 1); + for (int i = 0; i < values.size(); i++) { + System.out.println(values.get(i)); + XSSFCell cell = row.createCell(i + 1); + cell.setCellValue(values.get(i)); + } + createCellStyle(sheet, row); + } + + } + } + fos = new FileOutputStream(new File(path)); + workbook.write(fos); + + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + try { + if (fis != null) + fis.close(); + if (fos != null) { + fos.flush(); + fos.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + } + + /** + * 为新建的表格添加样式 当模板表格不够用的情况下,需要自动创建一行表格,且为新建的表格添加样式 + * + * @param sheet + * @param targetRow 新创建的一个表格 + */ + private void createCellStyle(XSSFSheet sheet, XSSFRow targetRow) { + // 模板表格样式 + XSSFRow sourceRow = sheet.getRow(5); + for (int i = 0; i < sourceRow.getLastCellNum(); i++) { + System.out.println(i); + XSSFCellStyle style = sourceRow.getCell(i).getCellStyle(); + targetRow.getCell(i).setCellStyle(style); + } + + } + + /** + * 取出工程更改通知单中的数据放到list中,便于填写excel表格 + * + * @param changeNoticeRev + * @return + * @throws TCException + */ + private List getCellValueList(TCComponentItemRevision changeNoticeRev) throws TCException { + List valueList = new ArrayList<>(); + valueList.add(changeNoticeRev.getStringProperty("hs2_changepartname")); +// System.out.println("更改零件名称:" + changeNoticeRev.getProperty("hs2_GGLJMC")); + valueList.add(changeNoticeRev.getStringProperty("hs2_changepartnumber")); + valueList.add(changeNoticeRev.getStringProperty("hs2_customernumber")); + valueList.add(changeNoticeRev.getStringProperty("hs2_applicant")); + valueList.add(changeNoticeRev.getStringProperty("hs2_reasonchange")); + TCComponent[] valueArray = changeNoticeRev.getTCProperty("HS2_ValidationReport").getReferenceValueArray(); + System.out.println(valueArray.length); + if (valueArray != null && valueArray.length > 0) { + System.out.println(valueArray[0].getStringProperty("object_name")); + if ("HS2_Verify".equals(valueArray[0].getStringProperty("object_type"))) { + valueList.add(dateFormate.format(valueArray[0].getDateProperty("creation_date"))); + } else { + valueList.add(""); + } + } else { + valueList.add(""); + } + valueList.add(""); + valueList.add(""); + TCComponent[] changeTasks = changeNoticeRev.getTCProperty("HS2_TaskList").getReferenceValueArray(); + if (changeTasks != null && changeTasks.length > 0) { + System.out.println(changeTasks[0].getStringProperty("object_name")); + if ("HS2_ChangeTask".equals(changeTasks[0].getStringProperty("object_type"))) { +// valueList.add(changeTasks[0].getProperty("owning_user")); + valueList.add(changeTasks[0].getRelatedComponent("owning_user").getProperty("person")); + } else { + valueList.add(""); + } + } else { + valueList.add(""); + } + if (valueArray != null && valueArray.length > 1) { + if ("HS2_Verify".equals(valueArray[0].getStringProperty("object_type"))) { + TCComponentItem validateReport = (TCComponentItem) valueArray[0]; + if (MethodUtil.isCompReleased(validateReport.getLatestItemRevision())) { + valueList.add("合格"); + } else { + valueList.add(""); + } + } else { + valueList.add(""); + } + + } else { + valueList.add(""); + } + System.out.println(valueList); + return valueList; + } + +} diff --git a/src/com/connor/nbhs/plm/shentu/hs013SpotcheckDelivery/SpotCheckDeliveryDialog.java b/src/com/connor/nbhs/plm/shentu/hs013SpotcheckDelivery/SpotCheckDeliveryDialog.java new file mode 100644 index 0000000..0eb0c48 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/hs013SpotcheckDelivery/SpotCheckDeliveryDialog.java @@ -0,0 +1,28 @@ +package com.connor.nbhs.plm.shentu.hs013SpotcheckDelivery; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCSession; + +public class SpotCheckDeliveryDialog extends AbstractAIFDialog { + + private AbstractAIFApplication app; + + private TCSession session; + + private TCComponentSchedule schedule; + + public SpotCheckDeliveryDialog(AbstractAIFApplication app, TCComponentSchedule schedule) { + super(); + this.app = app; + this.session = (TCSession) app.getSession(); + this.schedule = schedule; + } + + @Override + public void run() { + + } + +} diff --git a/src/com/connor/nbhs/plm/shentu/hs013SpotcheckDelivery/SpotCheckDeliveryHandler.java b/src/com/connor/nbhs/plm/shentu/hs013SpotcheckDelivery/SpotCheckDeliveryHandler.java new file mode 100644 index 0000000..875e9ac --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/hs013SpotcheckDelivery/SpotCheckDeliveryHandler.java @@ -0,0 +1,36 @@ +package com.connor.nbhs.plm.shentu.hs013SpotcheckDelivery; + +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; + +public class SpotCheckDeliveryHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + // 获取commandName,与交付物相对应 + String cname = ""; + String id = ""; + String version = ""; + try { + cname = event.getCommand().getName(); + id = event.getCommand().getId(); + if (id.contains("fullVersion")) { + version = "完整版"; + } else { + version = "简易版"; + } + } catch (NotDefinedException e) { + e.printStackTrace(); + } + SpotCheckDeliveryOperation operation = new SpotCheckDeliveryOperation(app, cname, version); + app.getSession().queueOperation(operation); + return null; + } + +} diff --git a/src/com/connor/nbhs/plm/shentu/hs013SpotcheckDelivery/SpotCheckDeliveryOperation.java b/src/com/connor/nbhs/plm/shentu/hs013SpotcheckDelivery/SpotCheckDeliveryOperation.java new file mode 100644 index 0000000..3d7331d --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/hs013SpotcheckDelivery/SpotCheckDeliveryOperation.java @@ -0,0 +1,519 @@ +package com.connor.nbhs.plm.shentu.hs013SpotcheckDelivery; + +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 org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.nbhs.plm.shentu.utils.DataBaseControl; +import com.connor.nbhs.plm.shentu.utils.MethodUtil; +import com.connor.nbhs.plm.shentu.utils.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.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class SpotCheckDeliveryOperation extends AbstractAIFOperation { + + private AbstractAIFApplication app; + + private TCSession session; + // 被选中的目标对象 + private InterfaceAIFComponent target; + + private TCComponentProject project; + + private String cname; + + private String version; + + private SpotCheckEnum spotCheckEnum; + + private int sheetIndex; + + private SimpleDateFormat dateFormate = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + + private String start_date; + + private String finish_date; + // // 所有任务的名称集合 + // private List taskNameList = new ArrayList(); + // // 所有任务对应的交付物名称 + // private List deliveryNameList = new ArrayList(); + // // 所有交付物对象类型名称 + // private List itemTypeList = new ArrayList(); + // 需要完成的交付物名称 + private List selectedDeliveryNameList = new ArrayList(); + // 需要完成的交付物对象类型名称集合 + private List selectedItemTypeList = new ArrayList(); + // 已经完成的交付物对象类型名称集合 + private List deliveredTypeList = new ArrayList(); + // 已经完成的交付物对象版本集合 + private List deliveredItemRevList = new ArrayList<>(); + // 修改后的点检结果保存路径 + private String path; + // 进度条 + private ProgressBarThread wait; + + public SpotCheckDeliveryOperation(AbstractAIFApplication app, String cname, String version) { + super(); + this.app = app; + this.cname = cname; + this.version = version; + this.session = (TCSession) app.getSession(); + this.target = app.getTargetComponent(); + switch (cname + version) { + case "第一阶段(立项阶段)完整版": + this.spotCheckEnum = SpotCheckEnum.ONE_F; + // sheetIndex = 0; + break; + case "第二阶段(产品设计开发阶段)完整版": + this.spotCheckEnum = SpotCheckEnum.TWO_F; + // sheetIndex = 1; + break; + case "第三阶段(过程设计开发阶段)完整版": + this.spotCheckEnum = SpotCheckEnum.THREE_F; + // sheetIndex = 2; + break; + case "第四阶段(产品过程确认)完整版": + this.spotCheckEnum = SpotCheckEnum.FOUR_F; + // sheetIndex = 3; + break; + case "第一阶段(立项阶段)简易版": + this.spotCheckEnum = SpotCheckEnum.ONE_E; + // sheetIndex = 0; + break; + case "第二阶段(产品设计开发阶段)简易版": + this.spotCheckEnum = SpotCheckEnum.TWO_E; + // sheetIndex = 1; + break; + case "第三阶段(过程设计开发阶段)简易版": + this.spotCheckEnum = SpotCheckEnum.THREE_E; + // sheetIndex = 2; + break; + case "第四阶段(产品过程确认)简易版": + this.spotCheckEnum = SpotCheckEnum.FOUR_E; + // sheetIndex = 3; + break; + case "第一阶段(前期阶段)完整版": + this.spotCheckEnum = SpotCheckEnum.FIVE_F; + // sheetIndex = 3; + break; + case "第二阶段(设计项目阶段)完整版": + this.spotCheckEnum = SpotCheckEnum.SIX_F; + // sheetIndex = 3; + break; + case "第三阶段(正式项目阶段)完整版": + this.spotCheckEnum = SpotCheckEnum.SEVEN_F; + // sheetIndex = 3; + break; + case "第一阶段(前期阶段)简易版": + this.spotCheckEnum = SpotCheckEnum.FIVE_E; + // sheetIndex = 3; + break; + case "第二阶段(设计项目阶段)简易版": + this.spotCheckEnum = SpotCheckEnum.SIX_E; + // sheetIndex = 3; + break; + case "第三阶段(正式项目阶段)简易版": + this.spotCheckEnum = SpotCheckEnum.SEVEN_E; + // sheetIndex = 3; + break; + default: + break; + } + } + + @Override + public void executeOperation() { + try { + if (target != null) { + if (target instanceof TCComponentProject) { + wait = new ProgressBarThread("导出点检表", "执行中,请稍等..."); + wait.start(); + project = (TCComponentProject) target; + TCComponent[] comps = project.getTCProperty("project_data").getReferenceValueArray(); + System.out.println("spotCheckEnum.getPhaseName()===="+spotCheckEnum.getPhaseName()); + TCComponent[] valueArray = null; + for (int i = 0; i < comps.length; i++) { + if (spotCheckEnum.getProjectName().equals(comps[i].getStringProperty("folder_name"))) { + TCComponent[] dataComps = comps[i].getTCProperty("project_data").getReferenceValueArray(); + for (int k = 0; k < dataComps.length; k++) { + if (spotCheckEnum.getPhaseName().equals(dataComps[k].getStringProperty("folder_name"))) { + TCComponent[] valueArray2 = dataComps[k].getTCProperty("project_data").getReferenceValueArray(); + for (int j = 0; j < valueArray2.length; j++) { + System.out.println(valueArray2[j].getStringProperty("object_name")); + if (valueArray2[j] instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) valueArray2[j]; + TCComponentItemRevision itemRevision = item.getLatestItemRevision(); + deliveredItemRevList.add(itemRevision); + deliveredTypeList.add(valueArray2[j].getStringProperty("object_type")); + } + } + break; + } + } + }else if ("项目计划".equals(comps[i].getStringProperty("folder_name"))) { + valueArray = comps[i].getTCProperty("project_data").getReferenceValueArray(); + } + } + + + if (valueArray != null && valueArray.length > 0) { + for (int j = 0; j < valueArray.length; j++) { + System.out.println("name====="+valueArray[j].getStringProperty("object_name")); + if (valueArray[j] instanceof TCComponentSchedule) { + TCComponentSchedule schedule = (TCComponentSchedule) valueArray[j]; + // 获取该时间任务下所有立项阶段需要完成的任务名称集合 + List leafTaskNameList = getChildTask(schedule); + System.out.println(leafTaskNameList); + // 从数据库中取出需要完成任务对应的交付物 + getDeliveryNameList(leafTaskNameList); + // + // test(); + createSpotCheckResult(); + wait.setBool(true); + } + } + } else { + MessageBox.post("没有安排项目计划,请先安排项目计划", "提示", MessageBox.INFORMATION); + } + } else { + MessageBox.post("选中的不是项目对象", "提示", MessageBox.INFORMATION); + } + } else { + MessageBox.post("请先选中要点检的项目", "提示", MessageBox.INFORMATION); + return; + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + wait.setBool(true); + } + + } + + /** + * 从数据库中取出需要完成任务对应的交付物 和 交付物对应的对象类型名称 + * + * selectedDeliveryNameList selectedItemTypeList + * + * @param leafTaskNameList + */ + private void getDeliveryNameList(List leafTaskNameList) { + // 所有任务的名称集合 + List taskNameList = new ArrayList(); + // 所有任务对应的交付物名称 + List deliveryNameList = new ArrayList(); + // 所有交付物对象类型名称 + List itemTypeList = new ArrayList(); + DataBaseControl dataBaseControl = new DataBaseControl(session); + dataBaseControl.getTaskFileList(taskNameList, deliveryNameList, itemTypeList,cname); + System.out.println("leafTaskNameList==="+leafTaskNameList); + for (int i = 0; i < taskNameList.size(); i++) { + System.out.println("taskNameList==1111="+taskNameList.get(i)); + if (leafTaskNameList.contains(taskNameList.get(i))) { + selectedDeliveryNameList.add(deliveryNameList.get(i)); + selectedItemTypeList.add(itemTypeList.get(i)); + } + } + + } + + /** + * 获取该时间任务下所有指定项目阶段下需要完成的任务名称集合 + * + * @param schedule + * @return + * @throws Exception + */ + private List getChildTask(TCComponentSchedule schedule) throws Exception { + List leafTaskNameList = new ArrayList(); + AIFComponentContext[] childs = getChilds(schedule); + for (AIFComponentContext child : childs) { + TCComponentScheduleTask scheduleTask = (TCComponentScheduleTask) child.getComponent(); + String type = scheduleTask.getType(); + if (!"ScheduleTask".equals(type)) { + continue; + } + String name = scheduleTask.getStringProperty("object_name"); + System.out.println(name); + // 找到对应阶段的子时间任务表,递归取出叶子节点任务,并存入到集合当中 + if (spotCheckEnum.getPhaseName().equals(name)) { + getLeafTaskName(scheduleTask, leafTaskNameList); + return leafTaskNameList; + } + } + return null; + } + + /** + * 递归取出叶子节点任务,并存入到集合当中 + * + * @param task + * @return + * @throws TCException + */ + private void getLeafTaskName(TCComponentScheduleTask task, List leafTaskNameList) throws TCException { + AIFComponentContext[] childrens = task.getChildren("child_task_taglist"); + if (childrens != null && childrens.length > 0) { + for (AIFComponentContext children : childrens) { + TCComponentScheduleTask childTask = (TCComponentScheduleTask) children.getComponent(); + getLeafTaskName(childTask, leafTaskNameList); + } + } else { + String leafTaskName = task.getStringProperty("object_name"); + leafTaskNameList.add(leafTaskName); + String name = cname; + if(cname.contains("(")) { + String[] split = cname.split("\\("); + name = split[0]; + } + if ((name + "评审").equals(leafTaskName)) { + Date startDate = task.getDateProperty("start_date"); + start_date = dateFormate.format(startDate); + } + } + } + + /** + * 获得时间表任务的子任务节点 + */ + public AIFComponentContext[] getChilds(TCComponentSchedule schedule) { + AIFComponentContext[] childs = null; + try { + TCComponent scheduleChild = schedule.getReferenceProperty("fnd0SummaryTask"); + childs = scheduleChild.getChildren(); + } catch (TCException e) { + e.printStackTrace(); + } + return childs; + } + + /** + * 创建交付物点检结果 + */ + public void createSpotCheckResult() { + // 根据首选项里配置的值,找到对应阶段的点检模板Excel文件 + String[] prefval = MethodUtil.getPrefStrArray("Connor_Deliverables_Template"); + if (prefval == null || prefval.length == 0) { + MessageBox.post("请联系管理员创建首选项Connor_Deliverables_Template或为该首选项赋值", "提示", MessageBox.INFORMATION); + return; + } + String uid = null; + for (int i = 0; i < prefval.length; i++) { + if (prefval[i].contains(version) && prefval[i].contains(cname)) { + if(prefval[i].contains("=")) { + String[] uids = prefval[i].split("="); + uid = uids[1]; + }else { + MessageBox.post("Connor_Deliverables_Template配置有问题,请联系管理员查看", "提示", MessageBox.INFORMATION); + return; + } + System.out.println(uid); + break; + } + } + if (uid == null) { + MessageBox.post("请联系管理员在首选项Connor_Deliverables_Template中配置对应项目阶段的点检模板uid", "提示", MessageBox.INFORMATION); + return; + } + TCComponent comp = null; + try { + comp = session.stringToComponent(uid); + if (comp == null) { + MessageBox.post("未找到该UID:" + uid + "对应的点检模板,请联系管理员配置", "提示", MessageBox.INFORMATION); + return; + } + // 根据不同阶段得到对应的点检模板,修改模板excel,保存到新建的点检结果中 + if (comp instanceof TCComponentDataset) { + TCComponentDataset excelData = (TCComponentDataset) comp; + String name = cname + "交付物点检" + version; + System.out.println(name); + // TCComponentDataset newDataset = excelData.saveAs(name); + // File file = newDataset.getTcFiles()[0].getFmsFile(); + File[] files = excelData.getFiles(""); + // 缓存文件的绝对路径 + String absolutePath = files[0].getAbsolutePath(); + System.out.println(absolutePath); + SimpleDateFormat sf = new SimpleDateFormat("yyyyMMDDHHmmss"); + String time = sf.format(new Date()); + path = files[0].getParent() + File.separator + cname + "交付物点检报告" + version + time + ".xlsx"; + System.out.println(path); + if (files[0] != null) { + alterExcel(files[0]); + } else { + MessageBox.post("点检模板下未关联对应的Excel模板", "提示", MessageBox.INFORMATION); + return; + } + TCComponentItem resultItem = MethodUtil.createItem("HS2_FirstStage", name); + // 修改数据集在服务器上的引用文件 + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset"); + String datasetName = cname + "交付物点检报告" + version; + System.out.println(datasetName); + TCComponentDataset newDataset = datasetType.create(datasetName, "", "MSExcelX"); + newDataset.setFiles(new String[] { path }, new String[] { "excel" }); + resultItem.getLatestItemRevision().add("IMAN_specification", newDataset); + // 将点检结果保存在NewStuffFolder中,并且指派到项目中 + TCComponentFolder newStuffFolder = session.getUser().getNewStuffFolder(); + newStuffFolder.add("contents", resultItem); + project.assignToProject(new TCComponent[] { resultItem }); + MessageBox.post("交付物点检完成", "提示", MessageBox.INFORMATION); + project.refresh(); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /** + * 根据点检结果修改点检Excel模板 + * + * @param file + * @throws IOException + */ + public void alterExcel(File file) { + FileInputStream fis = null; + FileOutputStream fos = null; + XSSFWorkbook workbook = null; + try { + System.out.println("deliveredTypeList"+deliveredTypeList); + System.out.println("deliveredItemRevList"+deliveredItemRevList); + System.out.println("selectedDeliveryNameList"+selectedDeliveryNameList); + fis = new FileInputStream(file); + workbook = new XSSFWorkbook(fis); + fis.close(); + XSSFSheet sheet = workbook.getSheetAt(sheetIndex); + + // XSSFRow row2 = sheet.getRow(2); + // for (int i = 0; i < row2.getLastCellNum(); i++) { + // XSSFCell cell = row2.getCell(i); + // System.out.println(cell.getStringCellValue() + "-----" + i); + // } + // 设置评审报告抬头 + setReportTitle(sheet); + // 设置评审结果 + for (int i = 7; i < spotCheckEnum.getRowNum(); i++) { + XSSFRow row = sheet.getRow(i); + XSSFCell cell = row.getCell(1); + String cellValue = cell.getStringCellValue(); + System.out.println(cellValue); + if (!cellValue.equals("") && '*' == cellValue.charAt(0)) { + cellValue = cellValue.substring(1); + } + if (selectedDeliveryNameList.contains(cellValue)) { + System.out.println(cellValue); + row.getCell(9).setCellValue("是"); + System.out.println(row.getCell(2).getStringCellValue()); + String itemType = selectedItemTypeList.get(selectedDeliveryNameList.indexOf(cellValue)); + // 不仅要存在,且要发布,才能填写完成 + System.out.println("itemType"+itemType); + if (deliveredTypeList.contains(itemType)) { + int indexOf = deliveredTypeList.indexOf(itemType); + TCComponentItemRevision deliveredItemRev = deliveredItemRevList + .get(indexOf); + deliveredTypeList.remove(indexOf); + deliveredItemRevList.remove(indexOf); + System.out.println("deliveredItemRev :"+deliveredItemRev.toString()); + if (MethodUtil.isCompReleased(deliveredItemRev)) { + row.getCell(11).setCellValue("完成"); + } else { + System.out.println("未发布的对象,未完成"); + row.getCell(12).setCellValue("未完成"); + } + } else { + System.out.println("deliveredTypeList,未完成"); + row.getCell(12).setCellValue("未完成"); + } + } else { + row.getCell(10).setCellValue("否"); + System.out.println(row.getCell(3).getStringCellValue()); + } + } + // SimpleDateFormat sf = new SimpleDateFormat("yyyyMMDDHHmmss"); + // String time = sf.format(new Date()); + // path = "c:/SpotCheckFile/项目阶段评审报告PLM(包含四个阶段)" + time + ".xlsx"; + // File desc = new File(path); + // desc.getParentFile().mkdirs(); + fos = new FileOutputStream(new File(path)); + workbook.write(fos); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + try { + if (fis != null) + fis.close(); + if (fos != null) { + fos.flush(); + fos.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + } + + /** + * 填写评审报告抬头数据 + * + * @param sheet + * @throws TCException + */ + private void setReportTitle(XSSFSheet sheet) throws TCException { + XSSFRow row = sheet.getRow(2); + row.getCell(3).setCellValue(project.getStringProperty("project_name")); + row.getCell(12).setCellValue(project.getStringProperty("project_id")); + + row = sheet.getRow(3); + row.getCell(3).setCellValue(project.getStringProperty("hs2_CusName")); + + TCComponentUser user = session.getUser(); + + String userName = user.getStringProperty("user_name"); + + row.getCell(12).setCellValue(userName); + + row = sheet.getRow(4); + row.getCell(3).setCellValue(start_date); + finish_date = dateFormate.format(new Date()); + row.getCell(12).setCellValue(finish_date); + } + + // public void test() { + // selectedDeliveryNameList.add("新产品开发建议&可行性分析报告"); + // selectedDeliveryNameList.add("项目前期收集信息确认表"); + // } +} diff --git a/src/com/connor/nbhs/plm/shentu/hs013SpotcheckDelivery/SpotCheckEnum.java b/src/com/connor/nbhs/plm/shentu/hs013SpotcheckDelivery/SpotCheckEnum.java new file mode 100644 index 0000000..5f51663 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/hs013SpotcheckDelivery/SpotCheckEnum.java @@ -0,0 +1,33 @@ +package com.connor.nbhs.plm.shentu.hs013SpotcheckDelivery; + +public enum SpotCheckEnum { + // 定义枚举的值 + ONE_F(25, "立项阶段", "APQP开发流程项目"), TWO_F(25, "产品设计开发阶段", "APQP开发流程项目"), THREE_F(41, "过程设计开发阶段", "APQP开发流程项目"), + FOUR_F(25, "产品过程确认", "APQP开发流程项目"), FIVE_F(6, "前期阶段", "简化开发流程项目"), SIX_F(27, "设计项目阶段", "简化开发流程项目"), + SEVEN_F(41, "正式项目阶段", "简化开发流程项目"), + ONE_E(15, "立项阶段", "APQP开发流程项目"), TWO_E(17, "产品设计开发阶段", "APQP开发流程项目"), THREE_E(32, "过程设计开发阶段", "APQP开发流程项目"), + FOUR_E(24, "产品过程确认", "APQP开发流程项目"), FIVE_E(6, "前期阶段", "简化开发流程项目"), SIX_E(27, "设计项目阶段", "简化开发流程项目"), + SEVEN_E(41, "正式项目阶段", "简化开发流程项目"),; + + private int rowNum; + private String phaseName; + private String projectName; + + // 构造方法(枚举的构造方法只允许private类型) + private SpotCheckEnum(int rowNum, String phaseName, String projectName) { + this.rowNum = rowNum; + this.phaseName = phaseName; + this.projectName = projectName; + } + + public int getRowNum() { + return rowNum; + } + + public String getPhaseName() { + return phaseName; + } + public String getProjectName() { + return projectName; + } +} diff --git a/src/com/connor/nbhs/plm/shentu/utils/AutoSign.java b/src/com/connor/nbhs/plm/shentu/utils/AutoSign.java new file mode 100644 index 0000000..1a15a8b --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/utils/AutoSign.java @@ -0,0 +1,127 @@ +package com.connor.nbhs.plm.shentu.utils; + +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.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; + +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/nbhs/plm/shentu/utils/ClassAttributeBean.java b/src/com/connor/nbhs/plm/shentu/utils/ClassAttributeBean.java new file mode 100644 index 0000000..ffe5e82 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/utils/ClassAttributeBean.java @@ -0,0 +1,66 @@ +package com.connor.nbhs.plm.shentu.utils; + +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/nbhs/plm/shentu/utils/ClassProperty.java b/src/com/connor/nbhs/plm/shentu/utils/ClassProperty.java new file mode 100644 index 0000000..e4b050f --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/utils/ClassProperty.java @@ -0,0 +1,42 @@ +package com.connor.nbhs.plm.shentu.utils; + +/** + * @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/nbhs/plm/shentu/utils/ClassValueBean.java b/src/com/connor/nbhs/plm/shentu/utils/ClassValueBean.java new file mode 100644 index 0000000..7162c40 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/utils/ClassValueBean.java @@ -0,0 +1,50 @@ +package com.connor.nbhs.plm.shentu.utils; + +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/nbhs/plm/shentu/utils/CodeBean.java b/src/com/connor/nbhs/plm/shentu/utils/CodeBean.java new file mode 100644 index 0000000..f359870 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/utils/CodeBean.java @@ -0,0 +1,118 @@ +package com.connor.nbhs.plm.shentu.utils; + +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/nbhs/plm/shentu/utils/CopyPropsBean.java b/src/com/connor/nbhs/plm/shentu/utils/CopyPropsBean.java new file mode 100644 index 0000000..8b60fdd --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/utils/CopyPropsBean.java @@ -0,0 +1,31 @@ +package com.connor.nbhs.plm.shentu.utils; + +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/nbhs/plm/shentu/utils/DataBaseControl.java b/src/com/connor/nbhs/plm/shentu/utils/DataBaseControl.java new file mode 100644 index 0000000..37c5658 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/utils/DataBaseControl.java @@ -0,0 +1,674 @@ +package com.connor.nbhs.plm.shentu.utils; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.Statement; +import java.text.DecimalFormat; +import java.util.HashMap; +import java.util.List; +import java.util.Vector; + +import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ; +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 = "jdbc:oracle:thin:@127.0.0.1:1521:tc12"; + private String strUrl = ""; + private String strUserName = ""; + private String strPassword = ""; + + public DataBaseControl() { + // 加载驱动 + try { + Class.forName(strDriver);// 通过反射加载驱动到内存 + } catch (ClassNotFoundException cnfe) { + cnfe.printStackTrace(); + } + } + + /** + * 构造器 + */ + 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, "HS2_SQL_Connect"); + if (stringArray != null && stringArray.length == 3) { + strUrl = "jdbc:oracle:thin:@" + stringArray[0]; + strUserName = stringArray[1]; + strPassword = stringArray[2]; + } else { + MessageBox.post("未配置HS2_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; + } + + /** + * 表更新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; + + } + + /** + * 获得流水码 + * + * @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 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(); + } + } + + // 检查分类库中是否有相同的物料 + public boolean checkValue(String[] classVals) { + // TODO Auto-generated method stub + try { + String query = "select count(*) from PICM0 where "; + StringBuilder sb = new StringBuilder(query); + for (int i = 0; i < classVals.length; i++) { + sb.append("psm"); + if (i < 9) { + sb.append("0"); + sb.append(i + 1); + } else { + sb.append(i + 1); + } + sb.append(" = '"); + sb.append(classVals[i]); + sb.append("'"); + if (i < classVals.length - 1) { + sb.append(" And "); + } + } + query = sb.toString(); + System.out.println("sql=======" + query); + ResultSet rs_get = dbQuery(query); + // System.out.println("RS_GET:"+rs_get); + int num = 0; + if (rs_get != null) { + if (rs_get.next()) { + num = rs_get.getInt(1); + System.out.println("查询到的数量为---------" + num); + } + + } + if (conn != null) { + closeDataBase(); + } + if (num != 0) { + return false; + } + } catch (Exception e) { + e.printStackTrace(); + } + return true; + } + + /** + * 取出存放在数据库中的任务及对应的交付物 + * + * @param taskNameList + * @param deliveryNameList + * @param cname + */ + + public void getTaskFileList(List taskNameList, List deliveryNameList, List itemTypeList, String cname) { + openDataBase(); + String sql = "select * from AHMC_TASK_CHECK"; + try { + pstmt = conn.prepareStatement(sql); + rs = pstmt.executeQuery(); + while (rs.next()) { + + String taskName = rs.getString(1); + String deliveryName = rs.getString(2); + String itemType = rs.getString(3); + String stage = rs.getString(4); + if(stage!=null && stage.equals(cname)) { + taskNameList.add(taskName); + + deliveryNameList.add(deliveryName); + + itemTypeList.add(itemType); + } + } + System.out.println(taskNameList); + System.out.println(deliveryNameList); + System.out.println("itemType"+itemTypeList); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + closeDataBase(); + } + + } + + /** + * 获取邮箱地址 + * + * @param taskNameList + * @param deliveryNameList + * @throws SQLException + */ + public String getEmail(String Assignor) throws SQLException { + openDataBase(); + String result = null; + String sql = "select PPA9 from PPERSON where PUSER_NAME = '" + Assignor + "'"; + System.out.println("4.12--sql:" + sql); + + try { + ResultSet rs_get = dbQuery(sql); + if (rs_get != null) { + while (rs_get.next()) { + result = rs_get.getString(1); + } + } else { + System.out.println("没有数据"); + } + } finally { + closeDataBase(); + } + + return result; + + } +} diff --git a/src/com/connor/nbhs/plm/shentu/utils/DateChooser.java b/src/com/connor/nbhs/plm/shentu/utils/DateChooser.java new file mode 100644 index 0000000..6be6e86 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/utils/DateChooser.java @@ -0,0 +1,1163 @@ +package com.connor.nbhs.plm.shentu.utils; + +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/nbhs/plm/shentu/utils/MenuBean.java b/src/com/connor/nbhs/plm/shentu/utils/MenuBean.java new file mode 100644 index 0000000..5e0d753 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/utils/MenuBean.java @@ -0,0 +1,36 @@ +package com.connor.nbhs.plm.shentu.utils; + +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/nbhs/plm/shentu/utils/MenuCodeBean.java b/src/com/connor/nbhs/plm/shentu/utils/MenuCodeBean.java new file mode 100644 index 0000000..18ef7cd --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/utils/MenuCodeBean.java @@ -0,0 +1,32 @@ +package com.connor.nbhs.plm.shentu.utils; + +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/nbhs/plm/shentu/utils/MethodUtil.java b/src/com/connor/nbhs/plm/shentu/utils/MethodUtil.java new file mode 100644 index 0000000..59bb277 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/utils/MethodUtil.java @@ -0,0 +1,289 @@ +package com.connor.nbhs.plm.shentu.utils; + +import java.util.ArrayList; +import java.util.List; + +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; + +import com.connor.nbhs.plm.shentu.BOMTransform.ItemRevInfo; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +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 MethodUtil { + + 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 getAllBomItemByBomline(TCComponentBOMLine line, List revList,DefaultMutableTreeNode top) + throws TCException { + if (line == null) { + return; + } + +// TCComponentItemRevision itemRevision = line.getItemRevision(); +// String item_id = itemRevision.getStringProperty("item_id"); +// System.out.println("material"+item_id); + int childCount = top.getChildCount(); +// boolean flag=false; +// DefaultMutableTreeNode nextNode=null; + AIFComponentContext[] contextS = line.getChildren(); + + + for(int t=0;t revList) + throws TCException { + if (line == null) { + return; + } + revList.add(line.getItemRevision()); + AIFComponentContext[] contextS = line.getChildren(); + for (AIFComponentContext context : contextS) { + TCComponentBOMLine child = (TCComponentBOMLine) context.getComponent(); + getAllBomItemByBomline(child, revList); + } + } + + /** + * 获取顶层Rev下的RevList + * + * @param rev + * @return + */ + public static List getAllBomItemByItemRev(TCComponentItemRevision rev,DefaultMutableTreeNode top) { + TCComponentBOMLine line = null; + List materialRevs = new ArrayList<>(); + try { + TCTypeService service = session.getTypeService(); + + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + TCComponentBOMWindow window = winType.create(null); + + line = window.setWindowTopLine(rev.getItem(), rev, null, null); + + ItemRevInfo childAt = (ItemRevInfo)top.getUserObject(); + TCComponentItemRevision itemRev = childAt.getItemRev(); + TCComponent[] referenceValueArray = itemRev.getTCProperty("representation_for").getReferenceValueArray(); + String stringProperty = itemRev.getStringProperty("item_id"); + for(TCComponent component:referenceValueArray) { + if(component.getStringProperty("item_id").equals(rev.getStringProperty("item_id"))) { + materialRevs.add(rev); + getAllBomItemByBomline(line, materialRevs,top); +// flag=true; +// nextNode=node; + } + } + +// int childCount = top.getChildCount(); +// boolean flag=false; +// DefaultMutableTreeNode nextNode=null; +// for(int t=0;t getAllBomItemByItemRev(TCComponentItemRevision rev) { + TCComponentBOMLine line = null; + List revList = new ArrayList<>(); + try { + TCTypeService service = session.getTypeService(); + + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + TCComponentBOMWindow window = winType.create(null); + + line = window.setWindowTopLine(rev.getItem(), rev, null, null); + getAllBomItemByBomline(line, revList); + + window.close(); + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return revList; + } + + /** + * 获取首选项里的值 + * + * @param prefName + * @return + */ + public static String[] getPrefStrArray(String prefName) { + String[] values = service.getStringValues(prefName); + return values; + } + + /** + * 根据Item对象类型创建Item + * + * @param objectType + * @return + * @throws TCException + */ + public static TCComponentItem createItem(String objectType) throws TCException { + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent(objectType); + if (typeComponent == null) { + MessageBox.post("系統中不存在该交付物对应的对象类型" + objectType + "请在BMIDE中创建后再尝试", "提示", MessageBox.INFORMATION); + return null; + } + String newID = typeComponent.getNewID(); + String newRev = typeComponent.getNewRev(null); + TCComponentItem newItem = typeComponent.create(newID, newRev, objectType, "", null, null); + return newItem; + } + + /** + * 根据Item对象类型和名称创建对应的Item对象 + * + * @param objectType + * @param itemName + * @return + * @throws TCException + */ + public static TCComponentItem createItem(String objectType, String itemName) throws TCException { + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent(objectType); + if (typeComponent == null) { + MessageBox.post("系統中不存在该对象对应的类型" + objectType + "请在BMIDE中创建后再尝试", "提示", MessageBox.INFORMATION); + return null; + } + String newID = typeComponent.getNewID(); + String newRev = typeComponent.getNewRev(null); + TCComponentItem newItem = typeComponent.create(newID, newRev, objectType, itemName, null, null); + return newItem; + } + + /** + * 检查对象是否已经发布 + * + * @param comp + * @return + * @throws TCException + */ + public static boolean isCompReleased(TCComponent comp) throws TCException { + TCComponent[] comps = comp.getRelatedComponents("release_status_list"); + if (comps != null && comps.length > 0) { + return true; + } + return false; + } + + public static boolean isCompReleased(List compList) throws TCException { + for (TCComponent comp : compList) { + if (!isCompReleased(comp)) { + return false; + } + } + return true; + } + + /** + * 将Rev的属性值拼接返回 + * + * @param materialRev + * @return + * @throws TCException + */ + public static String getRevTableValue(TCComponentItemRevision materialRev) throws TCException { + return materialRev.getStringProperty("item_id") + "-" + materialRev.getStringProperty("object_name") + "-" + + materialRev.getStringProperty("hs2_materialcolor"); + } + + public static List getStringList(List bomlineList) { + List stringList = new ArrayList(); + for (TCComponentBOMLine bl : bomlineList) { + String blString = bl.toString(); + stringList.add(blString.substring(0, blString.indexOf(";"))); + } + return stringList; + } + +} diff --git a/src/com/connor/nbhs/plm/shentu/utils/PartBean.java b/src/com/connor/nbhs/plm/shentu/utils/PartBean.java new file mode 100644 index 0000000..607a46c --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/utils/PartBean.java @@ -0,0 +1,31 @@ +package com.connor.nbhs.plm.shentu.utils; + +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/nbhs/plm/shentu/utils/ProgressBar.java b/src/com/connor/nbhs/plm/shentu/utils/ProgressBar.java new file mode 100644 index 0000000..379e6a2 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/utils/ProgressBar.java @@ -0,0 +1,176 @@ +/** + * @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.nbhs.plm.shentu.utils; + +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; + } + }); + System.out.println("启动进度条"); + 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/nbhs/plm/shentu/utils/ProgressBarThread.java b/src/com/connor/nbhs/plm/shentu/utils/ProgressBarThread.java new file mode 100644 index 0000000..286f978 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/utils/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.nbhs.plm.shentu.utils; + +/** + * @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/nbhs/plm/shentu/utils/PropBean.java b/src/com/connor/nbhs/plm/shentu/utils/PropBean.java new file mode 100644 index 0000000..e2c4bd7 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/utils/PropBean.java @@ -0,0 +1,108 @@ +package com.connor.nbhs.plm.shentu.utils; + +/** + * 单个属性 + * + * @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/nbhs/plm/shentu/utils/RealBean.java b/src/com/connor/nbhs/plm/shentu/utils/RealBean.java new file mode 100644 index 0000000..baf99db --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/utils/RealBean.java @@ -0,0 +1,47 @@ +package com.connor.nbhs.plm.shentu.utils; + +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/nbhs/plm/shentu/utils/SoaServerUtil.java b/src/com/connor/nbhs/plm/shentu/utils/SoaServerUtil.java new file mode 100644 index 0000000..5292417 --- /dev/null +++ b/src/com/connor/nbhs/plm/shentu/utils/SoaServerUtil.java @@ -0,0 +1,342 @@ +package com.connor.nbhs.plm.shentu.utils; + +import java.util.List; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.client.Options; +import org.apache.axis2.client.ServiceClient; +import org.apache.axis2.transport.http.HTTPConstants; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCComponentUserType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; + +import net.sf.json.JSONArray; + +/** + * 发送分类Util类 + * @author 61666 + * + */ +public class SoaServerUtil { + + public static void sendToClass(String wsoPUID, String classID, String json, String url) { + // AbstractAIFApplication app; + // app=AIFUtility.getCurrentApplication(); + // TCSession session; + // session=(TCSession) app.getSession(); + // TCPreferenceService preferenceService; + // preferenceService=session.getPreferenceService(); + // String account=preferenceService.getStringValue("Autocode_PriverUser_ID"); + // String url; + // url = preferenceService.getStringValue("Autocode_SendClassServer_URL"); + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + // url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("SendToClass"); + sc.setOptions(opts); + + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("SendToClass", omNs); + OMElement value = fac.createOMElement("wsoPuiid", omNs); + value.setText(wsoPUID); + OMElement value1 = fac.createOMElement("classID", omNs); + value1.setText(classID); + OMElement value2 = fac.createOMElement("JsonContainer", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + value2.setText(json); + + method.addChild(value); + method.addChild(value1); + method.addChild(value2); + + OMElement res = sc.sendReceive(method); + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { + e.printStackTrace(); + } + + } + + public static String updateToClass(String wsoPUID, String classID, String json, String url, String icoUid) { + // AbstractAIFApplication app; + // app=AIFUtility.getCurrentApplication(); + // TCSession session; + // session=(TCSession) app.getSession(); + // TCPreferenceService preferenceService; + // preferenceService=session.getPreferenceService(); + // String account=preferenceService.getStringValue("Autocode_PriverUser_ID"); + // String url; + // url = preferenceService.getStringValue("Autocode_SendClassServer_URL"); + String reMsgString=""; + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + // url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("UpdateToClass"); + sc.setOptions(opts); + + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("UpdateToClass", omNs); + OMElement value = fac.createOMElement("wsoPuiid", omNs); + value.setText(wsoPUID); + OMElement value1 = fac.createOMElement("classID", omNs); + value1.setText(classID); + OMElement value2 = fac.createOMElement("JsonContainer", omNs); + + OMElement value3 = fac.createOMElement("icoPUID", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + value2.setText(json); + value3.setText(icoUid); + + method.addChild(value); + method.addChild(value1); + method.addChild(value2); + method.addChild(value3); + OMElement res = sc.sendReceive(method); + reMsgString=res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + + } catch (AxisFault e) { + e.printStackTrace(); + } + + return reMsgString; + + } + public static void deleteAndSendToClass(String icoPUID,String wsoPUID, String classID, String json, String url) { + // AbstractAIFApplication app; + // app=AIFUtility.getCurrentApplication(); + // TCSession session; + // session=(TCSession) app.getSession(); + // TCPreferenceService preferenceService; + // preferenceService=session.getPreferenceService(); + // String account=preferenceService.getStringValue("Autocode_PriverUser_ID"); + // String url; + // url = preferenceService.getStringValue("Autocode_SendClassServer_URL"); + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + // url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("SendToClass"); + sc.setOptions(opts); + + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("editToClass", omNs); + OMElement icovalue = fac.createOMElement("icoPUID", omNs); + icovalue.setText(icoPUID); + OMElement value = fac.createOMElement("wsoPuiid", omNs); + value.setText(wsoPUID); + OMElement value1 = fac.createOMElement("classID", omNs); + value1.setText(classID); + OMElement value2 = fac.createOMElement("JsonContainer", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + value2.setText(json); + method.addChild(icovalue); + method.addChild(value); + method.addChild(value1); + method.addChild(value2); + + OMElement res = sc.sendReceive(method); + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { + e.printStackTrace(); + } + + } + // public static void main(String[] args) { + // deleteClass("1111", ""); + // } + // 分类库中删除临时物料 + public static void deleteClass(String icoPUID, String url) { + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + // url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL";//TODO + // 首选项Autocode_SendClassServer_URL + // url = preferenceService.getStringValue("Autocode_SendClassServer_URL");//TODO + // 首选项Autocode_SendClassServer_URL + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("DeleteClass"); + opts.setProperty(HTTPConstants.CHUNKED, "false"); + sc.setOptions(opts); + + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("DeleteClass", omNs); + OMElement value = fac.createOMElement("icoPuid", omNs); + value.setText(icoPUID); + // OMElement value1 = fac.createOMElement("classID", omNs); + //// value1.setText(classID); + // OMElement value2 = fac.createOMElement("JsonContainer", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + // value2.setText(json); + + method.addChild(value); + // method.addChild(value1); + // method.addChild(value2); + + OMElement res = sc.sendReceive(method); + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { + e.printStackTrace(); + } + + } + + public static String objectToJson(List props) { + String str = null; + try { + JSONArray json = JSONArray.fromObject(props);// 将java对象转换为json对象 + str = json.toString();// 将json对象转换为字符串 + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("JSON =>" + str); + return str; + } + + public static void grantReadPrivilege(TCSession tcSession, TCComponent tccomponent) { + AbstractAIFApplication app; + app = AIFUtility.getCurrentApplication(); + TCSession session; + session = (TCSession) app.getSession(); + TCPreferenceService preferenceService; + preferenceService = session.getPreferenceService(); + String account = preferenceService.getStringValue("Autocode_PriverUser_ID"); + try { + 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(); + setByPass(true,tcSession); + accessControlService.grantPrivilege(tempItem, user, as2); + setByPass(false,tcSession); + + setByPass(true,tcSession); + accessControlService.grantPrivilege(tccomponent, user, as2); + setByPass(false,tcSession); + } else { + setByPass(true,tcSession); + accessControlService.grantPrivilege(tccomponent, user, as2); + setByPass(false,tcSession); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public static void openByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = ""; + userservice.call("Connor_set_bypass", obj); + } + + public static void closeByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = ""; + userservice.call("Connor_close_bypass", obj); + +// session.getUserService().call("Connor_set_bypass", new Object[]{});//开bypass +// session.getUserService().call("Connor_close_bypass", new Object[]{});//关bypass + } + public static void setByPass(boolean val,TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + if (userservice == null) { + userservice = session.getUserService(); + } + Object[] obj = new Object[1]; + obj[0] = "origin"; + if (val) { +// userservice.call("ORIGIN_set_bypass", obj); + userservice.call("Connor_set_bypass", obj); + } else { +// userservice.call("ORIGIN_close_bypass", obj); + userservice.call("Connor_close_bypass", obj); + } + } + +} diff --git a/src/com/connor/renben/process/plm/message/Message.properties b/src/com/connor/renben/process/plm/message/Message.properties new file mode 100644 index 0000000..f2fdd2f --- /dev/null +++ b/src/com/connor/renben/process/plm/message/Message.properties @@ -0,0 +1,1594 @@ +xljid_display.TITLE=New Item ID +bbid_display.TITLE=Revision ID +mc_display.TITLE=Name +jlzjid_display.TITLE=Old Item ID +qd_display.TITLE=Sure +qx_display.TITLE=Cancel +cxdr_display.TITLE=Re-import +hbgykdc_display.TITLE=Export horizontal plate process card +sbgykdc_display.TITLE=Export vertical process card +zpgykdc_display.TITLE=Export of assembly process card +zyjzsdc_display.TITLE=Operation reference book export +xzdctp_display.TITLE=Select export picture +sc08_display.TITLE=Delete +lx_display.TITLE=Type +dw_display.TITLE=Unit +scgc_display.TITLE=Production plant +xljxx_display.TITLE=New Item Information +jy_display.TITLE=Based_on +lzjxx_display.TITLE=Item Information +sx_display.TITLE=Attribute +sxsj_display.TITLE=Refresh +ssckzjh_display.TITLE=Pilot production control plan +sckzjh_display.TITLE=Production control plan +dc_display.TITLE=Export +xzlj_display.TITLE=Select path +xzwjj_display.TITLE=Select Folder: +pldctz_display.TITLE=Batch export drawings +dcd_display.TITLE=Export to: +ll_display.TITLE=Browse... +txkzjh_display.TITLE=Fill in control plan +bc_display.TITLE=Save +CP/kzjh_display.TITLE=CONTROL PLAN/Control plan +yj_display.TITLE=Sample +ssc_display.TITLE=Trial production +sc_display.TITLE=Production +kzjhbh_display.TITLE=Control plan number +zylxrbzr_display.TITLE=Main contact / Preparer +zylxrdhbzrdh_display.TITLE=Main contact telephone number / Preparer telephone number +rq(bz)_display.TITLE=Date (Preparation) +rq(xd)_display.TITLE=Date (Revised) +SORhmmc_display.TITLE=SOR Number / Name +ljhzzbb_display.TITLE=Part number / Final version +hxxz_display.TITLE=Core group +gkgcpzrq_display.TITLE=Customer engineering approval / Date +khtzbh_display.TITLE=Customer drawing number +ljmcms_display.TITLE=Item name / Description +gfgcpzrq_display.TITLE=Supplier / Factory approval / Date +gkzlpzrq_display.TITLE=Customer quality approval / Date +gfgc_display.TITLE=Supplier / Factory +gfdh_display.TITLE=Supplier code +gkpzrq_display.TITLE=Customer approval / Date +qtpzrq_display.TITLE=Other approval / Date +tjh_display.TITLE=Add rows +tjdh_display.TITLE=Add multiple lines +tjhbh_display.TITLE=Add merge row +tjdghbh_display.TITLE=Add multiple merged rows +tjgx_display.TITLE=Add procedure +hbh_display.TITLE=Merge lines +cfhbdyg_display.TITLE=Split and merge cells +yczh_display.TITLE=Remove entire row +sxxzl_display.TITLE=Zoom out the selected column +qxsxxzl_display.TITLE=Cancel narrowing selected column +txbz_display.TITLE=Filling standard +dcnbkzjh_display.TITLE=Export internal control plan +fqsh_display.TITLE=Initiate audit +kzjhk_display.TITLE=Control plan library +ck_display.TITLE=Lexicon +cxjz_display.TITLE=Reload +qksj_display.TITLE=Clear all data +cjgy_display.TITLE=Create technology +xh_display.TITLE=Model +cpmc_display.TITLE=Product name +cxyj_display.TITLE=Forming press +khmc_display.TITLE=Customer name +khth_display.TITLE=Customer drawing number +zxyj_display.TITLE=Integral press +khxmh_display.TITLE=Customer project number +clbz_display.TITLE=Material standard +sjry_display.TITLE=Designers +cjrq_display.TITLE=Creation date +cx06_display.TITLE=Query +cph06_display.TITLE=Product ID +gybh06_display.TITLE=Process number +mc06_display.TITLE=Name +gyfg08_display.TITLE=Process division +xzz08_display.TITLE=Selection value: +yhm08_display.TITLE=User name: +ss08_display.TITLE=Search +txPFMEA10_display.TITLE=Fill in PFMEA +qzsxmsjhgfx10_display.TITLE=Potential failure mode and consequence analysis +gsmc10_display.TITLE=Corporate name +xm10_display.TITLE=Project +PFMEAIDbh10_display.TITLE=PFMEA ID number +zzdz10_display.TITLE=Manufacturing address +PFMEAksrq10_display.TITLE=PFMEA start date +PFMEAxdrq10_display.TITLE=PFMEA revision date +gczz10_display.TITLE=Process responsibilities +gkmc10_display.TITLE=Customer name +bmjb10_display.TITLE=Security level +cxpt10_display.TITLE=Model / Platform +kzntd10_display.TITLE=Cross functional team +ll10_display.TITLE=PFMEA experience database +wc10_display.TITLE=Complete +dcPFMEA10_display.TITLE=Export PFMEA +PFMEAc10_display.TITLE=PFMEA Library +xztsfh10_display.TITLE=Select special symbol +cz10_display.TITLE=Search +fzdh10_display.TITLE=Copy multiple lines +crhs10_display.TITLE=Insert rows +ych12_display.TITLE=Remove row +tjjd12_display.TITLE=Add node +ycjd12_display.TITLE=Remove node +gxjd12_display.TITLE=Update node +jdmc12_display.TITLE=Node name +jdID12_display.TITLE=Node ID +xztsfh12_display.TITLE=Select special symbol +bzgy17_display.TITLE=Packaging technology +cpdh17_display.TITLE=Product code +cpmc17_display.TITLE=Product name +yhth17_display.TITLE=User drawing number +chmc17_display.TITLE=Customer name +jszg17_display.TITLE=Technical director +sjxzljtp17_display.TITLE=Double click to select the part image +bzfs17_display.TITLE=Packing method +jyfs17_display.TITLE=Oil immersion method +mxsl17_display.TITLE=Quantity per case +jx17_display.TITLE=Pieces / case +wzxm17_display.TITLE=Name of outer carton +bzde17_display.TITLE=Packaging quota +xs17_display.TITLE=Case / hour +nldm17_display.TITLE=Name of nylon bag +cpdz17_display.TITLE=Unit weight of finished product +xsm17_display.TITLE=Blister name +zxmz17_display.TITLE=Gross weight of full container +wxbq17_display.TITLE=Outer box label +rktp17_display.TITLE=Storage tray +xc17_display.TITLE=Box / layer +ct17_display.TITLE=Floor / tray +sjxztp17_display.TITLE=Double click to select Picture +bzsm17_display.TITLE=Step description +zysx17_display.TITLE=Matters needing attention +bzry17_display.TITLE=Staffing +pzry17_display.TITLE=Approved personnel +xgrq17_display.TITLE=Modification date +bz17_display.TITLE=Remarks +ysbzlx17_display.TITLE=Type of transport package +dbfs17_display.TITLE=Packing method +tpgg17_display.TITLE=Tray specification +jgfs17_display.TITLE=Reinforcement method +sjxzdbt17_display.TITLE=Double click to select packing map +dybzxx17_display.TITLE=Unit packaging information +ysbzxx17_display.TITLE=Transport package information +dh17_display.TITLE=Code-named +cckcg17_display.TITLE=Length * width * height (CM) +hd17_display.TITLE=Thickness (MM) +cl17_display.TITLE=Material +gg17_display.TITLE=Specifications +ks17_display.TITLE=Number of holes +cp17_display.TITLE=Product +xgdj18_display.TITLE=Revision level +cxnd18_display.TITLE=Model / year +bz18_display.TITLE=Tagging +ycbz18_display.TITLE=Remove dimension +kzjhdc19_display.TITLE=Control plan export +gx19_display.TITLE=Procedure +cx19_display.TITLE=Query +kzjhwjmc19_display.TITLE=Name of control plan document +drkzjh20_display.TITLE=Import control plan +xzkzjhwj20_display.TITLE=Select control plan file +qcwcbj21_display.TITLE=Clear completion flag +xzgytz23_display.TITLE=Select process drawings +gytz23_display.TITLE=Process drawings: +xz24_display.TITLE=Select +kzjh24_display.TITLE=Control plan +yqrq25_display.TITLE=Overdue date +PDMEAtj25_display.TITLE=PFMEA statistics +dcbb25_display.TITLE=Export report +gb25_display.TITLE=Close +jcfxwtd27_display.TITLE=Inspection and analysis order +wtdbh27_display.TITLE=Relegated bill number +jclx27_display.TITLE=Testing type +jcbm27_display.TITLE=Testing department +wtdw27_display.TITLE=Entrusted unit +wtr27_display.TITLE=Entrusted person +wtdz27_display.TITLE=Entrusted address +wtrlxfs27_display.TITLE=Contact information of client +wtrq27_display.TITLE=Date of commission +xwwcsj27_display.TITLE=Expected completion time +jcyt27_display.TITLE=Testing purpose +jcjg27_display.TITLE=Testing result +xmdj27_display.TITLE=Project level +khdj27_display.TITLE=Customer level +xmbh27_display.TITLE=Project number +yyly27_display.TITLE=Application area +xmmc27_display.TITLE=Project name +cph27_display.TITLE=Product ID +wlh27_display.TITLE=Material number +cplx27_display.TITLE=Product type +scdw27_display.TITLE=Production unit +ypsl27_display.TITLE=Number of samples +ypzt27_display.TITLE=Sample status +wldh27_display.TITLE=Logistics order No +ypbh27_display.TITLE=Sample number +ypclfs27_display.TITLE=Sample handling method +sybw27_display.TITLE=Application site +syhj27_display.TITLE=Use environment +gzzh27_display.TITLE=Working load +zhlx27_display.TITLE=Load type +xzfs27_display.TITLE=Rotation way +xzsd27_display.TITLE=Rotation speed +gzwd27_display.TITLE=Working temperature +xzwtnr27_display.TITLE=Select delegation content +bz27_display.TITLE=Remarks +ypydxc27_display.TITLE=The sample has arrived at the scene +sysj27_display.TITLE=Sample receiving time +syr27_display.TITLE=Sample receiver +ypshjg27_display.TITLE=Sample audit results +yqwcsj27_display.TITLE=Expected completion time +thyy27_display.TITLE=Reason for return +jcrwzb27_display.TITLE=Host of testing task +jcrwxb27_display.TITLE=Testing task jointly +jhkssj27_display.TITLE=Planned start time +jhwcsj27_display.TITLE=Planned completion time +djdywtd27_display.TITLE=Click Print Order +djdyypbs27_display.TITLE=Click to print sample identification +sjwcsj27_display.TITLE=Actual completion time +jcjgsm27_display.TITLE=Description of test results +ypcz27_display.TITLE=Sample disposal +cywz27_display.TITLE=Sample storage location +shsj27_display.TITLE=Audit time +shy27_display.TITLE=Auditor +shjg27_display.TITLE=Audit results +wtxx27_display.TITLE=Delegation information +clfx27_display.TITLE=Material analysis +jljc27_display.TITLE=Metrological testing +wtnr27_display.TITLE=Content of entrustment +zygyk28_display.TITLE=Operation process card +gsmc28_display.TITLE=Corporate name +ljdh28_display.TITLE=Part number +sbxh28_display.TITLE=Product name +bgx28_display.TITLE=This process +sbmc28_display.TITLE=Equipment name +gzmx28_display.TITLE=Tooling details +jgcs28_display.TITLE=Processing parameters +cptxkzyq28_display.TITLE=Product characteristic control requirements +zpgyk29_display.TITLE=Assembly process card +gsmc29_display.TITLE=Corporate name +ljdh29_display.TITLE=Part code +sbxh29_display.TITLE=Equipment model +zyjzs30_display.TITLE=Operation standard +xzdclj31_display.TITLE=Select export path +wjmc31_display.TITLE=File name +jyjzs33_display.TITLE=Inspection standard +bzbz34_display.TITLE=Packaging standard +ljh34_display.TITLE=Part number +ljmc34_display.TITLE=Part name +gys34_display.TITLE=Supplier +gysdh34_display.TITLE=Supplier Code +syzcdmmc34_display.TITLE=Applicable assembly code / name +ljdw(tg)34_display.TITLE=Parts unit (set / piece) +ljgg34_display.TITLE=Part specification (mm) +ljzl34_display.TITLE=Weight of parts (kg) +bzbzclfhdjyms34_display.TITLE=Brief description of packaging, packaging materials, protection, etc +bqgshwz34_display.TITLE=Label format and location +zt35_display.TITLE=Status +wtdsh35_display.TITLE=Authorization form approval +gzfp35_display.TITLE=Assignment of work +scjl35_display.TITLE=Upload record +wtrq35_display.TITLE=Date of commission +wtdh35_display.TITLE=Odd Numbers of commission +wtdw35_display.TITLE=entrusted unit +jclx35_display.TITLE=Test type +xmdj35_display.TITLE=Project level +ycwcrq35_display.TITLE=Expected completion date +jhwcrq35_display.TITLE=Planned completion date +zbry35_display.TITLE=Sponsor +lcjs35_display.TITLE=Process monitoring +dqzt35_display.TITLE=Current status +wtdhypsh35_display.TITLE=Order and sample audit +gzfp35_display.TITLE=Assignment of work +scjg35_display.TITLE=Upload results +sywtd41_display.TITLE=Test order +wtdbh41_display.TITLE=Order No: +scdw41_display.TITLE=Production unit +ccxh41_display.TITLE=Bearing model +sych41_display.TITLE=Use occasion +xmmc41_display.TITLE=entry name +xmbh41_display.TITLE=Project number +xmdj41_display.TITLE=Project level +wtsylx41_display.TITLE=Type of commission test +yzsy41_display.TITLE=Verification test +tzxxsy41_display.TITLE=Special new type test +khyq41_display.TITLE=Customer requirements +sybj41_display.TITLE=Background of the experiment +symd41_display.TITLE=Purpose of the experiment +sygfsjry41_display.TITLE=Test specification (designer) +yjgsyry41_display.TITLE=handed over to the tester +qtsyyq41_display.TITLE=Other test requirements +wtr41_display.TITLE=client +lxfs41_display.TITLE=contact information +gsdz41_display.TITLE=Company address +gscz41_display.TITLE=Company fax +shr41_display.TITLE=Reviewer +shrq41_display.TITLE=Audit date +zjlpz41_display.TITLE=Approved by general manager +sywtftx41_display.TITLE=Fill in by test client +psjl41_display.TITLE=Review record +jhkssj41_display.TITLE=Planned start time +jhjssj41_display.TITLE=Planned end time +syfzr41_display.TITLE=Person in charge of the test +lxdh41_display.TITLE=contact number +psrq41_display.TITLE=Review / date +pzrq41_display.TITLE=Approval / date +swtftx41_display.TITLE=Fill in by client +bz41_display.TITLE=Remarks +gzsjtd41_display.TITLE=Tooling design team +xzscgztz41_display.TITLE=Select upload tooling drawing +qxzyscdwj41_display.TITLE=Please select the file to upload +qd41_display.TITLE=determine +gzsjwcrq141_display.TITLE=Tooling design completion date +gzsj141_display.TITLE=Tooling design +gzdhrq41_display.TITLE=Tooling arrival date +gzsjrq41_display.TITLE=Tooling inspection date +gzsjwcrq41_display.TITLE=Tooling inspection completion date +gzjcbgbh41_display.TITLE=Tooling test report (record) No +gzsj41_display.TITLE=Tooling inspection +ypdyrq41_display.TITLE=Sample arrival date +syqypjcwcrq41_display.TITLE=Sample test completion date before test +syqypjcbgbh41_display.TITLE=Sample test report (record) No. before test +syksrq41_display.TITLE=Test start date +sywcrq41_display.TITLE=Test completion date +syss41_display.TITLE=Test implementation +syhypjcwcrq41_display.TITLE=Completion date of sample test after test +syhypjcbg41_display.TITLE=Sample test report (record) No. after test +ypjc41_display.TITLE=Sample testing +xzscsybg41_display.TITLE=Select upload test report +sywcrq241_display.TITLE=Test completion date +sybgbh41_display.TITLE=Test report no +sybg241_display.TITLE=Test report +sywtd241_display.TITLE=Test order +sykxljap41_display.TITLE=The test is feasible,and arrange immediately +sybkx41_display.TITLE=The test is not feasible +zybcfjywwsy41_display.TITLE=The resources are not enough, suggest to subcontract the test +qijy241_display.TITLE=Other suggestions +btxxbnwk41_display.TITLE=Required item cannot be empty! +gzcg41_display.TITLE=Tooling procurement +xqsp41_display.TITLE=Requirement approval +fxwtd40_display.TITLE=Analysis order +CEAwtd40_display.TITLE=CAE order +wtdbh40_display.TITLE=Order No: +kemc40_display.TITLE=Customer name +xmsstd40_display.TITLE=Project team +xmmc40_display.TITLE=Project name +xmjl40_display.TITLE=Project manager +xmdj40_display.TITLE=Project level +sjbsstd40_display.TITLE=Team of design department +xmbh40_display.TITLE=Project number +sjfzr40_display.TITLE=Design director +xmlx40_display.TITLE=Project type +qwwcsj40_display.TITLE=Expected completion time +jbxx40_display.TITLE=1.Basic Information +scfxry40_display.TITLE=Last analyst +scbgsj40_display.TITLE=Last report time +ggd40_display.TITLE=Change point +ggyy40_display.TITLE=Reason for change +srzl40_display.TITLE=2.Input information +cjtd40_display.TITLE=Undertaking team +xmwtsj40_display.TITLE=Project entrustment time +cjr40_display.TITLE=Undertaker +xmggcs40_display.TITLE=Number of project changes +xbr40_display.TITLE=Co sponsor +jhkssj40_display.TITLE=Planned start time +Romaxjf40_display.TITLE=Romax integral +jsxqts40_display.TITLE=Calculate demand days +yxyjf40_display.TITLE=Finite element integration +jswcsj40_display.TITLE=Calculate completion time +xmcjxx40_display.TITLE=3. Project undertaking information +bghjgmc40_display.TITLE=Report or result name +bgbh40_display.TITLE=Report no +bghjgscsj40_display.TITLE=Report or result upload time +bghjgfk40_display.TITLE=4.Report or result feedback +jdr40_display.TITLE=Check reader +jdsj40_display.TITLE=Check reading time +jdjg40_display.TITLE=Check reading results +thyy40_display.TITLE=Reason for return +bghjgjd40_display.TITLE=5.Report or result check +khmc40_display.TITLE=Customer name +xmbssty40_display.TITLE=Team of project department +sybw40_display.TITLE=Application site +srzl40_display.TITLE=2.Input information +bxqrbgxxx40_display.TITLE=Information must be confirmed and checked +jsscxm40_display.TITLE=Calculate output items +kgxxx40_display.TITLE=Checkable information +ydndqjddjgzwd40_display.TITLE=Kinematic viscosity, cleanliness grade, working temperature +EPtjj40_display.TITLE=EP additive +ysr40_display.TITLE=Pre judge +yssj40_display.TITLE=Preliminary hearing time +ysjg40_display.TITLE=Preliminary results +zbdzys40_display.TITLE=1.Pre-review by team leader +wtdbh240_display.TITLE=Order No +jhwcsj40_display.TITLE=Planned completion time +xmcjxx240_display.TITLE=2.Project undertaking information +jsfxjm40_display.TITLE=Computational analysis modeling +bczlsj40_display.TITLE=Supplementary information time +zyss40_display.TITLE=3.Work implementation +bghjgfk240_display.TITLE=4.Report or result feedback +bghjgjd240_display.TITLE=5.Report or result check +CAEfxxqwtd40_display.TITLE=CAE analysis demand order +jsfxtdcjd40_display.TITLE=Calculation and analysis team acceptance order +ggxmwtd40_display.TITLE=Change project order +tk_display.TITLE=Picture library + + +ljgybh04_display.TITLE=Part / process number +gcmc04_display.TITLE=Process name +jqsbgzjj04_display.TITLE=Machine, equipment, tooling, fixture +smjyzyzb04_display.TITLE=Initial and final inspection / operation preparation +bh04_display.TITLE=Number +cp04_display.TITLE=product +gc04_display.TITLE=process +tstxfl04_display.TITLE=Classification of special characteristics +cpgcgfgc04_display.TITLE=Product / process / specification / tolerance +pgclff04_display.TITLE=Evaluation / measurement method +rl04_display.TITLE=capacity +pl04_display.TITLE=frequency +kzff04_display.TITLE=Control method +fyjh04_display.TITLE=Response plan +tsfhwz04_display.TITLE=Special symbol location +sfwc04_display.TITLE=Complete +fjdID04_display.TITLE=Parent node ID +tszfszwz04_display.TITLE=Location of special characters +xh04_display.TITLE=Serial number +z04_display.TITLE=value +mc04_display.TITLE=name +gysjfdygc34_display.TITLE=Composition of supplier delivery unit +yjbz34_display.TITLE=Primary packaging +ejbz34_display.TITLE=Secondary packaging +sjbz34_display.TITLE=Tertiary packaging + + +wxzcpdxqcxxz02_display.TITLE=Product object is not selected, please Reselect! +qxzzcdxhcj02_display.TITLE=Please select the assembly object and create it +gy02_display.TITLE=Technology +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= + diff --git a/src/com/connor/renben/process/plm/message/Message_zh_CN.properties b/src/com/connor/renben/process/plm/message/Message_zh_CN.properties new file mode 100644 index 0000000..3188761 --- /dev/null +++ b/src/com/connor/renben/process/plm/message/Message_zh_CN.properties @@ -0,0 +1,1173 @@ +xljid_display.TITLE=\u5DE5\u5E8FID +bbid_display.TITLE=\u7248\u672c\u0049\u0044 +mc_display.TITLE=\u540d\u79f0 +jlzjid_display.TITLE=\u65e7\u96f6\u7ec4\u4ef6\u0049\u0044 +qd_display.TITLE=\u786e\u5b9a +qx_display.TITLE=\u53d6\u6d88 +bc_display.TITLE=\u4FDD\u5B58 +cxdr_display.TITLE=\u91CD\u65B0\u5BFC\u5165 +hbgykdc_display.TITLE=\u6A2A\u7248\u5DE5\u827A\u5361\u5BFC\u51FA +sbgykdc_display.TITLE=\u7AD6\u7248\u5DE5\u827A\u5361\u5BFC\u51FA +zpgykdc_display.TITLE=\u88C5\u914D\u5DE5\u827A\u5361\u5BFC\u51FA +zyjzsdc_display.TITLE=\u4F5C\u4E1A\u57FA\u51C6\u4E66\u5BFC\u51FA +xzdctp_display.TITLE=\u9009\u62E9\u5BFC\u51FA\u56FE\u7247 +sc08_display.TITLE=\u5220\u9664 +lx_display.TITLE=\u7c7b\u578b +dw_display.TITLE=\u5355\u4f4d +scgc_display.TITLE=\u751F\u4EA7\u5DE5\u5382 +xljxx_display.TITLE=\u65b0\u96f6\u4ef6\u4fe1\u606f +jy_display.TITLE=\u57fa\u4e8e +lzjxx_display.TITLE=\u96f6\u7ec4\u4ef6\u4fe1\u606f +sx_display.TITLE=\u5c5e\u6027 +sxsj_display.TITLE=\u5237\u65B0 +ssckzjh_display.TITLE=\u8bd5\u751f\u4ea7\u63a7\u5236\u8ba1\u5212 +sckzjh_display.TITLE=\u751f\u4ea7\u63a7\u5236\u8ba1\u5212 +dc_display.TITLE=\u5bfc\u51fa +xzlj_display.TITLE=\u9009\u62E9\u8DEF\u5F84 +xzwjj_display.TITLE=\u9009\u62e9\u6587\u4ef6\u5939\u003a +pldctz_display.TITLE=\u6279\u91cf\u5bfc\u51fa\u56fe\u7eb8 +dcd_display.TITLE=\u5BFC\u51FA\u5230\uFF1A +ll_display.TITLE=\u6D4F\u89C8... +txkzjh_display.TITLE=\u586B\u5199\u63A7\u5236\u8BA1\u5212 +CP/kzjh_display.TITLE=\u0043\u004f\u004e\u0054\u0052\u004f\u004c\u0020\u0050\u004c\u0041\u004e\u002f\u63a7\u5236\u8ba1\u5212 +yj_display.TITLE=\u6837\u4EF6 +ssc_display.TITLE=\u8BD5\u751F\u4EA7 +sc_display.TITLE=\u751F\u4EA7 +kzjhbh_display.TITLE=\u63A7\u5236\u8BA1\u5212\u7F16\u53F7 +zylxrbzr_display.TITLE=\u4E3B\u8981\u8054\u7CFB\u4EBA/\u7F16\u5236\u4EBA +zylxrdhbzrdh_display.TITLE=\u4E3B\u8981\u8054\u7CFB\u4EBA\u7535\u8BDD/\u7F16\u5236\u4EBA\u7535\u8BDD +rq(bz)_display.TITLE=\u65E5\u671F\uFF08\u7F16\u5236\uFF09 +rq(xd)_display.TITLE=\u65E5\u671F\uFF08\u4FEE\u8BA2\uFF09 +SORhmmc_display.TITLE=SOR\u53F7\u7801/\u540D\u79F0 +ljhzzbb_display.TITLE=\u96F6\u4EF6\u53F7/\u6700\u7EC8\u7248\u672C +hxxz_display.TITLE=\u6838\u5FC3\u5C0F\u7EC4 +gkgcpzrq_display.TITLE=\u987E\u5BA2\u5DE5\u7A0B\u6279\u51C6/\u65E5\u671F +khtzbh_display.TITLE=\u5BA2\u6237\u56FE\u7EB8\u7F16\u53F7 +ljmcms_display.TITLE=\u96F6\u4EF6\u540D\u79F0/\u63CF\u8FF0 +gfgcpzrq_display.TITLE=\u4F9B\u65B9/\u5DE5\u5382\u6279\u51C6/\u65E5\u671F +gkzlpzrq_display.TITLE=\u987E\u5BA2\u8D28\u91CF\u6279\u51C6/\u65E5\u671F +gfgc_display.TITLE=\u4F9B\u65B9/\u5DE5\u5382 +gfdh_display.TITLE=\u4F9B\u65B9\u4EE3\u53F7 +gkpzrq_display.TITLE=\u987E\u5BA2\u6279\u51C6/\u65E5\u671F +qtpzrq_display.TITLE=\u5176\u4ED6\u6279\u51C6/\u65E5\u671F +tjh_display.TITLE=\u6DFB\u52A0\u884C +tjdh_display.TITLE=\u6DFB\u52A0\u591A\u884C +tjhbh_display.TITLE=\u6DFB\u52A0\u5408\u5E76\u884C +tjdghbh_display.TITLE=\u6DFB\u52A0\u591A\u4E2A\u5408\u5E76\u884C +tjgx_display.TITLE=\u6DFB\u52A0\u5DE5\u5E8F +hbh_display.TITLE=\u5408\u5E76\u884C +cfhbdyg_display.TITLE=\u62C6\u5206\u5408\u5E76\u5355\u5143\u683C +yczh_display.TITLE=\u79FB\u9664\u6574\u884C +sxxzl_display.TITLE=\u7F29\u5C0F\u9009\u4E2D\u5217 +qxsxxzl_display.TITLE=\u53D6\u6D88\u7F29\u5C0F\u9009\u4E2D\u5217 +txbz_display.TITLE=\u586B\u5199\u6807\u51C6 +dcnbkzjh_display.TITLE=\u5BFC\u51FA\u63A7\u5236\u8BA1\u5212 +fqsh_display.TITLE=\u53D1\u8D77\u5BA1\u6838 +kzjhk_display.TITLE=\u63A7\u5236\u8BA1\u5212\u5E93 +ck_display.TITLE=\u8BCD\u5E93 +cxjz_display.TITLE=\u91CD\u65B0\u52A0\u8F7D +qksj_display.TITLE=\u6E05\u7A7A\u6570\u636E +cjgy_display.TITLE=\u521B\u5EFA\u5DE5\u827A +xh_display.TITLE=\u578B\u53F7 +cpmc_display.TITLE=\u4EA7\u54C1\u540D\u79F0 +cxyj_display.TITLE=\u6210\u5F62\u538B\u673A +khmc_display.TITLE=\u5BA2\u6237\u540D\u79F0 +khth_display.TITLE=\u5BA2\u6237\u56FE\u53F7 +zxyj_display.TITLE=\u6574\u578B\u538B\u673A +khxmh_display.TITLE=\u5BA2\u6237\u9879\u76EE\u53F7 +clbz_display.TITLE=\u6750\u6599\u6807\u51C6 +sjry_display.TITLE=\u8BBE\u8BA1\u4EBA\u5458 +cjrq_display.TITLE=\u521B\u5EFA\u65E5\u671F +cx06_display.TITLE=\u67E5\u8BE2 +cph06_display.TITLE=\u4EA7\u54C1\u53F7 +gybh06_display.TITLE=\u5DE5\u827A\u7F16\u53F7 +mc06_display.TITLE=\u540D\u79F0 +gyfg08_display.TITLE=\u5DE5\u827A\u5206\u5DE5 +xzz08_display.TITLE=\u9009\u62E9\u503C\uFF1A +yhm08_display.TITLE=\u7528\u6237\u540D\uFF1A +ss08_display.TITLE=\u641C\u7D22 +txPFMEA10_display.TITLE=\u586B\u5199PFMEA +qzsxmsjhgfx10_display.TITLE=\u6F5C\u5728\u5931\u6548\u6A21\u5F0F\u53CA\u540E\u679C\u5206\u6790 +gsmc10_display.TITLE=\u516C\u53F8\u540D\u79F0 +xm10_display.TITLE=\u9879\u76EE +PFMEAIDbh10_display.TITLE=PFMEA ID\u7F16\u53F7 +zzdz10_display.TITLE=\u5236\u9020\u5730\u5740 +PFMEAksrq_display.TITLE=PFMEA\u5F00\u59CB\u65E5\u671F +PFMEAxdrq10_display.TITLE=PFMEA\u4FEE\u8BA2\u65E5\u671F +gczz10_display.TITLE=\u8FC7\u7A0B\u804C\u8D23 +gkmc10_display.TITLE=\u987E\u5BA2\u540D\u79F0 +bmjb10_display.TITLE=PFMEA\u5173\u952E\u65E5\u671F +cxpt10_display.TITLE=\u8F66\u578B/\u5E73\u53F0 +kzntd10_display.TITLE=\u8DE8\u804C\u80FD\u56E2\u961F +ll10_display.TITLE=PFMEA\u7ECF\u9A8C\u6570\u636E\u5E93 +wc10_display.TITLE=\u5B8C\u6210 +dcPFMEA10_display.TITLE=\u5BFC\u51FAPFMEA +PFMEAksrq10_display.TITLE=PFMEA\u5F00\u59CB\u65E5\u671F +PFMEAc10_display.TITLE=PFMEA\u5E93 +xztsfh10_display.TITLE=\u9009\u62E9\u7279\u6B8A\u7B26\u53F7 +cz10_display.TITLE=\u67E5\u627E +fzdh10_display.TITLE=\u590D\u5236\u591A\u884C +crhs10_display.TITLE=\u63D2\u5165\u884C\u6570 +ych12_display.TITLE=\u79FB\u9664\u884C +tjjd12_display.TITLE=\u6DFB\u52A0\u8282\u70B9 +ycjd12_display.TITLE=\u79FB\u9664\u8282\u70B9 +gxjd12_display.TITLE=\u66F4\u65B0\u8282\u70B9 +jdmc12_display.TITLE=\u8282\u70B9\u540D\u79F0 +jdID12_display.TITLE=\u8282\u70B9ID +xztsfh12_display.TITLE=\u9009\u62E9\u7279\u6B8A\u7B26\u53F7 +bzgy17_display.TITLE=\u5305\u88C5\u5DE5\u827A +cpdh17_display.TITLE=\u4EA7\u54C1\u4EE3\u53F7 +cpmc17_display.TITLE=\u4EA7\u54C1\u540D\u79F0 +yhth17_display.TITLE=\u7528\u6237\u56FE\u53F7 +chmc17_display.TITLE=\u5BA2\u6237\u540D\u79F0 +jszg17_display.TITLE=\u6280\u672F\u4E3B\u7BA1 +sjxzljtp17_display.TITLE=\u53CC\u51FB\u9009\u62E9\u96F6\u4EF6\u56FE\u7247 +bzfs17_display.TITLE=\u5305\u88C5\u65B9\u5F0F +jyfs17_display.TITLE=\u6D78\u6CB9\u65B9\u5F0F +mxsl17_display.TITLE=\u6BCF\u7BB1\u6570\u91CF +jx17_display.TITLE=\u4EF6/\u7BB1 +wzxm17_display.TITLE=\u5916\u7EB8\u7BB1\u540D +bzde17_display.TITLE=\u5305\u88C5\u5B9A\u989D +xs17_display.TITLE=\u7BB1/\u65F6 +nldm17_display.TITLE=\u5C3C\u9F99\u888B\u540D +cpdz17_display.TITLE=\u6210\u54C1\u5355\u91CD +xsm17_display.TITLE= \u5438\u5851\u540D +zxmz17_display.TITLE=\u6574\u7BB1\u6BDB\u91CD +wxbq17_display.TITLE=\u5916\u7BB1\u6807\u7B7E +rktp17_display.TITLE=\u5165\u5E93\u6258\u76D8 +xc17_display.TITLE=\u7BB1/\u5C42 +ct17_display.TITLE=\u5C42/\u6258 +sjxztp17_display.TITLE=\u53CC\u51FB\u9009\u62E9\u56FE\u7247 +bzsm17_display.TITLE=\u6B65\u9AA4\u8BF4\u660E +zysx17_display.TITLE=\u6CE8\u610F\u4E8B\u9879 +bzry17_display.TITLE=\u7F16\u5236\u4EBA\u5458 +pzry17_display.TITLE=\u6279\u51C6\u4EBA\u5458 +xgrq17_display.TITLE=\u4FEE\u6539\u65E5\u671F +bz17_display.TITLE=\u5907 \u6CE8 +ysbzlx17_display.TITLE=\u8FD0\u8F93\u5305\u88C5\u7C7B\u578B +dbfs17_display.TITLE=\u6253\u5305\u65B9\u5F0F +tpgg17_display.TITLE=\u6258\u76D8\u89C4\u683C +jgfs17_display.TITLE=\u52A0\u56FA\u65B9\u5F0F +sjxzdbt17_display.TITLE=\u53CC\u51FB\u9009\u62E9\u6253\u5305\u56FE +dybzxx17_display.TITLE=\u5355\u5143\u5305\u88C5\u4FE1\u606F +ysbzxx17_display.TITLE=\u8FD0\u8F93\u5305\u88C5\u4FE1\u606F +dh17_display.TITLE=\u4EE3\u53F7 +cckcg17_display.TITLE=\u957F*\u5BBD*\u9AD8\uFF08cm\uFF09 +hd17_display.TITLE=\u539A\u5EA6\uFF08mm\uFF09 +cl17_display.TITLE=\u6750\u6599 +gg17_display.TITLE=\u89C4\u683C +ks17_display.TITLE=\u5B54\u6570 +cp17_display.TITLE=\u4EA7\u54C1 +xgdj18_display.TITLE=\u4FEE\u6539\u7B49\u7EA7 +cxnd18_display.TITLE=\u8F66\u578B/\u5E74\u5EA6 +bz18_display.TITLE=\u6807\u6CE8 +ycbz18_display.TITLE=\u79FB\u9664\u6807\u6CE8 +kzjhdc19_display.TITLE=\u63A7\u5236\u8BA1\u5212\u5BFC\u51FA +gx19_display.TITLE=\u5DE5\u5E8F: +cx19_display.TITLE=\u67E5\u8BE2 +kzjhwjmc19_display.TITLE=\u63A7\u5236\u8BA1\u5212\u6587\u4EF6\u540D\u79F0 +drkzjh20_display.TITLE=\u5BFC\u5165\u63A7\u5236\u8BA1\u5212 +xzkzjhwj20_display.TITLE=\u9009\u62E9\u63A7\u5236\u8BA1\u5212\u6587\u4EF6 +qcwcbj21_display.TITLE=\u6E05\u9664\u5B8C\u6210\u6807\u8BB0 +xzgytz23_display.TITLE=\u9009\u62E9\u5DE5\u827A\u56FE\u7EB8 +gytz23_display.TITLE=\u5DE5\u827A\u56FE\u7EB8\uFF1A +xz24_display.TITLE=\u9009\u62E9 +kzjh24_display.TITLE=\u63A7\u5236\u8BA1\u5212 +yqrq25_display.TITLE=\u903E\u671F\u65E5\u671F +PDMEAtj25_display.TITLE=PFMEA\u7EDF\u8BA1 +dcbb25_display.TITLE=\u5BFC\u51FA\u62A5\u8868 +gb25_display.TITLE=\u5173\u95ED +jcfxwtd27_display.TITLE=\u68C0\u6D4B\u5206\u6790\u59D4\u6258\u5355 +wtdbh27_display.TITLE=\u59D4\u6258\u5355\u7F16\u53F7\uFF1A +jclx27_display.TITLE=\u68C0\u6D4B\u7C7B\u578B +jcbm27_display.TITLE=\u68C0\u6D4B\u90E8\u95E8 +wtdw27_display.TITLE=\u59D4\u6258\u5355\u4F4D +wtr27_display.TITLE=\u59D4\u6258\u4EBA +wtdz27_display.TITLE=\u59D4\u6258\u5730\u5740 +wtrlxfs27_display.TITLE=\u59D4\u6258\u4EBA\u8054\u7CFB\u65B9\u5F0F +wtrq27_display.TITLE=\u59D4\u6258\u65E5\u671F +xwwcsj27_display.TITLE=\u5E0C\u671B\u5B8C\u6210\u65F6\u95F4 +jcyt27_display.TITLE=\u68C0\u6D4B\u7528\u9014 +jcjg27_display.TITLE=\u68C0\u6D4B\u7ED3\u679C +xmdj27_display.TITLE=\u9879\u76EE\u7B49\u7EA7 +khdj27_display.TITLE=\u5BA2\u6237\u7B49\u7EA7 +xmbh27_display.TITLE=\u9879\u76EE\u7F16\u53F7 +yyly27_display.TITLE=\u5E94\u7528\u9886\u57DF +xmmc27_display.TITLE=\u9879\u76EE\u540D\u79F0 +cph27_display.TITLE=\u4EA7\u54C1\u53F7 +wlh27_display.TITLE=\u7269\u6599\u53F7 +cplx27_display.TITLE=\u4EA7\u54C1\u7C7B\u578B +scdw27_display.TITLE=\u751F\u4EA7\u5355\u4F4D +ypsl27_display.TITLE=\u6837\u54C1\u6570\u91CF +ypzt27_display.TITLE=\u6837\u54C1\u72B6\u6001 +wldh27_display.TITLE=\u7269\u6D41\u5355\u53F7 +ypbh27_display.TITLE=\u6837\u54C1\u7F16\u53F7 +ypclfs27_display.TITLE=\u6837\u54C1\u5904\u7406\u65B9\u5F0F +sybw27_display.TITLE=\u4F7F\u7528\u90E8\u4F4D +syhj27_display.TITLE=\u4F7F\u7528\u73AF\u5883 +gzzh27_display.TITLE=\u5DE5\u4F5C\u8F7D\u8377 +zhlx27_display.TITLE=\u8F7D\u8377\u7C7B\u578B +xzfs27_display.TITLE=\u65CB\u8F6C\u65B9\u5F0F +xzsd27_display.TITLE=\u65CB\u8F6C\u901F\u5EA6 +gzwd27_display.TITLE=\u5DE5\u4F5C\u6E29\u5EA6 +xzwtnr27_display.TITLE=\u9009\u62E9\u59D4\u6258\u5185\u5BB9 +bz27_display.TITLE=\u5907\u6CE8 +ypydxc27_display.TITLE=\u6837\u54C1\u5DF2\u5230\u8FBE\u73B0\u573A +sysj27_display.TITLE=\u6536\u6837\u65F6\u95F4 +syr27_display.TITLE=\u6536\u6837\u4EBA +ypshjg27_display.TITLE=\u6837\u54C1\u5BA1\u6838\u7ED3\u679C +yqwcsj27_display.TITLE=\u9884\u671F\u5B8C\u6210\u65F6\u95F4 +thyy27_display.TITLE=\u9000\u56DE\u539F\u56E0 +jcrwzb27_display.TITLE=\u68C0\u6D4B\u4EFB\u52A1\u4E3B\u529E +jcrwxb27_display.TITLE=\u68C0\u6D4B\u4EFB\u52A1\u534F\u529E +jhkssj27_display.TITLE=\u8BA1\u5212\u5F00\u59CB\u65F6\u95F4 +jhwcsj27_display.TITLE=\u8BA1\u5212\u5B8C\u6210\u65F6\u95F4 +djdywtd27_display.TITLE=\u70B9\u51FB\u6253\u5370\u59D4\u6258\u5355 +djdyypbs27_display.TITLE=\u70B9\u51FB\u6253\u5370\u6837\u54C1\u6807\u8BC6 +sjwcsj27_display.TITLE=\u5B9E\u9645\u5B8C\u6210\u65F6\u95F4 +jcjgsm27_display.TITLE=\u68C0\u6D4B\u7ED3\u679C\u8BF4\u660E +ypcz27_display.TITLE=\u6837\u54C1\u5904\u7F6E +cywz27_display.TITLE=\u5B58\u6837\u4F4D\u7F6E +shsj27_display.TITLE=\u5BA1\u6838\u65F6\u95F4 +shy27_display.TITLE=\u5BA1\u6838\u5458 +shjg27_display.TITLE=\u5BA1\u6838\u7ED3\u679C +wtxx27_display.TITLE=\u59D4\u6258\u4FE1\u606F +clfx27_display.TITLE=\u6750\u6599\u5206\u6790 +jljc27_display.TITLE=\u8BA1\u91CF\u68C0\u6D4B +wtnr27_display.TITLE=\u59D4\u6258\u5185\u5BB9 +zygyk28_display.TITLE=\u4F5C\u4E1A\u5DE5\u827A\u5361 +gsmc28_display.TITLE=\u516C\u53F8\u540D\u79F0 +ljdh28_display.TITLE=\u96F6\u4EF6\u4EE3\u53F7 +sbxh28_display.TITLE=\u4EA7\u54C1\u540D\u79F0 +bgx28_display.TITLE=\u672C\u5DE5\u5E8F +sbmc28_display.TITLE=\u8BBE\u5907\u540D\u79F0 +gzmx28_display.TITLE=\u5DE5\u88C5\u660E\u7EC6 +jgcs28_display.TITLE=\u52A0\u5DE5\u53C2\u6570 +cptxkzyq28_display.TITLE=\u4EA7\u54C1\u7279\u6027\u63A7\u5236\u8981\u6C42 +zpgyk29_display.TITLE=\u88C5\u914D\u5DE5\u827A\u5361 +gsmc29_display.TITLE=\u516C\u53F8\u540D\u79F0 +ljdh29_display.TITLE=\u96F6\u4EF6\u4EE3\u53F7 +sbxh29_display.TITLE=\u8BBE\u5907\u578B\u53F7 +zyjzs30_display.TITLE=\u4F5C\u4E1A\u57FA\u51C6\u4E66 +xzdclj31_display.TITLE=\u9009\u62E9\u5BFC\u51FA\u8DEF\u5F84 +wjmc31_display.TITLE=\u6587\u4EF6\u540D\u79F0 +jyjzs33_display.TITLE=\u68C0\u9A8C\u57FA\u51C6\u4E66 +bzbz34_display.TITLE=\u5305\u88C5\u6807\u51C6 +ljh34_display.TITLE=\u96F6\u4EF6\u53F7 +ljmc34_display.TITLE=\u96F6\u4EF6\u540D\u79F0 +gys34_display.TITLE=\u4F9B\u5E94\u5546 +gysdh34_display.TITLE=\u4F9B\u5E94\u5546\u4EE3\u53F7 +syzcdmmc34_display.TITLE=\u9002\u7528\u603B\u6210\u4EE3\u7801/\u540D\u79F0 +ljdw(tg)34_display.TITLE=\u96F6\u4EF6\u5355\u4F4D\uFF08\u5957/\u4E2A\uFF09 +ljgg34_display.TITLE=\u96F6\u4EF6\u89C4\u683C\uFF08mm\uFF09 +ljzl34_display.TITLE=\u96F6\u4EF6\u91CD\u91CF\uFF08kg\uFF09 +bzbzclfhdjyms34_display.TITLE=\u5305\u88C5\u3001\u5305\u88C5\u6750\u6599\u3001\u9632\u62A4\u7B49\u7B80\u8981\u63CF\u8FF0 +bqgshwz34_display.TITLE=\u6807\u7B7E\u683C\u5F0F\u548C\u4F4D\u7F6E +zt35_display.TITLE=\u72B6\u6001 +wtdsh35_display.TITLE=\u59D4\u6258\u5355\u5BA1\u6838 +gzfp35_display.TITLE=\u5DE5\u4F5C\u5206\u914D +scjl35_display.TITLE=\u4E0A\u4F20\u8BB0\u5F55 +wtrq35_display.TITLE=\u59D4\u6258\u65E5\u671F +wtdh35_display.TITLE=\u59D4\u6258\u5355\u53F7 +wtdw35_display.TITLE=\u59D4\u6258\u5355\u4F4D +jclx35_display.TITLE=\u68C0\u6D4B\u7C7B\u578B +xmdj35_display.TITLE=\u9879\u76EE\u7B49\u7EA7 +ycwcrq35_display.TITLE=\u9884\u671F\u5B8C\u6210\u65E5\u671F +jhwcrq35_display.TITLE=\u8BA1\u5212\u5B8C\u6210\u65E5\u671F +zbry35_display.TITLE=\u4E3B\u529E\u4EBA\u5458 +lcjs35_display.TITLE=\u6D41\u7A0B\u76D1\u89C6 +dqzt35_display.TITLE=\u5F53\u524D\u72B6\u6001 +wtdhypsh35_display.TITLE=\u59D4\u6258\u5355\u548C\u6837\u54C1\u5BA1\u6838 +gzfp35_display.TITLE=\u5DE5\u4F5C\u5206\u914D +scjg35_display.TITLE=\u4E0A\u4F20\u7ED3\u679C +sywtd41_display.TITLE=\u8BD5\u9A8C\u59D4\u6258\u5355 +wtdbh41_display.TITLE=\u59D4\u6258\u5355\u7F16\u53F7\uFF1A +scdw41_display.TITLE=\u751F\u4EA7\u5355\u4F4D +ccxh41_display.TITLE=\u8F74\u627F\u578B\u53F7 +sych41_display.TITLE=\u4F7F\u7528\u573A\u5408 +xmmc41_display.TITLE=\u9879\u76EE\u540D\u79F0 +xmbh41_display.TITLE=\u9879\u76EE\u7F16\u53F7 +xmdj41_display.TITLE=\u9879\u76EE\u7B49\u7EA7 +wtsylx41_display.TITLE=\u59D4\u6258\u8BD5\u9A8C\u7C7B\u578B +yzsy41_display.TITLE=\u9A8C\u8BC1\u8BD5\u9A8C +tzxxsy41_display.TITLE=\u7279\u79CD\u65B0\u578B\u8BD5\u9A8C +khyq41_display.TITLE=\u5BA2\u6237\u8981\u6C42 +sybj41_display.TITLE=\u8BD5\u9A8C\u80CC\u666F +symd41_display.TITLE=\u8BD5\u9A8C\u76EE\u7684 +sygfsjry41_display.TITLE=\u8BD5\u9A8C\u89C4\u8303\uFF08\u8BBE\u8BA1\u4EBA\u5458\uFF09 +yjgsyry41_display.TITLE=\u5DF2\u4EA4\u7ED9\u8BD5\u9A8C\u4EBA\u5458 +qtsyyq41_display.TITLE=\u5176\u4ED6\u8BD5\u9A8C\u8981\u6C42 +wtr41_display.TITLE=\u59D4\u6258\u4EBA +lxfs41_display.TITLE=\u8054\u7CFB\u65B9\u5F0F +gsdz41_display.TITLE=\u516C\u53F8\u5730\u5740 +gscz41_display.TITLE=\u516C\u53F8\u4F20\u771F +shr41_display.TITLE=\u5BA1\u6838\u4EBA +shrq41_display.TITLE=\u5BA1\u6838\u65E5\u671F +zjlpz41_display.TITLE=\u603B\u7ECF\u7406\u6279\u51C6 +sywtftx41_display.TITLE=\u8BD5\u9A8C\u59D4\u6258\u65B9\u586B\u5199 +psjl41_display.TITLE=\u8BC4\u5BA1\u8BB0\u5F55 +jhkssj41_display.TITLE=\u8BA1\u5212\u5F00\u59CB\u65F6\u95F4 +jhjssj41_display.TITLE=\u8BA1\u5212\u7ED3\u675F\u65F6\u95F4 +syfzr41_display.TITLE=\u8BD5\u9A8C\u8D1F\u8D23\u4EBA +lxdh41_display.TITLE=\u8054\u7CFB\u7535\u8BDD +psrq41_display.TITLE=\u8BC4\u5BA1/\u65E5\u671F +pzrq41_display.TITLE=\u6279\u51C6/\u65E5\u671F +swtftx41_display.TITLE=\u53D7\u59D4\u6258\u65B9\u586B\u5199 +bz41_display.TITLE=\u5907\u6CE8 +gzsjtd41_display.TITLE=\u5DE5\u88C5\u8BBE\u8BA1\u56E2\u961F +xzscgztz41_display.TITLE=\u9009\u62E9\u4E0A\u4F20\u5DE5\u88C5\u56FE\u7EB8 +qxzyscdwj41_display.TITLE=\u8BF7\u9009\u62E9\u8981\u4E0A\u4F20\u7684\u6587\u4EF6... +qd41_display.TITLE=\u786E\u5B9A +gzsjwcrq141_display.TITLE=\u5DE5\u88C5\u8BBE\u8BA1\u5B8C\u6210\u65E5\u671F +gzsj141_display.TITLE=\u5DE5\u88C5\u8BBE\u8BA1 +gzdhrq41_display.TITLE=\u5DE5\u88C5\u5230\u8D27\u65E5\u671F +gzsjrq41_display.TITLE=\u5DE5\u88C5\u9001\u68C0\u65E5\u671F +gzsjwcrq41_display.TITLE=\u5DE5\u88C5\u9001\u68C0\u5B8C\u6210\u65E5\u671F +gzjcbgbh41_display.TITLE=\u5DE5\u88C5\u68C0\u6D4B\u62A5\u544A\uFF08\u8BB0\u5F55\uFF09\u7F16\u53F7 +gzsj41_display.TITLE=\u5DE5\u88C5\u9001\u68C0 +ypdyrq41_display.TITLE=\u6837\u54C1\u5230\u6837\u65E5\u671F +syqypjcwcrq41_display.TITLE=\u8BD5\u9A8C\u524D\u6837\u54C1\u68C0\u6D4B\u5B8C\u6210\u65E5\u671F +syqypjcbgbh41_display.TITLE=\u8BD5\u9A8C\u524D\u6837\u54C1\u68C0\u6D4B\u62A5\u544A\uFF08\u8BB0\u5F55\uFF09\u7F16\u53F7 +syksrq41_display.TITLE=\u8BD5\u9A8C\u5F00\u59CB\u65E5\u671F +sywcrq41_display.TITLE=\u8BD5\u9A8C\u5B8C\u6210\u65E5\u671F +syss41_display.TITLE=\u8BD5\u9A8C\u5B9E\u65BD +syhypjcwcrq41_display.TITLE=\u8BD5\u9A8C\u540E\u6837\u54C1\u68C0\u6D4B\u5B8C\u6210\u65E5\u671F +syhypjcbg41_display.TITLE=\u8BD5\u9A8C\u540E\u6837\u54C1\u68C0\u6D4B\u62A5\u544A\uFF08\u8BB0\u5F55\uFF09\u7F16\u53F7 +ypjc41_display.TITLE=\u6837\u54C1\u68C0\u6D4B +xzscsybg41_display.TITLE=\u9009\u62E9\u4E0A\u4F20\u8BD5\u9A8C\u62A5\u544A +sywcrq241_display.TITLE=\u8BD5\u9A8C\u5B8C\u6210\u65E5\u671F +sybgbh41_display.TITLE=\u8BD5\u9A8C\u62A5\u544A\u7F16\u53F7 +sybg241_display.TITLE=\u8BD5\u9A8C\u62A5\u544A +sywtd241_display.TITLE=\u8BD5\u9A8C\u59D4\u6258\u5355 +sykxljap41_display.TITLE=\u8BD5\u9A8C\u53EF\u884C\uFF0C\u7ACB\u5373\u5B89\u6392 +sybkx41_display.TITLE=\u8BD5\u9A8C\u4E0D\u53EF\u884C +zybcfjywwsy41_display.TITLE=\u8D44\u6E90\u4E0D\u5145\u5206\uFF0C\u5EFA\u8BAE\u59D4\u5916\u8BD5\u9A8C +qijy241_display.TITLE=\u5176\u4ED6\u5EFA\u8BAE +btxxbnwk41_display.TITLE=\u5FC5\u586B\u9879\u4E0D\u80FD\u4E3A\u7A7A\uFF01 +gzcg41_display.TITLE=\u5DE5\u88C5\u91C7\u8D2D +xqsp41_display.TITLE=\u9700\u6C42\u5BA1\u6279 + + + +fxwtd40_display.TITLE=\u5206\u6790\u59D4\u6258\u5355 +CEAwtd40_display.TITLE=CAE\u59D4\u6258\u5355 +wtdbh40_display.TITLE=\u59D4\u6258\u5355\u7F16\u53F7\uFF1A +kemc40_display.TITLE=\u5BA2\u6237\u540D\u79F0 +xmsstd40_display.TITLE=\u9879\u76EE\u6240\u5C5E\u56E2\u961F +xmmc40_display.TITLE=\u9879\u76EE\u540D\u79F0 +xmjl40_display.TITLE=\u9879\u76EE\u7ECF\u7406 +xmdj40_display.TITLE=\u9879\u76EE\u7B49\u7EA7 +sjbsstd40_display.TITLE=\u8BBE\u8BA1\u90E8\u6240\u5C5E\u56E2\u961F +xmbh40_display.TITLE=\u9879\u76EE\u7F16\u53F7 +sjfzr40_display.TITLE=\u8BBE\u8BA1\u8D1F\u8D23\u4EBA +xmlx40_display.TITLE=\u9879\u76EE\u7C7B\u578B +qwwcsj40_display.TITLE=\u671F\u671B\u5B8C\u6210\u65F6\u95F4 +jbxx40_display.TITLE=1.\u57FA\u672C\u4FE1\u606F +scfxry40_display.TITLE=\u4E0A\u6B21\u5206\u6790\u4EBA\u5458 +scbgsj40_display.TITLE=\u4E0A\u6B21\u62A5\u544A\u65F6\u95F4 +ggd40_display.TITLE=\u66F4\u6539\u70B9 +ggyy40_display.TITLE=\u66F4\u6539\u539F\u56E0 +srzl40_display.TITLE=2.\u8F93\u5165\u8D44\u6599 +cjtd40_display.TITLE=\u627F\u63A5\u56E2\u961F +xmwtsj40_display.TITLE=\u9879\u76EE\u59D4\u6258\u65F6\u95F4 +cjr40_display.TITLE=\u627F\u63A5\u4EBA +xmggcs40_display.TITLE=\u9879\u76EE\u66F4\u6539\u6B21\u6570 +xbr40_display.TITLE=\u534F\u529E\u4EBA +jhkssj40_display.TITLE=\u8BA1\u5212\u5F00\u59CB\u65F6\u95F4 +Romaxjf40_display.TITLE=Romax\u79EF\u5206 +jsxqts40_display.TITLE=\u8BA1\u7B97\u9700\u6C42\u5929\u6570 +yxyjf40_display.TITLE=\u6709\u9650\u5143\u79EF\u5206 +jswcsj40_display.TITLE=\u8BA1\u7B97\u5B8C\u6210\u65F6\u95F4 +xmcjxx40_display.TITLE=3.\u9879\u76EE\u627F\u63A5\u4FE1\u606F +bghjgmc40_display.TITLE=\u62A5\u544A\u6216\u7ED3\u679C\u540D\u79F0 +bgbh40_display.TITLE=\u62A5\u544A\u7F16\u53F7 +bghjgscsj40_display.TITLE=\u62A5\u544A\u6216\u7ED3\u679C\u4E0A\u4F20\u65F6\u95F4 +bghjgfk40_display.TITLE=4.\u62A5\u544A\u6216\u7ED3\u679C\u53CD\u9988 +jdr40_display.TITLE=\u6821\u5BF9\u4EBA +jdsj40_display.TITLE=\u6821\u5BF9\u65F6\u95F4 +jdjg40_display.TITLE=\u6821\u5BF9\u7ED3\u679C +thyy40_display.TITLE=\u9000\u56DE\u539F\u56E0 +bghjgjd40_display.TITLE=5.\u62A5\u544A\u6216\u7ED3\u679C\u6821\u5BF9 +khmc40_display.TITLE=\u5BA2\u6237\u540D\u79F0 +xmbssty40_display.TITLE=\u9879\u76EE\u90E8\u6240\u5C5E\u56E2\u961F +sybw40_display.TITLE=\u4F7F\u7528\u90E8\u4F4D +srzl40_display.TITLE=2.\u8F93\u5165\u8D44\u6599 +bxqrbgxxx40_display.TITLE=\u5FC5\u987B\u786E\u8BA4\u5E76\u52FE\u9009\u4FE1\u606F +jsscxm40_display.TITLE=\u8BA1\u7B97\u8F93\u51FA\u9879\u76EE +kgxxx40_display.TITLE=\u53EF\u52FE\u9009\u4FE1\u606F +ydndqjddjgzwd40_display.TITLE=\u8FD0\u52A8\u7C98\u5EA6\u3001\u6E05\u6D01\u5EA6\u7B49\u7EA7\u3001\u5DE5\u4F5C\u6E29\u5EA6 +EPtjj40_display.TITLE=EP\u6DFB\u52A0\u5242 +ysr40_display.TITLE=\u9884\u5BA1\u4EBA +yssj40_display.TITLE=\u9884\u5BA1\u65F6\u95F4 +ysjg40_display.TITLE=\u9884\u5BA1\u7ED3\u679C +zbdzys40_display.TITLE=1.\u503C\u73ED\u56E2\u961F\u957F\u9884\u5BA1 +wtdbh240_display.TITLE=\u59D4\u6258\u5355\u7F16\u53F7 +jhwcsj40_display.TITLE=\u8BA1\u5212\u5B8C\u6210\u65F6\u95F4 +xmcjxx240_display.TITLE=2.\u9879\u76EE\u627F\u63A5\u4FE1\u606F +jsfxjm40_display.TITLE=\u8BA1\u7B97\u5206\u6790\u5EFA\u6A21 +bczlsj40_display.TITLE=\u8865\u5145\u8D44\u6599\u65F6\u95F4 +zyss40_display.TITLE=3.\u4F5C\u4E1A\u5B9E\u65BD +bghjgfk240_display.TITLE=4.\u62A5\u544A\u6216\u7ED3\u679C\u53CD\u9988 +bghjgjd240_display.TITLE=5.\u62A5\u544A\u6216\u7ED3\u679C\u6821\u5BF9 +CAEfxxqwtd40_display.TITLE=CAE\u5206\u6790\u9700\u6C42\u59D4\u6258\u5355 +jsfxtdcjd40_display.TITLE=\u8BA1\u7B97\u5206\u6790\u56E2\u961F\u627F\u63A5\u5355 +ggxmwtd40_display.TITLE=\u66F4\u6539\u9879\u76EE\u59D4\u6258\u5355 +tk_display.TITLE=\u56FE\u5E93 + + +ljgybh04_display.TITLE=\u96F6\u4EF6/\u5DE5\u827A\u7F16\u53F7 +gcmc04_display.TITLE=\u8FC7\u7A0B\u540D\u79F0 +jqsbgzjj04_display.TITLE=\u673A\u5668,\u8BBE\u5907,\u5DE5\u88C5\uFF0C\u5939\u5177 +smjyzyzb04_display.TITLE=\u9996\u672B\u68C0\u9A8C/\u4F5C\u4E1A\u51C6\u5907 +bh04_display.TITLE=\u7F16\u53F7 +cp04_display.TITLE=\u4EA7\u54C1 +gc04_display.TITLE=\u8FC7\u7A0B +tstxfl04_display.TITLE=\u7279\u6B8A\u7279\u6027\u5206\u7C7B +cpgcgfgc04_display.TITLE=\u4EA7\u54C1/\u8FC7\u7A0B/\u89C4\u683C/\u516C\u5DEE +pgclff04_display.TITLE=\u8BC4\u4F30/\u6D4B\u91CF\u65B9\u6CD5 +rl04_display.TITLE=\u5BB9\u91CF +pl04_display.TITLE=\u9891\u7387 +kzff04_display.TITLE=\u63A7\u5236\u65B9\u6CD5 +fyjh04_display.TITLE=\u53CD\u5E94\u8BA1\u5212 +tsfhwz04_display.TITLE=\u7279\u6B8A\u7B26\u53F7\u4F4D\u7F6E +sfwc04_display.TITLE=\u662F\u5426\u5B8C\u6210 +fjdID04_display.TITLE=\u7236\u8282\u70B9ID +tszfszwz04_display.TITLE=\u7279\u6B8A\u5B57\u7B26\u6240\u5728\u4F4D\u7F6E +xh04_display.TITLE=\u5E8F\u53F7 +z04_display.TITLE=\u503C +mc04_display.TITLE=\u540D\u79F0 +gysjfdygc34_display.TITLE=\u4F9B\u5E94\u5546\u4EA4\u4ED8\u5355\u5143\u6784\u6210 +yjbz34_display.TITLE=\u4E00\u7EA7\u5305\u88C5 +ejbz34_display.TITLE=\u4E8C\u7EA7\u5305\u88C5 +sjbz34_display.TITLE=\u4E09\u7EA7\u5305\u88C5 + + + +wxzcpdxqcxxz02_display.TITLE=\u672A\u9009\u4E2D\u4EA7\u54C1\u5BF9\u8C61\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\uFF01 +qxzzcdxhcj02_display.TITLE=\u8BF7\u9009\u62E9\u603B\u6210\u5BF9\u8C61\u540E\u521B\u5EFA +gy02_display.TITLE=\u5DE5\u827A +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/Adapter.java b/src/com/connor/renben/process/plm/util/Adapter.java new file mode 100644 index 0000000..00576ef --- /dev/null +++ b/src/com/connor/renben/process/plm/util/Adapter.java @@ -0,0 +1,299 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.swing.JTable; +import javax.swing.KeyStroke; + +/** + * Adapter 实现 JTables 中的复制粘贴 剪贴板功能。 适配器所用的剪贴板数据格式 与 Excel 所用的剪贴板格式兼容。这提供了 + * 支持的 JTables 和 Excel 间的互操作。 + */ +public class Adapter implements ActionListener { + private String rowstring, value; + private Clipboard system; + private StringSelection stsel; + private JTable jTable1; + private List> selectValue = new ArrayList>(); + + /** + * Excel 适配器由 JTable 构成, 它实现了 JTable 上的复制粘贴 功能,并充当剪贴板监听程序。 + */ + + public Adapter(JTable myJTable) { + jTable1 = myJTable; + KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, + ActionEvent.CTRL_MASK, false); + + // 确定复制按键用户可以对其进行修改 + // 以实现其它按键组合的复制功能。 + KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, + ActionEvent.CTRL_MASK, false); + + // 确定粘贴按键用户可以对其进行修改 + // 以实现其它按键组合的复制功能。 + + jTable1.registerKeyboardAction(this, "Copy", copy, + JComponent.WHEN_FOCUSED); + + jTable1.registerKeyboardAction(this, "Paste", paste, + JComponent.WHEN_FOCUSED); + + system = Toolkit.getDefaultToolkit().getSystemClipboard(); + } + + /** + * 此适配器运行图表的公共读方法。 + */ + public JTable getJTable() { + return jTable1; + } + + public void setJTable(JTable jTable1) { + this.jTable1 = jTable1; + } + + /** + * 在我们监听此实现的按键上激活这种方法。 此处,它监听复制和粘贴 ActionCommands。 包含不相邻单元格的选择导致选择无效, + * 而且此后复制动作无法执行。 粘贴的方法是将选定内容的左上角与 JTable 的当前选定内容的第一个元素对齐。 + */ + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().compareTo("Copy") == 0) { + StringBuffer sbf = new StringBuffer(); + + selectValue.clear(); + // 检查以确保我们仅选择了单元格的 + // 相邻块 + int numcols = jTable1.getSelectedColumnCount(); + int numrows = jTable1.getSelectedRowCount(); + int[] rowsselected = jTable1.getSelectedRows(); + int[] colsselected = jTable1.getSelectedColumns(); + +// if (!((numrows - 1 == rowsselected[rowsselected.length - 1] +// - rowsselected[0] && numrows == rowsselected.length) && (numcols - 1 == colsselected[colsselected.length - 1] +// - colsselected[0] && numcols == colsselected.length))) { +// JOptionPane.showMessageDialog(null, "Invalid Copy Selection", +// "Invalid Copy Selection", JOptionPane.ERROR_MESSAGE); +// +// return; +// } + + for (int i=0;i= 0) + { + sbf.append("\""); + sbf.append(jTable1.getValueAt(rowsselected[i],colsselected[j])); + sbf.append("\""); + } + else if(jTable1.getValueAt(rowsselected[i],colsselected[j]) == null) + { + sbf.append(""); + } + else + { + sbf.append(jTable1.getValueAt(rowsselected[i],colsselected[j])); + } + if (j= 0) + { + sb.append(values[i].replace("\n", " $")); + } + else + { + sb.append(values[i]); + } + //System.out.println(i+s[i]); + } + System.out.println("sb======"+sb.toString()); + String copyValue = sb.toString(); + String[] st1=copyValue.split("\\$"); //new StringTokenizer(sb.toString(),"$".toString()); + + + + int[] rows = jTable1.getSelectedRows(); + int[] columns = jTable1.getSelectedColumns(); + int startRow = rows[0]; + int startCol = columns[0]; + if(rows.length ==1 ) + { + for(int i=0;i= 0) + { + String[] cellValue = rowstring.split("\t"); + for(int j=0;j= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[k]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),rows[i],startCol+k); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),rows[i],startCol); + } + //} + //} + } + } + else //写入选中行内容 + { + for(int i=0;i= 0) + { + String[] cellValue = rowstring.split("\t"); + for(int j=0;j st1.length) + { + for (int i = 0; i < rows.length; i++) { + for (int j = 0; j < columns.length; j++) { + rowstring=st1[(i+st1.length)%st1.length]; + System.out.println("rowstring============"+rowstring); + if(rowstring.indexOf("\t") >= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[(j+cellValue.length)%cellValue.length]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),rows[i],columns[j]); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),rows[i],columns[j]); + } + } + } + } + else + { + for (int i = 0; i < st1.length; i++) { + for (int j = 0; j < columns.length; j++) { + rowstring=st1[(i+st1.length)%st1.length]; + System.out.println("rowstring============"+rowstring); + if(rowstring.indexOf("\t") >= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[(j+cellValue.length)%cellValue.length]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),startRow+i,columns[j]); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),startRow+i,columns[j]); + } + } + } + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + + } + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/Adapter1.java b/src/com/connor/renben/process/plm/util/Adapter1.java new file mode 100644 index 0000000..66fccd1 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/Adapter1.java @@ -0,0 +1,302 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.swing.JTable; +import javax.swing.KeyStroke; + +/** + * Adapter 实现 JTables 中的复制粘贴 剪贴板功能。 适配器所用的剪贴板数据格式 与 Excel 所用的剪贴板格式兼容。这提供了 + * 支持的 JTables 和 Excel 间的互操作。 + */ +public class Adapter1 implements ActionListener { + private String rowstring, value; + private Clipboard system; + private StringSelection stsel; + private JTable jTable1; + private List> selectValue = new ArrayList>(); + + /** + * Excel 适配器由 JTable 构成, 它实现了 JTable 上的复制粘贴 功能,并充当剪贴板监听程序。 + */ + + public Adapter1(JTable myJTable) { + jTable1 = myJTable; + KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, + ActionEvent.CTRL_MASK, false); + + // 确定复制按键用户可以对其进行修改 + // 以实现其它按键组合的复制功能。 + KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, + ActionEvent.CTRL_MASK, false); + + // 确定粘贴按键用户可以对其进行修改 + // 以实现其它按键组合的复制功能。 + + jTable1.registerKeyboardAction(this, "Copy", copy, + JComponent.WHEN_FOCUSED); + + jTable1.registerKeyboardAction(this, "Paste", paste, + JComponent.WHEN_FOCUSED); + + system = Toolkit.getDefaultToolkit().getSystemClipboard(); + } + + /** + * 此适配器运行图表的公共读方法。 + */ + public JTable getJTable() { + return jTable1; + } + + public void setJTable(JTable jTable1) { + this.jTable1 = jTable1; + } + + /** + * 在我们监听此实现的按键上激活这种方法。 此处,它监听复制和粘贴 ActionCommands。 包含不相邻单元格的选择导致选择无效, + * 而且此后复制动作无法执行。 粘贴的方法是将选定内容的左上角与 JTable 的当前选定内容的第一个元素对齐。 + */ + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().compareTo("Copy") == 0) { + StringBuffer sbf = new StringBuffer(); + + selectValue.clear(); + // 检查以确保我们仅选择了单元格的 + // 相邻块 + int numcols = jTable1.getSelectedColumnCount(); + int numrows = jTable1.getSelectedRowCount(); + int[] rowsselected = jTable1.getSelectedRows(); + int[] colsselected = jTable1.getSelectedColumns(); + +// if (!((numrows - 1 == rowsselected[rowsselected.length - 1] +// - rowsselected[0] && numrows == rowsselected.length) && (numcols - 1 == colsselected[colsselected.length - 1] +// - colsselected[0] && numcols == colsselected.length))) { +// JOptionPane.showMessageDialog(null, "Invalid Copy Selection", +// "Invalid Copy Selection", JOptionPane.ERROR_MESSAGE); +// +// return; +// } + + for (int i=0;i= 0) + { + sbf.append("\""); + sbf.append(jTable1.getValueAt(rowsselected[i],colsselected[j])); + sbf.append("\""); + } + else if(jTable1.getValueAt(rowsselected[i],colsselected[j]) == null) + { + sbf.append(""); + } + else + { + sbf.append(jTable1.getValueAt(rowsselected[i],colsselected[j])); + } + if (j= 0) + { + sb.append(values[i].replace("\n", " $")); + } + else + { + sb.append(values[i]); + } + //System.out.println(i+s[i]); + } + System.out.println("sb======"+sb.toString()); + String copyValue = sb.toString(); + String[] st1=copyValue.split("\\$"); //new StringTokenizer(sb.toString(),"$".toString()); + + + + int[] rows = jTable1.getSelectedRows(); + int[] columns = jTable1.getSelectedColumns(); + int startRow = rows[0]; + int startCol = columns[0]; + if(rows.length ==1 ) + { + for(int i=0;i= 0) + { + String[] cellValue = rowstring.split("\t"); + for(int j=0;j= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[k]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),rows[i],startCol+k); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),rows[i],startCol); + } + //} + //} + } + } + else //写入选中行内容 + { + for(int i=0;i= 0) + { + String[] cellValue = rowstring.split("\t"); + for(int j=0;j st1.length) + { + for (int i = 0; i < rows.length; i++) { + for (int j = 0; j < columns.length; j++) { + rowstring=st1[(i+st1.length)%st1.length]; + System.out.println("rowstring============"+rowstring); + if(rowstring.indexOf("\t") >= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[(j+cellValue.length)%cellValue.length]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),rows[i],columns[j]); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),rows[i],columns[j]); + } + } + } + } + else + { + for (int i = 0; i < st1.length; i++) { + for (int j = 0; j < columns.length; j++) { + rowstring=st1[(i+st1.length)%st1.length]; + System.out.println("rowstring============"+rowstring); + if(rowstring.indexOf("\t") >= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[(j+cellValue.length)%cellValue.length]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),startRow+i,columns[j]); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),startRow+i,columns[j]); + } + } + } + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + + } + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/CTMap.java b/src/com/connor/renben/process/plm/util/CTMap.java new file mode 100644 index 0000000..3ab87ba --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CTMap.java @@ -0,0 +1,397 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Dimension; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.swing.JOptionPane; +import javax.swing.event.TableModelEvent; +import javax.swing.table.DefaultTableModel; + +import org.apache.commons.collections.map.HashedMap; + +//import com.connor.hs.plm.GCLCT.JTableDemo; +import com.teamcenter.rac.util.MessageBox; + +public class CTMap extends DefaultTableModel implements CellSpan { + protected int rowSize; + protected int columnSize; + protected int[][][] span; // CellSpan + protected boolean isEditable = true; + + private int row = -1; + private int column = -1; + + public int getRow() { + return row; + } + + public void setRow(int row) { + this.row = row; + } + + public int getColumn() { + return column; + } + + public void setColumn(int column) { + this.column = column; + } + + public void setEditable(boolean isEditable) { + this.isEditable = isEditable; + } + + private List processRowList; + + public List getProcessRowList() { + return processRowList; + } + + public void setProcessRowList(List processRowList) { + this.processRowList = processRowList; + } + +// Class[] columnTypes = new Class[]{ +// Object.class, Boolean.class +// }; +// +// @Override +// public Class getColumnClass(int columnIndex) { +// if(columnIndex>=2) { +// return columnTypes[0]; +// }else { +// return columnTypes[columnIndex]; +// } +// +// } + + @Override + public void removeRow(int row) { + // 将可修改的行-1 + if (processRowList != null && processRowList.size() > 0) { + for (int i = processRowList.size() - 1; i >= 0; i--) { + if (processRowList.get(i) != null + && processRowList.get(i) == row) { + processRowList.remove(i); + } else if (processRowList.get(i) != null + && processRowList.get(i) > row) { + processRowList.set(i, processRowList.get(i) - 1); + } + } + } + super.removeRow(row); + } + + @Override + 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]; + } + + @Override + public void setSpan(int[] span, int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return; + this.span[row][column] = span; + } + + @Override + 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; + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + if ((arg0 == row && arg1 == column) || arg1 ==1) { + return this.isEditable; + } else { + return false; + } + } + + 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); + } + + @Override + 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 Map insertRowComb(int row, Map combineMap) { + Vector rowData = new Vector(getColumnCount()); + int index = 0; + + dataVector.insertElementAt(rowData, row); + System.out.println("size: and combine" + 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] = 1; // span[i][j][0]; + newSpan[i][j][1] = 1; // span[i][j][1]; + // newSpan[i][j][0] = 1; + // newSpan[i][j][1] = 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] = 1; //span[i - 1][j][0]; + newSpan[i][j][1] = 1; //span[i - 1][j][1]; + } + } + } + span = newSpan; + rowSize = newSpan.length;// 将可修改的行+1 + + Map combineNewMap = new HashMap(); + addNewCombine(combineMap,row,combineNewMap); + System.out.println("size: and combine new" + combineNewMap.toString()); + combineMap = combineNewMap; + if (combineMap != null && combineMap.size() != 0) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + combine(entry.getKey(), entry.getValue()); + } + } + + return combineNewMap; + } + private void addNewCombine(Map combineMap,int row,Map combineNewMap) { + // TODO Auto-generated method stub + if (combineMap != null && combineMap.size() != 0) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + int[] key = entry.getKey(); + int[] value = entry.getValue(); + if(key[0]>=row) { + + int[] keyN = new int[key.length]; + for(int t = 0; trow && key[0] 0) { + + for (int i = processRowList.size() - 1; i >= 0; i--) { + if (!processRowList.contains(row) + && processRowList.get(i) != null + && processRowList.get(i) == row - 1) { + index = i + 1; + processRowList.add(i + 1, row); + } else if (processRowList.get(i) != null + && processRowList.get(i) == row) { + index = i + 1; + processRowList.add(i + 1, row + 1); + } else if (processRowList.get(i) != null && i > index + && processRowList.get(i) >= row) { + processRowList.set(i, processRowList.get(i) + 1); + } + } + } + + } + + 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/renben/process/plm/util/CTMap2.java b/src/com/connor/renben/process/plm/util/CTMap2.java new file mode 100644 index 0000000..e3fa8d5 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CTMap2.java @@ -0,0 +1,356 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Dimension; +import java.util.List; +import java.util.Vector; + +import javax.swing.event.TableModelEvent; + +import java.awt.Dimension; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.List; +import java.util.Vector; + +import javax.swing.JOptionPane; +import javax.swing.event.TableModelEvent; +import javax.swing.table.DefaultTableModel; + +//import com.connor.hs.plm.GCLCT.JTableDemo; +import com.teamcenter.rac.util.MessageBox; + +public class CTMap2 extends DefaultTableModel implements CellSpan{ + protected int rowSize; + protected int columnSize; + protected int[][][] span; // CellSpan + protected boolean isEditable = true; + + private int row = -1; + private int column = -1; + + public int getRow() { + return row; + } + + public void setRow(int row) { + this.row = row; + } + + public int getColumn() { + return column; + } + + public void setColumn(int column) { + this.column = column; + } + + public void setEditable(boolean isEditable) { + this.isEditable = isEditable; + } + + private List processRowList; + + public List getProcessRowList() { + return processRowList; + } + + public void setProcessRowList(List processRowList) { + this.processRowList = processRowList; + } + +// Class[] columnTypes = new Class[]{ +// Object.class, Boolean.class +// }; +// +// @Override +// public Class getColumnClass(int columnIndex) { +// if(columnIndex==1) { +// return columnTypes[1]; +// }else { +// return columnTypes[0]; +// } +// +// } + + @Override + public void removeRow(int row) { + // 将可修改的行-1 + if (processRowList != null && processRowList.size() > 0) { + for (int i = processRowList.size() - 1; i >= 0; i--) { + if (processRowList.get(i) != null + && processRowList.get(i) == row) { + processRowList.remove(i); + } else if (processRowList.get(i) != null + && processRowList.get(i) > row) { + processRowList.set(i, processRowList.get(i) - 1); + } + } + } + super.removeRow(row); + } + + @Override + 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]; + } + + @Override + public void setSpan(int[] span, int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return; + this.span[row][column] = span; + } + + @Override + 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,int t) { + // TODO Auto-generated method stub + + int rowSpan = rows.length; + int columnSpan = columns.length; + int startRow = rows[0]; + int startColumn = columns[0]; + System.out.println("startColumn " +startColumn); +// for (int i = 0; i < rowSpan; i++) { +// for (int j = 0; j < columnSpan; j++) { +// int[][] js = span[startRow + i]; +// int[] ks = js[startColumn + j]; +// if ((ks[CellSpan.COLUMN] != 1) +// || (ks[CellSpan.ROW] != 1)) { +// // System.out.println("can't combine"); +// return; +// } +// } +// } + int removedRow = 0; + for (int i = 0, ii = 0; i < rowSpan; i++, ii--) { + if(startRow + i >= t) { + System.out.println(startRow + rowSpan +"-------"); + removedRow = removedRow +1; + continue; + } + for (int j = 0, jj = 0; j < columnSpan; j++, jj--) { + int[][] ks = span[startRow + i]; + int[] ks2 = ks[startColumn + j]; + 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 - removedRow; + System.out.println("over"); + } + @Override + 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]; + System.out.println("startColumn " +startColumn); + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + int[][] js = span[startRow + i]; + int[] ks = js[startColumn + j]; + if ((ks[CellSpan.COLUMN] != 1) + || (ks[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; + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + if ((arg0 == row && arg1 == column) || arg1 ==1) { + return this.isEditable; + } else { + return false; + } + } + + 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()); + int index = 0; + + 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]; + // newSpan[i][j][0] = 1; + // newSpan[i][j][1] = 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]; + // newSpan[i][j][0] = 1; + // newSpan[i][j][1] = 1; + } + } + } + span = newSpan; + rowSize = span.length;// 将可修改的行+1 + if (processRowList != null && processRowList.size() > 0) { + + for (int i = processRowList.size() - 1; i >= 0; i--) { + if (!processRowList.contains(row) + && processRowList.get(i) != null + && processRowList.get(i) == row - 1) { + index = i + 1; + processRowList.add(i + 1, row); + } else if (processRowList.get(i) != null + && processRowList.get(i) == row) { + index = i + 1; + processRowList.add(i + 1, row + 1); + } else if (processRowList.get(i) != null && i > index + && processRowList.get(i) >= row) { + processRowList.set(i, processRowList.get(i) + 1); + } + } + + + } + + } + + public CTMap2(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/renben/process/plm/util/CTUI.java b/src/com/connor/renben/process/plm/util/CTUI.java new file mode 100644 index 0000000..88f5661 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CTUI.java @@ -0,0 +1,107 @@ +package com.connor.renben.process.plm.util; + +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 = ((CTable) table).getColumnModel() + .getTotalColumnWidth(); + clipBounds.width = Math.min(clipBounds.width, tableWidth); + g.setClip(clipBounds); + + int firstIndex = ((CTable) table) + .rowAtPoint(new Point(0, clipBounds.y)); + int lastIndex = ((CTable) table).getRowCount() - 1; + Rectangle rowRect = new Rectangle(0, 0, tableWidth, + ((CTable) table).getRowHeight() + + ((CTable) 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) ((CTable) table).getModel(); + int numColumns = ((CTable) table).getColumnCount(); + + for (int column = 0; column < numColumns; column++) { + Rectangle cellRect = ((CTable) 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 = ((CTable) table).getRowMargin(); + int spacingWidth = ((CTable) table).getColumnModel().getColumnMargin(); + // System.out.println("X:"+cellRect.x+"Y:"+cellRect.y); + Color c = g.getColor(); + g.setColor(((CTable) 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 (((CTable) table).isEditing() + && ((CTable) table).getEditingRow() == row + && ((CTable) table).getEditingColumn() == column) { + Component component = ((CTable) table).getEditorComponent(); + component.setBounds(cellRect); + component.validate(); + } else { + TableCellRenderer renderer = ((CTable) table).getCellRenderer(row, + column); + Component component = ((CTable) table).prepareRenderer(renderer, + row, column); + + if (component.getParent() == null) { + rendererPane.add(component); + } + rendererPane.paintComponent(g, component, ((CTable) table), + cellRect.x, cellRect.y, cellRect.width, cellRect.height, + true); + } + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/CTable.java b/src/com/connor/renben/process/plm/util/CTable.java new file mode 100644 index 0000000..022864b --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CTable.java @@ -0,0 +1,235 @@ +package com.connor.renben.process.plm.util; + +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.JCheckBox; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +public class CTable extends JTable implements TableModelListener{ + Map map; + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + TextAreaCellEditor cellEditor = new TextAreaCellEditor(); + ComboBoxCellEditor comboBoxCellEditor = new ComboBoxCellEditor(new Object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); + +// CheckBoxCellEditor checkBoxCellEditor = new CheckBoxCellEditor(this); +// TableCellCheckboxRenderer checkboxRenderer = new TableCellCheckboxRenderer(this); + +// @Override +// public java.awt.Component prepareRenderer(javax.swing.table.TableCellRenderer renderer, int row, int column) { +// int modelRow = convertRowIndexToModel(row); +// int modelColumn = convertColumnIndexToModel(column); +// java.awt.Component comp = super.prepareRenderer(renderer, row, column); +// if (!isRowSelected(modelRow)) { +// if (modelRow == 1 && modelColumn == 1) //此处加入条件判断 +// comp.setBackground(Color.GRAY); +// else //不符合条件的保持原表格样式 +// comp.setBackground(Color.WHITE); +// } +// return comp; +// } + public CTable(TableModel model) { + super(model); + setUI(new CTUI()); + getTableHeader().setReorderingAllowed(false); + setCellSelectionEnabled(true); + setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); + + 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; + } + + // @Override + // protected void processKeyEvent(KeyEvent keyevent) { + // // TODO Auto-generated method stub + // if(keyevent.getKeyCode()==KeyEvent.VK_ENTER){ + // if(keyevent.isControlDown()) + // { + // System.out.println(1); + // } + // this.editCellAt(this.getSelectedRow(),this.getSelectedColumn()); + // } + // } + + 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(); + 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; + } + + // 隐藏列 + public void HiddenCell(int column) { + TableColumn tc = this.getTableHeader().getColumnModel().getColumn(column); + tc.setMaxWidth(0); + tc.setPreferredWidth(0); + tc.setWidth(0); + tc.setMinWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + } + + 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); + } + +// @Override +// public TableCellEditor getCellEditor(int row, int column) { +// if (this.getColumnName(column).equals("严重度S") || this.getColumnName(column).equals("频度数O") +// || this.getColumnName(column).equals("探测度D")) { +// return comboBoxCellEditor; +// } else if (this.getColumnName(column).equals("4")||this.getColumnName(column).equals("二")) { +// return checkBoxCellEditor; +// } else { +// return cellEditor; +// } +// } + +// @Override +// public TableCellRenderer getCellRenderer(int row, int column) { +// // TODO Auto-generated method stub +// if (this.getColumnName(column).equals("严重度S") || this.getColumnName(column).equals("频度数O") +// || this.getColumnName(column).equals("探测度D")) { +// return super.getCellRenderer(row, column); +// } else if (this.getColumnName(column).equals("选择")||this.getColumnName(column).equals("二")) { +// return checkboxRenderer; +// } else { +// return renderer; +// } +// +// } + + public void setRowHeight(int row, int rowHeight) { + super.setRowHeight(row, rowHeight); + } + + public void selectAllOrNull(String value) { + // Select All. The last column + for (int index = 0; index < getRowCount(); index++) { + this.setValueAt(value, index, this.getColumnCount() - 3); + } + } + + // @Override + // public boolean isCellSelected(int i, int j) { + // if( i == 1 || i == 3) + // { + // //this.clearSelection(); + // return false; + // } + // else + // { + // return super.isCellSelected(i, j); + // } + // } + +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/CTextField.java b/src/com/connor/renben/process/plm/util/CTextField.java new file mode 100644 index 0000000..5e22e87 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CTextField.java @@ -0,0 +1,39 @@ +package com.connor.renben.process.plm.util; + +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +import javax.swing.JTextField; + +import com.teamcenter.rac.util.MessageBox; + +public class CTextField extends JTextField implements FocusListener { + + public CTextField() { + // TODO Auto-generated constructor stub + this.addFocusListener(this); + } + + public CTextField(String s) { + super(s); + this.setToolTipText(this.getText()); + this.addFocusListener(this); + } + + @Override + public void focusGained(FocusEvent focusevent) { + // TODO Auto-generated method stub + // System.out.println(1); + + } + + @Override + public void focusLost(FocusEvent focusevent) { + // TODO Auto-generated method stub + // System.out.println(2); + this.setToolTipText(this.getText()); + } + +} diff --git a/src/com/connor/renben/process/plm/util/CTextFieldButton.java b/src/com/connor/renben/process/plm/util/CTextFieldButton.java new file mode 100644 index 0000000..a34e234 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CTextFieldButton.java @@ -0,0 +1,73 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JTextField; + +public class CTextFieldButton extends JTextField { + + private JButton choose = new JButton() { + // 打印容器 + @Override + public void paint(Graphics g) { + super.paint(g); + int width = 3; + int height = 3; + Rectangle rect = g.getClipBounds();// 返回当前剪贴区域边界矩形 + int x = rect.width / 3; + int y = rect.height / 2; + for (int i = 0; i < 3;) { + g.fillOval(++i * x, y, width, height);// 使用当前颜色填充外接指定矩形框的椭圆 + } + } + + // 容器首选大小 + @Override + public Dimension getPreferredSize() { + Dimension dimension = CTextFieldButton.super.getPreferredSize(); + dimension.height -= 6; + dimension.width = dimension.height; + return dimension; + } + }; + + private CTextFieldButton self = this; + + public CTextFieldButton(int column) { + super(column); + initButtonTest(); + } + + public CTextFieldButton() { + super(); + initButtonTest(); + } + + private void initButtonTest() { + choose.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionevent) { + // System.out.println(1); + CTextFieldButton.this.handleClick(self); + } + }); + // 如果没有这句话,按钮无法显示,原因是默认覆盖 + this.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); + } + + // JComponent通知此组件它现在已有了一个父组件 + @Override + public void addNotify() { + super.addNotify(); + add(choose);// Container中方法将指定组件追加到此容器的尾部 + } + + public void handleClick(CTextFieldButton jbuttonTest) { + } +} diff --git a/src/com/connor/renben/process/plm/util/CTreeNode.java b/src/com/connor/renben/process/plm/util/CTreeNode.java new file mode 100644 index 0000000..4af1d61 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CTreeNode.java @@ -0,0 +1,21 @@ +//package com.connor.renben.process.plm.util; +// +//import javax.swing.tree.DefaultMutableTreeNode; +// +// +//public class CTreeNode extends DefaultMutableTreeNode { +// +// public CTreeNode(Object arg0) { +// // TODO Auto-generated constructor stub +// super(arg0); +// } +// +// @Override +// public String toString() { +// // TODO Auto-generated method stub +// if (this.getUserObject() instanceof TreeBean) { +// return ((TreeBean) this.getUserObject()).getName(); +// } +// return super.toString(); +// } +//} diff --git a/src/com/connor/renben/process/plm/util/CellSpan.java b/src/com/connor/renben/process/plm/util/CellSpan.java new file mode 100644 index 0000000..0259381 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CellSpan.java @@ -0,0 +1,15 @@ +package com.connor.renben.process.plm.util; + +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/renben/process/plm/util/ChangeCharset.java b/src/com/connor/renben/process/plm/util/ChangeCharset.java new file mode 100644 index 0000000..0c471f4 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ChangeCharset.java @@ -0,0 +1,107 @@ +package com.connor.renben.process.plm.util; + +import java.io.UnsupportedEncodingException; + +/** + * 转换字符串的编码 + * + * @author joe + * + */ + +public class ChangeCharset { + /** 7位ASCII字符,也叫作ISO646-US、Unicode字符集的基本拉丁块 */ + public static final String US_ASCII = "US-ASCII"; + /** ISO拉丁字母表 No.1,也叫做ISO-LATIN-1 */ + public static final String ISO_8859_1 = "ISO-8859-1"; + /** 8 位 UCS 转换格式 */ + public static final String UTF_8 = "UTF-8"; + /** 16 位 UCS 转换格式,Big Endian(最低地址存放高位字节)字节顺序 */ + public static final String UTF_16BE = "UTF-16BE"; + /** 16 位 UCS 转换格式,Litter Endian(最高地址存放地位字节)字节顺序 */ + public static final String UTF_16LE = "UTF-16LE"; + /** 16 位 UCS 转换格式,字节顺序由可选的字节顺序标记来标识 */ + public static final String UTF_16 = "UTF-16"; + /** 中文超大字符集 **/ + public static final String GBK = "GBK"; + + public static final String GB2312 = "GB2312"; + + /** 将字符编码转换成US-ASCII码 */ + public String toASCII(String str) throws UnsupportedEncodingException { + return this.changeCharset(str, US_ASCII); + } + + /** 将字符编码转换成ISO-8859-1 */ + public String toISO_8859_1(String str) throws UnsupportedEncodingException { + return this.changeCharset(str, ISO_8859_1); + } + + /** 将字符编码转换成UTF-8 */ + public String toUTF_8(String str) throws UnsupportedEncodingException { + return this.changeCharset(str, UTF_8); + } + + /** 将字符编码转换成UTF-16BE */ + public String toUTF_16BE(String str) throws UnsupportedEncodingException { + return this.changeCharset(str, UTF_16BE); + } + + /** 将字符编码转换成UTF-16LE */ + public String toUTF_16LE(String str) throws UnsupportedEncodingException { + return this.changeCharset(str, UTF_16LE); + } + + /** 将字符编码转换成UTF-16 */ + public String toUTF_16(String str) throws UnsupportedEncodingException { + return this.changeCharset(str, UTF_16); + } + + /** 将字符编码转换成GBK */ + public String toGBK(String str) throws UnsupportedEncodingException { + return this.changeCharset(str, GBK); + } + + /** 将字符编码转换成GB2312 */ + public String toGB2312(String str) throws UnsupportedEncodingException { + return this.changeCharset(str, GB2312); + } + + /** + * 字符串编码转换的实现方法 + * + * @param str + * 待转换的字符串 + * @param newCharset + * 目标编码 + */ + public String changeCharset(String str, String newCharset) + throws UnsupportedEncodingException { + if (str != null) { + // 用默认字符编码解码字符串。与系统相关,中文windows默认为GB2312 + byte[] bs = str.getBytes(); + return new String(bs, newCharset); // 用新的字符编码生成字符串 + } + return null; + } + + /** + * 字符串编码转换的实现方法 + * + * @param str + * 待转换的字符串 + * @param oldCharset + * 源字符集 + * @param newCharset + * 目标字符集 + */ + public String changeCharset(String str, String oldCharset, String newCharset) + throws UnsupportedEncodingException { + if (str != null) { + // 用源字符编码解码字符串 + byte[] bs = str.getBytes(oldCharset); + return new String(bs, newCharset); + } + return null; + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/CheckBoxCellEditor.java b/src/com/connor/renben/process/plm/util/CheckBoxCellEditor.java new file mode 100644 index 0000000..93c857d --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CheckBoxCellEditor.java @@ -0,0 +1,118 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.EventObject; + +import javax.swing.JCheckBox; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.event.CellEditorListener; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellEditor; + +public class CheckBoxCellEditor extends JCheckBox implements TableCellEditor { + + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + private JTableHeader tableHeader; + private DefaultTableModel tableModel; + + public CheckBoxCellEditor(final CTable table) { + super(); + this.tableModel = (DefaultTableModel) table.getModel(); + this.tableHeader = table.getTableHeader(); + this.setName("4"); + // selectBox = new JCheckBox(tableModel.getColumnName(1)); + this.setSelected(false); + tableHeader.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() > 0) { + // 获得选中列 + int selectColumn = tableHeader.columnAtPoint(e.getPoint()); + if (table.getColumnName(selectColumn).equals("4")) { + boolean value = !CheckBoxCellEditor.this.isSelected(); + CheckBoxCellEditor.this.setSelected(value); + table.selectAllOrNull(value ? "1" : "0"); + tableHeader.repaint(); + } + } + } + }); + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + fireEditingStopped(); + } + }); + } + + public void addCellEditorListener(CellEditorListener listener) { + listenerList.add(CellEditorListener.class, listener); + } + + public void removeCellEditorListener(CellEditorListener listener) { + listenerList.remove(CellEditorListener.class, listener); + } + + protected void fireEditingStopped() { + System.out.println(this.isSelected() ? "1" : "0"); + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + listener = (CellEditorListener) listeners[i + 1]; + listener.editingStopped(changeEvent); + } + } + } + + protected void fireEditingCanceled() { + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + listener = (CellEditorListener) listeners[i + 1]; + listener.editingCanceled(changeEvent); + } + } + } + + public void cancelCellEditing() { + fireEditingCanceled(); + } + + public boolean stopCellEditing() { + // this.addItem(this.getSelectedItem()); + fireEditingStopped(); + return true; + } + + public boolean isCellEditable(EventObject event) { + return true; + } + + public boolean shouldSelectCell(EventObject event) { + return true; + } + + public Object getCellEditorValue() { + return this.isSelected() ? "1" : "0"; + } + + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + +// String valueStr = (String) value; +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // 表头标签剧中 + this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 + this.setBorderPainted(true); + this.setSelected(value.toString().equals("1")); + return this; + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/CheckListCellRenderer.java b/src/com/connor/renben/process/plm/util/CheckListCellRenderer.java new file mode 100644 index 0000000..97041fb --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CheckListCellRenderer.java @@ -0,0 +1,47 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Component; +import java.io.Serializable; + +import javax.swing.JCheckBox; +import javax.swing.JList; +import javax.swing.ListCellRenderer; +import javax.swing.UIManager; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; + +public class CheckListCellRenderer extends JCheckBox implements ListCellRenderer,Serializable{ + + protected static Border noFocusBorder; + + + public CheckListCellRenderer() { + super(); + if(noFocusBorder == null) { + noFocusBorder = new EmptyBorder(1,1,1,1); + } + setOpaque(true); + setBorder(noFocusBorder); + } + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + setComponentOrientation(list.getComponentOrientation()); + if(isSelected) { + setBackground(list.getSelectionBackground()); + setForeground(list.getSelectionForeground()); + } else { + setBackground(list.getBackground()); + setForeground(list.getForeground()); + } + if (value instanceof CheckValue) { + CheckValue ckValue = (CheckValue) value; + this.setText(ckValue.value == null ? "" : ckValue.value); + this.setSelected(ckValue.bolValue); + } + setEnabled(list.isEnabled()); + setFont(list.getFont()); + setBorder((cellHasFocus) ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder); + return this; + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/CheckValue.java b/src/com/connor/renben/process/plm/util/CheckValue.java new file mode 100644 index 0000000..d463bfc --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CheckValue.java @@ -0,0 +1,12 @@ +package com.connor.renben.process.plm.util; + +public class CheckValue { + public boolean bolValue = false; + public String value = null; + public CheckValue() { + } + public CheckValue(boolean bolValue, String value) { + this.bolValue = bolValue; + this.value = value; + } +} diff --git a/src/com/connor/renben/process/plm/util/CollectControlPlan.java b/src/com/connor/renben/process/plm/util/CollectControlPlan.java new file mode 100644 index 0000000..44956ce --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CollectControlPlan.java @@ -0,0 +1,185 @@ +package com.connor.renben.process.plm.util; + +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import java.util.UUID; + +import com.connor.hs2.plm.PFMEA.design.SqlUtilT; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class CollectControlPlan { + private TCSession session; + private String kzjhType; + private TCComponentItem meprocessItem; + + + public CollectControlPlan(TCSession session, String kzjhType,TCComponentItem meprocessItem) { + // TODO Auto-generated constructor stub + this.session = session; + this.kzjhType = kzjhType; + this.meprocessItem = meprocessItem; + CollectData(meprocessItem); + } + + public void CollectData(TCComponentItem item) { + // TODO Auto-generated method stub + SqlUtilT.getTCConnection(); + ResultSet rs = null; + ResultSet rs2 = null; + InputStream input = null; + try { + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + //获取BOM下的所有的子BOM对象 + TCComponent[] components = item.getLatestItemRevision().getRelatedComponents("ps_children"); + for (int i = 0; i < components.length; i++) { + System.out.println(components[i].getType()); + //如果是工艺对象 + if(components[i].getType().indexOf("MEProcess") >= 0) + { + //判断生产控制计划是否有数据 + String meprocessUid = components[i].getUid(); + if(components[i] instanceof TCComponentItemRevision) + { + meprocessUid = ((TCComponentItemRevision) components[i]).getItem().getUid(); + } + String scSql = String.format("select * from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and type = \'RB3_SCKZJH\'", meprocessUid); + rs = SqlUtilT.read(scSql); + //如果生产控制计划下有数据 + if(rs.next()) + { + //根据查找编号将总工艺中包含子工艺的工序移除 + String deleteSql = String.format("delete from rb3_controlplan " + + "where PROCESSPUID = \'%s\' and TYPE = \'%s\' and RB3_GYBH in (" + + "select RB3_GYBH from rb3_controlplan where PROCESSPUID = \'%s\' and TYPE = \'RB3_SCKZJH\' group by RB3_GYBH)", + meprocessItem.getUid(),kzjhType, meprocessUid); + System.out.println(deleteSql+"==========="); + SqlUtilT.delete2(deleteSql); + List> dataList = new ArrayList>(); + do { + List rowList = new ArrayList(); + rowList.add(rs.getString(2)); + rowList.add(rs.getString(3));rowList.add(rs.getString(4)); + rowList.add(rs.getString(5));rowList.add(rs.getString(6)); + rowList.add(rs.getString(7));rowList.add(rs.getString(8)); + rowList.add(rs.getString(9));rowList.add(rs.getString(10)); + rowList.add(rs.getString(11));rowList.add(rs.getString(12)); + rowList.add(rs.getString(13));rowList.add(rs.getString(14)); + rowList.add(rs.getString(15));rowList.add(rs.getString(16)); + rowList.add(rs.getString(17));rowList.add(rs.getString(18)); + rowList.add(rs.getString(19));rowList.add(rs.getString(20)); + rowList.add(rs.getString(21));rowList.add(rs.getString(22)); + rowList.add(rs.getString(23));rowList.add(rs.getString(24)); + rowList.add(rs.getString(25));rowList.add(rs.getString(26)); + rowList.add(rs.getString(27));rowList.add(rs.getString(28)); + dataList.add(rowList); + } while (rs.next()); + for (int j = 0; j < dataList.size(); j++) { + UUID scckzjhUid = UUID.randomUUID(); +// // 将数据插入到控制计划 + String insertSQL = pro.getProperty("INSERTSQL"); +// // 插入生产控制计划工序 + SqlUtilT.write( + new String[] { + scckzjhUid.toString().replace("-", ""), + meprocessItem.getUid(),dataList.get(j).get(1), + dataList.get(j).get(2),dataList.get(j).get(3), + dataList.get(j).get(4),dataList.get(j).get(5), + dataList.get(j).get(6),dataList.get(j).get(7), + dataList.get(j).get(8),dataList.get(j).get(9), + dataList.get(j).get(10),dataList.get(j).get(11), + dataList.get(j).get(12),dataList.get(j).get(13), + dataList.get(j).get(14),dataList.get(j).get(15), + dataList.get(j).get(16),dataList.get(j).get(17), + dataList.get(j).get(18),dataList.get(j).get(19), + dataList.get(j).get(20),dataList.get(j).get(21), + dataList.get(j).get(22),dataList.get(j).get(23), + dataList.get(j).get(24),dataList.get(j).get(25), + dataList.get(i).get(26),kzjhType,"0","0","","0" }, + insertSQL); + } + } + else + { + //根据查找编号将总工艺中包含子工艺的工序移除 + String deleteSql = String.format("delete from rb3_controlplan " + + "where PROCESSPUID = \'%s\' and TYPE = \'%s\' and RB3_GYBH in (" + + "select RB3_GYBH from rb3_controlplan where PROCESSPUID = \'%s\' and TYPE = \'RB3_SSCKZJH\' group by RB3_GYBH)", + meprocessItem.getUid(),kzjhType, meprocessUid); + System.out.println(deleteSql+"==========="); + SqlUtilT.delete2(deleteSql); + //判断试生产控制计划是否有数据 + String sscSql = String.format("select * from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and type = \'RB3_SSCKZJH\'", meprocessUid); + rs2 = SqlUtilT.read(sscSql); + List> dataList = new ArrayList>(); + while (rs2.next()) { + List rowList = new ArrayList(); + rowList.add(rs2.getString(2)); + rowList.add(rs2.getString(3));rowList.add(rs2.getString(4)); + rowList.add(rs2.getString(5));rowList.add(rs2.getString(6)); + rowList.add(rs2.getString(7));rowList.add(rs2.getString(8)); + rowList.add(rs2.getString(9));rowList.add(rs2.getString(10)); + rowList.add(rs2.getString(11));rowList.add(rs2.getString(12)); + rowList.add(rs2.getString(13));rowList.add(rs2.getString(14)); + rowList.add(rs2.getString(15));rowList.add(rs2.getString(16)); + rowList.add(rs2.getString(17));rowList.add(rs2.getString(18)); + rowList.add(rs2.getString(19));rowList.add(rs2.getString(20)); + rowList.add(rs2.getString(21));rowList.add(rs2.getString(22)); + rowList.add(rs2.getString(23));rowList.add(rs2.getString(24)); + rowList.add(rs2.getString(25));rowList.add(rs2.getString(26)); + rowList.add(rs2.getString(27));rowList.add(rs2.getString(28)); + dataList.add(rowList); + } + for (int j = 0; j < dataList.size(); j++) { + UUID scckzjhUid = UUID.randomUUID(); +// // 将数据插入到控制计划 + String insertSQL = pro.getProperty("INSERTSQL"); +// // 插入生产控制计划工序 + SqlUtilT.write( + new String[] { + scckzjhUid.toString().replace("-", ""), + meprocessItem.getUid(),dataList.get(j).get(1), + dataList.get(j).get(2),dataList.get(j).get(3), + dataList.get(j).get(4),dataList.get(j).get(5), + dataList.get(j).get(6),dataList.get(j).get(7), + dataList.get(j).get(8),dataList.get(j).get(9), + dataList.get(j).get(10),dataList.get(j).get(11), + dataList.get(j).get(12),dataList.get(j).get(13), + dataList.get(j).get(14),dataList.get(j).get(15), + dataList.get(j).get(16),dataList.get(j).get(17), + dataList.get(j).get(18),dataList.get(j).get(19), + dataList.get(j).get(20),dataList.get(j).get(21), + dataList.get(j).get(22),dataList.get(j).get(23), + dataList.get(j).get(24),dataList.get(j).get(25), + dataList.get(i).get(26),kzjhType,"0","0","","0" }, + insertSQL); + } + } + if(components[i] instanceof TCComponentItemRevision) + { + CollectData(((TCComponentItemRevision)components[i]).getItem()); + } + else + { + CollectData((TCComponentItem)components[i]); + } + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/renben/process/plm/util/CollectPfmea.java b/src/com/connor/renben/process/plm/util/CollectPfmea.java new file mode 100644 index 0000000..5a4ea87 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CollectPfmea.java @@ -0,0 +1,5 @@ +package com.connor.renben.process.plm.util; + +public class CollectPfmea { + +} diff --git a/src/com/connor/renben/process/plm/util/ComboBoxCellEditor.java b/src/com/connor/renben/process/plm/util/ComboBoxCellEditor.java new file mode 100644 index 0000000..e8a895e --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ComboBoxCellEditor.java @@ -0,0 +1,88 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.EventObject; + +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.event.CellEditorListener; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.TableCellEditor; + +public class ComboBoxCellEditor extends JComboBox implements TableCellEditor { + + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + + public ComboBoxCellEditor(Object[] itmes) { + super(); + for (int i = 0; i < itmes.length; i++) { + addItem(itmes[i]); + } + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + fireEditingStopped(); + } + }); + } + + public void addCellEditorListener(CellEditorListener listener) { + listenerList.add(CellEditorListener.class, listener); + } + + public void removeCellEditorListener(CellEditorListener listener) { + listenerList.remove(CellEditorListener.class, listener); + } + + protected void fireEditingStopped() { + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + listener = (CellEditorListener) listeners[i + 1]; + listener.editingStopped(changeEvent); + } + } + } + + protected void fireEditingCanceled() { + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + listener = (CellEditorListener) listeners[i + 1]; + listener.editingCanceled(changeEvent); + } + } + } + + public void cancelCellEditing() { + fireEditingCanceled(); + } + + public boolean stopCellEditing() { + fireEditingStopped(); + return true; + } + + public boolean isCellEditable(EventObject event) { + return true; + } + + public boolean shouldSelectCell(EventObject event) { + return true; + } + + public Object getCellEditorValue() { + return getSelectedItem(); + } + + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, int row, int column) { + this.setSelectedItem(value); + return this; + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/CopyOfSaveControlPlan.java b/src/com/connor/renben/process/plm/util/CopyOfSaveControlPlan.java new file mode 100644 index 0000000..d52ebff --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CopyOfSaveControlPlan.java @@ -0,0 +1,368 @@ +//package com.connor.renben.process.plm.util; +// +//import java.io.BufferedInputStream; +//import java.io.IOException; +//import java.io.InputStream; +//import java.sql.ResultSet; +//import java.util.ArrayList; +//import java.util.Arrays; +//import java.util.List; +//import java.util.Properties; +//import java.util.UUID; +// +//import com.connor.hs2.plm.PFMEA.design.SqlUtilT; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentItem; +//import com.teamcenter.rac.kernel.TCPreferenceService; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.util.MessageBox; +// +///** +// * 保存数据到控制计划表 +// * @author Administrator +// * +// */ +//public class CopyOfSaveControlPlan { +// private TCSession session; +// private TCComponentItem item; +// private List> properties = new ArrayList>(); +// private List> dataList = new ArrayList>();// 表格中的数据 +// +// public CopyOfSaveControlPlan(TCSession session,TCComponentItem item) { +// // TODO Auto-generated constructor stub +// this.session = session; +// this.item = item; +// } +// /** +// * 获取没有检验项的工序 +// * @param name 首选项名称 +// * @return 没有检验项的工序名称 +// */ +// private List getMeopNames(String name) { +// // TODO Auto-generated method stub +// String[] values = null; +// if(name != null) +// { +// TCPreferenceService service = this.session.getPreferenceService(); +// String[] props = service.getStringArray(TCPreferenceService.TC_preference_site, name); +// if(props != null || props.length>0) +// { +// values = props; +// } +// } +// else +// { +// MessageBox.post("未找首选项!", "错误!", MessageBox.ERROR); +// } +// return Arrays.asList(values); +// } +// public void insertData() { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// ResultSet result = null; +// ResultSet resultSet = null; +// InputStream input = null; +// try { +// properties = TMomMethodUtil.getBomPropertys(session, item); +// List meopNameList = getMeopNames("RB3_CONCEAL_MEOP_NAME"); +// String itemUid = item.getUid(); +// //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List kzjhList = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// kzjhList.add((TCComponentItem)kzjh[i]); +// } +// } +// SqlUtilT.getTCConnection(); +// input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// Properties pro = new Properties(); +// pro.load(input); +// // 查询数据库中的数据 +// String sql = String.format(pro.getProperty("BOMCHECKSAVESELECT"), +// itemUid, "检验(%"); +// rs = SqlUtilT.read(sql); +// while (rs.next()) { +// List rowList = new ArrayList(); +// rowList.add(rs.getString("RB3_MEOPID") == null ? "" : rs.getString("RB3_MEOPID")); +// //rowList.add(rs.getString("RB3_MEOPID")); +// rowList.add(rs.getString("RB3_GYBH")); +// rowList.add(rs.getString("RB3_GCMC")); +// rowList.add(rs.getString("RB3_JQSB") == null ? "" : rs.getString("RB3_JQSB")); +// dataList.add(rowList); +// } +// if (dataList == null && dataList.size() == 0) { +// for (int j = 0; j < properties.size(); j++) { +// if(kzjhList.size() == 0) +// { +// UUID kzjhUid = UUID.randomUUID(); +//// UUID ssckzjhUid = UUID.randomUUID(); +//// UUID yjkzjhUid = UUID.randomUUID(); +// // 将数据插入到控制计划 +// String insertSQL = pro.getProperty("INSERTSQL"); +// Integer number = Integer.parseInt(properties.get(j).get(1) +// .toString()) % 10 == 0 ? Integer +// .parseInt(properties.get(j).get(1).toString()) + 5 +// : Integer.parseInt(properties.get(j).get(1) +// .toString()) + 1; +// String name = "检验(" + properties.get(j).get(2).toString() +// + ")"; +// // 插入生产控制计划工序 +// SqlUtilT.write( +// new String[] { +// kzjhUid.toString().replace("-", ""), +// itemUid, properties.get(j).get(0), +// properties.get(j).get(1), +// properties.get(j).get(2), +// properties.get(j).get(3), "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "RB3_YJKZJH","0","0","","0" }, +// insertSQL); +// if(!meopNameList.contains(properties.get(j).get(2).toString())) +// { +// // 插入生产控制计划巡检项 +// SqlUtilT.write( +// new String[] { +// UUID.randomUUID().toString() +// .replace("-", ""), itemUid, +// properties.get(j).get(0), +// number.toString(), name, +// "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "RB3_YJKZJH","0","0","","0" }, +// insertSQL); +// } +// } +// else +// { +// for (int i = 0; i < kzjhList.size(); i++) { +// UUID kzjhUid = UUID.randomUUID(); +//// UUID ssckzjhUid = UUID.randomUUID(); +//// UUID yjkzjhUid = UUID.randomUUID(); +// // 将数据插入到控制计划 +// String insertSQL = pro.getProperty("INSERTSQL"); +// Integer number = Integer.parseInt(properties.get(j).get(1) +// .toString()) % 10 == 0 ? Integer +// .parseInt(properties.get(j).get(1).toString()) + 5 +// : Integer.parseInt(properties.get(j).get(1) +// .toString()) + 1; +// String name = "检验(" + properties.get(j).get(2).toString() +// + ")"; +// // 插入生产控制计划工序 +// SqlUtilT.write( +// new String[] { +// kzjhUid.toString().replace("-", ""), +// itemUid, properties.get(j).get(0), +// properties.get(j).get(1), +// properties.get(j).get(2), +// properties.get(j).get(3), "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", kzjhList.get(i).getType().toUpperCase(),"0","","0" }, +// insertSQL); +// if(!meopNameList.contains(properties.get(j).get(2).toString())) +// { +// // 插入生产控制计划巡检项 +// SqlUtilT.write( +// new String[] { +// UUID.randomUUID().toString() +// .replace("-", ""), itemUid, +// properties.get(j).get(0), +// number.toString(), name, +// properties.get(j).get(3), "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", kzjhList.get(i).getType().toUpperCase(),"0","","0" }, +// insertSQL); +// } +// } +// } +// } +// } else { +// // 修改表中相应的工序名称 +// for (int i = 0; i < dataList.size(); i++) { +// for (int j = 0; j < properties.size(); j++) { +// if (dataList.get(i).get(0) +// .equals(properties.get(j).get(0)) +// && (!dataList.get(i).get(1) +// .equals(properties.get(j).get(1)) +// || !dataList +// .get(i) +// .get(2) +// .equals(properties.get(j) +// .get(2)) || !dataList +// .get(i).get(3) +// .equals(properties.get(j).get(3)))) { +// Integer number = Integer.parseInt(properties.get(j) +// .get(1).toString()) % 10 == 0 ? Integer +// .parseInt(properties.get(j).get(1) +// .toString()) + 5 : Integer +// .parseInt(properties.get(j).get(1) +// .toString()) + 1; +// String name = "检验(" +// + properties.get(j).get(2).toString() + ")"; +// // 获取数据库连接 +// // 更新自检 +// String updateSQL = String.format( +// pro.getProperty("BOMCHECKSAVEUPDATE"), +// itemUid, dataList.get(i).get(0), "检验(%"); +// // 更新巡检 +// String updateSQL1 = String.format( +// pro.getProperty("BOMCHECKSAVEUPDATE2"), +// itemUid, dataList.get(i).get(0), "检验(%"); +// SqlUtilT.update(new String[] { +// properties.get(j).get(1), +// properties.get(j).get(2), +// properties.get(j).get(3) }, updateSQL); +// SqlUtilT.update(new String[] { number.toString(), +// name, +// ""}, updateSQL1); +// } +// // if(dataList.get(i).get(1).equals(properties[j][1].getStringValue()) +// // && !dataList.get(i).get(0).equals(properties[j][0])) +// // { +// // //获取数据库连接 +// // String updateSQL = +// // String.format("update CONTROLPLAN set RB3_GYBH = ? where PROCESSPUID = \'%s\' and RB3_GCMC = \'%s\'",itemUid,dataList.get(i).get(1)) +// // ; +// // SqlUtilT.update(new String[]{ +// // properties[j][0].getStringValue() },updateSQL); +// // } +// } +// } +// // 添加工序 +// // 查询数据库中的数据 +// result = SqlUtilT.read(sql); +// List indexList = new ArrayList(); +// while (result.next()) { +// indexList.add(result.getString("RB3_MEOPID")); +// } +// for (int i = 0; i < properties.size(); i++) { +// if (!indexList.contains(properties.get(i).get(0))) { +// if(kzjhList.size() == 0) +// { +// UUID kzjhUid = UUID.randomUUID(); +// // 将数据插入到表中 +// String insertSQL = pro.getProperty("INSERTSQL"); +// Integer number = Integer.parseInt(properties.get(i) +// .get(1).toString()) % 10 == 0 ? Integer +// .parseInt(properties.get(i).get(1).toString()) + 5 +// : Integer.parseInt(properties.get(i).get(1) +// .toString()) + 1; +// String name = "检验(" +// + properties.get(i).get(2).toString() + ")"; +// // 插入控制计划工序 +// SqlUtilT.write(new String[] { +// kzjhUid.toString().replace("-", ""), itemUid, +// properties.get(i).get(0), +// properties.get(i).get(1), +// properties.get(i).get(2), +// properties.get(i).get(3), "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "RB3_YJKZJH","0","0","","0" },insertSQL); +// if(!meopNameList.contains(properties.get(i).get(2).toString())) +// { +// // 插入控制计划巡检项 +// SqlUtilT.write( +// new String[] { +// UUID.randomUUID().toString() +// .replace("-", ""), itemUid, +// properties.get(i).get(0), +// number.toString(), name, +// "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", +// "RB3_YJKZJH","0","0","","0" },insertSQL); +// } +// } +// else +// { +// for (int k = 0; k < kzjhList.size(); k++) { +// UUID kzjhUid = UUID.randomUUID(); +// // 将数据插入到表中 +// String insertSQL = pro.getProperty("INSERTSQL"); +// Integer number = Integer.parseInt(properties.get(i) +// .get(1).toString()) % 10 == 0 ? Integer +// .parseInt(properties.get(i).get(1).toString()) + 5 +// : Integer.parseInt(properties.get(i).get(1) +// .toString()) + 1; +// String name = "检验(" +// + properties.get(i).get(2).toString() + ")"; +// // 插入控制计划工序 +// SqlUtilT.write(new String[] { +// kzjhUid.toString().replace("-", ""), itemUid, +// properties.get(i).get(0), +// properties.get(i).get(1), +// properties.get(i).get(2), +// properties.get(i).get(3), "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", kzjhList.get(k).getType().toUpperCase(),"0","0","","0" }, insertSQL); +// if(!meopNameList.contains(properties.get(i).get(2).toString())) +// { +// // 插入控制计划巡检项 +// SqlUtilT.write( +// new String[] { +// UUID.randomUUID().toString() +// .replace("-", ""), itemUid, +// properties.get(i).get(0), +// number.toString(), name, +// "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", +// kzjhList.get(k).getType().toUpperCase(),"0","0","","0" }, insertSQL); +// } +// } +// } +// } +// } +// // 删除表中相应的工序 +// StringBuffer sb = new StringBuffer(); +// sb.append("("); +// for (int i = 0; i < properties.size(); i++) { +// sb.append("\'" + properties.get(i).get(0) + "\',"); +// } +// // 获取数据库连接 +// String selectSql = String +// .format(pro.getProperty("BOMCHECKSAVESELECT2"), +// itemUid, +// sb.toString().substring(0, sb.length() - 1) +// + ")"); +// resultSet = SqlUtilT.read(selectSql); +// List deleteList = new ArrayList(); +// while (resultSet.next()) { +// deleteList.add(resultSet.getString("RB3_MEOPID")); +// } +// if (deleteList != null && deleteList.size() > 0) { +// for (int i = 0; i < deleteList.size(); i++) { +// String deleteSQL = String.format( +// pro.getProperty("DELETE"), deleteList.get(i), +// itemUid); +// SqlUtilT.delete(deleteSQL); +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } finally { +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// if (result != null) { +// SqlUtilT.free(result); +// } +// if (resultSet != null) { +// SqlUtilT.free(resultSet); +// } +// if (input != null) { +// try { +// input.close(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// SqlUtilT.freeAll(); +// } +// } +//} diff --git a/src/com/connor/renben/process/plm/util/CreateItemHandler.java b/src/com/connor/renben/process/plm/util/CreateItemHandler.java new file mode 100644 index 0000000..a34ecd5 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CreateItemHandler.java @@ -0,0 +1,18 @@ +package com.connor.renben.process.plm.util; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +public class CreateItemHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + String commandId = arg0.getCommand().getId(); + CreateNewBOHandler handler = new CreateNewBOHandler(commandId); + handler.execute(arg0); + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/util/CreateNewBOHandler.java b/src/com/connor/renben/process/plm/util/CreateNewBOHandler.java new file mode 100644 index 0000000..ca9110c --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CreateNewBOHandler.java @@ -0,0 +1,207 @@ +package com.connor.renben.process.plm.util; + +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.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.handlers.HandlerUtil; +import org.eclipse.jface.dialogs.MessageDialog; +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 com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.aifrcp.SelectionHelper; +import com.teamcenter.rac.kernel.TCSession; + +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.ui.commands.handlers.NewBOHandler; + +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; + +/** + * Our sample handler extends AbstractHandler, an IHandler base class. + * + * @see org.eclipse.core.commands.IHandler + * @see org.eclipse.core.commands.AbstractHandler + */ +public class CreateNewBOHandler extends AbstractHandler implements +IExecutableExtension { +private String itemtype; + +public CreateNewBOHandler(String itemtype) { +this.itemtype = itemtype; +} + +private class CreateNewBOSWTDialog implements Runnable { + +public void run() { + NewBOWizard newbowizard = (NewBOWizard) getWizard(); + if (newbowizard == null) + newbowizard = new NewBOWizard(wizardId); + m_boModel.setSession(session); + m_boModel.reInitializeTransientData(); + newbowizard.setBOModel(m_boModel); + newbowizard.setShell(m_shell); + newbowizard.setParentFrame(AIFUtility.getActiveDesktop()); + newbowizard.setTargetArray(selectedCmps); + newbowizard.setCurrentSelection(m_currentSelection); + newbowizard.setWindowTitle(getWizardTitle()); + newbowizard.setRevisionFlag(m_revisionFlag); + newbowizard.setDefaultType(m_type); + m_boModel.setRevisionFlag(m_revisionFlag); + // newbowizard.setWizardId("123"); + Shell shell = UIUtilities.getCurrentModalShell(); + dialog = new BaseExternalWizardDialog(m_shell, newbowizard); + dialog.create(); + newbowizard.retrievePersistedDialogSettings(dialog); + newbowizard.setWizardDialog(dialog); + UIUtilities.setCurrentModalShell(dialog.getShell()); + dialog.open(); +// InterfaceAIFComponent[] aifComponent = m_boModel.getTargetArray(); +// if(aifComponent != null && aifComponent.length > 0) +// { +// com.teamcenter.rac.common.Activator.getDefault() +// .openPerspective("com.teamcenter.rac.cme.mpp.MSEPerspective"); +// com.teamcenter.rac.common.Activator.getDefault().openComponents( +// "com.teamcenter.rac.cme.mpp.MSEPerspective", +// aifComponent); +// } + dialog = null; + m_boModel = null; + UIUtilities.setCurrentModalShell(shell); + System.out.println("关闭"); +} + +private final Shell m_shell; +private boolean m_revisionFlag = false; +private final String m_type; +final CreateNewBOHandler this$0; + +private CreateNewBOSWTDialog(Shell shell, boolean flag, String s) { + super(); + this$0 = CreateNewBOHandler.this; + m_shell = shell; + m_revisionFlag = flag; + m_type = s; +} + +CreateNewBOSWTDialog(Shell shell, boolean flag, String s, + CreateNewBOSWTDialog createnewboswtdialog) { + this(shell, flag, s); +} +} + +public Object execute(ExecutionEvent executionevent) + throws ExecutionException { + + + +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(); +try { + session = (TCSession) RACUICommandsActivator.getDefault() + .getSession(); +} catch (Exception _ex) { + session = (TCSession) AIFUtility.getDefaultSession(); +} +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) { +boolean flag = false; +// String s = "RT4Item"; +if (executionevent != null && executionevent.getParameters() != null) { + if (executionevent.getParameters().containsKey("revisionFlag")) + flag = ((Boolean) executionevent.getParameters().get( + "revisionFlag")).booleanValue(); + // s = (String)executionevent.getParameters().get("objectType"); + if (executionevent.getParameters().containsKey("pasteRelation")) { + String s1 = (String) executionevent.getParameters().get( + "pasteRelation"); + if (s1 != null) { + String as[] = null; + as = s1.split(","); + m_boModel.setRelType(as[0]); + m_boModel.setPreAssignedRelType(as); + } + } +} + + +AIFDesktop aifdesktop = AIFUtility.getActiveDesktop(); +Shell shell = aifdesktop.getShell(); +if (shell != null) + // if(itemtype!=null) + SWTUIUtilities.asyncExec(new CreateNewBOSWTDialog(shell, flag, + itemtype, null)); +} + +protected void readDisplayParameters(NewBOWizard newbowizard, + WizardDialog wizarddialog) { +newbowizard.retrievePersistedDialogSettings(wizarddialog); +} + +protected InterfaceAIFComponent selectedCmps[]; +protected ISelection m_currentSelection; +protected String wizardId; +protected BaseExternalWizardDialog dialog; +protected TCSession session; +protected NewBOModel m_boModel; +} diff --git a/src/com/connor/renben/process/plm/util/DDInClassDialog.java b/src/com/connor/renben/process/plm/util/DDInClassDialog.java new file mode 100644 index 0000000..de1b504 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/DDInClassDialog.java @@ -0,0 +1,528 @@ +//package com.connor.renben.process.plm.util; +// +//import java.awt.BorderLayout; +//import java.awt.event.ActionEvent; +//import java.awt.event.ActionListener; +//import java.util.ArrayList; +//import java.util.List; +// +//import javax.swing.DefaultListModel; +//import javax.swing.JButton; +//import javax.swing.JList; +//import javax.swing.JPanel; +//import javax.swing.JScrollPane; +//import javax.swing.JTabbedPane; +// +//import com.connor.renben.process.plm.tmom005.TMom005CreateOPByModuleOperation; +//import com.connor.renben.process.plm.tmom006.TMom006CreateProcessByProcessOperation; +//import com.connor.renben.process.plm.tmom007.TMom007ResourcesAssignedOperation; +//import com.teamcenter.rac.aif.AbstractAIFUIApplication; +//import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +//import com.teamcenter.rac.classification.common.G4MInClassDialog; +//import com.teamcenter.rac.classification.common.table.G4MTable; +//import com.teamcenter.rac.classification.common.table.G4MTableModel; +//import com.teamcenter.rac.classification.common.tree.G4MTree; +//import com.teamcenter.rac.commands.paste.PasteCommand; +//import com.teamcenter.rac.kernel.TCClassificationService; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentItem; +//import com.teamcenter.rac.kernel.TCComponentItemRevision; +//import com.teamcenter.rac.kernel.TCException; +//import com.teamcenter.rac.kernel.TCPreferenceService; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.kernel.ics.ICSHierarchyNodeDescriptor; +//import com.teamcenter.rac.util.ButtonLayout; +//import com.teamcenter.rac.util.HorizontalLayout; +//import com.teamcenter.rac.util.MessageBox; +//import com.teamcenter.rac.util.Registry; +//import com.teamcenter.rac.util.SplitPane; +//import com.teamcenter.rac.util.Utilities; +//import com.teamcenter.rac.util.VerticalLayout; +// +////import org.apache.log4j.Logger; +// +//public class DDInClassDialog extends G4MInClassDialog { +// private Registry m_reg; +// private TCSession m_session; +// protected InterfaceAIFComponent targets; +// private ArrayList listComps; +// private TCClassificationService m_ics; +// private JButton addButton; +// private JButton removeButton; +// private ArrayList objectsToBePasted = new ArrayList(); +// private ArrayList childrenList = new ArrayList(); +// private DefaultListModel selectedDictionaryListModel; +// private JList selectedDictionaryList; +// private TCPreferenceService m_filterPrefService; +// private String[] m_filterValues; +// private static final long serialVersionUID = 1L; +// private String commandId; +// +// // private static final Logger logger = +// // Logger.getLogger(DDInClassDialog.class); +// +// public DDInClassDialog( +// AbstractAIFUIApplication paramAbstractAIFUIApplication, +// InterfaceAIFComponent paramTCComponentBOMLine, int paramInt) { +// super(paramAbstractAIFUIApplication, paramInt); +// this.m_reg = Registry.getRegistry(DDInClassDialog.class); +// this.targets = paramTCComponentBOMLine; +// this.m_session = ((TCSession) paramAbstractAIFUIApplication +// .getSession()); +// this.m_ics = this.m_session.getClassificationService(); +// buildInitialization(); +// } +// +// public DDInClassDialog( +// AbstractAIFUIApplication paramAbstractAIFUIApplication, +// InterfaceAIFComponent paramTCComponentBOMLine, int paramInt, +// String commandId) { +// super(paramAbstractAIFUIApplication, paramInt); +// this.m_reg = Registry.getRegistry(DDInClassDialog.class); +// this.targets = paramTCComponentBOMLine; +// this.m_session = ((TCSession) paramAbstractAIFUIApplication +// .getSession()); +// this.m_ics = this.m_session.getClassificationService(); +// this.commandId = commandId; +// buildInitialization(); +// } +// +// public DDInClassDialog( +// AbstractAIFUIApplication paramAbstractAIFUIApplication, +// int paramInt, boolean paramBoolean) { +// super(paramAbstractAIFUIApplication, paramInt, paramBoolean); +// } +// +// public DDInClassDialog( +// AbstractAIFUIApplication paramAbstractAIFUIApplication, int paramInt) { +// super(paramAbstractAIFUIApplication, paramInt); +// } +// +// public DDInClassDialog( +// AbstractAIFUIApplication paramAbstractAIFUIApplication) { +// super(paramAbstractAIFUIApplication); +// } +// +// private void buildInitialization() { +// setTitle(this.m_reg.getString("DDInClassDialog.TITLE")); +// super.setTitleText(this.m_reg.getString("DDInClassDialog.TITLE")); +// JPanel localJPanel1 = new JPanel(new BorderLayout()); +// JPanel localJPanel2 = tableListPanel(); +// SplitPane localSplitPane = new SplitPane(1); +// localSplitPane.setTopComponent(localJPanel2); +// localSplitPane.setDividerLocation(0.95D); +// JPanel localJPanel3 = createButtonPanel(); +// localJPanel1.add("Center", localSplitPane); +// localJPanel1.add("South", localJPanel3); +// setContentPane(localJPanel1); +// } +// +// protected void initializeDialogBasedOnCookie() { +// setPersistentDisplayCookieFileName(G4MInClassDialog.COOKIE_FILENAME); +// setPersistentDisplay(true); +// setLocation(100, 100); +// pack(); +// setSize(700, 400); +// readDisplayParameters(); +// } +// +// private JPanel tableListPanel() { +// JPanel localJPanel1 = new JPanel(new HorizontalLayout(10, 10, 10, 10, +// 10)); +// JPanel localJPanel2 = treeTablePanel(); +// JPanel localJPanel3 = buildAddandRemoveButtonPanel(); +// JPanel localJPanel4 = new JPanel(new BorderLayout()); +// localJPanel4.add(localJPanel2, "Center"); +// localJPanel1.add("unbound.bind", localJPanel4); +// localJPanel1.add("right.bind.center.center", localJPanel3); +// JPanel localJPanel5 = buildSelectedDictionaryPanel(this.m_session, +// this.m_reg); +// SplitPane localSplitPane = new SplitPane(0); +// localSplitPane.setLeftComponent(localJPanel1); +// localSplitPane.setRightComponent(new JScrollPane(localJPanel5)); +// localSplitPane.setDividerLocation(0.85D); +// JPanel localJPanel6 = new JPanel(new BorderLayout()); +// localJPanel6.add(localSplitPane, "Center"); +// return localJPanel6; +// } +// +// protected JPanel buildAddandRemoveButtonPanel() { +// JPanel localJPanel = new JPanel(); +// localJPanel.setLayout(new ButtonLayout(2)); +// this.addButton = new JButton( +// this.m_reg.getImageIcon("quickAddButton.ICON")); +// this.listComps = new ArrayList(); +// this.addButton.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent paramAnonymousActionEvent) { +// DDInClassDialog.this.addSelectedNodeAction(); +// } +// }); +// this.listComps.clear(); +// localJPanel.add(this.addButton); +// this.removeButton = new JButton(this.m_reg.getImageIcon("minus.ICON")); +// this.removeButton.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent paramAnonymousActionEvent) { +// DDInClassDialog.this.removeSelectedNodeAction(); +// } +// }); +// localJPanel.add(this.removeButton); +// return localJPanel; +// } +// +// protected JPanel createButtonPanel() { +// JPanel localJPanel = new JPanel(); +// JButton localJButton = new JButton(this.m_reg.getString("cancel.NAME")); +// this.m_okButton = new JButton(this.m_reg.getString("oK.NAME")); +// this.m_okButton.addActionListener(this); +// if (this.selectedDictionaryListModel.getSize() > 0) { +// this.m_okButton.setEnabled(true); +// } +// localJButton.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent paramAnonymousActionEvent) { +// DDInClassDialog.this.closeDialogs(); +// } +// }); +// localJPanel.add(this.m_okButton); +// localJPanel.add(localJButton); +// return localJPanel; +// } +// +// private JPanel treeTablePanel() { +// setLayout(new BorderLayout()); +// JTabbedPane localJTabbedPane = createMainTabbedPane(); +// this.m_filterPrefService = this.m_session.getPreferenceService(); +// this.m_filterValues = this.m_filterPrefService +// .getStringValues("ICS_FilterBy_Library_types"); +// if (this.m_filterValues == null) { +// this.m_filterValues = new String[0]; +// } +// String[] arrayOfString = getAssoicateToProjectClassID(); +// if ((arrayOfString != null) && (arrayOfString.length > 0)) { +// this.m_tree = new G4MTree(this.m_context, true, +// this.m_filterValues, "Library"); +// this.m_tree.addG4MTreeListener(this); +// this.m_tree.setReducedClassList(arrayOfString); +// this.m_tree.refresh("ICM", true, false); +// } else { +// this.m_tree = new G4MTree(this.m_context, true, +// this.m_filterValues, "Library"); +// this.m_tree.addG4MTreeListener(this); +// } +// SplitPane localSplitPane = new SplitPane(0); +// localSplitPane.setDividerSize(2); +// localSplitPane.setDividerLocation(0.4D); +// localSplitPane.setLeftComponent(this.m_tree); +// localSplitPane.getLeftComponent().validate(); +// localSplitPane.setRightComponent(localJTabbedPane); +// localSplitPane.getRightComponent().validate(); +// JPanel localJPanel = new JPanel(new BorderLayout()); +// localJPanel.add(localSplitPane, "Center"); +// return localJPanel; +// } +// +// private String[] getAssoicateToProjectClassID() { +// String[] arrayOfString1 = null; +// ArrayList localArrayList1 = new ArrayList(); +// TCComponent[] arrayOfTCComponent1 = null; +// try { +// TCComponentItem localTCComponentItem = ((TCComponentItemRevision) this.targets) +// .getItem(); +// arrayOfTCComponent1 = localTCComponentItem +// .getReferenceListProperty("project_list"); +// TCClassificationService localTCClassificationService = this.m_session +// .getClassificationService(); +// int i; +// if ((arrayOfTCComponent1 != null) +// && (arrayOfTCComponent1.length > 0)) { +// for (i = 0; i < arrayOfTCComponent1.length; i++) { +// TCComponent[] arrayOfTCComponent2 = arrayOfTCComponent1[i] +// .getRelatedComponents("Fnd0LibraryForProject"); +// if (arrayOfTCComponent2.length > 0) { +// for (int j = 0; j < arrayOfTCComponent2.length; j++) { +// ICSHierarchyNodeDescriptor localICSHierarchyNodeDescriptor = localTCClassificationService +// .describeNode(arrayOfTCComponent2[j] +// .getProperty("cid"), 0); +// ICSHierarchyNodeDescriptor[] arrayOfICSHierarchyNodeDescriptor = this.m_context +// .getChildren( +// localICSHierarchyNodeDescriptor +// .getId(), +// localICSHierarchyNodeDescriptor +// .getClassChildrenCount()); +// String[] arrayOfString2 = this.m_context +// .getParents(arrayOfTCComponent2[j] +// .getProperty("cid")); +// if (arrayOfString2.length > 0) { +// for (int k = 0; k < arrayOfString2.length; k++) { +// localArrayList1.add(arrayOfString2[k]); +// } +// if (arrayOfICSHierarchyNodeDescriptor != null) { +// ArrayList localArrayList2 = new ArrayList(); +// localArrayList2 = getAssociateChildrensClassID(localICSHierarchyNodeDescriptor); +// for (int m = 0; m < localArrayList2.size(); m++) { +// localArrayList1.add(localArrayList2 +// .get(m)); +// } +// } +// localArrayList1.add(arrayOfTCComponent2[j] +// .getProperty("cid")); +// } +// } +// } +// } +// } +// if (localArrayList1 != null) { +// arrayOfString1 = new String[localArrayList1.size()]; +// for (i = 0; i < localArrayList1.size(); i++) { +// arrayOfString1[i] = ((String) localArrayList1.get(i)); +// } +// } +// } catch (Exception localException) { +// } +// return arrayOfString1; +// } +// +// private ArrayList getAssociateChildrensClassID( +// ICSHierarchyNodeDescriptor paramICSHierarchyNodeDescriptor) { +// ICSHierarchyNodeDescriptor[] arrayOfICSHierarchyNodeDescriptor = this.m_context +// .getChildren(paramICSHierarchyNodeDescriptor.getId(), +// paramICSHierarchyNodeDescriptor.getClassChildrenCount()); +// if (arrayOfICSHierarchyNodeDescriptor != null) { +// for (int i = 0; i < arrayOfICSHierarchyNodeDescriptor.length; i++) { +// getAssociateChildrensClassID(arrayOfICSHierarchyNodeDescriptor[i]); +// this.childrenList.add(arrayOfICSHierarchyNodeDescriptor[i] +// .getId()); +// } +// } +// return this.childrenList; +// } +// +// private void performOKAction() { +// this.selectedDictionaryListModel = ((DefaultListModel) this.selectedDictionaryList +// .getModel()); +// if (this.selectedDictionaryListModel.getSize() > 0) { +// Object[] arrayOfObject = this.selectedDictionaryListModel.toArray(); +// int i = arrayOfObject.length; +// for (int j = 0; j < i; j++) { +// TCComponent localTCComponent = (TCComponent) this.selectedDictionaryListModel +// .get(j); +// this.objectsToBePasted.add(localTCComponent); +// } +// } +// try { +// if (this.objectsToBePasted.size() > 0) { +// callPasteObjects(this.objectsToBePasted); +// } +// this.listComps.clear(); +// disposeDialog(); +// } catch (Exception localException) { +// // logger.error(localException.getClass().getName(), +// // localException); +// } +// } +// +// private void callPasteObjects(ArrayList paramArrayList) throws Exception { +// InterfaceAIFComponent[] arrayOfInterfaceAIFComponent = { this.targets }; +// TCComponent[] arrayOfTCComponent = null; +// PasteCommand localPasteCommand = null; +// arrayOfTCComponent = new TCComponent[paramArrayList.size()]; +// arrayOfTCComponent = (TCComponent[]) paramArrayList +// .toArray(arrayOfTCComponent); +// localPasteCommand = new PasteCommand(arrayOfTCComponent, +// arrayOfInterfaceAIFComponent, Boolean.TRUE); +// localPasteCommand.setFailBackFlag(true); +// localPasteCommand.executeModal(); +// } +// +// public void actionPerformed(ActionEvent paramActionEvent) { +// if (paramActionEvent.getSource() == this.m_clearButton.getButton()) { +// this.m_OIDtextField.setText(""); +// this.m_compTextField.setText(""); +// } else if (paramActionEvent.getSource() == this.m_okButton) { +// // String s = this.m_OIDtextField.getText(); +// // String s1 = this.m_compTextField.getText(); +// // MessageBox.post("确定按钮!", "错误!", 1); +// // performOKAction(); +// switch (commandId) { +// case "com.connor.renben.process.plm.commands.CreateOPByModule": +// TMom005CreateOPByModuleOperation createOPOperation = new TMom005CreateOPByModuleOperation( +// this.m_session, this.targets, +// this.m_compTextField.getText()); +// this.m_session.queueOperation(createOPOperation); +// break; +// case "com.connor.renben.process.plm.commands.CreateProcessByModule": +// TMom006CreateProcessByProcessOperation createProcessOperation = new TMom006CreateProcessByProcessOperation( +// targets, this.m_compTextField.getText(), this.m_session); +// this.m_session.queueOperation(createProcessOperation); +// break; +// case "com.connor.renben.process.plm.commands.ResourcesAssigned": +// TMom007ResourcesAssignedOperation resourcesAssignedOperation = new TMom007ResourcesAssignedOperation( +// targets, this.m_compTextField.getText(), this.m_session); +// this.m_session.queueOperation(resourcesAssignedOperation); +// break; +// +// default: +// break; +// } +// } else if (paramActionEvent.getSource() == this.m_searchButton) { +// performAttributeSearch(); +// } else { +// performObjectIDSearch(); +// } +// } +// +// private void addSelectedNodeAction() { +// int i = 1; +// ArrayList localArrayList = new ArrayList(); +// DefaultListModel localDefaultListModel = (DefaultListModel) this.selectedDictionaryList +// .getModel(); +// int j = this.m_tabbedPane.getSelectedIndex(); +// TCComponent localTCComponent = null; +// Object localObject1; +// Object localObject2; +// Object localObject3; +// if (j == 1) { +// localObject1 = this.m_context.getICSApplicationObject() +// .getClassifiedObjectUid(); +// try { +// localTCComponent = this.m_ics +// .getTCComponent((String) localObject1); +// if (!this.listComps.contains(localTCComponent)) { +// localDefaultListModel.addElement(localTCComponent); +// this.listComps.add(localTCComponent); +// this.selectedDictionaryList.setModel(localDefaultListModel); +// } else { +// localArrayList.add(localTCComponent); +// i = 0; +// } +// } catch (TCException localTCException1) { +// // logger.error(localTCException1.getClass().getName(), +// // localTCException1); +// } +// } else if (j == 2) { +// localObject1 = this.m_tablePane.getG4MTable(); +// if (localObject1 != null) { +// G4MTableModel localG4MTableModel = ((G4MTable) localObject1) +// .getG4MTableModel(); +// localObject2 = null; +// localObject3 = ((G4MTable) localObject1).getSelectedRows(); +// if (((int[]) localObject3).length == 0) { +// return; +// } +// for (int m = 0; m < ((int[]) localObject3).length; m++) { +// String str2 = localG4MTableModel.getValueAt( +// ((int[]) localObject3)[m], +// localG4MTableModel.getWSOColumnNo()).toString(); +// if ((str2 != null) && (str2.length() > 0)) { +// try { +// localObject2 = this.m_ics.getTCComponent(str2); +// if (!this.listComps.contains(localObject2)) { +// localDefaultListModel.addElement(localObject2); +// this.listComps.add((TCComponent) localObject2); +// this.selectedDictionaryList +// .setModel(localDefaultListModel); +// } else { +// localArrayList.add(localObject2); +// i = 0; +// } +// } catch (TCException localTCException2) { +// // logger.error(localTCException2.getClass().getName(), +// // localTCException2); +// } +// } else { +// MessageBox +// .post(Utilities.getCurrentFrame(), +// this.m_reg +// .getString("invalidSelectedObject.MESSAGE"), +// this.m_reg +// .getString("absOccIllegalSelection.TITLE"), +// 1); +// } +// if (this.m_tree != null) { +// this.m_tree.getTree().getSelectionModel() +// .clearSelection(); +// } +// } +// } +// } +// if (i == 0) { +// localObject1 = new StringBuffer(); +// if (localArrayList.size() > 0) { +// for (int k = 0; k < localArrayList.size(); k++) { +// if (((StringBuffer) localObject1).length() > 0) { +// ((StringBuffer) localObject1).append(","); +// } +// ((StringBuffer) localObject1).append(localArrayList.get(k)); +// } +// } +// if (((StringBuffer) localObject1).length() > 0) { +// Registry localRegistry = Registry.getRegistry(this); +// localObject2 = localRegistry +// .getString("duplicateAdded.MESSAGE"); +// localObject3 = ((String) localObject2).substring(0, +// ((String) localObject2).indexOf("%1")); +// String str1 = ((String) localObject2) +// .substring(((String) localObject2).indexOf("%1") + 2); +// MessageBox.post( +// Utilities.getCurrentFrame(), +// localObject3 + "[" +// + ((StringBuffer) localObject1).toString() +// + "]" + str1, +// localRegistry.getString("duplicateAdded.TITLE"), 1); +// } +// } +// } +// +// private void removeSelectedNodeAction() { +// List localList = this.selectedDictionaryList.getSelectedValuesList(); +// if ((localList != null) && (localList.size() > 0)) { +// for (int i = 0; i < localList.size(); i++) { +// this.selectedDictionaryListModel +// .removeElement(localList.get(i)); +// this.listComps.remove(localList.get(i)); +// } +// } +// if (this.selectedDictionaryList.getSelectedValue() != null) { +// this.selectedDictionaryListModel +// .removeElement(this.selectedDictionaryList +// .getSelectedValue()); +// this.listComps.remove(this.selectedDictionaryList +// .getSelectedValue()); +// } +// } +// +// protected JPanel buildSelectedDictionaryPanel(TCSession paramTCSession, +// Registry paramRegistry) { +// this.selectedDictionaryListModel = new DefaultListModel(); +// this.selectedDictionaryList = new JList( +// this.selectedDictionaryListModel); +// this.selectedDictionaryList.setSelectionMode(2); +// JScrollPane localJScrollPane = new JScrollPane( +// this.selectedDictionaryList, 20, 30); +// JPanel localJPanel1 = new JPanel(new VerticalLayout(3, 3, 3, 3, 3)); +// localJPanel1.add("unbound", localJScrollPane); +// JPanel localJPanel2 = new JPanel(new BorderLayout()); +// localJPanel2.add(localJPanel1, "Center"); +// JPanel localJPanel3 = new JPanel(new HorizontalLayout(3, 3, 3, 3, 3)); +// localJPanel3.add("unbound.bind", localJPanel2); +// return localJPanel3; +// } +// +// public ArrayList getObjectsToBePasted() { +// if ((this.objectsToBePasted == null) +// || (this.objectsToBePasted.size() == 0)) { +// this.selectedDictionaryListModel = ((DefaultListModel) this.selectedDictionaryList +// .getModel()); +// if (this.selectedDictionaryListModel.getSize() > 0) { +// Object[] arrayOfObject = this.selectedDictionaryListModel +// .toArray(); +// int i = arrayOfObject.length; +// for (int j = 0; j < i; j++) { +// TCComponent localTCComponent = (TCComponent) this.selectedDictionaryListModel +// .get(j); +// this.objectsToBePasted.add(localTCComponent); +// } +// } +// } +// return this.objectsToBePasted; +// } +//} diff --git a/src/com/connor/renben/process/plm/util/DraggableTabbedPane.java b/src/com/connor/renben/process/plm/util/DraggableTabbedPane.java new file mode 100644 index 0000000..969e917 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/DraggableTabbedPane.java @@ -0,0 +1,76 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; +import java.awt.image.BufferedImage; + +import javax.swing.JTabbedPane; + +public class DraggableTabbedPane extends JTabbedPane { + private boolean dragging = false; + private Image tabImage = null; + private Point currentMouseLocation = null; + private int draggedTabIndex = 0; + public DraggableTabbedPane() { + super(); + addMouseMotionListener(new MouseMotionAdapter() { + public void mouseDragged(MouseEvent e) { + if(!dragging) { + //Gets the tab index based on the mouse position + int tabNumber = getUI().tabForCoordinate(DraggableTabbedPane.this, e.getX(), e.getY()); + if(tabNumber >= 0) { + draggedTabIndex = tabNumber; + Rectangle bounds = getUI().getTabBounds(DraggableTabbedPane.this, tabNumber); + //Paint the tabbed pane to a buffer + Image totalImage = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB); + Graphics totalGraphics = totalImage.getGraphics(); + totalGraphics.setClip(bounds); + //Don't be double buffered when painting to a static image. + setDoubleBuffered(false); + paintComponent(totalGraphics); + //Paint just the dragged tab to the buffer + tabImage = new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_INT_ARGB); + Graphics graphics = tabImage.getGraphics(); + graphics.drawImage(totalImage, 0, 0, bounds.width, bounds.height, bounds.x, bounds.y, bounds.x + bounds.width, bounds.y+bounds.height, DraggableTabbedPane.this); + dragging = true; + repaint(); + } + } else { + currentMouseLocation = e.getPoint(); + //Need to repaint + repaint(); + } + super.mouseDragged(e); + } + }); + addMouseListener(new MouseAdapter() { + public void mouseReleased(MouseEvent e) { + if(dragging) { + int tabNumber = getUI().tabForCoordinate(DraggableTabbedPane.this, e.getX(), 10); + if(tabNumber >= 0) { + Component comp = getComponentAt(draggedTabIndex); + String title = getTitleAt(draggedTabIndex); + removeTabAt(draggedTabIndex); + insertTab(title, null, comp, null, tabNumber); + } + } + dragging = false; + tabImage = null; + } + }); + } + protected void paintComponent(Graphics g) { + super.paintComponent(g); + //Are we dragging? + if(dragging && currentMouseLocation!= null && tabImage!= null) { + //Draw the dragged tab + g.drawImage(tabImage, currentMouseLocation.x, currentMouseLocation.y, this); + } + } +} diff --git a/src/com/connor/renben/process/plm/util/ExcelFilter.java b/src/com/connor/renben/process/plm/util/ExcelFilter.java new file mode 100644 index 0000000..51d0bbd --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ExcelFilter.java @@ -0,0 +1,33 @@ +package com.connor.renben.process.plm.util; + +import java.io.File; + +import javax.swing.filechooser.FileFilter; + +public class ExcelFilter extends FileFilter { + public boolean accept(File f) { + if (f.isDirectory()) { + return true; + } + String fileName = f.getName(); + int index = fileName.lastIndexOf('.'); + String extension = ""; + if (index > 0 && index < fileName.length() - 1) { + extension = fileName.substring(index + 1).toLowerCase(); + } + if (extension != null) { + if (extension.equals("xls") || extension.equals("xlsx") + || extension.equals("xlt") || extension.equals("xlsm")) { + return true; + } else { + return false; + } + } + return false; + } + + public String getDescription() { + return "Excel文件(*.xls, *.xlsx, *.xlt, *.xlsm)"; + } + +} diff --git a/src/com/connor/renben/process/plm/util/ExcelUtil.java b/src/com/connor/renben/process/plm/util/ExcelUtil.java new file mode 100644 index 0000000..c4c3555 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ExcelUtil.java @@ -0,0 +1,1212 @@ +package com.connor.renben.process.plm.util; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.imageio.ImageIO; + +import com.spire.xls.ExcelPicture; +import com.spire.xls.ViewMode; +import com.spire.xls.Workbook; +import com.spire.xls.Worksheet; + +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.HSSFFont; +import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator; +import org.apache.poi.hssf.usermodel.HSSFName; +import org.apache.poi.hssf.usermodel.HSSFPatriarch; +import org.apache.poi.hssf.usermodel.HSSFRichTextString; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.SpreadsheetVersion; +import org.apache.poi.ss.usermodel.BorderStyle; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.CellValue; +import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType; +import org.apache.poi.ss.usermodel.IndexedColors; +import org.apache.poi.ss.util.AreaReference; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFFont; +import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator; +import org.apache.poi.xssf.usermodel.XSSFName; +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.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; + +/** + * Excel 签名 + * + * @author hub 2015-09-06 + */ +public class ExcelUtil { + // private static Registry reg = Registry.getRegistry(this); + // private static HSSFSheet sheet; + // private static final int MY_ROWS = 46; + private SimpleDateFormat dateFormat = new SimpleDateFormat( + "yyyy-M-dd HH:mm"); + + /** + * 读取EXCEL表 + * + * @param File + * excel_file + * @return List> 返回的信息 + * @throws IOException + * @throws FileNotFoundException + */ + public static List> readExcel(File excel_file) + throws FileNotFoundException, IOException { + if (excel_file == null || !excel_file.exists()) { + return null; + } + // 用来返回的所有的行的信息 + List> lines_msg = new ArrayList>(); + HSSFWorkbook workBook = new HSSFWorkbook( + new FileInputStream(excel_file)); + HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(workBook); + HSSFSheet sheet = workBook.getSheetAt(0); + HSSFRow title_row = sheet.getRow(0); + // 得到列的数目 + int col_count = title_row.getPhysicalNumberOfCells(); + System.out.println(" SHEET COL COUNT " + col_count); + // 得到行的数目 + int row_count = sheet.getLastRowNum(); + + System.out.println(" SHEET ROW COUNT " + row_count); + for (int j = 0; j < row_count + 1; j++) { + // 用来返回单行的信息 + HSSFRow row = sheet.getRow(j); + List line_msg = new ArrayList(); + for (int i = 0; i < col_count; i++) { + String value = getStringCellValue(evaluator, + row.getCell((short) i)); + line_msg.add(value); + } + lines_msg.add(line_msg); + } + // insertRow(sheet,4,1); + return lines_msg; + } + + public void writeSignName(String intExcelFilePath, String outExcelFilePath, + String signName, String msgValue, int sheetIndex, int rowIndex, + int cellIndex) throws IOException { + // 输出文件的路径 + FileOutputStream outPut = new FileOutputStream(new File( + outExcelFilePath)); + // 输入文件的路径 + FileInputStream inPut = new FileInputStream(new File(intExcelFilePath)); + HSSFWorkbook wb = new HSSFWorkbook(inPut); + wb.getName(""); + +// AreaReference.generateContiguous(null, msgValue) + AreaReference[] areaR2 = AreaReference.generateContiguous( SpreadsheetVersion.EXCEL2007,wb + .getName("").getRefersToFormula()); + AreaReference areaR = null; + CellReference[] cellR = areaR.getAllReferencedCells(); + cellR[0].getSheetName();// s + cellR[0].getCol();// + cellR[0].getRow();// + HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb); + HSSFSheet sheet = wb.getSheetAt(sheetIndex); + HSSFRow row = sheet.getRow(rowIndex); + + HSSFCell cell = row.getCell(cellIndex); + String value = getStringCellValue(evaluator, cell); + if (value.startsWith(signName)) { + value = value.substring(0, signName.length()); + } + + cell.setCellValue(value + msgValue); + wb.write(outPut); + inPut.close(); + outPut.close(); + } + + /** + * 设置单元格中指定字体的样式 + * + * @param wb + * @param s + * 内容 + * @param firstIndex + * 起始位置 + * @param lastIndex + * 结束位置 + * @param fontSize + * 字体大小 + * @param FontName + * 字体样式 + * @return + */ + public static HSSFRichTextString setCellFont(HSSFWorkbook wb, String s, + int firstIndex, int lastIndex, int fontSize, String FontName) { + HSSFRichTextString ts = new HSSFRichTextString(s); + HSSFFont font1 = (HSSFFont) wb.createFont(); + font1.setFontHeightInPoints((short) 8); // 字体高度 + font1.setFontName("宋体"); // 字体 + // font1.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 + HSSFFont font = (HSSFFont) wb.createFont(); + font.setFontHeightInPoints((short) fontSize); // 字体高度 + font.setFontName(FontName); // 字体 + // font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 + ts.applyFont(firstIndex, lastIndex, font); + ts.applyFont(lastIndex, ts.length(), font1); + return ts; + } + /** + * 设置单元格中指定字体的样式 + * + * @param wb + * @param s + * 内容 + * @param firstIndex + * 起始位置 + * @param lastIndex + * 结束位置 + * @param fontSize + * 字体大小 + * @param FontName + * 字体样式 + * @return + */ + public static HSSFRichTextString setCellFont_XSSF(XSSFWorkbook wb, String s, + int firstIndex, int lastIndex, int fontSize, String FontName) { + HSSFRichTextString ts = new HSSFRichTextString(s); + XSSFFont font1 = (XSSFFont) wb.createFont(); + font1.setFontHeightInPoints((short) 8); // 字体高度 + font1.setFontName("宋体"); // 字体 + // font1.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 + XSSFFont font = (XSSFFont) wb.createFont(); + font.setFontHeightInPoints((short) fontSize); // 字体高度 + font.setFontName(FontName); // 字体 + // font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 + ts.applyFont(firstIndex, lastIndex, font); + ts.applyFont(lastIndex, ts.length(), font1); + return ts; + } + + /** + * 合并单元格sheet.addMergedRegion(new CellRangeAddress(check_index-1, + * check_index+12+check_rows, 0, 0)); + * + * @param startRow + * @param endRow + * @return + */ + public static boolean combine(HSSFSheet sheet, int[] rows, int[] columns) { + boolean isOK = false; + if (rows.length > 0 && columns.length > 0) { + sheet.addMergedRegion(new CellRangeAddress(rows[0], + rows[rows.length - 1], columns[0], + columns[columns.length - 1])); + isOK = true; + } + return isOK; + } + /** + * 合并单元格sheet.addMergedRegion(new CellRangeAddress(check_index-1, + * check_index+12+check_rows, 0, 0)); + * + * @param startRow + * @param endRow + * @return + */ + public static boolean combine_XSSF(XSSFSheet sheet, int[] rows, int[] columns) { + boolean isOK = false; + + try { + if ((rows.length > 0 && columns.length > 0 ) && (rows.length > 1 || columns.length > 1 )) { + sheet.addMergedRegion(new CellRangeAddress(rows[0], + rows[rows.length - 1], columns[0], + columns[columns.length - 1])); + isOK = true; + } + } catch (Exception e) { + // TODO: handle exception + System.out.println(e.getMessage()); + } + + + return isOK; + } + + /** + * 获取单个的命名单元格的列 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static int getNamedColumnIndex(HSSFWorkbook wb, String cellName) + throws IOException { + int index = -1; + HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb); + HSSFName name = wb.getName(cellName); + if (name == null) { + return -1; + } + AreaReference[] areaRs = AreaReference.generateContiguous(SpreadsheetVersion.EXCEL2007,name + .getRefersToFormula()); + if (areaRs != null) + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + HSSFSheet sheet = wb.getSheet(sheetName); + HSSFRow row = sheet.getRow(rowIndex); + return colIndex; + } + } + } + return index; + } + /** + * 获取单个的命名单元格的列 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static int getNamedColumnIndex_XSSF(XSSFWorkbook wb, String cellName) + throws IOException { + int index = -1; + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); + XSSFName name = wb.getName(cellName); + if (name == null) { + return -1; + } + AreaReference[] areaRs = AreaReference.generateContiguous(SpreadsheetVersion.EXCEL2007,name + .getRefersToFormula()); + if (areaRs != null) + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + XSSFSheet sheet = wb.getSheet(sheetName); + XSSFRow row = sheet.getRow(rowIndex); + return colIndex; + } + } + } + return index; + } + + /** + * 添加命名的引用 + * + * @param session + * @param item + * 对象的版本 + * @param tcResource + * 文件的物理路径 + * @param relationName + * 关系名称 + */ + public static void setExcelToItem(TCSession session, + TCComponentItemRevision item, String tcResource, String fileName, + boolean isDelete) { + try { + String as1[] = { tcResource };// 文件的物理路径 + String as2[] = { "excel" }; + String as3[] = { "MSExcel" }; + String as4[] = { "Plain" }; + TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + TCComponentDataset tccomponentDataset = tccomponentDatasetType + .create(fileName, "excel", "MSExcel"); + tccomponentDataset.setFiles(as1, as3, as4, as2); + AIFComponentContext[] zyzdsChildrens = item.getChildren(); + TCComponentItemRevision zyzdsRev = item; + for (AIFComponentContext zyzdsChildren : zyzdsChildrens) { + if ("MSExcel".equals(zyzdsChildren.getComponent().getType())) { + TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren + .getComponent(); + zyzdsRev.remove("TC_Attaches", dateSet); + dateSet.delete(); + } + } + item.add("TC_Attaches", tccomponentDataset); + if (isDelete) { + new File(tcResource).delete(); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 获取单个的命名单元格的内容 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static String getNamedCellValue(HSSFWorkbook wb, String cellName) + throws IOException { + String value = null; + HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb); + HSSFName name = wb.getName(cellName); + AreaReference[] areaRs = AreaReference.generateContiguous(SpreadsheetVersion.EXCEL2007,name + .getRefersToFormula()); + if (areaRs != null) + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + HSSFSheet sheet = wb.getSheet(sheetName); + HSSFRow row = sheet.getRow(rowIndex); + HSSFCell cell = row.getCell(colIndex); + value = getStringCellValue(evaluator, cell); + } + } + } + return value; + } + + // 导出Excel + public void writeExcel(String xls_write_Address, InputStream stream, + Vector> ls, String[] sheetnames) { + FileOutputStream outStream; + try { + outStream = new FileOutputStream(new File(xls_write_Address)); + /* + * HSSFWorkbook workbook=new HSSFWorkbook(); HSSFSheet + * sheet=workbook.getSheetAt(0); for (int i = 0; i < + * this.resuList.size(); i++) { HSSFRow row = sheet.createRow(i); + * String[] s=this.resuList.get(i); for (int j = 0; j < s.length; + * j++) { HSSFCell cell=row.createCell(i); + * cell.setCellType(XSSFCell.CELL_TYPE_STRING); + * cell.setCellValue(s[i]); } } + */ + XSSFWorkbook workbook = new XSSFWorkbook(stream); + XSSFCellStyle style = workbook.createCellStyle(); + style.setBorderBottom(BorderStyle.THIN); + style.setBorderTop(BorderStyle.THIN); + style.setBorderRight(BorderStyle.THIN); + style.setBorderLeft(BorderStyle.THIN); + for (int sn = 0; sn < sheetnames.length; sn++) { + XSSFSheet sheet = workbook.getSheetAt(0); + for (int i = 0; i < ls.size(); i++) { + XSSFRow row = sheet.createRow(i + 1); + Vector ls2 = ls.get(i); + for (int cols = 0; cols < ls2.size(); cols++) { + XSSFCell cell = row.createCell(cols); + cell.setCellType(CellType.STRING);// 文本格式 + cell.setCellStyle(style);// 添加边框 + if (ls2.get(cols) instanceof Date) { + String date = ls2.get(cols) == null ? "" + : dateFormat.format(ls2.get(cols)); + cell.setCellValue(date);// 写入内容 + } else { + cell.setCellValue(ls2.get(cols) == null ? "" : ls2 + .get(cols).toString());// 写入内容 + } + } + } + } + workbook.write(outStream); + outStream.close(); + System.out.println("成功!"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void writeExcel(String xls_write_Address, InputStream stream, + ArrayList> ls, String[] sheetnames) { + FileOutputStream outStream; + try { + outStream = new FileOutputStream(new File(xls_write_Address)); + /* + * HSSFWorkbook workbook=new HSSFWorkbook(); HSSFSheet + * sheet=workbook.getSheetAt(0); for (int i = 0; i < + * this.resuList.size(); i++) { HSSFRow row = sheet.createRow(i); + * String[] s=this.resuList.get(i); for (int j = 0; j < s.length; + * j++) { HSSFCell cell=row.createCell(i); + * cell.setCellType(XSSFCell.CELL_TYPE_STRING); + * cell.setCellValue(s[i]); } } + */ + XSSFWorkbook workbook = new XSSFWorkbook(stream); + XSSFCellStyle style = workbook.createCellStyle(); + style.setBorderBottom(BorderStyle.THIN); + style.setBorderTop(BorderStyle.THIN); + style.setBorderRight(BorderStyle.THIN); + style.setBorderLeft(BorderStyle.THIN); + for (int sn = 0; sn < sheetnames.length; sn++) { + XSSFSheet sheet = workbook.getSheetAt(0); + for (int i = 0; i < ls.size(); i++) { + XSSFRow row = sheet.createRow(i + 1); + ArrayList ls2 = ls.get(i); + for (int cols = 0; cols < ls2.size(); cols++) { + XSSFCell cell = row.createCell(cols); + cell.setCellType(CellType.STRING);// 文本格式 + cell.setCellStyle(style);// 添加边框 + cell.setCellValue(ls2.get(cols));// 写入内容 + } + } + } + workbook.write(outStream); + outStream.close(); + System.out.println("成功!"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /*** + * 写入到EXCEL数据 (写入单种数据) + * + * @param xls_write_Address + * @param ls + * @param sheetnames + * @throws IOException + */ + public void writeExcel5(String xls_write_Address, InputStream stream, + ArrayList> ls, String[] sheetnames) + throws IOException { + FileOutputStream output = new FileOutputStream(new File( + xls_write_Address)); // 读取的文件路径 + HSSFWorkbook wb = new HSSFWorkbook(stream);// (new + // BufferedInputStream(output)); + HSSFCellStyle style = wb.createCellStyle(); + style.setBorderBottom(BorderStyle.THIN); + style.setBorderTop(BorderStyle.THIN); + style.setBorderRight(BorderStyle.THIN); + style.setBorderLeft(BorderStyle.THIN); + for (int sn = 0; sn < sheetnames.length; sn++) { + HSSFSheet sheet = wb.getSheetAt(0); + for (int i = 0; i < ls.size(); i++) { + HSSFRow row = sheet.createRow(i + 1); + ArrayList ls2 = ls.get(i); + for (int cols = 0; cols < ls2.size(); cols++) { + HSSFCell cell = row.createCell(cols); + cell.setCellType(CellType.STRING);// 文本格式 + cell.setCellStyle(style);// 添加边框 + cell.setCellValue(ls2.get(cols));// 写入内容 + } + } + } + wb.write(output); + output.close(); + System.out.println("-------WRITE EXCEL OVER-------"); + } + + /*** + * 写入到EXCEL数据 (写入单种数据) + * + * @param xls_write_Address + * @param ls + * @param sheetnames + * @throws IOException + */ + public void writeExcel(String xls_write_Address, ArrayList ls, + String[] sheetnames) throws IOException { + FileOutputStream output = new FileOutputStream(new File( + xls_write_Address)); // 读取的文件路径 + HSSFWorkbook wb = new HSSFWorkbook();// (new + // BufferedInputStream(output)); + for (int sn = 0; sn < ls.size(); sn++) { + HSSFSheet sheet = wb.createSheet(String.valueOf(sn)); + wb.setSheetName(sn, sheetnames[sn]); + ArrayList ls2 = ls.get(sn); + for (int i = 0; i < ls2.size(); i++) { + HSSFRow row = sheet.createRow(i); + String[] s = ls2.get(i); + for (int cols = 0; cols < s.length; cols++) { + HSSFCell cell = row.createCell(cols); + cell.setCellType(CellType.STRING);// 文本格式 + cell.setCellValue(s[cols]);// 写入内容 + } + } + } + wb.write(output); + output.close(); + System.out.println("-------WRITE EXCEL OVER-------"); + } + + /** + * 根据单元格的名字来找到单元格的内容 + * + * @param inputFilePath + * @param cellName + * @return + */ + public static List getExcelNamedCellValue(String inputFilePath, + String[] cellNames) { + List valueList = new ArrayList(); + try { + FileInputStream is = new FileInputStream(new File(inputFilePath)); + HSSFWorkbook wb = new HSSFWorkbook(is); + for (String name : cellNames) + valueList.add(getNamedCellValue(wb, name)); + is.close(); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return valueList; + } + + /** + * 针对工程变更的信息写入 + * + * @param xls_write_Address + * @param ls + * @throws IOException + */ + /* + * public static void writeExcel(String outPath, InputStream input, + * List beanListAll) throws IOException { int + * rowsCount = 5; + * + * // insertRow(); + * + * FileOutputStream output = new FileOutputStream(new File(outPath)); // + * 读取的文件路径 // FileInputStream input= new FileInputStream(); HSSFWorkbook wb + * = new HSSFWorkbook(input);// (new HSSFSheet sheet = wb.getSheetAt(0); for + * (int i = 0; i < (beanListAll.size() - rowsCount); i++) insertRow(sheet, + * 4, 1); int startRow = 2; for (int i = 0; i < beanListAll.size(); i++) { + * JFomProjectChangeBean bean = beanListAll.get(i); HSSFRow row = null; + * Boolean isCreat = false; if ((i + startRow) > sheet.getLastRowNum()) { + * row = sheet.createRow(i + startRow); isCreat = true; } else { row = + * sheet.getRow(i + startRow); isCreat = false; } + * + * for (int cols = 0; cols < 12; cols++) { HSSFCell cell = null; if + * (isCreat) { cell = row.createCell(cols); } else { cell = + * row.getCell(cols); } if (cell == null) cell = row.createCell(cols); + * cell.setCellType(HSSFCell.CELL_TYPE_STRING);// 文本格式 switch (cols) { + * + * case 0: cell.setCellValue(bean.getIndexStr());// 写入内容 break; case 1: + * cell.setCellValue(bean.getECRCode());// 写入内容 break; case 2: + * cell.setCellValue(bean.getInternalCode());// 写入内容 break; case 3: + * cell.setCellValue(bean.getDrawingNo());// 写入内容 break; case 4: + * cell.setCellValue(bean.getPartStatus());// 写入内容 break; case 5: + * cell.setCellValue(bean.getInitiator());// 写入内容 break; case 6: + * cell.setCellValue(bean.getSureDate());// 写入内容 break; case 7: + * cell.setCellValue(bean.getChangeMsgBef());// 写入内容 break; case 8: + * cell.setCellValue(bean.getChangeMsg());// 写入内容 break; case 9: + * cell.setCellValue(bean.getChargePerson());// 写入内容 break; case 10: + * cell.setCellValue("");// 写入内容 break; case 11: cell.setCellValue("");// + * 写入内容 break; } } } + * + * // } wb.write(output); output.close(); input.close(); + * System.out.println("-------WRITE EXCEL OVER-------"); } + */ + public void insertPicture(HSSFWorkbook wb, HSSFSheet sheet1, + String picPath, short colIndex, int rowIndex) { + + // FileOutputStream fileOut = null; + BufferedImage bufferImg = null; + // 先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray + try { + if (!new File(picPath).exists()) { + return; + } + String dexStr = picPath.substring(picPath.lastIndexOf(".") + 1, + picPath.length()); + + ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); + System.out.println(picPath); + bufferImg = ImageIO.read(new File(picPath)); + ImageIO.write(bufferImg, dexStr, byteArrayOut); + // HSSFWorkbook wb = new HSSFWorkbook(); + // HSSFSheet sheet1 = wb.createSheet("test picture"); + // 画图的顶级管理器,一个sheet只能获取一个(一定要注意这点) + HSSFPatriarch patriarch = sheet1.createDrawingPatriarch(); + // anchor主要用于设置图片的属性 + HSSFClientAnchor anchor = new HSSFClientAnchor(13, 13, 0, 0, + (short) colIndex, rowIndex, (short) (colIndex + 1), + rowIndex + 1); + anchor.setAnchorType(AnchorType.DONT_MOVE_AND_RESIZE); + // 插入图片 + patriarch + .createPicture(anchor, wb.addPicture( + byteArrayOut.toByteArray(), + HSSFWorkbook.PICTURE_TYPE_JPEG)); + + } catch (Exception e) { + e.printStackTrace(); + } + + } + + /** + * 设置单个的命名单元格的内容 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static void setNamedCellValue(HSSFWorkbook wb, String cellName, + String cellValue) throws IOException { + String value = null; + HSSFName name = wb.getName(cellName); + if (name == null) { + return; + } + AreaReference[] areaRs = AreaReference.generateContiguous(SpreadsheetVersion.EXCEL2007 ,name + .getRefersToFormula()); + if (areaRs != null) { + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + HSSFSheet sheet = wb.getSheet(sheetName); + HSSFRow row = sheet.getRow(rowIndex); + HSSFCell cell = row.getCell(colIndex); + cell.setCellValue(cellValue); + } + } + } + } + } + /** + * 设置单个的命名单元格的内容 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static void setNamedCellValue_XSSF(XSSFWorkbook wb, String cellName, + String cellValue) throws IOException { + String value = null; + XSSFName name = wb.getName(cellName); + if (name == null) { + return; + } + AreaReference[] areaRs = AreaReference.generateContiguous(SpreadsheetVersion.EXCEL2007 ,name + .getRefersToFormula()); + if (areaRs != null) { + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + XSSFSheet sheet = wb.getSheet(sheetName); + XSSFRow row = sheet.getRow(rowIndex); + XSSFCell cell = row.getCell(colIndex); + cell.setCellValue(cellValue); + } + } + } + } + } + + /** + * 移除合并的单元格 + * + * @param startRow + * @param endRow + * @return + */ + public static boolean removeMergen(HSSFSheet sheet, int startRow, int endRow) { + boolean isOK = false; + int count = sheet.getNumMergedRegions(); + for (int i = 0; i < count; i++) { + CellRangeAddress address = sheet.getMergedRegion(i); + System.out.println(address.getFirstRow() + "|" + + address.getLastRow()); + if (address.getFirstRow() == startRow + && address.getLastRow() == endRow) { + sheet.removeMergedRegion(i); + isOK = true; + break; + } + } + return isOK; + } + + //插入图片;isProportion:false是将图片嵌入到全部单元格。true是将原图比例放入区域内 + //sheet:操作的excel;picturePath:图片路径;Rows:插入图片区域的行(从1开始);colunms插入图片区域的列(从1开始) + //RowHeightCM是厘米制的行高;ColumnWidthCM是厘米制的列宽 + public static void InsertTitlePicture(File file,String outFilePath,String picturePath,int[] Rows,int[] colunms,boolean isProportion, + double RowHeightCM,double ColumnWidthCM,int ii,int jj) throws IOException { +// //获取系统分辨率 +// int screenWidth=((int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().width); +// int screenHeight = ((int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().height); + Workbook wb = new Workbook(); + wb.loadFromHtml(new FileInputStream(file)); + Worksheet sheet = wb.getWorksheets().get(0); + + double ColumnWidth=0.0;//列宽单元格像素 + double RowHeight=0.0;//行高像素 +// double ColumnWidthCM=0.0;//列宽单元格CM +// double RowHeightCM=0.0;//行高CM + + for(int i=0;iRH) { + w=W/CW; + h=(H/CW)*w1/h1;//w1是放图片区域列宽占的厘米数除以像素(0.18);h1是行高的占的厘米数除以像素(0.23) + }else { + h=H/RH; + w=(W/RH)*h1/w1; + } + pic1.setWidth((int) (w)); + pic1.setHeight((int) (h)); + }else { + pic1.setWidth((int) ColumnWidth); + pic1.setHeight((int) RowHeight); + } + + wb.saveToFile(outFilePath); + input.close(); + pic1.dispose(); + sourceImg.flush(); + new File(picturePath).delete(); + +// //消除水印 +// File file1=new File(outFilePath); +// FileInputStream input1 = new FileInputStream(file1); +// XSSFWorkbook wb1 = new XSSFWorkbook(input1); +// wb1.removeSheetAt(wb1.getActiveSheetIndex()); +// FileOutputStream output = new FileOutputStream(new File(outFilePath)); +// wb1.write(output); +// input.close(); +// output.close(); + } + + + +// //插入图片WorkBook +// public static void InsertPicture(File file,int row,int colunm,String outFilePath,String outFilePathp) throws IOException { +// //FileInputStream file = new FileInputStream(new File(outFilePath)); +// Workbook wb = new Workbook(); +// wb.loadFromHtml(new FileInputStream(file)); +// Worksheet sheet = wb.getWorksheets().get(0); +// //获取图片 +// InputStream input = new FileInputStream(outFilePathp); +// BufferedImage sourceImg = ImageIO.read(input); +// ExcelPicture pic1 = sheet.getPictures().add(row, colunm,sourceImg); +// +// double ColumnWidth=sheet.getColumnWidthPixels(colunm)+sheet.getColumnWidthPixels(colunm+1)+sheet.getColumnWidthPixels(colunm+2) +// +sheet.getColumnWidthPixels(colunm+3)+sheet.getColumnWidthPixels(colunm+4)+sheet.getColumnWidthPixels(colunm+5) +// +sheet.getColumnWidthPixels(colunm+6)+sheet.getColumnWidthPixels(colunm+7); +// double RowHeight=sheet.getRowHeightPixels(row)+sheet.getRowHeightPixels(row+1)+sheet.getRowHeightPixels(row+2)+sheet.getRowHeightPixels(row+3) +// +sheet.getRowHeightPixels(row+4)+sheet.getRowHeightPixels(row+5)+sheet.getRowHeightPixels(row+6) +// +sheet.getRowHeightPixels(row+7)+sheet.getRowHeightPixels(row+8)+sheet.getRowHeightPixels(row+9); +// System.out.println("图片单元格宽:"+ColumnWidth); +// System.out.println("图片单元格宽:"+RowHeight); +// //宽比、高比 +// double aaa=sourceImg.getWidth(); +// double bbbb=sourceImg.getHeight(); +// double WidthProportion=ColumnWidth/aaa; +// double HeightProportion=RowHeight/bbbb; +// if(WidthProportion>HeightProportion) { +// WidthProportion=HeightProportion; +// } +// //System.out.println("图片单元格高:"+sheet.getCellRange("K6:K6").getp.getRowHeight()); +// pic1.setWidth((int) (sourceImg.getWidth()*WidthProportion)); +// pic1.setHeight((int) (sourceImg.getHeight()*WidthProportion)); +// +// wb.saveToFile(outFilePath); +// wb.dispose(); +// input.close(); +// pic1.dispose(); +// sourceImg.flush(); +// new File(outFilePathp).delete(); +// +// +//// //消除水印 +//// File file1=new File(outFilePath); +//// FileInputStream input = new FileInputStream(file1); +//// XSSFWorkbook wb1 = new XSSFWorkbook(input); +//// wb1.removeSheetAt(1); +//// FileOutputStream output = new FileOutputStream(new File(outFilePath)); +//// wb1.write(output); +//// input.close(); +//// output.close(); +// +// } +// + + /** + * 截取字符串 + * + * @param inStr + * @return + */ + public static String changeStringToInt(String inStr) { + int index = inStr.indexOf("."); + System.out.println(index); + String outStr = null; + if (index != -1) { + + outStr = inStr.substring(0, index); + } else { + outStr = inStr; + + } + // System.out.println(outStr); + return outStr; + } + + /** + * 截取一定长度的字符串 + * + * @param inStr + * @param inLen + * @return + */ + public static String changeStringToInt(String inStr, int inLen) { + int index = inStr.indexOf("."); + inLen++; + System.out.println(index); + String outStr = null; + if (index != -1 && (inStr.length() - index) >= inLen) { + + outStr = inStr.substring(0, index + inLen); + } else { + outStr = inStr; + + } + // System.out.println(outStr); + return outStr; + } + + /** + * 将float转换成保留两位的字符串 + * + * @param f + * 需要转换的float数 + * @return + */ + public static String changeFloatToStr(float f) { + DecimalFormat decimalFormat = new DecimalFormat(".0");// 构造方法的字符格式这里如果小数不足2位,会以0补足. + String str = decimalFormat.format(f);// format 返回的是字符串 + return str; + } + + /** + * 将字符串转换成int + * + * @param str + * @return + */ + public static float changeStrToFloat(String str) { + float temp_int = 0; + try { + temp_int = Float.parseFloat(str.trim()); + return temp_int; + } catch (NumberFormatException e) { + System.out.println(e.getMessage()); + return -1; + } + } + + /** + * 设置formual的时候用来替换原有的单元格号到新的单元格号 + * + * @param originStr + * @param subStr + * @param index + * @param index2 + * @return + */ + public static String replaceSubString(String originStr, String subStr, + int index, int index2) { + StringBuffer sbO = new StringBuffer(); + sbO.append(subStr); + sbO.append(index); + StringBuffer sbR = new StringBuffer(); + sbR.append(subStr); + sbR.append(index2); + String resultStr = originStr.replace(sbO.toString(), sbR.toString()); + return resultStr; + } + + /** + * 读取EXCEL信息 + * + * @param String + * excel_file + * @return List> 返回信息 + * @throws IOException + * @throws FileNotFoundException + */ + public static List> readExcel(String excel_file) + throws FileNotFoundException, IOException { + if (excel_file == null) { + return null; + } + File file = new File(excel_file); + return readExcel(file); + } + + /** + * 获取单元格数据内容为字符串类型的数据 + * + * @param cell + * Excel单元格 + * @return String 单元格数据内容 + */ + private static String getStringCellValue(HSSFFormulaEvaluator evaluator, + HSSFCell cell) { + if (cell == null) { + return ""; + } + String strCell = ""; + + switch (cell.getCellType()) { + case STRING: + strCell = cell.getStringCellValue(); + break; + case NUMERIC: + strCell = "" + cell.getNumericCellValue(); + if (strCell.endsWith(".0")) { + strCell = strCell.substring(0, strCell.indexOf(".0")); + } + break; + case BOOLEAN: + strCell = String.valueOf(cell.getBooleanCellValue()); + break; + case BLANK: + strCell = ""; + break; + case ERROR: + strCell = String.valueOf(cell.getErrorCellValue()); + break; + case FORMULA: + CellValue value = evaluator.evaluate(cell); + try { + strCell = value.getStringValue(); + if (strCell == null) { + strCell = "" + value.getNumberValue(); + if (strCell.endsWith(".0")) { + strCell = strCell.substring(0, strCell.indexOf(".0")); + } + } + } catch (Exception e) { + + strCell = "" + value.getNumberValue(); + if (strCell.endsWith(".0")) { + strCell = strCell.substring(0, strCell.indexOf(".0")); + } + } + break; + default: + strCell = ""; + break; + } + if (strCell.equals("") || strCell == null) { + return ""; + } + return strCell; + } + + // public static void insertRow(HSSFSheet sheet, int starRow, int rows) { + // HSSFRow sourceRow = sheet.getRow(starRow); + // sheet.shiftRows(starRow + 1, sheet.getLastRowNum(), rows, true, false); + // // starRow = starRow -1; + // for (int i = 0; i < rows; i++) { + // // sheet.shiftRows(starRow + i, sheet.getLastRowNum(), 1, true, + // // false); + // HSSFRow targetRow = null; + // HSSFCell sourceCell = null; + // HSSFCell targetCell = null; + // short m; + // targetRow = sheet.createRow(starRow + 1); + // targetRow.setHeight(sourceRow.getHeight()); + // System.out.println(sourceRow.getLastCellNum()); + // for (m = sourceRow.getFirstCellNum(); m < sourceRow + // .getLastCellNum(); m++) { + // System.out.println(m); + // sourceCell = sourceRow.getCell(m); + // targetCell = targetRow.createCell(m); + // // System.out.println(" ===== " + sourceCell + " " + + // // targetCell); + // // targetCell.setEncoding(sourceCell.get); + // targetCell.setCellStyle(sourceCell.getCellStyle()); + // targetCell.setCellType(sourceCell.getCellType()); + // // targetCell.setCellValue("11111"); + // } + // } + // } + + /** + * 插入行数 + * + * @param starRow + * @param rows + */ + public static void insertRow(HSSFSheet sheet, int starRow, int rows) { + HSSFRow sourceRow = sheet.getRow(starRow); + sheet.shiftRows(starRow + 1, sheet.getLastRowNum(), rows, true, false); + for (int i = 0; i < rows; i++) { + HSSFRow targetRow = null; + HSSFCell sourceCell = null; + HSSFCell targetCell = null; + short m; + targetRow = sheet.createRow(starRow + 1); + targetRow.setHeight(sourceRow.getHeight()); + System.out.println(sourceRow.getLastCellNum()); + for (m = sourceRow.getFirstCellNum(); m < sourceRow + .getLastCellNum(); m++) { + System.out.println(m); + sourceCell = sourceRow.getCell(m); + targetCell = targetRow.createCell(m); + targetCell.setCellStyle(sourceCell.getCellStyle()); + targetCell.setCellType(sourceCell.getCellType()); + } + } + } + + /*** + * 向sheet中插入一行 + * + * @param sheet + * @param startRow + * @param rows + * @return + */ + public static HSSFSheet insertRows(HSSFSheet sheet, int startRow, int rows) { + HSSFRow sourceRow = sheet.getRow(startRow); + sheet.shiftRows(startRow + 1, sheet.getLastRowNum(), rows, true, false); + for (int i = 0; i < rows; i++) { + HSSFRow targetRow = null; + HSSFCell sourceCell = null; + HSSFCell targetCell = null; + short m; + targetRow = sheet.createRow(startRow + 1); + targetRow.setHeight(sourceRow.getHeight()); + System.out.println(sourceRow.getLastCellNum()); + for (m = sourceRow.getFirstCellNum(); m < sourceRow + .getLastCellNum(); m++) { + System.out.println(m); + sourceCell = sourceRow.getCell(m); + targetCell = targetRow.createCell(m); + targetCell.setCellStyle(sourceCell.getCellStyle()); + targetCell.setCellType(sourceCell.getCellType()); + } + } + return sheet; + } + + /** + * 检查单元格内容是否是数字 + * + * @param value + * @return + */ + public static boolean CheckCellValueIsNumber(String value) { + boolean is_ok = false; + if (value.equals("")) { + return false; + } + try { + Float.parseFloat(value); + } catch (NumberFormatException e) { + e.printStackTrace(); + System.out.println("===>" + value); + is_ok = true; + } + return is_ok; + } + + public static void setFlowChart(Map valueMap, File file) { + // TODO Auto-generated method stub + file.setWritable(true); + try { + InputStream is = new FileInputStream(file); + HSSFWorkbook wb = new HSSFWorkbook(is);// ( + //HSSFSheet sheet = wb.getSheetAt(0); + + Iterator> it = valueMap.entrySet() + .iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + setNamedCellValue(wb, entry.getKey(), entry.getValue()); + } + FileOutputStream output = new FileOutputStream(file); + wb.write(output); + output.close(); + is.close(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + //file.setReadOnly(); + System.out.println("-------WRITE EXCEL OVER-------"); + } +} diff --git a/src/com/connor/renben/process/plm/util/ExcelUtil07.java b/src/com/connor/renben/process/plm/util/ExcelUtil07.java new file mode 100644 index 0000000..e66d4a0 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ExcelUtil07.java @@ -0,0 +1,6561 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Graphics; + +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.HeadlessException; +import java.awt.Image; +import java.awt.Transparency; +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import javax.imageio.ImageIO; +import javax.swing.ImageIcon; +import javax.swing.tree.DefaultMutableTreeNode; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.SpreadsheetVersion; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellValue; +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.ss.usermodel.Name; +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.ss.util.AreaReference; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFClientAnchor; +import org.apache.poi.xssf.usermodel.XSSFDrawing; +import org.apache.poi.xssf.usermodel.XSSFFont; +import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator; +import org.apache.poi.xssf.usermodel.XSSFName; +import org.apache.poi.xssf.usermodel.XSSFRichTextString; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import com.spire.xls.ExcelPicture; +import com.spire.xls.Worksheet; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.FileUtility; +import com.teamcenter.rac.util.MessageBox; + +/** + * Excel Toolling + * + * @author hub 2015-09-06 + */ +public class ExcelUtil07 { + // private static Registry reg = Registry.getRegistry(this); + // private static XSSFSheet sheet; + // private static final int MY_ROWS = 46; + private static Map map = new HashMap(); + private static final String EXCEL_XLS = "xls"; + private static final String EXCEL_XLSX = "xlsx"; + + + public static String getID(String ID) { + if(ID.indexOf("-")>-1) { + String[] iDs=ID.split("-"); + String id=""; + for(int i=0;i> 返回的信息 + * @throws IOException + * @throws FileNotFoundException + */ +// public static List> readExcel(File excel_file) throws FileNotFoundException, IOException { +// if (excel_file == null || !excel_file.exists()) { +// return null; +// } +// // 用来返回的所有的行的信息 +// List> lines_msg = new ArrayList>(); +// XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); +// XSSFSheet sheet = workBook.getSheetAt(0); +// XSSFRow title_row = sheet.getRow(0); +// +// // 得到列的数目 +// int col_count = title_row.getPhysicalNumberOfCells(); +// System.out.println(" SHEET COL COUNT " + col_count); +// // 得到行的数目 +// int row_count = sheet.getLastRowNum(); +// System.out.println(" SHEET ROW COUNT " + row_count); +// for (int j = 0; j < row_count + 1; j++) { +// // 用来返回单行的信息 +// XSSFRow row = sheet.getRow(j); +// List line_msg = new ArrayList(); +// for (int i = 0; i < col_count; i++) { +// String value = getStringCellValue(evaluator, row.getCell((short) i)); +// line_msg.add(value); +// } +// lines_msg.add(line_msg); +// } +// // insertRow(sheet,4,1); +// return lines_msg; +// } +// +// /** +// * 读取控制计划EXCEL表 +// * +// * @param File excel_file +// * @return List> 返回的信息 +// * @throws IOException +// * @throws FileNotFoundException +// */ +// public static List> readControlPlanExcel(File excel_file) throws FileNotFoundException, IOException { +// if (excel_file == null || !excel_file.exists()) { +// return null; +// } +// // 用来返回的所有的行的信息 +// List> lines_msg = new ArrayList>(); +// XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); +// XSSFSheet sheet = workBook.getSheetAt(0); +// XSSFRow title_row = sheet.getRow(0); +// int startRow = 9; +// // 获取合并单元格 +// Map regionCellMap = getRegionCell(sheet); +// +// // 得到列的数目 +// int col_count = title_row.getPhysicalNumberOfCells(); +// System.out.println(" SHEET COL COUNT " + col_count); +// // 得到行的数目 +// int row_count = sheet.getLastRowNum(); +// System.out.println(" SHEET ROW COUNT " + row_count); +// for (int j = startRow; j < row_count + 1; j++) { +// // 用来返回单行的信息 +// XSSFRow row = sheet.getRow(j); +// List line_msg = new ArrayList(); +// for (int i = 0; i < 15; i++) { +// if(i== 5 || i == 10) +// { +// continue; +// } +// String value = getStringCellValue(evaluator, row.getCell((short) i)); +// if (value == null || value.equals("")) { +// line_msg.add(getRegionValue(workBook, sheet, j, i)); +// } else { +// line_msg.add(value); +// } +// } +// // 行号 +// line_msg.add(((Integer) (j - startRow)).toString()); +// // 合并单元格 +// line_msg.add(toControlPlanRegionCell(regionCellMap, j)); +// if (line_msg.get(0) != null) { +// lines_msg.add(line_msg); +// } +// } +// // insertRow(sheet,4,1); +// return lines_msg; +// } +// +// /** +// * 读取委托内容EXCEL表 +// * +// * @param File excel_file +// * @return List> 返回的信息 +// * @throws IOException +// * @throws FileNotFoundException +// */ +// public static List> readEntrustingContentExcel(File excel_file) +// throws FileNotFoundException, IOException { +// if (excel_file == null || !excel_file.exists()) { +// return null; +// } +// // 用来返回的所有的行的信息 +// List> lines_msg = new ArrayList>(); +// XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); +// XSSFSheet sheet = workBook.getSheetAt(0); +// XSSFRow title_row = sheet.getRow(0); +// int startRow = 0; +// // 获取合并单元格 +// Map regionCellMap = getEntrustingContentRegionCell(sheet); +// +// // 得到列的数目 +// int col_count = title_row.getPhysicalNumberOfCells(); +// System.out.println(" SHEET COL COUNT " + col_count); +// // 得到行的数目 +// int row_count = sheet.getLastRowNum(); +// System.out.println(" SHEET ROW COUNT " + row_count); +// for (int j = startRow; j < row_count + 1; j++) { +// // 用来返回单行的信息 +// XSSFRow row = sheet.getRow(j); +// List line_msg = new ArrayList(); +// for (int i = 0; i < 3; i++) { +// String value = getStringCellValue(evaluator, row.getCell((short) i)); +// if (value == null || value.equals("")) { +// line_msg.add(getRegionValue(workBook, sheet, j, i)); +// } else { +// line_msg.add(value); +// } +// } +// // 合并单元格 +// line_msg.add(toEntrustingContentRegionCell(regionCellMap, j)); +// if (line_msg.get(0) != null) { +// lines_msg.add(line_msg); +// } +// } +// // insertRow(sheet,4,1); +// return lines_msg; +// } +// +// public static void main(String[] args) { +// try { +// List> strList = readExcel(new File("F:\\Connor(项目管理)\\东睦项目\\东睦系统\\控制计划\\生产控制计划模板3.xlsx")); +// for (List list : strList) { +// for (String str : list) { +// System.out.print(str + "|"); +// } +// System.out.println(); +// } +// +// } catch (FileNotFoundException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// +// public void writeSignName(String intExcelFilePath, String outExcelFilePath, String signName, String msgValue, +// int sheetIndex, int rowIndex, int cellIndex) throws IOException { +// // 输出文件的路径 +// FileOutputStream outPut = new FileOutputStream(new File(outExcelFilePath)); +// // 输入文件的路径 +// FileInputStream inPut = new FileInputStream(new File(intExcelFilePath)); +// XSSFWorkbook wb = new XSSFWorkbook(inPut); +// wb.getName(""); +// AreaReference[] areaR2 = AreaReference.generateContiguous(SpreadsheetVersion.EXCEL2007 ,wb.getName("").getRefersToFormula()); +// AreaReference areaR = null; +// CellReference[] cellR = areaR.getAllReferencedCells(); +// cellR[0].getSheetName();// s +// cellR[0].getCol();// +// cellR[0].getRow();// +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); +// XSSFSheet sheet = wb.getSheetAt(sheetIndex); +// XSSFRow row = sheet.getRow(rowIndex); +// XSSFCell cell = row.getCell(cellIndex); +// String value = getStringCellValue(evaluator, cell); +// if (value.startsWith(signName)) { +// value = value.substring(0, signName.length()); +// } +// cell.setCellValue(value + msgValue); +// wb.write(outPut); +// inPut.close(); +// outPut.close(); +// } + + /*** + * 写入到EXCEL数据 (写入单种数据) + * + * @param xls_write_Address + * @param beanListAll + * @param sheetnames + * @throws IOException + */ + /* + * public void writeExcel(String xls_write_Address, String path, + * List beanListAll, int index) throws IOException { + * FileOutputStream output = new FileOutputStream(new File(path)); // 读取的文件路径 + * FileInputStream input = new FileInputStream(new File(xls_write_Address)); + * XSSFWorkbook wb = new XSSFWorkbook(input);// (new XSSFSheet sheet = + * wb.getSheetAt(0); for (int i = 0; i < beanListAll.size(); i++) { + * JFomPasteBean bean = beanListAll.get(i); XSSFRow row = null; Boolean isCreat + * = false; if ((i + 3) > sheet.getLastRowNum()) { row = sheet.createRow(i + 3); + * isCreat = true; } else { row = sheet.getRow(i + 3); isCreat = false; } + * + * for (int cols = 0; cols < 7; cols++) { XSSFCell cell = null; if (isCreat) { + * cell = row.createCell(cols); } else { cell = row.getCell(cols); } + * cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 switch (cols) { + * + * case 0: cell.setCellValue(bean.getIndexStr());// 写入内容 break; case 1: + * cell.setCellValue(bean.getProductName());// 写入内容 break; case 2: // + * cell.setCellValue(bean.getPicturePath());// 写入内容 insertPicture(wb, sheet, + * bean.getPicturePath(), (short) 2, (i + 3)); break; case 3: + * cell.setCellValue(bean.getDatasetName());// 写入内容 break; case 4: + * cell.setCellValue(bean.getItemRevisionId());// 写入内容 break; case 5: + * cell.setCellValue("");// 写入内容 + * + * break; case 6: // cell.setCellType(XSSFCell.CELL_TYPE_);// 文本格式 + * cell.setCellValue(bean.getReleaseDateStr());// 写入内容 break; + * + * } } } // } wb.write(output); output.close(); input.close(); + * System.out.println("-------WRITE EXCEL OVER-------"); } + */ + /** + * 获取单个的命名单元格的内容 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ +// public static String getNamedCellValue(XSSFWorkbook wb, String cellName) throws IOException { +// String value = null; +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); +// XSSFName name = wb.getName(cellName); +// if (name == null) { +// return ""; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(SpreadsheetVersion.EXCEL2007 ,name.getRefersToFormula()); +// if (areaRs != null) +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// short colIndex = cellR.getCol(); +// int rowIndex = cellR.getRow(); +// XSSFSheet sheet = wb.getSheet(sheetName); +// XSSFRow row = sheet.getRow(rowIndex); +// XSSFCell cell = row.getCell(colIndex); +// value = getStringCellValue(evaluator, cell); +// } +// } +// } +// return value; +// } + + /** + * 设置单个的命名单元格的内容 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static void setNamedCellValue(XSSFWorkbook wb, String cellName, String cellValue) throws IOException { + XSSFName name = wb.getName(cellName); + if (name == null) { + return; + } + AreaReference[] areaRs = AreaReference.generateContiguous(SpreadsheetVersion.EXCEL2007 ,name.getRefersToFormula()); + if (areaRs != null) { + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + XSSFSheet sheet = wb.getSheet(sheetName); + XSSFRow row = sheet.getRow(rowIndex); + XSSFCell cell = row.getCell(colIndex); + cell.setCellValue(cellValue); + } + } + } + } + } + + /** + * 插入图片到指定的单元格中 + * + * @param wb + * @param sheet1 + * @param picPath + * @param colIndex + * @param rowIndex + */ +// public static void insertPicture(XSSFWorkbook wb, XSSFSheet sheet1, ImageIcon imageIcon, String cellName, +// double columns, int rows) { +// +// // 先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray +// try { +// if (imageIcon == null) { +// return; +// } +// ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); +// ImageIO.write(toBufferedImage(imageIcon.getImage()), "jpg", byteArrayOut); +// // 画图的顶级管理器,一个sheet只能获取一个(一定要注意这点) +// XSSFDrawing patriarch = sheet1.createDrawingPatriarch(); +// // anchor主要用于设置图片的属性 +// XSSFName name = wb.getName(cellName); +// if (name == null) { +// return; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(SpreadsheetVersion.EXCEL2007 ,name.getRefersToFormula()); +// if (areaRs != null) { +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// short colIndex = cellR.getCol(); +// int rowIndex = cellR.getRow(); +// XSSFSheet sheet = wb.getSheet(sheetName); +// XSSFRow row = sheet.getRow(rowIndex); +// XSSFClientAnchor anchor = new XSSFClientAnchor(13, 13, 0, 0, (short) colIndex, rowIndex, +// (short) (colIndex + columns), rowIndex + rows); +// anchor.setAnchorType(3); +// // 插入图片 +// patriarch.createPicture(anchor, +// wb.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_JPEG)); +// } +// } +// } +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// +// /** +// * 将Image转BufferedImage +// * +// * @param image +// * @return +// */ +// public static BufferedImage toBufferedImage(Image image) { +// if (image instanceof BufferedImage) { +// return (BufferedImage) image; +// } +// +// // This code ensures that all the pixels in the image are loaded +// image = new ImageIcon(image).getImage(); +// +// // Determine if the image has transparent pixels; for this method's +// // implementation, see e661 Determining If an Image Has Transparent Pixels +// // boolean hasAlpha = hasAlpha(image); +// +// // Create a buffered image with a format that's compatible with the screen +// BufferedImage bimage = null; +// GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); +// try { +// // Determine the type of transparency of the new buffered image +// int transparency = Transparency.OPAQUE; +// /* +// * if (hasAlpha) { transparency = Transparency.BITMASK; } +// */ +// +// // Create the buffered image +// GraphicsDevice gs = ge.getDefaultScreenDevice(); +// GraphicsConfiguration gc = gs.getDefaultConfiguration(); +// bimage = gc.createCompatibleImage(image.getWidth(null), image.getHeight(null), transparency); +// } catch (HeadlessException e) { +// // The system does not have a screen +// } +// +// if (bimage == null) { +// // Create a buffered image using the default color model +// int type = BufferedImage.TYPE_INT_RGB; +// // int type = BufferedImage.TYPE_3BYTE_BGR;//by wang +// /* +// * if (hasAlpha) { type = BufferedImage.TYPE_INT_ARGB; } +// */ +// bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type); +// } +// +// // Copy image to buffered image +// Graphics g = bimage.createGraphics(); +// +// // Paint the image onto the buffered image +// g.drawImage(image, 0, 0, null); +// g.dispose(); +// +// return bimage; +// } +// +// /*** +// * 写入到EXCEL数据 (写入单种数据) +// * +// * @param xls_write_Address +// * @param ls +// * @param sheetnames +// * @throws IOException +// */ +// public void writeExcel(String xls_write_Address, ArrayList ls, String[] sheetnames) throws IOException { +// FileOutputStream output = new FileOutputStream(new File(xls_write_Address)); // 读取的文件路径 +// XSSFWorkbook wb = new XSSFWorkbook();// (new +// // BufferedInputStream(output)); +// for (int sn = 0; sn < ls.size(); sn++) { +// XSSFSheet sheet = wb.createSheet(String.valueOf(sn)); +// wb.setSheetName(sn, sheetnames[sn]); +// ArrayList ls2 = ls.get(sn); +// for (int i = 0; i < ls2.size(); i++) { +// XSSFRow row = sheet.createRow(i); +// String[] s = ls2.get(i); +// for (int cols = 0; cols < s.length; cols++) { +// XSSFCell cell = row.createCell(cols); +// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +// cell.setCellValue(s[cols]);// 写入内容 +// } +// } +// } +// wb.write(output); +// output.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// } +// +// /** +// * 根据单元格的名字来找到单元格的内容 +// * +// * @param inputFilePath +// * @param cellName +// * @return +// */ +// public static List getExcelNamedCellValue(String inputFilePath, String[] cellNames) { +// List valueList = new ArrayList(); +// if (!new File(inputFilePath).exists()) { +// for (int i = 0; i < cellNames.length; i++) +// valueList.add(""); +// return valueList; +// } +// try { +// FileInputStream is = new FileInputStream(new File(inputFilePath)); +// XSSFWorkbook wb = new XSSFWorkbook(is); +// for (String name : cellNames) +// valueList.add(getNamedCellValue(wb, name)); +// is.close(); +// } catch (FileNotFoundException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return valueList; +// } +// +// /** +// * 针对工程变更的信息写入 +// * +// * @param xls_write_Address +// * @param ls +// * @throws IOException +// */ +// /* +// * public static void writeExcel(String outPath, InputStream input, +// * List beanListAll) throws IOException { +// * +// * FileOutputStream output = new FileOutputStream(new File(outPath)); // 读取的文件路径 +// * // FileInputStream input= new FileInputStream(); XSSFWorkbook wb = new +// * XSSFWorkbook(input);// (new XSSFSheet sheet = wb.getSheetAt(0); int startRow +// * = 2; for (int i = 0; i < beanListAll.size(); i++) { JFomProjectChangeBean +// * bean = beanListAll.get(i); XSSFRow row = null; Boolean isCreat = false; if +// * ((i + startRow) > sheet.getLastRowNum()) { row = sheet.createRow(i + +// * startRow); isCreat = true; } else { row = sheet.getRow(i + startRow); isCreat +// * = false; } +// * +// * for (int cols = 0; cols < 12; cols++) { XSSFCell cell = null; if (isCreat) { +// * cell = row.createCell(cols); } else { cell = row.getCell(cols); } +// * cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 switch (cols) { +// * +// * case 0: cell.setCellValue(bean.getIndexStr());// 写入内容 break; case 1: +// * cell.setCellValue(bean.getECRCode());// 写入内容 break; case 2: +// * cell.setCellValue(bean.getInternalCode());// 写入内容 break; case 3: +// * cell.setCellValue(bean.getDrawingNo());// 写入内容 break; case 4: +// * cell.setCellValue(bean.getPartStatus());// 写入内容 break; case 5: +// * cell.setCellValue(bean.getInitiator());// 写入内容 break; case 6: +// * cell.setCellValue(bean.getSureDate());// 写入内容 break; case 7: +// * cell.setCellValue(bean.getChangeMsgBef());// 写入内容 break; case 8: +// * cell.setCellValue(bean.getChangeMsg());// 写入内容 break; case 9: +// * cell.setCellValue(bean.getChargePerson());// 写入内容 break; case 10: +// * cell.setCellValue("");// 写入内容 break; case 11: cell.setCellValue("");// 写入内容 +// * break; } } } // } wb.write(output); output.close(); input.close(); +// * System.out.println("-------WRITE EXCEL OVER-------"); } +// */ +// /** +// * 设置单元格 +// * +// * @param row1 +// * @param index +// * @param str +// */ +// public static void setCellValue(XSSFRow row1, int index, String str) { +// XSSFCell cell = row1.getCell(index); +// cell.setCellType(XSSFCell.CELL_TYPE_STRING); +// cell.setCellValue(str); +// } +// +// /** +// * 设置单元格 +// * +// * @param row1 +// * @param index +// * @param str +// */ +// public static void setCellValue(Row row1, int index, String str) { +// Cell cell = row1.getCell(index); +// cell.setCellType(XSSFCell.CELL_TYPE_STRING); +// cell.setCellValue(str); +// } +// +// /** +// * 针对工程变更的信息写入 +// * +// * @param xls_write_Address +// * @param ls +// * @throws IOException +// */ +// /* +// * public static void writeExcelBomExport(String outPath, InputStream input, +// * List beanListAll, JFomBomExportProjBean projBean) throws +// * IOException { +// * +// * FileOutputStream output = new FileOutputStream(new File(outPath)); // 读取的文件路径 +// * // FileInputStream input= new FileInputStream(); XSSFWorkbook wb = new +// * XSSFWorkbook(input);// (new XSSFSheet sheet = wb.getSheetAt(0); int startRow +// * = 4; if (projBean != null) { XSSFRow row1 = sheet.getRow(0); +// * setCellValue(row1, 11, projBean.getPROJ_NAME()); setCellValue(row1, 14, +// * projBean.getPROJ_MODE()); setCellValue(row1, 16, projBean.getPRODUCT_LIFE()); +// * row1 = sheet.getRow(1); setCellValue(row1, 11, projBean.getPROJ_CUSTOMER()); +// * setCellValue(row1, 14, projBean.getPROJ_MEMBER()); } for (int i = 0; i < +// * beanListAll.size(); i++) { JFomBomExportBean bean = beanListAll.get(i); +// * XSSFRow row = null; Boolean isCreat = false; if ((i + startRow) > +// * sheet.getLastRowNum()) { row = sheet.createRow(i + startRow); isCreat = true; +// * } else { row = sheet.getRow(i + startRow); isCreat = false; } +// * +// * for (int cols = 0; cols < 22; cols++) { XSSFCell cell = null; if (isCreat) { +// * cell = row.createCell(cols); } else { cell = row.getCell(cols); } +// * cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 int indexStr = +// * bean.getIndexStr(); if (cols == (indexStr + 1)) { +// * cell.setCellValue(JFomUtil.JF3_INDEX_STR);// 写入内容 } +// * +// * switch (cols) { +// * +// * case 0: cell.setCellValue(bean.getIndexExt());// 写入内容 break; case 7: +// * cell.setCellValue(bean.getWlNumber());// 写入内容 break; case 8: +// * cell.setCellValue(bean.getMPS()); break; case 9: +// * cell.setCellValue(bean.getCustomerNo()); break; case 10: +// * cell.setCellValue(bean.getWlName()); break; case 11: +// * cell.setCellValue(bean.getK3code()); break; case 12: insertPicture(wb, sheet, +// * bean.getPicturePath(), (short) 14, i + startRow); break; case 13: +// * cell.setCellValue(bean.getMaterialName()); break; case 14: +// * cell.setCellValue(bean.getMaterialSize()); break; case 15: +// * cell.setCellValue(bean.getMaterialStander()); break; case 16: +// * cell.setCellValue(bean.getMaterialPark()); break; case 17: +// * cell.setCellValue(bean.getJingzhong()); break; case 18: +// * cell.setCellValue(bean.getMaozhong()); break; case 19: +// * cell.setCellValue(bean.getGongyi()); break; case 20: +// * cell.setCellValue(bean.getGongyingshang()); break; default: break; } } } // } +// * wb.write(output); output.close(); input.close(); +// * System.out.println("-------WRITE EXCEL OVER-------"); } +// */ +// public static void insertPicture(XSSFWorkbook wb, XSSFSheet sheet1, String picPath, short colIndex, int rowIndex) { +// +// // FileOutputStream fileOut = null; +// BufferedImage bufferImg = null; +// // 先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray +// try { +// if (!new File(picPath).exists()) { +// return; +// } +// String dexStr = picPath.substring(picPath.lastIndexOf(".") + 1, picPath.length()); +// ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); +// System.out.println(picPath); +// bufferImg = ImageIO.read(new File(picPath)); +// ImageIO.write(bufferImg, dexStr, byteArrayOut); +// // XSSFWorkbook wb = new XSSFWorkbook(); +// // XSSFSheet sheet1 = wb.createSheet("test picture"); +// // 画图的顶级管理器,一个sheet只能获取一个(一定要注意这点) +// XSSFDrawing patriarch = sheet1.createDrawingPatriarch(); +// // anchor主要用于设置图片的属性 +// XSSFClientAnchor anchor = new XSSFClientAnchor(13, 13, 0, 0, (short) colIndex, rowIndex, +// (short) (colIndex + 1), rowIndex + 1); +// anchor.setAnchorType(3); +// // 插入图片 +// patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_JPEG)); +// +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// } +// //复制图片 +// public static void CopyPic(File path1,String path2) { +// // 创建文件字节输入流对象 +// FileInputStream fis = null; +// // 创建文件字节输出流对象 +// FileOutputStream fos = null; +// +// try { +// // 连接文件字节输入流 +// fis = new FileInputStream(path1); +// // 连接文件字节输出流 +// fos = new FileOutputStream(path2); +// +// //准备一个byte[]数组,存储字节码,大小为1024字节,即1KB +// byte[] bytes = new byte[1024]; +// +// int readCount = 0; +// // 开始读和写 +// while ((readCount = fis.read(bytes)) != -1) { +// // 将数组中读到的字节码写入 +// fos.write(bytes, 0, readCount); +// } +// +// // 最后刷新管道,强制输出完数据 +// fos.flush(); +// +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); +// } finally { +// if (fis != null) { +// try { +// fis.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// if (fos != null) { +// try { +// fos.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// } +// } +// +// // +// +// +// +// /** +// * 移除合并的单元格 合并单元格sheet.addMergedRegion(new CellRangeAddress(check_index-1, +// * check_index+12+check_rows, 0, 0)); +// * +// * @param startRow +// * @param endRow +// * @return +// */ +// public static boolean removeMergen(XSSFSheet sheet, int startRow, int endRow) { +// boolean isOK = false; +// int count = sheet.getNumMergedRegions(); +// for (int i = 0; i < count; i++) { +// CellRangeAddress address = sheet.getMergedRegion(i); +// System.out.println(address.getFirstRow() + "|" + address.getLastRow()); +// if (address.getFirstRow() == startRow && address.getLastRow() == endRow) { +// sheet.removeMergedRegion(i); +// isOK = true; +// break; +// } +// } +// return isOK; +// } +// +// /** +// * 合并单元格sheet.addMergedRegion(new CellRangeAddress(check_index-1, +// * check_index+12+check_rows, 0, 0)); +// * +// * @param startRow +// * @param endRow +// * @return +// */ +// public static boolean combine(XSSFSheet sheet, int[] rows, int[] columns) { +// boolean isOK = false; +// if (rows.length > 0 && columns.length > 0) { +// sheet.addMergedRegion( +// new CellRangeAddress(rows[0], rows[rows.length - 1], columns[0], columns[columns.length - 1])); +// isOK = true; +// } +// return isOK; +// } +// +// /** +// * 截取字符串 +// * +// * @param inStr +// * @return +// */ +// public static String changeStringToInt(String inStr) { +// int index = inStr.indexOf("."); +// System.out.println(index); +// String outStr = null; +// if (index != -1) { +// +// outStr = inStr.substring(0, index); +// } else { +// outStr = inStr; +// +// } +// // System.out.println(outStr); +// return outStr; +// } +// +// /** +// * 截取一定长度的字符串 +// * +// * @param inStr +// * @param inLen +// * @return +// */ +// public static String changeStringToInt(String inStr, int inLen) { +// int index = inStr.indexOf("."); +// inLen++; +// System.out.println(index); +// String outStr = null; +// if (index != -1 && (inStr.length() - index) >= inLen) { +// +// outStr = inStr.substring(0, index + inLen); +// } else { +// outStr = inStr; +// +// } +// // System.out.println(outStr); +// return outStr; +// } +// +// /** +// * 将float转换成保留两位的字符串 +// * +// * @param f 需要转换的float数 +// * @return +// */ +// public static String changeFloatToStr(float f) { +// DecimalFormat decimalFormat = new DecimalFormat(".0");// 构造方法的字符格式这里如果小数不足2位,会以0补足. +// String str = decimalFormat.format(f);// format 返回的是字符串 +// return str; +// } +// +// /** +// * 将字符串转换成int +// * +// * @param str +// * @return +// */ +// public static float changeStrToFloat(String str) { +// float temp_int = 0; +// try { +// temp_int = Float.parseFloat(str.trim()); +// return temp_int; +// } catch (NumberFormatException e) { +// System.out.println(e.getMessage()); +// return -1; +// } +// } +// +// /** +// * 设置formual的时候用来替换原有的单元格号到新的单元格号 +// * +// * @param originStr +// * @param subStr +// * @param index +// * @param index2 +// * @return +// */ +// public static String replaceSubString(String originStr, String subStr, int index, int index2) { +// StringBuffer sbO = new StringBuffer(); +// sbO.append(subStr); +// sbO.append(index); +// StringBuffer sbR = new StringBuffer(); +// sbR.append(subStr); +// sbR.append(index2); +// String resultStr = originStr.replace(sbO.toString(), sbR.toString()); +// return resultStr; +// } +// +// /** +// * 读取EXCEL信息 +// * +// * @param String excel_file +// * @return List> 返回信息 +// * @throws IOException +// * @throws FileNotFoundException +// */ +// public static List> readExcel(String excel_file) throws FileNotFoundException, IOException { +// if (excel_file == null) { +// return null; +// } +// File file = new File(excel_file); +// // 获取EXCEL数据的具体逻辑的函数 +// return readExcel(file); +// } +// +// /** +// * 获取作业指导书Bean +// * +// * @param result +// * @return +// */ +// public static List getCXBean(Map> result) { +// List cxBeans = new ArrayList(); +// for (Integer key : result.keySet()) { +// CXBean cxBean = new CXBean(); +// cxBean.setNo((int) Float.parseFloat(result.get(key).get(3))); +// cxBean.setJcxm((result.get(key).get(6))); +// cxBean.setJsyq(result.get(key).get(9)); +// cxBean.setClqj((result.get(key).get(10))); +// cxBean.setZjpc(result.get(key).get(11) + "&" + result.get(key).get(12)); +// if (result.get(key).contains("xj")) { +// cxBean.setZjpc(""); +// cxBean.setXjpc(result.get(key).get(11) + "&" + result.get(key).get(12)); +// } else { +// cxBean.setXjpc(result.get(key).get(result.get(key).size() - 2) + "&" +// + result.get(key).get(result.get(key).size() - 1)); +// } +// cxBean.setTstx(result.get(key).get(8)); +// cxBean.setSj(true); +// if (result.get(key).get(12).indexOf("末件") > -1) { +// cxBean.setMj(true); +// } +// cxBeans.add(cxBean); +// } +// return cxBeans; +// } +// +// public static String combinationString(String s) { +// String result = ""; +// List sList = new ArrayList(); +// List sList2 = new ArrayList(); +// if (s.indexOf("&") > -1) { +// String[] ss = s.split("&"); +// if (ss[0].indexOf("/") > -1) { +// String[] sss = ss[0].split("/"); +// for (int i = 0; i < sss.length; i++) { +// sList.add(sss[i]); +// } +// } else { +// sList.add(ss[0]); +// } +// if (ss[1].indexOf("/") > -1) { +// String[] sss = ss[1].split("/"); +// for (int i = 0; i < sss.length; i++) { +// sList2.add(sss[i]); +// } +// } else { +// sList2.add(ss[1]); +// } +// +// if (sList.size() == sList2.size()) { +// StringBuffer sb = new StringBuffer(); +// for (int i = 0; i < sList.size(); i++) { +// sb.append(sList.get(i) + "/" + sList2.get(i) + "&"); +// } +// if (sb != null && sb.length() != 0) { +// result = sb.substring(0, sb.length() - 1); +// } +// } +// } +// return result; +// +// } +// +// /** +// * 读取控制计划信息 +// * +// * @param String excel_file +// * @return List> 返回信息 +// * @throws IOException +// * @throws FileNotFoundException +// */ +// public static Map> readExcel(String excel_file, String cellName) +// throws FileNotFoundException, IOException { +// if (excel_file == null) { +// return null; +// } +// File file = new File(excel_file); +// XSSFWorkbook xwb = new XSSFWorkbook(new FileInputStream(file)); +// Map> result = new LinkedHashMap>(); +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(xwb); +// XSSFSheet sheet = xwb.getSheetAt(0); +// XSSFRow row; +// String cell; +// for (int i = sheet.getFirstRowNum(); i < sheet.getPhysicalNumberOfRows(); i = i + 2) { +// +// row = sheet.getRow(i); +// if (getRegionValue(xwb, sheet, i, 1).toString().equals(cellName)) { +// List rowValue = new ArrayList(); +// int lastRow = getRegionIndex(sheet, i, 1, cellName); +// for (int j = row.getFirstCellNum(); j < row.getLastCellNum(); j++) { +// if (j == 10) { +// continue; +// } +// if ((row.getCell(j) == null || row.getCell(j).toString().equals("")) && i <= lastRow) { +// String s = getRegionValue(xwb, sheet, i, j); +// if (s == null) { +// cell = ""; +// } else { +// if (j == 9) { +// if (row.getCell(10) != null && !row.getCell(10).toString().equals("")) { +// s = s + "/" + sheet.getRow(i - 1).getCell(10).toString() + "/" +// + row.getCell(10).toString(); +// } +// } +// cell = s; +// } +// } else { +// cell = getStringCellValue(evaluator, row.getCell(j)); +// } +// System.out.print(cell + ","); +// rowValue.add(cell); +// } +// result.put((int) Float.parseFloat(rowValue.get(3)), rowValue); +// } +// System.out.println("**********************"); +// } +// return result; +// } +// +// /** +// * 获取单个的命名单元格的位置 +// * +// * @param wb +// * @param cellName +// * @return +// * @throws IOException +// */ +// public static int[] getNamedCellIndex(XSSFWorkbook wb, String cellName) throws IOException { +// int[] index = new int[2]; +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); +// XSSFName name = wb.getName(cellName); +// if (name == null) { +// return null; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); +// if (areaRs != null) { +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// index[0] = cellR.getCol(); +// index[1] = cellR.getRow(); +// // colIndex = cellR.getCol(); +// // rowIndex = cellR.getRow(); +// } +// } +// } +// } +// return index; +// } +// +// /** +// * 获取单个的命名单元格的列 +// * +// * @param wb +// * @param cellName +// * @return +// * @throws IOException +// */ +// public static int getNamedColumnIndex(XSSFWorkbook wb, String cellName) throws IOException { +// int index = -1; +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); +// XSSFName name = wb.getName(cellName); +// if (name == null) { +// return -1; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); +// if (areaRs != null) +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// short colIndex = cellR.getCol(); +// int rowIndex = cellR.getRow(); +// XSSFSheet sheet = wb.getSheet(sheetName); +// XSSFRow row = sheet.getRow(rowIndex); +// return colIndex; +// } +// } +// } +// return index; +// } +// +// /** +// * 获取合并单元格内容 +// * +// * @param sheet +// * @param rowIndex +// * @param cellIndex +// * @return +// */ +// public static String getRegionValue(XSSFWorkbook workbook, XSSFSheet sheet, int rowIndex, int cellIndex) { +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workbook); +// for (int i = 0; i < sheet.getNumMergedRegions(); i++) { +// CellRangeAddress region = sheet.getMergedRegion(i); +// int colIndex = region.getFirstColumn(); +// int lastColIndex = region.getLastColumn(); +// int rowNum = region.getFirstRow(); +// int lastRowNum = region.getLastRow(); +// // System.out.println(rowNum+"+++++++"+colIndex+"++++++++++"+lastRowNum+"++++++++++++"+lastColIndex); +// if (rowIndex <= lastRowNum && rowIndex >= rowNum && cellIndex <= lastColIndex && cellIndex >= colIndex) { +// return getStringCellValue(evaluator, sheet.getRow(rowNum).getCell((short) colIndex)); +// } +// } +// return null; +// } +// +// /** +// * 获取EXCEL合并单元格 +// * +// * @param sheet +// * @param rowIndex +// * @param cellIndex +// * @return +// */ +// public static Map getRegionCell(XSSFSheet sheet) { +// Map regionCellMap = new HashMap(); +// for (int i = 0; i < sheet.getNumMergedRegions(); i++) { +// CellRangeAddress region = sheet.getMergedRegion(i); +// int colIndex = region.getFirstColumn(); +// int lastColIndex = region.getLastColumn(); +// int rowNum = region.getFirstRow(); +// int lastRowNum = region.getLastRow(); +// if (rowNum >= 13) { +// // System.out.println(rowNum+"+++++++"+colIndex+"++++++++++"+lastRowNum+"++++++++++++"+lastColIndex); +// // 行集合 +// int[] rows = new int[lastRowNum - (rowNum - 1)]; +// // 列集合 +// for (int j = 0; j < rows.length; j++) { +// rows[j] = rowNum + j; +// } +// int[] columns = new int[lastColIndex - (colIndex - 1)]; +// for (int j = 0; j < columns.length; j++) { +// columns[j] = colIndex + j + 1; +// } +// regionCellMap.put(rows, columns); +// } +// } +// return regionCellMap; +// } +// +// /** +// * 获取EXCEL合并单元格 +// * +// * @param sheet +// * @param rowIndex +// * @param cellIndex +// * @return +// */ +// public static Map getEntrustingContentRegionCell(XSSFSheet sheet) { +// Map regionCellMap = new HashMap(); +// for (int i = 0; i < sheet.getNumMergedRegions(); i++) { +// CellRangeAddress region = sheet.getMergedRegion(i); +// int colIndex = region.getFirstColumn(); +// int lastColIndex = region.getLastColumn(); +// int rowNum = region.getFirstRow(); +// int lastRowNum = region.getLastRow(); +// if (rowNum >= 0) { +// // System.out.println(rowNum+"+++++++"+colIndex+"++++++++++"+lastRowNum+"++++++++++++"+lastColIndex); +// // 行集合 +// int[] rows = new int[lastRowNum - (rowNum - 1)]; +// // 列集合 +// for (int j = 0; j < rows.length; j++) { +// rows[j] = rowNum + j; +// } +// int[] columns = new int[lastColIndex - (colIndex - 1)]; +// for (int j = 0; j < columns.length; j++) { +// columns[j] = colIndex + j + 1; +// } +// regionCellMap.put(rows, columns); +// } +// } +// return regionCellMap; +// } +// +// /** +// * 转换为控制计划合并单元格 +// * +// * @param sheet +// * @param rowIndex +// * @param cellIndex +// * @return +// */ +// public static String toControlPlanRegionCell(Map regionCell, int row) { +// Iterator> it = regionCell.entrySet().iterator(); +// StringBuffer sb = new StringBuffer(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// StringBuffer rowSb = new StringBuffer(); +// StringBuffer columnSb = new StringBuffer(); +// for (int k = 0; k < entry.getKey().length; k++) { +// rowSb.append(entry.getKey()[k] - 13); +// rowSb.append(","); +// } +// for (int k = 0; k < entry.getValue().length; k++) { +// columnSb.append(entry.getValue()[k]); +// columnSb.append(","); +// } +// if (entry.getKey()[0] == row) { +// sb.append(rowSb.substring(0, rowSb.length() - 1) + "/" + columnSb.substring(0, columnSb.length() - 1) +// + "-"); +// } +// } +// if (sb.length() > 0) { +// return sb.toString().substring(0, sb.length() - 1); +// } else { +// return ""; +// } +// } +// +// /** +// * 转换为委托内容合并单元格 +// * +// * @param sheet +// * @param rowIndex +// * @param cellIndex +// * @return +// */ +// public static String toEntrustingContentRegionCell(Map regionCell, int row) { +// Iterator> it = regionCell.entrySet().iterator(); +// StringBuffer sb = new StringBuffer(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// StringBuffer rowSb = new StringBuffer(); +// StringBuffer columnSb = new StringBuffer(); +// for (int k = 0; k < entry.getKey().length; k++) { +// rowSb.append(entry.getKey()[k]); +// rowSb.append(","); +// } +// for (int k = 0; k < entry.getValue().length; k++) { +// columnSb.append(entry.getValue()[k] - 1); +// columnSb.append(","); +// } +// if (entry.getKey()[0] == row) { +// sb.append(rowSb.substring(0, rowSb.length() - 1) + "/" + columnSb.substring(0, columnSb.length() - 1) +// + "-"); +// } +// } +// if (sb.length() > 0) { +// return sb.toString().substring(0, sb.length() - 1); +// } else { +// return ""; +// } +// } +// +// /** +// * 设置单元格中指定字体的样式 +// * +// * @param wb +// * @param s 内容 +// * @param firstIndex 起始位置 +// * @param lastIndex 结束位置 +// * @param fontSize 字体大小 +// * @param FontName 字体样式 +// * @return +// */ +// public static XSSFRichTextString setCellFont(XSSFWorkbook wb, String s, int firstIndex, int lastIndex, int fontSize, +// String FontName) { +// XSSFRichTextString ts = new XSSFRichTextString(s); +// XSSFFont font1 = (XSSFFont) wb.createFont(); +// font1.setFontHeightInPoints((short) 8); // 字体高度 +// font1.setFontName("宋体"); // 字体 +// // font1.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 +// XSSFFont font = (XSSFFont) wb.createFont(); +// font.setFontHeightInPoints((short) fontSize); // 字体高度 +// font.setFontName(FontName); // 字体 +// // font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 +// ts.applyFont(firstIndex, lastIndex, font); +// ts.applyFont(lastIndex, ts.length(), font1); +// return ts; +// } +// +// /** +// * 获取单元格大小 +// * +// * @param sheet +// * @param rowIndex +// * @param cellIndex +// * @param cellValue +// */ +// public static int getRegionIndex(XSSFSheet sheet, int rowIndex, int cellIndex, String cellValue) { +// int lastRow = 0; +// for (int i = 0; i < sheet.getNumMergedRegions(); i++) { +// CellRangeAddress region = sheet.getMergedRegion(i); +// int colIndex = region.getFirstColumn(); +// int lastColIndex = region.getLastColumn(); +// int rowNum = region.getFirstRow(); +// int lastRowNum = region.getLastRow(); +// if (sheet.getRow(rowNum).getCell(colIndex).toString().equals(cellValue)) { +// lastRow = lastRowNum; +// } +// } +// return lastRow; +// } +// +// /** +// * 获取单元格数据内容为字符串类型的数据 +// * +// * @param cell Excel单元格 +// * @return String 单元格数据内容 +// */ +// private static String getStringCellValue(XSSFFormulaEvaluator evaluator, XSSFCell cell) { +// if (cell == null) { +// return ""; +// } +// String strCell = ""; +// switch (cell.getCellType()) { +// case XSSFCell.CELL_TYPE_STRING: +// strCell = cell.getStringCellValue(); +// break; +// case XSSFCell.CELL_TYPE_NUMERIC: +// // strCell = cell.getStringCellValue(); +// if (DateUtil.isCellDateFormatted(cell)) { +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); +// Date date = cell.getDateCellValue(); +// if (date != null) +// strCell = sdf.format(date); +// } else { +// +// strCell = "" + cell.getNumericCellValue(); +// if (strCell.endsWith(".0")) { +// strCell = strCell.substring(0, strCell.indexOf(".0")); +// } +// } +// break; +// case XSSFCell.CELL_TYPE_BOOLEAN: +// strCell = String.valueOf(cell.getBooleanCellValue()); +// break; +// case XSSFCell.CELL_TYPE_BLANK: +// strCell = ""; +// break; +// case XSSFCell.CELL_TYPE_ERROR: +// strCell = String.valueOf(cell.getErrorCellValue()); +// break; +// case XSSFCell.CELL_TYPE_FORMULA: +// CellValue value = evaluator.evaluate(cell); +// try { +// strCell = value.getStringValue(); +// if (strCell == null) { +// strCell = "" + value.getNumberValue(); +// if (strCell.endsWith(".0")) { +// strCell = strCell.substring(0, strCell.indexOf(".0")); +// } +// } +// } catch (Exception e) { +// +// strCell = "" + value.getNumberValue(); +// if (strCell.endsWith(".0")) { +// strCell = strCell.substring(0, strCell.indexOf(".0")); +// } +// } +// break; +// +// default: +// strCell = ""; +// break; +// } +// if (strCell.equals("") || strCell == null) { +// return ""; +// } +// // System.out.println(" === Type =" + cell.getCellType() + " Value =" + +// // strCell); +// return strCell; +// } +// +// /** +// * 插入行数 +// * +// * @param starRow +// * @param rows +// */ +// public static void insertRow(XSSFSheet sheet, int starRow, int rows) { +// XSSFRow sourceRow = sheet.getRow(starRow); +// sheet.shiftRows(starRow + 1, sheet.getLastRowNum(), rows, true, false); +// for (int i = 0; i < rows; i++) { +// XSSFRow targetRow = null; +// XSSFCell sourceCell = null; +// XSSFCell targetCell = null; +// short m; +// targetRow = sheet.createRow(starRow + 1); +// targetRow.setHeight(sourceRow.getHeight()); +// System.out.println(sourceRow.getLastCellNum()); +// for (m = sourceRow.getFirstCellNum(); m < sourceRow.getLastCellNum(); m++) { +// System.out.println(m); +// sourceCell = sourceRow.getCell(m); +// targetCell = targetRow.createCell(m); +// targetCell.setCellStyle(sourceCell.getCellStyle()); +// targetCell.setCellType(sourceCell.getCellType()); +// } +// } +// } +// +// /*** +// * 向sheet中插入一行 +// * +// * @param sheet +// * @param startRow +// * @param rows +// * @return +// */ +// public static XSSFSheet insertRows(XSSFSheet sheet, int startRow, int rows) { +// XSSFRow sourceRow = sheet.getRow(startRow); +// sheet.shiftRows(startRow + 1, sheet.getLastRowNum(), rows, true, false); +// for (int i = 0; i < rows; i++) { +// XSSFRow targetRow = null; +// XSSFCell sourceCell = null; +// XSSFCell targetCell = null; +// short m; +// targetRow = sheet.createRow(startRow + 1); +// targetRow.setHeight(sourceRow.getHeight()); +// System.out.println(sourceRow.getLastCellNum()); +// for (m = sourceRow.getFirstCellNum(); m < sourceRow.getLastCellNum(); m++) { +// System.out.println(m); +// sourceCell = sourceRow.getCell(m); +// targetCell = targetRow.createCell(m); +// targetCell.setCellStyle(sourceCell.getCellStyle()); +// targetCell.setCellType(sourceCell.getCellType()); +// } +// } +// return sheet; +// } +// +// /** +// * 检查单元格内容是否是数字 +// * +// * @param value +// * @return +// */ +// public static boolean CheckCellValueIsNumber(String value) { +// boolean is_ok = false; +// if (value.equals("")) { +// return false; +// } +// try { +// Float.parseFloat(value); +// } catch (NumberFormatException e) { +// e.printStackTrace(); +// System.out.println("===>" + value); +// is_ok = true; +// } +// return is_ok; +// } +// +//// /** +//// * 拼接麦格纳的联系人和联系电话 +//// * +//// * @param persion +//// * @param phone +//// * @return +//// */ +//// public static String connectPhoneAndPersion(String persion, String phone) { +//// StringBuffer persionPhoneSb = new StringBuffer(); +//// if (persion != null && phone != null) { +//// +//// String[] persions = null; +//// String[] phones = null; +//// if (persion.contains("、")) { +//// persions = persion.split("、"); +//// } else if (persion.contains("\\/")) { +//// persions = persion.split("\\/"); +//// } else if (persion.contains(",")) { +//// persions = persion.split(","); +//// } else { +//// persions = new String[] { persion }; +//// } +//// +//// if (phone.contains("、")) { +//// phones = phone.split("、"); +//// } else if (phone.contains("\\/")) { +//// phones = phone.split("\\/"); +//// } else if (phone.contains(",")) { +//// phones = phone.split(","); +//// } else { +//// phones = new String[] { phone }; +//// } +//// +//// if (persions != null && phones != null) { +//// int persionCount = persions.length; +//// int phonesCount = phones.length; +//// if (persionCount == phonesCount) { +//// for (int i = 0; i < persionCount; i++) { +//// persionPhoneSb.append(persions[i]).append("/") +//// .append(phones[i]).append(" "); +//// +//// } +//// } +//// } +//// } +//// +//// return persionPhoneSb.toString(); +//// } +// +// /*** +// * 输出成形作业指导书 +// * +// * @param xls_write_Address +// * @param ls +// * @param sheetnames +// * @param row_num +// * @param col_num +// * @throws IOException +// * +// */ +// public static void writeExcelForCX(String xls_write_Address, File file, ArrayList> ls, +// int row_num, int col_num) throws IOException { +// InputStream is = new FileInputStream(file); +// XSSFWorkbook wb = new XSSFWorkbook(is);// (new +// is.close(); +// FileOutputStream output = new FileOutputStream(new File(xls_write_Address)); // 读取的文件路径 +// XSSFCellStyle style = wb.createCellStyle(); +//// style.setBorderBottom(XSSFCellStyle.BORDER_THIN); +//// style.setBorderTop(XSSFCellStyle.BORDER_THIN); +//// style.setBorderRight(XSSFCellStyle.BORDER_THIN); +//// style.setAlignment(XSSFCellStyle.ALIGN_CENTER); +// XSSFFont font = wb.createFont(); +// font.setFontHeightInPoints((short) 8); +// style.setFont(font); +// XSSFSheet sheet = wb.getSheetAt(0); +// sheet.setForceFormulaRecalculation(true); +// if (ls != null) +// for (int i = 0; i < ls.size(); i++) { +// if (i % 27 == 0 && i != 0) { +// row_num += 11; +// } +// XSSFRow row = sheet.getRow(i + row_num - 1); +// ArrayList ls2 = ls.get(i); +// for (int cols = 0; cols < ls2.size(); cols++) { +// XSSFCell cell = row.getCell(cols + col_num - 1); +// if (cell == null) { +// cell = row.createCell(cols + col_num - 1); +// } +//// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +//// cell.setCellStyle(style);// 添加边框 +// if (cols + col_num == 9) { +// String cpgc = ls2.get(cols); +// System.out.println(cpgc); +// String[] strs = cpgc.split("special"); +// System.out.println("strs.length=>" + strs.length); +// if (cpgc != null && cpgc != "") { +// if (!" ".equals(strs[1])) { +// String special = strs[1]; +// if (special.indexOf("|") <= 0) { +// if ("产品/过程/规格/公差".equals(special.split("-")[0])) { +// int index = Integer.valueOf(special.split("-")[1]); +// if (strs[0] != null && strs[0] != "") { +// cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); +// } +// } +// +// } else { +// String[] tstxs = special.split("\\|"); +// for (String str : tstxs) { +// if ("产品/过程/规格/公差".equals(str.split("-")[0])) { +// int index = Integer.valueOf(str.split("-")[1]); +// if (strs[0] != null && strs[0] != "") { +// cell.setCellValue( +// setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); +// } +// } +// } +// } +// } else { +// // 直接写入strs[0] +// cell.setCellValue(strs[0]); +// } +// } +// } else +// cell.setCellValue(ls2.get(cols));// 写入内容 +// } +// +// } +// else +// MessageBox.post("请完善控制计划!", "警告", MessageBox.WARNING); +// wb.write(output); +// output.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// } +// +// /** +// * 输出整形作业指导书 +// * +// * @param string +// * @param is +// * @param zx +// * @param strings +// * @param i +// * @param j +// */ +// public static void writeExcelForZX(String xls_write_Address, File file, ArrayList> ls, +// int row_num, int col_num) throws IOException { +// InputStream is = new FileInputStream(file); +// XSSFWorkbook wb = new XSSFWorkbook(is);// (new +// is.close(); +// FileOutputStream output = new FileOutputStream(new File(xls_write_Address)); // 读取的文件路径 +// XSSFCellStyle style = wb.createCellStyle(); +// style.setBorderBottom(XSSFCellStyle.BORDER_THIN); +// style.setBorderTop(XSSFCellStyle.BORDER_THIN); +// style.setBorderRight(XSSFCellStyle.BORDER_THIN); +// style.setBorderLeft(XSSFCellStyle.BORDER_THIN); +// style.setAlignment(XSSFCellStyle.ALIGN_CENTER); +// XSSFFont font = wb.createFont(); +// font.setFontHeightInPoints((short) 8); +// style.setFont(font); +// XSSFSheet sheet = wb.getSheetAt(0); +// for (int i = 0; i < ls.size(); i++) { +// if (i % 30 == 0 && i != 0) { +// row_num += 10; +// } +// XSSFRow row = sheet.getRow(i + row_num - 1); +// ArrayList ls2 = ls.get(i); +// for (int cols = 0; cols < ls2.size(); cols++) { +// XSSFCell cell = null; +// if (cols == ls2.size() - 1) +// cell = row.getCell(cols + col_num - 1); +// else +// cell = row.getCell(cols + col_num - 1); +// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +//// cell.setCellStyle(style);// 添加边框 +// if (cols + col_num == 11) { +// String cpgc = ls2.get(cols); +// System.out.println(cpgc); +// String[] strs = cpgc.split("special"); +// System.out.println("strs.length=>" + strs.length); +// if (cpgc != null && cpgc != "") { +// if (!" ".equals(strs[1])) { +// String special = strs[1]; +// if (special.indexOf("|") <= 0) { +// if ("产品/过程/规格/公差".equals(special.split("-")[0])) { +// int index = Integer.valueOf(special.split("-")[1]); +// if (strs[0] != null && strs[0] != "") { +// cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); +// } +// } +// +// } else { +// String[] tstxs = special.split("\\|"); +// for (String str : tstxs) { +// if ("产品/过程/规格/公差".equals(str.split("-")[0])) { +// int index = Integer.valueOf(str.split("-")[1]); +// if (strs[0] != null && strs[0] != "") { +// cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); +// } +// } +// } +// } +// } else { +// // 直接写入strs[0] +// cell.setCellValue(strs[0]); +// } +// } +// } else +// cell.setCellValue(ls2.get(cols));// 写入内容 +// } +// +// } +// wb.write(output); +// output.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// } +// +// /** +// * 输出烧结作业指导书 +// * +// * @param string +// * @param is +// * @param zx +// * @param strings +// * @param i +// * @param j +// */ +// public static void writeExcelForSJ(String xls_write_Address, File file, ArrayList> ls, +// List productNameList24, List productNameList18) throws IOException { +// InputStream is = new FileInputStream(file); +// XSSFWorkbook wb = new XSSFWorkbook(is);// (new +// is.close(); +// FileOutputStream output = new FileOutputStream(new File(xls_write_Address)); // 读取的文件路径 +//// writeExcelWithOneCellName(wb, "生产设备", rb3_jqsb); +// XSSFCellStyle style = wb.createCellStyle(); +// style.setBorderBottom(XSSFCellStyle.BORDER_THIN); +// style.setBorderTop(XSSFCellStyle.BORDER_THIN); +// style.setBorderRight(XSSFCellStyle.BORDER_THIN); +// style.setBorderLeft(XSSFCellStyle.BORDER_THIN); +// style.setAlignment(XSSFCellStyle.ALIGN_CENTER); +// XSSFFont font = wb.createFont(); +// font.setFontHeightInPoints((short) 8); +// style.setFont(font); +// XSSFSheet s = wb.getSheetAt(0); +// s.setForceFormulaRecalculation(true); +// if (productNameList24 != null) { +// setNamedCellValue(wb, "二十四寸", +// productNameList24.toString().substring(1, productNameList24.toString().length() - 1)); +// } +// if (productNameList18 != null) { +// setNamedCellValue(wb, "十八寸", +// productNameList18.toString().substring(1, productNameList18.toString().length() - 1)); +// } +// int[] indexs = getNamedCellIndex(wb, "设备"); +// int startRow = indexs[1] + 1; +// int startColumn = indexs[0]; +// for (int i = 0; i < productNameList24.size(); i++) { +// +// Row r = s.getRow(startRow + i); +// setCellValue(r, startColumn, productNameList24.get(i)); +// } +// for (int i = 0; i < productNameList18.size(); i++) { +// Row r = s.getRow(startRow + productNameList24.size() + i); +// setCellValue(r, startColumn, productNameList18.get(i)); +// } +// +// int row_num = 0; +// int t = 0; +// for (int i = 0; i < ls.size(); i++) { +// if (t % 12 == 0 && i != 0) { +// t = 0; +// row_num += 29; +// } +// +// ArrayList ls2 = ls.get(i); +// System.out.println("SJ_data.size===============>" + ls2.size()); +// System.out.println("SJ_data====================>" + ls2.toString()); +// for (int j = 0; j < ls2.size() + 1; j++) { +// int namedCellIdx = wb.getNameIndex("head" + String.valueOf(j + 1)); +// if (namedCellIdx != -1) { +// Name aNamedCell = wb.getNameAt(namedCellIdx); +// AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula()); +// CellReference[] crefs = arefs[0].getAllReferencedCells(); +// for (int k = 0; k < crefs.length; k++) { +// Row r = s.getRow(crefs[k].getRow() + row_num + 1); +// Cell c = r.getCell(crefs[k].getCol()); +// if (j == 2) { +// toSpecial(j, wb, c, ls2); +// } else if (namedCellIdx != wb.getNameIndex("head7")) +// c.setCellValue(ls2.get(j)); +// else +// c.setCellValue("√"); +// } +// } +// +// } +// t++; +// row_num++; +// } +// wb.write(output); +// output.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// } + + // 20181220-ReinhartEdit + /*** + * 输出热处理作业指导书 + * + * @param xls_write_Address + * @param ls + * @param sheetnames + * @param row_num + * @param col_num + * @throws IOException + * + */ +// public static void writeExcelForRCL(String xls_write_Address, File file, ArrayList> ls, +// int row_num, int col_num) throws IOException { +// // InputStream is = new FileInputStream(file); +// // XSSFWorkbook wb = new XSSFWorkbook(is);// (new +// // is.close(); +// // FileOutputStream output = new FileOutputStream(new File( +// // xls_write_Address)); // 读取的文件路径 +// +// // XSSFCellStyle style = wb.createCellStyle(); +// // MessageBox.post("In Processing", "Step", MessageBox.WARNING); +// +// // MessageBox.post(xls_write_Address, "Step", MessageBox.WARNING); +// +// // 读取Excel文档 +// // File finalXlsxFile = new File("D:/NBTM热处理工艺指导书.xlsx"); +// File finalXlsxFile = new File(xls_write_Address); +// Workbook workBook = getWorkbok(finalXlsxFile); +// // sheet 对应一个工作页 +// Sheet getSheet = workBook.getSheetAt(0); +// +//// style.setBorderBottom(XSSFCellStyle.BORDER_THIN); +//// style.setBorderTop(XSSFCellStyle.BORDER_THIN); +//// style.setBorderRight(XSSFCellStyle.BORDER_THIN); +//// style.setAlignment(XSSFCellStyle.ALIGN_CENTER); +// // XSSFFont font = wb.createFont(); +// /// font.setFontHeightInPoints((short) 8); +// // style.setFont(font); +// +// if (ls != null) { +// +// int rowNumber = getSheet.getLastRowNum(); // 第一行从0开始算 +// System.out.println("原始数据总行数:" + ls.size()); +// +// // 先把模板文件内容清空了 +// for (int i = 0; i < 10; i++) { +// Row row = getSheet.getRow(i + 26); +// +// if (row == null) { +// row = getSheet.createRow(i + 26); +// } +// try { +// Cell Itemcell = row.getCell(2); +// if (Itemcell == null) { +// Itemcell = row.createCell(2); +// } +// Itemcell.setCellValue("");// 写入内容 +// +// Cell Valuecell = row.getCell(6); +// if (Valuecell == null) { +// Valuecell = row.createCell(6); +// } +// Valuecell.setCellValue("");// 写入内容 +// +// Cell Processcell = row.getCell(10); +// if (Processcell == null) { +// Processcell = row.createCell(10); +// } +// Processcell.setCellValue("");// 写入内容 +// +// Cell Doublecell = row.getCell(14); +// if (Doublecell == null) { +// Doublecell = row.createCell(14); +// } +// Doublecell.setCellValue("");// 写入内容 +// +// } catch (Exception ex) { +// System.out.println(ex.toString()); +// MessageBox.post(ex.toString(), "Error", MessageBox.ERROR); +// +// return; +// } +// +// } +// // System.out.println("先把模板文件内容清空了" ); +// +// // 先把模板文件内容清空了 +// // 写入参数数据 +// // System.out.println(ls.size()); +// for (int i = 0; i < ls.size(); i++) { +// +// System.out.println("写入实际数据!"); +// Row row = getSheet.getRow(i + 26); +// +// if (row == null) { +// row = getSheet.createRow(i + 26); +// } +// +// ArrayList ls2 = ls.get(i); +// // System.out.println(ls2.get(i)); +// // MessageBox.post(ls2.get(0), "Step", MessageBox.WARNING); +// +// try { +// +// Cell Itemcell = row.getCell(2); +// if (Itemcell == null) { +// Itemcell = row.createCell(2); +// } +// System.out.println(ls2.get(1)); +// Itemcell.setCellValue(ls2.get(1));// 写入内容 +// +// Cell Valuecell = row.getCell(6); +// if (Valuecell == null) { +// Valuecell = row.createCell(6); +// } +// System.out.println(ls2.get(2)); +// Valuecell.setCellValue(ls2.get(2));// 写入内容 +// +// Cell Processcell = row.getCell(10); +// if (Processcell == null) { +// Processcell = row.createCell(10); +// } +// System.out.println(ls2.get(3)); +// Processcell.setCellValue(ls2.get(3));// 写入内容 +// +// Cell Doublecell = row.getCell(14); +// if (Doublecell == null) { +// Doublecell = row.createCell(14); +// } +// System.out.println(ls2.get(4)); +// Doublecell.setCellValue(ls2.get(4));// 写入内容 +// +// } catch (Exception ex) { +// System.out.println(ex.toString()); +// MessageBox.post(ex.toString(), "Error", MessageBox.ERROR); +// +// return; +// } +// +// } +// // 写入参数数据 +// +// // FileOutputStream output = new FileOutputStream("D:/MY热处理工艺指导书.xlsx"); // +// // 读取的文件路径 +// FileOutputStream output = new FileOutputStream(xls_write_Address); // 读取的文件路径 +// +// workBook.write(output); +// // wb.write(output); +// +// if (output != null) { +// output.flush(); +// output.close(); +// } +// +// // System.out.println("Start output data to Excel end!!!!!"); +// // MessageBox.post(" output data to Excel end!!!!!", "Step", +// // MessageBox.WARNING); +// +// } else { +// MessageBox.post("请完善控制计划!", "警告", MessageBox.WARNING); +// } +// +// System.out.println("-------WRITE EXCEL OVER-------"); +// } +// +// public static void toSpecial(int cols, XSSFWorkbook wb, Cell cell, ArrayList cell_Date) { +// String cpgc = cell_Date.get(cols); +//// System.out.println(cpgc); +// String[] strs = cpgc.split("special"); +//// System.out.println(strs.length); +// if (cpgc != null || cpgc != "") { +// if (!"null".equals(strs[1]) && !" ".equals(strs[1])) { +// String special = strs[1]; +// if (special.indexOf("|") <= 0) { +// if ("产品/过程/规格/公差".equals(special.split("-")[0])) { +// int index = Integer.valueOf(special.split("-")[1]); +// if (strs[0] != null && strs[0] != "") { +// cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); +// } +// } +// +// } else { +// String[] tstxs = special.split("\\|"); +// for (String str : tstxs) { +// if ("产品/过程/规格/公差".equals(str.split("-")[0])) { +// int index = Integer.valueOf(str.split("-")[1]); +// if (strs[0] != null && strs[0] != "") { +// cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); +// } +// } +// } +// } +// } else { +// // 直接写入strs[0] +// cell.setCellValue(strs[0]); +// } +// } +// +// } +// +// public static void writeExcelWithOneCellName(XSSFWorkbook wb, String cellName, String value) { +// +// int namedCellIdx = wb.getNameIndex(cellName); +// if (namedCellIdx != -1) { +// Name aNamedCell = wb.getNameAt(namedCellIdx); +// AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula()); +// for (int i = 0; i < arefs.length; i++) { +// CellReference[] crefs = arefs[i].getAllReferencedCells(); +// for (int j = 0; j < crefs.length; j++) { +// Sheet s = wb.getSheet(crefs[j].getSheetName()); +// Row r = s.getRow(crefs[j].getRow()); +// Cell c = r.getCell(crefs[j].getCol()); +// c.setCellValue(value); +// } +// } +// } +// } +// +// /** +// * 将对象属性值写入到Excel中 +// * +// * @param output +// * @param file +// * @param cellName +// * @param cellValue +// */ +// public static void writeExcelWithCellName(File file, String fileOutUrl, Map map, int code, +// String meop_name) { +// try { +// InputStream is = new FileInputStream(file); +// Workbook wb = new XSSFWorkbook(is);// retrieve workbook +// is.close(); +// FileOutputStream output = new FileOutputStream(new File(fileOutUrl)); +// boolean is_first = true; +// for (String key : map.keySet()) { +// if (is_first && "产品代号".equals(key) && (code == 3 || code == 4 || code == 5)) { +// int a1CellIndex = wb.getNameIndex("head"); +// if (a1CellIndex != -1) { +// Name a1NameCell = wb.getNameAt(a1CellIndex); +// AreaReference[] a1ARF = AreaReference.generateContiguous(a1NameCell.getRefersToFormula()); +// CellReference[] a1CRF = a1ARF[0].getAllReferencedCells(); +// Sheet s = wb.getSheet(a1CRF[0].getSheetName()); +// Row r = s.getRow(a1CRF[0].getRow()); +// Cell c = r.getCell(a1CRF[0].getCol()); +// System.out.println(key + ":" + c.getStringCellValue()); +// c.setCellValue(c.getStringCellValue() + map.get(key)); +// is_first = false; +// } +// } +// +// if ("工艺流程".equals(key)) { +// SetFont(wb, map.get(key), meop_name); +// } +// +// else { +// +// int namedCellIdx = wb.getNameIndex(key); +// if (namedCellIdx != -1) { +// Name aNamedCell = wb.getNameAt(namedCellIdx); +// AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula()); +// for (int i = 0; i < arefs.length; i++) { +// CellReference[] crefs = arefs[i].getAllReferencedCells(); +// +// for (int j = 0; j < crefs.length; j++) { +// +// Sheet s = wb.getSheet(crefs[j].getSheetName()); +// Row r = s.getRow(crefs[j].getRow()); +// Cell c = r.getCell(crefs[j].getCol()); +// if (code == 2) { +// c.setCellValue(map.get(key).split("/")[0]); +// } else +// c.setCellValue(map.get(key)); +// } +// } +// } +// } +// } +// wb.write(output); +// output.close(); +// +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// +// /** +// * 设置str1中str2的字体 +// * +// * @param wb +// * @param str1 +// * @param str2 +// * @throws IOException +// */ +// private static void SetFont(Workbook wb, String str1, String str2) throws IOException { +// int index = 0; +// int start_index = 0; +// int end_index = str1.length(); +// String meop_name = str2.split("/")[0]; +// if (str1.indexOf("成形") != -1) +// start_index = str1.indexOf("成形"); +// if (str1.lastIndexOf("包装") != -1) +// end_index = str1.lastIndexOf("包装") + 2; +// str1 = str1.substring(start_index, end_index); +// while ((index = str1.indexOf(meop_name, index)) != -1) { +// int next_index = index + meop_name.length(); +// boolean begin = index - 1 < 0 || str1.charAt(index - 1) == '-'; +// boolean end = next_index > str1.length() || next_index + 1 > str1.length() ? true +// : str1.charAt(next_index) == '-'; +// if (begin && end) +// break; +// else +// index = index + meop_name.length(); +// } +// XSSFRichTextString ts = new XSSFRichTextString(str1); +// XSSFFont font1 = (XSSFFont) wb.createFont(); +// font1.setFontHeightInPoints((short) 10); // 字体高度 +// font1.setFontName("仿宋"); // 字体 +// XSSFFont font = (XSSFFont) wb.createFont(); +// font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); +// font.setFontHeightInPoints((short) 12); // 字体高度 +// font.setFontName("仿宋"); +// ts.applyFont(index, index + meop_name.length(), font); +// ts.applyFont(index + meop_name.length(), ts.length(), font1); +//// XSSFFont font = (XSSFFont) wb.createFont(); +//// +//// font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); +//// ts.applyFont(index, index+str2.length(), font); +// int namedCellIdx = wb.getNameIndex("工艺流程"); +// if (namedCellIdx != -1) { +// Name aNamedCell = wb.getNameAt(namedCellIdx); +// AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula()); +// for (int i = 0; i < arefs.length; i++) { +// CellReference[] crefs = arefs[i].getAllReferencedCells(); +// for (int j = 0; j < crefs.length; j++) { +// Sheet s = wb.getSheet(crefs[j].getSheetName()); +// Row r = s.getRow(crefs[j].getRow()); +// Cell c = r.getCell(crefs[j].getCol()); +// c.setCellValue(ts); +// } +// } +// } +// } + + /** + * 添加命名的引用 + * + * @param session + * @param item 对象的版本 + * @param tcResource 文件的物理路径 + * @param relationType 关系名称 + * @param fileName 文件名 + */ + public static void setExcelToItem(TCSession session, TCComponentItemRevision item, String tcResource, + String fileName, String relationType, String excelType, boolean isDelete) { + try { + String as1[] = { tcResource };// 文件的物理路径 + String as2[] = { "excel" }; + String as3[] = { excelType }; + String as4[] = { "Plain" }; + TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + TCComponentDataset tccomponentDataset = tccomponentDatasetType.create(fileName, "excel", excelType); + tccomponentDataset.setFiles(as1, as3, as4, as2); + AIFComponentContext[] zyzdsChildrens = item.getChildren(); + TCComponentItemRevision zyzdsRev = item; + for (AIFComponentContext zyzdsChildren : zyzdsChildrens) { + if (excelType.equals(zyzdsChildren.getComponent().getType())) { + TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren.getComponent(); + if (dateSet.getStringProperty("object_name").equals(fileName)) { + dateSet.delete(); + zyzdsRev.remove(relationType, dateSet); + } + } + } + item.add(relationType, tccomponentDataset); + if (isDelete) { + new File(tcResource).delete(); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 获取命名的引用返回所有对象 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + public static TCComponentDataset[] getComponentToDatasets(TCSession session, TCComponentItemRevision item, + String relationType) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + TCComponentDataset[] Childrens = new TCComponentDataset[zyzdsChildrens.length]; + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (int ii = 0; ii < zyzdsChildrens.length; ii++) { + + if (zyzdsChildrens[ii] instanceof TCComponentDataset) { + // + + Childrens[ii] = (TCComponentDataset) zyzdsChildrens[ii]; + + // + } + +// + + } + + return Childrens; + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * 获取命名的引用 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + + public static TCComponentDataset getComponentToDataset(TCSession session, TCComponentItemRevision item, + String relationType) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (TCComponent zyzdsChildren : zyzdsChildrens) { + + return (TCComponentDataset) zyzdsChildren; +// + + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * 获取命名的引用 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + public static TCComponentDataset getExcelToDataset(TCSession session, TCComponentItemRevision item, + String relationType, String fileType) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (TCComponent zyzdsChildren : zyzdsChildrens) { + if (fileType.equals(zyzdsChildren.getType())) { + return (TCComponentDataset) zyzdsChildren; +// TCComponentTcFile[] tcFile = dateSet.getTcFiles(); +// return tcFile[0].getFmsFile(); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * 获取命名的引用 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + public static File getExcelToItem(TCSession session, TCComponentItemRevision item, String relationType, + String fileType) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (TCComponent zyzdsChildren : zyzdsChildrens) { + if (fileType.equals(zyzdsChildren.getType())) { + TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren; + TCComponentTcFile[] tcFile = dateSet.getTcFiles(); + return tcFile[0].getFmsFile(); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * 获取合并单元格 + * + * @param value 值 + * @param startIndex 起始行 + * @return + */ + public static void getCombineRow(String value, int startIndex) { + // TODO Auto-generated method stub + String[] sombines = null; + if (value != null && !value.equals("")) { + if (value.indexOf("-") >= 0) { + sombines = value.split("-"); + } else { + sombines = new String[] { value }; + } + } + for (int j = 0; j < sombines.length; j++) { + if (sombines[j].indexOf("/") >= 0) { + int[] row; + int[] cloumn; + String[] cells = sombines[j].split("/"); + if (cells[0].indexOf(",") >= 0) { + String[] rows = cells[0].split(","); + row = new int[rows.length]; + for (int k = 0; k < rows.length; k++) { + row[k] = Integer.parseInt(rows[k]) + startIndex; + } + } else { + row = new int[] { Integer.parseInt(cells[0]) + startIndex }; + } + if (cells[1].indexOf(",") >= 0) { + String[] cloumns = cells[1].split(","); + cloumn = new int[cloumns.length]; + for (int k = 0; k < cloumns.length; k++) { + cloumn[k] = Integer.parseInt(cloumns[k]) - 1; + } + } else { + cloumn = new int[] { Integer.parseInt(cells[1]) - 1 }; + } + map.put(row, cloumn); + } + } + } + + /** + * 获取单个的命名单元格的列 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ +// public static int getOneNamedCellIndex(XSSFWorkbook wb, String cellName) throws IOException { +// int index = -1; +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); +// XSSFName name = wb.getName(cellName); +// if (name == null) { +// return -1; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); +// if (areaRs != null) +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// short colIndex = cellR.getCol(); +// int rowIndex = cellR.getRow(); +// XSSFSheet sheet = wb.getSheet(sheetName); +// XSSFRow row = sheet.getRow(rowIndex); +// return colIndex; +// } +// } +// } +// return index; +// } + + /** + * 爱信--输出控制计划到EXCEL表格中 + * + * @param controlPlanBean 控制计划信息 + * @param input 模版文件流 + * @param outputFilePath 需要输出的全路径 + * @throws IOException + */ +// public static int writeAixinControlPlanToExcel(TMomControlPlanBean controlPlanBean, InputStream input, +// String outputFilePath, String type) throws IOException { +// +// FileOutputStream output = new FileOutputStream(new File(outputFilePath)); // +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// map.clear(); +// int startRow = 14; +// List simpleBeanList = null; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// simpleBeanList = controlPlanBean.getSimpleBeanList(); +// +// for (int i = 0; i < (simpleBeanList.size()); i++) +// insertRow(sheet, 14, 1);// 插入表格行数 +// XSSFRow row1 = sheet.getRow(5); +// setCellValue(row1, 10, controlPlanBean.getSorName()); +// setCellValue(row1, 13, controlPlanBean.getControlPlanNo()); +// XSSFRow row2 = sheet.getRow(8); +// setCellValue(row2, 0, controlPlanBean.getCustromPartNumber()); +// setCellValue(row2, 4, controlPlanBean.getPartNameDesc()); +// setCellValue(row2, 6, controlPlanBean.getMode()); +// setCellValue(row2, 8, controlPlanBean.getSupplier()); +// setCellValue(row2, 10, controlPlanBean.getKeyPersion());// 此处可能需要修改 +// setCellValue(row2, 13, controlPlanBean.getKeyPhone());// 此处可能需要修改 +// XSSFRow row3 = sheet.getRow(9); +// setCellValue(row3, 7, controlPlanBean.getSupplierApprovalDateStr()); +// setCellValue(row3, 9, controlPlanBean.getCustromApprovalDateStr()); +// XSSFRow row4 = sheet.getRow(10); +// setCellValue(row4, 0, controlPlanBean.getCoreTeam()); +// setCellValue(row4, 10, controlPlanBean.getCreateDateStr()); +// setCellValue(row4, 13, controlPlanBean.getUpdateDateStr()); +// } else { +// return -1; +// } +// if (simpleBeanList == null) { +// return -1; +// } +// for (int i = 0; i < simpleBeanList.size(); i++) { +// TMomControlPlanSimpleBean bean = simpleBeanList.get(i); +// if (bean.getHbdyg() != null && !bean.getHbdyg().equals("")) { +// getCombineRow(bean.getHbdyg(), startRow); +// } +// XSSFRow row = null; +// Boolean isCreat = false; +// if ((i + startRow) > sheet.getLastRowNum()) { +// row = sheet.createRow(i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // 获取特殊字符所在位置 +// String[] columnNames = null; +// Map indexMap = new HashMap(); +// if (bean.getSpecial() != null && !bean.getSpecial().equals("")) { +// try { +// if (bean.getSpecial().indexOf("|") >= 0) { +// columnNames = bean.getSpecial().split("\\|"); +// } else { +// columnNames = new String[] { bean.getSpecial() }; +// } +// if (columnNames != null && columnNames.length > 0) { +// for (int i1 = 0; i1 < columnNames.length; i1++) { +// if (columnNames[i1].indexOf("-") >= 0) { +// String[] columnName = columnNames[i1].split("-"); +// // 通过列名称获取列 +// int cellindex = -1; +// if (columnName[0].indexOf(",") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll(",", "")); +// } else if (columnName[0].indexOf("/") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll("/", "")); +// } else { +// cellindex = getOneNamedCellIndex(wb, columnName[0]); +// } +// if (cellindex > -1) { +// indexMap.put(cellindex, Integer.parseInt(columnName[1])); +// } +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// } +// for (int cols = 0; cols <= 15; cols++) { +// XSSFCell cell = null; +// if (isCreat) { +// cell = row.createCell(cols); +// } else { +// cell = row.getCell(cols); +// } +// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +// +// switch (cols) { +// +// case 0: +// if (bean.getPartProcessNumber() != null && bean.getPartProcessNumber().indexOf("\n") >= 0 +// && bean.getPartProcessNumber().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getPartProcessNumber().split("\n")[1]); +// } else if (bean.getPartProcessNumber() != null && bean.getPartProcessNumber().indexOf("\n") >= 0 +// && bean.getPartProcessNumber().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getPartProcessNumber().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getPartProcessNumber(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getPartProcessNumber()); +// } +// break; +// case 1: +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("\n") >= 0 +// && bean.getProcessName().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProcessName().split("\n")[1]); +// } else if (bean.getProcessName() != null && bean.getProcessName().indexOf("\n") >= 0 +// && bean.getProcessName().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProcessName().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcessName(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcessName()); +// } +// break; +// case 2: +// if (bean.getMachineDevice() != null && bean.getMachineDevice().indexOf("\n") >= 0 +// && bean.getMachineDevice().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getMachineDevice().split("\n")[1]); +// } else if (bean.getMachineDevice() != null && bean.getMachineDevice().indexOf("\n") >= 0 +// && bean.getMachineDevice().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getMachineDevice().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getMachineDevice(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getMachineDevice()); +// } +// break; +// case 3: +// if (bean.getSmjy() != null && bean.getSmjy().indexOf("\n") >= 0 +// && bean.getSmjy().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSmjy().split("\n")[1]); +// } else if (bean.getSmjy() != null && bean.getSmjy().indexOf("\n") >= 0 +// && bean.getSmjy().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSmjy().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSmjy(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSmjy()); +// } +// break; +// case 4: +// // String noo = bean.(); +// if (bean.getBubbledPrintNo() != null && bean.getBubbledPrintNo().indexOf("\n") >= 0 +// && bean.getBubbledPrintNo().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getBubbledPrintNo().split("\n")[1]); +// } else if (bean.getBubbledPrintNo() != null && bean.getBubbledPrintNo().indexOf("\n") >= 0 +// && bean.getBubbledPrintNo().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getBubbledPrintNo().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getBubbledPrintNo(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getBubbledPrintNo()); +// } +// break; +// case 5: +// if (bean.getProduct() != null && bean.getProduct().indexOf("\n") >= 0 +// && bean.getProduct().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProduct().split("\n")[1]); +// } else if (bean.getProduct() != null && bean.getProduct().indexOf("\n") >= 0 +// && bean.getProduct().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProduct().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProduct(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProduct()); +// } +// break; +// case 6: +// if (bean.getProcess() != null && bean.getProcess().indexOf("\n") >= 0 +// && bean.getProcess().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProcess().split("\n")[1]); +// } else if (bean.getProcess() != null && bean.getProcess().indexOf("\n") >= 0 +// && bean.getProcess().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProcess().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcess(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcess()); +// } +// break; +// case 7: +// if (bean.getSpecialClass() != null && bean.getSpecialClass().indexOf("\n") >= 0 +// && bean.getSpecialClass().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSpecialClass().split("\n")[1]); +// } else if (bean.getSpecialClass() != null && bean.getSpecialClass().indexOf("\n") >= 0 +// && bean.getSpecialClass().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSpecialClass().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSpecialClass(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSpecialClass()); +// } +// break; +// case 8: +// if (bean.getConceal().equals("1")) { +// String processName = bean.getProcessName();// .split("\n")[1]; +// String productId = bean.getMeopId().split("_")[0]; +// StringBuffer value = new StringBuffer(); +// System.out.println(value.length()); +// if (type.indexOf("CHINESE") != -1) { +// String name = processName.split("\n")[0]; +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) { +// name = name.substring(3, name.length() - 1); +// } +// value.append("详见" + name + "作业指导书/" + productId); +// // cell.setCellValue("详见"+processName+"作业指导书/"+productId); +// } +// if (type.indexOf("ENGLISH") != -1) { +// String name = processName.split("\n")[1]; +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) { +// name = name.substring(8, name.length() - 1); +// } +// if (value.length() != 0) +// value.append("\n"); +// value.append("In " + name + " OP INS/" + productId); +// +// } +// cell.setCellValue(value.toString()); +// } else { +// if (bean.getProductProcessSpecificationTolerance() != null +// && bean.getProductProcessSpecificationTolerance().indexOf("\n") >= 0 +// && bean.getProductProcessSpecificationTolerance().split("\n").length == 2 +// && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance().split("\n")[1]); +// } else if (bean.getProductProcessSpecificationTolerance() != null +// && bean.getProductProcessSpecificationTolerance().indexOf("\n") >= 0 +// && bean.getProductProcessSpecificationTolerance().split("\n").length == 2 +// && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProductProcessSpecificationTolerance(), +// indexMap.get(cols), indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance()); +// } +// } +//// if (bean.getUpProductProcessSpecificationTolerance() == null) { +//// cell.setCellValue(""); +//// } else if (!bean +//// .getUpProductProcessSpecificationTolerance().trim() +//// .isEmpty() +//// && !bean.getDownProductProcessSpecificationTolerance() +//// .trim().isEmpty()) +//// cell.setCellValue(bean +//// .getProductProcessSpecificationTolerance() +//// + " " +//// + bean.getUpProductProcessSpecificationTolerance() +//// + "/" +//// + bean.getDownProductProcessSpecificationTolerance()); +//// else { +//// +//// } +// break; +// case 9: +// if (bean.getEvaluationMeasurementTechnique() != null +// && bean.getEvaluationMeasurementTechnique().indexOf("\n") >= 0 +// && bean.getEvaluationMeasurementTechnique().split("\n").length == 2 +// && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique().split("\n")[1]); +// } else if (bean.getEvaluationMeasurementTechnique() != null +// && bean.getEvaluationMeasurementTechnique().indexOf("\n") >= 0 +// && bean.getEvaluationMeasurementTechnique().split("\n").length == 2 +// && type.equals("CHINESE")) { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getEvaluationMeasurementTechnique(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique()); +// } +// break; +// case 10: +// if (bean.getSampleSize() != null && bean.getSampleSize().indexOf("\n") >= 0 +// && bean.getSampleSize().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSampleSize().split("\n")[1]); +// } else if (bean.getSampleSize() != null && bean.getSampleSize().indexOf("\n") >= 0 +// && bean.getSampleSize().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSampleSize().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleSize(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleSize()); +// } +// break; +// case 11: +// if (bean.getSampleFreq() != null && bean.getSampleFreq().indexOf("\n") >= 0 +// && bean.getSampleFreq().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSampleFreq().split("\n")[1]); +// } else if (bean.getSampleFreq() != null && bean.getSampleFreq().indexOf("\n") >= 0 +// && bean.getSampleFreq().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSampleFreq().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleFreq(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleFreq()); +// } +// break; +// case 12: +// if (bean.getResp() != null && bean.getResp().indexOf("\n") >= 0 +// && bean.getResp().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getResp().split("\n")[1]); +// } else if (bean.getResp() != null && bean.getResp().indexOf("\n") >= 0 +// && bean.getResp().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getResp().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getResp(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getResp()); +// } +// break; +// case 13: +// if (bean.getControlMethod() != null && bean.getControlMethod().indexOf("\n") >= 0 +// && bean.getControlMethod().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getControlMethod().split("\n")[1]); +// } else if (bean.getControlMethod() != null && bean.getControlMethod().indexOf("\n") >= 0 +// && bean.getControlMethod().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getControlMethod().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getControlMethod(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getControlMethod()); +// } +// break; +// case 14: +// if (bean.getOperationCriteria() != null && bean.getOperationCriteria().indexOf("\n") >= 0 +// && bean.getOperationCriteria().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getOperationCriteria().split("\n")[1]); +// } else if (bean.getOperationCriteria() != null && bean.getOperationCriteria().indexOf("\n") >= 0 +// && bean.getOperationCriteria().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getOperationCriteria().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getOperationCriteria(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getOperationCriteria()); +// } +// break; +// case 15: +// if (bean.getReactionPlan() != null && bean.getReactionPlan().indexOf("\n") >= 0 +// && bean.getReactionPlan().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getReactionPlan().split("\n")[1]); +// } else if (bean.getReactionPlan() != null && bean.getReactionPlan().indexOf("\n") >= 0 +// && bean.getReactionPlan().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getReactionPlan().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getReactionPlan(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getReactionPlan()); +// } +// break; +// +// default: +// break; +// +// } +// } +// } +// if (map != null && map.size() != 0) { +// Iterator> it = map.entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// List columnIndex = new ArrayList(); +// for (int i = 0; i < entry.getValue().length; i++) { +// if (entry.getValue()[i] == 3 || entry.getValue()[i] == 5 +// || (entry.getValue()[i] >= 18 && entry.getValue()[i] <= 20)) { +// continue; +// } else if (entry.getValue()[i] == 4) { +// columnIndex.add(entry.getValue()[i] - 1); +// } else if (entry.getValue()[i] >= 7 && entry.getValue()[i] <= 17) { +// columnIndex.add(entry.getValue()[i] - 3); +// } else { +// columnIndex.add(entry.getValue()[i]); +// } +// } +// int[] column = new int[columnIndex.size()]; +// for (int i = 0; i < columnIndex.size(); i++) { +// column[i] = columnIndex.get(i); +// } +// if (column.length > 0) { +// combine(sheet, entry.getKey(), column); +// } +// } +// } +// wb.write(output); +// output.close(); +// input.close(); +// System.out.println("-------WRITE EXCEL OVERax-------"); +// +// return 0; +// } +// +// /** +// * 拼接麦格纳的联系人和联系电话 +// * +// * @param persion +// * @param phone +// * @return +// */ +// public static String connectPhoneAndPersion(String persion, String phone) { +// StringBuffer persionPhoneSb = new StringBuffer(); +// if (persion != null && phone != null) { +// +// String[] persions = null; +// String[] phones = null; +// if (persion.contains("、")) { +// persions = persion.split("、"); +// } else if (persion.contains("\\/")) { +// persions = persion.split("\\/"); +// } else if (persion.contains(",")) { +// persions = persion.split(","); +// } else { +// persions = new String[] { persion }; +// } +// +// if (phone.contains("、")) { +// phones = phone.split("、"); +// } else if (phone.contains("\\/")) { +// phones = phone.split("\\/"); +// } else if (phone.contains(",")) { +// phones = phone.split(","); +// } else { +// phones = new String[] { phone }; +// } +// +// if (persions != null && phones != null) { +// int persionCount = persions.length; +// int phonesCount = phones.length; +// if (persionCount == phonesCount) { +// for (int i = 0; i < persionCount; i++) { +// persionPhoneSb.append(persions[i]).append("/").append(phones[i]).append(" "); +// +// } +// } +// } +// } +// +// return persionPhoneSb.toString(); +// } +// +// /** +// * 麦格纳--输出控制计划到EXCEL表格中 +// * +// * @param controlPlanBean 控制计划信息 +// * @param input 模版文件流 +// * @param outputFilePath 需要输出的全路径 +// * @throws IOException +// */ +// public static int writeMaigelaControlPlanToExcel(TMomControlPlanBean controlPlanBean, InputStream input, +// String outputFilePath, String type) throws IOException { +// +// FileOutputStream output = new FileOutputStream(new File(outputFilePath)); // +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// int startRow = 14; +// map.clear(); +// List simpleBeanList = null; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// simpleBeanList = controlPlanBean.getSimpleBeanList(); +// +// // for (int i = 0; i < (simpleBeanList.size()); i++) +// // insertRow(sheet, 15, 1);// 插入表格行数 +// XSSFRow row0 = sheet.getRow(1); +// setCellValue(row0, 11, row0.getCell(11).getStringCellValue() + controlPlanBean.getControlPlanNo()); +// XSSFRow row1 = sheet.getRow(3); +// setCellValue(row1, 0, controlPlanBean.getPartNumber()); +// setCellValue(row1, 6, +// connectPhoneAndPersion(controlPlanBean.getKeyPersion(), controlPlanBean.getKeyPhone())); +// setCellValue(row1, 12, controlPlanBean.getCreateDateStr()); +// setCellValue(row1, 14, controlPlanBean.getUpdateDateStr()); +// setCellValue(row1, 15, controlPlanBean.getChangeLev()); +// XSSFRow row2 = sheet.getRow(5); +// setCellValue(row2, 0, controlPlanBean.getCustromPartNumber()); +// setCellValue(row2, 7, controlPlanBean.getCoreTeam()); +// setCellValue(row2, 12, controlPlanBean.getCustromEngineeringApprovalDateStr()); +// +// XSSFRow row3 = sheet.getRow(7); +// setCellValue(row3, 0, controlPlanBean.getPartNameDesc()); +// setCellValue(row3, 7, controlPlanBean.getSupplierApprovalDateStr()); +// setCellValue(row3, 12, controlPlanBean.getCustromQuantyApprovalDateStr()); +// XSSFRow row4 = sheet.getRow(9); +// setCellValue(row4, 0, controlPlanBean.getSupplier()); +// setCellValue(row4, 3, controlPlanBean.getSupplierCode()); +// setCellValue(row4, 7, controlPlanBean.getOtherApprovalDateStr()); +// setCellValue(row4, 12, controlPlanBean.getOtherApprovalIfDateStr()); +// +// } else { +// return -1; +// } +// if (simpleBeanList == null) { +// return -1; +// } +// for (int i = 0; i < simpleBeanList.size(); i++) { +// TMomControlPlanSimpleBean bean = simpleBeanList.get(i); +// if (bean.getHbdyg() != null && !bean.getHbdyg().equals("")) { +// getCombineRow(bean.getHbdyg(), startRow); +// } +// XSSFRow row = null; +// Boolean isCreat = false; +// if ((i + startRow) > sheet.getLastRowNum()) { +// row = sheet.createRow(i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // 获取特殊字符所在位置 +// String[] columnNames = null; +// Map indexMap = new HashMap(); +// if (bean.getSpecial() != null && !bean.getSpecial().equals("")) { +// try { +// if (bean.getSpecial().indexOf("|") >= 0) { +// columnNames = bean.getSpecial().split("\\|"); +// } else { +// columnNames = new String[] { bean.getSpecial() }; +// } +// if (columnNames != null && columnNames.length > 0) { +// for (int i1 = 0; i1 < columnNames.length; i1++) { +// if (columnNames[i1].indexOf("-") >= 0) { +// String[] columnName = columnNames[i1].split("-"); +// // 通过列名称获取列 +// int cellindex = -1; +// if (columnName[0].indexOf(",") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll(",", "")); +// } else if (columnName[0].indexOf("/") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll("/", "")); +// } else { +// cellindex = getOneNamedCellIndex(wb, columnName[0]); +// } +// if (cellindex > -1) { +// indexMap.put(cellindex, Integer.parseInt(columnName[1])); +// } +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// } +// for (int cols = 0; cols <= 15; cols++) { +// XSSFCell cell = null; +// if (isCreat) { +// cell = row.createCell(cols); +// } else { +// cell = row.getCell(cols); +// } +// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +// +// switch (cols) { +// +// case 0: +// if (bean.getPartProcessNumber() != null && bean.getPartProcessNumber().indexOf("\n") >= 0 +// && bean.getPartProcessNumber().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getPartProcessNumber().split("\n")[1]); +// } else if (bean.getPartProcessNumber() != null && bean.getPartProcessNumber().indexOf("\n") >= 0 +// && bean.getPartProcessNumber().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getPartProcessNumber().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getPartProcessNumber(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getPartProcessNumber()); +// } +//// cell.setCellValue(bean.getPartProcessNumber()); +// break; +// case 1: +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("\n") >= 0 +// && bean.getProcessName().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProcessName().split("\n")[1]); +// } else if (bean.getProcessName() != null && bean.getProcessName().indexOf("\n") >= 0 +// && bean.getProcessName().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProcessName().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcessName(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcessName()); +// } +//// cell.setCellValue(bean.getProcessName()); +// break; +// case 2: +// if (bean.getMachineDevice() != null && bean.getMachineDevice().indexOf("\n") >= 0 +// && bean.getMachineDevice().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getMachineDevice().split("\n")[1]); +// } else if (bean.getMachineDevice() != null && bean.getMachineDevice().indexOf("\n") >= 0 +// && bean.getMachineDevice().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getMachineDevice().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getMachineDevice(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getMachineDevice()); +// } +//// cell.setCellValue(bean.getMachineDevice()); +// break; +// case 3: +// if (bean.getSmjy() != null && bean.getSmjy().indexOf("\n") >= 0 +// && bean.getSmjy().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSmjy().split("\n")[1]); +// } else if (bean.getSmjy() != null && bean.getSmjy().indexOf("\n") >= 0 +// && bean.getSmjy().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSmjy().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSmjy(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSmjy()); +// } +//// cell.setCellValue(bean.getMachineDevice()); +// break; +// case 4: +// if (bean.getBubbledPrintNo() != null && bean.getBubbledPrintNo().indexOf("\n") >= 0 +// && bean.getBubbledPrintNo().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getBubbledPrintNo().split("\n")[1]); +// } else if (bean.getBubbledPrintNo() != null && bean.getBubbledPrintNo().indexOf("\n") >= 0 +// && bean.getBubbledPrintNo().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getBubbledPrintNo().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getBubbledPrintNo(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getBubbledPrintNo()); +// } +//// cell.setCellValue(bean.getBubbledPrintNo()); +// break; +// case 5: +// if (bean.getSize() != null && bean.getSize().indexOf("\n") >= 0 +// && bean.getSize().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSize().split("\n")[1]); +// } else if (bean.getSize() != null && bean.getSize().indexOf("\n") >= 0 +// && bean.getSize().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSize().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSize(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSize()); +// } +//// cell.setCellValue(bean.getSize()); +// break; +// case 6: +// if (bean.getNo() != null && bean.getNo().indexOf("\n") >= 0 && bean.getNo().split("\n").length == 2 +// && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getNo().split("\n")[1]); +// } else if (bean.getNo() != null && bean.getNo().indexOf("\n") >= 0 +// && bean.getNo().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getNo().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getNo(), indexMap.get(cols), indexMap.get(cols) + 1, 10, +// "Y14.5M")); +// } else { +// cell.setCellValue(bean.getNo()); +// } +//// cell.setCellValue(bean.getNo()); +// break; +// +// case 7: +// if (bean.getProduct() != null && bean.getProduct().indexOf("\n") >= 0 +// && bean.getProduct().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProduct().split("\n")[1]); +// } else if (bean.getProduct() != null && bean.getProduct().indexOf("\n") >= 0 +// && bean.getProduct().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProduct().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProduct(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProduct()); +// } +//// cell.setCellValue(bean.getProduct()); +// break; +// case 8: +// if (bean.getProcess() != null && bean.getProcess().indexOf("\n") >= 0 +// && bean.getProcess().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProcess().split("\n")[1]); +// } else if (bean.getProcess() != null && bean.getProcess().indexOf("\n") >= 0 +// && bean.getProcess().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProcess().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcess(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcess()); +// } +//// cell.setCellValue(bean.getProcess()); +// break; +// case 9: +// if (bean.getSpecialClass() != null && bean.getSpecialClass().indexOf("\n") >= 0 +// && bean.getSpecialClass().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSpecialClass().split("\n")[1]); +// } else if (bean.getSpecialClass() != null && bean.getSpecialClass().indexOf("\n") >= 0 +// && bean.getSpecialClass().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSpecialClass().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSpecialClass(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSpecialClass()); +// } +//// cell.setCellValue(bean.getSpecialClass()); +// break; +// case 10: +// if (bean.getConceal().equals("1")) { +// String processName = bean.getProcessName();// .split("\n")[1]; +// String productId = bean.getMeopId().split("_")[0]; +// StringBuffer value = new StringBuffer(); +// System.out.println(value.length()); +// if (type.indexOf("CHINESE") != -1) { +// String name = processName.split("\n")[0]; +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) { +// name = name.substring(3, name.length() - 1); +// } +// value.append("详见" + name + "作业指导书/" + productId); +// // cell.setCellValue("详见"+processName+"作业指导书/"+productId); +// } +// if (type.indexOf("ENGLISH") != -1) { +// String name = processName.split("\n")[1]; +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) { +// name = name.substring(8, name.length() - 1); +// } +// if (value.length() != 0) +// value.append("\n"); +// value.append("In " + name + " OP INS/" + productId); +// +// } +// cell.setCellValue(value.toString()); +// } else { +// if (bean.getProductProcessSpecificationTolerance() != null +// && bean.getProductProcessSpecificationTolerance().indexOf("\n") >= 0 +// && bean.getProductProcessSpecificationTolerance().split("\n").length == 2 +// && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance().split("\n")[1]); +// } else if (bean.getProductProcessSpecificationTolerance() != null +// && bean.getProductProcessSpecificationTolerance().indexOf("\n") >= 0 +// && bean.getProductProcessSpecificationTolerance().split("\n").length == 2 +// && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProductProcessSpecificationTolerance(), +// indexMap.get(cols), indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance()); +// } +// } +//// if (bean.getUpProductProcessSpecificationTolerance() == null) { +//// cell.setCellValue(""); +//// } else if (!bean +//// .getUpProductProcessSpecificationTolerance().trim() +//// .isEmpty() +//// && !bean.getDownProductProcessSpecificationTolerance() +//// .trim().isEmpty()) +//// cell.setCellValue(bean +//// .getProductProcessSpecificationTolerance() +//// + " " +//// + bean.getUpProductProcessSpecificationTolerance() +//// + "/" +//// + bean.getDownProductProcessSpecificationTolerance()); +//// else { +//// cell.setCellValue(bean +//// .getProductProcessSpecificationTolerance()); +//// } +// break; +// case 11: +// if (bean.getEvaluationMeasurementTechnique() != null +// && bean.getEvaluationMeasurementTechnique().indexOf("\n") >= 0 +// && bean.getEvaluationMeasurementTechnique().split("\n").length == 2 +// && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique().split("\n")[1]); +// } else if (bean.getEvaluationMeasurementTechnique() != null +// && bean.getEvaluationMeasurementTechnique().indexOf("\n") >= 0 +// && bean.getEvaluationMeasurementTechnique().split("\n").length == 2 +// && type.equals("CHINESE")) { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getEvaluationMeasurementTechnique(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique()); +// } +// break; +// case 12: +// if (bean.getSampleSize() != null && bean.getSampleSize().indexOf("\n") >= 0 +// && bean.getSampleSize().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSampleSize().split("\n")[1]); +// } else if (bean.getSampleSize() != null && bean.getSampleSize().indexOf("\n") >= 0 +// && bean.getSampleSize().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSampleSize().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleSize(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleSize()); +// } +// break; +// case 13: +// if (bean.getSampleFreq() != null && bean.getSampleFreq().indexOf("\n") >= 0 +// && bean.getSampleFreq().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSampleFreq().split("\n")[1]); +// } else if (bean.getSampleFreq() != null && bean.getSampleFreq().indexOf("\n") >= 0 +// && bean.getSampleFreq().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSampleFreq().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleFreq(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleFreq()); +// } +// break; +// +// case 14: +// if (bean.getControlMethod() != null && bean.getControlMethod().indexOf("\n") >= 0 +// && bean.getControlMethod().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getControlMethod().split("\n")[1]); +// } else if (bean.getControlMethod() != null && bean.getControlMethod().indexOf("\n") >= 0 +// && bean.getControlMethod().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getControlMethod().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getControlMethod(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getControlMethod()); +// } +// break; +// +// case 15: +// if (bean.getReactionPlan() != null && bean.getReactionPlan().indexOf("\n") >= 0 +// && bean.getReactionPlan().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getReactionPlan().split("\n")[1]); +// } else if (bean.getReactionPlan() != null && bean.getReactionPlan().indexOf("\n") >= 0 +// && bean.getReactionPlan().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getReactionPlan().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getReactionPlan(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getReactionPlan()); +// } +// break; +// +// default: +// break; +// +// } +// } +// } +// if (map != null && map.size() != 0) { +// Iterator> it = map.entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// List columnIndex = new ArrayList(); +// for (int i = 0; i < entry.getValue().length; i++) { +// if (entry.getValue()[i] == 3 || (entry.getValue()[i] >= 18 && entry.getValue()[i] <= 20) +// || entry.getValue()[i] == 14 || entry.getValue()[i] == 16) { +// continue; +// } else if (entry.getValue()[i] >= 4 && entry.getValue()[i] <= 13) { +// columnIndex.add(entry.getValue()[i] - 1); +// } else if (entry.getValue()[i] == 15) { +// columnIndex.add(entry.getValue()[i] - 2); +// } else if (entry.getValue()[i] == 17) { +// columnIndex.add(entry.getValue()[i] - 3); +// } else { +// columnIndex.add(entry.getValue()[i]); +// } +// } +// int[] column = new int[columnIndex.size()]; +// for (int i = 0; i < columnIndex.size(); i++) { +// column[i] = columnIndex.get(i); +// } +// if (column.length > 0) { +// combine(sheet, entry.getKey(), column); +// } +// } +// } +// wb.write(output); +// output.close(); +// input.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// return 0; +// } +// +// /** +// * 博格华纳英文表头--输出控制计划到EXCEL表格中 +// * +// * @param controlPlanBean 控制计划信息 +// * @param input 模版文件流 +// * @param outputFilePath 需要输出的全路径 +// * @throws IOException +// */ +// public static int writeBogehuanaControlPlanToExcel2(TMomControlPlanBean controlPlanBean, InputStream input, +// String outputFilePath) throws IOException { +// +// FileOutputStream output = new FileOutputStream(new File(outputFilePath)); // +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// int startRow = 13; +// map.clear(); +// List simpleBeanList = null; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// simpleBeanList = controlPlanBean.getSimpleBeanList(); +// +// // for (int i = 0; i < (simpleBeanList.size()); i++) +// // insertRow(sheet, 14, 1);// 插入表格行数 +// XSSFRow row1 = sheet.getRow(3); +// setCellValue(row1, 0, row1.getCell(0).getStringCellValue() + controlPlanBean.getControlPlanNo()); +// setCellValue(row1, 5, +// connectPhoneAndPersion(controlPlanBean.getKeyPersion(), controlPlanBean.getKeyPhone())); +// setCellValue(row1, 9, controlPlanBean.getCreateDateStr()); +// setCellValue(row1, 12, controlPlanBean.getUpdateDateStr()); +// XSSFRow row2 = sheet.getRow(5); +// setCellValue(row2, 0, controlPlanBean.getPartNumber()); +// +// setCellValue(row2, 5, controlPlanBean.getCoreTeam()); +// setCellValue(row2, 9, controlPlanBean.getCustromEngineeringApprovalDateStr()); +// +// XSSFRow row3 = sheet.getRow(7); +// setCellValue(row3, 0, controlPlanBean.getPartNameDesc()); +// setCellValue(row3, 5, controlPlanBean.getSupplierApprovalDateStr()); +// setCellValue(row3, 9, controlPlanBean.getCustromQuantyApprovalDateStr()); +// +// XSSFRow row4 = sheet.getRow(9); +// setCellValue(row4, 0, controlPlanBean.getSupplier()); +// setCellValue(row4, 3, controlPlanBean.getSupplierCode()); +// setCellValue(row4, 5, controlPlanBean.getOtherApprovalDateStr()); +// setCellValue(row4, 9, controlPlanBean.getOtherApprovalIfDateStr()); +// +// } else { +// return -1; +// } +// if (simpleBeanList == null) { +// return -1; +// } +// for (int i = 0; i < simpleBeanList.size(); i++) { +// TMomControlPlanSimpleBean bean = simpleBeanList.get(i); +// if (bean.getHbdyg() != null && !bean.getHbdyg().equals("")) { +// getCombineRow(bean.getHbdyg(), startRow); +// } +// XSSFRow row = null; +// Boolean isCreat = false; +// System.out.println("row = " + (i + startRow)); +// if ((i + startRow) > sheet.getLastRowNum()) { +// row = sheet.createRow(i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // 获取特殊字符所在位置 +// String[] columnNames = null; +// Map indexMap = new HashMap(); +// if (bean.getSpecial() != null && !bean.getSpecial().equals("")) { +// try { +// if (bean.getSpecial().indexOf("|") >= 0) { +// columnNames = bean.getSpecial().split("\\|"); +// } else { +// columnNames = new String[] { bean.getSpecial() }; +// } +// if (columnNames != null && columnNames.length > 0) { +// for (int i1 = 0; i1 < columnNames.length; i1++) { +// if (columnNames[i1].indexOf("-") >= 0) { +// String[] columnName = columnNames[i1].split("-"); +// // 通过列名称获取列 +// int cellindex = -1; +// if (columnName[0].indexOf(",") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll(",", "")); +// } else if (columnName[0].indexOf("/") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll("/", "")); +// } else { +// cellindex = getOneNamedCellIndex(wb, columnName[0]); +// } +// if (cellindex > -1) { +// indexMap.put(cellindex, Integer.parseInt(columnName[1])); +// } +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// } +// for (int cols = 0; cols < 13; cols++) { +// XSSFCell cell = null; +// if (isCreat) { +// cell = row.createCell(cols); +// } else { +// cell = row.getCell(cols); +// } +// if (cell == null) +// cell = row.getCell(cols); +// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +// +// switch (cols) { +// +// case 0: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getPartProcessNumber(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getPartProcessNumber()); +// } +// break; +// case 1: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcessName(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcessName()); +// } +// break; +// case 2: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getMachineDevice(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getMachineDevice()); +// } +// break; +// case 3: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getNo(), indexMap.get(cols), indexMap.get(cols) + 1, 10, +// "Y14.5M")); +// } else { +// cell.setCellValue(bean.getNo()); +// } +// break; +// case 4: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProduct(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProduct()); +// } +// break; +// case 5: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcess(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcess()); +// } +// break; +// case 6: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSpecialClass(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSpecialClass()); +// } +// break; +// case 7: +// if (bean.getConceal().equals("1")) { +// String processName = bean.getProcessName(); +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) { +// processName = bean.getProcessName().substring(3, +// bean.getProcessName().toString().length() - 1); +// } +// cell.setCellValue("详见" + processName + "作业指导书"); +// } else { +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProductProcessSpecificationTolerance(), +// indexMap.get(cols), indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance()); +// } +// } +//// if (bean.getUpProductProcessSpecificationTolerance() == null) { +//// sheet.addMergedRegion(new CellRangeAddress( +//// i + startRow, i + startRow + 1, 7, 8)); +//// cell.setCellValue(bean +//// .getProductProcessSpecificationTolerance()); +//// } else if (!bean +//// .getUpProductProcessSpecificationTolerance().trim() +//// .isEmpty() +//// && !bean.getDownProductProcessSpecificationTolerance() +//// .trim().isEmpty()) { +//// +//// sheet.addMergedRegion(new CellRangeAddress( +//// i + startRow, i + startRow + 1, 7, 7)); +//// cell.setCellValue(bean +//// .getProductProcessSpecificationTolerance()); +//// row.getCell(8) +//// .setCellValue( +//// bean.getUpProductProcessSpecificationTolerance()); +//// XSSFRow rowNext = sheet.getRow(i + 1 + startRow); +//// rowNext.getCell(8) +//// .setCellValue( +//// bean.getDownProductProcessSpecificationTolerance()); +//// } else { +//// sheet.addMergedRegion(new CellRangeAddress( +//// i + startRow, i + startRow + 1, 7, 8)); +//// cell.setCellValue(bean +//// .getProductProcessSpecificationTolerance()); +//// } +// break; +// case 8: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getEvaluationMeasurementTechnique(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique()); +// } +// break; +// case 9: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleSize(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleSize()); +// } +// break; +// case 10: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleFreq(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleFreq()); +// } +// break; +// +// case 11: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getControlMethod(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getControlMethod()); +// } +// break; +// +// case 12: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getReactionPlan(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getReactionPlan()); +// } +// break; +// +// default: +// break; +// +// } +// } +// } +// if (map != null && map.size() != 0) { +// Iterator> it = map.entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// List columnIndex = new ArrayList(); +// for (int i = 0; i < entry.getValue().length; i++) { +// if (entry.getValue()[i] == 3 || entry.getValue()[i] == 5 || entry.getValue()[i] == 6 +// || (entry.getValue()[i] >= 18 && entry.getValue()[i] <= 20) || entry.getValue()[i] == 14 +// || entry.getValue()[i] == 16) { +// continue; +// } else if (entry.getValue()[i] == 4) { +// columnIndex.add(entry.getValue()[i] - 1); +// } else if (entry.getValue()[i] >= 7 && entry.getValue()[i] <= 13) { +// columnIndex.add(entry.getValue()[i] - 3); +// } else if (entry.getValue()[i] == 15) { +// columnIndex.add(entry.getValue()[i] - 4); +// } else if (entry.getValue()[i] == 17) { +// columnIndex.add(entry.getValue()[i] - 5); +// } else { +// columnIndex.add(entry.getValue()[i]); +// } +// } +// int[] column = new int[columnIndex.size()]; +// for (int i = 0; i < columnIndex.size(); i++) { +// column[i] = columnIndex.get(i); +// } +// if (column.length > 0) { +// combine(sheet, entry.getKey(), column); +// } +// } +// } +// wb.write(output); +// output.close(); +// input.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// return 0; +// } + + /** + * 博格华纳--输出控制计划到EXCEL表格中 + * + * @param controlPlanBean 控制计划信息 + * @param input 模版文件流 + * @param outputFilePath 需要输出的全路径 + * @throws IOException + */ +// public static int writeBogehuanaControlPlanToExcel(TMomControlPlanBean controlPlanBean, InputStream input, +// String outputFilePath, String type) throws IOException { +// +// FileOutputStream output = new FileOutputStream(new File(outputFilePath)); // +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// int startRow = 13; +// map.clear(); +// List simpleBeanList = null; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// simpleBeanList = controlPlanBean.getSimpleBeanList(); +// +// // for (int i = 0; i < (simpleBeanList.size()); i++) +// // insertRow(sheet, 14, 1);// 插入表格行数 +// XSSFRow row1 = sheet.getRow(3); +// setCellValue(row1, 0, row1.getCell(0).getStringCellValue() + controlPlanBean.getControlPlanNo()); +// setCellValue(row1, 6, +// connectPhoneAndPersion(controlPlanBean.getKeyPersion(), controlPlanBean.getKeyPhone())); +// setCellValue(row1, 10, controlPlanBean.getCreateDateStr()); +// setCellValue(row1, 12, controlPlanBean.getUpdateDateStr()); +// XSSFRow row2 = sheet.getRow(5); +// setCellValue(row2, 0, controlPlanBean.getCustromPartNumber()); +// +// setCellValue(row2, 6, controlPlanBean.getCoreTeam()); +// setCellValue(row2, 10, controlPlanBean.getCustromEngineeringApprovalDateStr()); +// +// XSSFRow row3 = sheet.getRow(7); +// setCellValue(row3, 0, controlPlanBean.getPartNameDesc()); +// setCellValue(row3, 6, controlPlanBean.getSupplierApprovalDateStr()); +// setCellValue(row3, 10, controlPlanBean.getCustromQuantyApprovalDateStr()); +// +// XSSFRow row4 = sheet.getRow(9); +// setCellValue(row4, 0, controlPlanBean.getSupplier()); +// setCellValue(row4, 4, controlPlanBean.getSupplierCode()); +// setCellValue(row4, 6, controlPlanBean.getOtherApprovalDateStr()); +// setCellValue(row4, 10, controlPlanBean.getOtherApprovalIfDateStr()); +// +// } else { +// return -1; +// } +// if (simpleBeanList == null) { +// return -1; +// } +// for (int i = 0; i < simpleBeanList.size(); i++) { +// TMomControlPlanSimpleBean bean = simpleBeanList.get(i); +// if (bean.getHbdyg() != null && !bean.getHbdyg().equals("")) { +// getCombineRow(bean.getHbdyg(), startRow); +// } +// XSSFRow row = null; +// Boolean isCreat = false; +// System.out.println("row = " + (i + startRow)); +// if ((i + startRow) > sheet.getLastRowNum()) { +// row = sheet.createRow(i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // 获取特殊字符所在位置 +// String[] columnNames = null; +// Map indexMap = new HashMap(); +// if (bean.getSpecial() != null && !bean.getSpecial().equals("")) { +// try { +// if (bean.getSpecial().indexOf("|") >= 0) { +// columnNames = bean.getSpecial().split("\\|"); +// } else { +// columnNames = new String[] { bean.getSpecial() }; +// } +// if (columnNames != null && columnNames.length > 0) { +// for (int i1 = 0; i1 < columnNames.length; i1++) { +// if (columnNames[i1].indexOf("-") >= 0) { +// String[] columnName = columnNames[i1].split("-"); +// // 通过列名称获取列 +// int cellindex = -1; +// if (columnName[0].indexOf(",") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll(",", "")); +// } else if (columnName[0].indexOf("/") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll("/", "")); +// } else { +// cellindex = getOneNamedCellIndex(wb, columnName[0]); +// } +// if (cellindex > -1) { +// indexMap.put(cellindex, Integer.parseInt(columnName[1])); +// } +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// } +// for (int cols = 0; cols <= 13; cols++) { +// XSSFCell cell = null; +// if (isCreat) { +// cell = row.createCell(cols); +// } else { +// cell = row.getCell(cols); +// } +// if (cell == null) +// cell = row.getCell(cols); +// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +// +// switch (cols) { +// +// case 0: +// if (bean.getPartProcessNumber() != null && bean.getPartProcessNumber().indexOf("\n") >= 0 +// && bean.getPartProcessNumber().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getPartProcessNumber().split("\n")[1]); +// } else if (bean.getPartProcessNumber() != null && bean.getPartProcessNumber().indexOf("\n") >= 0 +// && bean.getPartProcessNumber().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getPartProcessNumber().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getPartProcessNumber(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getPartProcessNumber()); +// } +// break; +// case 1: +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("\n") >= 0 +// && bean.getProcessName().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProcessName().split("\n")[1]); +// } else if (bean.getProcessName() != null && bean.getProcessName().indexOf("\n") >= 0 +// && bean.getProcessName().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProcessName().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcessName(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcessName()); +// } +// break; +// case 2: +// if (bean.getMachineDevice() != null && bean.getMachineDevice().indexOf("\n") >= 0 +// && bean.getMachineDevice().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getMachineDevice().split("\n")[1]); +// } else if (bean.getMachineDevice() != null && bean.getMachineDevice().indexOf("\n") >= 0 +// && bean.getMachineDevice().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getMachineDevice().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getMachineDevice(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getMachineDevice()); +// } +// break; +// case 3: +// if (bean.getSmjy() != null && bean.getSmjy().indexOf("\n") >= 0 +// && bean.getSmjy().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSmjy().split("\n")[1]); +// } else if (bean.getSmjy() != null && bean.getSmjy().indexOf("\n") >= 0 +// && bean.getSmjy().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSmjy().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSmjy(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSmjy()); +// } +// break; +// case 4: +// if (bean.getBubbledPrintNo() != null && bean.getBubbledPrintNo().indexOf("\n") >= 0 +// && bean.getBubbledPrintNo().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getBubbledPrintNo().split("\n")[1]); +// } else if (bean.getBubbledPrintNo() != null && bean.getBubbledPrintNo().indexOf("\n") >= 0 +// && bean.getBubbledPrintNo().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getBubbledPrintNo().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getBubbledPrintNo(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getBubbledPrintNo()); +// } +// break; +// case 5: +// if (bean.getProduct() != null && bean.getProduct().indexOf("\n") >= 0 +// && bean.getProduct().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProduct().split("\n")[1]); +// } else if (bean.getProduct() != null && bean.getProduct().indexOf("\n") >= 0 +// && bean.getProduct().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProduct().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProduct(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProduct()); +// } +// break; +// case 6: +// if (bean.getProcess() != null && bean.getProcess().indexOf("\n") >= 0 +// && bean.getProcess().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProcess().split("\n")[1]); +// } else if (bean.getProcess() != null && bean.getProcess().indexOf("\n") >= 0 +// && bean.getProcess().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProcess().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcess(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcess()); +// } +// break; +// case 7: +// if (bean.getSpecialClass() != null && bean.getSpecialClass().indexOf("\n") >= 0 +// && bean.getSpecialClass().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSpecialClass().split("\n")[1]); +// } else if (bean.getSpecialClass() != null && bean.getSpecialClass().indexOf("\n") >= 0 +// && bean.getSpecialClass().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSpecialClass().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSpecialClass(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSpecialClass()); +// } +// break; +// case 8: +// if (bean.getConceal().equals("1")) { +// String processName = bean.getProcessName();// .split("\n")[1]; +// String productId = bean.getMeopId().split("_")[0]; +// StringBuffer value = new StringBuffer(); +// System.out.println(value.length()); +// if (type.indexOf("CHINESE") != -1) { +// String name = processName.split("\n")[0]; +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) { +// name = name.substring(3, name.length() - 1); +// } +// value.append("详见" + name + "作业指导书/" + productId); +// // cell.setCellValue("详见"+processName+"作业指导书/"+productId); +// } +// if (type.indexOf("ENGLISH") != -1) { +// String name = processName.split("\n")[1]; +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) { +// name = name.substring(8, name.length() - 1); +// } +// if (value.length() != 0) +// value.append("\n"); +// value.append("In " + name + " OP INS/" + productId); +// +// } +// cell.setCellValue(value.toString()); +// } else { +// if (bean.getProductProcessSpecificationTolerance() != null +// && bean.getProductProcessSpecificationTolerance().indexOf("\n") >= 0 +// && bean.getProductProcessSpecificationTolerance().split("\n").length == 2 +// && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance().split("\n")[1]); +// } else if (bean.getProductProcessSpecificationTolerance() != null +// && bean.getProductProcessSpecificationTolerance().indexOf("\n") >= 0 +// && bean.getProductProcessSpecificationTolerance().split("\n").length == 2 +// && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProductProcessSpecificationTolerance(), +// indexMap.get(cols), indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance()); +// } +// } +// break; +// case 9: +// if (bean.getEvaluationMeasurementTechnique() != null +// && bean.getEvaluationMeasurementTechnique().indexOf("\n") >= 0 +// && bean.getEvaluationMeasurementTechnique().split("\n").length == 2 +// && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique().split("\n")[1]); +// } else if (bean.getEvaluationMeasurementTechnique() != null +// && bean.getEvaluationMeasurementTechnique().indexOf("\n") >= 0 +// && bean.getEvaluationMeasurementTechnique().split("\n").length == 2 +// && type.equals("CHINESE")) { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getEvaluationMeasurementTechnique(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique()); +// } +// break; +// case 10: +// if (bean.getSampleSize() != null && bean.getSampleSize().indexOf("\n") >= 0 +// && bean.getSampleSize().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSampleSize().split("\n")[1]); +// } else if (bean.getSampleSize() != null && bean.getSampleSize().indexOf("\n") >= 0 +// && bean.getSampleSize().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSampleSize().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleSize(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleSize()); +// } +// break; +// case 11: +// if (bean.getSampleFreq() != null && bean.getSampleFreq().indexOf("\n") >= 0 +// && bean.getSampleFreq().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSampleFreq().split("\n")[1]); +// } else if (bean.getSampleFreq() != null && bean.getSampleFreq().indexOf("\n") >= 0 +// && bean.getSampleFreq().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSampleFreq().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleFreq(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleFreq()); +// } +// break; +// +// case 12: +// if (bean.getControlMethod() != null && bean.getControlMethod().indexOf("\n") >= 0 +// && bean.getControlMethod().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getControlMethod().split("\n")[1]); +// } else if (bean.getControlMethod() != null && bean.getControlMethod().indexOf("\n") >= 0 +// && bean.getControlMethod().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getControlMethod().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getControlMethod(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getControlMethod()); +// } +// break; +// +// case 13: +// if (bean.getReactionPlan() != null && bean.getReactionPlan().indexOf("\n") >= 0 +// && bean.getReactionPlan().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getReactionPlan().split("\n")[1]); +// } else if (bean.getReactionPlan() != null && bean.getReactionPlan().indexOf("\n") >= 0 +// && bean.getReactionPlan().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getReactionPlan().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getReactionPlan(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getReactionPlan()); +// } +// break; +// +// default: +// break; +// +// } +// } +// } +// if (map != null && map.size() != 0) { +// Iterator> it = map.entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// List columnIndex = new ArrayList(); +// for (int i = 0; i < entry.getValue().length; i++) { +// if (entry.getValue()[i] == 6 || entry.getValue()[i] == 7 +// || (entry.getValue()[i] >= 17 && entry.getValue()[i] <= 20) || entry.getValue()[i] == 15) { +// continue; +// } else if (entry.getValue()[i] == 4) { +// columnIndex.add(entry.getValue()[i] - 1); +// } else if (entry.getValue()[i] >= 8 && entry.getValue()[i] <= 14) { +// columnIndex.add(entry.getValue()[i] - 2); +// } else if (entry.getValue()[i] == 16) { +// columnIndex.add(entry.getValue()[i] - 3); +// } else if (entry.getValue()[i] == 18) { +// columnIndex.add(entry.getValue()[i] - 4); +// } else { +// columnIndex.add(entry.getValue()[i]); +// } +// } +// int[] column = new int[columnIndex.size()]; +// for (int i = 0; i < columnIndex.size(); i++) { +// column[i] = columnIndex.get(i); +// } +// if (column.length > 0) { +// combine(sheet, entry.getKey(), column); +// } +// } +// } +// wb.write(output); +// output.close(); +// input.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// return 0; +// } +// +// /** +// * 东睦英文表头--输出控制计划到EXCEL表格中 +// * +// * @param controlPlanBean 控制计划信息 +// * @param input 模版文件流 +// * @param outputFilePath 需要输出的全路径 +// * @throws IOException +// */ +// public static int writeNBTMControlPlanToExcel(TMomControlPlanBean controlPlanBean, InputStream input, +// String outputFilePath, String type) throws IOException { +// +// FileOutputStream output = new FileOutputStream(new File(outputFilePath)); // +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// int startRow = 13; +// map.clear(); +// List simpleBeanList = null; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// simpleBeanList = controlPlanBean.getSimpleBeanList(); +// +// // for (int i = 0; i < (simpleBeanList.size()); i++) +// // insertRow(sheet, 14, 1);// 插入表格行数 +// XSSFRow row1 = sheet.getRow(3); +// setCellValue(row1, 0, row1.getCell(0).getStringCellValue() + controlPlanBean.getControlPlanNo()); +// setCellValue(row1, 5, +// connectPhoneAndPersion(controlPlanBean.getKeyPersion(), controlPlanBean.getKeyPhone())); +// setCellValue(row1, 10, controlPlanBean.getCreateDateStr()); +// setCellValue(row1, 12, controlPlanBean.getUpdateDateStr()); +// XSSFRow row2 = sheet.getRow(5); +// setCellValue(row2, 0, controlPlanBean.getPartNumber()); +// +// setCellValue(row2, 6, controlPlanBean.getCoreTeam()); +// setCellValue(row2, 10, controlPlanBean.getCustromEngineeringApprovalDateStr()); +// +// XSSFRow row3 = sheet.getRow(7); +// setCellValue(row3, 0, controlPlanBean.getPartNameDesc()); +// setCellValue(row3, 6, controlPlanBean.getSupplierApprovalDateStr()); +// setCellValue(row3, 10, controlPlanBean.getCustromQuantyApprovalDateStr()); +// +// XSSFRow row4 = sheet.getRow(9); +// setCellValue(row4, 0, controlPlanBean.getSupplier()); +// setCellValue(row4, 3, controlPlanBean.getSupplierCode()); +// setCellValue(row4, 6, controlPlanBean.getOtherApprovalDateStr()); +// setCellValue(row4, 10, controlPlanBean.getOtherApprovalIfDateStr()); +// +// } else { +// return -1; +// } +// if (simpleBeanList == null) { +// return -1; +// } +// for (int i = 0; i < simpleBeanList.size(); i++) { +// TMomControlPlanSimpleBean bean = simpleBeanList.get(i); +// if (bean.getHbdyg() != null && !bean.getHbdyg().equals("")) { +// getCombineRow(bean.getHbdyg(), startRow); +// } +// XSSFRow row = null; +// Boolean isCreat = false; +// System.out.println("row = " + (i + startRow)); +// if ((i + startRow) > sheet.getLastRowNum()) { +// row = sheet.createRow(i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // 获取特殊字符所在位置 +// String[] columnNames = null; +// Map indexMap = new HashMap(); +// if (bean.getSpecial() != null && !bean.getSpecial().equals("")) { +// try { +// if (bean.getSpecial().indexOf("|") >= 0) { +// columnNames = bean.getSpecial().split("\\|"); +// } else { +// columnNames = new String[] { bean.getSpecial() }; +// } +// if (columnNames != null && columnNames.length > 0) { +// for (int i1 = 0; i1 < columnNames.length; i1++) { +// if (columnNames[i1].indexOf("-") >= 0) { +// String[] columnName = columnNames[i1].split("-"); +// // 通过列名称获取列 +// int cellindex = -1; +// if (columnName[0].indexOf(",") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll(",", "")); +// } else if (columnName[0].indexOf("/") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll("/", "")); +// } else { +// cellindex = getOneNamedCellIndex(wb, columnName[0]); +// } +// if (cellindex > -1) { +// indexMap.put(cellindex, Integer.parseInt(columnName[1])); +// } +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// } +// for (int cols = 0; cols <= 13; cols++) { +// XSSFCell cell = null; +// if (isCreat) { +// cell = row.createCell(cols); +// } else { +// cell = row.getCell(cols); +// } +// if (cell == null) +// cell = row.getCell(cols); +// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +// +// switch (cols) { +// +// case 0: +// // 通过 type.equals("ENGLISH") 来判断中英文显示 +// if (bean.getPartProcessNumber() != null && bean.getPartProcessNumber().indexOf("\n") >= 0 +// && bean.getPartProcessNumber().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getPartProcessNumber().split("\n")[1]);// 英文显示 +// } else if (bean.getPartProcessNumber() != null && bean.getPartProcessNumber().indexOf("\n") >= 0 +// && bean.getPartProcessNumber().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getPartProcessNumber().split("\n")[0]); // 中文显示 +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getPartProcessNumber(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getPartProcessNumber()); // 中英文都显示 +// } +// break; +// case 1: +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("\n") >= 0 +// && bean.getProcessName().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProcessName().split("\n")[1]); +// } else if (bean.getProcessName() != null && bean.getProcessName().indexOf("\n") >= 0 +// && bean.getProcessName().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProcessName().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcessName(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcessName()); +// } +// break; +// case 2: +// if (bean.getMachineDevice() != null && bean.getMachineDevice().indexOf("\n") >= 0 +// && bean.getMachineDevice().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getMachineDevice().split("\n")[1]); +// } else if (bean.getMachineDevice() != null && bean.getMachineDevice().indexOf("\n") >= 0 +// && bean.getMachineDevice().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getMachineDevice().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getMachineDevice(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getMachineDevice()); +// } +// break; +// case 3: +// if (bean.getSmjy() != null && bean.getSmjy().indexOf("\n") >= 0 +// && bean.getSmjy().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSmjy().split("\n")[1]); +// } else if (bean.getSmjy() != null && bean.getSmjy().indexOf("\n") >= 0 +// && bean.getSmjy().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSmjy().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSmjy(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSmjy()); +// } +// break; +// case 4: +// if (bean.getBubbledPrintNo() != null && bean.getBubbledPrintNo().indexOf("\n") >= 0 +// && bean.getBubbledPrintNo().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getBubbledPrintNo().split("\n")[1]); +// } else if (bean.getBubbledPrintNo() != null && bean.getBubbledPrintNo().indexOf("\n") >= 0 +// && bean.getBubbledPrintNo().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getBubbledPrintNo().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getBubbledPrintNo(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getBubbledPrintNo()); +// } +// break; +// case 5: +// if (bean.getProduct() != null && bean.getProduct().indexOf("\n") >= 0 +// && bean.getProduct().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProduct().split("\n")[1]); +// } else if (bean.getProduct() != null && bean.getProduct().indexOf("\n") >= 0 +// && bean.getProduct().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProduct().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProduct(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProduct()); +// } +// break; +// case 6: +// if (bean.getProcess() != null && bean.getProcess().indexOf("\n") >= 0 +// && bean.getProcess().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProcess().split("\n")[1]); +// } else if (bean.getProcess() != null && bean.getProcess().indexOf("\n") >= 0 +// && bean.getProcess().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProcess().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcess(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcess()); +// } +// break; +// case 7: +// if (bean.getSpecialClass() != null && bean.getSpecialClass().indexOf("\n") >= 0 +// && bean.getSpecialClass().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSpecialClass().split("\n")[1]); +// } else if (bean.getSpecialClass() != null && bean.getSpecialClass().indexOf("\n") >= 0 +// && bean.getSpecialClass().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSpecialClass().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSpecialClass(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSpecialClass()); +// } +// break; +// case 8: +// if (bean.getConceal().equals("1")) { +// String processName = bean.getProcessName();// .split("\n")[1]; +// String productId = bean.getMeopId().split("_")[0]; +// StringBuffer value = new StringBuffer(); +// System.out.println(value.length()); +// if (type.indexOf("CHINESE") != -1) { +// String name = processName.split("\n")[0]; +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) { +// name = name.substring(3, name.length() - 1); +// } +// value.append("详见" + name + "作业指导书/" + productId); +// // cell.setCellValue("详见"+processName+"作业指导书/"+productId); +// } +// if (type.indexOf("ENGLISH") != -1) { +// String name = processName.split("\n")[1]; +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) { +// name = name.substring(8, name.length() - 1); +// } +// if (value.length() != 0) +// value.append("\n"); +// value.append("In " + name + " OP INS/" + productId); +// +// } +// cell.setCellValue(value.toString()); +// } else { +// if (bean.getProductProcessSpecificationTolerance() != null +// && bean.getProductProcessSpecificationTolerance().indexOf("\n") >= 0 +// && bean.getProductProcessSpecificationTolerance().split("\n").length == 2 +// && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance().split("\n")[1]); +// } else if (bean.getProductProcessSpecificationTolerance() != null +// && bean.getProductProcessSpecificationTolerance().indexOf("\n") >= 0 +// && bean.getProductProcessSpecificationTolerance().split("\n").length == 2 +// && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProductProcessSpecificationTolerance(), +// indexMap.get(cols), indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance()); +// } +// } +// break; +// case 9: +// if (bean.getEvaluationMeasurementTechnique() != null +// && bean.getEvaluationMeasurementTechnique().indexOf("\n") >= 0 +// && bean.getEvaluationMeasurementTechnique().split("\n").length == 2 +// && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique().split("\n")[1]); +// } else if (bean.getEvaluationMeasurementTechnique() != null +// && bean.getEvaluationMeasurementTechnique().indexOf("\n") >= 0 +// && bean.getEvaluationMeasurementTechnique().split("\n").length == 2 +// && type.equals("CHINESE")) { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getEvaluationMeasurementTechnique(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique()); +// } +// break; +// case 10: +// if (bean.getSampleSize() != null && bean.getSampleSize().indexOf("\n") >= 0 +// && bean.getSampleSize().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSampleSize().split("\n")[1]); +// } else if (bean.getSampleSize() != null && bean.getSampleSize().indexOf("\n") >= 0 +// && bean.getSampleSize().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSampleSize().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleSize(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleSize()); +// } +// break; +// case 11: +// if (bean.getSampleFreq() != null && bean.getSampleFreq().indexOf("\n") >= 0 +// && bean.getSampleFreq().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSampleFreq().split("\n")[1]); +// } else if (bean.getSampleFreq() != null && bean.getSampleFreq().indexOf("\n") >= 0 +// && bean.getSampleFreq().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSampleFreq().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleFreq(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleFreq()); +// } +// break; +// +// case 12: +// if (bean.getControlMethod() != null && bean.getControlMethod().indexOf("\n") >= 0 +// && bean.getControlMethod().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getControlMethod().split("\n")[1]); +// } else if (bean.getControlMethod() != null && bean.getControlMethod().indexOf("\n") >= 0 +// && bean.getControlMethod().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getControlMethod().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getControlMethod(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getControlMethod()); +// } +// break; +// +// case 13: +// if (bean.getReactionPlan() != null && bean.getReactionPlan().indexOf("\n") >= 0 +// && bean.getReactionPlan().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getReactionPlan().split("\n")[1]); +// } else if (bean.getReactionPlan() != null && bean.getReactionPlan().indexOf("\n") >= 0 +// && bean.getReactionPlan().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getReactionPlan().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getReactionPlan(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getReactionPlan()); +// } +// break; +// +// default: +// break; +// +// } +// } +// } +// if (map != null && map.size() != 0) { +// Iterator> it = map.entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// List columnIndex = new ArrayList(); +// for (int i = 0; i < entry.getValue().length; i++) { +// if (entry.getValue()[i] == 3 || entry.getValue()[i] == 5 || entry.getValue()[i] == 6 +// || (entry.getValue()[i] >= 18 && entry.getValue()[i] <= 20) || entry.getValue()[i] == 14 +// || entry.getValue()[i] == 16) { +// continue; +// } else if (entry.getValue()[i] == 4) { +// columnIndex.add(entry.getValue()[i] - 1); +// } else if (entry.getValue()[i] >= 7 && entry.getValue()[i] <= 13) { +// columnIndex.add(entry.getValue()[i] - 3); +// } else if (entry.getValue()[i] == 15) { +// columnIndex.add(entry.getValue()[i] - 4); +// } else if (entry.getValue()[i] == 17) { +// columnIndex.add(entry.getValue()[i] - 5); +// } else { +// columnIndex.add(entry.getValue()[i]); +// } +// } +// int[] column = new int[columnIndex.size()]; +// for (int i = 0; i < columnIndex.size(); i++) { +// column[i] = columnIndex.get(i); +// } +// if (column.length > 0) { +// combine(sheet, entry.getKey(), column); +// } +// } +// } +// wb.write(output); +// output.close(); +// input.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// return 0; +// } +// +// /** +// * 输出本部控制计划到EXCEL表格中 +// * +// * @param controlPlanBean 控制计划信息 +// * @param input 模版文件流 +// * @param outputFilePath 需要输出的全路径 +// * @throws IOException +// */ +// public static int writeControlPlanToExcel(TMomControlPlanBean controlPlanBean, File file) throws IOException { +// file.setWritable(true); +// InputStream is = new FileInputStream(file); +// XSSFWorkbook wb = new XSSFWorkbook(is);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// map.clear(); +// int startRow = 13; +// List simpleBeanList = null; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// simpleBeanList = controlPlanBean.getSimpleBeanList(); +// +// for (int i = 0; i < (simpleBeanList.size()); i++) +// insertRow(sheet, 13, 1);// 插入表格行数 +// XSSFRow row1 = sheet.getRow(3); +// setCellValue(row1, 4, controlPlanBean.getControlPlanNo()); +// setCellValue(row1, 8, controlPlanBean.getKeyPersion()); +// setCellValue(row1, 10, controlPlanBean.getKeyPhone()); +// setCellValue(row1, 12, controlPlanBean.getCreateDateStr()); +// setCellValue(row1, 15, controlPlanBean.getUpdateDateStr()); +// XSSFRow row2 = sheet.getRow(5); +// setCellValue(row2, 0, controlPlanBean.getSorName()); +// setCellValue(row2, 4, controlPlanBean.getPartNumber()); +// setCellValue(row2, 8, controlPlanBean.getCoreTeam()); +// setCellValue(row2, 12, controlPlanBean.getCustromEngineeringApprovalDateStr()); +// XSSFRow row3 = sheet.getRow(7); +// setCellValue(row3, 0, controlPlanBean.getCustromPartNumber()); +// setCellValue(row3, 4, controlPlanBean.getPartNameDesc()); +// setCellValue(row3, 8, controlPlanBean.getSupplierApprovalDateStr()); +// setCellValue(row3, 12, controlPlanBean.getCustromQuantyApprovalDateStr()); +// XSSFRow row4 = sheet.getRow(9); +// setCellValue(row4, 0, controlPlanBean.getSupplier()); +// setCellValue(row4, 4, controlPlanBean.getSupplierCode()); +// setCellValue(row4, 6, controlPlanBean.getChangeLev()); +// setCellValue(row4, 8, controlPlanBean.getMode()); +// setCellValue(row4, 10, controlPlanBean.getCustromApprovalDateStr()); +// setCellValue(row4, 12, controlPlanBean.getOtherApprovalDateStr()); +// setCellValue(row4, 15, controlPlanBean.getOtherApprovalIfDateStr()); +// } else { +// return -1; +// } +// if (simpleBeanList == null) { +// return -1; +// } +// for (int i = 0; i < simpleBeanList.size(); i++) { +// TMomControlPlanSimpleBean bean = simpleBeanList.get(i); +// if (bean.getHbdyg() != null && !bean.getHbdyg().equals("")) { +// getCombineRow(bean.getHbdyg(), startRow); +// } +// XSSFRow row = null; +// Boolean isCreat = false; +// if ((i + startRow) > sheet.getLastRowNum()) { +// row = sheet.createRow(i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // 获取特殊字符所在位置+++++++++++++++++ +// String[] columnNames = null; +// Map indexMap = new HashMap(); +// if (bean.getSpecial() != null && !bean.getSpecial().equals("")) { +// try { +// if (bean.getSpecial().indexOf("|") >= 0) { +// columnNames = bean.getSpecial().split("\\|"); +// } else { +// columnNames = new String[] { bean.getSpecial() }; +// } +// if (columnNames != null && columnNames.length > 0) { +// for (int i1 = 0; i1 < columnNames.length; i1++) { +// if (columnNames[i1].indexOf("-") >= 0) { +// String[] columnName = columnNames[i1].split("-"); +// // 通过列名称获取列 +// int cellindex = -1; +// if (columnName[0].indexOf(",") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll(",", "")); +// } else if (columnName[0].indexOf("/") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll("/", "")); +// } else { +// cellindex = getOneNamedCellIndex(wb, columnName[0]); +// } +// if (cellindex > -1) { +// indexMap.put(cellindex, Integer.parseInt(columnName[1])); +// } +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// } +// for (int cols = 0; cols < 18; cols++) { +// XSSFCell cell = null; +// if (isCreat) { +// cell = row.createCell(cols); +// } else { +// cell = row.getCell(cols); +// } +// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +// +// switch (cols) { +// +// case 0: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getPartProcessNumber(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getPartProcessNumber()); +// } +// break; +// case 1: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcessName(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcessName()); +// } +// break; +// case 2: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getMachineDevice(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getMachineDevice()); +// } +// break; +// case 3: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSmjy(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSmjy()); +// } +// break; +// case 4: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getBubbledPrintNo(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getBubbledPrintNo()); +// } +// break; +// case 5: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSize(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSize()); +// } +// break; +// case 6: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getNo(), indexMap.get(cols), indexMap.get(cols) + 1, 10, +// "Y14.5M")); +// } else { +// cell.setCellValue(bean.getNo()); +// } +// break; +// case 7: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProduct(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProduct()); +// } +// break; +// case 8: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcess(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcess()); +// } +// break; +// case 9: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSpecialClass(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSpecialClass()); +// } +// break; +// case 10: +// if (bean.getConceal().equals("1")) { +// String processName = bean.getProcessName(); +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) { +// processName = bean.getProcessName().substring(3, +// bean.getProcessName().toString().length() - 1); +// } +// cell.setCellValue("详见" + processName + "作业指导书"); +// } else { +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProductProcessSpecificationTolerance(), +// indexMap.get(cols), indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance()); +// } +// } +////注释 +//// if (bean.getUpProductProcessSpecificationTolerance() == null) { +//// cell.setCellValue(""); +//// } else if (!bean +//// .getUpProductProcessSpecificationTolerance().trim() +//// .isEmpty() +//// && !bean.getDownProductProcessSpecificationTolerance() +//// .trim().isEmpty()) +//// cell.setCellValue(bean +//// .getProductProcessSpecificationTolerance() +//// + " " +//// + bean.getUpProductProcessSpecificationTolerance() +//// + "/" +//// + bean.getDownProductProcessSpecificationTolerance()); +//// else { +//// +//// } +////注释 +// break; +// case 11: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getEvaluationMeasurementTechnique(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique()); +// } +// break; +// case 12: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleSize(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleSize()); +// } +// break; +// case 13: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleFreq(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleFreq()); +// } +// break; +// case 14: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getResp(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getResp()); +// } +// break; +// case 15: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getControlMethod(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getControlMethod()); +// } +// break; +// case 16: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getOperationCriteria(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getOperationCriteria()); +// } +// break; +// case 17: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getReactionPlan(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getReactionPlan()); +// } +// break; +// +// default: +// break; +// +// } +// } +// } +// if (map != null && map.size() != 0) { +// Iterator> it = map.entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// List columnIndex = new ArrayList(); +// for (int i = 0; i < entry.getValue().length; i++) { +// if ((entry.getValue()[i] >= 18 && entry.getValue()[i] <= 20)) { +// continue; +// } else { +// columnIndex.add(entry.getValue()[i]); +// } +// } +// int[] column = new int[columnIndex.size()]; +// for (int i = 0; i < columnIndex.size(); i++) { +// column[i] = columnIndex.get(i); +// } +// if (column.length > 0) { +// combine(sheet, entry.getKey(), column); +// } +// } +// } +// //+++++++++++++++++++ +// FileOutputStream output = new FileOutputStream(file); +// wb.write(output); +// output.close(); +// is.close(); +// // file.setReadOnly(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// return 0; +// } +// +// /** +// * 输出本部控制计划到EXCEL表格中 +// * +// * @param controlPlanBean 控制计划信息 +// * @param input 模版文件流 +// * @param outputFilePath 需要输出的全路径 +// * @throws IOException +// */ +// public static int writeControlPlanToExcel(TMomControlPlanBean controlPlanBean, File file, String outFilePath) +// throws IOException { +// InputStream input = new FileInputStream(file); +// FileOutputStream output = new FileOutputStream(new File(outFilePath)); // +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// map.clear(); +// int startRow = 9; +// List simpleBeanList = null; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// simpleBeanList = controlPlanBean.getSimpleBeanList(); +// +// for (int i = 0; i < (simpleBeanList.size()); i++) { +// //+++ +// if (simpleBeanList.get(i).getHbdyg() != null && !simpleBeanList.get(i).getHbdyg().equals("")) { +// String sombine = simpleBeanList.get(i).getHbdyg().toString(); +// int rowDif = 0; +// String[] sombines; +// if (sombine.indexOf("-") >= 0) { +// sombines = sombine.split("-"); +// } else { +// sombines = new String[] { sombine }; +// } +// for (int j = 0; j < sombines.length; j++) { +// if (sombines[j].indexOf("/") >= 0) { +// int[] row; +// int[] cloumn; +// String[] cells = sombines[j].split("/"); +// if (cells[0].indexOf(",") >= 0) { +// String[] rows = cells[0].split(","); +// row = new int[rows.length]; +// for (int k = 0; k < rows.length; k++) { +// row[k] = Integer.parseInt(rows[k]) + rowDif; +// } +// } else { +// row = new int[] { Integer.parseInt(cells[0]) + rowDif }; +// } +// if (cells[1].indexOf(",") >= 0) { +// String[] cloumns = cells[1].split(","); +// cloumn = new int[cloumns.length]; +// for (int k = 0; k < cloumns.length; k++) { +// cloumn[k] = Integer.parseInt(cloumns[k]); +// } +// } else { +// cloumn = new int[] { Integer.parseInt(cells[1]) }; +// } +// map.put(row, cloumn); +// } +// } +// } +// //+++ +// // insertRow(sheet, 13, 1);// 插入表格行数 +// } +// XSSFRow row3 = sheet.getRow(2); +// //setCellValue(row3, 0,"控制计划类型:"+ controlPlanBean.getControlType()+"\n控制计划编号:"+controlPlanBean.getControlPlanNo()); +// +// setCellValue(row3,5,"主要联系人/电话:"+controlPlanBean.getKeyPhone()); +// setCellValue(row3,10,"日期(编制):"+controlPlanBean.getCreateDateStr()); +// setCellValue(row3,13,"日期(修订):"+controlPlanBean.getUpdateDateStr()); +// XSSFRow row4 = sheet.getRow(3); +// setCellValue(row4,0,"零件号/最新更改程度:"+controlPlanBean.getPartNumber()); +// setCellValue(row4,5,"核心小组:"+controlPlanBean.getCoreTeam()); +// setCellValue(row4,10,"顾客工程批准/日期(如需要):"+controlPlanBean.getCustromEngineeringApprovalDateStr()); +// XSSFRow row5 = sheet.getRow(4); +// setCellValue(row5,0,"零件名称/描述:"+controlPlanBean.getPartNameDesc()); +// setCellValue(row5,5,"供方/工厂批准/日期:"+controlPlanBean.getSupplierApprovalDateStr()); +// setCellValue(row5,10,"顾客质量批准/日期(如需要):"+controlPlanBean.getCustromQuantyApprovalDateStr()); +// XSSFRow row6 = sheet.getRow(5); +// setCellValue(row6,0,"供方/工厂:"+controlPlanBean.getSupplier()); +// setCellValue(row6,3,"供方代号:"+controlPlanBean.getSupplierCode()); +// setCellValue(row6,5,"其它批准/日期(如需要):"+controlPlanBean.getOtherApprovalDateStr()); +// setCellValue(row6,10,"其它批准/日期(如需要):"+controlPlanBean.getOtherApprovalIfDateStr()); +// +// } else { +// return -1; +// } +// if (simpleBeanList == null) { +// return -1; +// } +// for (int i = 0; i < simpleBeanList.size(); i++) { +// +// XSSFRow row = null; +// Boolean isCreat = false; +// if(i<22) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// }else{ +// row = sheet.createRow(i+ startRow); +// isCreat = true; +// } +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 0; j < 15; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// combine(sheet, new int[] { i + startRow }, new int[] { 4, 5 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 9, 10 }); +// } +// XSSFCell cell0 = row.getCell(0); +// cell0.setCellValue(simpleBeanList.get(i).getPartProcessNumber()); +// XSSFCell cell1 = row.getCell(1); +// cell1.setCellValue(simpleBeanList.get(i).getProcessName()); +// XSSFCell cell2 = row.getCell(2); +// cell2.setCellValue(simpleBeanList.get(i).getMachineDevice()); +// XSSFCell cell3 = row.getCell(3); +// cell3.setCellValue(simpleBeanList.get(i).getNo()); +// XSSFCell cell4 = row.getCell(4); +// cell4.setCellValue(simpleBeanList.get(i).getProduct()); +// XSSFCell cell6 = row.getCell(6); +// cell6.setCellValue(simpleBeanList.get(i).getProcess()); +//// XSSFCell cell7 = row.getCell(7); +//// cell7.setCellValue(simpleBeanList.get(i).getSpecialClass()); +// +// //+++处理特殊字符,到数据库表格RB3_SPETABLE查询对应的字符 +// XSSFCell cell7 = row.getCell(7); +// ResultSet rs = null; +// SqlUtilT.getTCConnection(); +// String selectSQL = String.format("SELECT SPE FROM RB3_SPETABLE WHERE ORI='%s'",simpleBeanList.get(i).getSpecialClass()); +// System.out.print(selectSQL); +// try { +// String ss=simpleBeanList.get(i).getSpecialClass(); +// rs = SqlUtilT.read(selectSQL); +// while (rs.next()) { +// ss=rs.getString("SPE"); +// } +// cell7.setCellValue(ss); +// } catch (SQLException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// //+++ +// +// XSSFCell cell8 = row.getCell(8); +// cell8.setCellValue(simpleBeanList.get(i).getProductProcessSpecificationTolerance()); +// XSSFCell cell9 = row.getCell(9); +// cell9.setCellValue(simpleBeanList.get(i).getEvaluationMeasurementTechnique()); +// XSSFCell cell11 = row.getCell(11); +// cell11.setCellValue(simpleBeanList.get(i).getSampleSize()); +// XSSFCell cell12 = row.getCell(12); +// cell12.setCellValue(simpleBeanList.get(i).getSampleFreq()); +// XSSFCell cell13 = row.getCell(13); +// cell13.setCellValue(simpleBeanList.get(i).getControlMethod()); +// XSSFCell cell14 = row.getCell(14); +// cell14.setCellValue(simpleBeanList.get(i).getReactionPlan()); +// } +//// TMomControlPlanSimpleBean bean = simpleBeanList.get(i); +//// if (bean.getHbdyg() != null && !bean.getHbdyg().equals("")) { +//// getCombineRow(bean.getHbdyg(), startRow); +//// } +//// XSSFRow row = null; +//// Boolean isCreat = false; +//// if ((i + startRow) > sheet.getLastRowNum()) { +//// row = sheet.createRow(i + startRow); +//// isCreat = true; +//// } else { +//// row = sheet.getRow(i + startRow); +//// isCreat = false; +//// } +//// +//// // 获取特殊字符所在位置++++++ +//// String[] columnNames = null; +//// Map indexMap = new HashMap(); +//// if (bean.getSpecial() != null && !bean.getSpecial().equals("")) { +//// try { +//// if (bean.getSpecial().indexOf("|") >= 0) { +//// columnNames = bean.getSpecial().split("\\|"); +//// } else { +//// columnNames = new String[] { bean.getSpecial() }; +//// } +//// if (columnNames != null && columnNames.length > 0) { +//// for (int i1 = 0; i1 < columnNames.length; i1++) { +//// if (columnNames[i1].indexOf("-") >= 0) { +//// String[] columnName = columnNames[i1].split("-"); +//// // 通过列名称获取列 +//// int cellindex = -1; +//// if (columnName[0].indexOf(",") >= 0) { +//// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll(",", "")); +//// } else if (columnName[0].indexOf("/") >= 0) { +//// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll("/", "")); +//// } else { +//// cellindex = getOneNamedCellIndex(wb, columnName[0]); +//// } +//// if (cellindex > -1) { +//// indexMap.put(cellindex, Integer.parseInt(columnName[1])); +//// } +//// } +//// } +//// } +//// } catch (Exception e) { +//// // TODO: handle exception +//// e.printStackTrace(); +//// } +//// } +//// for (int cols = 0; cols < 18; cols++) { +//// XSSFCell cell = null; +//// if (isCreat) { +//// cell = row.createCell(cols); +//// } else { +//// cell = row.getCell(cols); +//// } +//// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +//// +//// switch (cols) { +//// +//// case 0: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getPartProcessNumber(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getPartProcessNumber()); +//// } +//// break; +//// case 1: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getProcessName(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getProcessName()); +//// } +//// break; +//// case 2: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getMachineDevice(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getMachineDevice()); +//// } +//// break; +//// case 3: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getSmjy(), indexMap.get(cols), indexMap.get(cols) + 1, +//// 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getSmjy()); +//// } +//// break; +//// case 4: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getBubbledPrintNo(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getBubbledPrintNo()); +//// } +//// break; +//// case 5: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getSize(), indexMap.get(cols), indexMap.get(cols) + 1, +//// 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getSize()); +//// } +//// break; +//// case 6: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getNo(), indexMap.get(cols), indexMap.get(cols) + 1, 10, +//// "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getNo()); +//// } +//// break; +//// case 7: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getProduct(), indexMap.get(cols), indexMap.get(cols) + 1, +//// 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getProduct()); +//// } +//// break; +//// case 8: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getProcess(), indexMap.get(cols), indexMap.get(cols) + 1, +//// 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getProcess()); +//// } +//// break; +//// case 9: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getSpecialClass(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getSpecialClass()); +//// } +//// break; +//// case 10: +////// if(bean.getConceal().equals("1")) +////// { +////// String processName = bean.getProcessName(); +////// if(bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) +////// { +////// processName = bean.getProcessName().substring(3, bean.getProcessName().toString().length()-1); +////// } +////// cell.setCellValue("详见"+processName+"作业指导书"); +////// } +////// else +////// { +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getProductProcessSpecificationTolerance(), +//// indexMap.get(cols), indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getProductProcessSpecificationTolerance()); +//// } +//////注释 +////// } +////// if (bean.getUpProductProcessSpecificationTolerance() == null) { +////// cell.setCellValue(""); +////// } else if (!bean +////// .getUpProductProcessSpecificationTolerance().trim() +////// .isEmpty() +////// && !bean.getDownProductProcessSpecificationTolerance() +////// .trim().isEmpty()) +////// cell.setCellValue(bean +////// .getProductProcessSpecificationTolerance() +////// + " " +////// + bean.getUpProductProcessSpecificationTolerance() +////// + "/" +////// + bean.getDownProductProcessSpecificationTolerance()); +////// else { +////// +////// } +//////注释 +//// break; +//// case 11: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getEvaluationMeasurementTechnique(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getEvaluationMeasurementTechnique()); +//// } +//// break; +//// case 12: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getSampleSize(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getSampleSize()); +//// } +//// break; +//// case 13: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getSampleFreq(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getSampleFreq()); +//// } +//// break; +//// case 14: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getResp(), indexMap.get(cols), indexMap.get(cols) + 1, +//// 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getResp()); +//// } +//// break; +//// case 15: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getControlMethod(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getControlMethod()); +//// } +//// break; +//// case 16: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getOperationCriteria(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getOperationCriteria()); +//// } +//// break; +//// case 17: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getReactionPlan(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getReactionPlan()); +//// } +//// break; +//// +//// default: +//// break; +//// +//// } +//// } +//// } +//// if (map != null && map.size() != 0) { +//// Iterator> it = map.entrySet().iterator(); +//// while (it.hasNext()) { +//// Map.Entry entry = it.next(); +//// List columnIndex = new ArrayList(); +//// for (int i = 0; i < entry.getValue().length; i++) { +//// if ((entry.getValue()[i] >= 18 && entry.getValue()[i] <= 20)) { +//// continue; +//// } else { +//// columnIndex.add(entry.getValue()[i]); +//// } +//// } +//// int[] column = new int[columnIndex.size()]; +//// for (int i = 0; i < columnIndex.size(); i++) { +//// column[i] = columnIndex.get(i); +//// } +//// if (column.length > 0) { +//// combine(sheet, entry.getKey(), column); +//// } +//// } +//// } +// //+++ +// // 合并单元格 +// if (map != null && map.size() > 0) { +// Iterator> it = map.entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// int[] row = new int[entry.getKey().length]; +// int[] column = new int[entry.getValue().length]; +// for (int k = 0; k < entry.getKey().length; k++) { +// //row[k] = entry.getKey()[k] + 17; +// row[k] = entry.getKey()[k]+9 ; +// } +// for (int k = 0; k < entry.getValue().length; k++) { +// if(entry.getValue()[k]<=5) { +// column[k] = entry.getValue()[k] -1; +// }else if(entry.getValue()[k]>9) { +// column[k] = entry.getValue()[k] +1; +// }else { +// column[k] = entry.getValue()[k]; +// } +// } +// if(column.length==1&&column[0]==4){ +// for(int s=0;s= firstRow && row <= lastRow) + { + if(column >= firstColumn && column <= lastColumn) + { + index = i; + } + } + } + sheet.removeMergedRegion(index);//移除合并单元格 + } +//+++ + + /** + * 改变数据集的命名引用 + * + * @param tccomponentDataset + * @param quote + * @param type + * @param path + * @throws TCException + */ + public static void changeDataSet(TCComponentDataset tccomponentDataset, String quote, String type, String path) + throws TCException { + String myPath[] = { path }; + String myQuote[] = { quote };// 引用"excel" + String myType[] = { type };// 类型"MSExcelX" + String myPlain[] = { "Plain" }; + + // 删除数据集的引用 + deleDateSetRef(tccomponentDataset); + // 数据集的替换 + tccomponentDataset.setFiles(myPath, myType, myPlain, myQuote); + + } + + /** + * 删除数据集的命名引用 + * + * @param dataset + * @throws TCException + */ + private static void deleDateSetRef(TCComponentDataset dataset) throws TCException { + + TCComponentTcFile[] tcFiles = dataset.getTcFiles(); + for (int i = 0; i < tcFiles.length; i++) { + // 得到数据集的引用类型 + String str_temp = getNamedRefType(dataset, tcFiles[i]); + // 删除引用 + dataset.removeNamedReference(str_temp); + } + + } + + /** + * 得到数据集的引用类型 + * + * @param datasetComponent + * @param tccomponent + * @return + * @throws TCException + */ + private static String getNamedRefType(TCComponentDataset datasetComponent, TCComponentTcFile tccomponent) + throws TCException { + String s; + s = ""; + TCProperty tcproperty; + TCProperty tcproperty1; + TCComponent atccomponent[]; + String as[]; + int i; + int j; + int k; + try { + tcproperty = datasetComponent.getTCProperty("ref_list"); + tcproperty1 = datasetComponent.getTCProperty("ref_names"); + if (tcproperty == null || tcproperty1 == null) + return s; + } catch (TCException tcexception) { + return s; + } + atccomponent = tcproperty.getReferenceValueArray(); + as = tcproperty1.getStringValueArray(); + if (atccomponent == null || as == null) + return s; + i = atccomponent.length; + if (i != as.length) + return s; + j = -1; + k = 0; + do { + if (k >= i) + break; + if (tccomponent == atccomponent[k]) { + j = k; + break; + } + k++; + } while (true); + if (j != -1) + s = as[j]; + return s; + } + + /** + * 下载文件 + * + * @param comps + * @return + * @throws TCException + * @throws IOException + */ + public static String downLoadFile(TCComponentDataset dateSet, String compType) throws TCException, IOException { + String value = ""; + String tempPath = System.getenv("TEMP"); + // MessageBox.post(" tempPath = "+tempPath,"INFO",MessageBox.INFORMATION); + if (tempPath == null) { + tempPath = ""; + } else if (!tempPath.endsWith("\\")) { + tempPath = tempPath + "\\"; + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyymmdd"); + TCComponentTcFile[] tcFiles = dateSet.getTcFiles(); + File file = null; + if (tcFiles != null) { + file = tcFiles[0].getFmsFile(); + String fileName = file.getName(); + String fileDix = fileName.substring(fileName.lastIndexOf("."), fileName.length()); + fileName = tempPath + sdf.format(new Date()) + fileDix; + File dirFile = new File(fileName); + FileUtility.copyFile(file, dirFile); +// if (compType.equals("MSExcelX")) { +// this.excelDataset = (TCComponentDataset) comp; +// } + return fileName; + } + return value; + } + + public static void setFlowChart(Map valueMap, File file) { + // TODO Auto-generated method stub + file.setWritable(true); + try { + InputStream is = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(is);// ( + XSSFSheet sheet = wb.getSheetAt(0); + + Iterator> it = valueMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + setNamedCellValue(wb, entry.getKey(), entry.getValue()); + } + FileOutputStream output = new FileOutputStream(file); + wb.write(output); + output.close(); + is.close(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + // file.setReadOnly(); + System.out.println("-------WRITE EXCEL OVER-------"); + } + + public static Workbook getWorkbok(File file) throws IOException { + Workbook wb = null; + FileInputStream in = new FileInputStream(file); + System.out.println(file.getName()); + + if (file.getName().endsWith(EXCEL_XLS)) { // Excel 2003 + wb = new HSSFWorkbook(in); + } else if (file.getName().endsWith(EXCEL_XLSX)) { // Excel 2007/2010 + System.out.println("OK"); + wb = new XSSFWorkbook(in); + } + return wb; + } + + /** + * 读取EXCEL表 + * + * @param File excel_file + * @return List> 返回的信息 + * @throws IOException + * @throws FileNotFoundException + */ +// public static List readExcelByEntrustment(File excel_file, String type) +// throws FileNotFoundException, IOException { +// if (excel_file == null || !excel_file.exists()) { +// return null; +// } +// // 用来返回的所有的行的信息 +// List lines_msg = new ArrayList(); +// XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); +// XSSFSheet sheet = workBook.getSheetAt(0); +// XSSFRow title_row = sheet.getRow(0); +// +// // 得到列的数目 +// int col_count = title_row.getPhysicalNumberOfCells(); +// // 得到行的数目 +// int row_count = sheet.getLastRowNum(); +// boolean isSelectType = false;// 判断是否找到指定的类型 +// for (int j = 0; j < row_count + 1; j++) { +// // 用来返回单行的信息 +// XSSFRow row = sheet.getRow(j); +// if (row == null) { +// isSelectType = false; +// continue; +// } +// // System.out.println(getStringCellValue(evaluator, row.getCell((short) 0))); +// if (getStringCellValue(evaluator, row.getCell((short) 0)) == null +// || getStringCellValue(evaluator, row.getCell((short) 0)).isEmpty()) { +// isSelectType = false; +// } else if (isSelectType || type.compareTo(getStringCellValue(evaluator, row.getCell((short) 0))) == 0) { +// isSelectType = true; +// if (row.getCell((short) 2) != null) { +// String value = getStringCellValue(evaluator, row.getCell((short) 1)); +// lines_msg.add(value); +// } +// } else { +// continue; +// } +// +// } +// // insertRow(sheet,4,1); +// return lines_msg; +// } +// +// /** +// * 读取EXCEL表 +// * +// * @param File excel_file +// * @return List> 返回的信息 +// * @throws IOException +// * @throws FileNotFoundException +// */ +// public static DefaultMutableTreeNode readExcelNodeByEntrustment(File excel_file, String type) +// throws FileNotFoundException, IOException { +// DefaultMutableTreeNode node = new DefaultMutableTreeNode("应用领域"); +// if (excel_file == null || !excel_file.exists()) { +// return node; +// } +// // 用来返回的所有的行的信息 +// //List lines_msg = new ArrayList(); +// XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); +// XSSFSheet sheet = workBook.getSheetAt(0); +// XSSFRow title_row = sheet.getRow(0); +// +// // 得到列的数目 +// int col_count = title_row.getPhysicalNumberOfCells(); +// // 得到行的数目 +// int row_count = sheet.getLastRowNum(); +// boolean isSelectType = false;// 判断是否找到指定的类型 +// String no1 = ""; +// String no2 = ""; +// DefaultMutableTreeNode no1Node = null; +// DefaultMutableTreeNode no2Node = null; +// for (int j = 0; j < row_count + 1; j++) { +// +// // 用来返回单行的信息 +// XSSFRow row = sheet.getRow(j); +// String sss=getStringCellValue(evaluator, row.getCell((short) 0)); +// if (row == null) { +// isSelectType = false; +// continue; +// } +// // System.out.println(getStringCellValue(evaluator, row.getCell((short) 0))); +// if (getStringCellValue(evaluator, row.getCell((short) 0)) == null +// || getStringCellValue(evaluator, row.getCell((short) 0)).isEmpty()) { +// isSelectType = false; +// } else if (isSelectType || type.compareTo(sss) == 0) { +// isSelectType = true; +// if (row.getCell((short) 3) != null) { +// String value1 = getStringCellValue(evaluator, row.getCell((short) 1)); +// String value2 = getStringCellValue(evaluator, row.getCell((short) 2)); +// //String value = getStringCellValue(evaluator, row.getCell((short) 3)); +// String value4 = getStringCellValue(evaluator, row.getCell((short) 3)); +// if(!value1.isEmpty() && value1.compareTo(no1) != 0) +// { +// no1Node = new DefaultMutableTreeNode(value1); +// node.add(no1Node); +// no2Node = new DefaultMutableTreeNode(value2); +// no1Node.add(no2Node); +// } +// else if(!value2.isEmpty() && value2.compareTo(no2) != 0) { +// no2Node = new DefaultMutableTreeNode(value2); +// no1Node.add(no2Node); +// } +// +// no2Node.add(new DefaultMutableTreeNode(value4)); +// +// //lines_msg.add(value); +// } +// } else { +// continue; +// } +// +// } +// // insertRow(sheet,4,1); +// return node; +// } +// +// /** +// * 输出本部控制计划到EXCEL表格中 +// * +// * @param controlPlanBean 控制计划信息 +// * @param input 模版文件流 +// * @param outputFilePath 需要输出的全路径 +// * @throws IOException +// */ +// public static int writeEntrustmentFormToExcel(EntrustmentFormBean controlPlanBean, File file, String outFilePath) +// throws IOException { +// InputStream input = new FileInputStream(file); +// FileOutputStream output = new FileOutputStream(new File(outFilePath)); // +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// map.clear(); +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// XSSFRow row = sheet.getRow(4); +// setCellValue(row, 2, controlPlanBean.getP1()); +// setCellValue(row, 7, controlPlanBean.getItemId()); +// XSSFRow row1 = sheet.getRow(5); +// setCellValue(row1, 2, controlPlanBean.getP3()); +// setCellValue(row1, 7, controlPlanBean.getP4()); +// XSSFRow row2 = sheet.getRow(6); +// setCellValue(row2, 2, controlPlanBean.getP5()); +// setCellValue(row2, 7, controlPlanBean.getP6()); +// XSSFRow row3 = sheet.getRow(7); +// setCellValue(row3, 2, controlPlanBean.getP7()); +// setCellValue(row3, 7, controlPlanBean.getP8()); +// XSSFRow row4 = sheet.getRow(8); +// setCellValue(row4, 2, controlPlanBean.getP9()); +// setCellValue(row4, 7, controlPlanBean.getP10()); +// XSSFRow row5 = sheet.getRow(10); +// setCellValue(row5, 2, controlPlanBean.getP11()); +// XSSFRow row6 = sheet.getRow(11); +// setCellValue(row6, 2, controlPlanBean.getP12()); +// setCellValue(row6, 7, controlPlanBean.getP15()); +// XSSFRow row7 = sheet.getRow(12); +// setCellValue(row7, 1, controlPlanBean.getP13()); +// setCellValue(row7, 4, controlPlanBean.getP14()); +// setCellValue(row7, 7, controlPlanBean.getP16()); +// XSSFRow row8 = sheet.getRow(14); +// setCellValue(row8, 2, controlPlanBean.getP17()); +// setCellValue(row8, 7, controlPlanBean.getP18()); +// XSSFRow row9 = sheet.getRow(15); +// setCellValue(row9, 2, controlPlanBean.getP19()); +// setCellValue(row9, 7, controlPlanBean.getP20()); +// XSSFRow row10 = sheet.getRow(16); +// setCellValue(row10, 2, controlPlanBean.getP21()); +// setCellValue(row10, 7, controlPlanBean.getP22()); +// XSSFRow row11 = sheet.getRow(17); +// setCellValue(row11, 2, controlPlanBean.getP23()); +// setCellValue(row11, 7, controlPlanBean.getP24()); +// XSSFRow row12 = sheet.getRow(18); +// setCellValue(row12, 2, controlPlanBean.getP25()); +// XSSFRow row13 = sheet.getRow(20); +// setCellValue(row13, 2, controlPlanBean.getP26()); +// setCellValue(row13, 7, controlPlanBean.getP27()); +// XSSFRow row14 = sheet.getRow(21); +// setCellValue(row14, 1, controlPlanBean.getP28()); +// setCellValue(row14, 4, controlPlanBean.getP29()); +// setCellValue(row14, 7, controlPlanBean.getP30()); +// XSSFRow row15 = sheet.getRow(22); +// setCellValue(row15, 2, controlPlanBean.getP31()); +// setCellValue(row15, 7, controlPlanBean.getP32()); +// XSSFRow row16 = sheet.getRow(24); +// setCellValue(row16, 0, controlPlanBean.getP33()); +// XSSFRow row17 = sheet.getRow(26); +// setCellValue(row17, 0, controlPlanBean.getP66()); +// } else { +// return -1; +// } +// +// wb.write(output); +// output.close(); +// input.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// return 0; +// } +// +// /** +// * 竖版作业工艺卡 +// * +// * @param controlPlanBean 控制计划信息 +// * @param input 模版文件流 +// * @param outputFilePath 需要输出的全路径 +// * @throws IOException +// */ +// public static int writeJobProcessFormVerticalToExcel(JobProcessFormBean controlPlanBean, File file, +// String outFilePath,TCComponentTcFile picFile,String outFilePathp) throws IOException { +// //导出图 +// if(outFilePathp!=null) { +// //ExcelUtil.InsertPicture(file,6,10,outFilePath,outFilePathp); +// //第6行到底15行的总行高:5.67cm +// //第10列到17列的总列宽:9.52cm +// ExcelUtil.InsertTitlePicture(file,outFilePath,outFilePathp,new int[] {7,8,9,10,11,12,13,14,15,16}, +// new int[] {10,11,12,13,14,15,16,17},true,3.1,9.52,7,10);//最后两个参数是插入的位置 +// } +// +// File file1=new File(outFilePath); +// InputStream input = new FileInputStream(file1); +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// +// +// wb.removeSheetAt(wb.getActiveSheetIndex());//消除水印 +// map.clear(); +// int startRow = 6; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// XSSFRow titleRow = sheet.getRow(0); +// setCellValue(titleRow, 3, controlPlanBean.getGsmc()); +// titleRow = sheet.getRow(1); +// setCellValue(titleRow, 9, controlPlanBean.getLjdh()); +// titleRow = sheet.getRow(2); +// setCellValue(titleRow, 9, controlPlanBean.getSbmc()); +// titleRow = sheet.getRow(3); +// setCellValue(titleRow, 9, controlPlanBean.getSbxh()); +// //setCellValue(titleRow, 13, " 下工序:"+controlPlanBean.getXdgx()); +// +// List> toolingDetailData = controlPlanBean.getToolingDetailData(); +// List> machiningParameterData = controlPlanBean.getMachiningParameterData(); +// List> controlRequirementData = controlPlanBean.getControlRequirementData(); +// for (int i = 0; i < toolingDetailData.size(); i++) { +// +// XSSFRow row = null; +// Boolean isCreat = false; +// if (i == toolingDetailData.size() - 1) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } else if (i > 9) {//i从0开始,所以i=10是最后一行 +// row = createRow(sheet, i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // XSSFRow row = sheet.getRow(i + startRow); +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 0; j < 16; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// // 合并单元格 +// combine(sheet, new int[] { i + startRow }, new int[] { 3, 4 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 5, 6 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 7, 8 }); +// } +// +// List toolingDetailList = toolingDetailData.get(i); +// // XSSFRow row = sheet.getRow(i + startRow); +// XSSFCell cell1 = row.getCell(2); +// cell1.setCellValue(toolingDetailList.get(1)); +// XSSFCell cell2 = row.getCell(3); +// cell2.setCellValue(toolingDetailList.get(2)); +// XSSFCell cell3 = row.getCell(5); +// cell3.setCellValue(toolingDetailList.get(3)); +// XSSFCell cell4 = row.getCell(7); +// cell4.setCellValue(toolingDetailList.get(4)); +// } +// startRow = 19; +// if (toolingDetailData.size() > 11) { +// // 拆分合并单元格 +// unMerge(sheet, "A4"); +// // 合并单元格 +// int[] rows = new int[2 + toolingDetailData.size()]; +// rows[0] = 3; +// rows[1] = 4; +// for (int i = 0; i < toolingDetailData.size(); i++) { +// rows[i + 2] = i + 5; +// } +// +// combine(sheet, rows, new int[] { 0, 1 }); +// startRow = 19 + toolingDetailData.size() - 11; +// } +// +// int rows = 10; +// if (machiningParameterData.size() > 20) { +// rows = (int) Math.ceil(machiningParameterData.size() / 2); +// for (int i = 9; i < rows - 1; i++) { +// XSSFRow row = null; +// Boolean isCreat = false; +// if (i == toolingDetailData.size() - 1) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } else if (i > 8) { +// row = createRow(sheet, i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // XSSFRow row = sheet.getRow(i + startRow); +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 0; j < 16; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// // 合并单元格 +// combine(sheet, new int[] { i + startRow }, new int[] { 3, 4 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 6, 7, 8 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 10, 11 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 13, 14, 15,16 }); +// } +// } +// } +// +// if (machiningParameterData.size() > 10) { +// +// for (int i = 0; i < rows; i++) { +// List machiningParameterList = machiningParameterData.get(i); +// XSSFRow row = sheet.getRow(i + startRow); +// XSSFCell cell1 = row.getCell(2); +// cell1.setCellValue(machiningParameterList.get(1)); +// XSSFCell cell2 = row.getCell(3); +// cell2.setCellValue(machiningParameterList.get(2)); +// XSSFCell cell3 = row.getCell(5); +// cell3.setCellValue(machiningParameterList.get(3)); +// XSSFCell cell4 = row.getCell(6); +// cell4.setCellValue(machiningParameterList.get(4)); +// } +// for (int i = rows; i < machiningParameterData.size(); i++) { +// List machiningParameterList = machiningParameterData.get(i); +// XSSFRow row = sheet.getRow(i - rows + startRow); +// XSSFCell cell1 = row.getCell(9); +// cell1.setCellValue(machiningParameterList.get(1)); +// XSSFCell cell2 = row.getCell(10); +// cell2.setCellValue(machiningParameterList.get(2)); +// XSSFCell cell3 = row.getCell(12); +// cell3.setCellValue(machiningParameterList.get(3)); +// XSSFCell cell4 = row.getCell(13); +// cell4.setCellValue(machiningParameterList.get(4)); +// } +// } else { +// for (int i = 0; i < machiningParameterData.size(); i++) { +// List machiningParameterList = machiningParameterData.get(i); +// XSSFRow row = sheet.getRow(i + startRow); +// XSSFCell cell1 = row.getCell(2); +// cell1.setCellValue(machiningParameterList.get(1)); +// XSSFCell cell2 = row.getCell(3); +// cell2.setCellValue(machiningParameterList.get(2)); +// XSSFCell cell3 = row.getCell(5); +// cell3.setCellValue(machiningParameterList.get(3)); +// XSSFCell cell4 = row.getCell(6); +// cell4.setCellValue(machiningParameterList.get(4)); +// } +// } +// if (rows > 10) { +// // 拆分合并单元格 +// unMerge(sheet, "A" + startRow); +// // 合并单元格 +// int[] rowInders = new int[1 + rows]; +// rowInders[0] = startRow - 1; +// for (int i = 0; i < rows; i++) { +// rowInders[i + 1] = i + startRow; +// } +// +// combine(sheet, rowInders, new int[] { 0, 1 }); +// } +// if (toolingDetailData.size() > 11) { +// startRow = 33 + toolingDetailData.size() - 11; +// } else { +// startRow = 33; +// } +// if (rows > 10) { +// startRow = startRow + rows - 10; +// } +// for (int i = 0; i < controlRequirementData.size(); i++) { +// +// XSSFRow row = null; +// Boolean isCreat = false; +// if (i == controlRequirementData.size() - 1) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } else if (i > 7) { +// row = createRow(sheet, i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // XSSFRow row = sheet.getRow(i + startRow); +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 0; j < 17; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// // 合并单元格 +// combine(sheet, new int[] { i + startRow }, new int[] { 3, 4 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 6, 7 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 10, 11 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 13, 14, 15 }); +// } +// +// List controlRequirementList = controlRequirementData.get(i); +// // XSSFRow row = sheet.getRow(i + startRow); +// XSSFCell cell1 = row.getCell(2); +// cell1.setCellValue(controlRequirementList.get(1)); +// XSSFCell cell2 = row.getCell(3); +// cell2.setCellValue(controlRequirementList.get(2)); +// XSSFCell cell3 = row.getCell(5); +// cell3.setCellValue(controlRequirementList.get(3)); +// XSSFCell cell4 = row.getCell(6); +// cell4.setCellValue(controlRequirementList.get(4)); +// XSSFCell cell5 = row.getCell(8); +// cell5.setCellValue(controlRequirementList.get(5)); +// XSSFCell cell6 = row.getCell(9); +// cell6.setCellValue(controlRequirementList.get(6)); +// XSSFCell cell7 = row.getCell(10); +// cell7.setCellValue(controlRequirementList.get(7)); +// XSSFCell cell8 = row.getCell(12); +// cell8.setCellValue(controlRequirementList.get(8)); +// XSSFCell cell9 = row.getCell(13); +// cell9.setCellValue(controlRequirementList.get(9)); +// XSSFCell cel20 = row.getCell(16); +// cel20.setCellValue(controlRequirementList.get(10)); +// } +// +// if (controlRequirementData.size() > 9) { +// // 拆分合并单元格 +// unMerge(sheet, "A" + (startRow - 2)); +// // 合并单元格 +// int[] rowInders = new int[3 + controlRequirementData.size()]; +// rowInders[0] = startRow - 3; +// rowInders[1] = startRow - 2; +// rowInders[2] = startRow - 1; +// for (int i = 0; i < controlRequirementData.size(); i++) { +// rowInders[i + 3] = i + startRow; +// } +// +// combine(sheet, rowInders, new int[] { 0, 1 }); +// } +// +// } else { +// return -1; +// } +// FileOutputStream output = new FileOutputStream(new File(outFilePath)); // +// wb.write(output); +// output.close(); +// input.close(); +// +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// return 0; +// } +// +// /** +// * 横版作业工艺卡 +// * +// * @param controlPlanBean 控制计划信息 +// * @param input 模版文件流 +// * @param outputFilePath 需要输出的全路径 +// * @throws IOException +// */ +// public static int writeJobProcessFormAcrossToExcel(JobProcessFormBean controlPlanBean, File file, +// String outFilePath,TCComponentTcFile picFile,String outFilePathp) throws IOException{ +// //插入图片 +// //导出图 +// if(outFilePathp!=null) { +// //第17行到底28行的总行高:3.96cm +// //第18列到24列的总列宽:8.9cm +// int i=0; +// if(controlPlanBean.getToolingDetailData().size()>9) { +// i=controlPlanBean.getToolingDetailData().size()-9; +// } +// if(controlPlanBean.getMachiningParameterData().size()-9>i) { +// i=controlPlanBean.getMachiningParameterData().size()-9; +// } +// ExcelUtil.InsertTitlePicture(file,outFilePath,outFilePathp,new int[] {17,18,19,20,21,22,23,24,25,26,27,28}, +// new int[] {18,19,20,21,22,23,24},true,3.96,8.9,17+i,18); +// } +// +// File file1=new File(outFilePath); +// InputStream input = new FileInputStream(file1); +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// wb.removeSheetAt(wb.getActiveSheetIndex()); +// map.clear(); +// int startRow = 5; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// XSSFRow titleRow = sheet.getRow(0); +// setCellValue(titleRow, 2, controlPlanBean.getGsmc()); +// setCellValue(titleRow, 17, controlPlanBean.getSbmc()); +// titleRow = sheet.getRow(1); +// setCellValue(titleRow, 13, controlPlanBean.getLjdh()); +// setCellValue(titleRow, 17, controlPlanBean.getSbxh()); +// titleRow = sheet.getRow(2); +// setCellValue(titleRow, 13, controlPlanBean.getBgx()); +// +// +// List> toolingDetailData = controlPlanBean.getToolingDetailData(); +// List> machiningParameterData = controlPlanBean.getMachiningParameterData(); +// List> controlRequirementData = controlPlanBean.getControlRequirementData(); +// for (int i = 0; i < toolingDetailData.size(); i++) { +// +// XSSFRow row = null; +// Boolean isCreat = false; +// if (i == toolingDetailData.size() - 1) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } else if (i > 7) { +// row = createRow(sheet, i + startRow); +// +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // XSSFRow row = sheet.getRow(i + startRow); +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 0; j < 24; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// // 合并单元格 +// combine(sheet, new int[] { i + startRow }, new int[] { 3, 4 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 5, 6 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 7, 8, 9, 10 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 16, 17 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 19, 20 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 22, 23 }); +// } +// +// List toolingDetailList = toolingDetailData.get(i); +// XSSFCell cell1 = row.getCell(2); +// cell1.setCellValue(toolingDetailList.get(1)); +// XSSFCell cell2 = row.getCell(3); +// cell2.setCellValue(toolingDetailList.get(2)); +// XSSFCell cell3 = row.getCell(5); +// cell3.setCellValue(toolingDetailList.get(3)); +// XSSFCell cell4 = row.getCell(7); +// cell4.setCellValue(toolingDetailList.get(4)); +// } +// startRow = 4; +//// if (toolingDetailData.size() > 11) { +//// // 拆分合并单元格 +//// unMerge(sheet, "A4"); +//// // 合并单元格 +//// int[] rows = new int[2 + toolingDetailData.size()]; +//// rows[0] = 3; +//// rows[1] = 4; +//// for (int i = 0; i < toolingDetailData.size(); i++) { +//// rows[i + 2] = i + 5; +//// } +//// +//// combine(sheet, rows, new int[] { 0, 1 }); +//// startRow = 18 + toolingDetailData.size() - 10; +//// } +// int rows = 10; +// if (toolingDetailData.size() > 9) { +// rows = toolingDetailData.size() + 1; +// } +// if (machiningParameterData.size() > 2 * rows) { +// rows = (int) Math.ceil(machiningParameterData.size() / 2); +// for (int i = 10; i < rows - 1; i++) { +// XSSFRow row = null; +// Boolean isCreat = false; +// if (i == toolingDetailData.size() - 1) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } else if (i > 8) { +// row = createRow(sheet, i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // XSSFRow row = sheet.getRow(i + startRow); +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 0; j < 24; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// // 合并单元格 +// combine(sheet, new int[] { i + startRow }, new int[] { 3, 4 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 5, 6 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 7, 8, 9, 10 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 16, 17 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 19, 20 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 22, 23 }); +// } +// } +// } +// +// if (machiningParameterData.size() > rows) { +// +// for (int i = 0; i < rows; i++) { +// List machiningParameterList = machiningParameterData.get(i); +// XSSFRow row = sheet.getRow(i + startRow); +// XSSFCell cell1 = row.getCell(13); +// cell1.setCellValue(machiningParameterList.get(1)); +// XSSFCell cell2 = row.getCell(14); +// cell2.setCellValue(machiningParameterList.get(2)); +// XSSFCell cell3 = row.getCell(15); +// cell3.setCellValue(machiningParameterList.get(3)); +// XSSFCell cell4 = row.getCell(16); +// cell4.setCellValue(machiningParameterList.get(4)); +// } +// for (int i = rows; i < machiningParameterData.size(); i++) { +// List machiningParameterList = machiningParameterData.get(i); +// XSSFRow row = sheet.getRow(i - rows + startRow); +// XSSFCell cell1 = row.getCell(17); +// cell1.setCellValue(machiningParameterList.get(1)); +// XSSFCell cell2 = row.getCell(18); +// cell2.setCellValue(machiningParameterList.get(2)); +// XSSFCell cell3 = row.getCell(20); +// cell3.setCellValue(machiningParameterList.get(3)); +// XSSFCell cell4 = row.getCell(21); +// cell4.setCellValue(machiningParameterList.get(4)); +// } +// } else { +// for (int i = 0; i < machiningParameterData.size(); i++) { +// List machiningParameterList = machiningParameterData.get(i); +// XSSFRow row = sheet.getRow(i + startRow); +// XSSFCell cell1 = row.getCell(13); +// cell1.setCellValue(machiningParameterList.get(1)); +// XSSFCell cell2 = row.getCell(14); +// cell2.setCellValue(machiningParameterList.get(2)); +// XSSFCell cell3 = row.getCell(15); +// cell3.setCellValue(machiningParameterList.get(3)); +// XSSFCell cell4 = row.getCell(16); +// cell4.setCellValue(machiningParameterList.get(4)); +// } +// } +// // startRow = 18; +// // 合并单元格 +// if (rows > 10) { +// // 拆分合并单元格 +// unMerge(sheet, "A4"); +// // 拆分合并单元格 +// unMerge(sheet, "L1"); +// // 拆分合并单元格 +// unMerge(sheet, "M4"); +// // 合并单元格 +// int[] rowIndexs = new int[2 + rows - 1]; +// rowIndexs[0] = 3; +// rowIndexs[1] = 4; +// for (int i = 0; i < rows - 1; i++) { +// rowIndexs[i + 2] = i + 5; +// } +// // 合并单元格 +// int[] rowIndexs2 = new int[startRow + rows]; +//// rowIndexs2[0] = 3; +//// rowIndexs2[1] = 4; +// for (int i = 0; i < startRow + rows; i++) { +// rowIndexs2[i] = i; +// } +// // 合并单元格 +// int[] rowIndexs3 = new int[1 + rows]; +// rowIndexs3[0] = 3; +// for (int i = 0; i < rows; i++) { +// rowIndexs3[i + 1] = i + 4; +// } +// +// combine(sheet, rowIndexs, new int[] { 0, 1 }); +// combine(sheet, rowIndexs2, new int[] { 11 }); +// combine(sheet, rowIndexs3, new int[] { 12 }); +// startRow = 18 + rows - 10; +// } +// else +// { +// startRow = 18; +// } +// for (int i = 0; i < controlRequirementData.size(); i++) { +// +// XSSFRow row = null; +// Boolean isCreat = false; +// if (i == controlRequirementData.size() - 1) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } else if (i > 9) { +// row = createRow(sheet, i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // XSSFRow row = sheet.getRow(i + startRow); +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 0; j < 24; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// // 合并单元格 +// combine(sheet, new int[] { i + startRow }, new int[] { 3, 4 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 6, 7 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 10, 11 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 13, 14}); +// combine(sheet, new int[] { i + startRow }, new int[] { 15, 16}); +// } +// +// List controlRequirementList = controlRequirementData.get(i); +// XSSFCell cell1 = row.getCell(2); +// cell1.setCellValue(controlRequirementList.get(1)); +// XSSFCell cell2 = row.getCell(3); +// cell2.setCellValue(controlRequirementList.get(2)); +// XSSFCell cell3 = row.getCell(5); +// cell3.setCellValue(controlRequirementList.get(3)); +// XSSFCell cell4 = row.getCell(6); +// cell4.setCellValue(controlRequirementList.get(4)); +// XSSFCell cell5 = row.getCell(8); +// cell5.setCellValue(controlRequirementList.get(5)); +// XSSFCell cell6 = row.getCell(9); +// cell6.setCellValue(controlRequirementList.get(6)); +// XSSFCell cell7 = row.getCell(10); +// cell7.setCellValue(controlRequirementList.get(7)); +// XSSFCell cell8 = row.getCell(12); +// cell8.setCellValue(controlRequirementList.get(8)); +// XSSFCell cell9 = row.getCell(13); +// cell9.setCellValue(controlRequirementList.get(9)); +// XSSFCell cell10 = row.getCell(15); +// cell10.setCellValue(controlRequirementList.get(10)); +// } +// +// //++++++ +// // 合并单元格 +// if (controlRequirementData.size() > 11) { +// // 拆分合并单元格 +// unMerge(sheet, "A" + (startRow - 2)); +// // 合并单元格 +// int[] rowIndexs = new int[3 + controlRequirementData.size()]; +// rowIndexs[0] = startRow - 3; +// rowIndexs[1] = startRow - 2; +// rowIndexs[1] = startRow - 1; +// for (int i = 0; i < controlRequirementData.size(); i++) { +// rowIndexs[i + 3] = i + startRow; +// } +// +// combine(sheet, rowIndexs, new int[] { 0, 1 }); +// } +// +// } else { +// return -1; +// } +//// //导出图 +//// if(outFilePathp!=null) { +//// insertPicture(wb, sheet, new ImageIcon(outFilePathp), "工序示意图",7,8); +//// new File(outFilePathp).delete(); +//// } +// FileOutputStream output = new FileOutputStream(new File(outFilePath)); // +// wb.write(output); +// output.close(); +// input.close(); +// +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// return 0; +// } +// +// /** +// * 装配工艺卡 +// * +// * @param controlPlanBean 控制计划信息 +// * @param input 模版文件流 +// * @param outputFilePath 需要输出的全路径 +// * @throws IOException +// */ +// public static int writeAssembleProcessFormToExcel(JobProcessFormBean controlPlanBean, File file, String outFilePath +// ,TCComponentTcFile picFile,String outFilePathp) +// throws IOException { +// //导出图 +// if(outFilePathp!=null) { +// //第5行到底16行的总行高:0.49*12=5.88cm +// //第1列到8列的总列宽:14.56cm +// ExcelUtil.InsertTitlePicture(file,outFilePath,outFilePathp,new int[] {6,7,8,9,10,11,12,13,14,15,16,17}, +// new int[] {1,2,3,4,5,6,7,8},true,5.88,14.56,6,1); +// } +// File file1=new File(outFilePath); +// InputStream input = new FileInputStream(file1); +// +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// wb.removeSheetAt(wb.getActiveSheetIndex()); +// map.clear(); +// int startRow = 7; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// XSSFRow titleRow = sheet.getRow(0); +// setCellValue(titleRow, 3, controlPlanBean.getGsmc()); +// titleRow = sheet.getRow(1); +// setCellValue(titleRow, 9, controlPlanBean.getLjdh()); +// titleRow = sheet.getRow(2); +// setCellValue(titleRow, 9, controlPlanBean.getSbmc()); +// titleRow = sheet.getRow(3); +// setCellValue(titleRow, 9, controlPlanBean.getSbxh()); +// //setCellValue(titleRow, 13, " 下工序:"+controlPlanBean.getXdgx()); +// +// List> toolingDetailData = controlPlanBean.getToolingDetailData(); +// List> machiningParameterData = controlPlanBean.getMachiningParameterData(); +// List> controlRequirementData = controlPlanBean.getControlRequirementData(); +// for (int i = 0; i < toolingDetailData.size(); i++) { +// +// XSSFRow row = null; +// Boolean isCreat = false; +// if (i == toolingDetailData.size() - 1) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } else if (i > 8) { +// row = createRow(sheet, i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // XSSFRow row = sheet.getRow(i + startRow); +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 8; j < 17; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// // 合并单元格 +// combine(sheet, new int[] { i + startRow }, new int[] { 9, 10 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 11, 12 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 13, 14, 15 }); +// } +// +// List toolingDetailList = toolingDetailData.get(i); +//// XSSFRow row = sheet.getRow(i + startRow); +// XSSFCell cell1 = row.getCell(8); +// cell1.setCellValue(toolingDetailList.get(1)); +// XSSFCell cell2 = row.getCell(9); +// cell2.setCellValue(toolingDetailList.get(2)); +// XSSFCell cell3 = row.getCell(11); +// cell3.setCellValue(toolingDetailList.get(3)); +// XSSFCell cell4 = row.getCell(13); +// cell4.setCellValue(toolingDetailList.get(4)); +// XSSFCell cell5 = row.getCell(16); +// cell5.setCellValue(toolingDetailList.get(5)); +// } +// startRow = 19; +// if (toolingDetailData.size() > 10) { +// // 拆分合并单元格 +// unMerge(sheet, "A5"); +// // 合并单元格 +// int[] rows = new int[2 + toolingDetailData.size()]; +// rows[0] = 4; +// rows[1] = 5; +// for (int i = 0; i < toolingDetailData.size(); i++) { +// rows[i + 2] = i + 6; +// } +// +// combine(sheet, rows, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }); +// startRow = 19 + toolingDetailData.size() - 10; +// } +// for (int i = 0; i < machiningParameterData.size(); i++) { +// +// XSSFRow row = null; +// Boolean isCreat = false; +// if (i == machiningParameterData.size() - 1) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } else if (i > 8) { +// row = createRow(sheet, i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // XSSFRow row = sheet.getRow(i + startRow); +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 0; j < 17; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// // 合并单元格 +// combine(sheet, new int[] { i + startRow }, new int[] { 0, 1 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 2, 3, 4, 5, 6, 7 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 8, 9, 10 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 11, 12, 13 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 14, 15, 16 }); +// } +// +// List machiningParameterList = machiningParameterData.get(i); +// XSSFCell cell1 = row.getCell(0); +// cell1.setCellValue(machiningParameterList.get(1)); +// XSSFCell cell2 = row.getCell(2); +// cell2.setCellValue(machiningParameterList.get(2)); +// XSSFCell cell3 = row.getCell(8); +// cell3.setCellValue(machiningParameterList.get(3)); +// XSSFCell cell4 = row.getCell(11); +// cell4.setCellValue(machiningParameterList.get(4)); +// XSSFCell cell5 = row.getCell(14); +// cell5.setCellValue(machiningParameterList.get(5)); +// } +// startRow = 33; +// if (toolingDetailData.size() > 10) { +// startRow = 33 + toolingDetailData.size() - 10; +// } +// if (machiningParameterData.size() > 10) { +// startRow = startRow + machiningParameterData.size() - 10; +// } +// for (int i = 0; i < controlRequirementData.size(); i++) { +// +// XSSFRow row = null; +// Boolean isCreat = false; +// if (i == controlRequirementData.size() - 1) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } else if (i > 7) { +// row = createRow(sheet, i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // XSSFRow row = sheet.getRow(i + startRow); +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 2; j < 17; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// // 合并单元格 +// combine(sheet, new int[] { i + startRow }, new int[] { 3, 4 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 6, 7 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 10, 11 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 13, 14, 15, 16 }); +// } +// +// List controlRequirementList = controlRequirementData.get(i); +// XSSFCell cell1 = row.getCell(2); +// cell1.setCellValue(controlRequirementList.get(1)); +// XSSFCell cell2 = row.getCell(3); +// cell2.setCellValue(controlRequirementList.get(2)); +// XSSFCell cell3 = row.getCell(5); +// cell3.setCellValue(controlRequirementList.get(3)); +// XSSFCell cell4 = row.getCell(6); +// cell4.setCellValue(controlRequirementList.get(4)); +// XSSFCell cell5 = row.getCell(8); +// cell5.setCellValue(controlRequirementList.get(5)); +// XSSFCell cell6 = row.getCell(9); +// cell6.setCellValue(controlRequirementList.get(6)); +// XSSFCell cell7 = row.getCell(10); +// cell7.setCellValue(controlRequirementList.get(7)); +// XSSFCell cell8 = row.getCell(12); +// cell8.setCellValue(controlRequirementList.get(8)); +// XSSFCell cell9 = row.getCell(13); +// cell9.setCellValue(controlRequirementList.get(9)); +// } +// +// if (controlRequirementData.size() > 9) { +// // 拆分合并单元格 +// unMerge(sheet, "A" + startRow); +// // 合并单元格 +// int[] rows = new int[3 + controlRequirementData.size()]; +// rows[0] = startRow - 3; +// rows[1] = startRow - 2; +// rows[2] = startRow - 1; +// for (int i = 0; i < controlRequirementData.size(); i++) { +// rows[i + 3] = i + startRow; +// } +// +// combine(sheet, rows, new int[] { 0, 1 }); +// } +// +// } else { +// return -1; +// } +// +//// //导出图 +//// if(outFilePathp!=null) { +//// insertPicture(wb, sheet, new ImageIcon(outFilePathp), "工序示意图",8,8); +//// new File(outFilePathp).delete(); +//// } +// FileOutputStream output = new FileOutputStream(new File(outFilePath)); // +// wb.write(output); +// output.close(); +// input.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// return 0; +// } +// +// /** +// * 检验基准书 +// * +// * @param controlPlanBean 控制计划信息 +// * @param input 模版文件流 +// * @param outputFilePath 需要输出的全路径 +// * @throws IOException +// */ +// public static int writeOperationReferenceBookToExcel(JobProcessFormBean controlPlanBean, File file, +// String outFilePath,TCComponentTcFile picFile,String outFilePathp) throws IOException { +// //导出图 +// if(outFilePathp!=null) { +// //第5行到底11行的总行高:6.3cm +// //第7列到14列的总列宽:15.31cm +// ExcelUtil.InsertTitlePicture(file,outFilePath,outFilePathp,new int[] {5,6,7,8,9,10,11}, +// new int[] {7,8,9,10,11,12,13,14},true,6.3,15.31,5,7); +// } +// File file1=new File(outFilePath); +// InputStream input = new FileInputStream(file1); +// +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// wb.removeSheetAt(wb.getActiveSheetIndex()); +// map.clear(); +// int startRow = 14; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// XSSFRow titleRow = sheet.getRow(0); +// setCellValue(titleRow, 3, controlPlanBean.getGsmc()); +// titleRow = sheet.getRow(1); +// setCellValue(titleRow, 10, controlPlanBean.getSbxh()); +// titleRow = sheet.getRow(2); +// setCellValue(titleRow, 10, controlPlanBean.getLjdh()); +// +// List> controlRequirementData = controlPlanBean.getControlRequirementData(); +// for (int i = 0; i < controlRequirementData.size(); i++) { +// List controlRequirementList = controlRequirementData.get(i); +// +// XSSFRow row = null; +// Boolean isCreat = false; +// if (i == controlRequirementData.size() - 1) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } else if ((i + startRow) > sheet.getLastRowNum() - 2) { +// row = createRow(sheet, i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // XSSFRow row = sheet.getRow(i + startRow); +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 0; j < 14; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// // 合并单元格 +// combine(sheet, new int[] { i + startRow }, new int[] { 0, 1 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 3, 4 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 6, 7 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 8, 9 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 12, 13 }); +// } +// +// XSSFCell cell1 = row.getCell(0); +// cell1.setCellValue(controlRequirementList.get(1)); +// XSSFCell cell2 = row.getCell(2); +// cell2.setCellValue(controlRequirementList.get(2)); +// XSSFCell cell3 = row.getCell(3); +// cell3.setCellValue(controlRequirementList.get(3)); +// XSSFCell cell4 = row.getCell(5); +// cell4.setCellValue(controlRequirementList.get(4)); +// XSSFCell cell5 = row.getCell(6); +// cell5.setCellValue(controlRequirementList.get(5)); +// XSSFCell cell6 = row.getCell(8); +// cell6.setCellValue(controlRequirementList.get(6)); +// XSSFCell cell7 = row.getCell(10); +// cell7.setCellValue(controlRequirementList.get(7)); +// XSSFCell cell8 = row.getCell(11); +// cell8.setCellValue(controlRequirementList.get(8)); +// XSSFCell cell9 = row.getCell(12); +// cell9.setCellValue(controlRequirementList.get(9)); +// } +// +// } else { +// return -1; +// } +// +//// //导出图 +//// if(outFilePathp!=null) { +//// insertPicture(wb, sheet, new ImageIcon(outFilePathp), "工序示意图",8,7); +//// new File(outFilePathp).delete(); +//// } +// FileOutputStream output = new FileOutputStream(new File(outFilePath)); // +// wb.write(output); +// output.close(); +// input.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// return 0; +// } +// +// /** +// * 找到需要插入的行数,并新建一个POI的row对象 +// * +// * @param sheet +// * @param rowIndex +// * @return +// */ +// private static XSSFRow createRow(XSSFSheet sheet, Integer rowIndex) { +// XSSFRow row = null; +// if (sheet.getRow(rowIndex) != null) { +// int lastRowNo = sheet.getLastRowNum(); +// sheet.shiftRows(rowIndex, lastRowNo, 1); +// } +// row = sheet.createRow(rowIndex); +// return row; +// } +// +// private static void unMerge(XSSFSheet sheet, String cellName) { +// // 从第C1开始,拆分单元格 +// CellReference ref = new CellReference(cellName); +// // 遍历sheet中的所有的合并区域 +// for (int i = sheet.getNumMergedRegions() - 1; i >= 0; i--) { +// String value = ""; +// CellRangeAddress region = sheet.getMergedRegion(i); +// Row firstRow = sheet.getRow(region.getFirstRow()); +// Cell firstCellOfFirstRow = firstRow.getCell(region.getFirstColumn()); +// // 如果第一个单元格的是字符串 +// if (firstCellOfFirstRow.getCellType() == Cell.CELL_TYPE_STRING) { +// value = firstCellOfFirstRow.getStringCellValue(); +// } +// // 判断到C1才进行拆分单元格 +// if (region.getFirstRow() == ref.getRow() && region.getFirstColumn() == ref.getCol()) { +// sheet.removeMergedRegion(i); +// } +// // 设置第一行的值为,拆分后的每一行的值 +// for (Row row : sheet) { +// for (Cell cell : row) { +// if (region.isInRange(cell.getRowIndex(), cell.getColumnIndex())) { +// cell.setCellType(Cell.CELL_TYPE_STRING); +// cell.setCellValue(value); +// } +// } +// } +// } +// } +// +///** +// * 导出包装方案 +// * @throws IOException +// * +// * +// */ +// public static int writePackagingSchemeToExcel(List mainValueData,List> TableDatas +// ,File file,String outFilePath) throws IOException { +// InputStream input = new FileInputStream(file); +// FileOutputStream output = new FileOutputStream(new File(outFilePath)); // +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// map.clear(); +// if(mainValueData!=null||TableDatas!=null){ +// //零件主属性 +// XSSFRow titleRow = sheet.getRow(2); +// setCellValue(titleRow, 2, mainValueData.get(0)); +// titleRow = sheet.getRow(3); +// setCellValue(titleRow, 2, mainValueData.get(1)); +// titleRow = sheet.getRow(4); +// setCellValue(titleRow, 2, mainValueData.get(2)); +// titleRow = sheet.getRow(5); +// setCellValue(titleRow, 2, mainValueData.get(3)); +// titleRow = sheet.getRow(6); +// setCellValue(titleRow, 2, mainValueData.get(4)); +// titleRow = sheet.getRow(7); +// setCellValue(titleRow, 2, mainValueData.get(5)); +// titleRow = sheet.getRow(8); +// setCellValue(titleRow, 2, mainValueData.get(6)); +// titleRow = sheet.getRow(9); +// setCellValue(titleRow, 2, mainValueData.get(7)); +// titleRow = sheet.getRow(24); +// setCellValue(titleRow, 2, mainValueData.get(8)); +// titleRow = sheet.getRow(25); +// setCellValue(titleRow, 2, mainValueData.get(9)); +// +// //打印表格数据 +// for(int i=0;i lineList=TableDatas.get(i); +// titleRow=sheet.getRow(12+i); +// setCellValue(titleRow, 2, lineList.get(2)); +// setCellValue(titleRow, 3, lineList.get(3)); +// setCellValue(titleRow, 4, lineList.get(4)); +// } +// } +// +// wb.write(output); +// output.close(); +// input.close(); +// return 0; +// } + +} diff --git a/src/com/connor/renben/process/plm/util/ImageFilter.java b/src/com/connor/renben/process/plm/util/ImageFilter.java new file mode 100644 index 0000000..114ac2c --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ImageFilter.java @@ -0,0 +1,32 @@ +package com.connor.renben.process.plm.util; +import java.io.File; + +import javax.swing.filechooser.FileFilter; + +public class ImageFilter extends FileFilter { + + public boolean accept(File f) { + if (f.isDirectory()) { + return true; + } + String fileName = f.getName(); + int index = fileName.lastIndexOf('.'); + String extension = ""; + if (index > 0 && index < fileName.length() - 1) { + extension = fileName.substring(index + 1).toLowerCase(); + } + if (extension != null) { + if (extension.equals("gif") || extension.equals("jpeg") + || extension.equals("jpg") || extension.equals("png")) { + return true; + } else { + return false; + } + } + return false; + } + + public String getDescription() { + return "图片文件(*.jpg, *.jpeg, *.gif, *.png)"; + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/JAutoCompleteComboBox.java b/src/com/connor/renben/process/plm/util/JAutoCompleteComboBox.java new file mode 100644 index 0000000..2c34960 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/JAutoCompleteComboBox.java @@ -0,0 +1,155 @@ +package com.connor.renben.process.plm.util; + +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.List; +import java.util.Vector; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.JTextField; + +public class JAutoCompleteComboBox extends JComboBox { + private AutoCompleter completer; + + public JAutoCompleteComboBox() { + super(); + addCompleter(); + } + + public JAutoCompleteComboBox(ComboBoxModel cm) { + super(cm); + addCompleter(); + } + + public JAutoCompleteComboBox(Object[] items) { + super(items); + addCompleter(); + } + + public JAutoCompleteComboBox(List v) { + super((Vector) v); + addCompleter(); + } + + private void addCompleter() { + setEditable(true); + completer = new AutoCompleter(this); + } + + public void autoComplete(String str) { + this.completer.autoComplete(str, str.length()); + } + + public String getText() { + return ((JTextField) getEditor().getEditorComponent()).getText(); + } + + public void setText(String text) { + ((JTextField) getEditor().getEditorComponent()).setText(text); + } + + public boolean containsItem(String itemString) { + for (int i = 0; i < this.getModel().getSize(); i++) { + String _item = " " + this.getModel().getElementAt(i); + if (_item.equals(itemString)) + return true; + } + return false; + } + +} + +class AutoCompleter implements KeyListener, ItemListener { + + private JComboBox owner = null; + private JTextField editor = null; + + private ComboBoxModel model = null; + + public AutoCompleter(JComboBox comboBox) { + owner = comboBox; + editor = (JTextField) comboBox.getEditor().getEditorComponent(); + editor.addKeyListener(this); + model = comboBox.getModel(); + owner.addItemListener(this); + } + + public void keyTyped(KeyEvent e) { + } + + public void keyPressed(KeyEvent e) { + } + + public void keyReleased(KeyEvent e) { + char ch = e.getKeyChar(); + // if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch) + // || ch == KeyEvent.VK_DELETE) + // return; + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + int caretPosition = editor.getCaretPosition(); + String str = editor.getText(); + if (str.length() == 0) + return; + autoComplete(str, caretPosition); + } + } + + protected void autoComplete(String strf, int caretPosition) { + Object[] opts; + opts = getMatchingOptions(strf.substring(0, caretPosition)); + if (owner != null) { + model = new DefaultComboBoxModel(opts); + owner.setModel(model); + } + if (opts.length > 0) { + String str = opts[0].toString(); + editor.setCaretPosition(caretPosition); + if (owner != null) { + try { + owner.showPopup(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + } + + protected Object[] getMatchingOptions(String str) { + List v = new Vector(); + List v1 = new Vector(); + //v.add(str); + for (int k = 0; k < model.getSize(); k++) { + Object itemObj = model.getElementAt(k); + if (itemObj != null) { + String item = itemObj.toString().toLowerCase(); + if (item.indexOf((str.toLowerCase())) > -1) + v.add(model.getElementAt(k)); + else + v1.add(model.getElementAt(k)); + } else + v1.add(model.getElementAt(k)); + } + for (int i = 0; i < v1.size(); i++) { + v.add(v1.get(i)); + } + // if (v.isEmpty()) + return v.toArray(); + } + + public void itemStateChanged(ItemEvent event) { + if (event.getStateChange() == ItemEvent.SELECTED) { + int caretPosition = editor.getCaretPosition(); + if (caretPosition != -1) { + try { + editor.moveCaretPosition(caretPosition); + } catch (IllegalArgumentException ex) { + ex.printStackTrace(); + } + } + } + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/MultiComboBox.java b/src/com/connor/renben/process/plm/util/MultiComboBox.java new file mode 100644 index 0000000..9fb91f6 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/MultiComboBox.java @@ -0,0 +1,219 @@ +package com.connor.renben.process.plm.util; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.GridLayout; +import java.awt.Insets; +import java.awt.LayoutManager; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.UIManager; +import javax.swing.plaf.basic.BasicArrowButton; + +import com.teamcenter.rac.util.PropertyLayout; + +import cn.com.origin.autocode.newitem.generatcode.BorderLayout; + +public class MultiComboBox extends JComponent { + + private Object[] values; + + public Object[] defaultValues; + + private List listeners = new ArrayList(); + + public MultiPopup popup; + + public JTextField editor; + + protected JButton arrowButton; + + private String valueSperator; + + private static final String DEFAULT_VALUE_SPERATOR = ","; + + public MultiComboBox(Object[] value, Object[] defaultValue){ + this(value,defaultValue,DEFAULT_VALUE_SPERATOR); + } + + public MultiComboBox(Object[] value, Object[] defaultValue , String valueSperator) { + values = value; + defaultValues = defaultValue; + this.valueSperator = valueSperator; + initComponent(); + } + + private void initComponent() { + //暂时使用该布局,后续自己写个布局 + this.setLayout(new PropertyLayout()); + //this.set + popup =new MultiPopup(values,defaultValues); + popup.addActionListener(new PopupAction()); + + editor = new JTextField(); + editor.setBackground(Color.WHITE); + editor.setEditable(false); + editor.setPreferredSize(new Dimension(150,30)); +// editor.setBorder(getBorder()); + editor.addMouseListener(new EditorHandler()); + arrowButton = createArrowButton(); + arrowButton.addMouseListener(new EditorHandler()); + + add("1.1.left.top",editor); + //add(arrowButton); + setText() ; + + + } + + public Object[] getSelectedValues() { + return popup.getSelectedValues(); + } + + public void addActionListener(ActionListener listener) { + if (!listeners.contains(listener)) + listeners.add(listener); + } + + public void removeActionListener(ActionListener listener) { + if (listeners.contains(listener)) + listeners.remove(listener); + } + + protected void fireActionPerformed(ActionEvent e) { + for (ActionListener l : listeners) { + l.actionPerformed(e); + } + } + + private class PopupAction implements ActionListener{ + + public void actionPerformed(ActionEvent e) { + + if(e.getActionCommand().equals(MultiPopup.CANCEL_EVENT)){ + + }else if(e.getActionCommand().equals(MultiPopup.COMMIT_EVENT)){ + defaultValues = popup.getSelectedValues(); + setText(); + //把事件继续传递出去 + fireActionPerformed(e); + } + + togglePopup(); + + + } + + } + + private void togglePopup(){ + if(popup.isVisible()){ + popup.setVisible(false); + }else{ + popup.setDefaultValue(defaultValues); + popup.show(this, 0, getHeight()); + } + } + + private void setText() { + StringBuilder builder = new StringBuilder(); + for(Object dv : defaultValues){ + builder.append(dv); + builder.append(valueSperator); + } + + editor.setText(builder.substring(0, builder.length() > 0 ? builder.length() -1 : 0).toString()); + } + + private class EditorHandler implements MouseListener{ + + public void mouseClicked(MouseEvent e) { + togglePopup(); + } + + public void mousePressed(MouseEvent e) { + + } + + public void mouseReleased(MouseEvent e) { + + } + + public void mouseEntered(MouseEvent e) { + + } + + public void mouseExited(MouseEvent e) { + + } + + } + + + public void paintComponent(Graphics g){ + g.setColor(Color.white); + g.fillRect(0,0,getWidth(),getHeight()); + } + + + protected JButton createArrowButton() { + JButton button = new BasicArrowButton(BasicArrowButton.SOUTH, + UIManager.getColor("ComboBox.buttonBackground"), + UIManager.getColor("ComboBox.buttonShadow"), + UIManager.getColor("ComboBox.buttonDarkShadow"), + UIManager.getColor("ComboBox.buttonHighlight")); + button.setName("ComboBox.arrowButton"); + return button; + } + + private class MulitComboboxLayout implements LayoutManager{ + + public void addLayoutComponent(String name, Component comp) { + // TODO Auto-generated method stub + + } + + public void removeLayoutComponent(Component comp) { + // TODO Auto-generated method stub + + } + + public Dimension preferredLayoutSize(Container parent) { + return parent.getPreferredSize(); + } + + public Dimension minimumLayoutSize(Container parent) { + return parent.getMinimumSize(); + } + + public void layoutContainer(Container parent) { + int w=parent.getWidth(); + int h=parent.getHeight(); + Insets insets=parent.getInsets(); + h=h-insets.top-insets.bottom; + + } + + } + +} + + diff --git a/src/com/connor/renben/process/plm/util/MultiComboBox2.java b/src/com/connor/renben/process/plm/util/MultiComboBox2.java new file mode 100644 index 0000000..5b6c7d0 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/MultiComboBox2.java @@ -0,0 +1,260 @@ +//package com.connor.renben.process.plm.util; +//import java.awt.Color; +//import java.awt.Component; +//import java.awt.Container; +//import java.awt.Dimension; +//import java.awt.FlowLayout; +//import java.awt.Graphics; +//import java.awt.GridLayout; +//import java.awt.Insets; +//import java.awt.LayoutManager; +//import java.awt.event.ActionEvent; +//import java.awt.event.ActionListener; +//import java.awt.event.ItemEvent; +//import java.awt.event.ItemListener; +//import java.awt.event.MouseEvent; +//import java.awt.event.MouseListener; +//import java.util.ArrayList; +//import java.util.Arrays; +//import java.util.List; +// +//import javax.swing.JButton; +//import javax.swing.JCheckBox; +//import javax.swing.JComponent; +//import javax.swing.JFrame; +//import javax.swing.JPanel; +//import javax.swing.JPopupMenu; +//import javax.swing.JScrollPane; +//import javax.swing.JTextArea; +//import javax.swing.JTextField; +//import javax.swing.UIManager; +//import javax.swing.plaf.basic.BasicArrowButton; +// +//import org.eclipse.swt.SWT; +//import org.eclipse.swt.custom.ScrolledComposite; +//import org.jacorb.idl.runtime.int_token; +// +//import com.teamcenter.rac.util.PropertyLayout; +// +//import cn.com.origin.autocode.newitem.generatcode.BorderLayout; +// +///** +// * 下拉复选框组件 +// * +// */ +//public class MultiComboBox2 extends JComponent implements ActionListener { +// +// private String[] values; +// private MultiPopup popup; +// private JTextArea editor; +// protected JButton arrowButton; +// private String[] selectName=null; +// +// public MultiComboBox2(String[] value) { +// values = value; +// initComponent(); +// } +// +// private void initComponent() { +// popup = new MultiPopup(values); +// editor = new JTextArea(); +// editor.setBackground(Color.WHITE); +// editor.setEditable(false); +// //editor.setPreferredSize(new Dimension(300, 100)); +// //editor.addActionListener(this); +// JScrollPane jslp2 = new JScrollPane(); // 给jta加滚动条 +// jslp2.setPreferredSize(new Dimension(300, 100)); +// jslp2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); +// jslp2.getVerticalScrollBar().setUnitIncrement(25); +// jslp2.setViewportView(editor); +// +// arrowButton = createArrowButton(); +// arrowButton.addActionListener(this); +// +// this.setLayout(new PropertyLayout()); +// +// add("1.1.left.top",jslp2); +// add("1.2.left.top",arrowButton); +// } +// +// //获取选中的数据 +// public Object[] getSelectedValues() { +// return popup.getSelectedValues(); +// } +// +// //设置需要选中的值 +// public void setSelectValues(Object[] selectvalues) { +// popup.setSelectValues(selectvalues); +// setText(selectvalues); +// } +// +// private void setText(Object[] values) { +// if (values.length > 0) { +// String value = Arrays.toString(values); +// value = value.replace("[", ""); +// value = value.replace("]", ""); +// String[] vtrings=value.split(","); +// selectName=vtrings; +// String vString=""; +// for(int i=0;i checkBoxList = new ArrayList(); +// private JButton commitButton; +// private JButton cancelButton; +// +// public MultiPopup(Object[] value) { +// super(); +// values = value; +// initComponent(); +// } +// +// private void initComponent() { +// JPanel checkboxPane = new JPanel(); +// JPanel buttonPane = new JPanel(); +// //this.setLayout(new BorderLayout()); +// this.setLayout(new PropertyLayout()); +// for (Object v : values) { +// JCheckBox temp = new JCheckBox(v.toString()); +// checkBoxList.add(temp); +// } +// +// if (checkBoxList.get(0).getText().equals("全选")) { +// checkBoxList.get(0).addItemListener(new ItemListener() { +// public void itemStateChanged(ItemEvent e) { +// if (checkBoxList.get(0).isSelected()) { +// for (int i = 1; i < checkBoxList.size(); i++) { +// if (!checkBoxList.get(i).isSelected()) { +// checkBoxList.get(i).setSelected(true); +// } +// } +// } else { +// for (int i = 1; i < checkBoxList.size(); i++) { +// if (checkBoxList.get(i).isSelected()) { +// checkBoxList.get(i).setSelected(false); +// } +// } +// } +// } +// }); +// } +// +// checkboxPane.setLayout(new GridLayout(checkBoxList.size(), 1, 3, 3)); +// for (JCheckBox box : checkBoxList) { +// checkboxPane.add(box); +// } +// JScrollPane jslp2 = new JScrollPane(); // 给jta加滚动条 +// jslp2.setPreferredSize(new Dimension(500, 200)); +// jslp2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); +// jslp2.getVerticalScrollBar().setUnitIncrement(25); +// jslp2.setViewportView(checkboxPane); +// +// commitButton = new JButton("确定"); +// commitButton.addActionListener(this); +// +// cancelButton = new JButton("取消"); +// cancelButton.addActionListener(this); +// +// buttonPane.add(commitButton); +// buttonPane.add(cancelButton); +//// this.add(checkboxPane, BorderLayout.CENTER); +//// this.add(buttonPane, BorderLayout.SOUTH); +// this.add("1.1.left.top",jslp2); +// this.add("2.1.left.top",buttonPane); +// +// } +// +// public void setSelectValues(Object[] values) { +// if (values.length > 0) { +// for (int i = 0; i < values.length; i++) { +// for (int j = 0; j < checkBoxList.size(); j++) { +// if (values[i].equals(checkBoxList.get(j).getText())) { +// checkBoxList.get(j).setSelected(true); +// } +// } +// } +// setText(getSelectedValues()); +// } +// } +// +// +// public Object[] getSelectedValues() { +// List selectedValues = new ArrayList(); +// +// if (checkBoxList.get(0).getText().equals("全选")) { +// if (checkBoxList.get(0).isSelected()) { +// for (int i = 1; i < checkBoxList.size(); i++) { +// selectedValues.add(values[i]); +// } +// } else { +// for (int i = 1; i < checkBoxList.size(); i++) { +// if (checkBoxList.get(i).isSelected()) { +// selectedValues.add(values[i]); +// } +// } +// } +// } else { +// for (int i = 0; i < checkBoxList.size(); i++) { +// if (checkBoxList.get(i).isSelected()) { +// selectedValues.add(values[i]); +// } +// } +// } +// +// return selectedValues.toArray(new Object[selectedValues.size()]); +// } +// +// +// +// @Override +// public void actionPerformed(ActionEvent arg0) { +// // TODO Auto-generated method stub +// Object source = arg0.getSource(); +// if (source instanceof JButton) { +// JButton button = (JButton) source; +// if (button.equals(commitButton)) { +// setText(getSelectedValues()); +// popup.setVisible(false); +// } else if (button.equals(cancelButton)) { +// popup.setVisible(false); +// } +// } +// } +// +// } +//} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/MultiPopup.java b/src/com/connor/renben/process/plm/util/MultiPopup.java new file mode 100644 index 0000000..49de43e --- /dev/null +++ b/src/com/connor/renben/process/plm/util/MultiPopup.java @@ -0,0 +1,190 @@ +package com.connor.renben.process.plm.util; +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.List; + + + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; + +public class MultiPopup extends JPopupMenu { + + private List listeners = new ArrayList(); + + private Object[] values; + + private Object[] defaultValues; + + private List checkBoxList = new ArrayList(); + + private JButton commitButton ; + + private JButton cancelButton; + + public static final String COMMIT_EVENT = "commit"; + + public static final String CANCEL_EVENT = "cancel"; + + public MultiPopup(Object[] value , Object[] defaultValue) { + super(); + values = value; + defaultValues = defaultValue; + initComponent(); + } + + public void addActionListener(ActionListener listener) { + if (!listeners.contains(listener)) + listeners.add(listener); + } + + public void removeActionListener(ActionListener listener) { + if (listeners.contains(listener)) + listeners.remove(listener); + } + + private void initComponent() { + + JPanel checkboxPane = new JPanel(); + + JPanel buttonPane = new JPanel(); + + this.setLayout(new BorderLayout()); + + + for(Object v : values){ + JCheckBox temp = new JCheckBox(v.toString() , selected(v)); + checkBoxList.add(temp); + } + + if(checkBoxList.get(0).getText().equals("Selected All")) + checkBoxList.get(0).addItemListener(new ItemListener() + { + public void itemStateChanged(ItemEvent e) + { + System.out.println("被选中状态 "+checkBoxList.get(0).isSelected()); + if(checkBoxList.get(0).isSelected())//Select All 被选中 + { + //检查其他的是否被选中乳沟没有就选中他们 + for(int i=1; i< checkBoxList.size();i++) + { + if(!checkBoxList.get(i).isSelected()) + checkBoxList.get(i).setSelected(true); + } + } + else + { + for(int i=1; i< checkBoxList.size();i++) + { + if(checkBoxList.get(i).isSelected()) + checkBoxList.get(i).setSelected(false); + } + } + } + }); + + + + checkboxPane.setLayout(new GridLayout(checkBoxList.size() , 1 ,3, 3)); + for(JCheckBox box : checkBoxList){ + checkboxPane.add(box); + } + + commitButton = new JButton("ok"); + + commitButton.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + commit(); + } + + }); + + cancelButton = new JButton("cancel"); + + cancelButton.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + cancel(); + } + + }); + + buttonPane.add(commitButton); + + buttonPane.add(cancelButton); + + this.add(checkboxPane , BorderLayout.CENTER); + + this.add(buttonPane , BorderLayout.SOUTH); + + + } + + private boolean selected(Object v) { + for(Object dv : defaultValues){ + if( dv .equals(v) ){ + return true; + } + } + return false; + } + + protected void fireActionPerformed(ActionEvent e) { + for (ActionListener l : listeners) { + l.actionPerformed(e); + } + } + + public Object[] getSelectedValues(){ + List selectedValues = new ArrayList(); + + if(checkBoxList.get(0).getText().equals("Selected All")) + { + if(checkBoxList.get(0).isSelected()) + { + for(int i = 1 ; i < checkBoxList.size() ; i++) + { + selectedValues.add(values[i]); + } + } + else + { + for(int i = 1 ; i < checkBoxList.size() ; i++){ + + if(checkBoxList.get(i).isSelected()) + selectedValues.add(values[i]); + } + } + }else + for(int i = 0 ; i < checkBoxList.size() ; i++){ + + if(checkBoxList.get(i).isSelected()) + selectedValues.add(values[i]); + } + + + return selectedValues.toArray(new Object[selectedValues.size()]); + } + + public void setDefaultValue(Object[] defaultValue) { + defaultValues = defaultValue; + + } + + public void commit(){ + fireActionPerformed(new ActionEvent(this, 0, COMMIT_EVENT)); + } + + public void cancel(){ + fireActionPerformed(new ActionEvent(this, 0, CANCEL_EVENT)); + } + +} diff --git a/src/com/connor/renben/process/plm/util/MyComboBox.java b/src/com/connor/renben/process/plm/util/MyComboBox.java new file mode 100644 index 0000000..80d8fb8 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/MyComboBox.java @@ -0,0 +1,66 @@ +package com.connor.renben.process.plm.util; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Vector; + +import javax.swing.JComboBox; +import javax.swing.SwingUtilities; + +public class MyComboBox extends JComboBox implements ActionListener { + public MyComboBox() { + addItem(new CheckValue(false,"Select All")); + this.addActionListener( + new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + itemSelected(); + } + }); + } + private void itemSelected(){ + if(getSelectedItem() instanceof CheckValue){ + if(getSelectedIndex() == 0){ + selectedAllItem(); + } else { + CheckValue jcb = (CheckValue) getSelectedItem(); + jcb.bolValue = (!jcb.bolValue); + setSelectedIndex((getSelectedIndex())); + } + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + //閫変腑鍚庝緷鐒朵繚鎸佸綋鍓嶅脊鍑虹姸鎬? + showPopup(); + + } + }); + } + } + + private void selectedAllItem(){ + boolean bl=false; + for (int i = 0; i < getItemCount(); i++) { + CheckValue jcb = (CheckValue) getItemAt(i); + if(i == 0) { + bl = !jcb.bolValue; + } + jcb.bolValue = (bl); + } + setSelectedIndex(0); + } + + public Vector getComboVc() { + Vector vc = new Vector(); + for (int i = 0; i < getItemCount(); i++) { + CheckValue jcb = (CheckValue) getItemAt(i); + if(jcb.bolValue) { + vc.add(jcb.value); + } + } + return vc; + } +} diff --git a/src/com/connor/renben/process/plm/util/MyTableModel.java b/src/com/connor/renben/process/plm/util/MyTableModel.java new file mode 100644 index 0000000..319522c --- /dev/null +++ b/src/com/connor/renben/process/plm/util/MyTableModel.java @@ -0,0 +1,48 @@ +package com.connor.renben.process.plm.util; + +import java.util.Vector; + +import javax.swing.table.DefaultTableModel; + +/** + * 自定义JTable + * + * @author Administrator + * + */ +public class MyTableModel extends DefaultTableModel { + + public MyTableModel(Object[][] values, Object[] titleNames) { + super(values, titleNames); + } + + public MyTableModel(Vector values, Vector titleNames) { + super(values, titleNames); + } + + + // 重写getColumnClass方法,根据每列的第一个值返回该列真实的数据类型 + @Override + public Class getColumnClass(int columnIndex) { + + Object ob = getValueAt(0, columnIndex); + if (ob == null) { + String bb = ""; + return bb.getClass(); + } else { + return getValueAt(0, columnIndex).getClass(); + } + } + + @Override + public Object getValueAt(int i, int j) { + // TODO Auto-generated method stub + Vector rowValue = (Vector) this.dataVector.get(i); + return rowValue.get(j); + } + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } + +} diff --git a/src/com/connor/renben/process/plm/util/ParseXMLUtil.java b/src/com/connor/renben/process/plm/util/ParseXMLUtil.java new file mode 100644 index 0000000..436ae1f --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ParseXMLUtil.java @@ -0,0 +1,143 @@ +package com.connor.renben.process.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 wangc + * + */ +public class ParseXMLUtil { + + /** + * 解析编码规则XML + * @param file + */ + public Map> parseXMLCode(File file) { + Map> attrMap = new HashMap>(); + List typelist = new ArrayList(); + List namelist = new ArrayList(); + List markList = new ArrayList(); + List valueList = new ArrayList(); + try { + SAXReader saxReader = new SAXReader(); + Document document = saxReader.read(file); + Element root = document.getRootElement(); + Iterator iter = root.elementIterator("largeclass");// largeclass标签 + while (iter.hasNext()) { + Element recordEle = (Element) iter.next(); + Iterator iter2 = recordEle.elementIterator("subclass");// subclass标签 + while (iter2.hasNext()) { + Element recordEle2 = (Element) iter2.next(); + String type = recordEle2.attributeValue("type"); + System.out.println("Type===================="+type); + typelist.add(type); + Iterator iter3 = recordEle2.elementIterator("prop");// prop标签 + StringBuilder sb = new StringBuilder(); + StringBuilder sb1 = new StringBuilder(); + StringBuilder sb2 = new StringBuilder(); + while (iter3.hasNext()) { + Element recordEle3 = (Element) iter3.next(); + String name = recordEle3.attributeValue("attrName"); + String mark = recordEle3.attributeValue("mark"); + String value = recordEle3.attributeValue("value"); + System.out.println("value====="+value); + if(mark == null || "".equals(mark)) { + mark = " "; + } + if(value == null || "".equals(value)) { + value = " "; + } + sb.append(name); + sb1.append(mark); + sb2.append(value); + sb.append(";"); + sb1.append(";"); + sb2.append(";"); + } + namelist.add(sb.toString()); + markList.add(sb1.toString()); + valueList.add(sb2.toString()); + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + for (int i = 0; i < typelist.size(); i++) { + List nameMarkList = new ArrayList(); + nameMarkList.add(namelist.get(i)); + nameMarkList.add(markList.get(i)); + nameMarkList.add(valueList.get(i)); + attrMap.put(typelist.get(i), nameMarkList); + } + return attrMap; + } + + /** + * 通过首选项里的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("C:\\Users\\wangc\\Desktop\\测试\\人本产品号拼接方式V1.xml"); +// //File file2 = new File("D:\\2.xml"); +// ParseXMLUtil t = new ParseXMLUtil(); +// // t.parseXML(file); +// t.parseXMLCode(file); +// } +} diff --git a/src/com/connor/renben/process/plm/util/PosParamCellEditor.java b/src/com/connor/renben/process/plm/util/PosParamCellEditor.java new file mode 100644 index 0000000..0294b65 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/PosParamCellEditor.java @@ -0,0 +1,37 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Component; + +import javax.swing.DefaultCellEditor; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; + +public class PosParamCellEditor extends DefaultCellEditor { + + public PosParamCellEditor(JComboBox box) { + super(box); + } + + public PosParamCellEditor(JCheckBox chb) { + super(chb); + } + + public PosParamCellEditor(JTextField txt) { + super(txt); + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, int row, int column) { + // TODO 当单元格处于编辑状态时 + if (column == 1) { + return new JTextArea(); + } + return super.getTableCellEditorComponent(table, value, isSelected, row, + column); + } + +} diff --git a/src/com/connor/renben/process/plm/util/ProgressBar.java b/src/com/connor/renben/process/plm/util/ProgressBar.java new file mode 100644 index 0000000..85094d9 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ProgressBar.java @@ -0,0 +1,138 @@ +package com.connor.renben.process.plm.util; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Registry; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.event.*; +import javax.swing.*; + +import org.eclipse.swt.graphics.Rectangle; + +public class ProgressBar extends AbstractAIFDialog implements ActionListener { + /** + * 内部类,线程任务 + * + * @author Administrator + * + */ + class TaskThread extends Thread { + + public void run() { + + Dimension d = progressbar.getSize(); + bar.paintAll(bar.getGraphics()); + // Rectangle rect = new Rectangle(0,0, d.width, d.height); + for (int i = 0; i < i + 1; i++) { + // 启动线程 + timer.start(); + int value = progressbar.getValue(); + // 让进度条分为100格,以每秒进5格 + if (value < 100) { + value += 5; + progressbar.setValue(value); + + } else { + // 计时器停止,重新开始加载 + timer.stop(); + progressbar.setValue(0); + bar.paintAll(bar.getGraphics()); + } + progressbar.paintImmediately(0, 0, d.width, d.height); + try { + // 线程停止100毫秒 + sleep(100L); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (bool) { + // 设置进度条的可见或者不可见 + bar.setVisible(false); + bar.dispose(); + return; + } + } + + } + + private ProgressBar bar; + + final ProgressBar this$0; + + // 将线程添加到任务中 + public TaskThread(ProgressBar bar) { + super(); + this$0 = ProgressBar.this; + this.bar = bar; + } + } + + public ProgressBar(String showlable) { + super(true); + bool = false; + showLable = null; + showLable = showlable; + } + + public void setBool(boolean bool) { + this.bool = bool; + } + + /** + * 构造进度条的面板 + * + */ + public void initUI() { + Container container = getContentPane(); + JPanel mainPanel = new JPanel(new PropertyLayout()); + label = new JLabel(showLable, 0); + progressbar = new JProgressBar(); + progressbar.setOrientation(0); + // 进度条从0开始,100结束 + progressbar.setMinimum(0); + progressbar.setMaximum(100); + progressbar.setValue(0); + progressbar.setPreferredSize(new Dimension(200, 15)); + progressbar.setBorderPainted(true); + // 启动计时器 + timer = new Timer(50, 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; + } + + }); + setVisible(true); + } + + public void actionPerformed(ActionEvent actionevent) { + } + + private JProgressBar progressbar; + + private JLabel label; + + private Timer timer; + + private boolean bool; + + private Registry registry; + + private String showLable; + +} diff --git a/src/com/connor/renben/process/plm/util/ProgressBarThread.java b/src/com/connor/renben/process/plm/util/ProgressBarThread.java new file mode 100644 index 0000000..7c52305 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ProgressBarThread.java @@ -0,0 +1,29 @@ +package com.connor.renben.process.plm.util; + +// Referenced classes of package com.teamcenter.rac.importflex: +// ProgressBar + +public class ProgressBarThread extends Thread { + + 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); + } + + private ProgressBar bar; + + private String title; +} diff --git a/src/com/connor/renben/process/plm/util/SaveControlPlan.java b/src/com/connor/renben/process/plm/util/SaveControlPlan.java new file mode 100644 index 0000000..1508ed5 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/SaveControlPlan.java @@ -0,0 +1,518 @@ +//package com.connor.renben.process.plm.util; +// +//import java.io.BufferedInputStream; +//import java.io.IOException; +//import java.io.InputStream; +//import java.sql.ResultSet; +//import java.util.ArrayList; +//import java.util.Arrays; +//import java.util.List; +//import java.util.Properties; +//import java.util.UUID; +// +//import org.apache.poi.xssf.eventusermodel.examples.FromHowTo; +// +//import com.connor.renben.process.plm.sql.util.SqlUtilT; +//import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentItem; +//import com.teamcenter.rac.kernel.TCPreferenceService; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.util.MessageBox; +// +///** +// * 保存数据到控制计划表 +// * @author Administrator +// * +// */ +//public class SaveControlPlan { +// private TCSession session; +// private TCComponentItem item; +// private InterfaceAIFComponent comp; +// private List> properties = new ArrayList>(); +// private List> dataList = new ArrayList>();// 表格中的数据 +// +// public SaveControlPlan(TCSession session,TCComponentItem item,InterfaceAIFComponent comp) { +// // TODO Auto-generated constructor stub +// this.session = session; +// this.item = item; +// this.comp=comp; +// } +// /** +// * 获取没有检验项的工序 +// * @param name 首选项名称 +// * @return 没有检验项的工序名称 +// */ +// private List getMeopNames(String name) { +// // TODO Auto-generated method stub +// String[] values = null; +// if(name != null) +// { +// TCPreferenceService service = this.session.getPreferenceService(); +// String[] props = service.getStringArray(TCPreferenceService.TC_preference_site, name); +// if(props != null || props.length>0) +// { +// values = props; +// } +// } +// else +// { +// MessageBox.post("未找首选项!", "错误!", MessageBox.ERROR); +// } +// return Arrays.asList(values); +// } +// public void insertData() { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// ResultSet result = null; +// ResultSet resultSet = null; +// InputStream input = null; +// try { +// properties = TMomMethodUtil.getBomPropertys(session, item); +// //properties.clear(); +// List meopNameList = getMeopNames("RB3_CONCEAL_MEOP_NAME"); +// String itemUid = item.getUid(); +// //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List kzjhList = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// kzjhList.add((TCComponentItem)kzjh[i]); +// } +// } +// SqlUtilT.getTCConnection(); +// input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// Properties pro = new Properties(); +// pro.load(input); +// if(kzjhList.size() == 0) +// { +// // 查询数据库中的数据 +// SqlUtilT.getTCConnection(); +// String sql = String.format(pro.getProperty("BOMCHECKSAVESELECT"), +// itemUid, "检验(%",comp.getUid()); +// rs = SqlUtilT.read(sql); +// while (rs.next()) { +// List rowList = new ArrayList(); +// rowList.add(rs.getString("RB3_MEOPID") == null ? "" : rs.getString("RB3_MEOPID")); +// //rowList.add(rs.getString("RB3_MEOPID")); +// rowList.add(rs.getString("RB3_GYBH")); +// rowList.add(rs.getString("RB3_GCMC")); +// rowList.add(rs.getString("RB3_JQSB") == null ? "" : rs.getString("RB3_JQSB")); +// dataList.add(rowList); +// } +// if (dataList == null || dataList.size() == 0) { +// for (int j = 0; j < properties.size(); j++) { +// UUID kzjhUid = UUID.randomUUID(); +//// UUID ssckzjhUid = UUID.randomUUID(); +//// UUID yjkzjhUid = UUID.randomUUID(); +// // 将数据插入到控制计划 +// SqlUtilT.getTCConnection(); +// String insertSQL = pro.getProperty("INSERTSQL"); +//// Integer number = Integer.parseInt(properties.get(j).get(1) +//// .toString()) % 10 == 0 ? Integer +//// .parseInt(properties.get(j).get(1).toString()) + 5 +//// : Integer.parseInt(properties.get(j).get(1) +//// .toString()) + 1; +// String name = "检验(" + properties.get(j).get(2).toString()+ ")"; +// if(properties.get(j).get(2).toString().indexOf("/") >=0 && properties.get(j).get(2).toString().split("/").length == 2 ) +// { +// name = "检验(" + properties.get(j).get(2).toString().split("/")[0] + ")\n" + +// "inspect("+properties.get(j).get(2).toString().split("/")[1]+")"; +// } +// //首末检验 +// String smjy = ""; +// if(properties.get(j).get(2).indexOf("检验") >= 0) +// { +// smjy = "巡检检验\nPatrol inspection"; +// } +// // 插入生产控制计划工序 +// SqlUtilT.getTCConnection(); +// SqlUtilT.write( +// new String[] { +// kzjhUid.toString().replace("-", ""), +// itemUid, properties.get(j).get(0), +// properties.get(j).get(1), +// properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2), +// properties.get(j).get(3), smjy, "1", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "RB3_YJKZJH","1","0","","0",comp.getUid(),properties.get(j).get(4) }, +// insertSQL); +// if(meopNameList.contains(properties.get(j).get(2).toString())) +// { +// // 插入生产控制计划巡检项 +// SqlUtilT.getTCConnection(); +// SqlUtilT.write( +// new String[] { +// UUID.randomUUID().toString() +// .replace("-", ""), itemUid, +// properties.get(j).get(0), +// properties.get(j).get(1).toString(), name, +// "", "巡检检验\nPatrol inspection", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "RB3_YJKZJH","1","0","","0",comp.getUid(), properties.get(j).get(4) }, +// insertSQL); +// } +// } +// } else { +// // 修改表中相应的工序名称 +// for (int i = 0; i < dataList.size(); i++) { +// for (int j = 0; j < properties.size(); j++) { +// if (dataList.get(i).get(0) +// .equals(properties.get(j).get(0)) +// && (!dataList.get(i).get(1) +// .equals(properties.get(j).get(1)) +// || !dataList +// .get(i) +// .get(2) +// .equals(properties.get(j) +// .get(2)) || !dataList +// .get(i).get(3) +// .equals(properties.get(j).get(3)))) { +//// Integer number = Integer.parseInt(properties.get(j) +//// .get(1).toString()) % 10 == 0 ? Integer +//// .parseInt(properties.get(j).get(1) +//// .toString()) + 5 : Integer +//// .parseInt(properties.get(j).get(1) +//// .toString()) + 1; +// String name = "检验(" +// + properties.get(j).get(2).toString() + ")"; +// if(properties.get(j).get(2).toString().indexOf("/") >=0 && properties.get(j).get(2).toString().split("/").length == 2 ) +// { +// name = "检验(" + properties.get(j).get(2).toString().split("/")[0] + ")\n" + +// "inspect("+properties.get(j).get(2).toString().split("/")[1]+")"; +// } +// // 获取数据库连接 +// // 更新自检 +// SqlUtilT.getTCConnection(); +// String updateSQL = String.format( +// pro.getProperty("BOMCHECKSAVEUPDATE"), +// itemUid, dataList.get(i).get(0), "检验(%"); +// // 更新巡检 +// String updateSQL1 = String.format( +// pro.getProperty("BOMCHECKSAVEUPDATE2"), +// itemUid, dataList.get(i).get(0), "检验(%"); +// SqlUtilT.update(new String[] { +// properties.get(j).get(1), +// properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2), +// properties.get(j).get(3) }, updateSQL); +// SqlUtilT.update(new String[] { properties.get(j).get(1).toString(), +// name, +// ""}, updateSQL1); +// } +// // if(dataList.get(i).get(1).equals(properties[j][1].getStringValue()) +// // && !dataList.get(i).get(0).equals(properties[j][0])) +// // { +// // //获取数据库连接 +// // String updateSQL = +// // String.format("update CONTROLPLAN set RB3_GYBH = ? where PROCESSPUID = \'%s\' and RB3_GCMC = \'%s\'",itemUid,dataList.get(i).get(1)) +// // ; +// // SqlUtilT.update(new String[]{ +// // properties[j][0].getStringValue() },updateSQL); +// // } +// } +// } +// // 添加工序 +// // 查询数据库中的数据 +// result = SqlUtilT.read(sql); +// List indexList = new ArrayList(); +// while (result.next()) { +// indexList.add(result.getString("RB3_MEOPID")); +// } +// for (int i = 0; i < properties.size(); i++) { +// if (!indexList.contains(properties.get(i).get(0))) { +// UUID kzjhUid = UUID.randomUUID(); +// // 将数据插入到表中 +// SqlUtilT.getTCConnection(); +// String insertSQL = pro.getProperty("INSERTSQL"); +//// Integer number = Integer.parseInt(properties.get(i) +//// .get(1).toString()) % 10 == 0 ? Integer +//// .parseInt(properties.get(i).get(1).toString()) + 5 +//// : Integer.parseInt(properties.get(i).get(1) +//// .toString()) + 1; +// String name = "检验(" +// + properties.get(i).get(2).toString() + ")"; +// if(properties.get(i).get(2).toString().indexOf("/") >=0 && properties.get(i).get(2).toString().split("/").length == 2 ) +// { +// name = "检验(" + properties.get(i).get(2).toString().split("/")[0] + ")\n" + +// "inspect("+properties.get(i).get(2).toString().split("/")[1]+")"; +// } +// +// //首末检验 +// String smjy = ""; +// if(properties.get(i).get(2).indexOf("检验") >= 0) +// { +// smjy = "巡检检验\nPatrol inspection"; +// } +// +// // 插入控制计划工序 +// SqlUtilT.getTCConnection(); +// SqlUtilT.write(new String[] { +// kzjhUid.toString().replace("-", ""), itemUid, +// properties.get(i).get(0), +// properties.get(i).get(1), +// properties.get(i).get(2).indexOf("/") >=0 ? properties.get(i).get(2).replace("/", "\n") : properties.get(i).get(2), +// properties.get(i).get(3), smjy, "1", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "RB3_YJKZJH","1","0","","0",comp.getUid(),properties.get(i).get(4) },insertSQL); +// if(meopNameList.contains(properties.get(i).get(2).toString())) +// { +// // 插入控制计划巡检项 +// SqlUtilT.getTCConnection(); +// SqlUtilT.write( +// new String[] { +// UUID.randomUUID().toString() +// .replace("-", ""), itemUid, +// properties.get(i).get(0), +// properties.get(i).get(1).toString(), name, +// "", "巡检检验\nPatrol inspection", "", "", +// "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", +// "RB3_YJKZJH","1","0","","0" ,comp.getUid(),properties.get(i).get(4) },insertSQL); +// } +// } +// } +// // 删除表中相应的工序 +// StringBuffer sb = new StringBuffer(); +// sb.append("("); +// for (int i = 0; i < properties.size(); i++) { +// sb.append("\'" + properties.get(i).get(0) + "\',"); +// } +// // 获取数据库连接 +// SqlUtilT.getTCConnection(); +// String selectSql = String +// .format(pro.getProperty("BOMCHECKSAVESELECT2"), +// itemUid, +// sb.toString().substring(0, sb.length() - 1) +// + ")"); +// resultSet = SqlUtilT.read(selectSql); +// List deleteList = new ArrayList(); +// while (resultSet.next()) { +// deleteList.add(resultSet.getString("RB3_MEOPID")); +// } +// if (deleteList != null && deleteList.size() > 0) { +// for (int i = 0; i < deleteList.size(); i++) { +// SqlUtilT.getTCConnection(); +// String deleteSQL = String.format( +// pro.getProperty("DELETE"), deleteList.get(i), +// itemUid); +// SqlUtilT.delete(deleteSQL); +// } +// } +// } +// } +// else +// { +// for (int i1 = 0; i1 < kzjhList.size(); i1++) { +// // 查询数据库中的数据 +// SqlUtilT.getTCConnection(); +// String sql = String.format(pro.getProperty("BOMCHECKSAVESELECT"), +// itemUid, "检验(%",comp.getUid()); +// rs = SqlUtilT.read(sql); +// while (rs.next()) { +// List rowList = new ArrayList(); +// rowList.add(rs.getString("RB3_MEOPID") == null ? "" : rs.getString("RB3_MEOPID")); +// //rowList.add(rs.getString("RB3_MEOPID")); +// rowList.add(rs.getString("RB3_GYBH")); +// rowList.add(rs.getString("RB3_GCMC")); +// rowList.add(rs.getString("RB3_JQSB") == null ? "" : rs.getString("RB3_JQSB")); +// dataList.add(rowList); +// } +// if (dataList == null || dataList.size() == 0) { +// for (int j = 0; j < properties.size(); j++) { +// UUID kzjhUid = UUID.randomUUID(); +//// UUID ssckzjhUid = UUID.randomUUID(); +//// UUID yjkzjhUid = UUID.randomUUID(); +// // 将数据插入到控制计划 +// SqlUtilT.getTCConnection(); +// String insertSQL = pro.getProperty("INSERTSQL"); +// +// String smjy = ""; +// // 插入控制计划工序 +// SqlUtilT.getTCConnection(); +// SqlUtilT.write( +// new String[] { +// kzjhUid.toString().replace("-", ""), +// itemUid, properties.get(j).get(0), +// properties.get(j).get(1), +// properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2), +// properties.get(j).get(3), smjy, "1", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", kzjhList.get(i1).getType().toUpperCase(),"","","","",comp.getUid(),properties.get(j).get(4) }, +// insertSQL); +// +// } +// } else { +// // 修改表中相应的工序属性 +// for (int i = 0; i < dataList.size(); i++) { +// for (int j = 0; j < properties.size(); j++) { +// if (dataList.get(i).get(0).equals(properties.get(j).get(0))&& +// (!dataList.get(i).get(1).equals(properties.get(j).get(1)) +// || !dataList.get(i).get(2).equals(properties.get(j).get(2)) +// || !dataList.get(i).get(3).equals(properties.get(j).get(3)))) { +// String name = "检验(" +// + properties.get(j).get(2).toString() + ")"; +// String s = properties.get(j).get(2).toString(); +// if(properties.get(j).get(2).toString().indexOf("/") >=0 && properties.get(j).get(2).toString().split("/").length == 2 ) +// { +// name = "检验(" + properties.get(j).get(2).toString().split("/")[0] + ")\n" + +// "inspect("+properties.get(j).get(2).toString().split("/")[1]+")"; +// } +// // 获取数据库连接 +// // 更新自检 +// SqlUtilT.getTCConnection(); +// String updateSQL = String.format( +// pro.getProperty("BOMCHECKSAVEUPDATE"), +// itemUid, dataList.get(i).get(0), "检验(%"); +// // 更新巡检 +// SqlUtilT.getTCConnection(); +// String updateSQL1 = String.format( +// pro.getProperty("BOMCHECKSAVEUPDATE2"), +// itemUid, dataList.get(i).get(0), "检验(%"); +// SqlUtilT.update(new String[] { +// properties.get(j).get(1), +// properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2), +// (dataList.get(i).get(3).equals("")?properties.get(j).get(3):dataList.get(i).get(3).toString())}, +// updateSQL);//机器设备只有在为空的时候才更新 +// //System.out.println(updateSQL); +// SqlUtilT.update(new String[] { properties.get(j).get(1).toString(), +// name, +// ""}, updateSQL1); +// } +// // if(dataList.get(i).get(1).equals(properties[j][1].getStringValue()) +// // && !dataList.get(i).get(0).equals(properties[j][0])) +// // { +// // //获取数据库连接 +// // String updateSQL = +// // String.format("update CONTROLPLAN set RB3_GYBH = ? where PROCESSPUID = \'%s\' and RB3_GCMC = \'%s\'",itemUid,dataList.get(i).get(1)) +// // ; +// // SqlUtilT.update(new String[]{ +// // properties[j][0].getStringValue() },updateSQL); +// // } +// } +// } +// // 添加工序 +// // 查询数据库中的数据 +// result = SqlUtilT.read(sql); +// List indexList = new ArrayList(); +// while (result.next()) { +// indexList.add(result.getString("RB3_MEOPID")); +// } +// for (int i = 0; i < properties.size(); i++) { +// if (!indexList.contains(properties.get(i).get(0))) { +// UUID kzjhUid = UUID.randomUUID(); +// // 将数据插入到表中 +// String insertSQL = pro.getProperty("INSERTSQL"); +//// Integer number = Integer.parseInt(properties.get(i) +//// .get(1).toString()) % 10 == 0 ? Integer +//// .parseInt(properties.get(i).get(1).toString()) + 5 +//// : Integer.parseInt(properties.get(i).get(1) +//// .toString()) + 1; +// String name = "检验(" +// + properties.get(i).get(2).toString() + ")"; +// if(properties.get(i).get(2).toString().indexOf("/") >=0 && properties.get(i).get(2).toString().split("/").length == 2 ) +// { +// name = "检验(" + properties.get(i).get(2).toString().split("/")[0] + ")\n" + +// "inspect("+properties.get(i).get(2).toString().split("/")[1]+")"; +// } +// +// +// //首末检验 +// String smjy = ""; +// if(properties.get(i).get(2).indexOf("检验") >= 0) +// { +// smjy = "巡检检验\nPatrol inspection"; +// } +// +// // 插入控制计划工序 +// SqlUtilT.getTCConnection(); +// SqlUtilT.write(new String[] { +// kzjhUid.toString().replace("-", ""), itemUid, +// properties.get(i).get(0), +// properties.get(i).get(1), +// properties.get(i).get(2).indexOf("/") >=0 ? properties.get(i).get(2).replace("/", "\n") : properties.get(i).get(2), +// properties.get(i).get(3), smjy, "1", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", kzjhList.get(i1).getType().toUpperCase(),"1","0","","0" ,comp.getUid(),properties.get(i).get(4) },insertSQL); +// if(meopNameList.contains(properties.get(i).get(2).toString())) +// { +// // 插入控制计划巡检项 +// SqlUtilT.getTCConnection(); +// SqlUtilT.write( +// new String[] { +// UUID.randomUUID().toString() +// .replace("-", ""), itemUid, +// properties.get(i).get(0), +// properties.get(i).get(1).toString(), name, +// "", "巡检检验\nPatrol inspection", "", "", +// "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", +// kzjhList.get(i1).getType().toUpperCase(),"1","0","","0",comp.getUid(),properties.get(i).get(4) },insertSQL); +// } +// } +// } +// // 删除表中相应的工序 +// StringBuffer sb = new StringBuffer(); +// sb.append("("); +// if(properties.size()>0) { +// for (int i = 0; i < properties.size(); i++) { +// sb.append("\'" + properties.get(i).get(0) + "\',"); +// } +// }else { +// sb.append("\'" +"0"+ "\',");//如果没一个工序类,就直接全清空 +// } +// +// // 获取数据库连接 +// SqlUtilT.getTCConnection(); +// String selectSql = String +// .format(pro.getProperty("BOMCHECKSAVESELECT2"), +// itemUid, +// sb.toString().substring(0, sb.length() - 1) +// + ")"); +// resultSet = SqlUtilT.read(selectSql); +// System.out.println(selectSql); +// List deleteList = new ArrayList(); +// while (resultSet.next()) { +// if(!deleteList.contains(resultSet.getString("RB3_MEOPID"))) { +// deleteList.add(resultSet.getString("RB3_MEOPID")); +// } +// } +// if (deleteList != null && deleteList.size() > 0) { +// for (int i = 0; i < deleteList.size(); i++) { +// SqlUtilT.getTCConnection(); +// String deleteSQL = String.format( +// pro.getProperty("DELETE"), deleteList.get(i), +// itemUid); +// System.out.println(deleteSQL); +// SqlUtilT.delete(deleteSQL); +// } +// } +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } finally { +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// if (result != null) { +// SqlUtilT.free(result); +// } +// if (resultSet != null) { +// SqlUtilT.free(resultSet); +// } +// if (input != null) { +// try { +// input.close(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// SqlUtilT.freeAll(); +// } +// } +//} diff --git a/src/com/connor/renben/process/plm/util/SavePermissions.java b/src/com/connor/renben/process/plm/util/SavePermissions.java new file mode 100644 index 0000000..47e349f --- /dev/null +++ b/src/com/connor/renben/process/plm/util/SavePermissions.java @@ -0,0 +1,245 @@ +//package com.connor.renben.process.plm.util; +// +//import java.io.BufferedInputStream; +//import java.io.IOException; +//import java.io.InputStream; +//import java.sql.ResultSet; +//import java.util.ArrayList; +//import java.util.List; +//import java.util.Properties; +//import java.util.UUID; +// +//import com.connor.renben.process.plm.sql.util.SqlUtilT; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentItem; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.util.MessageBox; +// +///** +// * 保存数据到权限表 +// * @author Administrator +// * +// */ +//public class SavePermissions { +// +// private TCSession session; +// private TCComponentItem item; +// private List> properties = new ArrayList>(); +// private List> dataList = new ArrayList>();// 表格中的数据 +// private List controlUids=new ArrayList(); +// private List PFMEAUids=new ArrayList(); +// public SavePermissions(TCSession session,TCComponentItem item) { +// // TODO Auto-generated constructor stub +// this.session = session; +// this.item = item; +// } +// +// public void insertData() { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// ResultSet result = null; +// ResultSet resultSet = null; +// InputStream input = null; +// try { +// properties = TMomMethodUtil.getPermissionsBomPropertys(session, item); +// String itemUid = item.getUid(); +// //获取工艺下的控制计划和PFMEA对象 +// TCComponent[] referenceTarget= item.getRelatedComponents("IMAN_reference"); +// List referenceTargetList = new ArrayList(); +// for (int i = 0; i < referenceTarget.length; i++) { +// //获取控制计划对象 +// if(referenceTarget[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// TCComponent[] ControlRevisions=referenceTarget[i].getReferenceListProperty("revision_list"); +// for(int j=0;j= 0) +// { +// TCComponent[] PFMEAUidsRevisions=referenceTarget[i].getReferenceListProperty("revision_list"); +// for(int j=0;j rowList = new ArrayList(); +// rowList.add(rs.getString("RB3_MEOPID") == null ? "" : rs.getString("RB3_MEOPID"));//如果数据库是null值就赋值为"",不然下面与""进行equals比较会出问题 +// rowList.add(rs.getString("RB3_GYBH") == null ? "" : rs.getString("RB3_GYBH")); +// rowList.add(rs.getString("RB3_GCMC") == null ? "" : rs.getString("RB3_GCMC")); +// rowList.add(rs.getString("RB3_GXH") == null ? "" : rs.getString("RB3_GXH")); +// dataList.add(rowList); +// } +// if (dataList == null || dataList.size() == 0) { +// //这里是如果第一次工艺下没一个工序,就执行这里插入工序。与下面有区别 +// for (int j = 0; j < properties.size(); j++) { +// // 插入到权限表 +// String insertSQL = pro.getProperty("INSERTPERMISSIONS"); +// // 插入工序到权限表 +// SqlUtilT.getTCConnection(); +// SqlUtilT.write(new String[] { +// UUID.randomUUID().toString().replace("-", ""), +// itemUid, properties.get(j).get(0), +// properties.get(j).get(1), properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).split("/")[0] : properties.get(j).get(2), +// "", "", "", "",properties.get(j).get(3) }, insertSQL); +// } +// } else { +// // 修改表中相应的工序名称 +// for (int i = 0; i < dataList.size(); i++) { +// for (int j = 0; j < properties.size(); j++) { +// //工序相同,如果工序编号,名称,工序号有改动时会修改permissions。也可以把&&后面的条件去除,则permissions上和properties上都有的工序就会去修改permissions +// //&& (!(dataList.get(i).get(1) == properties.get(j).get(1)) +// //|| !dataList.get(i).get(2).equals(properties.get(j).get(2)) +// //||!dataList.get(i).get(3).equals(properties.get(j).get(3))) +// if (dataList.get(i).get(0).equals(properties.get(j).get(0)) +// && (!(dataList.get(i).get(1).equals(properties.get(j).get(1))) +// || !dataList.get(i).get(2).equals(properties.get(j).get(2)) +// ||!dataList.get(i).get(3).equals(properties.get(j).get(3)))) { +// String updateSQL = String.format( +// pro.getProperty("UPDATEPERMISSIONS"), +// itemUid, dataList.get(i).get(0)); +// System.out.print(i+"+++="+j); +// SqlUtilT.getTCConnection(); +// SqlUtilT.update(new String[] { +// properties.get(j).get(1), +// properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).split("/")[0] : properties.get(j).get(2) , +// properties.get(j).get(3) }, updateSQL); +// +// } +// } +// } +// // 添加工序 +// // 查询数据库中的数据 +// result = SqlUtilT.read(sql); +// List indexList = new ArrayList(); +// while (result.next()) { +// indexList.add(result.getString("RB3_MEOPID")); +// } +// for (int i = 0; i < properties.size(); i++) { +// //这里是已有部分工序,中途要插入工序则执行这里 +// if (!indexList.contains(properties.get(i).get(0))) { +// String insertSQL = pro +// .getProperty("INSERTPERMISSIONS"); +// // 插入工序到权限表 +// SqlUtilT.getTCConnection(); +// SqlUtilT.write(new String[] { +// UUID.randomUUID().toString().replace("-", ""), +// itemUid, properties.get(i).get(0), +// properties.get(i).get(1), +// properties.get(i).get(2).indexOf("/") >=0 ? properties.get(i).get(2).split("/")[0] : properties.get(i).get(2), +// "", "", "", "",properties.get(i).get(3) }, +// insertSQL); +// } +// } +// // 删除表中相应的工序 +// StringBuffer sb = new StringBuffer(); +// sb.append("("); +// //sb获取的是先工艺下所有的工序 +// for (int i = 0; i < properties.size(); i++) { +// sb.append("\'" + properties.get(i).get(0) + "\',"); +// } +// // 获取数据库连接 +// String selectSql = String +// .format(pro.getProperty("BOMCHECKSAVESELECTPERMISSIONS2"), +// itemUid, +// sb.toString().substring(0, sb.length() - 1) +// + ")");//将permissions中有,但是properties中没有的工序提取出来。即查询工艺下所有的工序,将不再sb数组中的工序查询出来 +// resultSet = SqlUtilT.read(selectSql); +// List deleteList = new ArrayList(); +// while (resultSet.next()) { +// deleteList.add(resultSet.getString("RB3_MEOPID")); +// } +// if (deleteList != null && deleteList.size() > 0) { +// for (int i = 0; i < deleteList.size(); i++) { +// String deleteSQL = String.format( +// pro.getProperty("DELETEPERMISSIONS"), deleteList.get(i), +// itemUid); +// SqlUtilT.getTCConnection(); +// SqlUtilT.delete(deleteSQL); +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } finally { +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// if (result != null) { +// SqlUtilT.free(result); +// } +// if (resultSet != null) { +// SqlUtilT.free(resultSet); +// } +// if (input != null) { +// try { +// input.close(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// SqlUtilT.freeAll(); +// } +// +// //++++++修改控制计划和PFMEA数据的编号 +// //控制计划 +// if(controlUids!=null&&controlUids.size()>0) { +// for(int j=0;j property=properties.get(i); +// String updateSql = String +// .format(updateSql = "UPDATE RB3_CONTROLPLAN SET NO=? " +// + "WHERE RB3_MEOPID = \'%s\'and RB3_GCMC = \'%s\'and REVISIONUID = \'%s\'", +// property.get(0),property.get(2),controlUid); +// SqlUtilT.getTCConnection(); +// SqlUtilT.write(new String[] {property.get(1)},updateSql); +// } +// } +// } +// +// //PFMEA +// if(PFMEAUids!=null&&PFMEAUids.size()>0) { +// for(int j=0;j property=properties.get(i); +// String updateSql = String +// .format(updateSql = "UPDATE RB3_PFMEA SET NO=? " +// + "WHERE RB3_MEOPID = \'%s\' and REVISIONID = \'%s\'", +// property.get(0),PFMEAUid); +// SqlUtilT.getTCConnection(); +// SqlUtilT.write(new String[] {property.get(1)},updateSql); +// } +// } +// } +// +// +// //+++++++ +// +// } +//} diff --git a/src/com/connor/renben/process/plm/util/SavePfmea.java b/src/com/connor/renben/process/plm/util/SavePfmea.java new file mode 100644 index 0000000..ccfa9ff --- /dev/null +++ b/src/com/connor/renben/process/plm/util/SavePfmea.java @@ -0,0 +1,212 @@ +//package com.connor.renben.process.plm.util; +// +//import java.io.BufferedInputStream; +//import java.io.IOException; +//import java.io.InputStream; +//import java.sql.ResultSet; +//import java.util.ArrayList; +//import java.util.List; +//import java.util.Properties; +//import java.util.UUID; +// +//import com.connor.renben.process.plm.sql.util.SqlUtilT; +//import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentItem; +//import com.teamcenter.rac.kernel.TCSession; +// +///** +// * 保存数据到PFMEA表 +// * @author Administrator +// * +// */ +//public class SavePfmea { +// +// private TCSession session; +// private TCComponentItem item; +// private InterfaceAIFComponent comp; +// private List> properties = new ArrayList>(); +// private List> dataList = new ArrayList>();// 表格中的数据 +// +// public SavePfmea(TCSession session,TCComponentItem item,InterfaceAIFComponent comp) { +// // TODO Auto-generated constructor stub +// this.session = session; +// this.item = item; +// this.comp=comp; +// } +// +// public void insertData() { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// ResultSet result = null; +// ResultSet resultSet = null; +// InputStream input = null; +// try { +// properties = TMomMethodUtil.getPFMEABomPropertys(session, item); +// String itemUid = item.getUid(); +// //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List kzjhList = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// kzjhList.add((TCComponentItem)kzjh[i]); +// } +// } +// input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// Properties pro = new Properties(); +// pro.load(input); +// // 查询数据库中的数据 +// SqlUtilT.getTCConnection(); +// String sql = String.format(pro.getProperty("BOMCHECKSAVESELECTPFMEA"), +// itemUid, "检验(%"); +// rs = SqlUtilT.read(sql); +// while (rs.next()) { +// List rowList = new ArrayList(); +// rowList.add(rs.getString("RB3_MEOPID") == null ? "" : rs.getString("RB3_MEOPID")); +// rowList.add(rs.getString("RB3_STATION")); +// dataList.add(rowList); +// } +// if (dataList == null || dataList.size() == 0) { +// for (int j = 0; j < properties.size(); j++) { +// // 插入到PFMEA表 +// SqlUtilT.getTCConnection(); +// String insertPFMEA = pro.getProperty("INSERTPFMEA"); +// // 插入PFMEA表 +//// SqlUtilT.write(new String[] { +//// UUID.randomUUID().toString().replace("-", ""), +//// itemUid, properties.get(j).get(0), +//// properties.get(j).get(1), +//// properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2), +//// "", "", "", "", "", "", "", "", "", "", "", "", "", +//// "", "", "", "", "", "", "", "", "", "", "", "", "", +//// "" ,"","","","","","","","",comp.getUid()}, insertPFMEA); +// //+++ +// SqlUtilT.getTCConnection(); +// SqlUtilT.write(new String[] { +// UUID.randomUUID().toString().replace("-", ""), +// itemUid, properties.get(j).get(0), "","","", +// properties.get(j).get(1)+(properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2)), "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", "","","","","","","","","" ,comp.getUid(),properties.get(j).get(4)}, +// insertPFMEA); +// //+++ +// } +// } +// else { +//// //修改后注释的———————— +//// // 修改表中相应的工序名称 +//// for (int i = 0; i < dataList.size(); i++) { +//// for (int j = 0; j < properties.size(); j++) { +//// String station=properties.get(j).get(1)+ +//// (properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2)); +//// if (dataList.get(i).get(0).equals(properties.get(j).get(0))&&!dataList.get(i).get(1).equals(station) ) { +//// String updatePFMEA = String.format( +//// pro.getProperty("UPDATEPFMEA"), itemUid, +//// dataList.get(i).get(0)); +////// // 更新PFMEA +////// SqlUtilT.update(new String[] { +////// properties.get(j).get(1), +////// properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2) }, updatePFMEA); +//// //+++ +//// // 更新PFMEA +//// SqlUtilT.update(new String[] { +//// properties.get(j).get(1)+ +//// (properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2)) }, updatePFMEA); +//// //+++ +//// } +//// } +//// } +//// //———————— +// +// // 添加工序 +// // 查询数据库中的数据 +// result = SqlUtilT.read(sql); +// List indexList = new ArrayList(); +// while (result.next()) { +// indexList.add(result.getString("RB3_MEOPID")); +// } +// for (int i = 0; i < properties.size(); i++) { +// if (!indexList.contains(properties.get(i).get(0))) { +// // 插入到PFMEA表 +// String insertPFMEA = pro.getProperty("INSERTPFMEA"); +// // 插入PFMEA表 +//// SqlUtilT.write(new String[] { +//// UUID.randomUUID().toString().replace("-", ""), +//// itemUid, properties.get(i).get(0), +//// properties.get(i).get(1), +//// properties.get(i).get(2).indexOf("/") >=0 ? properties.get(i).get(2).replace("/", "\n") : properties.get(i).get(2), "", "", "", "", "", +//// "", "", "", "", "", "", "", "", "", "", "", "", +//// "", "", "", "", "", "", "", "", "", "","","","","","","","","",comp.getUid() }, +//// insertPFMEA); +// //+++ +// SqlUtilT.getTCConnection(); +// SqlUtilT.write(new String[] { +// UUID.randomUUID().toString().replace("-", ""), +// itemUid, properties.get(i).get(0), "","", "", +// properties.get(i).get(1)+(properties.get(i).get(2).indexOf("/") >=0 ? properties.get(i).get(2).replace("/", "\n") : properties.get(i).get(2)), "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", "","","","","","","","","",comp.getUid(),properties.get(i).get(4) }, +// insertPFMEA); +// //+++ +// +// } +// } +// // 删除表中相应的工序 +// StringBuffer sb = new StringBuffer(); +// sb.append("("); +// if(properties.size()>0) { +// for (int i = 0; i < properties.size(); i++) { +// sb.append("\'" + properties.get(i).get(0) + "\',"); +// } +// }else { +// sb.append("\'" +"0"+ "\',");//如果没一个工序类,就直接全清空 +// } +// // 获取数据库连接 +// SqlUtilT.getTCConnection(); +// String selectSql = String +// .format(pro.getProperty("BOMCHECKSAVESELECTPFMEA2"), +// itemUid, +// sb.toString().substring(0, sb.length() - 1) +// + ")"); +// resultSet = SqlUtilT.read(selectSql); +// List deleteList = new ArrayList(); +// while (resultSet.next()) { +// deleteList.add(resultSet.getString("RB3_MEOPID")); +// } +// if (deleteList != null && deleteList.size() > 0) { +// for (int i = 0; i < deleteList.size(); i++) { +// SqlUtilT.getTCConnection(); +// String deleteSQL = String.format( +// pro.getProperty("DELETEPFMEA"), deleteList.get(i), +// itemUid); +// SqlUtilT.delete(deleteSQL); +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } finally { +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// if (result != null) { +// SqlUtilT.free(result); +// } +// if (resultSet != null) { +// SqlUtilT.free(resultSet); +// } +// if (input != null) { +// try { +// input.close(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// SqlUtilT.freeAll(); +// } +// } +//} diff --git a/src/com/connor/renben/process/plm/util/TCGroupDialogTree.java b/src/com/connor/renben/process/plm/util/TCGroupDialogTree.java new file mode 100644 index 0000000..3e62abb --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TCGroupDialogTree.java @@ -0,0 +1,73 @@ +//package com.connor.renben.process.plm.util; +// +//import javax.swing.ImageIcon; +//import javax.swing.JTree; +//import javax.swing.tree.DefaultMutableTreeNode; +//import javax.swing.tree.DefaultTreeCellRenderer; +// +//import com.connor.renben.process.plm.bean.TMomUserBean; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentGroup; +//import com.teamcenter.rac.kernel.TCComponentGroupType; +//import com.teamcenter.rac.kernel.TCComponentRole; +//import com.teamcenter.rac.kernel.TCException; +//import com.teamcenter.rac.kernel.TCSession; +// +//public class TCGroupDialogTree { +// +// public void getUsers(DefaultMutableTreeNode node, TCComponent comp, +// TCComponent parent) { +// try { +// if (comp instanceof TCComponentGroup) { +// TCComponent[] comps = ((TCComponentGroup) comp) +// .getRolesAndGroups(); +// for (int i = 0; i < comps.length; i++) { +// TMomUserBean bean = new TMomUserBean(comps[i], comp); +// DefaultMutableTreeNode node1 = new DefaultMutableTreeNode( +// bean); +// node.add(node1); +// getUsers(node1, comps[i], comp); +// } +// } else if (comp instanceof TCComponentRole) { +// TCComponent[] comps = ((TCComponentRole) comp) +// .getUsers((TCComponentGroup) parent); +// for (int i = 0; i < comps.length; i++) { +// TMomUserBean bean = new TMomUserBean(comps[i], comp); +// DefaultMutableTreeNode node1 = new DefaultMutableTreeNode( +// bean); +// node.add(node1); +// } +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// +// public JTree getTcOrgTree(TCSession session, String goupFullName) { +// JTree tree = new JTree(); +// +// try { +// TCComponentGroupType type = ((TCComponentGroupType) session +// .getTypeComponent("Group")); +// TCComponentGroup group = type.find("NBTM"); +// TMomUserBean bean = new TMomUserBean(group, null); +// DefaultMutableTreeNode node1 = new DefaultMutableTreeNode(bean); +// getUsers(node1, group, null); +// tree = new JTree(node1); +// tree.setRowHeight(20); +// DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) tree +// .getCellRenderer(); +// cellRenderer.setLeafIcon(new ImageIcon("icons\\person_16.png")); +// cellRenderer.setOpenIcon(new ImageIcon("icons\\role_16.png")); +// cellRenderer.setClosedIcon(new ImageIcon("icons\\group_16.png")); +// +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// +// return tree; +// } +// +//} diff --git a/src/com/connor/renben/process/plm/util/TMomFinalUtil.java b/src/com/connor/renben/process/plm/util/TMomFinalUtil.java new file mode 100644 index 0000000..c9fcad0 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TMomFinalUtil.java @@ -0,0 +1,106 @@ +package com.connor.renben.process.plm.util; + +public class TMomFinalUtil { + // ---------------ALL---------------------------------------------- + public static final String PROCESS_MODEL_FILE = "PROCESS_MODEL_FILE";// 工艺模板文件 + // ---------------TMom001---------------------------------------------- + public static final int CX_INSTRUCTION = 0;// 成形作业指导书代号 + public static final int ZX_INSTRUCTION = 1;// 整形作业指导书代号 + public static final int SJ_INSTRUCTION = 2;// 烧结作业指导书代号 + public static final int PS_INSTRUCTION = 3;// 喷砂作业指导书代号 + public static final int GS_INSTRUCTION = 4;// 光饰作业指导书代号 + public static final int ST_INSTRUCTION = 5;// ST处理作业指导书代号 + + public static final int ELDECRCL_INSTRUCTION = 6;// Eldec热处理工艺指导书代号 + public static final int BZDXMJ_INSTRUCTION = 7;// 半自动修毛机工艺指导书代号 + public static final int GSJ_INSTRUCTION = 8;// 攻丝机工艺指导书 + public static final int JJG_INSTRUCTION = 9;// 机加工工艺指导书代号 + public static final int PTRCL_INSTRUCTION = 10;// 普通热处理工艺指导书代号 + public static final int TZ_INSTRUCTION = 11;// 台钻工艺指导书代号 + public static final int TGSXMJ_INSTRUCTION = 12;// 通过式修毛机工艺指导书代号 + public static final int TYMC_INSTRUCTION = 13;// 通用磨床工艺指导书代号 + public static final int WXM_INSTRUCTION = 14;// 无心磨工艺指导书代号 + public static final int YZ_INSTRUCTION = 15;// 压装工艺指导书代号 + public static final int TS_INSTRUCTION = 16;//探伤作业指导书 + public static final int CC_INSTRUCTION = 9;//车床工艺指导书 + public static final int JGZX_INSTRUCTION = 9;//加工中心工艺指导书 + + public static final int WG_INSTRUCTION = 17;//外观作业指导书 + + + // ---------------TMom002---------------------------------------------- + public static final int GY_CODE = 0;// 工艺代号 + public static final int HISGY_CODE = 2;// 历史工艺代号 + public static final int GX_CODE = 1;// 工序代号 + public static final int GYTZ_CODE = 3;//工艺图纸代号 + public static final int BZGX_CODE = 4;// 工序代号 + + public static final String GY_TYPE_DIS = "工艺";// 工艺类型 + public static final String GY_TYPE = "MEProcess"; + + public static final String HISGY_TYPE_DIS = "工艺";// 工艺类型 + public static final String HISGY_TYPE = "MEProcess"; + + public static final String GX_TYPE_DIS = "工序";// 工序类型 + public static final String GX_TYPE = "MEOP"; + + public static final String GYTZ_TYPE = "RB3_TEdrawing";//工艺图纸类型 + public static final String GYTZ_TYPE_DIS = "工艺图纸"; + + public static final String GY_ITEM_NAMES = "GY_ITEM_NAMES";// 工艺对象名称下拉列表 + public static final String GX_ITEM_NAMES = "GX_ITEM_NAMES";// 工序对象名称下拉列表 + + // ---------------TMom014---------------------------------------------- + public static final int CXSJTY_CHECKTABLE = 0; //成形首检调试记录表(通用) 烧结首件 200 AjQtFS$T4iZo5B 工序质量检查表(烧结) + public static final int CXSJCNCZY_CHECKTABLE = 0; //成形首检调试记录表(CNC专用) + public static final int CXGCJ_CHECKTABLE = 1; //成形工序过程自检记录表(操作工) 整形工序过程自检记录表(操作工) 101 + public static final int CXMJ_CHECKTABLE = 2; //成形末件记录表 整形末件记录表 102 + public static final int CXXJ_CHECKTABLE = 3; //成形工序巡检检查表 整形工序巡检检查表 103 + public static final int ZX_CHECKTABLE = 4; //精整工序产品批量生产记录单(批准单) + public static final int JJGSJ_CHECKTABLE = 5; //机加工科产品首件检查表 + public static final int JJGGCJ_CHECKTABLE = 6; //机加工科产品过程质量检查表 + public static final int JJGMJ_CHECKTABLE = 7; //机加工科产品末件检查表 + public static final int MKSJ_CHECKTABLE = 8; //盲孔感应淬火批次首件批准单 + public static final int MKGCJ_CHECKTABLE = 9; //盲孔感应淬火过程检验记录表 + public static final int MKMJ_CHECKTABLE = 10;//盲孔感应淬火批次末件记录单 + public static final int GXZL_CHECKTABLE = 11;//工序质量检查表-按时间 + public static final int ZZ_CHECKTABLE = 12;//最终检查表 + public static final int CPZL_CHECKTABLE = 13;//产品质量检查表 + public static final int JJGHDSJ_CHECKTABLE = 14;//机加工换刀首检验检查表 + public static final int JJGHDMJ_CHECKTABLE = 15;//机加工换刀末检验检查表 + public static final int GXZLPC_CHECKTABLE = 16;//工序质量检查表-按批次 + + + // ---------------TMom017---------------------------------------------- + public static final String BZFS_COMBOBOX_VALUES = "BZFS_COMBOBOX_VALUES"; //包装方式下拉菜单 + public static final String QYFS_COMBOBOX_VALUES = "QYFS_COMBOBOX_VALUES"; //油方式下拉菜单 + public static final String OUTERBOX_COMBOBOX_VALUESS = "OUTERBOX_COMBOBOX_VALUESS";//外箱标签下拉菜单 + public static final String STORAGETRAY_COMBOBOX_VALUES = "STORAGETRAY_COMBOBOX_VALUES";//入库托盘下拉菜单 + public static final String CARRIAGEPACK_COMBOBOX_VALUES = "CARRIAGEPACK_COMBOBOX_VALUES";//运输包装类型下拉菜单 + public static final String PACKAGING_COMBOBOX_VALUES = "PACKAGING_COMBOBOX_VALUES";//打包方式下拉列表框 + public static final String PALLETSPEC_COMBOBOX_VALUES = "PALLETSPEC_COMBOBOX_VALUES";//托盘规格下拉列表框 + public static final String METHODSREINFORCEMENT_COMBOBOX_VALUES = "METHODSREINFORCEMENT_COMBOBOX_VALUES";//加固方式下拉列表框 + + //---------------TMom019----------------------------------------------- + //public static final int AIXING_CONTROL = 0;// 爱信控制计划代号 + public static final int AIXING_CHINESE_CONTROL = 0;// 爱信中文控制计划代号 + public static final int AIXING_ENGLISH_CONTROL = 1;// 爱信英文控制计划代号 + public static final int AIXING_CHINESE_ENGLISH_CONTROL = 2;// 爱信中英文控制计划代号 + //public static final int BOGEHUALAEN_CONTROL = 1;// 英文博格华纳控制计划代号 + public static final int BOGEHUALAEN_CHINESE_CONTROL = 3;// 博格华纳中文控制计划代号 + public static final int BOGEHUALAEN_ENGLISH_CONTROL = 4;// 博格华纳英文控制计划代号 + public static final int BOGEHUALAEN_CHINESE_ENGLISH_CONTROL = 5;// 博格华纳中英文控制计划代号 + //public static final int BOGEHUALAZH_CONTROL = 2;// 中午博格华纳控制计划代号 + //public static final int MAIGELA_CONTROL = 3;// 麦格纳控制计划代号 + public static final int MAIGELA_CHINESE_CONTROL = 6;// 麦格纳中文控制计划代号 + public static final int MAIGELA_ENGLISH_CONTROL = 7;// 麦格纳英文控制计划代号 + public static final int MAIGELA_CHINESE_ENGLISH_CONTROL = 8;// 麦格纳中英文控制计划代号 + + public static final int NBTM_CHINESE_CONTROL = 9;//东睦中文控制计划代号 + public static final int NBTM_ENGLISH_CONTROL = 10;// 东睦英文控制计划代号 + public static final int NBTM_CHINESE_ENGLISH_CONTROL = 11;// 东睦中英文控制计划代号 + + + + +} diff --git a/src/com/connor/renben/process/plm/util/TMomMethodUtil.java b/src/com/connor/renben/process/plm/util/TMomMethodUtil.java new file mode 100644 index 0000000..3945063 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TMomMethodUtil.java @@ -0,0 +1,1486 @@ +//package com.connor.renben.process.plm.util; +// +//import java.io.File; +//import java.io.IOException; +//import java.text.DecimalFormat; +//import java.text.ParseException; +//import java.text.SimpleDateFormat; +//import java.util.ArrayList; +//import java.util.Date; +//import java.util.Iterator; +//import java.util.List; +//import java.util.Map; +//import java.util.regex.Matcher; +//import java.util.regex.Pattern; +// +//import com.connor.renben.process.plm.bean.ControlPlanComboBoxBean; +//import com.connor.renben.process.plm.bean.TMomItemBean; +//import com.connor.renben.process.plm.bean.TMomPropExplictBean; +//import com.teamcenter.rac.aif.AbstractAIFApplication; +//import com.teamcenter.rac.aif.kernel.AIFComponentContext; +//import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +//import com.teamcenter.rac.aifrcp.AIFUtility; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentBOMLine; +//import com.teamcenter.rac.kernel.TCComponentBOMWindow; +//import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +//import com.teamcenter.rac.kernel.TCComponentContextList; +//import com.teamcenter.rac.kernel.TCComponentDataset; +//import com.teamcenter.rac.kernel.TCComponentFolder; +//import com.teamcenter.rac.kernel.TCComponentICO; +//import com.teamcenter.rac.kernel.TCComponentItem; +//import com.teamcenter.rac.kernel.TCComponentItemRevision; +//import com.teamcenter.rac.kernel.TCComponentItemType; +//import com.teamcenter.rac.kernel.TCComponentProcess; +//import com.teamcenter.rac.kernel.TCComponentQuery; +//import com.teamcenter.rac.kernel.TCComponentQueryType; +//import com.teamcenter.rac.kernel.TCComponentTcFile; +//import com.teamcenter.rac.kernel.TCComponentType; +//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.TCQueryClause; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.kernel.TCTextService; +//import com.teamcenter.rac.kernel.TCUserService; +//import com.teamcenter.rac.kernel.ics.ICSProperty; +//import com.teamcenter.rac.util.FileUtility; +//import com.teamcenter.rac.util.MessageBox; +//import com.teamcenter.services.rac.core.DataManagementService; +// +//public class TMomMethodUtil { +// +// private static List> bomPropertyList = new ArrayList>(); +// +// public static void main(String[] args) { +// String str = "123|1234|123124"; +// System.out.println(str.split("\\|").length); +// } +// +// /** +// * 判断获取的对象是否全部为ITEM +// * +// * @param comps +// * 需要判断的目标对象 +// * @param isNotIgor +// * 是否需要忽略,如果TRUE 则不能忽略,如果FALSE 则可以忽略 +// * +// * @param isSameType +// * 是否要求是相同的类型,如果TRUE 要求必须是相同的类型 +// * @return +// */ +// public static List getItemList( +// InterfaceAIFComponent[] comps, Boolean isNotIgor, Boolean isSameType) { +// if (comps == null) { +// +// return null; +// } +// List itemList = new ArrayList(); +// String type = null; +// for (int i = 0; i < comps.length; i++) { +// if (comps[i] instanceof TCComponentItem) { +// if (isSameType) { +// if (type == null) { +// type = comps[i].getType(); +// } else if (!type.equals(comps[i].getType())) { +// return null; +// } +// } +// itemList.add((TCComponentItem) comps[i]); +// } else if (isNotIgor) { +// return null; +// } +// } +// return itemList; +// } +// +// /** +// * 获取模板文件 +// * @param session session +// * @param fileName 文件名 +// * @param Filetype 文件类型 +// * @return +// */ +// public static File getFile(TCSession session,String fileName,String Filetype) { +// // TODO Auto-generated method stub +// try { +// TCPreferenceService service = session.getPreferenceService(); +// String[] modelFiles = service.getStringValues(TMomFinalUtil.PROCESS_MODEL_FILE); +// if (modelFiles == null) +// { +// System.out.println("未找到首选项"); +// return null; +// } +// String puid = ""; +// for (int i = 0; i < modelFiles.length; i++) { +// if(modelFiles[i].split("-")[0].equals(fileName)) +// { +// puid = modelFiles[i].split("-")[1]; +// } +// } +// TCComponentItem fileItem = (TCComponentItem)session +// .stringToComponent(puid); +// TCComponentDataset dat = null; +// TCComponentItemRevision fileItemLastRev = getLastItemRevision(fileItem); +// TCComponent[] comps = fileItemLastRev.getReferenceListProperty("IMAN_specification"); +// System.out.println("count =" + comps == null ? "null" +// : comps.length); +// // 遍历TC_Attaches关系下的所有对象 +// for (TCComponent compt : comps) { +// // 获取对象类型 +// String type = compt.getType(); +// System.out.println(" TYPE = " + type); +// // 判断类型 +// if (type.equals(type)) { +// dat = (TCComponentDataset)compt; +// } +// } +// TCComponentTcFile[] tcFile = dat.getTcFiles(); +// if(tcFile != null && tcFile.length == 0) +// { +// System.out.println("未找到配置文件"); +// } +// else +// { +// return tcFile[0].getFmsFile(); +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// return null; +// } +// /** +// * 获取最新的已发布的版本 +// * @param item +// * @return +// */ +// public static TCComponentItemRevision getLastItemRevision(TCComponentItem item) { +// // TODO Auto-generated method stub +// try { +// TCComponentItemRevision[] items = item.getReleasedItemRevisions(); +// int revId = 0; +// TCComponentItemRevision itemRevision = null; +// for (int i = 0; i < items.length; i++) { +// String revisionId = items[i].getStringProperty("item_revision_id"); +// if(letterToNumber(revisionId) >= revId ) +// { +// itemRevision = items[i]; +// revId = letterToNumber(revisionId); +// } +// } +// return itemRevision; +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return null; +// } +// +// public static int letterToNumber(String letter) { +// int length = letter.length(); +// int num = 0; +// int number = 0; +// for(int i = 0; i < length; i++) { +// char ch = letter.charAt(length - i - 1); +// num = (int)(ch - 'A' + 1) ; +// num *= Math.pow(26, i); +// number += num; +// } +// return number; +// } +// +// /** +// * 获取选取的ITEM的目标的信息 +// * +// * @param itemList +// * @return +// */ +// public static List getTargetsMsg( +// List itemList) { +// if (itemList == null) { +// return null; +// } +// List beanList = new ArrayList<>(); +// try { +// TCProperty[][] props = TCComponentType.getTCPropertiesSet(itemList, +// new String[] { "object_name", // 名称 +// "object_type",// 类型 +// "uom_tag",// 单位 +// "item_id" }); +// for (int i = 0; i < props.length; i++) { +// +// TCProperty[] prop = props[i]; +// TMomItemBean bean = new TMomItemBean(); +// bean.setItem(itemList.get(i)); +// if (prop[0] != null) { +// bean.setName(prop[0].getDisplayValue()); +// } +// bean.setFolder(getParentFolder(itemList.get(i), bean.getName())); +// if (prop[1] != null) { +// bean.setTypeDis(prop[1].getDisplayValue()); +// bean.setType(itemList.get(i).getType()); +// } +// if (prop[2] != null) { +// bean.setUnit(prop[2].getDisplayableValue()); +// bean.setUnitDis(prop[2].getDisplayValue()); +// } +// if (prop[3] != null) { +// // bean.setUnit(prop[2].getDisplayableValue()); +// bean.setItemID(prop[3].getDisplayValue()); +// } +// beanList.add(bean); +// } +// } catch (TCException e) { +// e.printStackTrace(); +// } +// return beanList; +// } +// +// /** +// * 过滤掉所有不需要显示的属性的 +// * +// * @param session +// * @return +// */ +// public static List getExplictPropList(TCSession session) { +// List beanList = new ArrayList<>(); +// TCPreferenceService service = session.getPreferenceService(); +// String[] values = service.getStringArray( +// TCPreferenceService.TC_preference_site, +// "Cust_prop_explict_mapping"); +// if (values != null) { +// for (int i = 0; i < values.length; i++) { +// String[] types = values[i].split("\\|"); +// if (types.length != 2) { +// continue; +// } +// String[] props = types[1].split("\\;"); +// if (props.length == 0) { +// continue; +// } +// List list = new ArrayList<>(); +// for (String str : props) { +// list.add(str); +// } +// TMomPropExplictBean bean = new TMomPropExplictBean(); +// bean.setType(types[0]); +// bean.setPropList(list); +// beanList.add(bean); +// } +// } +// +// return beanList; +// } +// +// /** +// * 获取版本对象 +// * +// * @param comps +// * 需要判断的目标对象 +// * @param isNotIgor +// * 是否需要忽略,如果TRUE 则不能忽略,如果FALSE 则可以忽略 +// * +// * @param isSameType +// * 是否要求是相同的类型,如果TRUE 要求必须是相同的类型 +// * @return +// */ +// public static List getItemRevList( +// InterfaceAIFComponent[] comps, Boolean isNotIgor, Boolean isSameType) { +// if (comps == null) { +// +// return null; +// } +// List itemList = new ArrayList(); +// +// String type = null; +// for (int i = 0; i < comps.length; i++) { +// if (comps[i] instanceof TCComponentItemRevision) { +// +// if (isSameType) { +// if (type == null) { +// type = comps[i].getType(); +// } else if (!type.equals(comps[i].getType())) { +// return null; +// } +// } +// itemList.add((TCComponentItemRevision) comps[i]); +// } else if (isNotIgor) { +// return null; +// } +// } +// return itemList; +// } +// +// /** +// * 获取存放的文件夹 +// * +// * @param item +// * @param name +// * @return +// */ +// public static TCComponentFolder getParentFolder(TCComponentItem item, +// String name) { +// TCComponentFolder folder = null; +// try { +// AIFComponentContext[] comtexts = item.whereReferenced(); +// if (comtexts != null) { +// for (int i = 0; i < comtexts.length; i++) { +// if (comtexts[i].getComponent() instanceof TCComponentFolder) { +// String nameT = ((TCComponentFolder) comtexts[i] +// .getComponent()) +// .getStringProperty("object_name"); +// if (name.equals("工艺图纸") && nameT.equals("工艺图纸")) { +// folder = (TCComponentFolder) comtexts[i] +// .getComponent(); +// } +// else if(nameT.equals(name)) +// { +// folder = (TCComponentFolder) comtexts[i] +// .getComponent(); +// } +// } +// } +// } +// } catch (TCException e) { +// e.printStackTrace(); +// } +// return folder; +// } +// +// /** +// * 获取存在的ITEM的个数 +// * +// * @param session +// * 会话 +// * @param oldItemID +// * 旧编码 +// * @return +// */ +// public static Integer getItemCount(TCSession session, String oldItemID) { +// Integer count = 0; +// InterfaceAIFComponent[] comps = searchComponentsCollection(session, +// "Connor_TMom_Query_Item", new String[] { "item_id" }, +// new String[] { oldItemID }); +// if (comps == null) { +// return null; +// } +// count = comps.length; +// return count; +// } +// +// /** +// * 根据规则获取ID +// * +// * @param oldItemID +// * 旧的ID +// * @return 新的ID +// */ +// public static String getRuleItemID(TCSession session, String oldItemID, +// String typeID, int operateCode) { +// String newId = null; +// // 调用查询 Connor_TMom_Query_Item item_id +// // 添加规则 +// switch (operateCode) { +// case TMomFinalUtil.GY_CODE: +// newId = getGyRuleID(session, oldItemID); +// break; +// case TMomFinalUtil.HISGY_CODE: +// newId = getGyRuleID(session, oldItemID); +// break; +// case TMomFinalUtil.GX_CODE: +// newId = getGxRuleID(session, oldItemID); +// break; +// default: +// break; +// } +// return newId; +// } +// +//// /** +//// * 工艺生成新的ID +//// * +//// * @param oldItemID +//// * @return +//// */ +//// public static String getGyRuleID(TCSession session, String oldItemID) { +//// DecimalFormat df = new DecimalFormat("00"); +//// String newID = oldItemID + "_MEP01"; +//// Integer count = 0; +//// // String idTemp = +//// TCComponentItemType tccomponentitemtype; +//// try { +//// tccomponentitemtype = (TCComponentItemType) (session +//// .getTypeComponent("Item")); +//// +//// tccomponentitemtype.getNewID(); +//// int i = 1; +//// while (tccomponentitemtype.find(newID) != null) { +//// i++; +//// newID = oldItemID + "_MEP" + df.format(i); +//// } +//// } catch (TCException e) { +//// // TODO Auto-generated catch block +//// e.printStackTrace(); +//// } +//// return newID; +//// } +// /** +// * 工艺生成新的ID +// * +// * @param oldItemID +// * @return +// */ +// public static String getGyRuleID(TCSession session, String oldItemID) { +// DecimalFormat df = new DecimalFormat("000"); +// String newID = oldItemID + "_P001"; +// Integer count = 0; +// // String idTemp = +// TCComponentItemType tccomponentitemtype; +// try { +// tccomponentitemtype = (TCComponentItemType) (session +// .getTypeComponent("Item")); +// +// tccomponentitemtype.getNewID(); +// int i = 1; +// //setByPass(session,true); +// while (tccomponentitemtype.find(newID) != null) { +// i++; +// newID = oldItemID + "_P" + df.format(i); +// } +// // setByPass(session,false); +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return newID; +// } +// +//// /** +//// * 工序生成新ID +//// * +//// * @param oldItemID +//// * @return +//// */ +//// public static String getGxRuleID(TCSession session, String oldItemID) { +//// DecimalFormat df = new DecimalFormat("000"); +//// String newID = oldItemID.substring( +//// 0, +//// oldItemID.indexOf("_") > 0 ? oldItemID.indexOf("_") : oldItemID +//// .length()) +//// + "_MEOP001"; +//// Integer count = 0; +//// // String idTemp = +//// TCComponentItemType tccomponentitemtype; +//// try { +//// tccomponentitemtype = (TCComponentItemType) (session +//// .getTypeComponent("Item")); +//// int i = 0; +//// while (tccomponentitemtype.find(newID) != null) { +//// i++; +//// newID = oldItemID.substring(0, +//// oldItemID.indexOf("_") > 0 ? oldItemID.indexOf("_") +//// : oldItemID.length()) +//// + "_MEOP" + df.format(i); +//// } +//// } catch (TCException e) { +//// // TODO Auto-generated catch block +//// e.printStackTrace(); +//// } +//// return newID; +//// } +// +// /** +// * 工序生成新ID +// * +// * @param oldItemID +// * @return +// */ +// public static String getGxRuleID(TCSession session, String oldItemID) { +// // DecimalFormat df = new DecimalFormat("000"); +// // String newID = oldItemID.substring( +//// 0, +//// oldItemID.indexOf("_") > 0 ? oldItemID.indexOf("_") : oldItemID +//// .length()) +//// + "_MEOP001"; +// // Integer count = 0; +// // String idTemp = +// TCComponentItemType tccomponentitemtype; +// try { +// tccomponentitemtype = (TCComponentItemType) (session +// .getTypeComponent("MEOP")); +// +// return tccomponentitemtype.getNewID(); +// // int i = 0; +// // while (tccomponentitemtype.find(newID) != null) { +//// i++; +//// newID = oldItemID.substring(0, +//// oldItemID.indexOf("_") > 0 ? oldItemID.indexOf("_") +//// : oldItemID.length()) +//// + "_MEOP" + df.format(i); +// // } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return ""; +// } +// /** +// * 通过SOA创建ITEM对象 +// * +// * @param session +// * 会话 +// * @param itemID +// * 创建对象的ID +// * @param itemRev +// * 创建对象的版本 +// * @param itemType +// * 创建对象的类型 +// * @param itemName +// * 创建对象的名称 +// * @param itemDesc +// * 创建对象的描述 +// * @param unit +// * 创建对象的单位 +// * @param itemPropMap +// * 创建对象的ITEM属性 +// * @param itemRevPropMap +// * 创建对象的版本属性 +// * @param itemRevMasterPropMap +// * 创建对象的版本表单属性 +// */ +// public static TCComponentItem createNewItemSoa(TCSession session, +// String itemID, String itemRev, String itemType, String itemName, +// String itemDesc, String unit, Map itemPropMap, +// Map itemRevPropMap, +// Map itemRevMasterPropMap) { +// TCComponentItem newComp = null; +// try { +// DataManagementService datamanagementservice = DataManagementService +// .getService(session); +// com.teamcenter.services.rac.core._2006_03.DataManagement.CreateItemsResponse createitemsresponse = null; +// // 设置创建对象的主要属性 +// com.teamcenter.services.rac.core._2006_03.DataManagement.ItemProperties aitemproperties[] = new com.teamcenter.services.rac.core._2006_03.DataManagement.ItemProperties[1]; +// aitemproperties[0] = new com.teamcenter.services.rac.core._2006_03.DataManagement.ItemProperties(); +// aitemproperties[0].clientId = Integer.toString(1); +// aitemproperties[0].description = itemDesc; +// aitemproperties[0].itemId = itemID; +// aitemproperties[0].name = itemName; +// aitemproperties[0].revId = itemRev; +// aitemproperties[0].type = itemType; +// aitemproperties[0].uom = unit;// == null ? "" : uomComp.toString(); +// // 设置扩展属性 +// // com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes +// // extendedattributes[] = new +// // com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes[3]; +// ArrayList list = new ArrayList(); +// // 设置item对象的扩展属性 +// if (itemPropMap != null) { +// com.teamcenter.services.rac.core._2006_03.DataManagement.RevisionIds revids = null; +// com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributesItem = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); +// extendedattributesItem = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); +// extendedattributesItem.objectType = itemType; +// extendedattributesItem.attributes = itemPropMap; +// list.add(extendedattributesItem); +// } +// // 设置REV的扩展属性 +// if (itemRevPropMap != null) { +// com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributesRev = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); +// extendedattributesRev = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); +// extendedattributesRev.objectType = itemType + "Revision"; +// extendedattributesRev.attributes = itemRevPropMap; +// list.add(extendedattributesRev); +// } +// // 设置REVMASTER的扩展属性 +// if (itemRevMasterPropMap != null) { +// com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributesRevMaster = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); +// extendedattributesRevMaster = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); +// extendedattributesRevMaster.objectType = itemType +// + "RevisionMaster"; +// extendedattributesRevMaster.attributes = itemRevMasterPropMap; +// list.add(extendedattributesRevMaster); +// } +// // 添加扩展属性 +// if (list.size() != 0) { +// com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributes[] = null; +// extendedattributes = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes[list +// .size()]; +// for (int i = 0; i < list.size(); i++) { +// extendedattributes[i] = list.get(i); +// } +// aitemproperties[0].extendedAttributes = extendedattributes; +// } +// TCComponent tccomponent1 = null; +// String s1 = ""; +// createitemsresponse = datamanagementservice.createItems( +// aitemproperties, tccomponent1, s1); +// if (createitemsresponse.serviceData.sizeOfPartialErrors() == 0) { +// newComp = createitemsresponse.output[0].item; +// } +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// System.out.println("创建对象[item_id= " + itemID + " / rev =" + itemRev +// + " / name= " + itemName + "]失败"); +// } +// return newComp; +// } +// +// /** +// * 通过查询,查找符合条件的版本 +// * +// * @param session +// * 会话 +// * @param searchName +// * 查询名称 +// * @param keys +// * 查询关键字 +// * @param values +// * 查询值 +// * @return +// */ +// 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); +// if (query == null) { +// MessageBox.post("通过查询构建器" + searchName + "不存在", "错误", 1); +// return null; +// } +// 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(); +// TCQueryClause[] clauses = query.describe(); +// 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) { +// e.printStackTrace(); +// MessageBox.post("通过查询构建器" + searchName + "查询发生错误.", "错误", 1); +// } +// +// return result; +// } +// /** +// * 自定义文件名下载文件 +// * +// * @param comps +// * @return +// * @throws TCException +// * @throws IOException +// */ +// +// public static String downLoadFiles(TCComponent comp,String Titles,String URL,Boolean flag) { +// if (comp == null) { +// return ""; +// } +// String value = ""; +// String tempPath = System.getenv("TEMP"); +// // MessageBox.post(" tempPath = +// // "+tempPath,"INFO",MessageBox.INFORMATION); +// if (tempPath == null) { +// tempPath = ""; +// } else if (!tempPath.endsWith("\\")) { +// tempPath = tempPath + "\\"; +// } +// +// // MessageBox.post(" tempPath = "+tempPath,"INFO",MessageBox.INFORMATION); +// // MessageBox.post(" URL = "+URL,"INFO",MessageBox.INFORMATION); +// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); +// // for(TCComponent comp : comps){ +// try { +// if (comp instanceof TCComponentDataset) { +// TCComponentTcFile[] tcFiles = ((TCComponentDataset) comp) +// .getTcFiles(); +// File file = null; +// if (tcFiles != null && tcFiles.length != 0) { +// file = tcFiles[0].getFmsFile(); +// String fileName = file.getName(); +// String fileDix = fileName.substring( +// fileName.lastIndexOf("."), fileName.length()); +// if (flag == true) +// { +// if ((URL != "")&&(URL != " ")&&(URL != null)) +// { +// fileName = URL + Titles + fileDix; +// } +// else +// { +// fileName = tempPath + Titles + fileDix; +// } +// } +// else +// { +// fileName = tempPath + sdf.format(new Date()) + fileDix; +// } +// File dirFile = new File(fileName); +// FileUtility.copyFile(file, dirFile); +// +// return fileName; +// } +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// // } +// return value; +// } +// +// +// +// +// +// /** +// * 下载文件 +// * +// * @param comps +// * @return +// * @throws TCException +// * @throws IOException +// */ +// public static String downLoadFile(TCComponent comp) { +// if (comp == null) { +// return ""; +// } +// String value = ""; +// String tempPath = System.getenv("TEMP"); +// // MessageBox.post(" tempPath = +// // "+tempPath,"INFO",MessageBox.INFORMATION); +// if (tempPath == null) { +// tempPath = ""; +// } else if (!tempPath.endsWith("\\")) { +// tempPath = tempPath + "\\"; +// } +// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); +// // for(TCComponent comp : comps){ +// try { +// if (comp instanceof TCComponentDataset) { +// TCComponentTcFile[] tcFiles = ((TCComponentDataset) comp) +// .getTcFiles(); +// File file = null; +// if (tcFiles != null && tcFiles.length != 0) { +// file = tcFiles[0].getFmsFile(); +// String fileName = file.getName(); +// String fileDix = fileName.substring( +// fileName.lastIndexOf("."), fileName.length()); +// fileName = tempPath + sdf.format(new Date()) + fileDix; +// File dirFile = new File(fileName); +// FileUtility.copyFile(file, dirFile); +// +// return fileName; +// } +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// // } +// return value; +// } +// +// /*** +// * 获取首选项 +// * +// * @param session +// * 会话 +// * @param preferenceName +// * 首选项名称 +// * @return +// */ +// public static String[] getPreferenceValues(String preferenceName) { +// AbstractAIFApplication app = AIFUtility.getCurrentApplication(); +// TCSession session = (TCSession) app.getSession(); +// if (preferenceName == null || session == null) { +// System.out.println(""); +// return null; +// } +// String[] values = null; +// TCPreferenceService service = session.getPreferenceService(); +// values = service.getStringArray(TCPreferenceService.TC_preference_site, +// preferenceName); +// String[] resultValues = new String[values.length]; +// for (int i = 0; i < values.length; i++) { +// if(values[i].indexOf("\\n") >= 0) +// { +// resultValues[i] = values[i].replace("\\n", "\n"); +// } +// else +// { +// resultValues[i] = values[i]; +// } +// } +// return resultValues; +// } +// +// /** +// * 删除文件 +// * +// * @param filePathList +// * 文件地址 +// */ +// public static void deleteFile(List filePathList) { +// for (int i = 0; i < filePathList.size(); i++) { +// File file = new File(filePathList.get(i)); +// if (file.exists() && file.isFile()) { +// if (file.delete()) { +// System.out.println("文件" + filePathList.get(i) + "已删除!"); +// } +// } +// } +// } +// +// /** +// * 旁路 +// * +// * @param session +// * @param val +// * @throws TCException +// */ +// public static void setByPass(TCSession session, boolean val) +// throws TCException { +// +// TCUserService userservice = session.getUserService(); +// +// Object[] obj = new Object[1]; +// obj[0] = ""; +// if (val) { +// userservice.call("Connor_set_bypass", obj); +// } else { +// userservice.call("Connor_close_bypass", obj); +// } +// } +// /** +// * 转换合并单元格 +// * @param regionCell +// * @param row +// * @return +// */ +// public static String getCombineCell(Map regionCell, int row) { +// Iterator> it = regionCell.entrySet().iterator(); +// StringBuffer sb = new StringBuffer(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// StringBuffer rowSb = new StringBuffer(); +// StringBuffer columnSb = new StringBuffer(); +// for (int k = 0; k < entry.getKey().length; k++) { +// rowSb.append(entry.getKey()[k]); +// rowSb.append(","); +// } +// for (int k = 0; k < entry.getValue().length; k++) { +// columnSb.append(entry.getValue()[k]); +// columnSb.append(","); +// } +// if (entry.getKey()[0] == row) { +// sb.append(rowSb.substring(0, rowSb.length() - 1)+ "/"+ columnSb.substring(0,columnSb.length() - 1)+"-"); +// } +// } +// if(sb.length() > 0) +// { +// return sb.toString().substring(0, sb.length()-1); +// } +// else +// { +// return ""; +// } +// } +// +// /** +// * 通知流程 +// * +// * @param session +// * @param val +// * @throws TCException +// */ +// public static void setProcess(TCSession session, +// TCComponentProcess process, TCComponentUser user) +// throws TCException { +// +// TCUserService userservice = session.getUserService(); +// +// Object[] obj = new Object[2]; +// obj[0] = process; +// obj[1] = user; +// userservice.call("TMOM_meop_tongzhi", obj); +// } +// +// /** +// * 获取PFMEA BOM属性 +// */ +// public static List> getPFMEABomPropertys(TCSession session, TCComponentItem item) { +// // TODO Auto-generated method stub +// //获取BOM +// TCComponentBOMWindow bomWindow = null; +// bomPropertyList.clear(); +// try { +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session +// .getTypeComponent("BOMWindow"); +// bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, +// item.getLatestItemRevision(), null, null); +// //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List itme = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// itme.add((TCComponentItem)kzjh[i]); +// } +// } +// getBomPropertys(topBomLine, true); +// return bomPropertyList; +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// return null; +// } +//// public static List> getPFMEABomPropertys(TCSession session, TCComponentItem item) { +//// // TODO Auto-generated method stub +//// //获取BOM +//// TCComponentBOMWindow bomWindow = null; +//// try { +//// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session +//// .getTypeComponent("BOMWindow"); +//// bomWindow = bomWindowType.create(null); +//// TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, +//// item.getLatestItemRevision(), null, null); +//// //获取工艺下的控制计划对象 +//// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +//// List itme = new ArrayList(); +//// for (int i = 0; i < kzjh.length; i++) { +//// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +//// { +//// itme.add((TCComponentItem)kzjh[i]); +//// } +//// } +//// // 获取工序对象 +//// AIFComponentContext aif[] = topBomLine.getChildren(); +//// List> properties = new ArrayList>(); +//// for (int i = 0; i < aif.length; i++) { +//// TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] +//// .getComponent(); +//// if(subline.getStringProperty("RB3_is_hide") != null && subline.getStringProperty("RB3_is_hide").equals("true")) +//// { +//// continue; +//// } +//// List propertie = new ArrayList(); +//// propertie +//// .add(subline.getStringProperty("bl_indented_title") +//// .split("/")[0]); +//// propertie.add(subline.getStringProperty("bl_sequence_no")); +//// propertie +//// .add(subline +//// .getStringProperty("bl_item_object_name") == null ? "" +//// : subline +//// .getStringProperty("bl_item_object_name")); +//// //获取工序下的BOM +//// List equipmentNameList = new ArrayList(); +//// if(subline.getChildren().length>0) +//// { +//// for (int j = 0; j < subline.getChildren().length; j++) { +//// TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] +//// .getComponent(); +//// System.out.println(subChildrenline.getType()); +//// if(subChildrenline.getType().indexOf("Equipment") >= 0) +//// { +//// TCComponentICO[] icos = subChildrenline.getItem().getLatestItemRevision() +//// .getClassificationObjects(); +//// if (icos.length > 0) { +//// ICSProperty[] descriptions = icos[0] +//// .getICSProperties(true); +//// for (int k = 0; k < descriptions.length; k++) { +//// if (descriptions[k].getId() == 1004 && descriptions[k].getValue() != null +//// && !descriptions[k].getValue().equals("")) { +//// System.out.println(equipmentNameList.toString()); +//// if(!equipmentNameList.contains(descriptions[k].getValue())) +//// { +//// equipmentNameList.add(descriptions[k].getValue()); +//// } +//// System.out.println(equipmentNameList.toString()); +//// //sb.append(descriptions[k].getValue()+","); +//// +//// } +//// } +//// } +//// } +//// } +//// } +//// if(equipmentNameList.size() > 0) +//// { +//// propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); +//// } +//// else +//// { +//// propertie.add(""); +//// } +//// properties.add(propertie); +//// } +//// return properties; +//// } catch (Exception e) { +//// // TODO: handle exception +//// e.printStackTrace(); +//// } +//// return null; +//// } +// +// /** +// * 获取BOM属性 +// */ +// public static List> getBomPropertys(TCSession session, TCComponentItem item) { +// // TODO Auto-generated method stub +// bomPropertyList.clear(); +// //获取BOM +// TCComponentBOMWindow bomWindow = null; +// try { +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session +// .getTypeComponent("BOMWindow"); +// bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, +// item.getLatestItemRevision(), null, null); +// //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List itme = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// itme.add((TCComponentItem)kzjh[i]); +// } +// } +// getBomPropertys(topBomLine, false); +// return bomPropertyList; +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// return null; +// } +//// public static List> getBomPropertys(TCSession session, TCComponentItem item) { +//// // TODO Auto-generated method stub +//// //获取BOM +//// TCComponentBOMWindow bomWindow = null; +//// try { +//// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session +//// .getTypeComponent("BOMWindow"); +//// bomWindow = bomWindowType.create(null); +//// TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, +//// item.getLatestItemRevision(), null, null); +//// //获取工艺下的控制计划对象 +//// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +//// List itme = new ArrayList(); +//// for (int i = 0; i < kzjh.length; i++) { +//// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +//// { +//// itme.add((TCComponentItem)kzjh[i]); +//// } +//// } +//// // 获取工序对象 +//// AIFComponentContext aif[] = topBomLine.getChildren(); +//// List> properties = new ArrayList>(); +//// for (int i = 0; i < aif.length; i++) { +//// TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] +//// .getComponent(); +//// List propertie = new ArrayList(); +//// propertie +//// .add(subline.getStringProperty("bl_indented_title") +//// .split("/")[0]); +//// propertie.add(subline.getStringProperty("bl_sequence_no")); +//// propertie +//// .add(subline +//// .getStringProperty("bl_item_object_name") == null ? "" +//// : subline +//// .getStringProperty("bl_item_object_name")); +//// //获取工序下的BOM +//// List equipmentNameList = new ArrayList(); +//// if(subline.getChildren().length>0) +//// { +//// for (int j = 0; j < subline.getChildren().length; j++) { +//// TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] +//// .getComponent(); +//// System.out.println(subChildrenline.getType()); +//// if(subChildrenline.getType().indexOf("Equipment") >= 0) +//// { +//// TCComponentICO[] icos = subChildrenline.getItem().getLatestItemRevision() +//// .getClassificationObjects(); +//// if (icos.length > 0) { +//// ICSProperty[] descriptions = icos[0] +//// .getICSProperties(true); +//// for (int k = 0; k < descriptions.length; k++) { +//// if (descriptions[k].getId() == 1004 && descriptions[k].getValue() != null +//// && !descriptions[k].getValue().equals("")) { +//// System.out.println(equipmentNameList.toString()); +//// if(!equipmentNameList.contains(descriptions[k].getValue())) +//// { +//// equipmentNameList.add(descriptions[k].getValue()); +//// } +//// System.out.println(equipmentNameList.toString()); +//// //sb.append(descriptions[k].getValue()+","); +//// +//// } +//// } +//// } +//// } +//// } +//// } +//// if(equipmentNameList.size() > 0) +//// { +//// propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); +//// } +//// else +//// { +//// propertie.add(""); +//// } +//// properties.add(propertie); +//// } +//// return properties; +//// } catch (Exception e) { +//// // TODO: handle exception +//// e.printStackTrace(); +//// } +//// return null; +//// } +// /** +// * 获取插入到权限表的BOM行 +// * @param session +// * @param item +// * @return +// */ +// public static List> getPermissionsBomPropertys(TCSession session, TCComponentItem item) { +// // TODO Auto-generated method stub +// //获取BOM +// TCComponentBOMWindow bomWindow = null; +// +// try { +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session +// .getTypeComponent("BOMWindow"); +// bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, +// item.getLatestItemRevision(), null, null); +// //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List itme = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// itme.add((TCComponentItem)kzjh[i]); +// } +// } +// // 获取工序对象 +// AIFComponentContext aif[] = topBomLine.getChildren(); +// List> properties = new ArrayList>(); +// for (int i = 0; i < aif.length; i++) { +// if(((TCComponentBOMLine)aif[i].getComponent()).getItem().getType().equals("MEProcess")) +// { +// continue; +// } +// TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] +// .getComponent(); +// List propertie = new ArrayList(); +// propertie +// .add(subline.getStringProperty("bl_indented_title") +// .split("/")[0]); +// propertie.add(subline.getStringProperty("bl_sequence_no")); +// +// String objectName = subline.getStringProperty("bl_item_object_name") == null ? "" +// : subline.getStringProperty("bl_item_object_name"); +// if(objectName.indexOf("/") >= 0) +// { +// propertie.add(objectName.split("/")[0]); +// } +// else +// { +// propertie.add(objectName); +// } +// //+++获取工序号 +// propertie.add(subline.getStringProperty("RB3_GXH")); +// //+++ +// //获取工序下的BOM +// List equipmentNameList = new ArrayList(); +// if(subline.getChildren().length>0) +// { +// for (int j = 0; j < subline.getChildren().length; j++) { +// TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] +// .getComponent(); +// System.out.println(subChildrenline.getType()); +// //if(subChildrenline.getType().indexOf("Equipment") >= 0) +// //{ +// equipmentNameList.add(subChildrenline.getItem().getStringProperty("item_id")); +//// TCComponentICO[] icos = subChildrenline.getItem().getLatestItemRevision() +//// .getClassificationObjects(); +//// +//// if (icos.length > 0) { +//// ICSProperty[] descriptions = icos[0] +//// .getICSProperties(true); +//// for (int k = 0; k < descriptions.length; k++) { +//// if (descriptions[k].getId() == 1004 && descriptions[k].getValue() != null +//// && !descriptions[k].getValue().equals("")) { +//// System.out.println(equipmentNameList.toString()); +//// if(!equipmentNameList.contains(descriptions[k].getValue())) +//// { +//// equipmentNameList.add(descriptions[k].getValue()); +//// } +//// System.out.println(equipmentNameList.toString()); +//// //sb.append(descriptions[k].getValue()+","); +//// +//// } +//// } +//// } +// //} +// } +// } +// if(equipmentNameList.size() > 0) +// { +// propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); +// } +// else +// { +// propertie.add(""); +// } +// properties.add(propertie); +// } +// return properties; +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// return null; +// } +// +// /** +// * 获取BOM信息 +// * @param meprocess 工艺BOMLINE +// * @param isMeop 是否是PFEMA +// * +// */ +// public static void getBomPropertys(TCComponentBOMLine meprocessBomLine, boolean isPFEMA) +// { +// try { +// //获取工艺下的BOM +// AIFComponentContext aif[] = meprocessBomLine.getChildren(); +// for (int i = 0; i < aif.length; i++) { +// if(aif[i]==null) {//防止 +// continue; +// } +// TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] +// .getComponent(); +// if(subline==null) { +// continue; +// } +// TCComponentItem item = subline.getItem(); +// //判断是否是工艺 +// if(item.getType().equals("MEProcess")) +// { +// getBomPropertys(subline, isPFEMA); +// } +// else if(item.getType().equals("MEOP")) +// { +// List propertie = new ArrayList(); +// //String ss = subline.getStringProperty("bl_indented_title"); +// propertie +// .add(subline.getStringProperty("bl_indented_title") +// .split("/")[0]); +// //控制计划中的零件/工艺编号改为工序号 +// //propertie.add(subline.getStringProperty("bl_sequence_no")); +// propertie.add(subline.getStringProperty("RB3_GXH")==null ? "": +// subline.getStringProperty("RB3_GXH")); +// propertie +// .add(subline +// .getStringProperty("bl_item_object_name") == null ? "" +// : subline +// .getStringProperty("bl_item_object_name")); +// +// //获取工序下的BOM的资源,机器设备。PFMEA跳过 +// if(isPFEMA) +// { +// propertie.add(""); +// }else { +// List equipmentNameList = new ArrayList(); +// if(subline.getChildren().length>0) +// { +// for (int j = 0; j < subline.getChildren().length; j++) { +// TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] +// .getComponent(); +// if(subChildrenline.toString().equals("<<无法读取>>")&&subChildrenline!=null) {//防止工艺资源出错,无权限读取 +// continue; +// } +// System.out.println(subChildrenline.getType()); +// String ClassID=subChildrenline.getItemRevision().getClassificationClass(); +// if(ClassID!=null&&!ClassID.equals("")&&ClassID.length()>2) { +// if(ClassID.substring(0,2).equals("15")) { +// equipmentNameList.add(subChildrenline.getItem().getStringProperty("object_name")); +// } +// } +// +// } +// } +// if(equipmentNameList.size() > 0) +// { +// propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); +// } +// else +// { +// propertie.add(""); +// } +// } +// propertie.add(subline.getStringProperty("bl_sequence_no")); +// bomPropertyList.add(propertie); +// } +// } +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// /*** +// * 根据正则表达式提取括号中的内容 +// * @param value +// * @return +// */ +// public static List getListByRegular(String value) +// { +// List resultList = new ArrayList(); +// Pattern p = Pattern.compile("(\\[[^\\]]*\\])"); +// Matcher m = p.matcher(value); +// while(m.find()) +// { +// resultList.add(m.group().substring(1, m.group().length() - 1)); +// } +// return resultList; +// } +// +// public static int getDays(String dateStr1, String dateStr2, String dateFormat) { +// SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat); +// Date date1 = null; +// Date date2 = null; +// try { +// date1 = simpleDateFormat.parse(dateStr1); +// date2 = simpleDateFormat.parse(dateStr2); +// } catch (ParseException e) { +// e.printStackTrace(); +// } +// +// String year1 = String.format("%tY", date1); +// String mon1 = String.format("%tm", date1); +// String day1 = String.format("%td", date1); +// int y1 = Integer.valueOf(year1); +// int m1 = Integer.valueOf(mon1); +// int d1 = Integer.valueOf(day1); +// int days1 = getRecentYearDays(y1, m1, d1); +// System.out.println(days1); +// +// String year2 = String.format("%tY", date2); +// String mon2 = String.format("%tm", date2); +// String day2 = String.format("%td", date2); +// int y2 = Integer.valueOf(year2); +// int m2 = Integer.valueOf(mon2); +// int d2 = Integer.valueOf(day2); +// int days2 = getRecentYearDays(y2, m2, d2); +// System.out.println(days2); +// +// int count = 0; +// for (int i = y1; i < y2; i++) { +// if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0) { +// count += 366; +// } else { +// count += 365; +// } +// } +// count = count + days2 - days1; +// +// return count; +// } +// +// public static int getRecentYearDays(int y, int m, int d) { +// +// int count = 0; +// +// switch (m - 1) { +// case 1: +// count += 31; +// break; +// case 2: +// count += 31 + 28; +// break; +// case 3: +// count += 31 + 28 + 31; +// break; +// case 4: +// count += 31 + 28 + 31 + 30; +// break; +// case 5: +// count += 31 + 28 + 31 + 30 + 31; +// break; +// case 6: +// count += 31 + 28 + 31 + 30 + 31 + 30; +// break; +// case 7: +// count += 31 + 28 + 31 + 30 + 31 + 30 + 31; +// break; +// case 8: +// count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31; +// break; +// case 9: +// count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30; +// break; +// case 10: +// count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31; +// break; +// case 11: +// count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30; +// break; +// } +// if (((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) && m > 2) +// count++; +// return count + d; +// } +// +// public static ControlPlanComboBoxBean[] getComboxItem(TCSession session,String pernaem) +// { +// ControlPlanComboBoxBean[] comboBoxBeans = null; +// TCPreferenceService pref = session.getPreferenceService(); +// String[] items = pref.getStringValues(pernaem);// 首选项查puid +// comboBoxBeans = new ControlPlanComboBoxBean[items.length]; +// for (int i = 0; i < items.length; i++) { +// if(items[i].indexOf("-")>0) +// { +// ControlPlanComboBoxBean bean = new ControlPlanComboBoxBean(); +// bean.setItemId(items[i].split("-")[0]); +// bean.setItemName(items[i].split("-")[1]); +// comboBoxBeans[i] = bean; +// } +// } +// return comboBoxBeans; +// } +// +//} diff --git a/src/com/connor/renben/process/plm/util/TableCellCheckboxRenderer.java b/src/com/connor/renben/process/plm/util/TableCellCheckboxRenderer.java new file mode 100644 index 0000000..ae2dc54 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TableCellCheckboxRenderer.java @@ -0,0 +1,100 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Checkbox; +import java.awt.Color; +import java.awt.Component; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.List; + +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.JTextPane; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +import com.teamcenter.rac.util.MessageBox; + +public class TableCellCheckboxRenderer extends JCheckBox implements + TableCellRenderer { + private List processRows; + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + private DefaultTableModel tableModel; + private JTableHeader tableHeader; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + public TableCellCheckboxRenderer(final CTable table) { + this.tableModel = (DefaultTableModel) table.getModel(); + this.tableHeader = table.getTableHeader(); + this.setName("4"); + // selectBox = new JCheckBox(tableModel.getColumnName(1)); + this.setSelected(false); + tableHeader.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() > 0) { + // 获得选中列 + int selectColumn = tableHeader.columnAtPoint(e.getPoint()); + if (table.getColumnName(selectColumn).equals("4")) { + boolean value = !TableCellCheckboxRenderer.this.isSelected(); + TableCellCheckboxRenderer.this.setSelected(value); + table.selectAllOrNull(value ? "1" : "0"); + tableHeader.repaint(); + } + } + } + }); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 + this.setBorderPainted(true); + if(value != null) + { + this.setSelected(value.toString().equals("1")); + } + else + { + this.setSelected(false); + } +// if() +// String valueStr = (String) value; +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // 表头标签剧中 +// this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 +// this.setBorderPainted(true); + return this; + } + /** + * 查看一个字符串是否可以转换为数字 + * @param str 字符串 + * @return true 可以; false 不可以 + */ + public boolean isStr2Num(String str) { + try { + Integer.parseInt(str); + return true; + } catch (NumberFormatException e) { + return false; + } + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/TableCellTextAreaRenderer.java b/src/com/connor/renben/process/plm/util/TableCellTextAreaRenderer.java new file mode 100644 index 0000000..3deaef6 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TableCellTextAreaRenderer.java @@ -0,0 +1,207 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.util.List; + +import javax.swing.BorderFactory; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextPane; +import javax.swing.table.TableCellRenderer; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +import org.w3c.dom.css.RGBColor; + +public class TableCellTextAreaRenderer extends JTextPane implements + TableCellRenderer { + private List processRows; + private boolean isRelease=false; + public List getProcessRows() { + return processRows; + } + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + public TableCellTextAreaRenderer() { + // setLineWrap(true);//自动换行 + // setWrapStyleWord(true); + } + + public void setIsRelease(boolean isRelease) { + this.isRelease=isRelease; + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + int maxPreferredHeight = 0; + if (table.getColumnName(column).equals("RPN")) { + // 5,9,11 + String yzd = table.getValueAt(row, 7) == null ? "0" : table + .getValueAt(row, 7).toString(); + String pds = table.getValueAt(row, 11) == null ? "0" : table + .getValueAt(row, 11).toString(); + String tcd = table.getValueAt(row, 13) == null ? "0" : table + .getValueAt(row, 13).toString(); + int rpn = Integer.parseInt(yzd) * Integer.parseInt(pds) + * Integer.parseInt(tcd); + if (rpn == 0) { + table.setValueAt("", row, column); + setText(""); + } else { + table.setValueAt(String.valueOf(rpn), row, column); + setText(String.valueOf(rpn)); + } + } else { + setText(value == null ? "" : value.toString()); + } + // 特殊符号 + // setText(value == null ? "" : value.toString()); + // if(table.getValueAt(row, table.getColumnCount()-1) == null) + // { + // return this; + // } + // String special = table.getValueAt(row, + // table.getColumnCount()-1).toString(); + // if(special.indexOf("|") >= 0) + // { + // String[] specials = special.split("\\|"); + // for (int i = 0; i < specials.length; i++) { + // if(specials[i].indexOf("-") >= 0) + // { + // String[] columnName = specials[i].split("-"); + // if(table.getColumnName(column).equals(columnName[0])) + // { + // setTextFont(value.toString(),Integer.parseInt(columnName[1]) + // ,"Y14.5M"); + // } + // } + // } + // } + // else if(special.indexOf("-") >= 0) + // { + // String[] columnName = special.split("-"); + // if(table.getColumnName(column).equals(columnName[0])) + // { + // setTextFont(value.toString(),Integer.parseInt(columnName[1]) + // ,"Y14.5M"); + // } + // } + // if(value!=null) + // { + // if(column == 1) + // { + // setTextFont(value.toString(),"Y14.5M"); + // } + // } + + for (int i = 0; i < table.getColumnCount(); i++) { + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, + getPreferredSize().height); + } + if (table.getColumnName(column).equals("RPN") && value != null + && !value.equals("") + && Integer.parseInt(value.toString()) >= 100) { + setBackground(Color.RED); + setForeground(Color.black); + } + else if (isRelease) { + setBackground(new Color(220,220,220)); + setForeground(Color.black); + } + + else { + setBackground(Color.white); + setForeground(Color.black); + } + if (isSelected) { + setBackground(new Color(184,184,184)); + setForeground(Color.black); + } + if (table.getRowHeight(row) != maxPreferredHeight)// 少了这行则处理器瞎忙 + { + table.setRowHeight(row, maxPreferredHeight); + } + return this; + } + + // 设置字体,如一个字符串中需要包含多个字体样式,可创建多个SimpleAttributeSet,并将字符串拆分开,按顺序使用Document的insertString方法插入 + private void setTextFont(String value, int index, String font) { + // TODO Auto-generated method stub + SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set, font);// 设置字体样式 + SimpleAttributeSet set2 = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set2, "Courier New");// 设置字体样式 + // StyleConstants.setFontSize(set2, 10); + Document doc = this.getStyledDocument(); + try { + // 插入前需要先删除 + doc.remove(0, value.toString().length()); + value = value.replaceAll(" ", ""); + doc.insertString(doc.getLength(), + value.toString().substring(0, index), set2); + doc.insertString(doc.getLength(), + value.toString().substring(index, index + 1), set); + doc.insertString( + doc.getLength(), + value.toString().substring(index + 1, + value.toString().length()), set2); + if (value.toString() + .substring(index + 1, value.toString().length()) == null + || value.toString() + .substring(index + 1, value.toString().length()) + .equals("")) { + doc.insertString(doc.getLength(), " ", set2); + } + } catch (BadLocationException e) { + e.printStackTrace(); + } finally { + set = null; + doc = null; + System.gc(); + } + } + // + // @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/renben/process/plm/util/TextAreaCellEditor.java b/src/com/connor/renben/process/plm/util/TextAreaCellEditor.java new file mode 100644 index 0000000..360152f --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TextAreaCellEditor.java @@ -0,0 +1,204 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Event; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.io.UnsupportedEncodingException; +import java.util.EventObject; + +import javax.swing.DefaultCellEditor; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JTextPane; +import javax.swing.event.CaretEvent; +import javax.swing.event.CaretListener; +import javax.swing.event.CellEditorListener; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.TableCellEditor; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +public class TextAreaCellEditor extends JTextPane implements TableCellEditor, + CaretListener { + private static final long serialVersionUID = 5860619160549087886L; + private EventListenerList listenerList = new EventListenerList(); + private ChangeEvent changeEvent = new ChangeEvent(this); + private int index;// 光标所在位置 + + public TextAreaCellEditor() { + // TODO Auto-generated constructor stub + super(); + this.addCaretListener(this); + // this.setLineWrap(true); //自动换行 + // this.setWrapStyleWord(true); + } + + public int getIndex() { + return index; + } + + @Override + public void addCellEditorListener(CellEditorListener listener) { + // TODO Auto-generated method stub + listenerList.add(CellEditorListener.class, listener); + } + + @Override + public void cancelCellEditing() { + // TODO Auto-generated method stub + System.out.println(2); + } + + @Override + public Object getCellEditorValue() { + // TODO Auto-generated method stub + // System.out.println(3); + return this.getText(); + } + + @Override + public boolean isCellEditable(EventObject arg0) { + // TODO Auto-generated method stub + return true; + } + + @Override + public void removeCellEditorListener(CellEditorListener listener) { + // TODO Auto-generated method stub + listenerList.remove(CellEditorListener.class, listener); + } + + private void fireEditingStopped() { + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + // 之所以是i+1,是因为一个为CellEditorListener.class(Class对象), + // 接着的是一个CellEditorListener的实例 + listener = (CellEditorListener) listeners[i + 1]; + // 让changeEvent去通知编辑器已经结束编辑 + // 在editingStopped方法中,JTable调用getCellEditorValue()取回单元格的值, + // 并且把这个值传递给TableValues(TableModel)的setValueAt() + try { + listener.editingStopped(changeEvent); + } catch (Exception e) { + // TODO: handle exception + System.out.println(e.toString()); + } + } + } + } + + @Override + public boolean shouldSelectCell(EventObject arg0) { + // TODO Auto-generated method stub + return true; + } + + @Override + public boolean stopCellEditing() { + // TODO Auto-generated method stub + // 可以注释掉下面的fireEditingStopped();,然后在GenderEditor的构造函数中把 + // addActionListener()的注释去掉(这时请求终止编辑操作从JComboBox获得), + // System.out.println("编辑其中一个单元格,再点击另一个单元格时,调用。"); + fireEditingStopped();// 请求终止编辑操作从JTable获得 + return true; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelect, int row, int column) { + // TODO Auto-generated method stub + setText(value == null ? "" : value.toString()); + // 特殊符号 + if (table.getValueAt(row, table.getColumnCount() - 1) == null) { + return new JScrollPane(this); + } + String special = table.getValueAt(row, table.getColumnCount() - 1) + .toString(); + if (special.indexOf("|") >= 0) { + String[] specials = special.split("\\|"); + for (int i = 0; i < specials.length; i++) { + if (specials[i].indexOf("-") >= 0) { + String[] columnName = specials[i].split("-"); + if (table.getColumnName(column).equals(columnName[0])) { + setTextFont(value.toString(), + Integer.parseInt(columnName[1]), "Y14.5M"); + } + } + } + } else if (special.indexOf("-") >= 0) { + String[] columnName = special.split("-"); + if (table.getColumnName(column).equals(columnName[0])) { + setTextFont(value.toString(), Integer.parseInt(columnName[1]), + "Y14.5M"); + } + } + // if(value!=null) + // { + // if(cloumn == 1) + // { + // setTextFont(value.toString(),"Y14.5M"); + // } + // } + // System.out.println(8) + return new JScrollPane(this); + } + + @Override + public void caretUpdate(CaretEvent caretevent) { + // TODO Auto-generated method stub + index = caretevent.getMark(); + // System.out.println(index); + } + + // 设置字体,如一个字符串中需要包含多个字体样式,可创建多个SimpleAttributeSet,并将字符串拆分开,按顺序使用Document的insertString方法插入 + private void setTextFont(String value, int index, String font) { + // TODO Auto-generated method stub + SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set, font);// 设置字体样式 + // StyleConstants.setFontSize(set, 14); + SimpleAttributeSet set2 = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set2, "Courier New");// 设置字体样式 + // StyleConstants.setFontSize(set2, 10); + Document doc = this.getStyledDocument(); + try { + // 插入前需要先删除 + doc.remove(0, value.toString().length()); + value = value.replaceAll(" ", ""); + doc.insertString(doc.getLength(), + value.toString().substring(0, index), set2); + doc.insertString(doc.getLength(), + value.toString().substring(index, index + 1), set); + doc.insertString( + doc.getLength(), + value.toString().substring(index + 1, + value.toString().length()), set2); + if (value.toString() + .substring(index + 1, value.toString().length()) == null + || value.toString() + .substring(index + 1, value.toString().length()) + .equals("")) { + doc.insertString(doc.getLength(), " ", set2); + } + } catch (BadLocationException e) { + e.printStackTrace(); + } finally { + set = null; + doc = null; + System.gc(); + } + } +} diff --git a/src/com/connor/renben/process/plm/util/TreeComboBox.java b/src/com/connor/renben/process/plm/util/TreeComboBox.java new file mode 100644 index 0000000..14edb49 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TreeComboBox.java @@ -0,0 +1,298 @@ +//package com.connor.renben.process.plm.util; +// +//import java.awt.Color; +//import java.awt.Component; +//import java.awt.Container; +//import java.awt.Dimension; +//import java.awt.Graphics; +//import java.awt.Insets; +//import java.awt.LayoutManager; +//import java.awt.event.ActionEvent; +//import java.awt.event.ActionListener; +//import java.awt.event.KeyEvent; +//import java.awt.event.KeyListener; +//import java.awt.event.MouseEvent; +//import java.awt.event.MouseListener; +//import java.util.ArrayList; +//import java.util.Enumeration; +//import java.util.List; +// +//import javax.swing.JButton; +//import javax.swing.JComponent; +//import javax.swing.JPanel; +//import javax.swing.JScrollPane; +//import javax.swing.JTextArea; +//import javax.swing.JTextField; +//import javax.swing.UIManager; +//import javax.swing.plaf.basic.BasicArrowButton; +//import javax.swing.tree.DefaultMutableTreeNode; +//import javax.swing.tree.TreeNode; +//import javax.swing.tree.TreePath; +// +//import com.connor.renben.process.plm.bean.TMomUserBean; +//import com.teamcenter.rac.kernel.TCComponent; +//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 TreeComboBox extends JComponent { +// +// private Object[] values; +// +// public Object[] defaultValues; +// +// private List listeners = new ArrayList(); +// +// public TreeComboBoxPopup popup; +// +// public JTextArea editor; +// +// protected JButton arrowButton; +// +// private String valueSperator; +// +// private TCSession session; +// private String value; +// private List nameList = new ArrayList(); +// +// private static final String DEFAULT_VALUE_SPERATOR = ","; +// +// public TreeComboBox(Object[] value, Object[] defaultValue,TCSession session) { +// this(value, defaultValue, DEFAULT_VALUE_SPERATOR,session); +// } +// +// public TreeComboBox(Object[] value, Object[] defaultValue, String valueSperator,TCSession session) { +// values = value; +// defaultValues = defaultValue; +// this.valueSperator = valueSperator; +// this.session = session; +// initComponent(); +// } +// +// private void initComponent() { +// // 暂时使用该布局,后续自己写个布局 +// this.setLayout(new PropertyLayout()); +// // this.set +// popup = new TreeComboBoxPopup(values, defaultValues,session); +// popup.addActionListener(new PopupAction()); +// +// editor = new JTextArea(); +// editor.setBackground(Color.WHITE); +// editor.setEditable(true); +//// editor.setBorder(getBorder()); +// editor.addKeyListener(new KeyListener() { +// +// @Override +// public void keyTyped(KeyEvent e) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void keyReleased(KeyEvent e) { +// // TODO Auto-generated method stub +// char ch = e.getKeyChar(); +// // if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch) +// // || ch == KeyEvent.VK_DELETE) +// // return; +// if (e.getKeyCode() == KeyEvent.VK_ENTER) { +// editor.setText(editor.getText().substring(0, editor.getText().length()-1)); +// int caretPosition = editor.getCaretPosition(); +// String str = editor.getText(); +// if (str.length() == 0) +// return; +// +// if (value != null && !value.equals(str)) { +// nameList.clear(); +// value = str; +// } else { +// value = str; +// } +// DefaultMutableTreeNode node = popup.searchNode( +// str, nameList); +// if (node != null) { +// String user = ((String) node.getUserObject()); +// nameList.add(user); +// TreeNode[] nodes = popup.m_model.getPathToRoot(node); +// TreePath path = new TreePath(nodes); +// popup.tree.scrollPathToVisible(path); +// popup.tree.setSelectionPath(path); +// +// togglePopup(); +// } else { +// MessageBox.post("未找到选项", "错误", MessageBox.ERROR); +// nameList.clear(); +// } +// +// +// //autoComplete(str, caretPosition); +// } +// } +// +// @Override +// public void keyPressed(KeyEvent e) { +// // TODO Auto-generated method stub +// +// } +// }); +// //editor.addMouseListener(new EditorHandler()); +// arrowButton = new JButton("↓");//createArrowButton(); +// arrowButton.setPreferredSize(new Dimension(50, 60)); +// arrowButton.addMouseListener(new EditorHandler()); +// JScrollPane scrollPane1 = new JScrollPane(); // 给jta加滚动条 +// scrollPane1.setPreferredSize(new Dimension(335, 58)); +// scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); +// scrollPane1.setViewportView(this.editor); +// add("1.1.left.top", scrollPane1); +// add("1.2.left.top", arrowButton); +// // add(arrowButton); +// setText(); +// +// } +// +// public Object[] getSelectedValues() { +// return popup.getSelectedValues(); +// } +// +// public void addActionListener(ActionListener listener) { +// if (!listeners.contains(listener)) +// listeners.add(listener); +// } +// +// public void removeActionListener(ActionListener listener) { +// if (listeners.contains(listener)) +// listeners.remove(listener); +// } +// +// protected void fireActionPerformed(ActionEvent e) { +// for (ActionListener l : listeners) { +// l.actionPerformed(e); +// } +// } +// +// private class PopupAction implements ActionListener { +// +// public void actionPerformed(ActionEvent e) { +// +// if (e.getActionCommand().equals(TreeComboBoxPopup.CANCEL_EVENT)) { +// popup.setVisible(false); +// } else if (e.getActionCommand().equals(TreeComboBoxPopup.COMMIT_EVENT)) { +// defaultValues = popup.getSelectedValues(); +// if(defaultValues.length > 0) +// { +// setText(); +// // 把事件继续传递出去 +// fireActionPerformed(e); +// popup.setVisible(false); +// //togglePopup(); +// } +// } +// else if (e.getActionCommand().equals(TreeComboBoxPopup.CANCEL_NEXT)) { +// DefaultMutableTreeNode node = popup.searchNode( +// editor.getText(), nameList); +// if (node != null) { +// String user = ((String) node.getUserObject()); +// nameList.add(user); +// TreeNode[] nodes = popup.m_model.getPathToRoot(node); +// TreePath path = new TreePath(nodes); +// popup.tree.scrollPathToVisible(path); +// popup.tree.setSelectionPath(path); +// } else { +// MessageBox.post("未找到选项", "错误", MessageBox.ERROR); +// nameList.clear(); +// } +// } +// +// +// } +// +// } +// +// private void togglePopup() { +// if (popup.isVisible()) { +// //popup.setVisible(false); +// } else { +// popup.setDefaultValue(defaultValues); +// popup.show(this, 0, getHeight()); +// } +// } +// +// private void setText() { +// StringBuilder builder = new StringBuilder(); +// for (Object dv : defaultValues) { +// builder.append(dv); +// builder.append(valueSperator); +// } +// +// editor.setText(builder.substring(0, builder.length() > 0 ? builder.length() - 1 : 0).toString()); +// } +// +// private class EditorHandler implements MouseListener { +// +// public void mouseClicked(MouseEvent e) { +// togglePopup(); +// } +// +// public void mousePressed(MouseEvent e) { +// +// } +// +// public void mouseReleased(MouseEvent e) { +// +// } +// +// public void mouseEntered(MouseEvent e) { +// +// } +// +// public void mouseExited(MouseEvent e) { +// +// } +// +// } +// +// public void paintComponent(Graphics g) { +// g.setColor(Color.white); +// g.fillRect(0, 0, getWidth(), getHeight()); +// } +// +// protected JButton createArrowButton() { +// JButton button = new BasicArrowButton(BasicArrowButton.SOUTH, UIManager.getColor("ComboBox.buttonBackground"), +// UIManager.getColor("ComboBox.buttonShadow"), UIManager.getColor("ComboBox.buttonDarkShadow"), +// UIManager.getColor("ComboBox.buttonHighlight")); +// button.setName("ComboBox.arrowButton"); +// return button; +// } +// +// private class MulitComboboxLayout implements LayoutManager { +// +// public void addLayoutComponent(String name, Component comp) { +// // TODO Auto-generated method stub +// +// } +// +// public void removeLayoutComponent(Component comp) { +// // TODO Auto-generated method stub +// +// } +// +// public Dimension preferredLayoutSize(Container parent) { +// return parent.getPreferredSize(); +// } +// +// public Dimension minimumLayoutSize(Container parent) { +// return parent.getMinimumSize(); +// } +// +// public void layoutContainer(Container parent) { +// int w = parent.getWidth(); +// int h = parent.getHeight(); +// Insets insets = parent.getInsets(); +// h = h - insets.top - insets.bottom; +// +// } +// +// } +// +//} diff --git a/src/com/connor/renben/process/plm/util/TreeComboBoxPopup.java b/src/com/connor/renben/process/plm/util/TreeComboBoxPopup.java new file mode 100644 index 0000000..34b2e4a --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TreeComboBoxPopup.java @@ -0,0 +1,269 @@ +//package com.connor.renben.process.plm.util; +// +//import java.awt.BorderLayout; +//import java.awt.Dimension; +//import java.awt.GridLayout; +//import java.awt.event.ActionEvent; +//import java.awt.event.ActionListener; +//import java.io.File; +//import java.io.FileNotFoundException; +//import java.io.IOException; +//import java.util.ArrayList; +//import java.util.Enumeration; +//import java.util.List; +// +//import javax.swing.JButton; +//import javax.swing.JPanel; +//import javax.swing.JPopupMenu; +//import javax.swing.JScrollPane; +//import javax.swing.JTree; +//import javax.swing.tree.DefaultMutableTreeNode; +//import javax.swing.tree.DefaultTreeModel; +//import javax.swing.tree.TreeNode; +//import javax.swing.tree.TreePath; +// +//import com.connor.renben.process.plm.bean.TMomUserBean; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCException; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.util.MessageBox; +// +//public class TreeComboBoxPopup extends JPopupMenu { +// +// private List listeners = new ArrayList(); +// +// private TCSession session; +// +// private Object[] values; +// +// private Object[] defaultValues; +// +// // private List checkBoxList = new ArrayList(); +// +// public JTree tree; +// public DefaultMutableTreeNode parentNode = null; +// public DefaultTreeModel m_model = null; +// public String nodeStr; +// +// private JButton commitButton; +// +// private JButton cancelButton; +// +// private JButton nextButton; +// +// public static final String COMMIT_EVENT = "commit"; +// +// public static final String CANCEL_EVENT = "cancel"; +// +// public static final String CANCEL_NEXT = "next"; +// +// public TreeComboBoxPopup(Object[] value, Object[] defaultValue, TCSession session) { +// super(); +// values = value; +// defaultValues = defaultValue; +// this.session = session; +// initComponent(); +// } +// +// public void addActionListener(ActionListener listener) { +// if (!listeners.contains(listener)) +// listeners.add(listener); +// } +// +// public void removeActionListener(ActionListener listener) { +// if (listeners.contains(listener)) +// listeners.remove(listener); +// } +// +// private void initComponent() { +// +// JPanel treePane = new JPanel(); +// +// JPanel buttonPane = new JPanel(); +// +// this.setLayout(new BorderLayout()); +// +// // 定义几个初始节点 +// +// // File file = new File("C:\\Users\\Administrator\\Desktop\\web\\委托单下拉选项.xlsx"); +// +// File file = TMomMethodUtil.getFile(session, "应用领域", "MSExcelX"); +// +// try { +// parentNode = ExcelUtil07.readExcelNodeByEntrustment(file, "应用领域"); +// } catch (FileNotFoundException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// this.setPreferredSize(new Dimension(465, 400)); +//// DefaultMutableTreeNode parentNode = new DefaultMutableTreeNode( +//// "Agile.201304.WI"); +//// +//// DefaultMutableTreeNode iteration1 = new DefaultMutableTreeNode("迭代1"); +//// +//// DefaultMutableTreeNode iteration2 = new DefaultMutableTreeNode("迭代2"); +//// +//// DefaultMutableTreeNode iteration3 = new DefaultMutableTreeNode("迭代3"); +//// +//// // 通过add方法建立树节点之间的父子关系 +//// +//// parentNode.add(iteration1); +//// +//// parentNode.add(iteration2); +//// +//// parentNode.add(iteration3); +// +// // 以根节点创建树 +// m_model = new DefaultTreeModel(parentNode); +// tree = new JTree(m_model); +// +// // 设置是否显示根节点的“展开/折叠”图标,默认是false +// +// tree.setShowsRootHandles(true); +// +// // 设置节点是否可见,默认是true +// +// tree.setRootVisible(true); +// +// treePane.setLayout(new GridLayout(0, 1, 3, 3)); +// treePane.add(new JScrollPane(tree)); +//// for(JCheckBox box : checkBoxList){ +//// checkboxPane.add(box); +//// } +// +// commitButton = new JButton("确定"); +// +// commitButton.addActionListener(new ActionListener() { +// +// public void actionPerformed(ActionEvent e) { +// commit(); +// } +// +// }); +// +// cancelButton = new JButton("取消"); +// +// cancelButton.addActionListener(new ActionListener() { +// +// public void actionPerformed(ActionEvent e) { +// cancel(); +// } +// +// }); +// +// nextButton = new JButton("下一个"); +// +// nextButton.addActionListener(new ActionListener() { +// +// public void actionPerformed(ActionEvent e) { +// next(); +// } +// +// }); +// +// buttonPane.add(commitButton); +// +// buttonPane.add(cancelButton); +// +// buttonPane.add(nextButton); +// +// this.add(treePane, BorderLayout.CENTER); +// +// this.add(buttonPane, BorderLayout.SOUTH); +// +// } +// +// // 查找满足添加的节点 +// public DefaultMutableTreeNode searchNode(String nodeStr, List nameList) { +// this.nodeStr = nodeStr; +// DefaultMutableTreeNode node = null; +// Enumeration e = this.parentNode.breadthFirstEnumeration(); +// while (e.hasMoreElements()) { +// node = (DefaultMutableTreeNode) e.nextElement(); +// +// if (node.getUserObject() instanceof String) { +// String user = (String) node.getUserObject(); +// try { +// if (user != null) { +//// System.out.println(user); +//// System.out.println(nodeStr); +// if ((user.indexOf(nodeStr) >= 0 || user.indexOf(nodeStr) >= 0) && !nameList.contains(user)) { +// return node; +// } +// } +// } catch (Exception e1) { +// e1.printStackTrace(); +// } +// } +// } +// return null; +// } +// +// private boolean selected(Object v) { +// for (Object dv : defaultValues) { +// if (dv.equals(v)) { +// return true; +// } +// } +// return false; +// } +// +// protected void fireActionPerformed(ActionEvent e) { +// for (ActionListener l : listeners) { +// l.actionPerformed(e); +// } +// } +// +// public Object[] getSelectedValues() { +// List selectedValues = new ArrayList(); +// +// int[] rows = tree.getSelectionRows(); +// for (int i = 0; i < rows.length; i++) { +// try { +// Object selectObj = tree.getPathForRow(rows[i]).getPathComponent(3); +// if (selectObj instanceof DefaultMutableTreeNode) { +// selectedValues.add(selectObj); +// } +// } catch (Exception ex) { +// // MessageBox.post("请选择最底层节点!", "错误", MessageBox.ERROR); +// } +// } +// +// return selectedValues.toArray(new Object[selectedValues.size()]); +// } +// +// public void setDefaultValue(Object[] defaultValue) { +// defaultValues = defaultValue; +// +// } +// +// public void commit() { +// fireActionPerformed(new ActionEvent(this, 0, COMMIT_EVENT)); +// } +// +// public void cancel() { +// fireActionPerformed(new ActionEvent(this, 0, CANCEL_EVENT)); +// } +// +// public void next() { +// fireActionPerformed(new ActionEvent(this, 0, CANCEL_NEXT)); +//// DefaultMutableTreeNode node = searchNode( +//// nodeStr, nameList); +//// if (node != null) { +//// String user = ((String) node.getUserObject()); +//// nameList.add(user); +//// TreeNode[] nodes = m_model.getPathToRoot(node); +//// TreePath path = new TreePath(nodes); +//// tree.scrollPathToVisible(path); +//// tree.setSelectionPath(path); +//// +//// //togglePopup(); +//// } else { +//// //MessageBox.post("未找到选项", "错误", MessageBox.ERROR); +//// nameList.clear(); +//// } +// } +//} diff --git a/src/com/connor/renben/process/plm/util/TreeTableCellEditor.java b/src/com/connor/renben/process/plm/util/TreeTableCellEditor.java new file mode 100644 index 0000000..2494568 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TreeTableCellEditor.java @@ -0,0 +1,36 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Component; + +import javax.swing.JTable; +import javax.swing.JTree; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellEditor; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.TreeCellEditor; + +public class TreeTableCellEditor extends DefaultTreeCellEditor { + + JTable table; + + @Override + public Component getTreeCellEditorComponent(JTree tree, Object value, + boolean isSelected, boolean expanded, boolean leaf, int row) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; + Object ud = node.getUserObject(); + if (!(ud instanceof JTable) || !leaf) { + return super.getTreeCellEditorComponent(tree, value, isSelected, + expanded, leaf, row); + } + return (JTable) ud; + } + + public TreeTableCellEditor(JTree tree, DefaultTreeCellRenderer renderer, + TreeCellEditor editor) { + super(tree, renderer, editor); + } + + public TreeTableCellEditor(JTree tree, DefaultTreeCellRenderer renderer) { + super(tree, renderer); + } +} diff --git a/src/com/connor/renben/process/plm/util/TreeTableCellRenderer.java b/src/com/connor/renben/process/plm/util/TreeTableCellRenderer.java new file mode 100644 index 0000000..06a396c --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TreeTableCellRenderer.java @@ -0,0 +1,26 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Component; + +import javax.swing.JTable; +import javax.swing.JTree; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; + +public class TreeTableCellRenderer extends DefaultTreeCellRenderer { + JTable table; + + @Override + public Component getTreeCellRendererComponent(JTree tree, Object value, + boolean selected, boolean expanded, boolean leaf, int row, + boolean hasFocus) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; + Object ud = node.getUserObject(); + + if (!(ud instanceof JTable) || !leaf) { + return super.getTreeCellRendererComponent(tree, value, leaf, + expanded, leaf, row, hasFocus); + } + return (JTable) ud; + } +} diff --git a/src/com/teamcenter/rac/cme/bvr/create/fromtemplate/CreateMEProcessCommand.java b/src/com/teamcenter/rac/cme/bvr/create/fromtemplate/CreateMEProcessCommand.java new file mode 100644 index 0000000..6b8e366 --- /dev/null +++ b/src/com/teamcenter/rac/cme/bvr/create/fromtemplate/CreateMEProcessCommand.java @@ -0,0 +1,121 @@ +package com.teamcenter.rac.cme.bvr.create.fromtemplate; +//package com.teamcenter.rac.cme.fromtemplate; +// +//import java.awt.Frame; +// +//import com.teamcenter.rac.aif.AbstractAIFCommand; +//import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +//import com.teamcenter.rac.cme.bvr.create.fromtemplate.NewMEProcessOperation; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentItemRevision; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.util.MessageBox; +//import com.teamcenter.rac.util.Registry; +// +//public class CreateMEProcessCommand +// extends AbstractAIFCommand +//{ +// private CreateMEProcessDialog dlg; +// private boolean itsAnOperation = false; +// +// public CreateMEProcessCommand(Frame paramFrame, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent) +// { +// if (validComponents(paramArrayOfInterfaceAIFComponent, paramFrame)) +// { +// this.dlg = new CreateMEProcessDialog(paramFrame, paramArrayOfInterfaceAIFComponent); +// setRunnable(this.dlg); +// } +// } +// +// public CreateMEProcessCommand(Frame paramFrame, Boolean paramBoolean, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent) +// { +// if (validComponents(paramArrayOfInterfaceAIFComponent, paramFrame)) +// { +// this.dlg = new CreateMEProcessDialog(paramFrame, paramBoolean.booleanValue(), paramArrayOfInterfaceAIFComponent); +// setRunnable(this.dlg); +// } +// } +// +// public CreateMEProcessCommand(Frame paramFrame, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent, Boolean paramBoolean) +// { +// this(paramFrame, paramArrayOfInterfaceAIFComponent, paramBoolean, null); +// } +// +// public CreateMEProcessCommand(Frame paramFrame, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent, Boolean paramBoolean, String paramString) +// { +// if (validComponents(paramArrayOfInterfaceAIFComponent, paramFrame)) +// { +// this.itsAnOperation = paramBoolean.booleanValue(); +// this.dlg = new CreateMEProcessDialog(paramFrame, paramArrayOfInterfaceAIFComponent, this.itsAnOperation, paramString); +// setRunnable(this.dlg); +// } +// } +// +// public CreateMEProcessCommand(Frame paramFrame, TCComponentItemRevision paramTCComponentItemRevision) +// { +// this.dlg = new CreateMEProcessDialog(paramFrame, paramTCComponentItemRevision); +// setRunnable(this.dlg); +// } +// +// public TCComponent getNewProcess() +// { +// if (this.dlg != null) { +// return this.dlg.getNewProcess(); +// } +// return null; +// } +// +// public CreateMEProcessCommand(Frame paramFrame, TCSession paramTCSession) +// { +// this.dlg = new CreateMEProcessDialog(paramFrame, paramTCSession); +// setRunnable(this.dlg); +// } +// +// public CreateMEProcessCommand(Frame paramFrame, TCSession paramTCSession, Boolean paramBoolean) +// { +// this.itsAnOperation = paramBoolean.booleanValue(); +// this.dlg = new CreateMEProcessDialog(paramFrame, paramTCSession, this.itsAnOperation); +// setRunnable(this.dlg); +// } +// +// public CreateMEProcessCommand(TCSession paramTCSession, String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, TCComponent paramTCComponent, Boolean paramBoolean) +// { +// setRunnable(new NewMEProcessRunnable(paramTCSession, paramString1, paramString2, paramString3, paramString4, paramString5, paramTCComponent, paramBoolean.booleanValue(), null)); +// } +// +// private boolean validComponents(InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent, Frame paramFrame) +// { +// Registry localRegistry = Registry.getRegistry(this); +// for (int i = 0; (paramArrayOfInterfaceAIFComponent != null) && (i < paramArrayOfInterfaceAIFComponent.length); i++) { +// if (paramArrayOfInterfaceAIFComponent[i] == null) +// { +// MessageBox localMessageBox = new MessageBox(paramFrame, localRegistry.getString("invalidObjects"), localRegistry.getString("newItemError.TITLE"), 4); +// localMessageBox.setModal(true); +// localMessageBox.setVisible(true); +// return false; +// } +// } +// return true; +// } +// +// public CreateMEProcessDialog getDlg() +// { +// return this.dlg; +// } +// +// private class NewMEProcessRunnable +// implements Runnable +// { +// private NewMEProcessOperation op = null; +// +// public NewMEProcessRunnable(TCSession paramTCSession, String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, TCComponent paramTCComponent, boolean paramBoolean, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent) +// { +// this.op = new NewMEProcessOperation(paramTCSession, !CreateMEProcessCommand.this.itsAnOperation, null, paramString1, paramString2, paramString3, paramString4, paramString5, paramTCComponent, paramBoolean, paramArrayOfInterfaceAIFComponent, null, null); +// } +// +// public void run() +// { +// this.op.executeModeless(); +// } +// } +//} diff --git a/src/com/teamcenter/rac/cme/bvr/create/fromtemplate/NewMEProcessDialog.java b/src/com/teamcenter/rac/cme/bvr/create/fromtemplate/NewMEProcessDialog.java new file mode 100644 index 0000000..721662f --- /dev/null +++ b/src/com/teamcenter/rac/cme/bvr/create/fromtemplate/NewMEProcessDialog.java @@ -0,0 +1,1423 @@ +package com.teamcenter.rac.cme.bvr.create.fromtemplate; +//package com.teamcenter.rac.cme.fromtemplate; +// +//import java.awt.Frame; +//import java.awt.Graphics; +//import java.awt.Insets; +//import java.awt.Toolkit; +//import java.awt.event.ActionEvent; +//import java.awt.event.ActionListener; +//import java.awt.event.FocusAdapter; +//import java.awt.event.FocusEvent; +//import java.awt.event.KeyAdapter; +//import java.awt.event.KeyEvent; +//import java.awt.event.WindowAdapter; +//import java.awt.event.WindowEvent; +//import java.text.DecimalFormat; +//import java.text.MessageFormat; +// +//import javax.swing.JButton; +//import javax.swing.JCheckBox; +//import javax.swing.JComponent; +//import javax.swing.JFormattedTextField; +//import javax.swing.JLabel; +//import javax.swing.JPanel; +//import javax.swing.JScrollPane; +//import javax.swing.JSpinner; +//import javax.swing.JTabbedPane; +//import javax.swing.JTextArea; +//import javax.swing.JTextField; +//import javax.swing.SpinnerNumberModel; +//import javax.swing.SwingUtilities; +//import javax.swing.event.ChangeEvent; +//import javax.swing.event.ChangeListener; +// +//import org.eclipse.jface.viewers.ISelection; +//import org.eclipse.ui.ISelectionListener; +//import org.eclipse.ui.ISelectionService; +//import org.eclipse.ui.IWorkbenchPart; +// +//import com.teamcenter.rac.aif.AIFDesktop; +//import com.teamcenter.rac.aif.AbstractAIFDialog; +//import com.teamcenter.rac.aif.AbstractAIFOperation; +//import com.teamcenter.rac.aif.AbstractAIFUIApplication; +//import com.teamcenter.rac.aif.InterfaceAIFOperationListener; +//import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +//import com.teamcenter.rac.aifrcp.AIFUtility; +//import com.teamcenter.rac.aifrcp.SelectionHelper; +//import com.teamcenter.rac.cme.bvr.create.fromtemplate.AutoGenerateIdUtil; +//import com.teamcenter.rac.cme.bvr.create.fromtemplate.METemplatePanel; +//import com.teamcenter.rac.cme.bvr.create.fromtemplate.Messages; +//import com.teamcenter.rac.cme.bvr.create.fromtemplate.NewMEProcessOperation; +//import com.teamcenter.rac.cme.framework.util.MFGStructureTypeUtil; +//import com.teamcenter.rac.cme.framework.util.PasteUtils; +//import com.teamcenter.rac.cme.kernel.bvr.TCComponentMfgBvrCompoundOperation; +//import com.teamcenter.rac.common.TCTypeRenderer; +//import com.teamcenter.rac.common.TCUtilities; +//import com.teamcenter.rac.common.cme.IMFGApplication; +//import com.teamcenter.rac.common.cme.InterfaceUseTemplateDialog; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentAbstractCCStructure; +//import com.teamcenter.rac.kernel.TCComponentAppGroupBOPLine; +//import com.teamcenter.rac.kernel.TCComponentBOMLine; +//import com.teamcenter.rac.kernel.TCComponentContextList; +//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.TCComponentMEOP; +//import com.teamcenter.rac.kernel.TCComponentMEProcess; +//import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; +//import com.teamcenter.rac.kernel.TCComponentQuery; +//import com.teamcenter.rac.kernel.TCComponentQueryType; +//import com.teamcenter.rac.kernel.TCComponentRevisionRule; +//import com.teamcenter.rac.kernel.TCComponentType; +//import com.teamcenter.rac.kernel.TCException; +//import com.teamcenter.rac.kernel.TCPreferenceService; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.kernel.TCTextService; +//import com.teamcenter.rac.ms.util.SelectionUtil; +//import com.teamcenter.rac.util.AdapterUtil; +//import com.teamcenter.rac.util.ButtonLayout; +//import com.teamcenter.rac.util.HorizontalLayout; +//import com.teamcenter.rac.util.MessageBox; +//import com.teamcenter.rac.util.Painter; +//import com.teamcenter.rac.util.PlatformHelper; +//import com.teamcenter.rac.util.PropertyLayout; +//import com.teamcenter.rac.util.Registry; +//import com.teamcenter.rac.util.SWTUIUtilities; +//import com.teamcenter.rac.util.Separator; +//import com.teamcenter.rac.util.VerticalLayout; +// +//public class NewMEProcessDialog +// extends AbstractAIFDialog +// implements InterfaceAIFOperationListener, InterfaceUseTemplateDialog +//{ +// public static final String PREFERENCE_KEY = "Process.Template"; +// private JTextField id; +// private JTextField rev; +// public JPanel namePanel; +// private JTextField name; +// private JTextArea descriptionText; +// private JCheckBox openOnCreate; +// private JButton okButton; +// private JButton applyButton; +// private JButton cancelButton; +// private JButton assignButton; +// protected static final short OK_BUTTON_CLICKED = 0; +// protected static final short APPLY_BUTTON_CLICKED = 1; +// protected short okOrApply = 0; +// protected TCSession session = null; +// protected InterfaceAIFComponent[] pasteTargets = null; +// protected AIFDesktop desktop = null; +// protected Frame parent = null; +// protected NewMEProcessOperation newMEProcessOp = null; +// private Registry appReg; +// protected TCComponentItem meProcessComponent = null; +// protected TCComponentItemRevision targetProductItem = null; +// private boolean isIDModifiable = true; +// private boolean isRevIDModifiable = true; +// boolean itsAnOperation = false; +// boolean itsAPlan = false; +// private String defaultProcessTypeName = "MEProcess"; +// protected static final String MEPROCESS_TYPE = "MEProcess"; +// protected static final String MEPROCESSOP_TYPE = "MEOP"; +// protected static int maxNumberOfItems = 0; +// private METemplatePanel useTemplatePanel = null; +// private JLabel idLabel; +// private String previousTemplateType = ""; +// private String meProcessType; +// private String templateIDStr; +// private String templateUIDStr; +// private JTabbedPane customTab; +// public JPanel quantityPanel; +// private SpinnerNumberModel quantitySpinnerModel; +// private JSpinner quantitySpinner; +// private JLabel spinnerLable; +// private JLabel parentLineLabel; +// private InterfaceAIFComponent[] tempTargets = null; +// private boolean opSuccessAndNotNewRootFlag = false; +// private boolean createAsNewRootFlag = false; +// private int numOfObjectsEntered = 0; +// +// public NewMEProcessDialog(Frame paramFrame, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent) +// { +// super(paramFrame, false); +// +// this.session = ((TCSession)paramArrayOfInterfaceAIFComponent[0].getSession()); +// this.pasteTargets = paramArrayOfInterfaceAIFComponent; +// this.parent = paramFrame; +// if ((paramFrame instanceof AIFDesktop)) { +// this.desktop = ((AIFDesktop)paramFrame); +// } +// setCreationType(); +// initializeDialog(); +// } +// +// public NewMEProcessDialog(Frame paramFrame, boolean paramBoolean, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent) +// { +// super(paramFrame, false); +// this.pasteTargets = paramArrayOfInterfaceAIFComponent; +// this.parent = paramFrame; +// if (paramArrayOfInterfaceAIFComponent != null) { +// this.session = ((TCSession)paramArrayOfInterfaceAIFComponent[0].getSession()); +// } +// if ((paramFrame instanceof AIFDesktop)) { +// this.desktop = ((AIFDesktop)paramFrame); +// } +// if ((this.pasteTargets != null) && (this.pasteTargets.length == 1) && ((this.pasteTargets[0] instanceof TCComponent))) +// { +// TCComponentItemRevision localTCComponentItemRevision; +// if ((this.pasteTargets[0] instanceof TCComponentBOMLine)) +// { +// try +// { +// localTCComponentItemRevision = ((TCComponentBOMLine)this.pasteTargets[0]).getItemRevision(); +// this.itsAPlan = (localTCComponentItemRevision instanceof TCComponentMEProcessRevision); +// } +// catch (TCException localTCException) {} +// } +// else if ((this.pasteTargets[0] instanceof TCComponentItemRevision)) +// { +// localTCComponentItemRevision = (TCComponentItemRevision)this.pasteTargets[0]; +// this.itsAPlan = (localTCComponentItemRevision instanceof TCComponentMEProcessRevision); +// } +// else +// { +// this.itsAPlan = (this.pasteTargets[0] instanceof TCComponentMEProcess); +// } +// this.itsAnOperation = (!this.itsAPlan); +// } +// initializeDialog(); +// } +// +// public NewMEProcessDialog(Frame paramFrame, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent, boolean paramBoolean) +// { +// this(paramFrame, paramArrayOfInterfaceAIFComponent, paramBoolean, null); +// } +// +// public NewMEProcessDialog(Frame paramFrame, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent, boolean paramBoolean, String paramString) +// { +// super(paramFrame, false); +// this.session = ((TCSession)paramArrayOfInterfaceAIFComponent[0].getSession()); +// this.pasteTargets = paramArrayOfInterfaceAIFComponent; +// this.parent = paramFrame; +// if ((paramFrame instanceof AIFDesktop)) { +// this.desktop = ((AIFDesktop)paramFrame); +// } +// this.itsAnOperation = paramBoolean; +// this.itsAPlan = (!this.itsAnOperation); +// initializeDialog(); +// } +// +// public NewMEProcessDialog(Frame paramFrame, TCComponentItemRevision paramTCComponentItemRevision) +// { +// super(paramFrame, false); +// this.session = paramTCComponentItemRevision.getSession(); +// this.pasteTargets = null; +// this.parent = paramFrame; +// if ((paramFrame instanceof AIFDesktop)) { +// this.desktop = ((AIFDesktop)paramFrame); +// } +// this.targetProductItem = paramTCComponentItemRevision; +// initializeDialog(); +// } +// +// public NewMEProcessDialog(Frame paramFrame, TCSession paramTCSession) +// { +// super(paramFrame, false); +// this.session = paramTCSession; +// this.parent = paramFrame; +// if ((paramFrame instanceof AIFDesktop)) { +// this.desktop = ((AIFDesktop)paramFrame); +// } +// initializeDialog(); +// } +// +// public NewMEProcessDialog(Frame paramFrame, TCSession paramTCSession, boolean paramBoolean) +// { +// super(paramFrame, false); +// this.session = paramTCSession; +// this.parent = paramFrame; +// if ((paramFrame instanceof AIFDesktop)) { +// this.desktop = ((AIFDesktop)paramFrame); +// } +// this.itsAnOperation = paramBoolean; +// this.itsAPlan = (!this.itsAnOperation); +// initializeDialog(); +// } +// +// private void addSelectionListenerToSelectionService() +// { +// ISelectionService localISelectionService = PlatformHelper.getCurrentWorkbenchWindow().getSelectionService(); +// localISelectionService.addSelectionListener(new ISelectionListener() +// { +// public void selectionChanged(IWorkbenchPart paramAnonymousIWorkbenchPart, ISelection paramAnonymousISelection) +// { +// InterfaceAIFComponent[] arrayOfInterfaceAIFComponent = SelectionHelper.getTargetComponents(paramAnonymousISelection); +// if (MFGStructureTypeUtil.isProcess((TCComponent)AdapterUtil.getAdapter(arrayOfInterfaceAIFComponent[0], TCComponent.class))) { +// NewMEProcessDialog.this.openOnCreate.setEnabled(true); +// } else { +// NewMEProcessDialog.this.openOnCreate.setEnabled(false); +// } +// } +// }); +// } +// +// private void initializeDialog() +// { +// System.out.println("initializeDialog"); +// this.appReg = Registry.getRegistry(this); +// TCPreferenceService localTCPreferenceService = this.session.getPreferenceService(); +// Integer localInteger = localTCPreferenceService.getIntegerValue("MaxNumberOfObjectsToCreate"); +// if (localInteger != null) { +// maxNumberOfItems = localInteger.intValue(); +// } else { +// maxNumberOfItems = 99; +// } +// String str1; +// if (this.itsAnOperation) { +// str1 = "NewMEOP.TITLE"; +// } else { +// str1 = "NewMEProcess.TITLE"; +// } +// setTitle(this.appReg.getString(str1)); +// String str2 = localTCPreferenceService.getStringValue("FLColumnCatIVFSeparatorPref"); +// String str3 = localTCPreferenceService.getStringValue("FLColumnCatObjSeparatorPref"); +// JPanel localJPanel1 = new JPanel(new VerticalLayout(5, 2, 2, 2, 2)); +// getContentPane().add(localJPanel1); +// JPanel localJPanel2 = new JPanel(new ButtonLayout()); +// JPanel localJPanel3 = new JPanel(new HorizontalLayout()); +// JPanel localJPanel4 = new JPanel(new HorizontalLayout()); +// JPanel localJPanel5 = new JPanel(new VerticalLayout()); +// JPanel localJPanel6 = new JPanel(new VerticalLayout()); +// this.customTab = new JTabbedPane(); +// this.customTab.addTab(this.appReg.getString("base.TITLE"), localJPanel6); +// JPanel localJPanel7 = new JPanel(new PropertyLayout()); +// String str4 = this.itsAPlan ? "MEProcess" : "MEOP"; +// JLabel localJLabel1 = new JLabel(this.appReg.getImageIcon("new" + str4 + ".ICON")); +// String str5 = this.itsAnOperation ? this.appReg.getString("meOperationId") : this.appReg.getString("meProcessId"); +// this.idLabel = new JLabel(str5); +// JLabel localJLabel2 = new JLabel(this.appReg.getString("meProcessRevision")); +// JLabel localJLabel3 = new JLabel(this.appReg.getString("meProcessName")); +// this.id = new JTextField(15) +// { +// public void paint(Graphics paramAnonymousGraphics) +// { +// super.paint(paramAnonymousGraphics); +// Painter.paintIsRequired(this, paramAnonymousGraphics); +// } +// }; +// this.id.addKeyListener(new KeyAdapter() +// { +// public void keyReleased(KeyEvent paramAnonymousKeyEvent) +// { +// NewMEProcessDialog.this.validateEntries(); +// } +// +// public void keyTyped(KeyEvent paramAnonymousKeyEvent) +// { +// JTextField localJTextField = (JTextField)paramAnonymousKeyEvent.getSource(); +// String str = localJTextField.getText(); +// int i = 128; +// if (str.length() >= i) +// { +// localJTextField.setText(str.substring(0, i - 1)); +// Toolkit.getDefaultToolkit().beep(); +// } +// } +// }); +// this.id.addFocusListener(new FocusAdapter() +// { +// public void focusGained(FocusEvent paramAnonymousFocusEvent) +// { +// NewMEProcessDialog.this.id.selectAll(); +// } +// }); +// AutoGenerateIdUtil.setToolTip(str4, "item_id", this.id, this.appReg.getString("itemInfo.id.TOOLTIP"), this.session); +// this.rev = new JTextField(4) +// { +// public void paint(Graphics paramAnonymousGraphics) +// { +// super.paint(paramAnonymousGraphics); +// Painter.paintIsRequired(this, paramAnonymousGraphics); +// } +// }; +// this.rev.addKeyListener(new KeyAdapter() +// { +// public void keyReleased(KeyEvent paramAnonymousKeyEvent) +// { +// NewMEProcessDialog.this.validateEntries(); +// } +// +// public void keyTyped(KeyEvent paramAnonymousKeyEvent) +// { +// JTextField localJTextField = (JTextField)paramAnonymousKeyEvent.getSource(); +// String str = localJTextField.getText(); +// int i = 32; +// if (str.length() >= i) +// { +// localJTextField.setText(str.substring(0, i - 1)); +// Toolkit.getDefaultToolkit().beep(); +// } +// } +// }); +// this.rev.addFocusListener(new FocusAdapter() +// { +// public void focusGained(FocusEvent paramAnonymousFocusEvent) +// { +// NewMEProcessDialog.this.rev.selectAll(); +// } +// }); +// this.name = new JTextField(10) +// { +// public void paint(Graphics paramAnonymousGraphics) +// { +// super.paint(paramAnonymousGraphics); +// Painter.paintIsRequired(this, paramAnonymousGraphics); +// } +// }; +// this.name.addKeyListener(new KeyAdapter() +// { +// public void keyReleased(KeyEvent paramAnonymousKeyEvent) +// { +// NewMEProcessDialog.this.validateEntries(); +// } +// +// public void keyTyped(KeyEvent paramAnonymousKeyEvent) +// { +// JTextField localJTextField = (JTextField)paramAnonymousKeyEvent.getSource(); +// String str = localJTextField.getText(); +// int i = 128; +// if (str.length() >= i) +// { +// localJTextField.setText(str.substring(0, i - 1)); +// Toolkit.getDefaultToolkit().beep(); +// } +// } +// +// public void keyPressed(KeyEvent paramAnonymousKeyEvent) +// { +// int i = paramAnonymousKeyEvent.getKeyCode(); +// if ((i == 10) && (NewMEProcessDialog.this.okButton.isEnabled()) && (NewMEProcessDialog.this.validateId())) +// { +// NewMEProcessDialog.this.okOrApply = 0; +// NewMEProcessDialog.this.startCreateOperation(); +// } +// } +// }); +// this.name.addFocusListener(new FocusAdapter() +// { +// public void focusGained(FocusEvent paramAnonymousFocusEvent) +// { +// NewMEProcessDialog.this.name.selectAll(); +// } +// }); +// this.namePanel = new JPanel(new HorizontalLayout()); +// if (str4 != null) { +// try +// { +// this.namePanel.removeAll(); +// this.namePanel.add("left.bind.left.center", this.name); +// this.namePanel.revalidate(); +// this.namePanel.repaint(); +// } +// catch (Exception localException) +// { +// this.namePanel.removeAll(); +// this.namePanel.add("left.bind.left.center", this.name); +// } +// } else { +// this.namePanel.add("left.bind.left.center", this.name); +// } +// this.assignButton = new JButton(this.appReg.getString("newProcessAssign")); +// this.assignButton.setMargin(new Insets(0, 0, 0, 0)); +// this.assignButton.addActionListener(new ActionListener() +// { +// public void actionPerformed(ActionEvent paramAnonymousActionEvent) +// { +// String str = NewMEProcessDialog.this.getMEProcessType(); +// if ((str == null) || (str.length() == 0)) { +// return; +// } +// if (NewMEProcessDialog.this.validateId()) +// { +// NewMEProcessDialog.this.getAssignedIds(str); +// NewMEProcessDialog.this.validateEntries(); +// NewMEProcessDialog.this.namePanel.requestFocus(); +// } +// else +// { +// NewMEProcessDialog.this.id.setText(""); +// } +// } +// }); +// this.quantityPanel = new JPanel(new HorizontalLayout()); +// this.quantitySpinnerModel = new SpinnerNumberModel(1, 1, this.appReg.getInt("MAX_NUMBER_OF_ITEMS", 0), 1); +// this.quantitySpinner = new JSpinner(this.quantitySpinnerModel); +// JFormattedTextField localJFormattedTextField = ((JSpinner.DefaultEditor)this.quantitySpinner.getEditor()).getTextField(); +// localJFormattedTextField.setColumns(3); +// this.spinnerLable = new JLabel(this.appReg.getString("itemInfo.quantity")); +// this.spinnerLable.setLabelFor(this.quantitySpinner); +// this.quantitySpinner.addChangeListener(new ChangeListener() +// { +// public void stateChanged(ChangeEvent paramAnonymousChangeEvent) +// { +// NewMEProcessDialog.this.validateEntries(); +// } +// }); +// addValidator(this.quantitySpinner); +// this.quantityPanel.add("left", this.spinnerLable); +// this.quantityPanel.add("left.nobind", this.quantitySpinner); +// JLabel localJLabel4 = new JLabel(this.appReg.getString("newProcessDescription")); +// this.descriptionText = new JTextArea(3, 30); +// this.descriptionText.setLineWrap(true); +// this.descriptionText.setWrapStyleWord(true); +// this.descriptionText.addKeyListener(new KeyAdapter() +// { +// public void keyTyped(KeyEvent paramAnonymousKeyEvent) +// { +// JTextArea localJTextArea = (JTextArea)paramAnonymousKeyEvent.getSource(); +// String str = localJTextArea.getText(); +// int i = 240; +// if (str.length() >= i) +// { +// localJTextArea.setText(str.substring(0, i - 1)); +// Toolkit.getDefaultToolkit().beep(); +// } +// } +// }); +// JScrollPane localJScrollPane = new JScrollPane(); +// localJScrollPane.getViewport().add(this.descriptionText); +// String str6 = this.itsAnOperation ? this.appReg.getString("setAsRootOperation") : this.appReg.getString("setAsRootProcess"); +// this.openOnCreate = new JCheckBox(str6); +// this.openOnCreate.addActionListener(new ActionListener() +// { +// public void actionPerformed(ActionEvent paramAnonymousActionEvent) +// { +// NewMEProcessDialog.this.enableApplyButton(); +// NewMEProcessDialog.this.showHideParentLineLabel(); +// } +// }); +// AbstractAIFUIApplication localAbstractAIFUIApplication = AIFUtility.getCurrentApplication(); +// Object localObject; +// if (((localAbstractAIFUIApplication instanceof IMFGApplication)) && ((this.pasteTargets == null) || (this.pasteTargets.length == 0))) +// { +// localObject = (IMFGApplication)localAbstractAIFUIApplication; +// TCComponentAbstractCCStructure localTCComponentAbstractCCStructure = ((IMFGApplication)localObject).getSelectedStructure(); +// if (localTCComponentAbstractCCStructure != null) +// { +// this.pasteTargets = new InterfaceAIFComponent[1]; +// this.pasteTargets[0] = localTCComponentAbstractCCStructure; +// } +// } +// try +// { +// localObject = "Operation"; +// if ((this.pasteTargets != null) && (this.pasteTargets.length > 0) && ((this.pasteTargets[0] instanceof TCComponentMfgBvrCompoundOperation))) { +// localObject = "Mfg0MEStep"; +// } +// if ((this.pasteTargets == null) || (this.pasteTargets.length == 0) || ((this.itsAnOperation) && (!PasteUtils.isPastableForNewCommands((String)localObject, (TCComponent)this.pasteTargets[0]))) || ((!this.itsAnOperation) && (!PasteUtils.isPastableForNewCommands("Process", (TCComponent)this.pasteTargets[0])))) +// { +// this.openOnCreate.setSelected(true); +// this.openOnCreate.setEnabled(false); +// this.createAsNewRootFlag = true; +// } +// else if ((this.pasteTargets != null) && (this.pasteTargets.length > 0) && ((this.pasteTargets[0] instanceof TCComponentBOMLine))) +// { +// try +// { +// if (!((TCComponentBOMLine)this.pasteTargets[0]).isPasteAllowed()) +// { +// this.openOnCreate.setSelected(true); +// this.openOnCreate.setEnabled(false); +// this.createAsNewRootFlag = true; +// } +// } +// catch (TCException localTCException2) +// { +// MessageBox.post(localTCException2); +// } +// } +// this.okButton = new JButton(this.appReg.getString("ok")); +// } +// catch (TCException localTCException1) +// { +// MessageBox.post(localTCException1); +// } +// this.okButton.setMnemonic(this.appReg.getString("ok.MNEMONIC").charAt(0)); +// this.okButton.setEnabled(false); +// this.okButton.addActionListener(new ActionListener() +// { +// public void actionPerformed(ActionEvent paramAnonymousActionEvent) +// { +// NewMEProcessDialog.this.okOrApply = 0; +// if ((NewMEProcessDialog.this.validateId()) && (NewMEProcessDialog.this.numOfObjectsEntered <= NewMEProcessDialog.maxNumberOfItems)) { +// NewMEProcessDialog.this.startCreateOperation(); +// } +// } +// }); +// this.applyButton = new JButton(this.appReg.getString("apply")); +// this.applyButton.setMnemonic(this.appReg.getString("apply.MNEMONIC").charAt(0)); +// this.applyButton.setEnabled(false); +// this.applyButton.addActionListener(new ActionListener() +// { +// public void actionPerformed(ActionEvent paramAnonymousActionEvent) +// { +// NewMEProcessDialog.this.okOrApply = 1; +// if ((NewMEProcessDialog.this.validateId()) && (NewMEProcessDialog.this.numOfObjectsEntered <= NewMEProcessDialog.maxNumberOfItems)) { +// NewMEProcessDialog.this.startCreateOperation(); +// } +// } +// }); +// this.cancelButton = new JButton(this.appReg.getString("cancel")); +// this.cancelButton.setMnemonic(this.appReg.getString("cancel.MNEMONIC").charAt(0)); +// this.cancelButton.addActionListener(new AbstractAIFDialog.IC_DisposeActionListener()); +// this.cancelButton.addActionListener(new ActionListener() +// { +// public void actionPerformed(ActionEvent paramAnonymousActionEvent) +// { +// NewMEProcessDialog.this.disposeDialog(); +// NewMEProcessDialog.this.useTemplatePanel.close(); +// } +// }); +// setDefaultCloseOperation(0); +// addWindowListener(new WindowAdapter() +// { +// public void windowClosing(WindowEvent paramAnonymousWindowEvent) +// { +// NewMEProcessDialog.this.cancelButton.doClick(); +// } +// }); +// this.useTemplatePanel = getTemplatePanel(str4); +// this.cancelButton.addActionListener(this.useTemplatePanel); +// this.okButton.addActionListener(this.useTemplatePanel); +// this.useTemplatePanel.getTemplateTextField().addKeyListener(new KeyAdapter() +// { +// public void keyReleased(KeyEvent paramAnonymousKeyEvent) +// { +// JTextField localJTextField = (JTextField)paramAnonymousKeyEvent.getSource(); +// String str = localJTextField.getText(); +// boolean bool = str.length() > 0; +// NewMEProcessDialog.this.assignButton.setEnabled(bool); +// } +// +// public void keyTyped(KeyEvent paramAnonymousKeyEvent) +// { +// JTextField localJTextField = (JTextField)paramAnonymousKeyEvent.getSource(); +// String str = localJTextField.getText(); +// int i = 128; +// if (str.length() >= i) +// { +// localJTextField.setText(str.substring(0, i - 1)); +// Toolkit.getDefaultToolkit().beep(); +// } +// } +// }); +// this.useTemplatePanel.getGetTemplateIDButton().addActionListener(new ActionListener() +// { +// public void actionPerformed(ActionEvent paramAnonymousActionEvent) +// { +// TCComponentBOMLine[] arrayOfTCComponentBOMLine = SelectionUtil.getSelectedBOMLines(); +// if (arrayOfTCComponentBOMLine != null) +// { +// final NewMEProcessDialog.GetPropertyOperation localGetPropertyOperation = new NewMEProcessDialog.GetPropertyOperation(NewMEProcessDialog.this, arrayOfTCComponentBOMLine[0]); +// localGetPropertyOperation.addOperationListener(new InterfaceAIFOperationListener() +// { +// public void startOperation(String paramAnonymous2String) {} +// +// public void endOperation() +// { +// final String str = (String)localGetPropertyOperation.getOperationResult(); +// SWTUIUtilities.asyncExec(new Runnable() +// { +// public void run() +// { +// NewMEProcessDialog.this.useTemplatePanel.getTemplateTextField().setText(str); +// TCComponentItem localTCComponentItem = NewMEProcessDialog.this.getTemplateComponent(); +// if (localTCComponentItem != null) { +// NewMEProcessDialog.this.favoriteSelected(localTCComponentItem); +// } +// JTextField localJTextField = NewMEProcessDialog.this.useTemplatePanel.getTemplateTextField(); +// String str = localJTextField.getText(); +// int i = 128; +// if (str.length() >= i) +// { +// localJTextField.setText(str.substring(0, i - 1)); +// Toolkit.getDefaultToolkit().beep(); +// } +// boolean bool = str.length() > 0; +// NewMEProcessDialog.this.assignButton.setEnabled(bool); +// } +// }); +// } +// }); +// NewMEProcessDialog.this.session.queueOperation(localGetPropertyOperation); +// } +// } +// }); +// this.useTemplatePanel.getTemplateTextField().addActionListener(new ActionListener() +// { +// public void actionPerformed(ActionEvent paramAnonymousActionEvent) +// { +// TCComponentItem localTCComponentItem = NewMEProcessDialog.this.getTemplateComponent(); +// if (localTCComponentItem != null) { +// NewMEProcessDialog.this.favoriteSelected(localTCComponentItem); +// } +// } +// }); +// this.useTemplatePanel.getTemplateTextField().addFocusListener(new FocusAdapter() +// { +// public void focusGained(FocusEvent paramAnonymousFocusEvent) +// { +// NewMEProcessDialog.this.useTemplatePanel.getTemplateTextField().selectAll(); +// } +// }); +// localJPanel2.add(this.okButton); +// addApplyButton(localJPanel2); +// localJPanel2.add(this.cancelButton); +// localJPanel3.add("left", this.idLabel); +// localJPanel3.add("left", new JLabel(str2)); +// localJPanel3.add("left", localJLabel2); +// localJPanel3.add("left", new JLabel(str3)); +// localJPanel3.add("left.nobind", localJLabel3); +// localJPanel4.add("left.nobind", this.id); +// localJPanel4.add("left", new JLabel(str2)); +// localJPanel4.add("left.nobind", this.rev); +// localJPanel4.add("left", new JLabel(str3)); +// localJPanel4.add("left.nobind", this.namePanel); +// localJPanel4.add("left.nobind", this.assignButton); +// localJPanel7.add("1.1.left.top", localJLabel4); +// localJPanel7.add("1.2.center.center.resizable.resizable", localJScrollPane); +// localJPanel5.add("top", localJPanel3); +// localJPanel5.add("top.bind", localJPanel4); +// addQuantityPanel(localJPanel5); +// localJPanel6.add("top.bind.resizable.resizable", localJPanel5); +// localJPanel6.add("top.bind.resizable.resizable", localJPanel7); +// TCComponent localTCComponent = null; +// if ((!getOpenOnCreateFlag()) && (this.pasteTargets != null) && (this.pasteTargets.length > 0)) +// { +// localTCComponent = (TCComponent)AdapterUtil.getAdapter(this.pasteTargets[0], TCComponent.class); +// if ((localTCComponent != null) && ((MFGStructureTypeUtil.isProcess(localTCComponent)) || (MFGStructureTypeUtil.isOperation(localTCComponent)))) +// { +// this.parentLineLabel = new JLabel(MessageFormat.format(Messages.FromTemple_createUnder, new Object[] { localTCComponent.toDisplayString() }), TCTypeRenderer.getIcon(localTCComponent, false), 2); +// localJPanel1.add("top.nobind.left", this.parentLineLabel); +// } +// } +// else +// { +// localJPanel1.add("top.nobind.left", localJLabel1); +// } +// localJPanel1.add("top.bind", new Separator()); +// localJPanel1.add("top.bind", this.useTemplatePanel); +// localJPanel1.add("top.bind.resizable.resizable", this.customTab); +// addOpenOnCreate(localJPanel1); +// localJPanel1.add("bottom.bind.center.top", localJPanel2); +// localJPanel1.add("bottom.bind", new Separator()); +// setSize(getWidth(), getHeight() + 50); +// pack(); +// setPersistentDisplay(true); +// this.id.requestFocus(); +// } +// +// private void addValidator(JSpinner paramJSpinner) +// { +// final JFormattedTextField localJFormattedTextField = ((JSpinner.DefaultEditor)this.quantitySpinner.getEditor()).getTextField(); +// localJFormattedTextField.addFocusListener(new FocusAdapter() +// { +// public void focusLost(FocusEvent paramAnonymousFocusEvent) +// { +// String str1 = localJFormattedTextField.getText(); +// int i = 1; +// try +// { +// NewMEProcessDialog.this.numOfObjectsEntered = Integer.parseInt(str1); +// } +// catch (NumberFormatException localNumberFormatException) +// { +// i = 0; +// } +// if ((NewMEProcessDialog.this.numOfObjectsEntered > NewMEProcessDialog.maxNumberOfItems) || (i == 0)) +// { +// String str2 = MessageFormat.format(com.teamcenter.rac.cme.bvr.create.item.Messages.CreateItem_invalidQuantity_MSG, new Object[] { Integer.valueOf(NewMEProcessDialog.maxNumberOfItems) }); +// MessageBox.post(str2, com.teamcenter.rac.cme.bvr.create.item.Messages.CreateItem_InvalidQuantity_TITLE, 1); +// localJFormattedTextField.requestFocusInWindow(); +// } +// } +// }); +// } +// +// protected void addApplyButton(JPanel paramJPanel) +// { +// paramJPanel.add(this.applyButton); +// } +// +// protected void enableApplyButton() +// { +// this.applyButton.setEnabled(!this.openOnCreate.isSelected()); +// } +// +// protected void showHideParentLineLabel() +// { +// if ((this.parentLineLabel != null) && (this.openOnCreate != null)) { +// this.parentLineLabel.setVisible(!this.openOnCreate.isSelected()); +// } +// } +// +// protected void setCreationType() +// { +// if ((this.pasteTargets != null) && (this.pasteTargets.length == 1) && ((this.pasteTargets[0] instanceof TCComponent))) +// { +// this.itsAPlan = (((this.pasteTargets[0] instanceof TCComponentMEProcess)) || ((this.pasteTargets[0] instanceof TCComponentMEProcessRevision))); +// this.itsAnOperation = (!this.itsAPlan); +// } +// } +// +// protected METemplatePanel getTemplatePanel(String paramString) +// { +// return new METemplatePanel(this, this.session, this.desktop, "Process.Template", "Process.Template." + paramString, paramString, true); +// } +// +// protected void addOpenOnCreate(JPanel paramJPanel) +// { +// paramJPanel.add("left", this.openOnCreate); +// } +// +// protected void addQuantityPanel(JPanel paramJPanel) +// { +// paramJPanel.add("top.bind", this.quantityPanel); +// ActionListener local24 = new ActionListener() +// { +// private int numObjectsToCreate = 1; +// +// public void actionPerformed(ActionEvent paramAnonymousActionEvent) +// { +// boolean bool1 = NewMEProcessDialog.this.openOnCreate.isSelected(); +// boolean bool2 = !bool1; +// int i = 0; +// Object localObject; +// if (NewMEProcessDialog.this.pasteTargets != null) +// { +// InterfaceAIFComponent[] arrayOfInterfaceAIFComponent; +// int k = (arrayOfInterfaceAIFComponent = NewMEProcessDialog.this.pasteTargets).length; +// for (int j = 0; j < k; j++) +// { +// localObject = arrayOfInterfaceAIFComponent[j]; +// if ((localObject instanceof TCComponentAppGroupBOPLine)) +// { +// i = 1; +// break; +// } +// } +// if (i != 0) { +// bool2 = false; +// } +// } +// NewMEProcessDialog.this.quantitySpinner.setEnabled(bool2); +// NewMEProcessDialog.this.spinnerLable.setEnabled(bool2); +// if (bool2) +// { +// NewMEProcessDialog.this.quantitySpinner.setToolTipText(null); +// NewMEProcessDialog.this.spinnerLable.setToolTipText(null); +// NewMEProcessDialog.this.quantitySpinnerModel.setValue(Integer.valueOf(this.numObjectsToCreate)); +// } +// else +// { +// this.numObjectsToCreate = NewMEProcessDialog.this.quantitySpinnerModel.getNumber().intValue(); +// NewMEProcessDialog.this.quantitySpinnerModel.setValue(Integer.valueOf(1)); +// if (bool1) +// { +// localObject = NewMEProcessDialog.this.appReg.getString(NewMEProcessDialog.this.itsAnOperation ? "QuantityFieldDisabledForRootOperations" : "QuantityFieldDisabledForRootProcesses"); +// NewMEProcessDialog.this.quantitySpinner.setToolTipText((String)localObject); +// NewMEProcessDialog.this.spinnerLable.setToolTipText((String)localObject); +// } +// else if (i != 0) +// { +// localObject = NewMEProcessDialog.this.appReg.getString("QuantityFieldDisabledForOG"); +// NewMEProcessDialog.this.quantitySpinner.setToolTipText((String)localObject); +// NewMEProcessDialog.this.spinnerLable.setToolTipText((String)localObject); +// } +// } +// } +// }; +// this.openOnCreate.addActionListener(local24); +// local24.actionPerformed(null); +// } +// +// public JComponent getNameField() +// { +// return this.name; +// } +// +// private String getProcessType(TCComponent paramTCComponent) +// { +// String str; +// if (this.itsAPlan) +// { +// try +// { +// str = paramTCComponent.getType(); +// if ((this.itsAPlan) && (str.equals("MEProcessRevision"))) { +// str = this.defaultProcessTypeName; +// } +// } +// catch (Exception localException1) +// { +// str = this.defaultProcessTypeName; +// } +// return str; +// } +// try +// { +// str = paramTCComponent.getType(); +// if ((this.itsAnOperation) && (str.equals("MEOPRevision"))) { +// str = this.defaultProcessTypeName; +// } +// } +// catch (Exception localException2) +// { +// str = this.defaultProcessTypeName; +// } +// return str; +// } +// +// private void clearFields() +// { +// this.id.setText(""); +// this.id.setEditable(true); +// this.rev.setText(""); +// validateEntries(); +// } +// +// /** +// * 工艺生成新的ID +// * +// * @param oldItemID +// * @return +// */ +// public static String getGyRuleID(TCSession session, String oldItemID) { +// DecimalFormat df = new DecimalFormat("000000"); +// String newID = oldItemID + "-000001"; +// // String idTemp = +// TCComponentItemType tccomponentitemtype; +// try { +// tccomponentitemtype = (TCComponentItemType) (session +// .getTypeComponent("Item")); +// int i = 1; +// while (tccomponentitemtype.find(newID) != null) { +// i++; +// newID = oldItemID + "-" + df.format(i); +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return newID; +// } +// +// private void getAssignedIds(String paramString) +// { +// TCComponentItemType localTCComponentItemType = null; +// String str1; +// Object localObject; +// try +// { +// localTCComponentItemType = (TCComponentItemType)this.session.getTypeComponent(paramString); +// str1 = getMEProcessID(); +// if (str1.length() == 0) +// { +// if(this.templateIDStr.indexOf("-") > 0) +// { +// +// String str2 = getGyRuleID(session, templateIDStr.substring(0, templateIDStr.lastIndexOf("-")));//localTCComponentItemType.getNewID(); +// +// this.isIDModifiable = false;//localTCComponentItemType.isNewIDModifiable(str2); +// this.id.setText(str2); +// if (!this.isIDModifiable) { +// this.id.setEditable(false); +// } +// } +// else +// { +// String str2 = localTCComponentItemType.getNewID(); +// +// this.isIDModifiable = localTCComponentItemType.isNewIDModifiable(str2); +// this.id.setText(str2); +// if (!this.isIDModifiable) { +// this.id.setEditable(false); +// } +// } +// +// } +// } +// catch (TCException localTCException1) +// { +// localObject = new MessageBox(this.parent, localTCException1); +// ((MessageBox)localObject).setModal(true); +// ((MessageBox)localObject).setVisible(true); +// return; +// } +// String str3; +// try +// { +// if ((str1.length() > 0) && (this.meProcessComponent == null)) +// { +// this.meProcessComponent = localTCComponentItemType.find(str1); +// if (this.meProcessComponent != null) +// { +// str3 = this.meProcessComponent.getProperty("object_name"); +// localObject = this.meProcessComponent.getProperty("object_desc"); +// String str4 = getProcessType(this.meProcessComponent); +// this.defaultProcessTypeName = str4; +// this.name.setText(str3); +// this.descriptionText.setText((String)localObject); +// } +// } +// } +// catch (TCException localTCException3) +// { +// this.meProcessComponent = null; +// } +// try +// { +// str3 = localTCComponentItemType.getNewRev(this.meProcessComponent); +// this.isRevIDModifiable = localTCComponentItemType.isNewRevModifiable(this.meProcessComponent, str3); +// this.rev.setText(str3); +// if (!this.isRevIDModifiable) { +// this.rev.setEditable(false); +// } +// } +// catch (TCException localTCException2) +// { +// localObject = new MessageBox(this.parent, localTCException2); +// ((MessageBox)localObject).setModal(true); +// ((MessageBox)localObject).setVisible(true); +// return; +// } +// if (paramString.equalsIgnoreCase("Mfg0MEPlantBOP")) +// { +// this.openOnCreate.setSelected(true); +// this.openOnCreate.setEnabled(false); +// } +// } +// +// protected void startCreateOperation() +// { +// String str1 = this.useTemplatePanel.getTemplateId(); +// TCComponentRevisionRule localTCComponentRevisionRule = this.useTemplatePanel.getTemplateRevisionRule(); +// String str2 = this.useTemplatePanel.getTemplateCloningRule(); +// TCComponent[] arrayOfTCComponent = getTemplateReferenceStructureTCComponents(); +// String str3 = this.useTemplatePanel.getTemplateUID(); +// int i = getNumberOfItemsToCreate(); +// String str4 = null; +// String str5 = null; +// String str6 = getMEProcessType(); +// String str7 = getMEProcessName(); +// if (i == 1) +// { +// str4 = getMEProcessID(); +// str5 = getRevID(); +// } +// this.tempTargets = this.pasteTargets; +// if (getOpenOnCreateFlag()) { +// this.tempTargets = null; +// } +// this.newMEProcessOp = new NewMEProcessOperation(this.session, this.itsAPlan, this.desktop, str7, str4, str5, getDescription(), str6, getUnitofMeasure(), getOpenOnCreateFlag(), this.tempTargets, this.meProcessComponent, null, this.targetProductItem, "Process.Template." + str2, str1, localTCComponentRevisionRule, i, arrayOfTCComponent, this.useTemplatePanel, str3); +// this.newMEProcessOp.addOperationListener(this); +// this.session.queueOperation(this.newMEProcessOp); +// } +// +// public void startOperation(String paramString) +// { +// SwingUtilities.invokeLater(new Runnable() +// { +// public void run() +// { +// NewMEProcessDialog.this.okButton.setVisible(false); +// NewMEProcessDialog.this.applyButton.setVisible(false); +// NewMEProcessDialog.this.cancelButton.setVisible(false); +// NewMEProcessDialog.this.id.setEnabled(false); +// NewMEProcessDialog.this.rev.setEnabled(false); +// NewMEProcessDialog.this.namePanel.setEnabled(false); +// NewMEProcessDialog.this.openOnCreate.setEnabled(false); +// NewMEProcessDialog.this.useTemplatePanel.setCloneComponentsEnabled(false); +// NewMEProcessDialog.this.validate(); +// } +// }); +// } +// +// public void endOperation() +// { +// this.newMEProcessOp.removeOperationListener(this); +// if (!this.newMEProcessOp.isAbortRequested()) +// { +// this.okButton.setVisible(true); +// this.applyButton.setVisible(true); +// this.cancelButton.setVisible(true); +// this.id.setEnabled(true); +// this.id.setText(""); +// this.rev.setEnabled(true); +// this.rev.setText(""); +// this.namePanel.setEnabled(true); +// if ((this.pasteTargets == null) || (this.itsAnOperation)) { +// this.openOnCreate.setEnabled(false); +// } else if ((this.pasteTargets != null) && (this.pasteTargets.length > 0) && ((this.pasteTargets[0] instanceof TCComponentBOMLine))) { +// try +// { +// if (!((TCComponentBOMLine)this.pasteTargets[0]).isPasteAllowed()) { +// this.openOnCreate.setEnabled(false); +// } else { +// this.openOnCreate.setEnabled(true); +// } +// } +// catch (TCException localTCException) +// { +// MessageBox.post(localTCException); +// } +// } else { +// this.openOnCreate.setEnabled(true); +// } +// this.useTemplatePanel.setCloneComponentsEnabled(true); +// this.namePanel.requestFocus(); +// if ((this.namePanel.getComponent(0) instanceof JTextField)) { +// this.name.selectAll(); +// } +// validate(); +// validateEntries(); +// if (this.newMEProcessOp.getSuccessFlag()) +// { +// if (this.okOrApply == 0) +// { +// disposeDialog(); +// this.useTemplatePanel.close(); +// } +// else if ((this.pasteTargets != null) && (this.pasteTargets.length == 1)) +// { +// TCComponent localTCComponent = (TCComponent)this.pasteTargets[0]; +// if ((localTCComponent instanceof TCComponentBOMLine)) { +// clearFields(); +// } +// } +// if (this.tempTargets != null) { +// this.opSuccessAndNotNewRootFlag = true; +// } +// } +// } +// } +// +// public TCComponent getNewProcess() +// { +// return this.newMEProcessOp.getNewProcess(); +// } +// +// public String getMEProcessName() +// { +// return this.name.getText(); +// } +// +// public String getMEProcessID() +// { +// return this.id.getText(); +// } +// +// public String getRevID() +// { +// return this.rev.getText(); +// } +// +// public String getDescription() +// { +// return this.descriptionText.getText(); +// } +// +// public TCComponent getUnitofMeasure() +// { +// return null; +// } +// +// public String getMEProcessType() +// { +// if ((this.meProcessType != null) && (this.templateIDStr.equals(this.useTemplatePanel.getTemplateId())) && (this.templateUIDStr.equals(this.useTemplatePanel.getTemplateUID()))) { +// return this.meProcessType; +// } +// this.templateIDStr = this.useTemplatePanel.getTemplateId(); +// this.templateUIDStr = this.useTemplatePanel.getTemplateUID(); +// this.meProcessType = null; +// TCComponentItem localTCComponentItem = getTemplateComponent(); +// if (localTCComponentItem != null) +// { +// this.meProcessType = localTCComponentItem.getType(); +// return this.meProcessType; +// } +// return null; +// } +// +// public boolean getOpenOnCreateFlag() +// { +// return this.openOnCreate.isSelected(); +// } +// +// private TCComponentItem getTemplateComponent() +// { +// String str1 = this.useTemplatePanel.getTemplateTextField().getText(); +// if ((str1 != null) && (!str1.equals(""))) { +// try +// { +// TCComponentQueryType localTCComponentQueryType = (TCComponentQueryType)this.session.getTypeComponent("ImanQuery"); +// String str2 = this.useTemplatePanel.getTemplateUID(); +// TCTextService localTCTextService = this.session.getTextService(); +// String str3 = localTCTextService.getTextValue("k_find_component_name"); +// TCComponentQuery localTCComponentQuery = (TCComponentQuery)localTCComponentQueryType.find("Item - simple"); +// if (localTCComponentQuery == null) { +// localTCComponentQuery = (TCComponentQuery)localTCComponentQueryType.find(str3); +// } +// String[] arrayOfString1 = { localTCTextService.getTextValue("ItemID") }; +// String[] arrayOfString2 = { str1 }; +// TCComponentContextList localTCComponentContextList = localTCComponentQuery.getExecuteResultsList(arrayOfString1, arrayOfString2); +// TCComponent[] arrayOfTCComponent = localTCComponentContextList.toTCComponentArray(); +// if ((arrayOfTCComponent != null) && (arrayOfTCComponent.length > 1) && (!str2.equalsIgnoreCase(""))) { +// for (int i = 0; i < arrayOfTCComponent.length; i++) { +// if ((str2.equalsIgnoreCase(arrayOfTCComponent[i].getUid())) && (i != 0)) +// { +// TCComponent localTCComponent = arrayOfTCComponent[0]; +// arrayOfTCComponent[0] = arrayOfTCComponent[i]; +// arrayOfTCComponent[i] = localTCComponent; +// } +// } +// } +// if ((arrayOfTCComponent == null) || (arrayOfTCComponent.length == 0) || (arrayOfTCComponent[0] == null) || (arrayOfTCComponent[0] instanceof TCComponentMEProcess == this.itsAnOperation) || (arrayOfTCComponent[0] instanceof TCComponentMEOP != this.itsAnOperation)) +// { +// MessageBox.post(this, this.appReg.getString("NoMatchingObject.MSG"), this.appReg.getString("NoMatchingObject.TITLE"), 1); +// return null; +// } +// if ((!this.itsAnOperation) && (!TCUtilities.isAllowedToCreate(arrayOfTCComponent[0], "MEProcess"))) +// { +// MessageBox.post(this.appReg.getString("newMEProductTemplates.roleProhibitCreate") + " " + arrayOfTCComponent[0].getSubType(), this.appReg.getString("failToCreate"), 4); +// return null; +// } +// if ((this.itsAnOperation) && (!TCUtilities.isAllowedToCreate(arrayOfTCComponent[0], "MEOP"))) +// { +// MessageBox.post(this.appReg.getString("newMEProductTemplates.roleProhibitCreate") + " " + arrayOfTCComponent[0].getSubType(), this.appReg.getString("failToCreate"), 4); +// return null; +// } +// return (TCComponentItem)arrayOfTCComponent[0]; +// } +// catch (Exception localException) {} +// } +// return null; +// } +// +// public void favoriteSelected(TCComponent paramTCComponent) +// { +// String str1 = paramTCComponent.getType(); +// if ((AutoGenerateIdUtil.isAutoGenerateNeededForType(str1)) && ((this.previousTemplateType == null) || (!this.previousTemplateType.equals(str1)))) +// { +// setTextIdField(""); +// setTextRevField(""); +// this.previousTemplateType = str1; +// } +// if (((this.id.getText() == null) || (this.id.getText().length() == 0)) && ((this.rev.getText() == null) || (this.rev.getText().length() == 0))) { +// try { +// this.templateIDStr = paramTCComponent.getStringProperty("item_id"); +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// getAssignedIds(paramTCComponent.getType()); +// } +// String str2; +// try +// { +// str2 = paramTCComponent.getStringProperty("object_name"); +// this.name.setText(str2); +// } +// catch (TCException localTCException1) {} +// try +// { +// str2 = paramTCComponent.getStringProperty("object_desc"); +// this.descriptionText.setText(str2); +// } +// catch (TCException localTCException2) {} +// validateEntries(); +// } +// +// public void validateEntries() +// { +// autoIdRev(); +// this.previousTemplateType = getMEProcessType(); +// int i = this.id.getText().length(); +// int j = getMEProcessName().trim().length(); +// int k = this.rev.getText().length(); +// int m = this.useTemplatePanel.getTemplateId() != null ? this.useTemplatePanel.getTemplateId().length() : 0; +// int n = getNumberOfItemsToCreate(); +// if (n == 1) +// { +// setEnabledIdField(true); +// if (this.isIDModifiable) { +// this.id.setEditable(true); +// } +// setEnabledRevField(true); +// if (this.isRevIDModifiable) { +// this.rev.setEditable(true); +// } +// } +// else +// { +// setEnabledIdField(false); +// setEnabledRevField(false); +// setTextIdField(""); +// setTextRevField(""); +// } +// if (((i > 0) && (k > 0)) || (n > 1) || (m == 0)) { +// this.assignButton.setEnabled(false); +// } else { +// this.assignButton.setEnabled(true); +// } +// if (((i > 0) && (k > 0)) || ((n > 1) && (j > 0) && (m > 0))) +// { +// this.okButton.setEnabled(true); +// enableApplyButton(); +// return; +// } +// this.okButton.setEnabled(false); +// this.applyButton.setEnabled(false); +// } +// +// public void run() +// { +// SwingUtilities.invokeLater(new Runnable() +// { +// public void run() +// { +// NewMEProcessDialog.this.setVisible(true); +// } +// }); +// } +// +// private void autoIdRev() +// { +// String str = getMEProcessType(); +// if (str != null) { +// if ((str.equalsIgnoreCase("Mfg0MEPlantBOP")) && ((this.openOnCreate.isEnabled()) || (!this.openOnCreate.isSelected()))) +// { +// this.openOnCreate.setSelected(true); +// this.openOnCreate.setEnabled(false); +// } +// else if ((!str.equalsIgnoreCase("Mfg0MEPlantBOP")) && (!this.openOnCreate.isEnabled()) && (!this.createAsNewRootFlag)) +// { +// this.openOnCreate.setSelected(false); +// this.openOnCreate.setEnabled(true); +// } +// } +// if ((!getMEProcessID().equals("")) && (!getRevID().equals(""))) { +// return; +// } +// if (AutoGenerateIdUtil.isAutoGenerateNeededForType(str)) { +// getAssignedIds(str); +// } +// } +// +// private boolean validateId() +// { +// Object localObject1 = null; +// if (getMEProcessID().length() > 0) +// { +// TCComponentItemType localTCComponentItemType = null; +// Object localObject2; +// try +// { +// localObject2 = getMEProcessType(); +// if ((localObject2 == null) || (((String)localObject2).length() == 0)) { +// return false; +// } +// TCComponentType localTCComponentType = this.session.getTypeComponent(getMEProcessType()); +// if (localTCComponentType != null) { +// if ((localTCComponentType instanceof TCComponentItemType)) +// { +// localTCComponentItemType = (TCComponentItemType)localTCComponentType; +// localObject1 = localTCComponentItemType.find(getMEProcessID()); +// } +// else if ((localTCComponentType instanceof TCComponentItemRevisionType)) +// { +// TCComponentItemRevisionType localTCComponentItemRevisionType = (TCComponentItemRevisionType)localTCComponentType; +// localObject1 = localTCComponentItemRevisionType.findRevision(getMEProcessID(), getRevID()); +// } +// } +// } +// catch (TCException localTCException2) +// { +// return true; +// } +// if (localObject1 != null) +// { +// localObject2 = Registry.getRegistry(this); +// MessageBox.post(((Registry)localObject2).getString("sameAsOldId"), ((Registry)localObject2).getString("error.TITLE"), 4); +// return false; +// } +// if (localTCComponentItemType != null) { +// try +// { +// localTCComponentItemType.validateId(getMEProcessID(), getRevID(), getMEProcessType()); +// } +// catch (TCException localTCException1) +// { +// MessageBox.post(this.parent, localTCException1); +// return false; +// } +// } +// } +// return true; +// } +// +// public int getNumberOfItemsToCreate() +// { +// return this.quantitySpinnerModel.getNumber().intValue(); +// } +// +// public void setEnabledIdField(boolean paramBoolean) +// { +// this.id.setEnabled(paramBoolean); +// } +// +// public void setTextIdField(String paramString) +// { +// this.id.setText(paramString); +// } +// +// public void setEnabledRevField(boolean paramBoolean) +// { +// this.rev.setEnabled(paramBoolean); +// } +// +// public void setTextRevField(String paramString) +// { +// this.rev.setText(paramString); +// } +// +// public TCComponent[] getTemplateReferenceStructureTCComponents() +// { +// return this.useTemplatePanel.getTemplateReferenceStructureTCComponents(); +// } +// +// public boolean isOpSuccessAndNotNewRootFlag() +// { +// return this.opSuccessAndNotNewRootFlag; +// } +// +// private class GetPropertyOperation +// extends AbstractAIFOperation +// { +// private TCComponentBOMLine bomline; +// +// public GetPropertyOperation(NewMEProcessDialog createMEProcessDialog, TCComponentBOMLine paramTCComponentBOMLine) +// { +// this.bomline = paramTCComponentBOMLine; +// } +// +// public void executeOperation() +// throws Exception +// { +// storeOperationResult(this.bomline.getProperty("bl_item_item_id")); +// } +// } +//} diff --git a/src/com/teamcenter/rac/cme/bvr/create/fromtemplate/NewMEProcessOperation.java b/src/com/teamcenter/rac/cme/bvr/create/fromtemplate/NewMEProcessOperation.java new file mode 100644 index 0000000..789daf9 --- /dev/null +++ b/src/com/teamcenter/rac/cme/bvr/create/fromtemplate/NewMEProcessOperation.java @@ -0,0 +1,949 @@ +package com.teamcenter.rac.cme.bvr.create.fromtemplate; + +import java.text.DecimalFormat; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.eclipse.swt.widgets.Display; + +import com.teamcenter.rac.aif.AIFDesktop; +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.aifrcp.AIFUtility; +import com.teamcenter.rac.aifrcp.event.ClientEventDispatcher; +import com.teamcenter.rac.cme.bvr.connect.Activator; +import com.teamcenter.rac.cme.bvr.create.fromtemplate.METemplatePanel; +import com.teamcenter.rac.cme.bvr.create.fromtemplate.Messages; +import com.teamcenter.rac.cme.common.views.secondary.AttachmentsView; +import com.teamcenter.rac.cme.connect.ConnectUtil; +import com.teamcenter.rac.cme.connect.MFGConnectData; +import com.teamcenter.rac.cme.connect.MfgConnectOperation; +import com.teamcenter.rac.cme.license.services.ICMELicenseService; +import com.teamcenter.rac.commands.newitem.IdUtils; +import com.teamcenter.rac.common.TCUtilities; +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.TCComponentBOPWindow; +import com.teamcenter.rac.kernel.TCComponentBOPWindowType; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentMEActivity; +import com.teamcenter.rac.kernel.TCComponentMEOP; +import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEOPType; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcessType; +import com.teamcenter.rac.kernel.TCComponentPart; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentRevisionRule; +import com.teamcenter.rac.kernel.TCComponentRevisionRuleType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.ms.util.ApplicationPerspectiveUtil; +import com.teamcenter.rac.psebase.AbstractBOMLineViewerApplication; +import com.teamcenter.rac.services.IOpenService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; +import com.teamcenter.rac.util.log.TcLogger; +import com.teamcenter.services.internal.rac.structuremanagement.StructureService; +import com.teamcenter.services.internal.rac.structuremanagement._2008_06.Structure; +import com.teamcenter.services.rac.core.DataManagementService; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse; + +public class NewMEProcessOperation + extends AbstractAIFOperation +{ + private static final String COMPONENT_LICENSE_ID = "PROCESS_AUTH"; + protected String meprocessName; + protected String meprocessId; + protected String revId; + protected String description; + protected String meprocessType; + protected TCComponent unitOfMeasure; + protected boolean openOnCreateFlag = true; + protected TCComponentItem oldMEProcess; + protected TCComponentItemRevision revToSaveAs; + protected InterfaceAIFComponent[] pasteTargets; + protected TCComponent newMEProcess; + protected TCComponentItemRevision targetProduct; + protected AIFDesktop desktop; + protected String templatePreferenceKey; + protected String templateId; + private String templateUID; + protected TCComponentRevisionRule templateRevRule; + private boolean successFlag = true; + private AbstractAIFUIApplication theApp; + private boolean itsAPlan; + private int itemsQuantity = 1; + private METemplatePanel templatePanel; +// private static TcLogger logger = TcLogger.getLogger(CreateMEProcessOperation.class); + protected TCComponent[] refStructs; + protected List dataToPaste; + protected TCSession session; + + public NewMEProcessOperation(TCSession paramTCSession, boolean paramBoolean1, AIFDesktop paramAIFDesktop, String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, TCComponent paramTCComponent, boolean paramBoolean2, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent, TCComponentItem paramTCComponentItem, TCComponentItemRevision paramTCComponentItemRevision1, TCComponentItemRevision paramTCComponentItemRevision2, String paramString6, String paramString7, TCComponentRevisionRule paramTCComponentRevisionRule, TCComponent[] paramArrayOfTCComponent) + { + this.session = paramTCSession; + this.itsAPlan = paramBoolean1; + this.desktop = paramAIFDesktop; + this.meprocessName = paramString1; + this.meprocessId = paramString2; + this.revId = paramString3; + this.description = paramString4; + this.meprocessType = paramString5; + this.unitOfMeasure = paramTCComponent; + this.openOnCreateFlag = paramBoolean2; + this.pasteTargets = paramArrayOfInterfaceAIFComponent; + this.oldMEProcess = paramTCComponentItem; + this.revToSaveAs = paramTCComponentItemRevision1; + this.targetProduct = paramTCComponentItemRevision2; + this.templatePreferenceKey = paramString6; + this.templateId = paramString7; + this.templateRevRule = paramTCComponentRevisionRule; + this.refStructs = paramArrayOfTCComponent; + this.theApp = paramAIFDesktop.getCurrentApplication(); + } + + public NewMEProcessOperation(TCSession paramTCSession, boolean paramBoolean1, AIFDesktop paramAIFDesktop, String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, TCComponent paramTCComponent, boolean paramBoolean2, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent, TCComponentItem paramTCComponentItem, TCComponentItemRevision paramTCComponentItemRevision1, TCComponentItemRevision paramTCComponentItemRevision2, String paramString6, String paramString7, TCComponentRevisionRule paramTCComponentRevisionRule, int paramInt, TCComponent[] paramArrayOfTCComponent) + { + this.session = paramTCSession; + this.itsAPlan = paramBoolean1; + this.desktop = paramAIFDesktop; + this.meprocessName = paramString1; + this.meprocessId = paramString2; + this.revId = paramString3; + this.description = paramString4; + this.meprocessType = paramString5; + this.unitOfMeasure = paramTCComponent; + this.openOnCreateFlag = paramBoolean2; + this.pasteTargets = paramArrayOfInterfaceAIFComponent; + this.oldMEProcess = paramTCComponentItem; + this.revToSaveAs = paramTCComponentItemRevision1; + this.targetProduct = paramTCComponentItemRevision2; + this.templatePreferenceKey = paramString6; + this.templateId = paramString7; + this.templateRevRule = paramTCComponentRevisionRule; + this.refStructs = paramArrayOfTCComponent; + this.theApp = paramAIFDesktop.getCurrentApplication(); + this.itemsQuantity = paramInt; + } + + public NewMEProcessOperation(TCSession paramTCSession, boolean paramBoolean1, AIFDesktop paramAIFDesktop, String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, TCComponent paramTCComponent, boolean paramBoolean2, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent, TCComponentItem paramTCComponentItem, TCComponentItemRevision paramTCComponentItemRevision1, TCComponentItemRevision paramTCComponentItemRevision2, String paramString6, String paramString7, TCComponentRevisionRule paramTCComponentRevisionRule, int paramInt, TCComponent[] paramArrayOfTCComponent, METemplatePanel paramMETemplatePanel) + { + this.session = paramTCSession; + this.itsAPlan = paramBoolean1; + this.desktop = paramAIFDesktop; + this.meprocessName = paramString1; + this.meprocessId = paramString2; + this.revId = paramString3; + this.description = paramString4; + this.meprocessType = paramString5; + this.unitOfMeasure = paramTCComponent; + this.openOnCreateFlag = paramBoolean2; + this.pasteTargets = paramArrayOfInterfaceAIFComponent; + this.oldMEProcess = paramTCComponentItem; + this.revToSaveAs = paramTCComponentItemRevision1; + this.targetProduct = paramTCComponentItemRevision2; + this.templatePreferenceKey = paramString6; + this.templateId = paramString7; + this.templateRevRule = paramTCComponentRevisionRule; + this.refStructs = paramArrayOfTCComponent; + this.theApp = paramAIFDesktop.getCurrentApplication(); + this.itemsQuantity = paramInt; + this.templatePanel = paramMETemplatePanel; + } + + public NewMEProcessOperation(TCSession paramTCSession, boolean paramBoolean1, AIFDesktop paramAIFDesktop, String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, TCComponent paramTCComponent, boolean paramBoolean2, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent, TCComponentMEProcess paramTCComponentMEProcess, TCComponentItemRevision paramTCComponentItemRevision) + { + this.session = paramTCSession; + this.desktop = paramAIFDesktop; + this.meprocessName = paramString1; + this.meprocessId = paramString2; + this.revId = paramString3; + this.description = paramString4; + this.meprocessType = paramString5; + this.unitOfMeasure = paramTCComponent; + this.openOnCreateFlag = paramBoolean2; + this.pasteTargets = paramArrayOfInterfaceAIFComponent; + this.oldMEProcess = paramTCComponentMEProcess; + this.targetProduct = paramTCComponentItemRevision; + this.itsAPlan = paramBoolean1; + this.templateId = null; + if (paramAIFDesktop != null) { + this.theApp = paramAIFDesktop.getCurrentApplication(); + } + } + + public NewMEProcessOperation(TCSession paramTCSession, boolean paramBoolean1, AIFDesktop paramAIFDesktop, String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, TCComponent paramTCComponent, boolean paramBoolean2, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent, TCComponentItem paramTCComponentItem, TCComponentItemRevision paramTCComponentItemRevision1, TCComponentItemRevision paramTCComponentItemRevision2, String paramString6, String paramString7, TCComponentRevisionRule paramTCComponentRevisionRule, int paramInt, TCComponent[] paramArrayOfTCComponent, METemplatePanel paramMETemplatePanel, String paramString8) + { + this.session = paramTCSession; + this.itsAPlan = paramBoolean1; + this.desktop = paramAIFDesktop; + this.meprocessName = paramString1; + this.meprocessId = paramString2; + this.revId = paramString3; + this.description = paramString4; + this.meprocessType = paramString5; + this.unitOfMeasure = paramTCComponent; + this.openOnCreateFlag = paramBoolean2; + this.pasteTargets = paramArrayOfInterfaceAIFComponent; + this.oldMEProcess = paramTCComponentItem; + this.revToSaveAs = paramTCComponentItemRevision1; + this.targetProduct = paramTCComponentItemRevision2; + this.templatePreferenceKey = paramString6; + this.templateId = paramString7; + this.templateRevRule = paramTCComponentRevisionRule; + this.refStructs = paramArrayOfTCComponent; + this.theApp = paramAIFDesktop.getCurrentApplication(); + this.itemsQuantity = paramInt; + this.templatePanel = paramMETemplatePanel; + this.templateUID = paramString8; + } + + public TCSession getSession() + { + return (TCSession)super.getSession(); + } + + public boolean getSuccessFlag() + { + return this.successFlag; + } + + public TCComponent getNewProcess() + { + return this.newMEProcess; + } + + public void executeOperation() + throws Exception + { + ICMELicenseService localICMELicenseService = Activator.getDefault().getCMELicenseService(); + String str = ApplicationPerspectiveUtil.getCurrentApplicationId(); + boolean bool = false; + if (localICMELicenseService != null) + { + bool = localICMELicenseService.checkAndConsumeComponentLicense("PROCESS_AUTH", str); + if (bool) { + executeOpInternal(); + } + } + } + + private void executeOpInternal() + throws Exception + { + Registry localRegistry = Registry.getRegistry(this); + if (this.itemsQuantity > 1) + { + IdUtils localIdUtils = new IdUtils(getSession()); + for (int i = 0; i < this.itemsQuantity; i++) + { + IdUtils.IdsData localIdsData = localIdUtils.generateIds(this.meprocessType); + String str1 = localIdsData.Id; + String str2 = localIdsData.Rev; + executeOperationInternal(localRegistry, this.meprocessName, str1, str2); + } + } + else + { + executeOperationInternal(localRegistry, this.meprocessName, this.meprocessId, this.revId); + } + if (this.newMEProcess != null) { + pasteNewComponent(localRegistry); + + //更改子对象的ID +// TCComponentMEProcess componentMEProcess = (TCComponentMEProcess) this.newMEProcess; +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); +// TCComponentBOMWindow bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topline = bomWindow.setWindowTopLine(componentMEProcess, componentMEProcess.getLatestItemRevision(), null, null); +// setMEOPId(topline); + } + } + + public void setMEOPId(TCComponentBOMLine topBomLine) throws Exception + { + AIFComponentContext[] childrens = topBomLine.getChildren(); + for (AIFComponentContext children : childrens) { + TCComponentBOMLine bomLine = ((TCComponentBOMLine) children.getComponent()); + + TCComponentItem item = bomLine.getItem(); + + //更新对象ID + String objectType = item.getProperty("object_type"); + System.out.println("objectType======================="+objectType); + String itemId = ""; + switch (objectType) { + case "ML8_SpecOp": + case "专项工序": + String ml8_SpecOpPeriod = item.getStringProperty("ml8_SpecOpPeriod"); + String ml8_SpecOpCode = item.getStringProperty("ml8_SpecOpCode"); + String ml8_SpecOpNumber = item.getStringProperty("ml8_SpecOpNumber"); + + itemId = getGyRuleID(getSession(), String.format("%s-%s-%s", ml8_SpecOpPeriod,ml8_SpecOpCode,ml8_SpecOpNumber)); + + break; + case "ML8_StdOperation": + case "标准工序": + + String stdOpType = item.getStringProperty("ml8_StdOpType"); + String stdOpPeriod = item.getStringProperty("ml8_StdOpPeriod"); + String productType = item.getStringProperty("ml8_ProductType"); + String materialType = item.getStringProperty("ml8_MaterialType"); + String stdOpNumber = item.getStringProperty("ml8_StdOpNumber"); + + itemId = getGyRuleID(getSession(), String.format("%s-%s%s%s-%s", stdOpType,stdOpPeriod,productType,materialType,stdOpNumber)); + + break; + + case "ML8_DifOperation": + case "差异化工序": + + String ml8_StdOpType = item.getStringProperty("ml8_StdOpType"); + String ml8_StdOpPeriod = item.getStringProperty("ml8_StdOpPeriod"); + String ml8_ProductType = item.getStringProperty("ml8_ProductType"); + String ml8_MaterialType = item.getStringProperty("ml8_MaterialType"); + String ml8_StdOpNumber = item.getStringProperty("ml8_StdOpNumber"); + + itemId = getGyRuleID(getSession(), String.format("%s-%s%s%s-%s", ml8_StdOpType,ml8_StdOpPeriod,ml8_ProductType,ml8_MaterialType,ml8_StdOpNumber)); + + break; + default: + break; + } + if(!itemId.isEmpty()) + { + item.lock(); + item.setProperty("item_id", itemId); + item.save(); + item.unlock(); + item.refresh(); + //return; + } + setMEOPId(bomLine); + } + } + + /** + * 工艺生成新的ID + * + * @param oldItemID + * @return + */ + public static String getGyRuleID(TCSession session, String oldItemID) { + DecimalFormat df = new DecimalFormat("000000"); + String newID = oldItemID + "-000001"; + // String idTemp = + TCComponentItemType tccomponentitemtype; + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("Item")); + + tccomponentitemtype.getNewID(); + int i = 1; + while (tccomponentitemtype.find(newID) != null) { + i++; + newID = oldItemID + "-" + df.format(i); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newID; + } + + /** + * 工艺生成新的ID + * + * @param oldItemID + * @return + */ + public static String getStdOpNumber( String itemID,int num) { + DecimalFormat df = new DecimalFormat("000"); + String newID = "010"; + // String idTemp = + try { + int i = 10; + while (itemID.compareTo(newID) != 0) { + i = i+1; + newID = df.format(i); + } + newID = df.format(i+num); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newID; + } + + private void executeOperationInternal(Registry paramRegistry, String paramString1, String paramString2, String paramString3) + throws Exception + { + if (this.templateId == null) { + createNotFromTemplate(paramRegistry, paramString1, paramString2, paramString3); + } else { + createFromTemplate(paramRegistry, paramString1, paramString2, paramString3); + } + if (isAbortRequested()) + { + getSession().setStatus(paramRegistry.getString("abort")); + } + else if (this.newMEProcess != null) + { + final Object localObject; + if ((this.pasteTargets != null) && (this.pasteTargets[0] != null) && (this.revToSaveAs != null) && ((this.pasteTargets[0] instanceof TCComponentBOMLine))) + { + localObject = (TCComponentBOMLine)this.pasteTargets[0]; + TCComponentItemRevision localTCComponentItemRevision = (TCComponentItemRevision)this.newMEProcess; + TCProperty localTCProperty = ((TCComponentBOMLine)localObject).getTCProperty("bl_is_precise"); + if (localTCProperty.getLogicalValue()) { + ((TCComponentBOMLine)localObject).replace(((TCComponentBOMLine)localObject).getItem(), localTCComponentItemRevision, ((TCComponentBOMLine)localObject).getReferenceProperty("bl_bomview")); + } + TCComponentBOMWindow localTCComponentBOMWindow = ((TCComponentBOMLine)localObject).window(); + localTCComponentBOMWindow.newIrfWhereConfigured(localTCComponentItemRevision); + localTCComponentBOMWindow.fireChangeEvent(); + } + if (this.openOnCreateFlag) + { + IOpenService localObject1 = AIFUtility.getCurrentOpenService(); + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + localObject1.open(NewMEProcessOperation.this.newMEProcess); + } + }); + } + else + { + getSession().setReadyStatus(); + } + } + } + + private void createNotFromTemplate(Registry paramRegistry, String paramString1, String paramString2, String paramString3) + throws Exception + { + getSession().setStatus(paramRegistry.getString("creatingNewMEProcess") + " " + paramString1 + " ..."); + try + { + Object localObject1; + if (this.itsAPlan) + { + localObject1 = null; + localObject1 = (TCComponentMEProcessType)getSession().getTypeComponent(this.meprocessType); + if (this.revToSaveAs != null) + { + this.newMEProcess = this.revToSaveAs.saveAs(paramString3, paramString1, this.description, false, null); + } + else if (this.oldMEProcess == null) + { + this.newMEProcess = ((TCComponentMEProcessType)localObject1).createProcess(paramString2, paramString3, this.meprocessType, paramString1, this.description); + if (this.targetProduct != null) { + this.newMEProcess.setRelated("IMAN_METarget", new TCComponent[] { this.targetProduct }); + } + } + } + else + { + localObject1 = null; + localObject1 = (TCComponentMEOPType)getSession().getTypeComponent(this.meprocessType); + if (this.revToSaveAs != null) + { + this.newMEProcess = this.revToSaveAs.saveAs(paramString3, paramString1, this.description, false, null); + } + else if (this.oldMEProcess == null) + { + this.newMEProcess = ((TCComponentMEOPType)localObject1).createProcessOperation(paramString2, paramString3, this.meprocessType, paramString1, this.description); + if (this.targetProduct != null) { + this.newMEProcess.setRelated("IMAN_METarget", new TCComponent[] { this.targetProduct }); + } + Object localObject2 = (TCComponentMEOP)this.newMEProcess; + Object localObject3 = (TCComponentMEOPRevision)((TCComponentMEOP)localObject2).getLatestItemRevision(); + TCComponentMEActivity localTCComponentMEActivity = (TCComponentMEActivity)((TCComponentMEOPRevision)localObject3).getRelatedComponent("root_activity"); + localTCComponentMEActivity.unlock(); + ((TCComponentMEOPRevision)localObject3).unlock(); + ((TCComponentMEOP)localObject2).unlock(); + } + else + { + this.newMEProcess = this.oldMEProcess.revise(paramString3, paramString1, this.description); + } + } + } + catch (TCException localTCException) + { + Object localObject3; + Object localObject2 = MessageFormat.format(paramRegistry.getString("failToCreate"), new Object[] { paramString1, localTCException.toString() }); + if (this.desktop != null) + { + localObject3 = new MessageBox(this.desktop, (String)localObject2, null, paramRegistry.getString("error.TITLE"), 1, true); + ((MessageBox)localObject3).setVisible(true); + } + else + { +// logger.error(localTCException.getLocalizedMessage(), localTCException); + } + this.successFlag = false; + throw localTCException; + } + if ((!(this.newMEProcess instanceof TCComponentMEProcessRevision)) && (!(this.newMEProcess instanceof TCComponentMEOPRevision))) { + addCompToPasteData(); + } + } + + private void createFromTemplate(Registry paramRegistry, String paramString1, String paramString2, String paramString3) + throws Exception + { + System.out.println("createFromTemplate"); + getSession().setStatus(paramRegistry.getString("cloningTemplate") + " " + this.templateId + " ..."); + TCComponentBOPWindow localTCComponentBOPWindow = null; + try + { + TCComponentItem localTCComponentItem = getTemplateItem(paramRegistry); + if (localTCComponentItem != null) + { + TCComponentBOMLine localTCComponentBOMLine = this.templatePanel.getTopBomLineFromTemplate(); + TCComponentBOMWindow[] arrayOfTCComponentBOMWindow = new TCComponentBOMWindow[2]; + if (this.refStructs != null) { + for (int i = 0; i < this.refStructs.length; i++) { + arrayOfTCComponentBOMWindow[i] = ((TCComponentBOMWindow)this.refStructs[i]); + } + } + TCComponent localTCComponent = null; + if ((this.theApp instanceof AbstractBOMLineViewerApplication)) + { + Object localObject1 = (AbstractBOMLineViewerApplication)this.theApp; + if (((AbstractBOMLineViewerApplication)localObject1).getEffectivityChangeControl() != null) { + localTCComponent = ((AbstractBOMLineViewerApplication)localObject1).getEffectivityChangeControl().getICRev(); + } + } + if (arrayOfTCComponentBOMWindow != null) + { + Object localObject1 = (TCComponentBOPWindowType)getSession().getTypeComponent("BOPWindow"); + localTCComponentBOPWindow = ((TCComponentBOPWindowType)localObject1).createBOPWindow(this.templateRevRule); + for (int j = 0; j < arrayOfTCComponentBOMWindow.length; j++) { + if (arrayOfTCComponentBOMWindow[j] != null) { + localTCComponentBOPWindow.addReferenceWindow(arrayOfTCComponentBOMWindow[j], "Temp"); + } + } + if (localTCComponent != null) { + localTCComponentBOPWindow.setIncrementalChangeRev(localTCComponent); + } + } + TCComponentItemRevision localObject1 = localTCComponentBOMLine.getItemRevision(); + if (localObject1 == null) + { + MessageBox.post(this.theApp.getDesktop(), Messages.FromTemplate_noConfiguredTopLineMsg, Messages.FromTemplate_noConfiguredTopLineTitle, 4); + this.successFlag = false; + return; + } + boolean bool1 = this.templatePanel.getCarryOverCheckboxValue(); + localTCComponentBOMLine.window().showSuppressedOccs(this.templatePanel.getCloneSuppressedLineCheckBoxValue()); + localTCComponentBOMLine.window().setRevisionRule(this.templatePanel.getTemplateRevisionRule()); + localTCComponentBOMLine.window().setRevisionRule(this.templatePanel.getTemplateRevisionRule()); + if (this.templatePanel.isEffectivityGroupUsed()) { + localTCComponentBOMLine.window().setEffGrpRevs(this.templatePanel.getEffGrpRevisions()); + } + if (this.templatePanel.isMiscFieldsChanged()) { + localTCComponentBOMLine.window().showUnconfiguredOccs(false); + } + StructureService localStructureService = StructureService.getService(getSession()); + Structure.CopyRecursivelyResponse localCopyRecursivelyResponse = localStructureService.copyRecursively + ((TCComponent)localObject1, this.templatePreferenceKey, localTCComponentBOMLine.window(), localTCComponentBOPWindow, + paramString1, this.description, paramString2, paramString3, bool1); + boolean bool2 = SoaUtil.handlePartialErrors(localCopyRecursivelyResponse.serviceData, AIFUtility.getActiveDesktop()); + if (bool2) + { + if (localCopyRecursivelyResponse.serviceData.sizeOfCreatedObjects() != 0) + { + TCComponentItemRevision localTCComponentItemRevision = (TCComponentItemRevision)localCopyRecursivelyResponse.serviceData.getCreatedObject(0); + if (localTCComponentItemRevision != null) { +// TCComponentBOMLine topBOMLine = localTCComponentBOPWindow.getTopBOMLine(); + AIFComponentContext[] children = localTCComponentBOMLine.getChildren(); + long time11 = System.nanoTime(); + System.out.println(children.length +"children" + localObject1.getStringProperty("object_string")); + getTableValue(localTCComponentBOMLine); + System.out.println("hs2ChangeList ===>"+hs2ChangeList.toString()); + System.out.println("hs2ImportantList ===>"+hs2ImportantList.toString()); + System.out.println("hs2ProcessControlList ===>"+hs2ProcessControlList.toString()); + + System.out.println("localTCComponentItemRevision ... "+localTCComponentItemRevision.getStringProperty("object_name")); + this.newMEProcess = localTCComponentItemRevision.getItem(); + TCComponentItem item = localTCComponentItemRevision.getItem(); +// newMEProcess.setR + System.out.println(newMEProcess.getStringProperty("item_id")+"newMEProcess === >"); + TCComponentBOMWindowType bopWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow bopWindow = bopWindowType.create(null); + TCComponentBOMLine topBopline = bopWindow.setWindowTopLine(item, item.getLatestItemRevision() , null, null); + + setTableValue(topBopline); + + long time12 = System.nanoTime(); + System.out.println("创建item用时(ms): " + (time12 - time11) / 1000000); + } + } + addCompToPasteData(); + } + } + } + catch (Exception localException) + { + MessageBox.post(localException); + getSession().setReadyStatus(); + this.successFlag = false; + throw localException; + } + finally + { + if (localTCComponentBOPWindow != null) + { + localTCComponentBOPWindow.closeBOPWindow(); + localTCComponentBOPWindow = null; + } + } + if (localTCComponentBOPWindow != null) + { + localTCComponentBOPWindow.closeBOPWindow(); + localTCComponentBOPWindow = null; + } + } + private void setTableValue(TCComponentBOMLine topBopline) { + // TODO Auto-generated method stub + + + try { + AIFComponentContext[] children = topBopline.getChildren(); +// children + for(AIFComponentContext context : children) { + + + TCComponentBOMLine component = (TCComponentBOMLine) context.getComponent(); + TCComponentItemRevision itemRevision = component.getItemRevision(); + TCComponentItem item = itemRevision.getItem(); + if(item.getType().equals("HS2_MEOP")) { + + TCComponent[] changes = hs2ChangeList.get(0); +// changes[0].sav + if(changes!=null && changes.length>0) { +// itemRevision.getTCProperty("hs2_Change").setReferenceValueArray(changes); + + String[] propName = new String[] {"hs2_DateChange","hs2_Changereason","hs2_Changetimes"}; + assignmentTable(changes,itemRevision,propName,"HS2_ChangeLine","hs2_Change"); + + } + hs2ChangeList.remove(0); + + TCComponent[] controls = hs2ProcessControlList.get(0); + if(controls!=null && controls.length>=1) { +// itemRevision.getTCProperty("hs2_ProcessControl").setReferenceValueArray(controls); + + String[] propName = new String[] {"hs2_Characteristic","hs2_Controlitems", "hs2_Controlmethod", + "hs2_Controlstandards","hs2_Frequency","hs2_Inspectionmethod","hs2_Number"}; + assignmentTable(controls,itemRevision,propName,"HS2_ProcessControlLine","hs2_ProcessControl"); + + } + hs2ProcessControlList.remove(0); + + }else if(item.getType().equals("HS2_Step")) { + TCComponent[] changes = hs2ImportantList.get(0); + if(changes!=null && changes.length>=1) { +// itemRevision.getTCProperty("hs2_Important").setReferenceValueArray(changes); + + String[] propName = new String[] {"hs2_Stress","hs2_Stressreason"}; + assignmentTable(changes,itemRevision,propName,"HS2_ImportantLine","hs2_Important"); + + } + hs2ImportantList.remove(0); + } + + setTableValue(component); + + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + + public void assignmentTable(TCComponent[] ry , TCComponent item, String[] propNames, String boName, String prop) { + try { +// AttachmentsView.this.getViewer().setInput(null); + System.out.println("设置"+prop+"的值"); + List c = new ArrayList(); + DataManagementService service = DataManagementService + .getService((TCSession) AIFUtility.getCurrentApplication().getSession()); + CreateIn[] newIn = new CreateIn[ry.length]; + for (int i = 0; i < ry.length ; ++i) { + CreateIn in = new CreateIn(); + Map propMap = new HashMap(); + for(String propName:propNames) { + propMap.put(propName, ry[i].getStringProperty(propName)); + } +// propMap.put(propNames[0], (ry.get(i)).getSerialNub()+""); +// propMap.put(propNames[1], (ry.get(i)).getChangeNub()); +// propMap.put(propNames[2], (ry.get(i)).getChangeName()); + in.data.boName = boName; + in.data.stringProps = propMap; + newIn[i] = in; + } + + CreateResponse response = service.createObjects(newIn); +// response. + if(response.serviceData.sizeOfPartialErrors()> 0) { + + System.out.println(response.serviceData.getPartialError(0).getMessages()[0]); + + } + if (response.serviceData.sizeOfCreatedObjects() > 0) { +// int length = response.serviceData.sizeOfCreatedObjects(); +// int sizeOfCreatedObjects = response.serviceData.sizeOfCreatedObjects(); +// System.out.println("create + "+sizeOfCreatedObjects); + int length = response.output.length; + for (int i = 0; i < length; ++i) { + c.add(response.output[i].objects[0]); + } + } + item.getTCProperty(prop).setReferenceValueArray((TCComponent[]) c.toArray(new TCComponent[c.size()])); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + +private List hs2ChangeList = new ArrayList(); + private List hs2ProcessControlList = new ArrayList(); + private List hs2ImportantList = new ArrayList(); + private void getTableValue(TCComponentBOMLine topBOMLine) { + // TODO Auto-generated method stub + + + try { + AIFComponentContext[] children = topBOMLine.getChildren(); + for(AIFComponentContext context : children) { + + TCComponentBOMLine component = (TCComponentBOMLine) context.getComponent(); + TCComponentItemRevision itemRevision = component.getItemRevision(); + TCComponentItem item = itemRevision.getItem(); + if(item.getType().equals("HS2_MEOP")) { + System.out.println("工序 === >hs2_Change hs2_ProcessControl " ); + TCComponent[] change = itemRevision.getReferenceListProperty("hs2_Change"); + TCComponent[] processControl = itemRevision.getReferenceListProperty("hs2_ProcessControl"); + if(change.length==0 ){ + hs2ChangeList.add(null); + }else { + hs2ChangeList.add(change); + } + if(processControl.length==0){ + hs2ProcessControlList.add(null); + }else { + hs2ProcessControlList.add(processControl); + } + }else if(item.getType().equals("HS2_Step")) { + System.out.println("工步 === > hs2_Important" ); + + TCComponent[] important = itemRevision.getReferenceListProperty("hs2_Important"); + if(important.length==0 ){ + hs2ImportantList.add(null); + }else { + hs2ImportantList.add(important); + } + } + + getTableValue(component); + + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +private TCComponentItem getTemplateItem(Registry paramRegistry) + { + TCComponentItem localTCComponentItem = null; + try + { + TCComponentQueryType localTCComponentQueryType = (TCComponentQueryType)getSession().getTypeComponent("ImanQuery"); + TCTextService localTCTextService = getSession().getTextService(); + String str = localTCTextService.getTextValue("k_find_component_name"); + TCComponentQuery localTCComponentQuery = (TCComponentQuery)localTCComponentQueryType.find("Item - simple"); + if (localTCComponentQuery == null) { + localTCComponentQuery = (TCComponentQuery)localTCComponentQueryType.find(str); + } + String[] arrayOfString1 = { localTCTextService.getTextValue("ItemID") }; + String[] arrayOfString2 = { this.templateId }; + TCComponentContextList localTCComponentContextList = localTCComponentQuery.getExecuteResultsList(arrayOfString1, arrayOfString2); + TCComponent[] arrayOfTCComponent = localTCComponentContextList.toTCComponentArray(); + if ((arrayOfTCComponent.length > 1) && (!this.templateUID.equalsIgnoreCase(""))) { + arrayOfTCComponent = selectItemUsingItemUID(arrayOfTCComponent); + } + if ((arrayOfTCComponent != null) && (arrayOfTCComponent.length > 0) && (arrayOfTCComponent[0] != null) && ((arrayOfTCComponent[0] instanceof TCComponentItem))) + { + if ((this.itsAPlan) && (!(arrayOfTCComponent[0] instanceof TCComponentMEProcess))) + { + MessageBox.post(paramRegistry.getString("newMEProcessTemplates.notAProcess"), paramRegistry.getString("newMEProcessTemplates.newFailedTitle"), 1); + this.successFlag = false; + } + else if ((!this.itsAPlan) && (!(arrayOfTCComponent[0] instanceof TCComponentMEOP))) + { + MessageBox.post(paramRegistry.getString("newMEProcessTemplates.notAnOp"), paramRegistry.getString("newMEProcessTemplates.newFailedTitle"), 1); + this.successFlag = false; + } + else if ((this.itsAPlan) && (!TCUtilities.isAllowedToCreate(arrayOfTCComponent[0], "MEProcess"))) + { + MessageBox.post(paramRegistry.getString("newMEProductTemplates.roleProhibitCreate") + " " + arrayOfTCComponent[0].getSubType(), paramRegistry.getString("failToCreateTitle"), 4); + this.successFlag = false; + } + else if ((!this.itsAPlan) && (!TCUtilities.isAllowedToCreate(arrayOfTCComponent[0], "MEOP"))) + { + MessageBox.post(paramRegistry.getString("newMEProductTemplates.roleProhibitCreate") + " " + arrayOfTCComponent[0].getSubType(), paramRegistry.getString("failToCreateTitle"), 4); + this.successFlag = false; + } + } + else + { + MessageBox.post(paramRegistry.getString("newMEProcessTemplates.badId") + " " + this.templateId, paramRegistry.getString("newMEProcessTemplates.newFailedTitle"), 1); + this.successFlag = false; + } + if (this.templateRevRule == null) { + try + { + TCComponentRevisionRuleType localTCComponentRevisionRuleType = (TCComponentRevisionRuleType)getSession().getTypeComponent("RevisionRule"); + this.templateRevRule = localTCComponentRevisionRuleType.getDefaultRule(); + } + catch (TCException localTCException) + { + MessageBox.post(paramRegistry.getString("newMEProcessTemplates.noRevRule"), paramRegistry.getString("newMEProcessTemplates.newFailedTitle"), 1); + this.successFlag = false; + } + } + if (this.templateRevRule == null) + { + MessageBox.post(paramRegistry.getString("newMEProcessTemplates.noRevRule"), paramRegistry.getString("newMEProcessTemplates.newFailedTitle"), 1); + this.successFlag = false; + } + if (this.successFlag) { + localTCComponentItem = (TCComponentItem)arrayOfTCComponent[0]; + } + } + catch (Exception localException) + { + MessageBox.post(localException); + this.successFlag = false; + } + return localTCComponentItem; + } + + private void addCompToPasteData() + { + Object localObject; + if (this.dataToPaste == null) + { + this.dataToPaste = new ArrayList(); + if (this.pasteTargets != null) + { + InterfaceAIFComponent[] arrayOfInterfaceAIFComponent; + int j = (arrayOfInterfaceAIFComponent = this.pasteTargets).length; + for (int i = 0; i < j; i++) + { + localObject = arrayOfInterfaceAIFComponent[i]; + MFGConnectData localMFGConnectData = new MFGConnectData((InterfaceAIFComponent)localObject, true); + localMFGConnectData.add(this.newMEProcess, null); + this.dataToPaste.add(localMFGConnectData); + } + } + else + { + localObject = new MFGConnectData(null, true); + ((MFGConnectData)localObject).add(this.newMEProcess, null); + this.dataToPaste.add((MFGConnectData)localObject); + } + } + else + { + Iterator localIterator = this.dataToPaste.iterator(); + while (localIterator.hasNext()) + { + localObject = (MFGConnectData)localIterator.next(); + ((MFGConnectData)localObject).add(this.newMEProcess, null); + } + } + } + + protected void pasteNewComponent(Registry paramRegistry) + throws Exception + { + Object localObject1; + Object localObject3; + Object localObject2; + if (((MFGConnectData)this.dataToPaste.get(0)).getTarget() == null) + { + localObject1 = new ArrayList(); + localObject3 = this.dataToPaste.iterator(); + while (((Iterator)localObject3).hasNext()) + { + localObject2 = (MFGConnectData)((Iterator)localObject3).next(); + AIFComponentContext[] arrayOfAIFComponentContext1 = ((MFGConnectData)localObject2).getContextsArray(); + AIFComponentContext[] arrayOfAIFComponentContext2; + int k = (arrayOfAIFComponentContext2 = arrayOfAIFComponentContext1).length; + for (int j = 0; j < k; j++) + { + AIFComponentContext localAIFComponentContext = arrayOfAIFComponentContext2[j]; + ((List)localObject1).add((TCComponent)localAIFComponentContext.getComponent()); + } + } + ConnectUtil.pasteToTargetAccordingToPreference(getSession(), (TCComponent[])((List)localObject1).toArray(new TCComponent[((List)localObject1).size()])); + } + else + { + localObject1 = new MfgConnectOperation(this.dataToPaste); + ((MfgConnectOperation)localObject1).runEx(); + if (((MfgConnectOperation)localObject1).isOperationDone()) + { + localObject2 = (TCComponent[])((MfgConnectOperation)localObject1).getOperationResult(); + if ((localObject2 != null) && (((TCComponent[])localObject2).length > 0) && ((((TCComponent[])localObject2)[0] instanceof TCComponentBOMLine))) + { + localObject3 = new ArrayList(); + for (int i = 0; i < ((TCComponent[])localObject2).length; i++) { + ((List)localObject3).add((TCComponentBOMLine)((TCComponent[])localObject2)[i]); + } + ClientEventDispatcher.fireEventLater(this, "com/teamcenter/rac/cme/ItemCreated", new Object[] { "bomLine", ((TCComponent[])localObject2)[0], "newComponent", localObject3, "recursive", "true", "categoryId", ApplicationPerspectiveUtil.getCurrentApplicationId() }); + } + } + } + } + + private TCComponent[] selectItemUsingItemUID(TCComponent[] paramArrayOfTCComponent) + { + for (int i = 0; i < paramArrayOfTCComponent.length; i++) { + if ((this.templateUID.equalsIgnoreCase(paramArrayOfTCComponent[i].getUid())) && (i != 0)) + { + TCComponent localTCComponent = paramArrayOfTCComponent[0]; + paramArrayOfTCComponent[0] = paramArrayOfTCComponent[i]; + paramArrayOfTCComponent[i] = localTCComponent; + } + } + return paramArrayOfTCComponent; + } +} diff --git a/src/sql.properties b/src/sql.properties new file mode 100644 index 0000000..9bfa4bd --- /dev/null +++ b/src/sql.properties @@ -0,0 +1,38 @@ +SETPFMEASELECT=SELECT * FROM AHMC_PFMEA WHERE PROCESSPUID = \'%s\' AND REVISIONID=\'%s\' ORDER BY to_number(NO),to_number(HH) +PFMEALIBRARYSELECT2=SELECT * FROM AHMC_PFMEALIBRARY WHERE PUID = \'%s\' order by HHC + +BOMCHECKSAVESELECTPFMEA=select MEOPID,station,gybh,GCMC from AHMC_PFMEA where PROCESSPUID = \'%s\' AND REVISIONID=\'%s\' + +BOMCHECKSAVESELECTPFMEA2=select * from AHMC_PFMEA where PROCESSPUID = \'%s\' and MEOPID not in %s + +DELETEPFMEA=delete from AHMC_PFMEA where MEOPID = \'%s\' and PROCESSPUID = \'%s\' + +INSERTPFMEA=INSERT INTO AHMC_PFMEA VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) +# order BY ID +PFMEALIBRARYSELECT=SELECT * FROM AHMC_PFMEA_NODE WHERE PARENT_ID = \'%s\' ORDER BY to_number(ROWNUMD) asc +SETPFMEASELECT2=SELECT MEOPID,REQUIREMENT from AHMC_PFMEA where PROCESSPUID = \'%s\' group by MEOPID,REQUIREMENT +SETPFMEADELETE=delete from AHMC_PFMEA where PLMEID = \'%s\' + +SETPFMEAUPDATE=update AHMC_PFMEA set GYBH = ?,GCMC = ?,STATION = ?,REQUIREMENT = ?,QZSXMS = ?,QZSXHG = ?,YZD = ?,JB = ?,QZSXQY = ?,XXGCKZYF = ?,PDS = ?,XXGCKZTC = ?,TCD = ?,RPN = ?,JYCS = ?,ZZR = ?,JHWCRQ = ?,CQDCS = ?,NEW_SEV = ?,NEW_OCC = ?,NEW_DET = ?,NEW_RPN = ?,IDEAL_STATE = ?,SPECIAL = ?,HH = ?,HBDYG = ? ,OCCURRRENCE = ?,DETECTION = ?,PRIORITY = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ? where plmeid = \'%s\' AND revisionid=\'%s\' +TM2PFMEATREESELECT=select * from AHMC_PFMEA_TREE ORDER BY PARENT_ID,ID + +CONTROLPLANLIBRARYSELECT=SELECT * FROM AHMC_CONTROLPLAN_NODE WHERE PARENT_ID = \'%s\' order BY ID + +TM2CONTROLPLANTREESELECT=select * from AHMC_CONTROLPLAN_TREE ORDER BY TO_NUMBER(PARENT_ID) + +TM2THESAURUSTREESELECT=select * from AHMC_THESAURUS_TREE ORDER BY TO_NUMBER(PARENT_ID) + +TM2THESAURUSNODESELECT=SELECT * FROM AHMC_THESAURUS_NODE WHERE PARENT_ID = \'%s\' order BY ID + +PFMEALIBRARYUPDATE=update AHMC_PFMEA_NODE set ID = ?,LSBG =?, STATION = ?,REQUIREMENT = ?,QZSXMS = ?,QZSXHG = ?,YZD = ?,JB = ?,QZSXQY = ?,XXGCKZYF = ?,PDS = ?,XXGCKZTC = ?,TCD = ?,RPN = ?,JYCS = ?,ZZR = ?,JHWCRQ = ?,CQDCS = ?,NEW_SEV = ?,NEW_OCC = ?,NEW_DET = ?,NEW_RPN = ?,IDEAL_STATE = ?,SPECIAL = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ?,P6 = ?,P7 = ?,P8 = ? , HBDYG=?, ROWNUMD=? where plmeid = \'%s\' + +PFMEALIBRARYDELETE=delete from AHMC_PFMEA_NODE where PLMEID = \'%s\' +PFMENODEDELETE=delete from AHMC_PFMEA_TREE where PARENT_ID = \'%s\' +PFMEALIBRARYINSERT=INSERT INTO AHMC_PFMEA_NODE VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + + + +SELECTFRAMESIZE=select * from AHMC_PFMEAFRAME_SIZE WHERE USERNAME = \'%s\' AND TYPE = \'%s\' +FRAMESIZEINSERT=INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?) +FRAMESIZEDELETE=DELETE FROM AHMC_PFMEAFRAME_SIZE WHERE USERNAME = \'%s\' AND TYPE = \'%s\' +FRAMESIZEUPDATE=update AHMC_PFMEAFRAME_SIZE set FRAMESIZE = ?, TABLE1SIZE = ?, TABLE2SIZE = ? WHERE USERNAME = \'%s\' AND TYPE = \'%s\' \ No newline at end of file